Source-Changes-HG archive

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

[src/trunk]: src/sys/arch In XEN PV, the idt vector table is not required to ...



details:   https://anonhg.NetBSD.org/src/rev/29ba2251cb30
branches:  trunk
changeset: 827587:29ba2251cb30
user:      cherry <cherry%NetBSD.org@localhost>
date:      Sat Nov 04 08:50:47 2017 +0000

description:
In XEN PV, the idt vector table is not required to be altered at
runtime, since only entries for exceptions/traps are registered with
the hypervisor and interrupts are managed via a completely different
mechanism.

This change uses the idt_vec_reserve() mechanism nevertheless,
modifying it slightly to only do namespace management in XEN, while on
native it will continue to do idt entry init as before.

Rationale: Consistent API usage and potential future merging of
XEN/non-XEN code.

There are no functional changes in this commit.

diffstat:

 sys/arch/amd64/amd64/machdep.c    |   6 ++++--
 sys/arch/amd64/include/segments.h |   6 +++---
 sys/arch/i386/i386/machdep.c      |   6 ++++--
 sys/arch/i386/include/segments.h  |   6 +++---
 sys/arch/x86/x86/idt.c            |  12 +++++++++---
 sys/arch/xen/conf/files.xen       |   3 ++-
 6 files changed, 25 insertions(+), 14 deletions(-)

diffs (186 lines):

diff -r 21f379cf5aec -r 29ba2251cb30 sys/arch/amd64/amd64/machdep.c
--- a/sys/arch/amd64/amd64/machdep.c    Sat Nov 04 08:33:28 2017 +0000
+++ b/sys/arch/amd64/amd64/machdep.c    Sat Nov 04 08:50:47 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.274 2017/10/29 10:25:28 maxv Exp $       */
+/*     $NetBSD: machdep.c,v 1.275 2017/11/04 08:50:47 cherry Exp $     */
 
 /*
  * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@@ -110,7 +110,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.274 2017/10/29 10:25:28 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.275 2017/11/04 08:50:47 cherry Exp $");
 
 /* #define XENDEBUG_LOW  */
 
@@ -1747,6 +1747,7 @@
                    GSEL(GCODE_SEL, SEL_KPL));
 #else /* XEN */
                pmap_changeprot_local(idt_vaddr, VM_PROT_READ|VM_PROT_WRITE);
