Source-Changes-HG archive

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

[src/trunk]: src/sys/arch convert to newer HYPERVISOR_physdev_op() interface,...



details:   https://anonhg.NetBSD.org/src/rev/05d9a785581e
branches:  trunk
changeset: 971330:05d9a785581e
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Tue Apr 21 20:13:39 2020 +0000

description:
convert to newer HYPERVISOR_physdev_op() interface, now command and the
arg are separate arguments - this is needed for newer physdev_op commands

remove code for PHYSDEVOP_IRQ_UNMASK_NOTIFY, it is obsolete since
interface version 0x00030202 and is unsupported by newer versions of Xen

confirmed working on amd64 Dom0, i386 compile-tested only

diffstat:

 sys/arch/amd64/amd64/machdep.c          |  18 ++++-----
 sys/arch/i386/i386/machdep.c            |  11 ++---
 sys/arch/xen/include/amd64/hypercalls.h |   6 +-
 sys/arch/xen/include/hypervisor.h       |   6 +--
 sys/arch/xen/include/i386/hypercalls.h  |  10 ++--
 sys/arch/xen/include/i82093var.h        |  24 ++++++-------
 sys/arch/xen/x86/hypervisor_machdep.c   |   7 +--
 sys/arch/xen/x86/pintr.c                |  21 +++++------
 sys/arch/xen/xen/evtchn.c               |  58 +-------------------------------
 9 files changed, 47 insertions(+), 114 deletions(-)

diffs (truncated from 401 to 300 lines):

diff -r 324b79d25a42 -r 05d9a785581e sys/arch/amd64/amd64/machdep.c
--- a/sys/arch/amd64/amd64/machdep.c    Tue Apr 21 19:03:51 2020 +0000
+++ b/sys/arch/amd64/amd64/machdep.c    Tue Apr 21 20:13:39 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.346 2020/01/31 08:21:11 maxv Exp $       */
+/*     $NetBSD: machdep.c,v 1.347 2020/04/21 20:13:39 jdolecek 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.346 2020/01/31 08:21:11 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.347 2020/04/21 20:13:39 jdolecek Exp $");
 
 #include "opt_modular.h"
 #include "opt_user_ldt.h"
@@ -428,10 +428,9 @@
 x86_64_switch_context(struct pcb *new)
 {
        HYPERVISOR_stack_switch(GSEL(GDATA_SEL, SEL_KPL), new->pcb_rsp0);
-       struct physdev_op physop;
-       physop.cmd = PHYSDEVOP_SET_IOPL;
-       physop.u.set_iopl.iopl = new->pcb_iopl;
-       HYPERVISOR_physdev_op(&physop);
+       struct physdev_set_iopl set_iopl;
+       set_iopl.iopl = new->pcb_iopl;
+       HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl);
 }
 
 void
@@ -489,14 +488,13 @@
 #if !defined(XENPV)
        lldt(GSYSSEL(GLDT_SEL, SEL_KPL));
 #else
-       struct physdev_op physop;
        xen_set_ldt((vaddr_t)ldtstore, LDT_SIZE >> 3);
        /* Reset TS bit and set kernel stack for interrupt handlers */
        HYPERVISOR_fpu_taskswitch(1);
        HYPERVISOR_stack_switch(GSEL(GDATA_SEL, SEL_KPL), pcb->pcb_rsp0);
-       physop.cmd = PHYSDEVOP_SET_IOPL;
-       physop.u.set_iopl.iopl = pcb->pcb_iopl;
-       HYPERVISOR_physdev_op(&physop);
+       struct physdev_set_iopl set_iopl;
+       set_iopl.iopl = pcb->pcb_iopl;
+       HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl);
 #endif
 }
 
