CVS commit: [netbsd-9] src/sys/arch/xen/x86
Module Name:src Committed By: sborrill Date: Thu Aug 10 10:30:28 UTC 2023 Modified Files: src/sys/arch/xen/x86 [netbsd-9]: xen_ipi.c Log Message: Pull up the following revisions(s) (requested by riastradh in ticket #1713): sys/arch/xen/x86/xen_ipi.c: revision 1.41 via patch xen/x86: Fix 'mach cpu N' in ddb by passing the right pointer to a struct intrframe to IPI handlers. To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.32.4.1 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: [netbsd-9] src/sys/arch/xen/x86
Module Name:src Committed By: sborrill Date: Thu Aug 10 10:30:28 UTC 2023 Modified Files: src/sys/arch/xen/x86 [netbsd-9]: xen_ipi.c Log Message: Pull up the following revisions(s) (requested by riastradh in ticket #1713): sys/arch/xen/x86/xen_ipi.c: revision 1.41 via patch xen/x86: Fix 'mach cpu N' in ddb by passing the right pointer to a struct intrframe to IPI handlers. To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.32.4.1 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.32 src/sys/arch/xen/x86/xen_ipi.c:1.32.4.1 --- src/sys/arch/xen/x86/xen_ipi.c:1.32 Sat Feb 2 12:32:55 2019 +++ src/sys/arch/xen/x86/xen_ipi.c Thu Aug 10 10:30:28 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: xen_ipi.c,v 1.32 2019/02/02 12:32:55 cherry Exp $ */ +/* $NetBSD: xen_ipi.c,v 1.32.4.1 2023/08/10 10:30:28 sborrill Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -33,10 +33,10 @@ /* * Based on: x86/ipi.c - * __KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.32 2019/02/02 12:32:55 cherry Exp $"); + * __KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.32.4.1 2023/08/10 10:30:28 sborrill Exp $"); */ -__KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.32 2019/02/02 12:32:55 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xen_ipi.c,v 1.32.4.1 2023/08/10 10:30:28 sborrill Exp $"); #include "opt_ddb.h" @@ -87,16 +87,13 @@ static void (*ipifunc[XEN_NIPIS])(struct }; static int -xen_ipi_handler(void *arg) +xen_ipi_handler(void *arg, struct intrframe *regs) { uint32_t pending; int bit; struct cpu_info *ci; - struct intrframe *regs; ci = curcpu(); - regs = arg; - pending = atomic_swap_32(>ci_ipis, 0); KDASSERT((pending >> XEN_NIPIS) == 0); @@ -138,7 +135,8 @@ xen_ipi_init(void) device_xname(ci->ci_dev)); if (xen_intr_establish_xname(-1, _pic, evtchn, IST_LEVEL, IPL_HIGH, - xen_ipi_handler, ci, true, intr_xname) == NULL) { + (int (*)(void *))xen_ipi_handler, ci, true, intr_xname) + == NULL) { panic("%s: unable to register ipi handler\n", __func__); /* NOTREACHED */ }
CVS commit: [netbsd-9] src/sys/arch/xen/x86
Module Name:src Committed By: martin Date: Mon Jul 31 15:39:24 UTC 2023 Modified Files: src/sys/arch/xen/x86 [netbsd-9]: hypervisor_machdep.c Log Message: Pull up following revision(s) (requested by riastradh in ticket #1681): sys/arch/xen/x86/hypervisor_machdep.c: revision 1.46 (patch) xen/x86: Need kpreempt_disable/enable around curcpu() access. This is called with `hardware' interrupts enabled (between sti and cli), so presumably preemption is possible here. To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.36.2.1 src/sys/arch/xen/x86/hypervisor_machdep.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/hypervisor_machdep.c diff -u src/sys/arch/xen/x86/hypervisor_machdep.c:1.36 src/sys/arch/xen/x86/hypervisor_machdep.c:1.36.2.1 --- src/sys/arch/xen/x86/hypervisor_machdep.c:1.36 Thu May 9 17:09:51 2019 +++ src/sys/arch/xen/x86/hypervisor_machdep.c Mon Jul 31 15:39:23 2023 @@ -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.36.2.1 2023/07/31 15:39:23 martin Exp $ */ /* * @@ -54,7 +54,7 @@ #include -__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.36.2.1 2023/07/31 15:39:23 martin Exp $"); #include #include @@ -168,6 +168,8 @@ stipending(void) volatile struct vcpu_info *vci; int ret; + kpreempt_disable(); + ret = 0; ci = curcpu(); vci = ci->ci_vcpu; @@ -211,6 +213,8 @@ stipending(void) ci->ci_xpending); #endif + kpreempt_enable(); + return (ret); }
CVS commit: [netbsd-9] src/sys/arch/xen/x86
Module Name:src Committed By: martin Date: Mon Jul 31 15:39:24 UTC 2023 Modified Files: src/sys/arch/xen/x86 [netbsd-9]: hypervisor_machdep.c Log Message: Pull up following revision(s) (requested by riastradh in ticket #1681): sys/arch/xen/x86/hypervisor_machdep.c: revision 1.46 (patch) xen/x86: Need kpreempt_disable/enable around curcpu() access. This is called with `hardware' interrupts enabled (between sti and cli), so presumably preemption is possible here. To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.36.2.1 src/sys/arch/xen/x86/hypervisor_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-9] src/sys/arch/xen/x86
Module Name:src Committed By: martin Date: Mon Jul 31 14:56:20 UTC 2023 Modified Files: src/sys/arch/xen/x86 [netbsd-9]: xen_intr.c Log Message: Pull up following revision(s) (requested by riastradh in ticket #1679): sys/arch/xen/x86/xen_intr.c: revision 1.31 xen_intr.c: Use kpreempt_disable/enable around access to curcpu(). curcpu() is not otherwise guaranteed to be stable at these points. While here, nix nonsensical membars. This need only be synchronized with interrupts on the same CPU. Proposed on port-xen: https://mail-index.netbsd.org/port-xen/2022/07/13/msg010250.html To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.17.2.1 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.17 src/sys/arch/xen/x86/xen_intr.c:1.17.2.1 --- src/sys/arch/xen/x86/xen_intr.c:1.17 Fri Jun 7 12:43:52 2019 +++ src/sys/arch/xen/x86/xen_intr.c Mon Jul 31 14:56:19 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: xen_intr.c,v 1.17 2019/06/07 12:43:52 cherry Exp $ */ +/* $NetBSD: xen_intr.c,v 1.17.2.1 2023/07/31 14:56:19 martin Exp $ */ /*- * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: xen_intr.c,v 1.17 2019/06/07 12:43:52 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xen_intr.c,v 1.17.2.1 2023/07/31 14:56:19 martin Exp $"); #include #include @@ -103,19 +103,28 @@ xen_spllower(int nlevel) void x86_disable_intr(void) { + + kpreempt_disable(); curcpu()->ci_vcpu->evtchn_upcall_mask = 1; - x86_lfence(); + kpreempt_enable(); + + __insn_barrier(); } void x86_enable_intr(void) { - volatile struct vcpu_info *_vci = curcpu()->ci_vcpu; + struct cpu_info *ci; + + __insn_barrier(); + + kpreempt_disable(); + ci = curcpu(); + ci->ci_vcpu->evtchn_upcall_mask = 0; __insn_barrier(); - _vci->evtchn_upcall_mask = 0; - x86_lfence(); /* unmask then check (avoid races) */ - if (__predict_false(_vci->evtchn_upcall_pending)) + if (__predict_false(ci->ci_vcpu->evtchn_upcall_pending)) hypervisor_force_callback(); + kpreempt_enable(); } #endif /* !XENPVHVM */ @@ -123,20 +132,27 @@ x86_enable_intr(void) u_long xen_read_psl(void) { + u_long psl; + + kpreempt_disable(); + psl = curcpu()->ci_vcpu->evtchn_upcall_mask; + kpreempt_enable(); - return (curcpu()->ci_vcpu->evtchn_upcall_mask); + return psl; } void xen_write_psl(u_long psl) { - struct cpu_info *ci = curcpu(); + struct cpu_info *ci; + kpreempt_disable(); + ci = curcpu(); ci->ci_vcpu->evtchn_upcall_mask = psl; - xen_rmb(); - if (ci->ci_vcpu->evtchn_upcall_pending && psl == 0) { + __insn_barrier(); + if (__predict_false(ci->ci_vcpu->evtchn_upcall_pending) && psl == 0) hypervisor_force_callback(); - } + kpreempt_enable(); } void *
CVS commit: [netbsd-9] src/sys/arch/xen/x86
Module Name:src Committed By: martin Date: Mon Jul 31 14:56:20 UTC 2023 Modified Files: src/sys/arch/xen/x86 [netbsd-9]: xen_intr.c Log Message: Pull up following revision(s) (requested by riastradh in ticket #1679): sys/arch/xen/x86/xen_intr.c: revision 1.31 xen_intr.c: Use kpreempt_disable/enable around access to curcpu(). curcpu() is not otherwise guaranteed to be stable at these points. While here, nix nonsensical membars. This need only be synchronized with interrupts on the same CPU. Proposed on port-xen: https://mail-index.netbsd.org/port-xen/2022/07/13/msg010250.html To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.17.2.1 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: [netbsd-9] src/sys/arch/xen/x86
Module Name:src Committed By: martin Date: Fri May 13 11:12:49 UTC 2022 Modified Files: src/sys/arch/xen/x86 [netbsd-9]: x86_xpmap.c Log Message: Pull up following revision(s) (requested by bouyer in ticket #1444): sys/arch/xen/x86/x86_xpmap.c: revision 1.91 In bootstrap, after switching to a new page table make sure that now-unused memory is unmapped. To generate a diff of this commit: cvs rdiff -u -r1.84.4.1 -r1.84.4.2 src/sys/arch/xen/x86/x86_xpmap.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/x86_xpmap.c diff -u src/sys/arch/xen/x86/x86_xpmap.c:1.84.4.1 src/sys/arch/xen/x86/x86_xpmap.c:1.84.4.2 --- src/sys/arch/xen/x86/x86_xpmap.c:1.84.4.1 Sun May 31 10:39:34 2020 +++ src/sys/arch/xen/x86/x86_xpmap.c Fri May 13 11:12:49 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: x86_xpmap.c,v 1.84.4.1 2020/05/31 10:39:34 martin Exp $ */ +/* $NetBSD: x86_xpmap.c,v 1.84.4.2 2022/05/13 11:12:49 martin Exp $ */ /* * Copyright (c) 2017 The NetBSD Foundation, Inc. @@ -95,7 +95,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: x86_xpmap.c,v 1.84.4.1 2020/05/31 10:39:34 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: x86_xpmap.c,v 1.84.4.2 2022/05/13 11:12:49 martin Exp $"); #include "opt_xen.h" #include "opt_ddb.h" @@ -909,7 +909,7 @@ xen_bootstrap_tables(vaddr_t old_pgd, va /* Unpin old PGD */ xpq_queue_unpin_table(xpmap_ptom_masked(old_pgd - KERNBASE)); - /* Mark old tables RW */ + /* Mark old tables RW if used, unmap otherwise */ page = old_pgd; addr = xpmap_mtop((paddr_t)L2[pl2_pi(page)] & PG_FRAME); pte = (pd_entry_t *)((u_long)addr + KERNBASE); @@ -923,6 +923,12 @@ xen_bootstrap_tables(vaddr_t old_pgd, va */ pte++; } + while (page < old_pgd + (old_count * PAGE_SIZE)) { + addr = xpmap_ptom(((u_long)pte) - KERNBASE); + xpq_queue_pte_update(addr, 0); + page += PAGE_SIZE; + pte++; + } xpq_flush_queue(); }
CVS commit: [netbsd-9] src/sys/arch/xen/x86
Module Name:src Committed By: martin Date: Fri May 13 11:12:49 UTC 2022 Modified Files: src/sys/arch/xen/x86 [netbsd-9]: x86_xpmap.c Log Message: Pull up following revision(s) (requested by bouyer in ticket #1444): sys/arch/xen/x86/x86_xpmap.c: revision 1.91 In bootstrap, after switching to a new page table make sure that now-unused memory is unmapped. To generate a diff of this commit: cvs rdiff -u -r1.84.4.1 -r1.84.4.2 src/sys/arch/xen/x86/x86_xpmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.