qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Detecting qemu from guest on arm/hvf (apple arm)


From: John-Mark Gurney
Subject: Re: Detecting qemu from guest on arm/hvf (apple arm)
Date: Mon, 20 Feb 2023 14:32:31 -0800
User-agent: Mutt/1.6.1 (2016-04-27)

Hello Peter,

btw, please keep me CC'd, as I'm not subscribed to the mailing list.

> I guess the question is, why do you want to know? Typically

The main reason is that FreeBSD (and other operating systems)
adjust some of the clock periods to be longer for better
effeciency.  When FreeBSD detects that it's a VM, is slows
down hz to 100 instead of 1000:
https://cgit.freebsd.org/src/tree/sys/kern/subr_param.c#n177

And in my case, if I didn't set hz to 100 manually, even an
idle machine would consume tons of host CPU, and on top of it
(I'm not sure why), it would run at a constant >1000 int/s,
compared to running hz at 100 where the int/s would drop to
around 50/s...

I'm not sure how good/bad the time counter is on ARM hardware
as I'm more familar w/ x86 time counter hardware, and I do know
that there's a large variety of quality of time counter hardware
and the expense to accessing it.

FreeBSD is using the ARM MPCore Timecounter, and it reports:
kern.timecounter.tc.ARM MPCore Timecounter.quality: 1000
kern.timecounter.tc.ARM MPCore Timecounter.frequency: 24000000
kern.timecounter.tc.ARM MPCore Timecounter.counter: 2182594876
kern.timecounter.tc.ARM MPCore Timecounter.mask: 4294967295

There isn't any other time counter hardware reported (except dummy,
but that isn't usable)...

FreeBSD has code to detect hyperv and xen, and detect VMWare through
SMBios.

> the guest OS shouldn't care about whether it's running
> on bare metal, under a hypervisor, or under emulated QEMU,
> except to the extent that it wants to use specific features,
> in which case the question is more "how do I query for the
> existence of feature X?".

Thanks for your help.
-- 
  John-Mark Gurney                              Voice: +1 415 225 5579

     "All that I will do, has been done, All that I have, has not."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]