diff -r 324b79d25a42 -r 05d9a785581e sys/arch/i386/i386/machdep.c
--- a/sys/arch/i386/i386/machdep.c      Tue Apr 21 19:03:51 2020 +0000
+++ b/sys/arch/i386/i386/machdep.c      Tue Apr 21 20:13:39 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.825 2020/01/31 08:21:11 maxv Exp $       */
+/*     $NetBSD: machdep.c,v 1.826 2020/04/21 20:13:39 jdolecek 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.825 2020/01/31 08:21:11 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.826 2020/04/21 20:13:39 jdolecek Exp $");
 
 #include "opt_beep.h"
 #include "opt_compat_freebsd.h"
@@ -494,15 +494,14 @@
 i386_switch_context(lwp_t *l)
 {
        struct pcb *pcb;
-       struct physdev_op physop;
 
        pcb = lwp_getpcb(l);
 
        HYPERVISOR_stack_switch(GSEL(GDATA_SEL, SEL_KPL), pcb->pcb_esp0);
 
-       physop.cmd = PHYSDEVOP_SET_IOPL;
-       physop.u.set_iopl.iopl = pcb->pcb_iopl;
-       HYPERVISOR_physdev_op(&physop);
+       struct physdev_set_iopl set_iopl;
+       set_iopl.iopl = pcb->pcb_iopl;
+       HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl);
 }
 
 void
diff -r 324b79d25a42 -r 05d9a785581e sys/arch/xen/include/amd64/hypercalls.h
--- a/sys/arch/xen/include/amd64/hypercalls.h   Tue Apr 21 19:03:51 2020 +0000
+++ b/sys/arch/xen/include/amd64/hypercalls.h   Tue Apr 21 20:13:39 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hypercalls.h,v 1.12 2019/02/10 11:10:34 cherry Exp $ */
+/* $NetBSD: hypercalls.h,v 1.13 2020/04/21 20:13:39 jdolecek Exp $ */
 /******************************************************************************
  * hypercall.h
  * 
@@ -274,9 +274,9 @@
 }
 
 static inline int
-HYPERVISOR_physdev_op(void *op)
+HYPERVISOR_physdev_op(int cmd, void *op)
 {
-       return _hypercall1(int, physdev_op_compat, op);
+       return _hypercall2(int, physdev_op, cmd, op);
 }
 
 static inline int
diff -r 324b79d25a42 -r 05d9a785581e sys/arch/xen/include/hypervisor.h
--- a/sys/arch/xen/include/hypervisor.h Tue Apr 21 19:03:51 2020 +0000
+++ b/sys/arch/xen/include/hypervisor.h Tue Apr 21 20:13:39 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hypervisor.h,v 1.49 2019/02/04 18:14:53 cherry Exp $   */
+/*     $NetBSD: hypervisor.h,v 1.50 2020/04/21 20:13:39 jdolecek Exp $ */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -147,10 +147,6 @@
 struct intrframe;
 struct cpu_info;
 void do_hypervisor_callback(struct intrframe *regs);
-#if NPCI > 0 || NISA > 0
-void hypervisor_prime_pirq_event(int, unsigned int);
-void hypervisor_ack_pirq_event(unsigned int);
-#endif /* NPCI > 0 || NISA > 0 */
 
 extern int xen_version;
 #define XEN_MAJOR(x) (((x) & 0xffff0000) >> 16)
diff -r 324b79d25a42 -r 05d9a785581e sys/arch/xen/include/i386/hypercalls.h
--- a/sys/arch/xen/include/i386/hypercalls.h    Tue Apr 21 19:03:51 2020 +0000
+++ b/sys/arch/xen/include/i386/hypercalls.h    Tue Apr 21 20:13:39 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hypercalls.h,v 1.19 2019/02/10 11:10:34 cherry Exp $   */
+/*     $NetBSD: hypercalls.h,v 1.20 2020/04/21 20:13:40 jdolecek Exp $ */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -533,13 +533,13 @@
 }
 
 static __inline int
-HYPERVISOR_physdev_op(void *physdev_op)
+HYPERVISOR_physdev_op(int cmd, void *physdev_op)
 {
     int ret;
-    unsigned long ign1;
+    unsigned long ign1, ign2;
 
-    _hypercall(__HYPERVISOR_physdev_op, _harg("1" (physdev_op)),
-       _harg("=a" (ret), "=b" (ign1)));
+    _hypercall(__HYPERVISOR_physdev_op, _harg("1" (cmd), "2" (physdev_op)),
+       _harg("=a" (ret), "=b" (ign1), "=c" (ign2)));
 
     return ret;
 }
diff -r 324b79d25a42 -r 05d9a785581e sys/arch/xen/include/i82093var.h
--- a/sys/arch/xen/include/i82093var.h  Tue Apr 21 19:03:51 2020 +0000
+++ b/sys/arch/xen/include/i82093var.h  Tue Apr 21 20:13:39 2020 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: i82093var.h,v 1.5 2017/11/04 09:31:08 cherry Exp $ */
+/*      $NetBSD: i82093var.h,v 1.6 2020/04/21 20:13:39 jdolecek Exp $ */
 
 #ifndef _XEN_I82093VAR_H_
 #define _XEN_I82093VAR_H_
@@ -11,31 +11,29 @@
 static inline  uint32_t
 ioapic_read_ul(struct ioapic_softc *sc, int regid)
 {
-       physdev_op_t op;
+       struct physdev_apic apic_op;
        int ret;
 
-        op.cmd = PHYSDEVOP_APIC_READ;
-       op.u.apic_op.apic_physbase = sc->sc_pa;
-       op.u.apic_op.reg = regid;
-       ret = HYPERVISOR_physdev_op(&op);
+       apic_op.apic_physbase = sc->sc_pa;
+       apic_op.reg = regid;
+       ret = HYPERVISOR_physdev_op(PHYSDEVOP_apic_read, &apic_op);
        if (ret) {
                printf("PHYSDEVOP_APIC_READ ret %d\n", ret);
                panic("PHYSDEVOP_APIC_READ");
        }
-       return op.u.apic_op.value;      
+       return apic_op.value;      
 }
 
 static inline void
 ioapic_write_ul(struct ioapic_softc *sc, int regid, uint32_t val)
 {
-       physdev_op_t op;
+       struct physdev_apic apic_op;
        int ret;
 
-        op.cmd = PHYSDEVOP_APIC_WRITE;
-       op.u.apic_op.apic_physbase = sc->sc_pa;
-       op.u.apic_op.reg = regid;
-       op.u.apic_op.value = val;
-       ret = HYPERVISOR_physdev_op(&op);
+       apic_op.apic_physbase = sc->sc_pa;
+       apic_op.reg = regid;
+       apic_op.value = val;
+       ret = HYPERVISOR_physdev_op(PHYSDEVOP_apic_write, &apic_op);
        if (ret)
                printf("PHYSDEVOP_APIC_WRITE ret %d\n", ret);
 }
