Skip to contentSkip to conversation

x86: VMX: INVEPT after modifying PA mapping in ept_untwiddle

PATCH Applied Oliver Upton 2 participants 2 messages Aug 28, 2019 – Sep 11, 2019 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: VMX: INVEPT after modifying PA mapping in ept_untwiddle

ept_untwiddle modifies a PA mapping in the EPT paging structure. According to the SDM 28.3.3.4, "Software should use the INVEPT instruction with the "single-context" INVEPT type after making any of the following changes to an EPT paging-structure entry ... Changing the physical address in bits 51:12".

---
 x86/vmx_tests.c | 1 +
 1 file changed, 1 insertion(+)
x86/vmx_tests.c +1 -0
index 8ad26741277f..94be937da41d 100644
@@ -2376,6 +2376,7 @@ static unsigned long ept_twiddle(unsigned long gpa, bool mkhuge, int level,
 static void ept_untwiddle(unsigned long gpa, int level, unsigned long orig_pte)
 {
 	set_ept_pte(pml4, gpa, level, orig_pte);
+	ept_sync(INVEPT_SINGLE, eptp);
 }
 
 static void do_ept_violation(bool leaf, enum ept_access_op op,
Signature · 1 line
2.23.0.187.g17f5b7556c-goog
maintainer Applied
#1 lore raw
Quoted 18 lines · Oliver Upton

ept_untwiddle modifies a PA mapping in the EPT paging structure. According to the SDM 28.3.3.4, "Software should use the INVEPT instruction with the "single-context" INVEPT type after making any of the following changes to an EPT paging-structure entry ... Changing the physical address in bits 51:12".

---
 x86/vmx_tests.c | 1 +
 1 file changed, 1 insertion(+)
x86/vmx_tests.c +0 -0
index 8ad26741277f..94be937da41d 100644

x86/vmx_tests.c static unsigned long ept_twiddle(unsigned long gpa, bool mkhuge, int level, · line 2382

Quoted 7 lines
x86/vmx_tests.c +1 -0
@@ -2376,6 +2376,7 @@ static unsigned long ept_twiddle(unsigned long gpa, bool mkhuge, int level,
 static void ept_untwiddle(unsigned long gpa, int level, unsigned long orig_pte)
 {
 	set_ept_pte(pml4, gpa, level, orig_pte);
+	ept_sync(INVEPT_SINGLE, eptp);
 }
 
 static void do_ept_violation(bool leaf, enum ept_access_op op,

Queued, thanks.

Paolo