Skip to contentSkip to conversation

x86: Reload SS when switching to 5-level page tables

PATCH New Sean Christopherson 1 participant 1 message Mar 10, 2020 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: Reload SS when switching to 5-level page tables

Load SS with a valid segment when switching to 5-level page tables to avoid taking a #SS due to a NULL segment when making a CALL with paging disabled.

The "access" test calls setup_5level_page_table()/switch_to_5level() after generating and handling usermode exceptions. Per Intel's SDM, SS is nullified on an exception that changes CPL:

The new SS is set to NULL if there is a change in CPL.

---
 x86/cstart64.S | 3 +++
 1 file changed, 3 insertions(+)
x86/cstart64.S +3 -0
index 6c1c87d..cffbb07 100644
@@ -159,6 +159,9 @@ switch_to_5level:
 	bts $12, %eax
 	mov %eax, %cr4
 
+	mov $0x10, %ax
+	mov %ax, %ss
+
 	call enter_long_mode
 	jmpl $8, $lvl5
 
Signature · 1 line
2.24.1