Skip to content

Commit 511da98

Browse files
Yu Zhangbonzini
authored andcommitted
kvm: x86: Return LA57 feature based on hardware capability
Previously, 'commit 372fddf ("x86/mm: Introduce the 'no5lvl' kernel parameter")' cleared X86_FEATURE_LA57 in boot_cpu_data, if Linux chooses to not run in 5-level paging mode. Yet boot_cpu_data is queried by do_cpuid_ent() as the host capability later when creating vcpus, and Qemu will not be able to detect this feature and create VMs with LA57 feature. As discussed earlier, VMs can still benefit from extended linear address width, e.g. to enhance features like ASLR. So we would like to fix this, by return the true hardware capability when Qemu queries. Signed-off-by: Yu Zhang <yu.c.zhang@linux.intel.com> Cc: stable@vger.kernel.org Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent ad7dc69 commit 511da98

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

arch/x86/kvm/cpuid.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
335335
unsigned f_xsaves = kvm_x86_ops->xsaves_supported() ? F(XSAVES) : 0;
336336
unsigned f_umip = kvm_x86_ops->umip_emulated() ? F(UMIP) : 0;
337337
unsigned f_intel_pt = kvm_x86_ops->pt_supported() ? F(INTEL_PT) : 0;
338+
unsigned f_la57 = 0;
338339

339340
/* cpuid 1.edx */
340341
const u32 kvm_cpuid_1_edx_x86_features =
@@ -489,7 +490,10 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
489490
// TSC_ADJUST is emulated
490491
entry->ebx |= F(TSC_ADJUST);
491492
entry->ecx &= kvm_cpuid_7_0_ecx_x86_features;
493+
f_la57 = entry->ecx & F(LA57);
492494
cpuid_mask(&entry->ecx, CPUID_7_ECX);
495+
/* Set LA57 based on hardware capability. */
496+
entry->ecx |= f_la57;
493497
entry->ecx |= f_umip;
494498
/* PKU is not yet implemented for shadow paging. */
495499
if (!tdp_enabled || !boot_cpu_has(X86_FEATURE_OSPKE))

0 commit comments

Comments
 (0)