WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] Using SYSCALL/SYSRET with a minios kernel

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] Using SYSCALL/SYSRET with a minios kernel
From: Goswin von Brederlow <goswin-v-b@xxxxxx>
Date: Mon, 25 Feb 2008 00:22:27 +0100
Delivery-date: Sun, 24 Feb 2008 15:22:49 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Gnus/5.110006 (No Gnus v0.6) XEmacs/21.4.19 (linux)
Hi,

I'm trying to use the SYSCALL/SYSRET opcodes with a minios kernel
without much success.

Going by the manuals (and linux sources) I first have to setup the
STAR and LSTAR registers to define the segment and instruction pointer
to be used for SYSCALL:

        /* 
         * LSTAR and STAR live in a bit strange symbiosis.
         * They both write to the same internal register. STAR allows to set
         * CS/DS but only a 32bit target. LSTAR sets the 64bit rip.
         */ 
        wrmsrl(MSR_STAR,  ((uint64_t)__USER_CS)<<48  | 
((uint64_t)__KERNEL_CS)<<32); 
        wrmsrl(MSR_LSTAR, system_call); 


But all that does is give a message on the xen console:

(XEN) traps.c:1467:d137 Domain attempted WRMSR 00000000c0000081 from 
e023e010:00000000 to e033e033:00000000.
(XEN) traps.c:1467:d137 Domain attempted WRMSR 00000000c0000082 from 
ffff8300:001e0800 to 00000000:001054c0.


A later
        __asm__ __volatile__("syscall"::);
does nothing while a
        __asm__ __volatile__("sysret"::);
causes a general protection fault:

(XEN) traps.c:405:d137 Unhandled general protection fault fault/trap [#13] in 
domain 137 on VCPU 0 [ec=0000]
(XEN) domain_crash_sync called from entry.S
(XEN) Domain 137 (vcpu#0) crashed on cpu#0:
(XEN) ----[ Xen-3.0.4-1  x86_64  debug=y  Not tainted ]----
(XEN) CPU:    0
(XEN) RIP:    e033:[<000000000010559f>]
(XEN) RFLAGS: 0000000000000216   CONTEXT: guest
(XEN) rax: fffffffffffffff2   rbx: 0000000001857000   rcx: 000000000010559f
(XEN) rdx: 0000000000000100   rsi: 00000000deadbeef   rdi: 00000000deadbeef
(XEN) rbp: 0000000000000000   rsp: 0000000000108310   r8:  00000000001ff000
(XEN) r9:  0000000001857000   r10: 00000000fffffff9   r11: 0000000000000216
(XEN) r12: 0000000001851000   r13: 0000000000000000   r14: 0000000000000000
(XEN) r15: 0000000000000000   cr0: 000000008005003b   cr4: 00000000000006f0
(XEN) cr3: 00000000268f8000   cr2: 0000000000000000
(XEN) ds: 0000   es: 0000   fs: 0000   gs: 0000   ss: e02b   cs: e033
(XEN) Guest stack trace from rsp=0000000000108310:
(XEN)    000000000010559f 0000000000000216 0000000000000000 000000000010559f
(XEN)    000000000000e030 0000000000010216 0000000000108350 000000000000e02b
(XEN)    0000000000000000 0000000000119000 0000000000000000 00000000001040ba
(XEN)    6f622065736f6f4d 2e2e2e676e69746f 0000000000000a0d 0000000000000000
(XEN)    61727473746f6f42 2e2e2e676e697070 000000000000000a 0000000000000000
(XEN)    0000000000000000 0000000000100010 0000000000119000 0000000000113000
(XEN)    0000000000000000 0000000000000000 0000000000000000 0000000000000000
(XEN)    0000000000000000 0000000000000000 0000000000000000 0000000000000000
(XEN)    0000000000000000 0000000000000000 0000000000000000 0000000000000000
(XEN)    0000000000000000 0000000000000000 0000000000000000 0000000000000000
(XEN)    0000000000000000 0000000000000000 0000000000000000 0000000000000000
(XEN)    0000000000000000 0000000000000000 0000000000000000 0000000000000000
(XEN)    0000000000000000 0000000000000000 0000000000000000 0000000000000000
(XEN)    0000000000000000 0000000000000000 0000000000000000 0000000000000000
(XEN)    0000000000000000 0000000000000000 0000000000000000 0000000000000000
(XEN)    0000000000000000 0000000000000000 0000000000000000 0000000000000000
(XEN)    0000000000000000 0000000000000000 0000000000000000 0000000000000000
(XEN)    0000000000000000 0000000000000000 0000000000000000 0000000000000000
(XEN)    0000000000000000 0000000000000000 0000000000000000 0000000000000000
(XEN)    0000000000000000 0000000000000000 0000000000000000 0000000000000000

Any pointers would be welcome.

MfG
        Goswin

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel