CVS commit: [bouyer-xenpvh] src/sys/arch/xen/conf
Module Name:src Committed By: bouyer Date: Sat Apr 25 15:01:41 UTC 2020 Modified Files: src/sys/arch/xen/conf [bouyer-xenpvh]: files.xen Log Message: restore part accidentaly deleted To generate a diff of this commit: cvs rdiff -u -r1.180.2.8 -r1.180.2.9 src/sys/arch/xen/conf/files.xen Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/conf/files.xen diff -u src/sys/arch/xen/conf/files.xen:1.180.2.8 src/sys/arch/xen/conf/files.xen:1.180.2.9 --- src/sys/arch/xen/conf/files.xen:1.180.2.8 Sat Apr 25 13:16:48 2020 +++ src/sys/arch/xen/conf/files.xen Sat Apr 25 15:01:41 2020 @@ -1,4 +1,4 @@ -# $NetBSD: files.xen,v 1.180.2.8 2020/04/25 13:16:48 bouyer Exp $ +# $NetBSD: files.xen,v 1.180.2.9 2020/04/25 15:01:41 bouyer Exp $ defflag opt_xen.h XEN XENPVH XENPVHVM PAE @@ -10,3 +10,37 @@ file arch/xen/xen/xengnt.c xen file arch/xen/x86/xen_mainbus.c xen file arch/xen/xen/xen_clock.c xen file arch/xen/x86/xen_bus_dma.c xen + +define hypervisorbus {} +define xendevbus {} + +# Xen hypervisor +device hypervisor { [apid = -1]}: isabus, pcibus, sysmon_power, xendevbus, acpibus +attach hypervisor at hypervisorbus +file arch/xen/xen/hypervisor.c hypervisor needs-flag +file arch/xen/xen/shutdown_xenbus.c hypervisor + +# Xenbus +device xenbus {[id = -1]} +attach xenbus at xendevbus +file arch/xen/xenbus/xenbus_client.c xenbus needs-flag +file arch/xen/xenbus/xenbus_comms.c xenbus needs-flag +file arch/xen/xenbus/xenbus_dev.c xenbus needs-flag +file arch/xen/xenbus/xenbus_probe.c xenbus needs-flag +file arch/xen/xenbus/xenbus_xs.c xenbus needs-flag + +# Xen console support +device xencons: tty +attach xencons at xendevbus +file arch/xen/xen/xencons.c xencons needs-flag + +# Xen Network driver +device xennet: arp, ether, ifnet +attach xennet at xenbus +file arch/xen/xen/if_xennet_xenbus.c xennet needs-flag +file arch/xen/xen/xennet_checksum.c xvif | xennet + +# Xen Block device driver and wd/sd/cd identities +device xbd: disk +attach xbd at xenbus +file arch/xen/xen/xbd_xenbus.c xbd
CVS commit: [bouyer-xenpvh] src/sys/arch/xen/conf
Module Name:src Committed By: bouyer Date: Sat Apr 25 15:01:41 UTC 2020 Modified Files: src/sys/arch/xen/conf [bouyer-xenpvh]: files.xen Log Message: restore part accidentaly deleted To generate a diff of this commit: cvs rdiff -u -r1.180.2.8 -r1.180.2.9 src/sys/arch/xen/conf/files.xen Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [bouyer-xenpvh] src/sys/arch/xen/conf
Module Name:src Committed By: bouyer Date: Sat Apr 25 10:52:26 UTC 2020 Modified Files: src/sys/arch/xen/conf [bouyer-xenpvh]: files.compat files.xen files.xen.pv Log Message: Include again xen/conf/files.compat for PV kernels, and make it build. My build.sh -u used stale opt_*.h files ... To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.32.10.1 src/sys/arch/xen/conf/files.compat cvs rdiff -u -r1.180.2.6 -r1.180.2.7 src/sys/arch/xen/conf/files.xen cvs rdiff -u -r1.1.2.4 -r1.1.2.5 src/sys/arch/xen/conf/files.xen.pv Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/conf/files.compat diff -u src/sys/arch/xen/conf/files.compat:1.32 src/sys/arch/xen/conf/files.compat:1.32.10.1 --- src/sys/arch/xen/conf/files.compat:1.32 Sun Dec 9 00:45:18 2018 +++ src/sys/arch/xen/conf/files.compat Sat Apr 25 10:52:26 2020 @@ -1,16 +1,10 @@ -# $NetBSD: files.compat,v 1.32 2018/12/09 00:45:18 mrg Exp $ +# $NetBSD: files.compat,v 1.32.10.1 2020/04/25 10:52:26 bouyer Exp $ # NetBSD: files.x86,v 1.10 2003/10/08 17:30:00 bouyer Exp # options for MP configuration through the MP spec #defflag opt_mpbios.h MPBIOS MPVERBOSE MPDEBUG MPBIOS_SCANPCI #defflag opt_mpacpi.h MPACPI MPACPI_SCANPCI -# MTRR support -defflagMTRR - -defflag opt_xen.h XEN PAE - - # XXX define fake options to make config create the .h files defflag lapic.h XXXLAPIC defflag apm.h XXXAPM Index: src/sys/arch/xen/conf/files.xen diff -u src/sys/arch/xen/conf/files.xen:1.180.2.6 src/sys/arch/xen/conf/files.xen:1.180.2.7 --- src/sys/arch/xen/conf/files.xen:1.180.2.6 Mon Apr 20 19:40:24 2020 +++ src/sys/arch/xen/conf/files.xen Sat Apr 25 10:52:26 2020 @@ -1,6 +1,6 @@ -# $NetBSD: files.xen,v 1.180.2.6 2020/04/20 19:40:24 bouyer Exp $ +# $NetBSD: files.xen,v 1.180.2.7 2020/04/25 10:52:26 bouyer Exp $ -defflag opt_xen.h XEN XENPVH XENPVHVM +defflag opt_xen.h XEN XENPVH XENPVHVM PAE file arch/xen/x86/hypervisor_machdep.c xen file arch/xen/x86/xen_intr.c xen Index: src/sys/arch/xen/conf/files.xen.pv diff -u src/sys/arch/xen/conf/files.xen.pv:1.1.2.4 src/sys/arch/xen/conf/files.xen.pv:1.1.2.5 --- src/sys/arch/xen/conf/files.xen.pv:1.1.2.4 Mon Apr 20 19:40:24 2020 +++ src/sys/arch/xen/conf/files.xen.pv Sat Apr 25 10:52:26 2020 @@ -1,4 +1,4 @@ -# $NetBSD: files.xen.pv,v 1.1.2.4 2020/04/20 19:40:24 bouyer Exp $ +# $NetBSD: files.xen.pv,v 1.1.2.5 2020/04/25 10:52:26 bouyer Exp $ file arch/xen/x86/autoconf.c xenpv file arch/xen/x86/x86_xpmap.c xenpv @@ -11,6 +11,8 @@ file arch/xen/x86/pintr.c machdep & dom file arch/xen/x86/xen_ipi.c multiprocessor & xenpv +include "arch/xen/conf/files.compat" + # # System bus types #
CVS commit: [bouyer-xenpvh] src/sys/arch/xen/conf
Module Name:src Committed By: bouyer Date: Sat Apr 25 10:52:26 UTC 2020 Modified Files: src/sys/arch/xen/conf [bouyer-xenpvh]: files.compat files.xen files.xen.pv Log Message: Include again xen/conf/files.compat for PV kernels, and make it build. My build.sh -u used stale opt_*.h files ... To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.32.10.1 src/sys/arch/xen/conf/files.compat cvs rdiff -u -r1.180.2.6 -r1.180.2.7 src/sys/arch/xen/conf/files.xen cvs rdiff -u -r1.1.2.4 -r1.1.2.5 src/sys/arch/xen/conf/files.xen.pv Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [bouyer-xenpvh] src/sys/arch/xen/include
Module Name:src Committed By: bouyer Date: Sat Apr 25 10:51:25 UTC 2020 Modified Files: src/sys/arch/xen/include [bouyer-xenpvh]: Makefile Log Message: Also install xen/intrdefs.h To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.3.108.1 src/sys/arch/xen/include/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [bouyer-xenpvh] src/sys/arch/xen/include
Module Name:src Committed By: bouyer Date: Sat Apr 25 10:51:25 UTC 2020 Modified Files: src/sys/arch/xen/include [bouyer-xenpvh]: Makefile Log Message: Also install xen/intrdefs.h To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.3.108.1 src/sys/arch/xen/include/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/include/Makefile diff -u src/sys/arch/xen/include/Makefile:1.3 src/sys/arch/xen/include/Makefile:1.3.108.1 --- src/sys/arch/xen/include/Makefile:1.3 Sun Feb 17 16:23:12 2008 +++ src/sys/arch/xen/include/Makefile Sat Apr 25 10:51:25 2020 @@ -1,8 +1,8 @@ -# $NetBSD: Makefile,v 1.3 2008/02/17 16:23:12 bouyer Exp $ +# $NetBSD: Makefile,v 1.3.108.1 2020/04/25 10:51:25 bouyer Exp $ INCSDIR= /usr/include/xen -INCS= xenio.h xenio3.h +INCS= intrdefs.h xenio.h xenio3.h .include
CVS commit: [bouyer-xenpvh] src/sys/arch/xen/xen
Module Name:src Committed By: bouyer Date: Wed Apr 22 20:49:08 UTC 2020 Modified Files: src/sys/arch/xen/xen [bouyer-xenpvh]: hypervisor.c Log Message: Don't try to attach vcpu on !XENPV remove debug printf and other misc cosmetic changes To generate a diff of this commit: cvs rdiff -u -r1.73.2.8 -r1.73.2.9 src/sys/arch/xen/xen/hypervisor.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/xen/hypervisor.c diff -u src/sys/arch/xen/xen/hypervisor.c:1.73.2.8 src/sys/arch/xen/xen/hypervisor.c:1.73.2.9 --- src/sys/arch/xen/xen/hypervisor.c:1.73.2.8 Mon Apr 20 11:29:01 2020 +++ src/sys/arch/xen/xen/hypervisor.c Wed Apr 22 20:49:08 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: hypervisor.c,v 1.73.2.8 2020/04/20 11:29:01 bouyer Exp $ */ +/* $NetBSD: hypervisor.c,v 1.73.2.9 2020/04/22 20:49:08 bouyer Exp $ */ /* * Copyright (c) 2005 Manuel Bouyer. @@ -53,7 +53,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.73.2.8 2020/04/20 11:29:01 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.73.2.9 2020/04/22 20:49:08 bouyer Exp $"); #include #include @@ -399,8 +399,6 @@ xen_hvm_init_cpu(struct cpu_info *ci) vm_guest = VM_GUEST_XENHVM; return 0; } - printf("cpu %s ci_acpiid %d vcpuid %d domid %d\n", - device_xname(ci->ci_dev), ci->ci_acpiid, descs[1], descs[2]); ci->ci_vcpuid = descs[1]; ci->ci_vcpu = _shared_info->vcpu_info[ci->ci_vcpuid]; @@ -434,9 +432,9 @@ xen_hvm_init_cpu(struct cpu_info *ci) * From FreeBSD: * Trick toolstack to think we are enlightened */ + xen_hvm_param.value = 1; aprint_verbose_dev(ci->ci_dev, "using event upcall vector: %d\n", xen_hvm_vec ); - xen_hvm_param.value = 1; } } @@ -476,14 +474,14 @@ hypervisor_match(device_t parent, cfdata return 1; } -#ifdef MULTIPROCESSOR +#if defined(MULTIPROCESSOR) && defined(XENPV) static int hypervisor_vcpu_print(void *aux, const char *parent) { /* Unconfigured cpus are ignored quietly. */ return (QUIET); } -#endif /* MULTIPROCESSOR */ +#endif /* MULTIPROCESSOR && XENPV */ /* * Attach the hypervisor. @@ -591,6 +589,7 @@ hypervisor_attach(device_t parent, devic xengnt_init(); events_init(); +#ifdef XENPV memset(, 0, sizeof(hac)); hac.hac_vcaa.vcaa_name = "vcpu"; hac.hac_vcaa.vcaa_caa.cpu_number = 0; @@ -622,6 +621,7 @@ hypervisor_attach(device_t parent, devic } #endif /* MULTIPROCESSOR */ +#endif /* XENPV */ #if NXENBUS > 0 extern struct x86_bus_dma_tag xenbus_bus_dma_tag;
CVS commit: [bouyer-xenpvh] src/sys/arch/xen/xen
Module Name:src Committed By: bouyer Date: Wed Apr 22 20:49:08 UTC 2020 Modified Files: src/sys/arch/xen/xen [bouyer-xenpvh]: hypervisor.c Log Message: Don't try to attach vcpu on !XENPV remove debug printf and other misc cosmetic changes To generate a diff of this commit: cvs rdiff -u -r1.73.2.8 -r1.73.2.9 src/sys/arch/xen/xen/hypervisor.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [bouyer-xenpvh] src/sys/arch/xen/xen
Module Name:src Committed By: bouyer Date: Tue Apr 21 16:57:40 UTC 2020 Modified Files: src/sys/arch/xen/xen [bouyer-xenpvh]: xengnt.c Log Message: It is possible to use grant_v2 with HVM guest; but the status table has to be mapped using XENMEM_add_to_physmap. To generate a diff of this commit: cvs rdiff -u -r1.29.2.2 -r1.29.2.3 src/sys/arch/xen/xen/xengnt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [bouyer-xenpvh] src/sys/arch/xen/xen
Module Name:src Committed By: bouyer Date: Tue Apr 21 16:57:40 UTC 2020 Modified Files: src/sys/arch/xen/xen [bouyer-xenpvh]: xengnt.c Log Message: It is possible to use grant_v2 with HVM guest; but the status table has to be mapped using XENMEM_add_to_physmap. To generate a diff of this commit: cvs rdiff -u -r1.29.2.2 -r1.29.2.3 src/sys/arch/xen/xen/xengnt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/xen/xengnt.c diff -u src/sys/arch/xen/xen/xengnt.c:1.29.2.2 src/sys/arch/xen/xen/xengnt.c:1.29.2.3 --- src/sys/arch/xen/xen/xengnt.c:1.29.2.2 Mon Apr 20 19:42:10 2020 +++ src/sys/arch/xen/xen/xengnt.c Tue Apr 21 16:57:40 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: xengnt.c,v 1.29.2.2 2020/04/20 19:42:10 bouyer Exp $ */ +/* $NetBSD: xengnt.c,v 1.29.2.3 2020/04/21 16:57:40 bouyer Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xengnt.c,v 1.29.2.2 2020/04/20 19:42:10 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xengnt.c,v 1.29.2.3 2020/04/21 16:57:40 bouyer Exp $"); #include #include @@ -44,16 +44,6 @@ __KERNEL_RCSID(0, "$NetBSD: xengnt.c,v 1 #include "opt_xen.h" -/* - * grant table v2 is not supported for HVM guests on 4.11 at last. - * see xen/arch/x86/hvm/hypercall.c in Xen sources (missing - * GNTTABOP_get_status_frames) - */ - -#ifdef XENPV -#define USE_GRANT_V2 -#endif - /* #define XENDEBUG */ #ifdef XENDEBUG #define DPRINTF(x) printf x @@ -77,7 +67,6 @@ int last_gnt_entry; #define XENGNT_NO_ENTRY 0x /* VM address of the grant table */ -#ifdef USE_GRANT_V2 #define NR_GRANT_ENTRIES_PER_PAGE (PAGE_SIZE / sizeof(grant_entry_v2_t)) #define NR_GRANT_STATUS_PER_PAGE (PAGE_SIZE / sizeof(grant_status_t)) @@ -86,10 +75,6 @@ grant_entry_v2_t *grant_table; int gnt_status_frames; grant_status_t *grant_status; -#else /* USE_GRANT_V2 */ -#define NR_GRANT_ENTRIES_PER_PAGE (PAGE_SIZE / sizeof(grant_entry_v1_t)) -grant_entry_v1_t *grant_table; -#endif /* USE_GRANT_V2 */ kmutex_t grant_lock; static grant_ref_t xengnt_get_entry(void); @@ -118,13 +103,11 @@ xengnt_init(void) gnt_nr_grant_frames = gnt_max_grant_frames; -#ifdef USE_GRANT_V2 struct gnttab_set_version gntversion; gntversion.version = 2; rc = HYPERVISOR_grant_table_op(GNTTABOP_set_version, , 1); if (rc < 0 || gntversion.version != 2) panic("GNTTABOP_set_version 2 failed %d", rc); -#endif /* USE_GRANT_V2 */ nr_grant_entries = gnt_max_grant_frames * NR_GRANT_ENTRIES_PER_PAGE; @@ -139,14 +122,12 @@ xengnt_init(void) for (i = 0; i <= nr_grant_entries; i++) gnt_entries[i] = XENGNT_NO_ENTRY; -#ifdef USE_GRANT_V2 gnt_status_frames = round_page(nr_grant_entries * sizeof(grant_status_t)) / PAGE_SIZE; grant_status = (void *)uvm_km_alloc(kernel_map, gnt_status_frames * PAGE_SIZE, 0, UVM_KMF_VAONLY); if (grant_status == NULL) panic("xengnt_init() status no VM space"); -#endif /* USE_GRANT_V2 */ mutex_init(_lock, MUTEX_DEFAULT, IPL_VM); @@ -194,10 +175,8 @@ xengnt_suspend(void) { /* Remove virtual => machine mapping for grant table */ pmap_kremove((vaddr_t)grant_table, gnt_nr_grant_frames * PAGE_SIZE); -#ifdef USE_GRANT_V2 /* Remove virtual => machine mapping for status table */ pmap_kremove((vaddr_t)grant_status, gnt_status_frames * PAGE_SIZE); -#endif pmap_update(pmap_kernel()); mutex_exit(_lock); @@ -210,12 +189,8 @@ xengnt_suspend(void) { static int xengnt_map_status(void) { -#ifdef USE_GRANT_V2 - gnttab_get_status_frames_t getstatus; uint64_t *pages; size_t sz; - int err; - KASSERT(mutex_owned(_lock)); sz = gnt_status_frames * sizeof(*pages); @@ -223,6 +198,10 @@ xengnt_map_status(void) if (pages == NULL) return ENOMEM; +#ifdef XENPV + gnttab_get_status_frames_t getstatus; + int err; + getstatus.dom = DOMID_SELF; getstatus.nr_frames = gnt_status_frames; set_xen_guest_handle(getstatus.frame_list, pages); @@ -240,7 +219,23 @@ xengnt_map_status(void) kmem_free(pages, sz); return ENOMEM; } +#else /* XENPV */ + for (int i = 0; i < gnt_status_frames; i++) { + struct vm_page *pg; + struct xen_add_to_physmap xmap; + + pg = uvm_pagealloc(NULL, 0, NULL, UVM_PGA_USERESERVE|UVM_PGA_ZERO); + pages[i] = atop(uvm_vm_page_to_phys(pg)); + + xmap.domid = DOMID_SELF; + xmap.space = XENMAPSPACE_grant_table; + xmap.idx = i | XENMAPIDX_grant_table_status; + xmap.gpfn = pages[i]; + if (HYPERVISOR_memory_op(XENMEM_add_to_physmap, ) < 0) + panic("%s: Unable to add grant tables\n", __func__); + } +#endif /* XENPV */ /* * map between status_table addresses and the machine addresses of * the status table frames @@ -253,8 +248,6 @@ xengnt_map_status(void) pmap_update(pmap_kernel()); kmem_free(pages, sz); - -#endif /* USE_GRANT_V2 */ return 0; } @@ -298,7 +291,7 @@ xengnt_more_entries(void) xmap.gpfn =
CVS commit: [bouyer-xenpvh] src/sys/arch/xen
Module Name:src Committed By: bouyer Date: Mon Apr 20 19:46:44 UTC 2020 Modified Files: src/sys/arch/xen/include [bouyer-xenpvh]: evtchn.h src/sys/arch/xen/x86 [bouyer-xenpvh]: xen_ipi.c src/sys/arch/xen/xen [bouyer-xenpvh]: evtchn.c Log Message: Misc fixes after merge To generate a diff of this commit: cvs rdiff -u -r1.28.2.2 -r1.28.2.3 src/sys/arch/xen/include/evtchn.h cvs rdiff -u -r1.35.6.5 -r1.35.6.6 src/sys/arch/xen/x86/xen_ipi.c cvs rdiff -u -r1.88.2.10 -r1.88.2.11 src/sys/arch/xen/xen/evtchn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/include/evtchn.h diff -u src/sys/arch/xen/include/evtchn.h:1.28.2.2 src/sys/arch/xen/include/evtchn.h:1.28.2.3 --- src/sys/arch/xen/include/evtchn.h:1.28.2.2 Mon Apr 20 11:29:00 2020 +++ src/sys/arch/xen/include/evtchn.h Mon Apr 20 19:46:44 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: evtchn.h,v 1.28.2.2 2020/04/20 11:29:00 bouyer Exp $ */ +/* $NetBSD: evtchn.h,v 1.28.2.3 2020/04/20 19:46:44 bouyer Exp $ */ /* * @@ -41,8 +41,8 @@ bool events_resume(void); unsigned int evtchn_do_event(int, struct intrframe *); void call_evtchn_do_event(int, struct intrframe *); void call_xenevt_event(int); -int event_set_handler(int, int (*func)(void *), void *, int, const char *, -const char *, bool, bool); +struct intrhand *event_set_handler(int, int (*func)(void *), void *, +int, const char *, const char *, bool, bool); int event_remove_handler(int, int (*func)(void *), void *); struct cpu_info; Index: src/sys/arch/xen/x86/xen_ipi.c diff -u src/sys/arch/xen/x86/xen_ipi.c:1.35.6.5 src/sys/arch/xen/x86/xen_ipi.c:1.35.6.6 --- src/sys/arch/xen/x86/xen_ipi.c:1.35.6.5 Mon Apr 20 11:29:01 2020 +++ src/sys/arch/xen/x86/xen_ipi.c Mon Apr 20 19:46:44 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: xen_ipi.c,v 1.35.6.5 2020/04/20 11:29:01 bouyer Exp $ */ +/* $NetBSD: xen_ipi.c,v 1.35.6.6 2020/04/20 19:46:44 bouyer Exp $ */ /*- * Copyright (c) 2011, 2019 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ * Based on: x86/ipi.c */ -__KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.35.6.5 2020/04/20 11:29:01 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.35.6.6 2020/04/20 19:46:44 bouyer Exp $"); #include "opt_ddb.h" @@ -143,7 +143,7 @@ xen_ipi_init(void) device_xname(ci->ci_dev)); if (event_set_handler(evtchn, xen_ipi_handler, ci, IPL_HIGH, NULL, - intr_xname, true, false) != 0) { + intr_xname, true, false) == NULL) { panic("%s: unable to register ipi handler\n", __func__); /* NOTREACHED */ } Index: src/sys/arch/xen/xen/evtchn.c diff -u src/sys/arch/xen/xen/evtchn.c:1.88.2.10 src/sys/arch/xen/xen/evtchn.c:1.88.2.11 --- src/sys/arch/xen/xen/evtchn.c:1.88.2.10 Mon Apr 20 11:29:01 2020 +++ src/sys/arch/xen/xen/evtchn.c Mon Apr 20 19:46:44 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: evtchn.c,v 1.88.2.10 2020/04/20 11:29:01 bouyer Exp $ */ +/* $NetBSD: evtchn.c,v 1.88.2.11 2020/04/20 19:46:44 bouyer Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -54,7 +54,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.88.2.10 2020/04/20 11:29:01 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.88.2.11 2020/04/20 19:46:44 bouyer Exp $"); #include "opt_xen.h" #include "isa.h" @@ -885,10 +885,11 @@ event_set_handler(int evtch, int (*func) if (bind) { op.cmd = EVTCHNOP_bind_vcpu; op.u.bind_vcpu.port = evtch; - op.u.bind_vcpu.vcpu = ci->ci_cpuid; + op.u.bind_vcpu.vcpu = ci->ci_vcpuid; if (HYPERVISOR_event_channel_op() != 0) { -panic("Failed to bind event %d to " -"VCPU %"PRIuCPUID, evtch, ci->ci_cpuid); +panic("Failed to bind event %d to VCPU %s %d", +evtch, device_xname(ci->ci_dev), +ci->ci_vcpuid); } } } else { @@ -955,15 +956,14 @@ event_set_iplhandler(struct cpu_info *ci ipls->is_recurse = xenev_stubs[level - IPL_VM].ist_recurse; ipls->is_resume = xenev_stubs[level - IPL_VM].ist_resume; ipls->is_handlers = ih; - ipls->is_maxlevel = level; ipls->is_pic = _pic; ci->ci_isources[sir] = ipls; - x86_intr_calculatemasks(ci); } else { ipls = ci->ci_isources[sir]; ih->ih_next = ipls->is_handlers; ipls->is_handlers = ih; } + x86_intr_calculatemasks(ci); } int
CVS commit: [bouyer-xenpvh] src/sys/arch/xen
Module Name:src Committed By: bouyer Date: Mon Apr 20 19:46:44 UTC 2020 Modified Files: src/sys/arch/xen/include [bouyer-xenpvh]: evtchn.h src/sys/arch/xen/x86 [bouyer-xenpvh]: xen_ipi.c src/sys/arch/xen/xen [bouyer-xenpvh]: evtchn.c Log Message: Misc fixes after merge To generate a diff of this commit: cvs rdiff -u -r1.28.2.2 -r1.28.2.3 src/sys/arch/xen/include/evtchn.h cvs rdiff -u -r1.35.6.5 -r1.35.6.6 src/sys/arch/xen/x86/xen_ipi.c cvs rdiff -u -r1.88.2.10 -r1.88.2.11 src/sys/arch/xen/xen/evtchn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [bouyer-xenpvh] src/sys/arch/xen/xen
Module Name:src Committed By: bouyer Date: Mon Apr 20 19:42:10 UTC 2020 Modified Files: src/sys/arch/xen/xen [bouyer-xenpvh]: xengnt.c Log Message: Bad news: * grant table v2 is not supported for HVM guests on 4.11 at last. * see xen/arch/x86/hvm/hypercall.c in Xen sources (missing * GNTTABOP_get_status_frames) So restore grant table v1 for !XENPV To generate a diff of this commit: cvs rdiff -u -r1.29.2.1 -r1.29.2.2 src/sys/arch/xen/xen/xengnt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/xen/xengnt.c diff -u src/sys/arch/xen/xen/xengnt.c:1.29.2.1 src/sys/arch/xen/xen/xengnt.c:1.29.2.2 --- src/sys/arch/xen/xen/xengnt.c:1.29.2.1 Mon Apr 20 11:29:01 2020 +++ src/sys/arch/xen/xen/xengnt.c Mon Apr 20 19:42:10 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: xengnt.c,v 1.29.2.1 2020/04/20 11:29:01 bouyer Exp $ */ +/* $NetBSD: xengnt.c,v 1.29.2.2 2020/04/20 19:42:10 bouyer Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xengnt.c,v 1.29.2.1 2020/04/20 11:29:01 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xengnt.c,v 1.29.2.2 2020/04/20 19:42:10 bouyer Exp $"); #include #include @@ -42,6 +42,18 @@ __KERNEL_RCSID(0, "$NetBSD: xengnt.c,v 1 #include #include +#include "opt_xen.h" + +/* + * grant table v2 is not supported for HVM guests on 4.11 at last. + * see xen/arch/x86/hvm/hypercall.c in Xen sources (missing + * GNTTABOP_get_status_frames) + */ + +#ifdef XENPV +#define USE_GRANT_V2 +#endif + /* #define XENDEBUG */ #ifdef XENDEBUG #define DPRINTF(x) printf x @@ -49,9 +61,6 @@ __KERNEL_RCSID(0, "$NetBSD: xengnt.c,v 1 #define DPRINTF(x) #endif -#define NR_GRANT_ENTRIES_PER_PAGE (PAGE_SIZE / sizeof(grant_entry_v2_t)) -#define NR_GRANT_STATUS_PER_PAGE (PAGE_SIZE / sizeof(grant_status_t)) - /* External tools reserve first few grant table entries. */ #define NR_RESERVED_ENTRIES 8 @@ -59,8 +68,6 @@ __KERNEL_RCSID(0, "$NetBSD: xengnt.c,v 1 int gnt_nr_grant_frames; /* Maximum number of frames that can make up the grant table */ int gnt_max_grant_frames; -/* Number of grant status frames */ -int gnt_status_frames; /* table of free grant entries */ grant_ref_t *gnt_entries; @@ -70,8 +77,19 @@ int last_gnt_entry; #define XENGNT_NO_ENTRY 0x /* VM address of the grant table */ +#ifdef USE_GRANT_V2 +#define NR_GRANT_ENTRIES_PER_PAGE (PAGE_SIZE / sizeof(grant_entry_v2_t)) +#define NR_GRANT_STATUS_PER_PAGE (PAGE_SIZE / sizeof(grant_status_t)) + grant_entry_v2_t *grant_table; +/* Number of grant status frames */ +int gnt_status_frames; + grant_status_t *grant_status; +#else /* USE_GRANT_V2 */ +#define NR_GRANT_ENTRIES_PER_PAGE (PAGE_SIZE / sizeof(grant_entry_v1_t)) +grant_entry_v1_t *grant_table; +#endif /* USE_GRANT_V2 */ kmutex_t grant_lock; static grant_ref_t xengnt_get_entry(void); @@ -83,7 +101,6 @@ void xengnt_init(void) { struct gnttab_query_size query; - struct gnttab_set_version gntversion; int rc; int nr_grant_entries; int i; @@ -100,10 +117,14 @@ xengnt_init(void) */ gnt_nr_grant_frames = gnt_max_grant_frames; + +#ifdef USE_GRANT_V2 + struct gnttab_set_version gntversion; gntversion.version = 2; rc = HYPERVISOR_grant_table_op(GNTTABOP_set_version, , 1); if (rc < 0 || gntversion.version != 2) panic("GNTTABOP_set_version 2 failed %d", rc); +#endif /* USE_GRANT_V2 */ nr_grant_entries = gnt_max_grant_frames * NR_GRANT_ENTRIES_PER_PAGE; @@ -118,12 +139,14 @@ xengnt_init(void) for (i = 0; i <= nr_grant_entries; i++) gnt_entries[i] = XENGNT_NO_ENTRY; +#ifdef USE_GRANT_V2 gnt_status_frames = round_page(nr_grant_entries * sizeof(grant_status_t)) / PAGE_SIZE; grant_status = (void *)uvm_km_alloc(kernel_map, gnt_status_frames * PAGE_SIZE, 0, UVM_KMF_VAONLY); if (grant_status == NULL) panic("xengnt_init() status no VM space"); +#endif /* USE_GRANT_V2 */ mutex_init(_lock, MUTEX_DEFAULT, IPL_VM); @@ -171,8 +194,10 @@ xengnt_suspend(void) { /* Remove virtual => machine mapping for grant table */ pmap_kremove((vaddr_t)grant_table, gnt_nr_grant_frames * PAGE_SIZE); +#ifdef USE_GRANT_V2 /* Remove virtual => machine mapping for status table */ pmap_kremove((vaddr_t)grant_status, gnt_status_frames * PAGE_SIZE); +#endif pmap_update(pmap_kernel()); mutex_exit(_lock); @@ -185,9 +210,11 @@ xengnt_suspend(void) { static int xengnt_map_status(void) { +#ifdef USE_GRANT_V2 gnttab_get_status_frames_t getstatus; uint64_t *pages; size_t sz; + int err; KASSERT(mutex_owned(_lock)); @@ -204,9 +231,9 @@ xengnt_map_status(void) * get the status frames, and return the list of their virtual * addresses in 'pages' */ - if (HYPERVISOR_grant_table_op(GNTTABOP_get_status_frames, - , 1) != 0) - panic("%s: get_status_frames failed", __func__); + if ((err =
CVS commit: [bouyer-xenpvh] src/sys/arch/xen/xen
Module Name:src Committed By: bouyer Date: Mon Apr 20 19:42:10 UTC 2020 Modified Files: src/sys/arch/xen/xen [bouyer-xenpvh]: xengnt.c Log Message: Bad news: * grant table v2 is not supported for HVM guests on 4.11 at last. * see xen/arch/x86/hvm/hypercall.c in Xen sources (missing * GNTTABOP_get_status_frames) So restore grant table v1 for !XENPV To generate a diff of this commit: cvs rdiff -u -r1.29.2.1 -r1.29.2.2 src/sys/arch/xen/xen/xengnt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [bouyer-xenpvh] src/sys/arch/xen/xen
Module Name:src Committed By: bouyer Date: Mon Apr 20 19:40:51 UTC 2020 Modified Files: src/sys/arch/xen/xen [bouyer-xenpvh]: xbdback_xenbus.c Log Message: Fix build with DIAGNOSTIC To generate a diff of this commit: cvs rdiff -u -r1.77.2.2 -r1.77.2.3 src/sys/arch/xen/xen/xbdback_xenbus.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [bouyer-xenpvh] src/sys/arch/xen/xen
Module Name:src Committed By: bouyer Date: Mon Apr 20 19:40:51 UTC 2020 Modified Files: src/sys/arch/xen/xen [bouyer-xenpvh]: xbdback_xenbus.c Log Message: Fix build with DIAGNOSTIC To generate a diff of this commit: cvs rdiff -u -r1.77.2.2 -r1.77.2.3 src/sys/arch/xen/xen/xbdback_xenbus.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/xen/xbdback_xenbus.c diff -u src/sys/arch/xen/xen/xbdback_xenbus.c:1.77.2.2 src/sys/arch/xen/xen/xbdback_xenbus.c:1.77.2.3 --- src/sys/arch/xen/xen/xbdback_xenbus.c:1.77.2.2 Mon Apr 20 18:50:46 2020 +++ src/sys/arch/xen/xen/xbdback_xenbus.c Mon Apr 20 19:40:51 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: xbdback_xenbus.c,v 1.77.2.2 2020/04/20 18:50:46 bouyer Exp $ */ +/* $NetBSD: xbdback_xenbus.c,v 1.77.2.3 2020/04/20 19:40:51 bouyer Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.77.2.2 2020/04/20 18:50:46 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.77.2.3 2020/04/20 19:40:51 bouyer Exp $"); #include #include @@ -1049,7 +1049,6 @@ xbdback_co_main_done2(struct xbdback_ins { int work_to_do; - KASSERT(xbdi->xbdio_io == NULL); RING_FINAL_CHECK_FOR_REQUESTS(>xbdi_ring.ring_n, work_to_do); if (work_to_do) xbdi->xbdi_cont = xbdback_co_main; @@ -1233,7 +1232,6 @@ static void * xbdback_co_do_io(struct xbdback_instance *xbdi, void *obj) { struct xbdback_io *xbd_io = xbdi->xbdi_io; - int nsegs __diagused; switch (xbd_io->xio_operation) { case BLKIF_OP_FLUSH_DISKCACHE:
CVS commit: [bouyer-xenpvh] src/sys/arch/xen
Module Name:src Committed By: bouyer Date: Mon Apr 20 19:40:24 UTC 2020 Modified Files: src/sys/arch/xen/conf [bouyer-xenpvh]: files.xen files.xen.pv src/sys/arch/xen/x86 [bouyer-xenpvh]: xen_bus_dma.c Log Message: We need xenbus_bus_dma_tag for PVHVM too, but without phys->machine translation To generate a diff of this commit: cvs rdiff -u -r1.180.2.5 -r1.180.2.6 src/sys/arch/xen/conf/files.xen cvs rdiff -u -r1.1.2.3 -r1.1.2.4 src/sys/arch/xen/conf/files.xen.pv cvs rdiff -u -r1.28.10.1 -r1.28.10.2 src/sys/arch/xen/x86/xen_bus_dma.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/conf/files.xen diff -u src/sys/arch/xen/conf/files.xen:1.180.2.5 src/sys/arch/xen/conf/files.xen:1.180.2.6 --- src/sys/arch/xen/conf/files.xen:1.180.2.5 Sun Apr 19 20:29:30 2020 +++ src/sys/arch/xen/conf/files.xen Mon Apr 20 19:40:24 2020 @@ -1,4 +1,4 @@ -# $NetBSD: files.xen,v 1.180.2.5 2020/04/19 20:29:30 bouyer Exp $ +# $NetBSD: files.xen,v 1.180.2.6 2020/04/20 19:40:24 bouyer Exp $ defflag opt_xen.h XEN XENPVH XENPVHVM @@ -9,6 +9,7 @@ file arch/xen/xen/evtchn.c xen file arch/xen/xen/xengnt.c xen file arch/xen/x86/xen_mainbus.c xen file arch/xen/xen/xen_clock.c xen +file arch/xen/x86/xen_bus_dma.c xen define hypervisorbus {} define xendevbus {} Index: src/sys/arch/xen/conf/files.xen.pv diff -u src/sys/arch/xen/conf/files.xen.pv:1.1.2.3 src/sys/arch/xen/conf/files.xen.pv:1.1.2.4 --- src/sys/arch/xen/conf/files.xen.pv:1.1.2.3 Sun Apr 19 20:29:30 2020 +++ src/sys/arch/xen/conf/files.xen.pv Mon Apr 20 19:40:24 2020 @@ -1,4 +1,4 @@ -# $NetBSD: files.xen.pv,v 1.1.2.3 2020/04/19 20:29:30 bouyer Exp $ +# $NetBSD: files.xen.pv,v 1.1.2.4 2020/04/20 19:40:24 bouyer Exp $ file arch/xen/x86/autoconf.c xenpv file arch/xen/x86/x86_xpmap.c xenpv @@ -6,7 +6,6 @@ file arch/xen/x86/xen_pmap.c xenpv file arch/xen/x86/xenfunc.c xenpv file arch/xen/xen/xen_acpi_machdep.c acpi & xenpv -file arch/xen/x86/xen_bus_dma.c machdep & xenpv file arch/xen/x86/consinit.c machdep & xenpv file arch/xen/x86/pintr.c machdep & dom0ops & xenpv Index: src/sys/arch/xen/x86/xen_bus_dma.c diff -u src/sys/arch/xen/x86/xen_bus_dma.c:1.28.10.1 src/sys/arch/xen/x86/xen_bus_dma.c:1.28.10.2 --- src/sys/arch/xen/x86/xen_bus_dma.c:1.28.10.1 Mon Apr 20 11:29:01 2020 +++ src/sys/arch/xen/x86/xen_bus_dma.c Mon Apr 20 19:40:23 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: xen_bus_dma.c,v 1.28.10.1 2020/04/20 11:29:01 bouyer Exp $ */ +/* $NetBSD: xen_bus_dma.c,v 1.28.10.2 2020/04/20 19:40:23 bouyer Exp $ */ /* NetBSD bus_dma.c,v 1.21 2005/04/16 07:53:35 yamt Exp */ /*- @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xen_bus_dma.c,v 1.28.10.1 2020/04/20 11:29:01 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xen_bus_dma.c,v 1.28.10.2 2020/04/20 19:40:23 bouyer Exp $"); #include #include @@ -45,7 +45,7 @@ __KERNEL_RCSID(0, "$NetBSD: xen_bus_dma. #include -extern paddr_t avail_end; +#include "opt_xen.h" /* No special needs */ struct x86_bus_dma_tag xenbus_bus_dma_tag = { @@ -56,6 +56,10 @@ struct x86_bus_dma_tag xenbus_bus_dma_ta ._may_bounce = NULL, }; +#ifdef XENPV + +extern paddr_t avail_end; + /* Pure 2^n version of get_order */ static inline int get_order(unsigned long size) { @@ -318,3 +322,4 @@ dorealloc: return error; goto again; } +#endif /* XENPV */
CVS commit: [bouyer-xenpvh] src/sys/arch/xen
Module Name:src Committed By: bouyer Date: Mon Apr 20 19:40:24 UTC 2020 Modified Files: src/sys/arch/xen/conf [bouyer-xenpvh]: files.xen files.xen.pv src/sys/arch/xen/x86 [bouyer-xenpvh]: xen_bus_dma.c Log Message: We need xenbus_bus_dma_tag for PVHVM too, but without phys->machine translation To generate a diff of this commit: cvs rdiff -u -r1.180.2.5 -r1.180.2.6 src/sys/arch/xen/conf/files.xen cvs rdiff -u -r1.1.2.3 -r1.1.2.4 src/sys/arch/xen/conf/files.xen.pv cvs rdiff -u -r1.28.10.1 -r1.28.10.2 src/sys/arch/xen/x86/xen_bus_dma.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [bouyer-xenpvh] src/sys/arch/xen/xen
Module Name:src Committed By: bouyer Date: Mon Apr 20 18:50:46 UTC 2020 Modified Files: src/sys/arch/xen/xen [bouyer-xenpvh]: xbdback_xenbus.c Log Message: Bring in 1.82 and 1.83 from HEAD To generate a diff of this commit: cvs rdiff -u -r1.77.2.1 -r1.77.2.2 src/sys/arch/xen/xen/xbdback_xenbus.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [bouyer-xenpvh] src/sys/arch/xen/xen
Module Name:src Committed By: bouyer Date: Mon Apr 20 18:50:46 UTC 2020 Modified Files: src/sys/arch/xen/xen [bouyer-xenpvh]: xbdback_xenbus.c Log Message: Bring in 1.82 and 1.83 from HEAD To generate a diff of this commit: cvs rdiff -u -r1.77.2.1 -r1.77.2.2 src/sys/arch/xen/xen/xbdback_xenbus.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/xen/xbdback_xenbus.c diff -u src/sys/arch/xen/xen/xbdback_xenbus.c:1.77.2.1 src/sys/arch/xen/xen/xbdback_xenbus.c:1.77.2.2 --- src/sys/arch/xen/xen/xbdback_xenbus.c:1.77.2.1 Mon Apr 20 11:29:01 2020 +++ src/sys/arch/xen/xen/xbdback_xenbus.c Mon Apr 20 18:50:46 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: xbdback_xenbus.c,v 1.77.2.1 2020/04/20 11:29:01 bouyer Exp $ */ +/* $NetBSD: xbdback_xenbus.c,v 1.77.2.2 2020/04/20 18:50:46 bouyer Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.77.2.1 2020/04/20 11:29:01 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.77.2.2 2020/04/20 18:50:46 bouyer Exp $"); #include #include @@ -74,9 +74,7 @@ __KERNEL_RCSID(0, "$NetBSD: xbdback_xenb /* Need to alloc one extra page to account for possible mapping offset */ #define VBD_VA_SIZE (MAXPHYS + PAGE_SIZE) -struct xbdback_request; struct xbdback_io; -struct xbdback_fragment; struct xbdback_instance; /* @@ -98,8 +96,8 @@ typedef enum {WAITING, RUN, DISCONNECTIN * callback), the return value of a continuation can be set to NULL. In that * case, the thread will go back to sleeping and wait for the proper * condition before it starts processing requests again from where it left. - * Continuation state is "stored" in the xbdback instance (xbdi_cont and - * xbdi_cont_aux), and should only be manipulated by the instance thread. + * Continuation state is "stored" in the xbdback instance (xbdi_cont), + * and should only be manipulated by the instance thread. * * As xbdback(4) has to handle different sort of asynchronous events (Xen * event channels, biointr() soft interrupts, xenbus commands), the xbdi_lock @@ -109,36 +107,23 @@ typedef enum {WAITING, RUN, DISCONNECTIN * Here's how the call graph is supposed to be for a single I/O: * * xbdback_co_main() - *| - *| --> xbdback_co_cache_doflush() or NULL - *| | - *| - xbdback_co_cache_flush2() <- xbdback_co_do_io() <- - *|| | - *| |-> xbdback_co_cache_flush() -> xbdback_co_map_io()- + *| --> xbdback_co_cache_flush() + *| || + *| |-> xbdback_co_cache_doflush() or NULL + *| || + *| |-> xbdback_co_do_io() * xbdback_co_main_loop()-| - *| |-> xbdback_co_main_done() ---> xbdback_co_map_io()- - *| | | - *| -- xbdback_co_main_done2() <-- xbdback_co_do_io() <- + *| |-> xbdback_co_main_done2() or NULL *| | - *| --> xbdback_co_main() or NULL + *| --> xbdback_co_main_incr() -> xbdback_co_main_loop() *| * xbdback_co_io() -> xbdback_co_main_incr() -> xbdback_co_main_loop() *| - * xbdback_co_io_gotreq()--+--> xbdback_co_map_io() --- - *|| | - * -> xbdback_co_io_loop()| <- xbdback_co_do_io() <-- - * | | | | - * | | | |--> xbdback_co_io_gotio() - * | | | | - * | | xbdback_co_main_incr() | - * | | | | - * | | xbdback_co_main_loop() | - * | | | - * | xbdback_co_io_gotio2() <---| - * | | | - * | | |--> xbdback_co_io_gotfrag() - * | | | - * -- xbdback_co_io_gotfrag2() <-| + * xbdback_co_io_gotio() -> xbdback_map_shm() + *| | + *| xbdback_co_main_incr() -> xbdback_co_main_loop() + *| + * xbdback_co_do_io() *| * xbdback_co_main_incr() -> xbdback_co_main_loop() */ @@ -192,17 +177,12 @@ struct xbdback_instance { * continuation-ness (see above). */ RING_IDX xbdi_req_prod; /* limit on request indices */ - xbdback_cont_t xbdi_cont, xbdi_cont_aux; + xbdback_cont_t xbdi_cont; /* _request state: track requests fetched from ring */ struct xbdback_request *xbdi_req; /* if NULL, ignore following */ blkif_request_t xbdi_xen_req; - int xbdi_segno; /* _io state: I/O
CVS commit: [bouyer-xenpvh] src/sys/arch/xen
Module Name:src Committed By: bouyer Date: Sun Apr 19 20:29:30 UTC 2020 Modified Files: src/sys/arch/xen/conf [bouyer-xenpvh]: files.xen files.xen.pv src/sys/arch/xen/x86 [bouyer-xenpvh]: hypervisor_machdep.c src/sys/arch/xen/xen [bouyer-xenpvh]: evtchn.c Log Message: Move xen_ipi.c to XENPV only. Make sure we don't need to send events to remote CPUs (outside of IPIs) To generate a diff of this commit: cvs rdiff -u -r1.180.2.4 -r1.180.2.5 src/sys/arch/xen/conf/files.xen cvs rdiff -u -r1.1.2.2 -r1.1.2.3 src/sys/arch/xen/conf/files.xen.pv cvs rdiff -u -r1.36.8.4 -r1.36.8.5 src/sys/arch/xen/x86/hypervisor_machdep.c cvs rdiff -u -r1.88.2.8 -r1.88.2.9 src/sys/arch/xen/xen/evtchn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/conf/files.xen diff -u src/sys/arch/xen/conf/files.xen:1.180.2.4 src/sys/arch/xen/conf/files.xen:1.180.2.5 --- src/sys/arch/xen/conf/files.xen:1.180.2.4 Thu Apr 16 19:23:50 2020 +++ src/sys/arch/xen/conf/files.xen Sun Apr 19 20:29:30 2020 @@ -1,4 +1,4 @@ -# $NetBSD: files.xen,v 1.180.2.4 2020/04/16 19:23:50 bouyer Exp $ +# $NetBSD: files.xen,v 1.180.2.5 2020/04/19 20:29:30 bouyer Exp $ defflag opt_xen.h XEN XENPVH XENPVHVM @@ -7,7 +7,6 @@ file arch/xen/x86/xen_intr.c xen file arch/xen/xen/xen_machdep.c xen file arch/xen/xen/evtchn.c xen file arch/xen/xen/xengnt.c xen -file arch/xen/x86/xen_ipi.c multiprocessor & xen file arch/xen/x86/xen_mainbus.c xen file arch/xen/xen/xen_clock.c xen Index: src/sys/arch/xen/conf/files.xen.pv diff -u src/sys/arch/xen/conf/files.xen.pv:1.1.2.2 src/sys/arch/xen/conf/files.xen.pv:1.1.2.3 --- src/sys/arch/xen/conf/files.xen.pv:1.1.2.2 Thu Apr 16 19:23:50 2020 +++ src/sys/arch/xen/conf/files.xen.pv Sun Apr 19 20:29:30 2020 @@ -1,4 +1,4 @@ -# $NetBSD: files.xen.pv,v 1.1.2.2 2020/04/16 19:23:50 bouyer Exp $ +# $NetBSD: files.xen.pv,v 1.1.2.3 2020/04/19 20:29:30 bouyer Exp $ file arch/xen/x86/autoconf.c xenpv file arch/xen/x86/x86_xpmap.c xenpv @@ -10,6 +10,8 @@ file arch/xen/x86/xen_bus_dma.c machdep file arch/xen/x86/consinit.c machdep & xenpv file arch/xen/x86/pintr.c machdep & dom0ops & xenpv +file arch/xen/x86/xen_ipi.c multiprocessor & xenpv + # # System bus types # Index: src/sys/arch/xen/x86/hypervisor_machdep.c diff -u src/sys/arch/xen/x86/hypervisor_machdep.c:1.36.8.4 src/sys/arch/xen/x86/hypervisor_machdep.c:1.36.8.5 --- src/sys/arch/xen/x86/hypervisor_machdep.c:1.36.8.4 Sat Apr 18 15:06:18 2020 +++ src/sys/arch/xen/x86/hypervisor_machdep.c Sun Apr 19 20:29:30 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: hypervisor_machdep.c,v 1.36.8.4 2020/04/18 15:06:18 bouyer Exp $ */ +/* $NetBSD: hypervisor_machdep.c,v 1.36.8.5 2020/04/19 20:29:30 bouyer Exp $ */ /* * @@ -54,7 +54,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.36.8.4 2020/04/18 15:06:18 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.36.8.5 2020/04/19 20:29:30 bouyer Exp $"); #include #include @@ -291,6 +291,7 @@ do_hypervisor_callback(struct intrframe #endif } +#if 0 void hypervisor_send_event(struct cpu_info *ci, unsigned int ev) { @@ -323,6 +324,7 @@ hypervisor_send_event(struct cpu_info *c } } } +#endif void hypervisor_unmask_event(unsigned int ev) @@ -422,6 +424,8 @@ hypervisor_set_ipending(uint32_t imask, KASSERT(ci->ci_isources[sir] != NULL); ci->ci_isources[sir]->ipl_evt_mask1 |= 1UL << l1; ci->ci_isources[sir]->ipl_evt_mask2[l1] |= 1UL << l2; + KASSERT(ci == curcpu()); +#if 0 if (__predict_false(ci != curcpu())) { if (xen_send_ipi(ci, XEN_IPI_HVCB)) { panic("hypervisor_set_ipending: " @@ -429,6 +433,7 @@ hypervisor_set_ipending(uint32_t imask, (int) ci->ci_cpuid, ci->ci_vcpuid); } } +#endif } void Index: src/sys/arch/xen/xen/evtchn.c diff -u src/sys/arch/xen/xen/evtchn.c:1.88.2.8 src/sys/arch/xen/xen/evtchn.c:1.88.2.9 --- src/sys/arch/xen/xen/evtchn.c:1.88.2.8 Sun Apr 19 19:39:11 2020 +++ src/sys/arch/xen/xen/evtchn.c Sun Apr 19 20:29:30 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: evtchn.c,v 1.88.2.8 2020/04/19 19:39:11 bouyer Exp $ */ +/* $NetBSD: evtchn.c,v 1.88.2.9 2020/04/19 20:29:30 bouyer Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -54,7 +54,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.88.2.8 2020/04/19 19:39:11 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.88.2.9 2020/04/19 20:29:30 bouyer Exp $"); #include "opt_xen.h" #include "isa.h" @@ -376,12 +376,15 @@ evtchn_do_event(int evtch, struct intrfr mutex_spin_enter([evtch]); ih = evtsource[evtch]->ev_handlers; while (ih != NULL) { + KASSERT(ih->ih_cpu == ci); +#if 0 if (ih->ih_cpu != ci) { hypervisor_send_event(ih->ih_cpu, evtch); iplmask &= ~(1 << XEN_IPL2SIR(ih->ih_level)); ih = ih->ih_evt_next; continue; } +#endif if (ih->ih_level <= ilevel) { #ifdef IRQ_DEBUG if
CVS commit: [bouyer-xenpvh] src/sys/arch/xen
Module Name:src Committed By: bouyer Date: Sun Apr 19 20:29:30 UTC 2020 Modified Files: src/sys/arch/xen/conf [bouyer-xenpvh]: files.xen files.xen.pv src/sys/arch/xen/x86 [bouyer-xenpvh]: hypervisor_machdep.c src/sys/arch/xen/xen [bouyer-xenpvh]: evtchn.c Log Message: Move xen_ipi.c to XENPV only. Make sure we don't need to send events to remote CPUs (outside of IPIs) To generate a diff of this commit: cvs rdiff -u -r1.180.2.4 -r1.180.2.5 src/sys/arch/xen/conf/files.xen cvs rdiff -u -r1.1.2.2 -r1.1.2.3 src/sys/arch/xen/conf/files.xen.pv cvs rdiff -u -r1.36.8.4 -r1.36.8.5 src/sys/arch/xen/x86/hypervisor_machdep.c cvs rdiff -u -r1.88.2.8 -r1.88.2.9 src/sys/arch/xen/xen/evtchn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [bouyer-xenpvh] src/sys/arch/xen/xen
Module Name:src Committed By: bouyer Date: Sat Apr 18 20:36:31 UTC 2020 Modified Files: src/sys/arch/xen/xen [bouyer-xenpvh]: evtchn.c Log Message: If we get an event for another CPU just ignore it. The hypervisor will callback on the other CPU anyway. To generate a diff of this commit: cvs rdiff -u -r1.88.2.5 -r1.88.2.6 src/sys/arch/xen/xen/evtchn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/xen/evtchn.c diff -u src/sys/arch/xen/xen/evtchn.c:1.88.2.5 src/sys/arch/xen/xen/evtchn.c:1.88.2.6 --- src/sys/arch/xen/xen/evtchn.c:1.88.2.5 Sat Apr 18 15:06:18 2020 +++ src/sys/arch/xen/xen/evtchn.c Sat Apr 18 20:36:31 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: evtchn.c,v 1.88.2.5 2020/04/18 15:06:18 bouyer Exp $ */ +/* $NetBSD: evtchn.c,v 1.88.2.6 2020/04/18 20:36:31 bouyer Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -54,7 +54,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.88.2.5 2020/04/18 15:06:18 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.88.2.6 2020/04/18 20:36:31 bouyer Exp $"); #include "opt_xen.h" #include "isa.h" @@ -341,15 +341,14 @@ evtchn_do_event(int evtch, struct intrfr } KASSERTMSG(evtsource[evtch] != NULL, "unknown event %d", evtch); + + if (evtsource[evtch]->ev_cpu != ci) + return 0; + ci->ci_data.cpu_nintr++; evtsource[evtch]->ev_evcnt.ev_count++; ilevel = ci->ci_ilevel; - if (evtsource[evtch]->ev_cpu != ci /* XXX: get stats */) { - hypervisor_send_event(evtsource[evtch]->ev_cpu, evtch); - return 0; - } - if (evtsource[evtch]->ev_maxlevel <= ilevel) { #ifdef IRQ_DEBUG if (evtch == IRQ_DEBUG)
CVS commit: [bouyer-xenpvh] src/sys/arch/xen/xen
Module Name:src Committed By: bouyer Date: Sat Apr 18 20:36:31 UTC 2020 Modified Files: src/sys/arch/xen/xen [bouyer-xenpvh]: evtchn.c Log Message: If we get an event for another CPU just ignore it. The hypervisor will callback on the other CPU anyway. To generate a diff of this commit: cvs rdiff -u -r1.88.2.5 -r1.88.2.6 src/sys/arch/xen/xen/evtchn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [bouyer-xenpvh] src/sys/arch/xen/xen
Module Name:src Committed By: bouyer Date: Thu Apr 16 20:21:45 UTC 2020 Modified Files: src/sys/arch/xen/xen [bouyer-xenpvh]: xen_clock.c Log Message: MOve the #ifdef XENPV block to the end, so that XEN3_DOM0 builds again. To generate a diff of this commit: cvs rdiff -u -r1.1.2.1 -r1.1.2.2 src/sys/arch/xen/xen/xen_clock.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [bouyer-xenpvh] src/sys/arch/xen/xen
Module Name:src Committed By: bouyer Date: Thu Apr 16 20:21:45 UTC 2020 Modified Files: src/sys/arch/xen/xen [bouyer-xenpvh]: xen_clock.c Log Message: MOve the #ifdef XENPV block to the end, so that XEN3_DOM0 builds again. To generate a diff of this commit: cvs rdiff -u -r1.1.2.1 -r1.1.2.2 src/sys/arch/xen/xen/xen_clock.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/xen/xen_clock.c diff -u src/sys/arch/xen/xen/xen_clock.c:1.1.2.1 src/sys/arch/xen/xen/xen_clock.c:1.1.2.2 --- src/sys/arch/xen/xen/xen_clock.c:1.1.2.1 Thu Apr 16 19:23:50 2020 +++ src/sys/arch/xen/xen/xen_clock.c Thu Apr 16 20:21:44 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: xen_clock.c,v 1.1.2.1 2020/04/16 19:23:50 bouyer Exp $ */ +/* $NetBSD: xen_clock.c,v 1.1.2.2 2020/04/16 20:21:44 bouyer Exp $ */ /*- * Copyright (c) 2017, 2018 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ #endif #include -__KERNEL_RCSID(0, "$NetBSD: xen_clock.c,v 1.1.2.1 2020/04/16 19:23:50 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xen_clock.c,v 1.1.2.2 2020/04/16 20:21:44 bouyer Exp $"); #include #include @@ -114,128 +114,6 @@ static void xen_timepush_intr(void *); static int sysctl_xen_timepush(SYSCTLFN_ARGS); #endif -#ifdef XENPV -static int xen_rtc_get(struct todr_chip_handle *, struct timeval *); -static int xen_rtc_set(struct todr_chip_handle *, struct timeval *); -static void xen_wallclock_time(struct timespec *); -/* - * xen time of day register: - * - * Xen wall clock time, plus a Xen vCPU system time adjustment. - */ -static struct todr_chip_handle xen_todr_chip = { - .todr_gettime = xen_rtc_get, - .todr_settime = xen_rtc_set, -}; - -/* - * startrtclock() - * - * Initialize the real-time clock from x86 machdep autoconf. - */ -void -startrtclock(void) -{ - - todr_attach(_todr_chip); -} - -/* - * setstatclockrate(rate) - * - * Set the statclock to run at rate, in units of ticks per second. - * - * Currently Xen does not have a separate statclock, so this is a - * noop; instad the statclock runs in hardclock. - */ -void -setstatclockrate(int rate) -{ -} - -/* - * xen_rtc_get(todr, tv) - * - * Get the current real-time clock from the Xen wall clock time - * and vCPU system time adjustment. - */ -static int -xen_rtc_get(struct todr_chip_handle *todr, struct timeval *tvp) -{ - struct timespec ts; - - xen_wallclock_time(); - TIMESPEC_TO_TIMEVAL(tvp, ); - - return 0; -} - -/* - * xen_rtc_set(todr, tv) - * - * Set the Xen wall clock time, if we can. - */ -static int -xen_rtc_set(struct todr_chip_handle *todr, struct timeval *tvp) -{ -#ifdef DOM0OPS - struct clock_ymdhms dt; - xen_platform_op_t op; - uint64_t systime_ns; - - if (xendomain_is_privileged()) { - /* Convert to ymdhms and set the x86 ISA RTC. */ - clock_secs_to_ymdhms(tvp->tv_sec, ); - rtc_set_ymdhms(NULL, ); - - /* Get the global system time so we can preserve it. */ - systime_ns = xen_global_systime_ns(); - - /* Set the hypervisor wall clock time. */ - op.cmd = XENPF_settime; - op.u.settime.secs = tvp->tv_sec; - op.u.settime.nsecs = tvp->tv_usec * 1000; - op.u.settime.system_time = systime_ns; - return HYPERVISOR_platform_op(); - } -#endif - - /* XXX Should this fail if not on privileged dom0? */ - return 0; -} - -/* - * xen_wallclock_time(tsp) - * - * Return a snapshot of the current low-resolution wall clock - * time, as reported by the hypervisor, in tsp. - */ -static void -xen_wallclock_time(struct timespec *tsp) -{ - struct xen_wallclock_ticket ticket; - uint64_t systime_ns; - - int s = splsched(); /* make sure we won't be interrupted */ - /* Read the last wall clock sample from the hypervisor. */ - do { - xen_wallclock_enter(); - tsp->tv_sec = HYPERVISOR_shared_info->wc_sec; - tsp->tv_nsec = HYPERVISOR_shared_info->wc_nsec; - } while (!xen_wallclock_exit()); - - /* Get the global system time. */ - systime_ns = xen_global_systime_ns(); - splx(s); - - /* Add the system time to the wall clock time. */ - systime_ns += tsp->tv_nsec; - tsp->tv_sec += systime_ns / 10ull; - tsp->tv_nsec = systime_ns % 10ull; -} - -#endif /* XENPV */ - /* * idle_block() * @@ -1011,3 +889,125 @@ sysctl_xen_timepush(SYSCTLFN_ARGS) } #endif /* DOM0OPS */ + +#ifdef XENPV +static int xen_rtc_get(struct todr_chip_handle *, struct timeval *); +static int xen_rtc_set(struct todr_chip_handle *, struct timeval *); +static void xen_wallclock_time(struct timespec *); +/* + * xen time of day register: + * + * Xen wall clock time, plus a Xen vCPU system time adjustment. + */ +static struct todr_chip_handle xen_todr_chip = { + .todr_gettime = xen_rtc_get, + .todr_settime = xen_rtc_set, +}; + +/* + * startrtclock() + * + * Initialize the real-time clock from x86 machdep autoconf. + */ +void +startrtclock(void) +{ + + todr_attach(_todr_chip); +} + +/* + * setstatclockrate(rate) + * + * Set the statclock to run at rate, in units of ticks per second. + *
CVS commit: [bouyer-xenpvh] src/sys/arch/xen/xen
Module Name:src Committed By: bouyer Date: Thu Apr 16 20:21:04 UTC 2020 Modified Files: src/sys/arch/xen/xen [bouyer-xenpvh]: hypervisor.c Log Message: switch vm_guest to VM_GUEST_XENPVHVM only after all tests succeeded. To generate a diff of this commit: cvs rdiff -u -r1.73.2.4 -r1.73.2.5 src/sys/arch/xen/xen/hypervisor.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/xen/hypervisor.c diff -u src/sys/arch/xen/xen/hypervisor.c:1.73.2.4 src/sys/arch/xen/xen/hypervisor.c:1.73.2.5 --- src/sys/arch/xen/xen/hypervisor.c:1.73.2.4 Thu Apr 16 19:23:50 2020 +++ src/sys/arch/xen/xen/hypervisor.c Thu Apr 16 20:21:04 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: hypervisor.c,v 1.73.2.4 2020/04/16 19:23:50 bouyer Exp $ */ +/* $NetBSD: hypervisor.c,v 1.73.2.5 2020/04/16 20:21:04 bouyer Exp $ */ /* * Copyright (c) 2005 Manuel Bouyer. @@ -53,7 +53,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.73.2.4 2020/04/16 19:23:50 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.73.2.5 2020/04/16 20:21:04 bouyer Exp $"); #include #include @@ -251,8 +251,6 @@ hypervisor_match(device_t parent, cfdata /* XXX: vtophys(_page) */ wrmsr(descs[1], (uintptr_t)_page - KERNBASE); - vm_guest = VM_GUEST_XENPVHVM; /* Be more specific */ - } else { return 0; } @@ -427,7 +425,7 @@ hypervisor_match(device_t parent, cfdata bi.common.len = sizeof(struct btinfo_rootdevice); /* From i386/multiboot.c */ - /* $NetBSD: hypervisor.c,v 1.73.2.4 2020/04/16 19:23:50 bouyer Exp $ */ + /* $NetBSD: hypervisor.c,v 1.73.2.5 2020/04/16 20:21:04 bouyer Exp $ */ int i, len; vaddr_t data; extern struct bootinfo bootinfo; @@ -456,6 +454,8 @@ hypervisor_match(device_t parent, cfdata events_default_setup(); delay_func = xen_delay; initclock_func = xen_initclocks; + vm_guest = VM_GUEST_XENPVHVM; /* Be more specific */ + #endif /* XENPVHVM */ /* If we got here, it must mean we matched */
CVS commit: [bouyer-xenpvh] src/sys/arch/xen/xen
Module Name:src Committed By: bouyer Date: Thu Apr 16 20:21:04 UTC 2020 Modified Files: src/sys/arch/xen/xen [bouyer-xenpvh]: hypervisor.c Log Message: switch vm_guest to VM_GUEST_XENPVHVM only after all tests succeeded. To generate a diff of this commit: cvs rdiff -u -r1.73.2.4 -r1.73.2.5 src/sys/arch/xen/xen/hypervisor.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [bouyer-xenpvh] src/sys/arch/xen
Module Name:src Committed By: bouyer Date: Thu Apr 16 19:23:51 UTC 2020 Modified Files: src/sys/arch/xen/conf [bouyer-xenpvh]: files.xen files.xen.pv src/sys/arch/xen/xen [bouyer-xenpvh]: hypervisor.c Added Files: src/sys/arch/xen/xen [bouyer-xenpvh]: xen_clock.c Removed Files: src/sys/arch/xen/xen [bouyer-xenpvh]: clock.c Log Message: Rename xen/xen/clock.c to xen_clock.c, so that it can be compiled with x86/isa/clock.c call events_default_setup() from hypervisor_match to that event arrays are properly initialised. Use xen_delay() and xen's timecounter for PVHVM. To generate a diff of this commit: cvs rdiff -u -r1.180.2.3 -r1.180.2.4 src/sys/arch/xen/conf/files.xen cvs rdiff -u -r1.1.2.1 -r1.1.2.2 src/sys/arch/xen/conf/files.xen.pv cvs rdiff -u -r1.80.6.2 -r0 src/sys/arch/xen/xen/clock.c cvs rdiff -u -r1.73.2.3 -r1.73.2.4 src/sys/arch/xen/xen/hypervisor.c cvs rdiff -u -r0 -r1.1.2.1 src/sys/arch/xen/xen/xen_clock.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [bouyer-xenpvh] src/sys/arch/xen
Module Name:src Committed By: bouyer Date: Thu Apr 16 19:23:51 UTC 2020 Modified Files: src/sys/arch/xen/conf [bouyer-xenpvh]: files.xen files.xen.pv src/sys/arch/xen/xen [bouyer-xenpvh]: hypervisor.c Added Files: src/sys/arch/xen/xen [bouyer-xenpvh]: xen_clock.c Removed Files: src/sys/arch/xen/xen [bouyer-xenpvh]: clock.c Log Message: Rename xen/xen/clock.c to xen_clock.c, so that it can be compiled with x86/isa/clock.c call events_default_setup() from hypervisor_match to that event arrays are properly initialised. Use xen_delay() and xen's timecounter for PVHVM. To generate a diff of this commit: cvs rdiff -u -r1.180.2.3 -r1.180.2.4 src/sys/arch/xen/conf/files.xen cvs rdiff -u -r1.1.2.1 -r1.1.2.2 src/sys/arch/xen/conf/files.xen.pv cvs rdiff -u -r1.80.6.2 -r0 src/sys/arch/xen/xen/clock.c cvs rdiff -u -r1.73.2.3 -r1.73.2.4 src/sys/arch/xen/xen/hypervisor.c cvs rdiff -u -r0 -r1.1.2.1 src/sys/arch/xen/xen/xen_clock.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/conf/files.xen diff -u src/sys/arch/xen/conf/files.xen:1.180.2.3 src/sys/arch/xen/conf/files.xen:1.180.2.4 --- src/sys/arch/xen/conf/files.xen:1.180.2.3 Thu Apr 16 08:46:35 2020 +++ src/sys/arch/xen/conf/files.xen Thu Apr 16 19:23:50 2020 @@ -1,4 +1,4 @@ -# $NetBSD: files.xen,v 1.180.2.3 2020/04/16 08:46:35 bouyer Exp $ +# $NetBSD: files.xen,v 1.180.2.4 2020/04/16 19:23:50 bouyer Exp $ defflag opt_xen.h XEN XENPVH XENPVHVM @@ -9,7 +9,7 @@ file arch/xen/xen/evtchn.c xen file arch/xen/xen/xengnt.c xen file arch/xen/x86/xen_ipi.c multiprocessor & xen file arch/xen/x86/xen_mainbus.c xen - +file arch/xen/xen/xen_clock.c xen define hypervisorbus {} define xendevbus {} Index: src/sys/arch/xen/conf/files.xen.pv diff -u src/sys/arch/xen/conf/files.xen.pv:1.1.2.1 src/sys/arch/xen/conf/files.xen.pv:1.1.2.2 --- src/sys/arch/xen/conf/files.xen.pv:1.1.2.1 Thu Apr 16 08:46:35 2020 +++ src/sys/arch/xen/conf/files.xen.pv Thu Apr 16 19:23:50 2020 @@ -1,4 +1,4 @@ -# $NetBSD: files.xen.pv,v 1.1.2.1 2020/04/16 08:46:35 bouyer Exp $ +# $NetBSD: files.xen.pv,v 1.1.2.2 2020/04/16 19:23:50 bouyer Exp $ file arch/xen/x86/autoconf.c xenpv file arch/xen/x86/x86_xpmap.c xenpv @@ -6,7 +6,6 @@ file arch/xen/x86/xen_pmap.c xenpv file arch/xen/x86/xenfunc.c xenpv file arch/xen/xen/xen_acpi_machdep.c acpi & xenpv -file arch/xen/xen/clock.c xenpv file arch/xen/x86/xen_bus_dma.c machdep & xenpv file arch/xen/x86/consinit.c machdep & xenpv file arch/xen/x86/pintr.c machdep & dom0ops & xenpv Index: src/sys/arch/xen/xen/hypervisor.c diff -u src/sys/arch/xen/xen/hypervisor.c:1.73.2.3 src/sys/arch/xen/xen/hypervisor.c:1.73.2.4 --- src/sys/arch/xen/xen/hypervisor.c:1.73.2.3 Thu Apr 16 17:47:37 2020 +++ src/sys/arch/xen/xen/hypervisor.c Thu Apr 16 19:23:50 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: hypervisor.c,v 1.73.2.3 2020/04/16 17:47:37 bouyer Exp $ */ +/* $NetBSD: hypervisor.c,v 1.73.2.4 2020/04/16 19:23:50 bouyer Exp $ */ /* * Copyright (c) 2005 Manuel Bouyer. @@ -53,7 +53,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.73.2.3 2020/04/16 17:47:37 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.73.2.4 2020/04/16 19:23:50 bouyer Exp $"); #include #include @@ -186,6 +186,10 @@ paddr_t HYPERVISOR_shared_info_pa; union start_info_union start_info_union __aligned(PAGE_SIZE); #endif +extern void (*delay_func)(unsigned int); +extern void (*initclock_func)(void); + + int xen_version; /* power management, for save/restore */ @@ -423,7 +427,7 @@ hypervisor_match(device_t parent, cfdata bi.common.len = sizeof(struct btinfo_rootdevice); /* From i386/multiboot.c */ - /* $NetBSD: hypervisor.c,v 1.73.2.3 2020/04/16 17:47:37 bouyer Exp $ */ + /* $NetBSD: hypervisor.c,v 1.73.2.4 2020/04/16 19:23:50 bouyer Exp $ */ int i, len; vaddr_t data; extern struct bootinfo bootinfo; @@ -449,6 +453,9 @@ hypervisor_match(device_t parent, cfdata aprint_error("%s: Unable to disable emulated devices\n", haa->haa_busname); } + events_default_setup(); + delay_func = xen_delay; + initclock_func = xen_initclocks; #endif /* XENPVHVM */ /* If we got here, it must mean we matched */ Added files: Index: src/sys/arch/xen/xen/xen_clock.c diff -u /dev/null src/sys/arch/xen/xen/xen_clock.c:1.1.2.1 --- /dev/null Thu Apr 16 19:23:51 2020 +++ src/sys/arch/xen/xen/xen_clock.c Thu Apr 16 19:23:50 2020 @@ -0,0 +1,1013 @@ +/* $NetBSD: xen_clock.c,v 1.1.2.1 2020/04/16 19:23:50 bouyer Exp $ */ + +/*- + * Copyright (c) 2017, 2018 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Taylor R. Campbell. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of
CVS commit: [bouyer-xenpvh] src/sys/arch/xen/xen
Module Name:src Committed By: bouyer Date: Thu Apr 16 17:47:37 UTC 2020 Modified Files: src/sys/arch/xen/xen [bouyer-xenpvh]: hypervisor.c Log Message: fail silently if hypervisor is not found. To generate a diff of this commit: cvs rdiff -u -r1.73.2.2 -r1.73.2.3 src/sys/arch/xen/xen/hypervisor.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/xen/hypervisor.c diff -u src/sys/arch/xen/xen/hypervisor.c:1.73.2.2 src/sys/arch/xen/xen/hypervisor.c:1.73.2.3 --- src/sys/arch/xen/xen/hypervisor.c:1.73.2.2 Sat Apr 11 21:21:16 2020 +++ src/sys/arch/xen/xen/hypervisor.c Thu Apr 16 17:47:37 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: hypervisor.c,v 1.73.2.2 2020/04/11 21:21:16 bouyer Exp $ */ +/* $NetBSD: hypervisor.c,v 1.73.2.3 2020/04/16 17:47:37 bouyer Exp $ */ /* * Copyright (c) 2005 Manuel Bouyer. @@ -53,7 +53,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.73.2.2 2020/04/11 21:21:16 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.73.2.3 2020/04/16 17:47:37 bouyer Exp $"); #include #include @@ -250,8 +250,6 @@ hypervisor_match(device_t parent, cfdata vm_guest = VM_GUEST_XENPVHVM; /* Be more specific */ } else { - aprint_normal("%s: Xen HVM mode not identified. Exiting.\n", - haa->haa_busname); return 0; } @@ -425,7 +423,7 @@ hypervisor_match(device_t parent, cfdata bi.common.len = sizeof(struct btinfo_rootdevice); /* From i386/multiboot.c */ - /* $NetBSD: hypervisor.c,v 1.73.2.2 2020/04/11 21:21:16 bouyer Exp $ */ + /* $NetBSD: hypervisor.c,v 1.73.2.3 2020/04/16 17:47:37 bouyer Exp $ */ int i, len; vaddr_t data; extern struct bootinfo bootinfo;
CVS commit: [bouyer-xenpvh] src/sys/arch/xen/xen
Module Name:src Committed By: bouyer Date: Thu Apr 16 17:47:37 UTC 2020 Modified Files: src/sys/arch/xen/xen [bouyer-xenpvh]: hypervisor.c Log Message: fail silently if hypervisor is not found. To generate a diff of this commit: cvs rdiff -u -r1.73.2.2 -r1.73.2.3 src/sys/arch/xen/xen/hypervisor.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [bouyer-xenpvh] src/sys/arch/xen/x86
Module Name:src Committed By: bouyer Date: Thu Apr 16 17:46:44 UTC 2020 Modified Files: src/sys/arch/xen/x86 [bouyer-xenpvh]: xen_mainbus.c Log Message: Don't try to attach hypervisor on non Xen; no more error messages about hypervisor when booting on bare metal. To generate a diff of this commit: cvs rdiff -u -r1.6.12.1 -r1.6.12.2 src/sys/arch/xen/x86/xen_mainbus.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [bouyer-xenpvh] src/sys/arch/xen/x86
Module Name:src Committed By: bouyer Date: Thu Apr 16 17:46:44 UTC 2020 Modified Files: src/sys/arch/xen/x86 [bouyer-xenpvh]: xen_mainbus.c Log Message: Don't try to attach hypervisor on non Xen; no more error messages about hypervisor when booting on bare metal. To generate a diff of this commit: cvs rdiff -u -r1.6.12.1 -r1.6.12.2 src/sys/arch/xen/x86/xen_mainbus.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/x86/xen_mainbus.c diff -u src/sys/arch/xen/x86/xen_mainbus.c:1.6.12.1 src/sys/arch/xen/x86/xen_mainbus.c:1.6.12.2 --- src/sys/arch/xen/x86/xen_mainbus.c:1.6.12.1 Thu Apr 16 08:46:35 2020 +++ src/sys/arch/xen/x86/xen_mainbus.c Thu Apr 16 17:46:44 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: xen_mainbus.c,v 1.6.12.1 2020/04/16 08:46:35 bouyer Exp $ */ +/* $NetBSD: xen_mainbus.c,v 1.6.12.2 2020/04/16 17:46:44 bouyer Exp $ */ /* NetBSD: mainbus.c,v 1.19 2017/05/23 08:54:39 nonaka Exp */ /* NetBSD: mainbus.c,v 1.53 2003/10/27 14:11:47 junyoung Exp */ @@ -33,7 +33,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xen_mainbus.c,v 1.6.12.1 2020/04/16 08:46:35 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xen_mainbus.c,v 1.6.12.2 2020/04/16 17:46:44 bouyer Exp $"); #include #include @@ -121,20 +121,31 @@ xen_mainbus_attach(device_t parent, devi { union xen_mainbus_attach_args mba; + switch(vm_guest) { + case VM_GUEST_XENPV: #if NIPMI > 0 && defined(XENPV) - memset(_ipmi, 0, sizeof(mba.mba_ipmi)); - mba.mba_ipmi.iaa_iot = x86_bus_space_io; - mba.mba_ipmi.iaa_memt = x86_bus_space_mem; - if (ipmi_probe(_ipmi)) - config_found_ia(self, "ipmibus", _ipmi, 0); -#endif - - mba.mba_haa.haa_busname = "hypervisor"; - config_found_ia(self, "hypervisorbus", _haa, xen_mainbus_print); - - /* save/restore for Xen */ - if (!pmf_device_register(self, NULL, NULL)) - aprint_error_dev(self, "couldn't establish power handler\n"); + memset(_ipmi, 0, sizeof(mba.mba_ipmi)); + mba.mba_ipmi.iaa_iot = x86_bus_space_io; + mba.mba_ipmi.iaa_memt = x86_bus_space_mem; + if (ipmi_probe(_ipmi)) + config_found_ia(self, "ipmibus", _ipmi, 0); +#endif + /* FALLTHROUGH */ + case VM_GUEST_XENHVM: + mba.mba_haa.haa_busname = "hypervisor"; + config_found_ia(self, "hypervisorbus", + _haa, xen_mainbus_print); + break; + default: + return; + } + + if (vm_guest == VM_GUEST_XENPV) { + /* save/restore for Xen */ + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, + "couldn't establish power handler\n"); + } } static int
CVS commit: [bouyer-xenpvh] src/sys/arch/xen/x86
Module Name:src Committed By: bouyer Date: Tue Apr 14 16:52:36 UTC 2020 Modified Files: src/sys/arch/xen/x86 [bouyer-xenpvh]: xen_intr.c Log Message: Remove spllower alias, xen_spllower is gone To generate a diff of this commit: cvs rdiff -u -r1.21.2.3 -r1.21.2.4 src/sys/arch/xen/x86/xen_intr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [bouyer-xenpvh] src/sys/arch/xen/x86
Module Name:src Committed By: bouyer Date: Tue Apr 14 16:52:36 UTC 2020 Modified Files: src/sys/arch/xen/x86 [bouyer-xenpvh]: xen_intr.c Log Message: Remove spllower alias, xen_spllower is gone To generate a diff of this commit: cvs rdiff -u -r1.21.2.3 -r1.21.2.4 src/sys/arch/xen/x86/xen_intr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/x86/xen_intr.c diff -u src/sys/arch/xen/x86/xen_intr.c:1.21.2.3 src/sys/arch/xen/x86/xen_intr.c:1.21.2.4 --- src/sys/arch/xen/x86/xen_intr.c:1.21.2.3 Sun Apr 12 19:53:37 2020 +++ src/sys/arch/xen/x86/xen_intr.c Tue Apr 14 16:52:35 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: xen_intr.c,v 1.21.2.3 2020/04/12 19:53:37 bouyer Exp $ */ +/* $NetBSD: xen_intr.c,v 1.21.2.4 2020/04/14 16:52:35 bouyer Exp $ */ /*- * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xen_intr.c,v 1.21.2.3 2020/04/12 19:53:37 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xen_intr.c,v 1.21.2.4 2020/04/14 16:52:35 bouyer Exp $"); #include "opt_multiprocessor.h" @@ -495,7 +495,6 @@ xen_intr_create_intrid(int legacy_irq, s } #if !defined(XENPVHVM) -__strong_alias(spllower, xen_spllower); __strong_alias(x86_read_psl, xen_read_psl); __strong_alias(x86_write_psl, xen_write_psl);
CVS commit: [bouyer-xenpvh] src/sys/arch/xen/x86
Module Name:src Committed By: bouyer Date: Sun Apr 12 21:19:49 UTC 2020 Modified Files: src/sys/arch/xen/x86 [bouyer-xenpvh]: autoconf.c Log Message: remove stray 'else' To generate a diff of this commit: cvs rdiff -u -r1.23.8.1 -r1.23.8.2 src/sys/arch/xen/x86/autoconf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [bouyer-xenpvh] src/sys/arch/xen/x86
Module Name:src Committed By: bouyer Date: Sun Apr 12 21:19:49 UTC 2020 Modified Files: src/sys/arch/xen/x86 [bouyer-xenpvh]: autoconf.c Log Message: remove stray 'else' To generate a diff of this commit: cvs rdiff -u -r1.23.8.1 -r1.23.8.2 src/sys/arch/xen/x86/autoconf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/x86/autoconf.c diff -u src/sys/arch/xen/x86/autoconf.c:1.23.8.1 src/sys/arch/xen/x86/autoconf.c:1.23.8.2 --- src/sys/arch/xen/x86/autoconf.c:1.23.8.1 Wed Apr 8 17:59:16 2020 +++ src/sys/arch/xen/x86/autoconf.c Sun Apr 12 21:19:49 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: autoconf.c,v 1.23.8.1 2020/04/08 17:59:16 bouyer Exp $ */ +/* $NetBSD: autoconf.c,v 1.23.8.2 2020/04/12 21:19:49 bouyer Exp $ */ /* NetBSD: autoconf.c,v 1.75 2003/12/30 12:33:22 pk Exp */ /*- @@ -45,7 +45,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.23.8.1 2020/04/08 17:59:16 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.23.8.2 2020/04/12 21:19:49 bouyer Exp $"); #include "opt_xen.h" #include "opt_multiprocessor.h" @@ -126,7 +126,7 @@ cpu_configure(void) /* identify hypervisor type from SMBIOS */ identify_hypervisor(); #endif /* NBIOS32 > 0 */ - } else + } #endif /* DOM0OPS */ #ifdef PCIBIOS pcibios_init();
CVS commit: [bouyer-xenpvh] src/sys/arch/xen/x86
Module Name:src Committed By: bouyer Date: Sun Apr 12 19:53:37 UTC 2020 Modified Files: src/sys/arch/xen/x86 [bouyer-xenpvh]: xen_intr.c Log Message: We need to call x86_init_preempt() for all CPUs now. To generate a diff of this commit: cvs rdiff -u -r1.21.2.2 -r1.21.2.3 src/sys/arch/xen/x86/xen_intr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/x86/xen_intr.c diff -u src/sys/arch/xen/x86/xen_intr.c:1.21.2.2 src/sys/arch/xen/x86/xen_intr.c:1.21.2.3 --- src/sys/arch/xen/x86/xen_intr.c:1.21.2.2 Sun Apr 12 17:25:52 2020 +++ src/sys/arch/xen/x86/xen_intr.c Sun Apr 12 19:53:37 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: xen_intr.c,v 1.21.2.2 2020/04/12 17:25:52 bouyer Exp $ */ +/* $NetBSD: xen_intr.c,v 1.21.2.3 2020/04/12 19:53:37 bouyer Exp $ */ /*- * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xen_intr.c,v 1.21.2.2 2020/04/12 17:25:52 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xen_intr.c,v 1.21.2.3 2020/04/12 19:53:37 bouyer Exp $"); #include "opt_multiprocessor.h" @@ -306,6 +306,11 @@ void xen_cpu_intr_init(struct cpu_info * void xen_cpu_intr_init(struct cpu_info *ci) { +#if defined(__HAVE_PREEMPTION) + x86_init_preempt(ci); +#endif + x86_intr_calculatemasks(ci); + #if defined(INTRSTACKSIZE) vaddr_t istack;
CVS commit: [bouyer-xenpvh] src/sys/arch/xen/x86
Module Name:src Committed By: bouyer Date: Sun Apr 12 19:53:37 UTC 2020 Modified Files: src/sys/arch/xen/x86 [bouyer-xenpvh]: xen_intr.c Log Message: We need to call x86_init_preempt() for all CPUs now. To generate a diff of this commit: cvs rdiff -u -r1.21.2.2 -r1.21.2.3 src/sys/arch/xen/x86/xen_intr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [bouyer-xenpvh] src/sys/arch/xen/x86
Module Name:src Committed By: bouyer Date: Sun Apr 12 17:17:38 UTC 2020 Modified Files: src/sys/arch/xen/x86 [bouyer-xenpvh]: xen_ipi.c Log Message: Add XEN_IPI_KPREEMPT to list of valid IPIs To generate a diff of this commit: cvs rdiff -u -r1.35.6.1 -r1.35.6.2 src/sys/arch/xen/x86/xen_ipi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/x86/xen_ipi.c diff -u src/sys/arch/xen/x86/xen_ipi.c:1.35.6.1 src/sys/arch/xen/x86/xen_ipi.c:1.35.6.2 --- src/sys/arch/xen/x86/xen_ipi.c:1.35.6.1 Sat Apr 11 18:26:07 2020 +++ src/sys/arch/xen/x86/xen_ipi.c Sun Apr 12 17:17:38 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: xen_ipi.c,v 1.35.6.1 2020/04/11 18:26:07 bouyer Exp $ */ +/* $NetBSD: xen_ipi.c,v 1.35.6.2 2020/04/12 17:17:38 bouyer Exp $ */ /*- * Copyright (c) 2011, 2019 The NetBSD Foundation, Inc. @@ -33,10 +33,10 @@ /* * Based on: x86/ipi.c - * __KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.35.6.1 2020/04/11 18:26:07 bouyer Exp $"); + * __KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.35.6.2 2020/04/12 17:17:38 bouyer Exp $"); */ -__KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.35.6.1 2020/04/11 18:26:07 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.35.6.2 2020/04/12 17:17:38 bouyer Exp $"); #include "opt_ddb.h" @@ -156,7 +156,7 @@ valid_ipimask(uint32_t ipimask) { uint32_t masks = XEN_IPI_GENERIC | XEN_IPI_HVCB | XEN_IPI_XCALL | XEN_IPI_DDB | XEN_IPI_SYNCH_FPU | - XEN_IPI_HALT | XEN_IPI_KICK | XEN_IPI_AST; + XEN_IPI_HALT | XEN_IPI_KICK | XEN_IPI_AST | XEN_IPI_KPREEMPT; if (ipimask & ~masks) { return false;
CVS commit: [bouyer-xenpvh] src/sys/arch/xen/x86
Module Name:src Committed By: bouyer Date: Sun Apr 12 17:17:38 UTC 2020 Modified Files: src/sys/arch/xen/x86 [bouyer-xenpvh]: xen_ipi.c Log Message: Add XEN_IPI_KPREEMPT to list of valid IPIs To generate a diff of this commit: cvs rdiff -u -r1.35.6.1 -r1.35.6.2 src/sys/arch/xen/x86/xen_ipi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [bouyer-xenpvh] src/sys/arch/xen/x86
Module Name:src Committed By: bouyer Date: Sun Apr 12 17:16:58 UTC 2020 Modified Files: src/sys/arch/xen/x86 [bouyer-xenpvh]: xenfunc.c Log Message: kpreempt_disable() only for x86_64 (which calls pmap_changeprot_local)). On i386 curcpu() is not valid yet and we don't need preemption disabled. To generate a diff of this commit: cvs rdiff -u -r1.26.8.1 -r1.26.8.2 src/sys/arch/xen/x86/xenfunc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/x86/xenfunc.c diff -u src/sys/arch/xen/x86/xenfunc.c:1.26.8.1 src/sys/arch/xen/x86/xenfunc.c:1.26.8.2 --- src/sys/arch/xen/x86/xenfunc.c:1.26.8.1 Sat Apr 11 18:26:07 2020 +++ src/sys/arch/xen/x86/xenfunc.c Sun Apr 12 17:16:58 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: xenfunc.c,v 1.26.8.1 2020/04/11 18:26:07 bouyer Exp $ */ +/* $NetBSD: xenfunc.c,v 1.26.8.2 2020/04/12 17:16:58 bouyer Exp $ */ /* * Copyright (c) 2004 Christian Limpach. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xenfunc.c,v 1.26.8.1 2020/04/11 18:26:07 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xenfunc.c,v 1.26.8.2 2020/04/12 17:16:58 bouyer Exp $"); #include @@ -61,7 +61,9 @@ lidt(struct region_descriptor *rd) * will be available at the boot stage when this is called. */ static char xen_idt_page[PAGE_SIZE] __attribute__((__aligned__ (PAGE_SIZE))); +#if defined(__x86_64__) kpreempt_disable(); +#endif memset(xen_idt_page, 0, PAGE_SIZE); struct trap_info *xen_idt = (void * )xen_idt_page; @@ -96,8 +98,8 @@ lidt(struct region_descriptor *rd) #if defined(__x86_64__) /* reset */ pmap_changeprot_local((vaddr_t) xen_idt, VM_PROT_READ|VM_PROT_WRITE); -#endif /* __x86_64 */ kpreempt_enable(); +#endif /* __x86_64 */ } void
CVS commit: [bouyer-xenpvh] src/sys/arch/xen/x86
Module Name:src Committed By: bouyer Date: Sun Apr 12 17:16:58 UTC 2020 Modified Files: src/sys/arch/xen/x86 [bouyer-xenpvh]: xenfunc.c Log Message: kpreempt_disable() only for x86_64 (which calls pmap_changeprot_local)). On i386 curcpu() is not valid yet and we don't need preemption disabled. To generate a diff of this commit: cvs rdiff -u -r1.26.8.1 -r1.26.8.2 src/sys/arch/xen/x86/xenfunc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [bouyer-xenpvh] src/sys/arch/xen/xen
Module Name:src Committed By: bouyer Date: Sun Apr 12 11:16:59 UTC 2020 Modified Files: src/sys/arch/xen/xen [bouyer-xenpvh]: evtchn.c Log Message: Now that we return from hypervisor_callback via Xdoreti, no need to emulate it in evtchn_do_event() any more. To generate a diff of this commit: cvs rdiff -u -r1.88.2.1 -r1.88.2.2 src/sys/arch/xen/xen/evtchn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/xen/evtchn.c diff -u src/sys/arch/xen/xen/evtchn.c:1.88.2.1 src/sys/arch/xen/xen/evtchn.c:1.88.2.2 --- src/sys/arch/xen/xen/evtchn.c:1.88.2.1 Fri Apr 10 14:38:19 2020 +++ src/sys/arch/xen/xen/evtchn.c Sun Apr 12 11:16:58 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: evtchn.c,v 1.88.2.1 2020/04/10 14:38:19 bouyer Exp $ */ +/* $NetBSD: evtchn.c,v 1.88.2.2 2020/04/12 11:16:58 bouyer Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -54,7 +54,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.88.2.1 2020/04/10 14:38:19 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.88.2.2 2020/04/12 11:16:58 bouyer Exp $"); #include "opt_xen.h" #include "isa.h" @@ -316,8 +316,6 @@ evtchn_do_event(int evtch, struct intrfr struct intrhand *ih; int (*ih_fun)(void *, void *); uint32_t iplmask; - int i; - uint32_t iplbit; KASSERTMSG(evtch >= 0, "negative evtch: %d", evtch); KASSERTMSG(evtch < NR_EVENT_CHANNELS, @@ -404,35 +402,6 @@ evtchn_do_event(int evtch, struct intrfr #endif /* NPCI > 0 || NISA > 0 */ splx: - /* - * C version of spllower(). ASTs will be checked when - * hypevisor_callback() exits, so no need to check here. - */ - iplmask = (XUNMASK(ci, ilevel) & ci->ci_xpending); - while (iplmask != 0) { - iplbit = 1 << (NIPL - 1); - i = (NIPL - 1); - while (iplmask != 0 && i > ilevel) { - while (iplmask & iplbit) { -ci->ci_xpending &= ~iplbit; -ci->ci_ilevel = i; -for (ih = ci->ci_xsources[i]->is_handlers; -ih != NULL; ih = ih->ih_next) { - KASSERT(ih->ih_cpu == ci); - x86_enable_intr(); - ih_fun = (void *)ih->ih_fun; - ih_fun(ih->ih_arg, regs); - x86_disable_intr(); -} -hypervisor_enable_ipl(i); -/* more pending IPLs may have been registered */ -iplmask = -(XUNMASK(ci, ilevel) & ci->ci_xpending); - } - i--; - iplbit >>= 1; - } - } ci->ci_ilevel = ilevel; return 0; }
CVS commit: [bouyer-xenpvh] src/sys/arch/xen/xen
Module Name:src Committed By: bouyer Date: Sun Apr 12 11:16:59 UTC 2020 Modified Files: src/sys/arch/xen/xen [bouyer-xenpvh]: evtchn.c Log Message: Now that we return from hypervisor_callback via Xdoreti, no need to emulate it in evtchn_do_event() any more. To generate a diff of this commit: cvs rdiff -u -r1.88.2.1 -r1.88.2.2 src/sys/arch/xen/xen/evtchn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [bouyer-xenpvh] src/sys/arch/xen/xen
Module Name:src Committed By: bouyer Date: Sat Apr 11 21:21:16 UTC 2020 Modified Files: src/sys/arch/xen/xen [bouyer-xenpvh]: hypervisor.c Log Message: Use some PIO magic to disable qemu emulated disks and network device when PVHVM is configured. From FreeBSD. To generate a diff of this commit: cvs rdiff -u -r1.73.2.1 -r1.73.2.2 src/sys/arch/xen/xen/hypervisor.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/xen/hypervisor.c diff -u src/sys/arch/xen/xen/hypervisor.c:1.73.2.1 src/sys/arch/xen/xen/hypervisor.c:1.73.2.2 --- src/sys/arch/xen/xen/hypervisor.c:1.73.2.1 Wed Apr 8 17:59:17 2020 +++ src/sys/arch/xen/xen/hypervisor.c Sat Apr 11 21:21:16 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: hypervisor.c,v 1.73.2.1 2020/04/08 17:59:17 bouyer Exp $ */ +/* $NetBSD: hypervisor.c,v 1.73.2.2 2020/04/11 21:21:16 bouyer Exp $ */ /* * Copyright (c) 2005 Manuel Bouyer. @@ -53,7 +53,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.73.2.1 2020/04/08 17:59:17 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.73.2.2 2020/04/11 21:21:16 bouyer Exp $"); #include #include @@ -73,6 +73,7 @@ __KERNEL_RCSID(0, "$NetBSD: hypervisor.c #include #include #include +#include #include #include @@ -191,6 +192,15 @@ int xen_version; static bool hypervisor_suspend(device_t, const pmf_qual_t *); static bool hypervisor_resume(device_t, const pmf_qual_t *); +/* from FreeBSD */ +#define XEN_MAGIC_IOPORT 0x10 +enum { + XMI_MAGIC= 0x49d2, + XMI_UNPLUG_IDE_DISKS = 0x01, + XMI_UNPLUG_NICS = 0x02, + XMI_UNPLUG_IDE_EXCEPT_PRI_MASTER = 0x04 +}; + /* * Probe for the hypervisor; always succeeds. */ @@ -415,7 +425,7 @@ hypervisor_match(device_t parent, cfdata bi.common.len = sizeof(struct btinfo_rootdevice); /* From i386/multiboot.c */ - /* $NetBSD: hypervisor.c,v 1.73.2.1 2020/04/08 17:59:17 bouyer Exp $ */ + /* $NetBSD: hypervisor.c,v 1.73.2.2 2020/04/11 21:21:16 bouyer Exp $ */ int i, len; vaddr_t data; extern struct bootinfo bootinfo; @@ -434,6 +444,13 @@ hypervisor_match(device_t parent, cfdata bip->bi_nentries++; } + /* disable emulated devices */ + if (inw(XEN_MAGIC_IOPORT) == XMI_MAGIC) { + outw(XEN_MAGIC_IOPORT, XMI_UNPLUG_IDE_DISKS | XMI_UNPLUG_NICS); + } else { + aprint_error("%s: Unable to disable emulated devices\n", + haa->haa_busname); + } #endif /* XENPVHVM */ /* If we got here, it must mean we matched */
CVS commit: [bouyer-xenpvh] src/sys/arch/xen/xen
Module Name:src Committed By: bouyer Date: Sat Apr 11 21:21:16 UTC 2020 Modified Files: src/sys/arch/xen/xen [bouyer-xenpvh]: hypervisor.c Log Message: Use some PIO magic to disable qemu emulated disks and network device when PVHVM is configured. From FreeBSD. To generate a diff of this commit: cvs rdiff -u -r1.73.2.1 -r1.73.2.2 src/sys/arch/xen/xen/hypervisor.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [bouyer-xenpvh] src/sys/arch/xen/xen
Module Name:src Committed By: bouyer Date: Fri Apr 10 14:38:19 UTC 2020 Modified Files: src/sys/arch/xen/xen [bouyer-xenpvh]: evtchn.c Log Message: Remove extra assignement To generate a diff of this commit: cvs rdiff -u -r1.88 -r1.88.2.1 src/sys/arch/xen/xen/evtchn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/xen/xen/evtchn.c diff -u src/sys/arch/xen/xen/evtchn.c:1.88 src/sys/arch/xen/xen/evtchn.c:1.88.2.1 --- src/sys/arch/xen/xen/evtchn.c:1.88 Mon Apr 6 19:26:00 2020 +++ src/sys/arch/xen/xen/evtchn.c Fri Apr 10 14:38:19 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: evtchn.c,v 1.88 2020/04/06 19:26:00 jdolecek Exp $ */ +/* $NetBSD: evtchn.c,v 1.88.2.1 2020/04/10 14:38:19 bouyer Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -54,7 +54,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.88 2020/04/06 19:26:00 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.88.2.1 2020/04/10 14:38:19 bouyer Exp $"); #include "opt_xen.h" #include "isa.h" @@ -942,7 +942,6 @@ event_set_iplhandler(struct cpu_info *ci KM_NOSLEEP); if (ipls == NULL) panic("can't allocate fixed interrupt source"); - ipls->is_recurse = xenev_stubs[level].ist_entry; ipls->is_recurse = xenev_stubs[level].ist_recurse; ipls->is_resume = xenev_stubs[level].ist_resume; ipls->is_handlers = ih;
CVS commit: [bouyer-xenpvh] src/sys/arch/xen/xen
Module Name:src Committed By: bouyer Date: Fri Apr 10 14:38:19 UTC 2020 Modified Files: src/sys/arch/xen/xen [bouyer-xenpvh]: evtchn.c Log Message: Remove extra assignement To generate a diff of this commit: cvs rdiff -u -r1.88 -r1.88.2.1 src/sys/arch/xen/xen/evtchn.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.