Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/x86_64/x86_64 Use flag to indicate whether an LWP s...



details:   https://anonhg.NetBSD.org/src/rev/91fa996e5bbe
branches:  trunk
changeset: 542469:91fa996e5bbe
user:      fvdl <fvdl%NetBSD.org@localhost>
date:      Thu Jan 30 02:04:59 2003 +0000

description:
Use flag to indicate whether an LWP should return to userspace via
sysret (should it have entered through syscall), or via a plain
iret. This can be done more quicker and dirtier, but I've decided
against that for now.

diffstat:

 sys/arch/x86_64/x86_64/genassym.cf |   5 ++++-
 sys/arch/x86_64/x86_64/machdep.c   |  10 +++++++++-
 sys/arch/x86_64/x86_64/vector.S    |  12 ++++++++----
 3 files changed, 21 insertions(+), 6 deletions(-)

diffs (92 lines):

diff -r af4a2582069b -r 91fa996e5bbe sys/arch/x86_64/x86_64/genassym.cf
--- a/sys/arch/x86_64/x86_64/genassym.cf        Thu Jan 30 02:03:35 2003 +0000
+++ b/sys/arch/x86_64/x86_64/genassym.cf        Thu Jan 30 02:04:59 2003 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: genassym.cf,v 1.10 2003/01/26 14:12:11 fvdl Exp $
+#      $NetBSD: genassym.cf,v 1.11 2003/01/30 02:04:59 fvdl Exp $
 
 #
 # Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -128,8 +128,11 @@
 define         L_PROC                  offsetof(struct lwp, l_proc)
 define         L_MD_TSS_SEL            offsetof(struct lwp, l_md.md_tss_sel)
 define         L_MD_REGS               offsetof(struct lwp, l_md.md_regs)
+define         L_MD_FLAGS              offsetof(struct lwp, l_md.md_flags)
 define         L_CPU                   offsetof(struct lwp, l_cpu)
 
+define         MDP_IRET                MDP_IRET
+
 define P_FLAG                  offsetof(struct proc, p_flag)
 define P_NRAS                  offsetof(struct proc, p_nras)
 define P_MD_SYSCALL            offsetof(struct proc, p_md.md_syscall)
diff -r af4a2582069b -r 91fa996e5bbe sys/arch/x86_64/x86_64/machdep.c
--- a/sys/arch/x86_64/x86_64/machdep.c  Thu Jan 30 02:03:35 2003 +0000
+++ b/sys/arch/x86_64/x86_64/machdep.c  Thu Jan 30 02:04:59 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.26 2003/01/26 00:05:39 fvdl Exp $        */
+/*     $NetBSD: machdep.c,v 1.27 2003/01/30 02:05:00 fvdl Exp $        */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -614,6 +614,12 @@
 
        tf = l->l_md.md_regs;
 
+#if 0
+       printf("proc %d: upcall to lwp %d, type %d ev %d int %d sas %p to %p\n",
+           (int)l->l_proc->p_pid, (int)l->l_lid, type, nevents, ninterrupted,
+           sas, (void *)upcall);
+#endif
+
        tf->tf_rdi = type;
        tf->tf_rsi = (u_int64_t)sas;
        tf->tf_rdx = nevents;
@@ -630,6 +636,8 @@
        tf->tf_cs = GSEL(GUCODE_SEL, SEL_UPL);
        tf->tf_ss = GSEL(GUDATA_SEL, SEL_UPL);
        tf->tf_rflags &= ~(PSL_T|PSL_VM|PSL_AC);
+
+       l->l_md.md_flags |= MDP_IRET;
 }
 
 /*
diff -r af4a2582069b -r 91fa996e5bbe sys/arch/x86_64/x86_64/vector.S
--- a/sys/arch/x86_64/x86_64/vector.S   Thu Jan 30 02:03:35 2003 +0000
+++ b/sys/arch/x86_64/x86_64/vector.S   Thu Jan 30 02:04:59 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vector.S,v 1.17 2003/01/26 00:05:39 fvdl Exp $ */
+/*     $NetBSD: vector.S,v 1.18 2003/01/30 02:05:00 fvdl Exp $ */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -266,9 +266,10 @@
        movq    $2,TF_ERR(%rsp)
        movq    $T_ASTFLT, TF_TRAPNO(%rsp)
 
-       movq    _C_LABEL(curlwp)(%rip),%r15
-       movq    %rsp,L_MD_REGS(%r15)    # save pointer to frame
-       movq    L_PROC(%r15),%r15
+       movq    _C_LABEL(curlwp)(%rip),%r14
+       movq    %rsp,L_MD_REGS(%r14)    # save pointer to frame
+       movq    L_PROC(%r14),%r15
+       andl    $~MDP_IRET,L_MD_FLAGS(%r14)
        call    *P_MD_SYSCALL(%r15)
 1:     /* Check for ASTs on exit to user mode. */
        cli
@@ -282,6 +283,8 @@
        jmp     1b
 2:
        sti
+       testl   $MDP_IRET, L_MD_FLAGS(%r14)
+       jne     iret_return;
 syscall_return:
 #ifdef DIAGNOSTIC
        cmpl    $0,_C_LABEL(cpl)(%rip)
@@ -368,6 +371,7 @@
        /* Pushed T_ASTFLT into tf_trapno on entry. */
        call    _C_LABEL(trap)
        jmp     2b
+iret_return:
 #ifndef DIAGNOSTIC
 1:     INTRFASTEXIT
 #else /* DIAGNOSTIC */



Home | Main Index | Thread Index | Old Index