+               idt_vec_reserve(x);
                xen_idt[xen_idt_idx].vector = x;
 
                switch (x) {
@@ -1776,6 +1777,7 @@
        setgate(&idt[128], &IDTVEC(osyscall), 0, SDT_SYS386IGT, SEL_UPL,
            GSEL(GCODE_SEL, SEL_KPL));
 #else
+       idt_vec_reserve(128);
        xen_idt[xen_idt_idx].vector = 128;
        xen_idt[xen_idt_idx].flags = SEL_KPL;
        xen_idt[xen_idt_idx].cs = GSEL(GCODE_SEL, SEL_KPL);
diff -r 21f379cf5aec -r 29ba2251cb30 sys/arch/amd64/include/segments.h
--- a/sys/arch/amd64/include/segments.h Sat Nov 04 08:33:28 2017 +0000
+++ b/sys/arch/amd64/include/segments.h Sat Nov 04 08:50:47 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: segments.h,v 1.32 2017/11/01 07:14:29 maxv Exp $       */
+/*     $NetBSD: segments.h,v 1.33 2017/11/04 08:50:47 cherry Exp $     */
 
 /*
  * Copyright (c) 1990 The Regents of the University of California.
@@ -245,12 +245,12 @@
 void cpu_init_idt(void);
 void update_descriptor(void *, void *);
 
-#if !defined(XEN)
+
 void idt_vec_reserve(int);
 int idt_vec_alloc(int, int);
 void idt_vec_set(int, void (*)(void));
 void idt_vec_free(int);
-#endif
+
 
 struct lwp;
 void cpu_segregs64_zero(struct lwp *);
diff -r 21f379cf5aec -r 29ba2251cb30 sys/arch/i386/i386/machdep.c
--- a/sys/arch/i386/i386/machdep.c      Sat Nov 04 08:33:28 2017 +0000
+++ b/sys/arch/i386/i386/machdep.c      Sat Nov 04 08:50:47 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.797 2017/10/29 10:01:21 maxv Exp $       */
+/*     $NetBSD: machdep.c,v 1.798 2017/11/04 08:50:47 cherry Exp $     */
 
 /*
  * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009, 2017
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.797 2017/10/29 10:01:21 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.798 2017/11/04 08:50:47 cherry Exp $");
 
 #include "opt_beep.h"
 #include "opt_compat_freebsd.h"
@@ -1355,6 +1355,7 @@
        xen_idt_idx = 0;
        for (x = 0; x < 32; x++) {
                KASSERT(xen_idt_idx < MAX_XEN_IDT);
+               idt_vec_reserve(x);
                xen_idt[xen_idt_idx].vector = x;
 
                switch (x) {
@@ -1377,6 +1378,7 @@
                xen_idt_idx++;
        }
        KASSERT(xen_idt_idx < MAX_XEN_IDT);
+       idt_vec_reserve(128);
        xen_idt[xen_idt_idx].vector = 128;
        xen_idt[xen_idt_idx].flags = SEL_UPL;
        xen_idt[xen_idt_idx].cs = GSEL(GCODE_SEL, SEL_KPL);
diff -r 21f379cf5aec -r 29ba2251cb30 sys/arch/i386/include/segments.h
--- a/sys/arch/i386/include/segments.h  Sat Nov 04 08:33:28 2017 +0000
+++ b/sys/arch/i386/include/segments.h  Sat Nov 04 08:50:47 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: segments.h,v 1.62 2017/09/17 09:41:35 maxv Exp $       */
+/*     $NetBSD: segments.h,v 1.63 2017/11/04 08:50:47 cherry Exp $     */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -200,12 +200,12 @@
 void cpu_init_idt(void);
 void update_descriptor(union descriptor *, union descriptor *);
 
-#if !defined(XEN)
+
 void idt_vec_reserve(int);
 int idt_vec_alloc(int, int);
 void idt_vec_set(int, void (*)(void));
 void idt_vec_free(int);
-#endif
+
 
 #endif /* _KERNEL */
 
diff -r 21f379cf5aec -r 29ba2251cb30 sys/arch/x86/x86/idt.c
--- a/sys/arch/x86/x86/idt.c    Sat Nov 04 08:33:28 2017 +0000
+++ b/sys/arch/x86/x86/idt.c    Sat Nov 04 08:50:47 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: idt.c,v 1.5 2017/08/07 17:10:09 maxv Exp $     */
+/*     $NetBSD: idt.c,v 1.6 2017/11/04 08:50:47 cherry Exp $   */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2009 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: idt.c,v 1.5 2017/08/07 17:10:09 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: idt.c,v 1.6 2017/11/04 08:50:47 cherry Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -75,9 +75,12 @@
 
 #include <machine/segments.h>
 
+/* On xen PV this is just numberspace management - used in x86/intr.c */
 #if !defined(XEN)
 
 struct gate_descriptor *idt;
+#endif
+
 static char idt_allocmap[NIDT];
 
 /*
@@ -120,8 +123,10 @@
 {
 
        KASSERT(idt_allocmap[vec] == 1);
+#if !defined(XEN)
        setgate(&idt[vec], function, 0, SDT_SYS386IGT, SEL_KPL,
            GSEL(GCODE_SEL, SEL_KPL));
+#endif
 }
 
 /*
@@ -131,8 +136,9 @@
 idt_vec_free(int vec)
 {
 
+#if !defined(XEN)
        unsetgate(&idt[vec]);
+#endif
        idt_allocmap[vec] = 0;
 }
 
-#endif /* !defined(XEN) */
diff -r 21f379cf5aec -r 29ba2251cb30 sys/arch/xen/conf/files.xen
--- a/sys/arch/xen/conf/files.xen       Sat Nov 04 08:33:28 2017 +0000
+++ b/sys/arch/xen/conf/files.xen       Sat Nov 04 08:50:47 2017 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.xen,v 1.157 2017/11/04 07:01:45 cherry Exp $
+#      $NetBSD: files.xen,v 1.158 2017/11/04 08:50:47 cherry Exp $
 #      NetBSD: files.x86,v 1.10 2003/10/08 17:30:00 bouyer Exp 
 #      NetBSD: files.i386,v 1.254 2004/03/25 23:32:10 jmc Exp 
 
@@ -140,6 +140,7 @@
 file   arch/x86/x86/identcpu.c         machdep
 file   arch/xen/x86/intr.c             machdep
 file   arch/xen/x86/xen_ipi.c          multiprocessor
+file   arch/x86/x86/idt.c              machdep
 file   arch/x86/x86/pmap.c             machdep
 file   arch/x86/x86/pmap_tlb.c         machdep
 file   arch/x86/x86/procfs_machdep.c   procfs



Home | Main Index | Thread Index | Old Index