Re: git: 2fee87562948 - main - abstract out the vm detection via smbios..

From: Kyle Evans <kevans_at_freebsd.org>
Date: Thu, 16 Mar 2023 04:15:56 UTC
On Thu, Mar 2, 2023 at 6:55 PM John-Mark Gurney <jmg@freebsd.org> wrote:
>
> The branch main has been updated by jmg:
>
> URL: https://cgit.FreeBSD.org/src/commit/?id=2fee8756294820ff9ec6f8d17324e7d8a0a45040
>
> commit 2fee8756294820ff9ec6f8d17324e7d8a0a45040
> Author:     John-Mark Gurney <jmg@FreeBSD.org>
> AuthorDate: 2023-02-23 20:59:50 +0000
> Commit:     John-Mark Gurney <jmg@FreeBSD.org>
> CommitDate: 2023-03-03 00:54:21 +0000
>
>     abstract out the vm detection via smbios..
>
>     This makes the detection of VMs common between platforms that
>     have SMBios.
>
>     Reviewed by:            imp, kib
>     Differential Revision:  https://reviews.freebsd.org/D38800
> ---
>  sys/amd64/amd64/machdep.c    |   3 ++
>  sys/arm64/arm64/machdep.c    |   4 ++
>  sys/conf/files.arm64         |   2 +
>  sys/conf/files.x86           |   1 +
>  sys/dev/smbios/smbios.h      |   4 ++
>  sys/dev/smbios/smbios_subr.c | 104 +++++++++++++++++++++++++++++++++++++++++++
>  sys/i386/i386/machdep.c      |   3 ++
>  sys/x86/x86/identcpu.c       |  57 ------------------------
>  8 files changed, 121 insertions(+), 57 deletions(-)
>
> diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c
> index f33f2c6509f0..480db1ed2c31 100644
> --- a/sys/amd64/amd64/machdep.c
> +++ b/sys/amd64/amd64/machdep.c
> [... snip ...]
> @@ -1315,6 +1317,7 @@ hammer_time(u_int64_t modulep, u_int64_t physfree)
>
>         identify_cpu1();
>         identify_hypervisor();
> +       identify_hypervisor_smbios();
>         identify_cpu_fixup_bsp();
>         identify_cpu2();
>         initializecpucache();

This brings in a behavior change that I don't think you intended.
Previously, we wouldn't let smbios clobber a vm_guest detected from
cpuid due to an early return, but nothing is stopping it from
happening now. I think this call should've been protected behind a
`vm_guest == VM_GUEST_NO || vm_guest == VM_GUEST_VM` (the latter being
"CPUID2_HV was set but we couldn't determine anything useful after
that"), perhaps?

Thanks,

Kyle Evans