Skip to contentSkip to conversation

x86: svm: Skip NPT-only part of guest CR3 tests when NPT is disabled

PATCH Applied Sean Christopherson 2 participants 3 messages Apr 22, 2021 – Jun 23, 2021 KVM

lore
Share & tools
lore

Sean Christopherson

author reviewer
#0 lore raw

PATCH 1/1 x86: svm: Skip NPT-only part of guest CR3 tests when NPT is disabled

Skip the sub-tests for guest CR3 that rely on NPT, unsurprisingly they fail when running with NPT disabled. Alternatively, the test could be modified to poke into the legacy page tables, but obviously no one actually cares that much about shadow paging.

Fixes 6d0ecbf ("nSVM: Test non-MBZ reserved bits in CR3 in long mode and legacy PAE mode")
---
 x86/svm_tests.c | 5 +++++
 1 file changed, 5 insertions(+)
x86/svm_tests.c +5 -0
index 29a0b59..353ab6b 100644
@@ -2237,6 +2237,9 @@ static void test_cr3(void)
 
 	vmcb->save.cr4 = cr4_saved & ~X86_CR4_PCIDE;
 
+	if (!npt_supported())
+		goto skip_npt_only;
+
 	/* Clear P (Present) bit in NPT in order to trigger #NPF */
 	pdpe[0] &= ~1ULL;
 
@@ -2255,6 +2258,8 @@ static void test_cr3(void)
 	    SVM_CR3_PAE_LEGACY_RESERVED_MASK, SVM_EXIT_NPF, "(PAE) ");
 
 	pdpe[0] |= 1ULL;
+
+skip_npt_only:
 	vmcb->save.cr3 = cr3_saved;
 	vmcb->save.cr4 = cr4_saved;
 }
Signature · 1 line
2.31.1.498.g6c1eba8ee3d-goog
author reviewer
#1 lore raw
Quoted 7 lines · Sean Christopherson

Skip the sub-tests for guest CR3 that rely on NPT, unsurprisingly they fail when running with NPT disabled. Alternatively, the test could be modified to poke into the legacy page tables, but obviously no one actually cares that much about shadow paging.

Fixes 6d0ecbf ("nSVM: Test non-MBZ reserved bits in CR3 in long mode and legacy PAE mode")

Ping! Doesn't look like this ever got merged.

Quoted 30 lines
---
 x86/svm_tests.c | 5 +++++
 1 file changed, 5 insertions(+)
x86/svm_tests.c +5 -0
index 29a0b59..353ab6b 100644
@@ -2237,6 +2237,9 @@ static void test_cr3(void)
 
 	vmcb->save.cr4 = cr4_saved & ~X86_CR4_PCIDE;
 
+	if (!npt_supported())
+		goto skip_npt_only;
+
 	/* Clear P (Present) bit in NPT in order to trigger #NPF */
 	pdpe[0] &= ~1ULL;
 
@@ -2255,6 +2258,8 @@ static void test_cr3(void)
 	    SVM_CR3_PAE_LEGACY_RESERVED_MASK, SVM_EXIT_NPF, "(PAE) ");
 
 	pdpe[0] |= 1ULL;
+
+skip_npt_only:
 	vmcb->save.cr3 = cr3_saved;
 	vmcb->save.cr4 = cr4_saved;
 }
Signature · 1 line
2.31.1.498.g6c1eba8ee3d-goog
maintainer Applied
#2 lore raw
In reply to Sean Christopherson
Quoted 27 lines · Sean Christopherson

Skip the sub-tests for guest CR3 that rely on NPT, unsurprisingly they fail when running with NPT disabled. Alternatively, the test could be modified to poke into the legacy page tables, but obviously no one actually cares that much about shadow paging.

Fixes 6d0ecbf ("nSVM: Test non-MBZ reserved bits in CR3 in long mode and legacy PAE mode")
---
  x86/svm_tests.c | 5 +++++
  1 file changed, 5 insertions(+)
x86/svm_tests.c +3 -0
index 29a0b59..353ab6b 100644
@@ -2237,6 +2237,9 @@ static void test_cr3(void)
 
  	vmcb->save.cr4 = cr4_saved & ~X86_CR4_PCIDE;
 
+	if (!npt_supported())
+		goto skip_npt_only;
+
  	/* Clear P (Present) bit in NPT in order to trigger #NPF */
  	pdpe[0] &= ~1ULL;
 

x86/svm_tests.c static void test_cr3(void) · line 2265

Quoted 8 lines
x86/svm_tests.c +2 -0
@@ -2255,6 +2258,8 @@ static void test_cr3(void)
  	    SVM_CR3_PAE_LEGACY_RESERVED_MASK, SVM_EXIT_NPF, "(PAE) ");
 
  	pdpe[0] |= 1ULL;
+
+skip_npt_only:
  	vmcb->save.cr3 = cr3_saved;
  	vmcb->save.cr4 = cr4_saved;
  }

Queued now, thanks!

Paolo