Make DOM0OPS build for PVH/PVHVM too

This commit is contained in:
bouyer 2020-05-05 17:02:01 +00:00
parent 9ae5cc2e42
commit 4dbd32ce08
9 changed files with 51 additions and 41 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: pmap.c,v 1.387 2020/05/02 16:44:36 bouyer Exp $ */
/* $NetBSD: pmap.c,v 1.388 2020/05/05 17:02:01 bouyer Exp $ */
/*
* Copyright (c) 2008, 2010, 2016, 2017, 2019, 2020 The NetBSD Foundation, Inc.
@ -130,7 +130,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.387 2020/05/02 16:44:36 bouyer Exp $");
__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.388 2020/05/05 17:02:01 bouyer Exp $");
#include "opt_user_ldt.h"
#include "opt_lockdebug.h"
@ -982,7 +982,7 @@ pmap_kenter_pa(vaddr_t va, paddr_t pa, vm_prot_t prot, u_int flags)
pte = vtopte(va);
else
pte = kvtopte(va);
#ifdef DOM0OPS
#if defined(XENPV) && defined(DOM0OPS)
if (pa < pmap_pa_start || pa >= pmap_pa_end) {
#ifdef DEBUG
printf_nolog("%s: pa %#" PRIxPADDR " for va %#" PRIxVADDR
@ -990,7 +990,7 @@ pmap_kenter_pa(vaddr_t va, paddr_t pa, vm_prot_t prot, u_int flags)
#endif /* DEBUG */
npte = pa;
} else
#endif /* DOM0OPS */
#endif /* XENPV && DOM0OPS */
npte = pmap_pa2pte(pa);
npte |= protection_codes[prot] | PTE_P | pmap_pg_g;
npte |= pmap_pat_flags(flags);

View File

@ -1,6 +1,6 @@
# $NetBSD: files.xen,v 1.184 2020/05/02 16:46:06 bouyer Exp $
# $NetBSD: files.xen,v 1.185 2020/05/05 17:02:01 bouyer Exp $
defflag opt_xen.h XEN XENPVH XENPVHVM PAE
defflag opt_xen.h XEN XENPVH XENPVHVM PAE DOM0OPS
file arch/xen/x86/hypervisor_machdep.c xen
file arch/xen/x86/xen_intr.c xen
@ -46,3 +46,15 @@ file arch/xen/xen/xennet_checksum.c xvif | xennet
device xbd: disk
attach xbd at xenbus
file arch/xen/xen/xbd_xenbus.c xbd
# Domain-0 operations
file arch/xen/xen/privcmd.c dom0ops
file arch/xen/x86/xen_shm_machdep.c dom0ops
file arch/xen/xen/xenevt.c xenevt & dom0ops
file arch/xen/xen/xennetback_xenbus.c xvif
file arch/xen/xen/xbdback_xenbus.c xbdback
# Xen event peudo-device
defpseudo xenevt
defpseudo xvif
defpseudo xbdback

View File

@ -1,4 +1,4 @@
# $NetBSD: files.xen.pv,v 1.2 2020/04/25 15:26:17 bouyer Exp $
# $NetBSD: files.xen.pv,v 1.3 2020/05/05 17:02:01 bouyer Exp $
file arch/xen/x86/autoconf.c xenpv
file arch/xen/x86/x86_xpmap.c xenpv
@ -17,11 +17,6 @@ include "arch/xen/conf/files.compat"
# System bus types
#
# Xen event peudo-device
defpseudo xenevt
defpseudo xvif
defpseudo xbdback
# PCI frontend
device xpci: pcibus
attach xpci at xenbus with xpci_xenbus
@ -40,10 +35,4 @@ device vcpu
attach vcpu at xendevbus
file arch/xen/x86/cpu.c xenpv & vcpu
# Domain-0 operations
defflag opt_xen.h DOM0OPS XENPV
file arch/xen/xen/privcmd.c dom0ops
file arch/xen/x86/xen_shm_machdep.c dom0ops
file arch/xen/xen/xenevt.c xenevt & (dom0ops | xenpvhvm)
file arch/xen/xen/xennetback_xenbus.c xvif
file arch/xen/xen/xbdback_xenbus.c xbdback
defflag opt_xen.h XENPV

View File

@ -1,4 +1,4 @@
/* $NetBSD: xen_intr.c,v 1.25 2020/05/04 15:55:56 jdolecek Exp $ */
/* $NetBSD: xen_intr.c,v 1.26 2020/05/05 17:02:01 bouyer Exp $ */
/*-
* Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: xen_intr.c,v 1.25 2020/05/04 15:55:56 jdolecek Exp $");
__KERNEL_RCSID(0, "$NetBSD: xen_intr.c,v 1.26 2020/05/05 17:02:01 bouyer Exp $");
#include "opt_multiprocessor.h"
@ -232,7 +232,7 @@ xen_intr_disestablish(struct intrhand *ih)
/* event_remove_handler frees ih */
return;
}
#if defined(DOM0OPS)
#if defined(DOM0OPS) && defined(XENPV)
/*
* Cache state, to prevent a use after free situation with
* ih.

View File

@ -1,4 +1,4 @@
/* $NetBSD: hypervisor.c,v 1.80 2020/05/03 17:24:11 bouyer Exp $ */
/* $NetBSD: hypervisor.c,v 1.81 2020/05/05 17:02:01 bouyer Exp $ */
/*
* Copyright (c) 2005 Manuel Bouyer.
@ -53,7 +53,7 @@
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.80 2020/05/03 17:24:11 bouyer Exp $");
__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.81 2020/05/05 17:02:01 bouyer Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -156,7 +156,7 @@ union hypervisor_attach_cookie {
* This is set when the ISA bus is attached. If it's not set by the
* time it's checked below, then mainbus attempts to attach an ISA.
*/
#ifdef DOM0OPS
#if defined(XENPV) && defined(DOM0OPS)
int isa_has_been_seen;
#if NISA > 0
struct x86_isa_chipset x86_isa_chipset;
@ -663,7 +663,7 @@ hypervisor_attach(device_t parent, device_t self, void *aux)
hac.hac_xencons.xa_device = "xencons";
config_found_ia(self, "xendevbus", &hac.hac_xencons, hypervisor_print);
#endif
#ifdef DOM0OPS
#if defined(XENPV) && defined(DOM0OPS)
#if NPCI > 0
#if NACPICA > 0
if (acpi_present) {
@ -728,7 +728,7 @@ hypervisor_attach(device_t parent, device_t self, void *aux)
if (xendomain_is_privileged()) {
xenprivcmd_init();
}
#endif /* DOM0OPS */
#endif /* XENPV && DOM0OPS */
hypervisor_machdep_attach();

View File

@ -1,4 +1,4 @@
/* $NetBSD: privcmd.c,v 1.56 2020/04/25 15:26:18 bouyer Exp $ */
/* $NetBSD: privcmd.c,v 1.57 2020/05/05 17:02:01 bouyer Exp $ */
/*-
* Copyright (c) 2004 Christian Limpach.
@ -27,7 +27,7 @@
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: privcmd.c,v 1.56 2020/04/25 15:26:18 bouyer Exp $");
__KERNEL_RCSID(0, "$NetBSD: privcmd.c,v 1.57 2020/05/05 17:02:01 bouyer Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -44,6 +44,8 @@ __KERNEL_RCSID(0, "$NetBSD: privcmd.c,v 1.56 2020/04/25 15:26:18 bouyer Exp $");
#include <uvm/uvm_fault_i.h>
#include <xen/kernfs_machdep.h>
#include <xen/hypervisor.h>
#include <xen/xen.h>
#include <xen/xenio.h>
#define PRIVCMD_MODE (S_IRUSR)

View File

@ -1,4 +1,4 @@
/* $NetBSD: xbdback_xenbus.c,v 1.92 2020/04/25 20:05:25 jdolecek Exp $ */
/* $NetBSD: xbdback_xenbus.c,v 1.93 2020/05/05 17:02:01 bouyer Exp $ */
/*
* Copyright (c) 2006 Manuel Bouyer.
@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.92 2020/04/25 20:05:25 jdolecek Exp $");
__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.93 2020/05/05 17:02:01 bouyer Exp $");
#include <sys/buf.h>
#include <sys/condvar.h>
@ -46,6 +46,7 @@ __KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.92 2020/04/25 20:05:25 jdolecek
#include <sys/types.h>
#include <sys/vnode.h>
#include <xen/hypervisor.h>
#include <xen/xen.h>
#include <xen/xen_shm.h>
#include <xen/evtchn.h>
@ -595,7 +596,7 @@ xbdback_connect(struct xbdback_instance *xbdi)
XENPRINTF(("xbdback %s: connect evchannel %d\n", xbusd->xbusd_path, xbdi->xbdi_evtchn));
xbdi->xbdi_evtchn = evop.u.bind_interdomain.local_port;
xbdi->xbdi_ih = xen_intr_establish_xname(-1, &xen_pic, xbdi->xbdi_evtchn,
xbdi->xbdi_ih = intr_establish_xname(-1, &xen_pic, xbdi->xbdi_evtchn,
IST_LEVEL, IPL_BIO, xbdback_evthandler, xbdi, false,
xbdi->xbdi_name);
KASSERT(xbdi->xbdi_ih != NULL);
@ -642,7 +643,7 @@ xbdback_disconnect(struct xbdback_instance *xbdi)
return;
}
hypervisor_mask_event(xbdi->xbdi_evtchn);
xen_intr_disestablish(xbdi->xbdi_ih);
intr_disestablish(xbdi->xbdi_ih);
/* signal thread that we want to disconnect, then wait for it */
xbdi->xbdi_status = DISCONNECTING;

View File

@ -1,4 +1,4 @@
/* $NetBSD: xenevt.c,v 1.57 2020/04/25 15:26:18 bouyer Exp $ */
/* $NetBSD: xenevt.c,v 1.58 2020/05/05 17:02:01 bouyer Exp $ */
/*
* Copyright (c) 2005 Manuel Bouyer.
@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: xenevt.c,v 1.57 2020/04/25 15:26:18 bouyer Exp $");
__KERNEL_RCSID(0, "$NetBSD: xenevt.c,v 1.58 2020/05/05 17:02:01 bouyer Exp $");
#include "opt_xen.h"
#include <sys/param.h>
@ -176,12 +176,12 @@ xenevtattach(int n)
* Allocate a loopback event port.
* This helps us massage xenevt_processevt() into the
* callchain at the appropriate level using only
* xen_intr_establish_xname().
* intr_establish_xname().
*/
evtchn_port_t evtchn = xenevt_alloc_event();
/* The real objective here is to wiggle into the ih callchain for IPL level */
ih = xen_intr_establish_xname(-1, &xen_pic, evtchn, IST_LEVEL, level,
ih = intr_establish_xname(-1, &xen_pic, evtchn, IST_LEVEL, level,
xenevt_processevt, NULL, true, "xenevt");
KASSERT(ih != NULL);
@ -357,8 +357,13 @@ xenevtmmap(dev_t dev, off_t off, int prot)
/* only one page, so off is always 0 */
if (off != 0)
return -1;
#ifdef XENPV
return x86_btop(
xpmap_mtop((paddr_t)xen_start_info.store_mfn << PAGE_SHIFT));
#else
return x86_btop(
(paddr_t)xen_start_info.store_mfn << PAGE_SHIFT);
#endif
}
return -1;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: xennetback_xenbus.c,v 1.104 2020/05/04 08:22:45 jdolecek Exp $ */
/* $NetBSD: xennetback_xenbus.c,v 1.105 2020/05/05 17:02:01 bouyer Exp $ */
/*
* Copyright (c) 2006 Manuel Bouyer.
@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: xennetback_xenbus.c,v 1.104 2020/05/04 08:22:45 jdolecek Exp $");
__KERNEL_RCSID(0, "$NetBSD: xennetback_xenbus.c,v 1.105 2020/05/05 17:02:01 bouyer Exp $");
#include "opt_xen.h"
@ -52,6 +52,7 @@ __KERNEL_RCSID(0, "$NetBSD: xennetback_xenbus.c,v 1.104 2020/05/04 08:22:45 jdol
#include <net/if_ether.h>
#include <xen/hypervisor.h>
#include <xen/xen.h>
#include <xen/xen_shm.h>
#include <xen/evtchn.h>
@ -361,7 +362,7 @@ xennetback_xenbus_destroy(void *arg)
if (xneti->xni_ih != NULL) {
hypervisor_mask_event(xneti->xni_evtchn);
xen_intr_disestablish(xneti->xni_ih);
intr_disestablish(xneti->xni_ih);
xneti->xni_ih = NULL;
}
@ -528,7 +529,7 @@ xennetback_connect(struct xnetback_instance *xneti)
xneti->xni_status = CONNECTED;
xen_wmb();
xneti->xni_ih = xen_intr_establish_xname(-1, &xen_pic, xneti->xni_evtchn,
xneti->xni_ih = intr_establish_xname(-1, &xen_pic, xneti->xni_evtchn,
IST_LEVEL, IPL_NET, xennetback_evthandler, xneti, false,
xneti->xni_if.if_xname);
KASSERT(xneti->xni_ih != NULL);