Re: [PATCH 1/3] kvm: wire up KVM_CAP_VM_GPA_BITS for x86

From: Tao Su
Date: Mon Mar 04 2024 - 04:02:39 EST


On Mon, Mar 04, 2024 at 09:43:53AM +0100, Gerd Hoffmann wrote:
> > > + kvm_caps.guest_phys_bits = boot_cpu_data.x86_phys_bits;
> >
> > When KeyID_bits is non-zero, MAXPHYADDR != boot_cpu_data.x86_phys_bits
> > here, you can check in detect_tme().
>
> from detect_tme():
>
> /*
> * KeyID bits effectively lower the number of physical address
> * bits. Update cpuinfo_x86::x86_phys_bits accordingly.
> */
> c->x86_phys_bits -= keyid_bits;
>
> This looks like x86_phys_bits gets adjusted if needed.

If TDP is enabled and supports 5-level, we want kvm_caps.guest_phys_bits=52,
but c->x86_phys_bits!=52 here. Maybe we need to set kvm_caps.guest_phys_bits
according to whether TDP is enabled or not, like leaf 0x80000008 in
__do_cpuid_func().

Thanks,
Tao