All of lore.kernel.org
 help / color / mirror / Atom feed
From: Goswin von Brederlow <goswin-v-b@web.de>
To: xen-devel@lists.xensource.com
Subject: Using SYSCALL/SYSRET with a minios kernel
Date: Mon, 25 Feb 2008 00:22:27 +0100	[thread overview]
Message-ID: <87k5kuym6k.fsf@web.de> (raw)

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

             reply	other threads:[~2008-02-24 23:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-24 23:22 Goswin von Brederlow [this message]
2008-02-25  0:01 ` Using SYSCALL/SYSRET with a minios kernel Daniel Stodden
2008-02-25  1:55   ` Goswin von Brederlow
2008-02-25  2:26     ` Daniel Stodden
2008-02-25 10:04       ` Goswin von Brederlow
2008-02-25 11:08         ` Daniel Stodden
2008-02-25 13:14           ` Goswin von Brederlow
2008-02-25 13:50             ` Daniel Stodden

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k5kuym6k.fsf@web.de \
    --to=goswin-v-b@web.de \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.