diff -r 324b79d25a42 -r 05d9a785581e sys/arch/xen/x86/hypervisor_machdep.c
--- a/sys/arch/xen/x86/hypervisor_machdep.c     Tue Apr 21 19:03:51 2020 +0000
+++ b/sys/arch/xen/x86/hypervisor_machdep.c     Tue Apr 21 20:13:39 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hypervisor_machdep.c,v 1.36 2019/05/09 17:09:51 bouyer Exp $   */
+/*     $NetBSD: hypervisor_machdep.c,v 1.37 2020/04/21 20:13:40 jdolecek Exp $ */
 
 /*
  *
@@ -54,7 +54,7 @@
 
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.36 2019/05/09 17:09:51 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.37 2020/04/21 20:13:40 jdolecek Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -378,9 +378,6 @@
 {
        KASSERT(args == NULL);
        hypervisor_unmask_event(port);
-#if NPCI > 0 || NISA > 0
-       hypervisor_ack_pirq_event(port);
-#endif /* NPCI > 0 || NISA > 0 */
 }
 
 void
diff -r 324b79d25a42 -r 05d9a785581e sys/arch/xen/x86/pintr.c
--- a/sys/arch/xen/x86/pintr.c  Tue Apr 21 19:03:51 2020 +0000
+++ b/sys/arch/xen/x86/pintr.c  Tue Apr 21 20:13:39 2020 +0000
@@ -103,7 +103,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pintr.c,v 1.11 2020/04/07 07:43:33 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pintr.c,v 1.12 2020/04/21 20:13:40 jdolecek Exp $");
 
 #include "opt_multiprocessor.h"
 #include "opt_xen.h"
@@ -163,22 +163,21 @@
 int
 xen_vec_alloc(int gsi)
 {
-       physdev_op_t op;
-
        KASSERT(gsi < 255);
 
        if (irq2port[gsi] == 0) {
-               op.cmd = PHYSDEVOP_ASSIGN_VECTOR;
-               op.u.irq_op.irq = gsi;
-               if (HYPERVISOR_physdev_op(&op) < 0) {
+               struct physdev_irq irq_op;
+               irq_op.irq = gsi;
+               if (HYPERVISOR_physdev_op(PHYSDEVOP_alloc_irq_vector,
+                   &irq_op) < 0) {
                        panic("PHYSDEVOP_ASSIGN_VECTOR gsi %d", gsi);
                }
                KASSERT(irq2vect[gsi] == 0 ||
-                       irq2vect[gsi] == op.u.irq_op.vector);
-               irq2vect[gsi] = op.u.irq_op.vector;
-               KASSERT(vect2irq[op.u.irq_op.vector] == 0 ||
-                        vect2irq[op.u.irq_op.vector] == gsi);
-               vect2irq[op.u.irq_op.vector] = gsi;
+                       irq2vect[gsi] == irq_op.vector);
+               irq2vect[gsi] = irq_op.vector;
+               KASSERT(vect2irq[irq_op.vector] == 0 ||
+                        vect2irq[irq_op.vector] == gsi);
+               vect2irq[irq_op.vector] = gsi;
        }
 
        return (irq2vect[gsi]);
diff -r 324b79d25a42 -r 05d9a785581e sys/arch/xen/xen/evtchn.c
--- a/sys/arch/xen/xen/evtchn.c Tue Apr 21 19:03:51 2020 +0000
+++ b/sys/arch/xen/xen/evtchn.c Tue Apr 21 20:13:39 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: evtchn.c,v 1.89 2020/04/13 22:54:12 bouyer Exp $       */
+/*     $NetBSD: evtchn.c,v 1.90 2020/04/21 20:13:40 jdolecek Exp $     */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -54,7 +54,7 @@
 
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.89 2020/04/13 22:54:12 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.90 2020/04/21 20:13:40 jdolecek Exp $");
 
 #include "opt_xen.h"
 #include "isa.h"
@@ -108,12 +108,7 @@
 #if NPCI > 0 || NISA > 0
 /* event-channel <-> PIRQ mapping */
 static int pirq_to_evtch[NR_PIRQS];



Home | Main Index | Thread Index | Old Index