Skip to contentSkip to conversation

x86/svm: work around Virtual VMLOAD/VMSAVE bug on Naples and Rome

PATCH Superseded Igor Mammedov 2 participants 5 messages May 15 – May 18 KVM

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 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 alocate the VMCB there.

Given that it's relative 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). And since test acts here as L1 it's not possible to fix issue in kernel (L0) anyway. Hence a quirk here, to prevent tests failures where we can't do anything about them.

---
CCed: AMD folks for awaraness and in case they would be willing to look into fixing issue on CPU side.

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 yeas

---
 x86/svm.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
x86/svm.c +22 -0
index a85da905..706ff2ef 100644
@@ -334,6 +334,21 @@ static void setup_npt(void)
 	__setup_mmu_range(pml4e, 0, size, X86_MMU_MAP_USER);
 }
 
+#define VLS_BUG_START	0x78000000ULL
+#define VLS_BUG_END	0x80000000ULL
+
+static bool has_vls_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 +428,13 @@ int run_svm_tests(int ac, char **av, struct svm_test *svm_tests)
 		return report_summary();
 	}
 
+	if (has_vls_bug()) {
+		phys_addr_t addr;
+
+		for (addr = VLS_BUG_START; addr < VLS_BUG_END; addr += PAGE_SIZE)
+			reserve_pages(addr, 1);
+	}
+
 	setup_svm();
 
 	vmcb = alloc_page();
Signature · 1 line
2.43.0
#1 lore raw
Quoted 14 lines · Igor Mammedov

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 alocate the VMCB there.

Given that it's relative 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). And since test acts here as L1 it's not possible to fix issue in kernel (L0) anyway. Hence a quirk here, to prevent tests failures where we can't do anything about them.

Quoted 4 lines

---
CCed: AMD folks for awaraness and in case they would be willing to look into fixing issue on CPU side.

LOL. Don't hold your breath. According to AMD, Zen4 erratum 1454 is a firmware issue.

https://lore.kernel.org/all/[email protected]

Quoted 12 lines

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 yeas

---
 x86/svm.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
x86/svm.c +0 -0
index a85da905..706ff2ef 100644

x86/svm.c static void setup_npt(void) · line 340

Quoted 7 lines
x86/svm.c +4 -0
@@ -334,6 +334,21 @@ static void setup_npt(void)
 	__setup_mmu_range(pml4e, 0, size, X86_MMU_MAP_USER);
 }
 
+#define VLS_BUG_START	0x78000000ULL
+#define VLS_BUG_END	0x80000000ULL
+
+static bool has_vls_bug(void)

Probably need to be more specific, because there appear to be multiple flavors of vls bugs. :-/

Quoted 31 lines
x86/svm.c +18 -0
+{
+	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 +428,13 @@ int run_svm_tests(int ac, char **av, struct svm_test *svm_tests)
 		return report_summary();
 	}
 
+	if (has_vls_bug()) {
+		phys_addr_t addr;
+
+		for (addr = VLS_BUG_START; addr < VLS_BUG_END; addr += PAGE_SIZE)
+			reserve_pages(addr, 1);
+	}
+
 	setup_svm();
 
 	vmcb = alloc_page();
Signature · 1 line
2.43.0
#2 lore raw
Quoted 20 lines · On Fri, 15 May 2026 05:44:37 -0700 Sean Christopherson <[email protected]>…
Quoted 14 lines · Igor Mammedov

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 alocate the VMCB there.

Given that it's relative 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). And since test acts here as L1 it's not possible to fix issue in kernel (L0) anyway. Hence a quirk here, to prevent tests failures where we can't do anything about them.

Quoted 4 lines

---
CCed: AMD folks for awaraness and in case they would be willing to look into fixing issue on CPU side.

Quoted 4 lines

LOL. Don't hold your breath. According to AMD, Zen4 erratum 1454 is a firmware issue.

https://lore.kernel.org/all/[email protected]

The might decide to nuke older server EPYCs, but until then ... I'll add a few folks from that thread on respin.

Quoted 16 lines
Quoted 16 lines

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 yeas

---
 x86/svm.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
x86/svm.c +0 -0
index a85da905..706ff2ef 100644
@@ -334,6 +334,21 @@ static void setup_npt(void)
 	__setup_mmu_range(pml4e, 0, size, X86_MMU_MAP_USER);
 }
 
Quoted 7 lines

x86/svm.c static void setup_npt(void) · line 340

Quoted 4 lines
x86/svm.c +4 -0
+#define VLS_BUG_START	0x78000000ULL
+#define VLS_BUG_END	0x80000000ULL
+
+static bool has_vls_bug(void)  

Probably need to be more specific, because there appear to be multiple flavors of vls bugs. :-/

would something like this work:

-static bool has_vls_bug(void)
+/*
+ * 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)

Quoted 32 lines
Quoted 31 lines
x86/svm.c +18 -0
+{
+	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 +428,13 @@ int run_svm_tests(int ac, char **av, struct svm_test *svm_tests)
 		return report_summary();
 	}
 
+	if (has_vls_bug()) {
+		phys_addr_t addr;
+
+		for (addr = VLS_BUG_START; addr < VLS_BUG_END; addr += PAGE_SIZE)
+			reserve_pages(addr, 1);
+	}
+
 	setup_svm();
 
 	vmcb = alloc_page();
Signature · 1 line
2.43.0
#3 lore raw
Quoted 10 lines · Igor Mammedov
Quoted 4 lines · On Fri, 15 May 2026 05:44:37 -0700 Sean Christopherson <[email protected]>…
Quoted 1 line

+static bool has_vls_bug(void)

Probably need to be more specific, because there appear to be multiple flavors of vls bugs. :-/

would something like this work:

Review

Quoted 6 lines
(quoted diff) +5 -1
-static bool has_vls_bug(void)
+/*
+ * 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)

Works for me. Any chance you have a specific erratum number that we could reference?

#4 lore raw
Quoted 11 lines · On Mon, 18 May 2026 07:30:14 -0700 Sean Christopherson <[email protected]>…
Quoted 10 lines · Igor Mammedov
Quoted 4 lines · On Fri, 15 May 2026 05:44:37 -0700 Sean Christopherson <[email protected]>…
Quoted 1 line

+static bool has_vls_bug(void)

Probably need to be more specific, because there appear to be multiple flavors of vls bugs. :-/

would something like this work:

Quoted 8 lines

Review

Quoted 6 lines
(quoted diff) +5 -1
-static bool has_vls_bug(void)
+/*
+ * 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)  

Works for me. Any chance you have a specific erratum number that we could reference?

I'll try to find it. That's also was a reason to cc AMD side, for they probably know better where/what to look for.

Quoted 1 line