Skip to contentSkip to conversation

x86: Fix wrong test for 5-level page-table

PATCH Superseded Nadav Amit 2 participants 4 messages Apr 11, 2019 KVM

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Nadav Amit

author
#0 lore raw

PATCH 1/1 x86: Fix wrong test for 5-level page-table

Untested, but clearly bit 12 is the one that needs to be tested.

---
 x86/cstart64.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
x86/cstart64.S +1 -1
index 21db10f..8626f02 100644
@@ -243,7 +243,7 @@ start64:
 setup_5level_page_table:
 	/* Check if 5-level paging has already enabled */
 	mov %cr4, %rax
-	test $12, %eax
+	bt $12, %eax
 	jnz lvl5
 
 	pushq $32
Signature · 1 line
2.17.1
#1 lore raw
Quoted 12 lines · Nadav Amit

Untested, but clearly bit 12 is the one that needs to be tested.

---
 x86/cstart64.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
x86/cstart64.S +0 -0
index 21db10f..8626f02 100644

x86/cstart64.S start64: · line 247

Quoted 6 lines
x86/cstart64.S +1 -1
@@ -243,7 +243,7 @@ start64:
 setup_5level_page_table:
 	/* Check if 5-level paging has already enabled */
 	mov %cr4, %rax
-	test $12, %eax
+	bt $12, %eax
 	jnz lvl5

Unfortunately BT doesn't affect RFLAGS.ZF, so 'jnz' needs to be changed to 'jc'. Or alternatively, do 'test $1000, %eax'.

Quoted 5 lines
x86/cstart64.S +0 -0
 	pushq $32
Signature · 1 line
2.17.1
#2 lore raw
Quoted 8 lines · Sean Christopherson
Quoted 7 lines · Nadav Amit

Untested, but clearly bit 12 is the one that needs to be tested.

---
 x86/cstart64.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 14 lines

x86/cstart64.S start64: · line 247

Quoted 11 lines
x86/cstart64.S +1 -1
index 21db10f..8626f02 100644
@@ -243,7 +243,7 @@ start64:
 setup_5level_page_table:
 	/* Check if 5-level paging has already enabled */
 	mov %cr4, %rax
-	test $12, %eax
+	bt $12, %eax
 	jnz lvl5

Unfortunately BT doesn't affect RFLAGS.ZF, so 'jnz' needs to be changed to 'jc'. Or alternatively, do 'test $1000, %eax'.

And of course that should be $0x1000...

author
#3 lore raw
In reply to Sean Christopherson
Quoted 10 lines · Sean Christopherson
Quoted 7 lines · Nadav Amit

Untested, but clearly bit 12 is the one that needs to be tested.

---
x86/cstart64.S | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 14 lines
Quoted 11 lines
x86/cstart64.S +0 -0
index 21db10f..8626f02 100644
@@ -243,7 +243,7 @@ start64:

setup_5level_page_table:

	/* Check if 5-level paging has already enabled */
	mov %cr4, %rax
x86/cstart64.S +1 -1
-	test $12, %eax
+	bt $12, %eax

jnz lvl5

Unfortunately BT doesn't affect RFLAGS.ZF, so 'jnz' needs to be changed to 'jc'. Or alternatively, do 'test $1000, %eax'.

Of course. Stupid me, but it’s not worse than it was before ;-)

I’ll send a revised version. Thanks.