Skip to contentSkip to conversation

x86-64: clear DF for kernel when forwarding syscall

PATCH In review Jan Beulich 2 participants 2 messages Jun 22, 2007 – Jun 23, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86-64: clear DF for kernel when forwarding syscall

While this is not really matching native behavior, no guest seems to assume EFLAGS.DF being set or reflecting application state. Thus clear it for now, the syscall/sysenter patch that I'll hopefully be able to get to work will then introduce a more consistent solution. In any case, without this any app can easily force kernel data corruption.

xen/arch/x86/x86_64/entry.S +1 -0
Index: 2007-06-18/xen/arch/x86/x86_64/entry.S
===================================================================
@@ -34,6 +34,7 @@ switch_to_kernel:
         jnc   1f
         movb  $TBF_INTERRUPT,TRAPBOUNCE_flags(%rdx)
 1:      call  create_bounce_frame
+        andl  $~X86_EFLAGS_DF,UREGS_eflags(%rsp)
         jmp   test_all_events
 
 /* %rbx: struct vcpu, interrupts disabled */
#1 lore raw

Thanks. By the way, I've been thinking that rather than rev'ing the paravirtual hypercall interface for specifying syscall/sysenter callback points, since these have a direct native equivalent that we're trying to emulate the semantics of as closely as possible then we may as well emulate the MSRs for specifying RIP/RFLAGS_mask/etc too. Callers can catch the #GP to detect whether the new MSR-based interface is supported, and/or we can add a feature flag in our CPUID leaves.

-- Keir

Quoted 29 lines · Jan Beulich

While this is not really matching native behavior, no guest seems to assume EFLAGS.DF being set or reflecting application state. Thus clear it for now, the syscall/sysenter patch that I'll hopefully be able to get to work will then introduce a more consistent solution. In any case, without this any app can easily force kernel data corruption.

Index: 2007-06-18/xen/arch/x86/x86_64/entry.S
===================================================================
--- 2007-06-18.orig/xen/arch/x86/x86_64/entry.S 2007-06-22 16:35:55.000000000 +0200
+++ 2007-06-18/xen/arch/x86/x86_64/entry.S 2007-06-22 16:36:59.000000000 +0200

xen/arch/x86/x86_64/entry.S +1 -0
@@ -34,6 +34,7 @@ switch_to_kernel:
         jnc   1f
         movb  $TBF_INTERRUPT,TRAPBOUNCE_flags(%rdx)
 1:      call  create_bounce_frame
+        andl  $~X86_EFLAGS_DF,UREGS_eflags(%rsp)
         jmp   test_all_events
 
 /* %rbx: struct vcpu, interrupts disabled */

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel