Module Name: src Committed By: bouyer Date: Sat Apr 11 10:11:31 UTC 2020
Modified Files: src/sys/arch/amd64/amd64 [bouyer-xenpvh]: genassym.cf spl.S src/sys/arch/amd64/include [bouyer-xenpvh]: frameasm.h src/sys/arch/i386/i386 [bouyer-xenpvh]: genassym.cf spl.S src/sys/arch/i386/include [bouyer-xenpvh]: frameasm.h src/sys/arch/x86/include [bouyer-xenpvh]: cpu.h src/sys/arch/xen/x86 [bouyer-xenpvh]: xen_intr.c Log Message: Include ci_isources[] for XenPV too. Adjust spllower() to XenPV needs, and switch XenPV to the native spllower(). Remove xen_spllower(). To generate a diff of this commit: cvs rdiff -u -r1.82.4.1 -r1.82.4.2 src/sys/arch/amd64/amd64/genassym.cf cvs rdiff -u -r1.43.4.3 -r1.43.4.4 src/sys/arch/amd64/amd64/spl.S cvs rdiff -u -r1.47 -r1.47.6.1 src/sys/arch/amd64/include/frameasm.h cvs rdiff -u -r1.119.4.1 -r1.119.4.2 src/sys/arch/i386/i386/genassym.cf cvs rdiff -u -r1.50.4.1 -r1.50.4.2 src/sys/arch/i386/i386/spl.S cvs rdiff -u -r1.29 -r1.29.6.1 src/sys/arch/i386/include/frameasm.h cvs rdiff -u -r1.117.4.2 -r1.117.4.3 src/sys/arch/x86/include/cpu.h cvs rdiff -u -r1.21 -r1.21.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/amd64/amd64/genassym.cf diff -u src/sys/arch/amd64/amd64/genassym.cf:1.82.4.1 src/sys/arch/amd64/amd64/genassym.cf:1.82.4.2 --- src/sys/arch/amd64/amd64/genassym.cf:1.82.4.1 Wed Apr 8 17:59:16 2020 +++ src/sys/arch/amd64/amd64/genassym.cf Sat Apr 11 10:11:30 2020 @@ -1,4 +1,4 @@ -# $NetBSD: genassym.cf,v 1.82.4.1 2020/04/08 17:59:16 bouyer Exp $ +# $NetBSD: genassym.cf,v 1.82.4.2 2020/04/11 10:11:30 bouyer Exp $ # # Copyright (c) 1998, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -246,13 +246,11 @@ define CPU_INFO_CURPRIORITY offsetof(str define CPU_INFO_GDT offsetof(struct cpu_info, ci_gdt) define CPU_INFO_ILEVEL offsetof(struct cpu_info, ci_ilevel) define CPU_INFO_IDEPTH offsetof(struct cpu_info, ci_idepth) -if !defined(XENPV) define CPU_INFO_IPENDING offsetof(struct cpu_info, ci_ipending) define CPU_INFO_IMASKED offsetof(struct cpu_info, ci_imasked) define CPU_INFO_IMASK offsetof(struct cpu_info, ci_imask) define CPU_INFO_IUNMASK offsetof(struct cpu_info, ci_iunmask) define CPU_INFO_ISOURCES offsetof(struct cpu_info, ci_isources) -endif define CPU_INFO_MTX_COUNT offsetof(struct cpu_info, ci_mtx_count) define CPU_INFO_MTX_OLDSPL offsetof(struct cpu_info, ci_mtx_oldspl) define CPU_INFO_CPUID offsetof(struct cpu_info, ci_cpuid) Index: src/sys/arch/amd64/amd64/spl.S diff -u src/sys/arch/amd64/amd64/spl.S:1.43.4.3 src/sys/arch/amd64/amd64/spl.S:1.43.4.4 --- src/sys/arch/amd64/amd64/spl.S:1.43.4.3 Fri Apr 10 14:41:59 2020 +++ src/sys/arch/amd64/amd64/spl.S Sat Apr 11 10:11:30 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: spl.S,v 1.43.4.3 2020/04/10 14:41:59 bouyer Exp $ */ +/* $NetBSD: spl.S,v 1.43.4.4 2020/04/11 10:11:30 bouyer Exp $ */ /* * Copyright (c) 2003 Wasabi Systems, Inc. @@ -226,7 +226,6 @@ IDTVEC(resume_preempt) IDTVEC_END(resume_preempt) #endif /* XEN */ -#ifndef XENPV /* * void spllower(int s); * @@ -238,8 +237,8 @@ ENTRY(spllower) cmpl CPUVAR(ILEVEL),%edi jae 1f movl CPUVAR(IUNMASK)(,%rdi,4),%edx - pushf - cli + PUSHF(ax) + CLI(ax) testl CPUVAR(IPENDING),%edx jnz 2f #if defined(XEN) @@ -248,12 +247,20 @@ ENTRY(spllower) jnz 2f #endif movl %edi,CPUVAR(ILEVEL) - popf + POPF /* clobbers %rdi */ 1: ret ret 2: +#ifdef XENPV + /* + * no need to call stipending, we're going to CLI again + * just drop the saved value on stack + */ + addq $8,%rsp +#else popf +#endif jmp _C_LABEL(Xspllower) 3: .space 16 @@ -261,6 +268,7 @@ ENTRY(spllower) END(spllower) LABEL(spllower_end) +#ifndef XENPV /* * void cx8_spllower(int s); * Index: src/sys/arch/amd64/include/frameasm.h diff -u src/sys/arch/amd64/include/frameasm.h:1.47 src/sys/arch/amd64/include/frameasm.h:1.47.6.1 --- src/sys/arch/amd64/include/frameasm.h:1.47 Sun Nov 17 14:07:00 2019 +++ src/sys/arch/amd64/include/frameasm.h Sat Apr 11 10:11:30 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: frameasm.h,v 1.47 2019/11/17 14:07:00 maxv Exp $ */ +/* $NetBSD: frameasm.h,v 1.47.6.1 2020/04/11 10:11:30 bouyer Exp $ */ #ifndef _AMD64_MACHINE_FRAMEASM_H #define _AMD64_MACHINE_FRAMEASM_H @@ -31,11 +31,23 @@ movq CPUVAR(VCPU),%r ## temp_reg ; \ movb $0,EVTCHN_UPCALL_MASK(%r ## temp_reg); +#define PUSHF(temp_reg) \ + movq CPUVAR(VCPU),%r ## temp_reg ; \ + movzbl EVTCHN_UPCALL_MASK(%r ## temp_reg), %e ## temp_reg; \ + pushq %r ## temp_reg + +#define POPF \ + popq %rdi; \ + call _C_LABEL(xen_write_psl) + + #else /* XENPV */ #define XEN_ONLY2(x,y) #define NOT_XEN(x) x #define CLI(temp_reg) cli #define STI(temp_reg) sti +#define PUSHF(temp_reg) pushf +#define POPL popl #endif /* XEN */ #define HP_NAME_CLAC 1 Index: src/sys/arch/i386/i386/genassym.cf diff -u src/sys/arch/i386/i386/genassym.cf:1.119.4.1 src/sys/arch/i386/i386/genassym.cf:1.119.4.2 --- src/sys/arch/i386/i386/genassym.cf:1.119.4.1 Wed Apr 8 17:59:16 2020 +++ src/sys/arch/i386/i386/genassym.cf Sat Apr 11 10:11:31 2020 @@ -1,4 +1,4 @@ -# $NetBSD: genassym.cf,v 1.119.4.1 2020/04/08 17:59:16 bouyer Exp $ +# $NetBSD: genassym.cf,v 1.119.4.2 2020/04/11 10:11:31 bouyer Exp $ # # Copyright (c) 1998, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -268,13 +268,11 @@ define CPU_INFO_VENDOR offsetof(struct define CPU_INFO_SIGNATURE offsetof(struct cpu_info, ci_signature) define CPU_INFO_GDT offsetof(struct cpu_info, ci_gdt) -if !defined(XENPV) define CPU_INFO_IPENDING offsetof(struct cpu_info, ci_ipending) define CPU_INFO_IMASKED offsetof(struct cpu_info, ci_imasked) define CPU_INFO_IMASK offsetof(struct cpu_info, ci_imask) define CPU_INFO_ISOURCES offsetof(struct cpu_info, ci_isources) define CPU_INFO_IUNMASK offsetof(struct cpu_info, ci_iunmask) -endif define CPU_INFO_ILEVEL offsetof(struct cpu_info, ci_ilevel) define CPU_INFO_IDEPTH offsetof(struct cpu_info, ci_idepth) define CPU_INFO_MTX_COUNT offsetof(struct cpu_info, ci_mtx_count) Index: src/sys/arch/i386/i386/spl.S diff -u src/sys/arch/i386/i386/spl.S:1.50.4.1 src/sys/arch/i386/i386/spl.S:1.50.4.2 --- src/sys/arch/i386/i386/spl.S:1.50.4.1 Fri Apr 10 14:42:00 2020 +++ src/sys/arch/i386/i386/spl.S Sat Apr 11 10:11:31 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: spl.S,v 1.50.4.1 2020/04/10 14:42:00 bouyer Exp $ */ +/* $NetBSD: spl.S,v 1.50.4.2 2020/04/11 10:11:31 bouyer Exp $ */ /* * Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <machine/asm.h> -__KERNEL_RCSID(0, "$NetBSD: spl.S,v 1.50.4.1 2020/04/10 14:42:00 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: spl.S,v 1.50.4.2 2020/04/11 10:11:31 bouyer Exp $"); #include "opt_ddb.h" #include "opt_spldebug.h" @@ -67,8 +67,6 @@ ENTRY(splraise) ret END(splraise) -#ifndef XENPV - /* * void spllower(int s); * @@ -90,8 +88,8 @@ ENTRY(spllower) cmpl CPUVAR(ILEVEL),%ecx jae 1f movl CPUVAR(IUNMASK)(,%ecx,4),%edx - pushf - cli + PUSHF(%eax) + CLI(%eax) testl CPUVAR(IPENDING),%edx jnz 2f #if defined(XEN) @@ -100,16 +98,25 @@ ENTRY(spllower) jnz 2f #endif movl %ecx,CPUVAR(ILEVEL) - popf + POPF(%eax) 1: ret 2: +#ifdef XENPV + /* + * no need to call stipending, we're going to CLI again + * just drop the saved value on stack + */ + addl $4,%esp +#else popf +#endif jmp _C_LABEL(Xspllower) .align 32 LABEL(spllower_end) END(spllower) +#ifndef XENPV /* * void cx8_spllower(int s); * Index: src/sys/arch/i386/include/frameasm.h diff -u src/sys/arch/i386/include/frameasm.h:1.29 src/sys/arch/i386/include/frameasm.h:1.29.6.1 --- src/sys/arch/i386/include/frameasm.h:1.29 Sat Oct 12 06:31:03 2019 +++ src/sys/arch/i386/include/frameasm.h Sat Apr 11 10:11:31 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: frameasm.h,v 1.29 2019/10/12 06:31:03 maxv Exp $ */ +/* $NetBSD: frameasm.h,v 1.29.6.1 2020/04/11 10:11:31 bouyer Exp $ */ #ifndef _I386_FRAMEASM_H_ #define _I386_FRAMEASM_H_ @@ -25,9 +25,16 @@ #define STIC(reg) movl CPUVAR(VCPU),reg ; \ XEN_UNBLOCK_EVENTS(reg) ; \ testb $0xff,EVTCHN_UPCALL_PENDING(reg) +#define PUSHF(reg) movl CPUVAR(VCPU),reg ; \ + movzbl EVTCHN_UPCALL_MASK(reg), reg; \ + pushl reg +#define POPF(reg) call _C_LABEL(xen_write_psl); \ + addl $4,%esp #else #define CLI(reg) cli #define STI(reg) sti +#define PUSHF(reg) pushf +#define POPF(reg) popf #ifdef XENPVHVM #define STIC(reg) sti ; \ movl CPUVAR(VCPU),reg ; \ Index: src/sys/arch/x86/include/cpu.h diff -u src/sys/arch/x86/include/cpu.h:1.117.4.2 src/sys/arch/x86/include/cpu.h:1.117.4.3 --- src/sys/arch/x86/include/cpu.h:1.117.4.2 Fri Apr 10 14:37:54 2020 +++ src/sys/arch/x86/include/cpu.h Sat Apr 11 10:11:31 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.h,v 1.117.4.2 2020/04/10 14:37:54 bouyer Exp $ */ +/* $NetBSD: cpu.h,v 1.117.4.3 2020/04/11 10:11:31 bouyer Exp $ */ /* * Copyright (c) 1990 The Regents of the University of California. @@ -132,9 +132,7 @@ struct cpu_info { int ci_kfpu_spl; -#ifndef XENPV struct intrsource *ci_isources[MAX_INTR_SOURCES]; -#endif #if defined(XEN) struct intrsource *ci_xsources[NIPL]; uint32_t ci_xmask[NIPL]; Index: src/sys/arch/xen/x86/xen_intr.c diff -u src/sys/arch/xen/x86/xen_intr.c:1.21 src/sys/arch/xen/x86/xen_intr.c:1.21.2.1 --- src/sys/arch/xen/x86/xen_intr.c:1.21 Mon Apr 6 19:26:00 2020 +++ src/sys/arch/xen/x86/xen_intr.c Sat Apr 11 10:11:31 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: xen_intr.c,v 1.21 2020/04/06 19:26:00 jdolecek Exp $ */ +/* $NetBSD: xen_intr.c,v 1.21.2.1 2020/04/11 10:11:31 bouyer Exp $ */ /*- * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: xen_intr.c,v 1.21 2020/04/06 19:26:00 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xen_intr.c,v 1.21.2.1 2020/04/11 10:11:31 bouyer Exp $"); #include "opt_multiprocessor.h" @@ -73,38 +73,6 @@ __KERNEL_RCSID(0, "$NetBSD: xen_intr.c,v static const char *xen_ipi_names[XEN_NIPIS] = XEN_IPI_NAMES; #endif -/* - * Restore a value to cpl (unmasking interrupts). If any unmasked - * interrupts are pending, call Xspllower() to process them. - */ -void xen_spllower(int nlevel); - -void -xen_spllower(int nlevel) -{ - struct cpu_info *ci = curcpu(); - uint32_t xmask; - u_long psl; - - if (ci->ci_ilevel <= nlevel) - return; - - __insn_barrier(); - - xmask = XUNMASK(ci, nlevel); - psl = xen_read_psl(); - x86_disable_intr(); - if (ci->ci_xpending & xmask) { - KASSERT(psl == 0); - Xspllower(nlevel); - /* Xspllower does enable_intr() */ - } else { - ci->ci_ilevel = nlevel; - xen_write_psl(psl); - } -} - - #if !defined(XENPVHVM) void x86_disable_intr(void)