x86/svm: work around Virtual VMLOAD/VMSAVE bug on Naples and Rome
PATCH v2 1/1 x86/svm: work around Virtual VMLOAD/VMSAVE bug on Naples and Rome
AMD Family 17h models 0x00-0x0f (Naples/Zen+) and 0x30-0x3f (Rome/Zen2) have a hardware bug where Virtual VMLOAD/VMSAVE causes spurious VMEXITs on VMLOAD/VMSAVE even with intercepts disabled, when the VMCB physical address as seen by L1 falls in [0x78000000, 0x80000000) range. Reserve this range on affected CPUs so the page allocator would never allocate the VMCB there.
Given that it's relatively old CPUs + nested env + only performance impact, it's not worth fixing on KVM side (which could involve messing with allocator or reallocating VMCB, until it's not in affected range). Hence a quirk here, to prevent tests failures where we can't do anything about them.
---
there is not official EOL dates on both, but using a newer generation(s) release dates it appears that both are effectively discontinued for ~3-5 years
v2:
* Sean Christopherson <[email protected]>
- s/has_vls_bug/has_vls_spurious_vmexit_bug/
--- x86/svm.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
x86/svm.c +26 -0
@@ -334,6 +334,25 @@ static void setup_npt(void)__setup_mmu_range (pml4e,0 , size,X86_MMU_MAP_USER ); } +#define VLS_SPURIOUS_VMEXIT_START 0x78000000ULL +#define VLS_SPURIOUS_VMEXIT_END 0x80000000ULL + +/* +* Naples (Fam17h/00-0f) and Rome (Fam17h/30-3f) cause spurious VMEXITs +* on VMLOAD/VMSAVE when the VMCB address falls in [0x78000000, 0x80000000). +*/ +static bool has_vls_spurious_vmexit_bug (void ) +{ +u32 sig =cpuid (1 ).a; +u32 fam =x86_family (sig); +u32 model =x86_model (sig); + +if (fam !=0x17 ) +return false; + +return model <=0x0f || (model >=0x30 && model <=0x3f ); +} +static void setup_svm (void ) {void *hsave =alloc_page ();
@@ -413,6 +432,13 @@ int run_svm_tests(int ac, char **av, struct svm_test *svm_tests)return report_summary (); } +if (has_vls_spurious_vmexit_bug ()) { +phys_addr_t addr; + +for (addr =VLS_SPURIOUS_VMEXIT_START ; addr <VLS_SPURIOUS_VMEXIT_END ; addr +=PAGE_SIZE ) +reserve_pages (addr,1 ); + } +setup_svm (); vmcb =alloc_page ();
Signature · 1 line
2.43.0