Skip to contentSkip to conversation

xpti: fix bug in double fault handling

PATCH In review Juergen Gross 3 participants 3 messages Apr 23, 2018

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 xpti: fix bug in double fault handling

When entering the hypervisor via the double fault handler resetting xen_cr3 was missing. This led to switching to pv_cr3 when returning from the next following exception, so repair this in order to allow exception handling to work even after a double fault.

---
 xen/arch/x86/x86_64/entry.S | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
xen/arch/x86/x86_64/entry.S +3 -1
index 45d9842d09..1cd7d93892 100644
@@ -767,12 +767,14 @@ ENTRY(double_fault)
         /* WARNING! `ret`, `call *`, `jmp *` not safe before this point. */
 
         mov   STACK_CPUINFO_FIELD(xen_cr3)(%r14), %rbx
-        test  %rbx, %rbx
+        neg   %rbx
         jz    .Ldblf_cr3_okay
         jns   .Ldblf_cr3_load
+        mov   %rbx, STACK_CPUINFO_FIELD(xen_cr3)(%r14)
         neg   %rbx
 .Ldblf_cr3_load:
         mov   %rbx, %cr3
+        movq $0, STACK_CPUINFO_FIELD(xen_cr3)(%r14)
 .Ldblf_cr3_okay:
 
         movq  %rsp,%rdi
Signature · 7 lines
2.13.6


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Reviewed-by on v3 1/1
#1 lore raw
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 23.04.18 at 15:59, <[email protected]> wrote:

When entering the hypervisor via the double fault handler resetting xen_cr3 was missing. This led to switching to pv_cr3 when returning from the next following exception, so repair this in order to allow exception handling to work even after a double fault.

(and I'm glad Andrew had noticed the issue before me putting this in)

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reviewed-by Tested-by on v3 1/1
#2 lore raw
In reply to Juergen Gross
Quoted 6 lines · Juergen Gross

When entering the hypervisor via the double fault handler resetting xen_cr3 was missing. This led to switching to pv_cr3 when returning from the next following exception, so repair this in order to allow exception handling to work even after a double fault.

Quoted 14 lines
---
 xen/arch/x86/x86_64/entry.S | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
xen/arch/x86/x86_64/entry.S +1 -1
index 45d9842d09..1cd7d93892 100644
@@ -767,12 +767,14 @@ ENTRY(double_fault)
         /* WARNING! `ret`, `call *`, `jmp *` not safe before this point. */
 
         mov   STACK_CPUINFO_FIELD(xen_cr3)(%r14), %rbx
-        test  %rbx, %rbx
+        neg   %rbx

xen/arch/x86/x86_64/entry.S ENTRY(double_fault) · line 780

Quoted 10 lines
xen/arch/x86/x86_64/entry.S +2 -0
         jz    .Ldblf_cr3_okay
         jns   .Ldblf_cr3_load
+        mov   %rbx, STACK_CPUINFO_FIELD(xen_cr3)(%r14)
         neg   %rbx
 .Ldblf_cr3_load:
         mov   %rbx, %cr3
+        movq $0, STACK_CPUINFO_FIELD(xen_cr3)(%r14)
 .Ldblf_cr3_okay:
 
         movq  %rsp,%rdi

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel