Re: [PATCH v3 2/2] kvm/cpuid: set proper GuestPhysBits in CPUID.0x80000008

From: Gerd Hoffmann
Date: Wed Mar 13 2024 - 04:38:41 EST


Hi,

> > > - entry->eax = phys_as | (virt_as << 8);
> > > + entry->eax = phys_as | (virt_as << 8) | (g_phys_as << 16);
> >
> > When g_phys_as==phys_as, I would suggest advertising g_phys_as==0,
> > otherwise application can easily know whether it is in a VM, I’m
> > concerned this could be abused by application.

There are *tons* of options to figure whenever you are running in a VM,
there is no need to go for this obscure way.

> IMO, this should be protected by userspace VMM, e.g., QEMU to set actual
> g_phys_as. On KVM side, KVM only reports the capability to userspace.

Yes, at the end of the day this is handled by qemu.

Current plan for qemu is to communicate it to the guest unconditionally
though. When setting this only in case g_phys_as != phys_as the
firmware has the problem that it doesn't know the reason for finding
zero there. Could be g_phys_as == phys_as, but could also be old kernel
/ qemu without GuestPhysBits support. So the firmware doesn't know
whenever it is save to use phys_as.

take care,
Gerd