Module Name: src Committed By: martin Date: Tue Oct 31 12:37:23 UTC 2017
Modified Files: src/sys/arch/arm/arm32: arm32_machdep.c src/sys/arch/arm/include: netbsd32_machdep.h proc.h src/sys/arch/mips/include: netbsd32_machdep.h src/sys/arch/mips/mips: netbsd32_machdep.c src/sys/compat/netbsd32: netbsd32_sysctl.c src/sys/kern: init_sysctl_base.c Log Message: Allow architectures to define a macro PROC_MACHINE_ARCH(P) and PROC_MACHINE_ARCH32(P) to override the value for sysctl hw.machine_arch (native and netbsd32 commpat resp.). Use these for arm and mips instead of the (not working, noisy, in case of arm) sysctl override and #ifdef __mips__ in architecture neutral code. To generate a diff of this commit: cvs rdiff -u -r1.114 -r1.115 src/sys/arch/arm/arm32/arm32_machdep.c cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/include/netbsd32_machdep.h cvs rdiff -u -r1.17 -r1.18 src/sys/arch/arm/include/proc.h cvs rdiff -u -r1.4 -r1.5 src/sys/arch/mips/include/netbsd32_machdep.h cvs rdiff -u -r1.14 -r1.15 src/sys/arch/mips/mips/netbsd32_machdep.c cvs rdiff -u -r1.36 -r1.37 src/sys/compat/netbsd32/netbsd32_sysctl.c cvs rdiff -u -r1.7 -r1.8 src/sys/kern/init_sysctl_base.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/arm/arm32/arm32_machdep.c diff -u src/sys/arch/arm/arm32/arm32_machdep.c:1.114 src/sys/arch/arm/arm32/arm32_machdep.c:1.115 --- src/sys/arch/arm/arm32/arm32_machdep.c:1.114 Sun Jul 2 16:16:44 2017 +++ src/sys/arch/arm/arm32/arm32_machdep.c Tue Oct 31 12:37:23 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: arm32_machdep.c,v 1.114 2017/07/02 16:16:44 skrll Exp $ */ +/* $NetBSD: arm32_machdep.c,v 1.115 2017/10/31 12:37:23 martin Exp $ */ /* * Copyright (c) 1994-1998 Mark Brinicombe. @@ -42,7 +42,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: arm32_machdep.c,v 1.114 2017/07/02 16:16:44 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: arm32_machdep.c,v 1.115 2017/10/31 12:37:23 martin Exp $"); #include "opt_modular.h" #include "opt_md.h" @@ -402,15 +402,6 @@ sysctl_machdep_powersave(SYSCTLFN_ARGS) return (0); } -static int -sysctl_hw_machine_arch(SYSCTLFN_ARGS) -{ - struct sysctlnode node = *rnode; - node.sysctl_data = l->l_proc->p_md.md_march; - node.sysctl_size = strlen(l->l_proc->p_md.md_march) + 1; - return sysctl_lookup(SYSCTLFN_CALL(&node)); -} - SYSCTL_SETUP(sysctl_machdep_setup, "sysctl machdep subtree setup") { @@ -532,18 +523,6 @@ SYSCTL_SETUP(sysctl_machdep_setup, "sysc SYSCTL_DESCR("Do SIGBUS for fixed unaligned accesses"), NULL, 0, &cpu_unaligned_sigbus, 0, CTL_MACHDEP, CTL_CREATE, CTL_EOL); - - - /* - * We need override the usual CTL_HW HW_MACHINE_ARCH so we - * return the right machine_arch based on the running executable. - */ - sysctl_createv(clog, 0, NULL, NULL, - CTLFLAG_PERMANENT|CTLFLAG_READONLY, - CTLTYPE_STRING, "machine_arch", - SYSCTL_DESCR("Machine CPU class"), - sysctl_hw_machine_arch, 0, NULL, 0, - CTL_HW, HW_MACHINE_ARCH, CTL_EOL); } void Index: src/sys/arch/arm/include/netbsd32_machdep.h diff -u src/sys/arch/arm/include/netbsd32_machdep.h:1.1 src/sys/arch/arm/include/netbsd32_machdep.h:1.2 --- src/sys/arch/arm/include/netbsd32_machdep.h:1.1 Fri Aug 3 07:59:23 2012 +++ src/sys/arch/arm/include/netbsd32_machdep.h Tue Oct 31 12:37:23 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: netbsd32_machdep.h,v 1.1 2012/08/03 07:59:23 matt Exp $ */ +/* $NetBSD: netbsd32_machdep.h,v 1.2 2017/10/31 12:37:23 martin Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -45,6 +45,9 @@ typedef struct { NETBSD32_POINTER_TYPE i typedef netbsd32_pointer_t netbsd32_sigcontextp_t; +/* Support varying ABI names for netbsd32 */ +#define PROC_MACHINE_ARCH32(P) ((P)->p_md.md_march) + /* * The sigcode is ABI neutral. */ Index: src/sys/arch/arm/include/proc.h diff -u src/sys/arch/arm/include/proc.h:1.17 src/sys/arch/arm/include/proc.h:1.18 --- src/sys/arch/arm/include/proc.h:1.17 Mon Feb 24 16:57:57 2014 +++ src/sys/arch/arm/include/proc.h Tue Oct 31 12:37:23 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: proc.h,v 1.17 2014/02/24 16:57:57 christos Exp $ */ +/* $NetBSD: proc.h,v 1.18 2017/10/31 12:37:23 martin Exp $ */ /* * Copyright (c) 1994 Mark Brinicombe. @@ -59,6 +59,7 @@ struct mdproc { char md_march[12]; /* machine arch of executable */ }; -#define PROC0_MD_INITIALIZERS .p_md = { .md_march = MACHINE_ARCH }, +#define PROC_MACHINE_ARCH(P) ((P)->p_md.md_march) +#define PROC0_MD_INITIALIZERS .p_md = { .md_march = MACHINE_ARCH }, #endif /* _ARM_PROC_H_ */ Index: src/sys/arch/mips/include/netbsd32_machdep.h diff -u src/sys/arch/mips/include/netbsd32_machdep.h:1.4 src/sys/arch/mips/include/netbsd32_machdep.h:1.5 --- src/sys/arch/mips/include/netbsd32_machdep.h:1.4 Sun May 17 18:52:37 2015 +++ src/sys/arch/mips/include/netbsd32_machdep.h Tue Oct 31 12:37:23 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: netbsd32_machdep.h,v 1.4 2015/05/17 18:52:37 matt Exp $ */ +/* $NetBSD: netbsd32_machdep.h,v 1.5 2017/10/31 12:37:23 martin Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -44,6 +44,11 @@ typedef struct { NETBSD32_POINTER_TYPE i typedef netbsd32_pointer_t netbsd32_sigcontextp_t; +/* Support varying ABI names for netbsd32 */ +extern const char machine_arch32[]; +#define PROC_MACHINE_ARCH32(P) ((P)->p_md.md_abi == _MIPS_BSD_API_O32) ? \ + __UNCONST(machine_arch32) : machine_arch + /* * The sigcode is ABI neutral. */ @@ -69,6 +74,4 @@ struct mips_cachectl_args32 { int ctl; }; -int cpu_machinearch32(SYSCTLFN_PROTO); - #endif /* _MACHINE_NETBSD32_H_ */ Index: src/sys/arch/mips/mips/netbsd32_machdep.c diff -u src/sys/arch/mips/mips/netbsd32_machdep.c:1.14 src/sys/arch/mips/mips/netbsd32_machdep.c:1.15 --- src/sys/arch/mips/mips/netbsd32_machdep.c:1.14 Thu Mar 16 16:13:20 2017 +++ src/sys/arch/mips/mips/netbsd32_machdep.c Tue Oct 31 12:37:23 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: netbsd32_machdep.c,v 1.14 2017/03/16 16:13:20 chs Exp $ */ +/* $NetBSD: netbsd32_machdep.c,v 1.15 2017/10/31 12:37:23 martin Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.14 2017/03/16 16:13:20 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.15 2017/10/31 12:37:23 martin Exp $"); #include "opt_compat_netbsd.h" #include "opt_coredump.h" @@ -343,14 +343,3 @@ cpu_coredump32(struct lwp *l, struct cor chdr->c_cpusize); } #endif - -int -cpu_machinearch32(SYSCTLFN_ARGS) -{ - struct sysctlnode node = *rnode; - const char *march = l->l_proc->p_md.md_abi == _MIPS_BSD_API_O32 - ? machine_arch32 : machine_arch; - node.sysctl_data = __UNCONST(march); - node.sysctl_size = strlen(march) + 1; - return sysctl_lookup(SYSCTLFN_CALL(&node)); -} Index: src/sys/compat/netbsd32/netbsd32_sysctl.c diff -u src/sys/compat/netbsd32/netbsd32_sysctl.c:1.36 src/sys/compat/netbsd32/netbsd32_sysctl.c:1.37 --- src/sys/compat/netbsd32/netbsd32_sysctl.c:1.36 Sun May 17 18:52:37 2015 +++ src/sys/compat/netbsd32/netbsd32_sysctl.c Tue Oct 31 12:37:23 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: netbsd32_sysctl.c,v 1.36 2015/05/17 18:52:37 matt Exp $ */ +/* $NetBSD: netbsd32_sysctl.c,v 1.37 2017/10/31 12:37:23 martin Exp $ */ /* * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: netbsd32_sysctl.c,v 1.36 2015/05/17 18:52:37 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: netbsd32_sysctl.c,v 1.37 2017/10/31 12:37:23 martin Exp $"); #if defined(_KERNEL_OPT) #include "opt_ddb.h" @@ -104,13 +104,24 @@ netbsd32_sysctl_vm_loadavg(SYSCTLFN_ARGS return (sysctl_lookup(SYSCTLFN_CALL(&node))); } +static int +sysctl_hw_machine_arch32(SYSCTLFN_ARGS) +{ + struct sysctlnode node = *rnode; +#ifndef PROC_MACHINE_ARCH32 + extern const char machine_arch32[]; +#define PROC_MACHINE_ARCH32(P) machine_arch32 +#endif + + node.sysctl_data = PROC_MACHINE_ARCH32(l->l_proc); + node.sysctl_size = strlen(node.sysctl_data) + 1; + return sysctl_lookup(SYSCTLFN_CALL(&node)); +} + void netbsd32_sysctl_init(void) { const struct sysctlnode *_root = &netbsd32_sysctl_root; -#ifndef __mips__ - extern const char machine_arch32[]; -#endif extern const char machine32[]; sysctl_createv(&netbsd32_clog, 0, &_root, NULL, @@ -152,19 +163,11 @@ netbsd32_sysctl_init(void) CTLTYPE_STRING, "machine", NULL, NULL, 0, __UNCONST(&machine32), 0, CTL_HW, HW_MACHINE, CTL_EOL); -#ifdef __mips__ sysctl_createv(&netbsd32_clog, 0, &_root, NULL, - CTLFLAG_PERMANENT, + CTLFLAG_PERMANENT|CTLFLAG_READONLY, CTLTYPE_STRING, "machine_arch", NULL, - cpu_machinearch32, 0, NULL, 0, + sysctl_hw_machine_arch32, 0, NULL, 0, CTL_HW, HW_MACHINE_ARCH, CTL_EOL); -#else - sysctl_createv(&netbsd32_clog, 0, &_root, NULL, - CTLFLAG_PERMANENT, - CTLTYPE_STRING, "machine_arch", NULL, - NULL, 0, __UNCONST(&machine_arch32), 0, - CTL_HW, HW_MACHINE_ARCH, CTL_EOL); -#endif } void Index: src/sys/kern/init_sysctl_base.c diff -u src/sys/kern/init_sysctl_base.c:1.7 src/sys/kern/init_sysctl_base.c:1.8 --- src/sys/kern/init_sysctl_base.c:1.7 Tue Aug 25 14:52:31 2015 +++ src/sys/kern/init_sysctl_base.c Tue Oct 31 12:37:23 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: init_sysctl_base.c,v 1.7 2015/08/25 14:52:31 pooka Exp $ */ +/* $NetBSD: init_sysctl_base.c,v 1.8 2017/10/31 12:37:23 martin Exp $ */ /*- * Copyright (c) 2003, 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -30,11 +30,12 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: init_sysctl_base.c,v 1.7 2015/08/25 14:52:31 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: init_sysctl_base.c,v 1.8 2017/10/31 12:37:23 martin Exp $"); #include <sys/types.h> #include <sys/param.h> #include <sys/sysctl.h> +#include <sys/proc.h> #include <sys/cpu.h> #include <sys/kernel.h> #include <sys/disklabel.h> @@ -183,6 +184,19 @@ SYSCTL_SETUP(sysctl_kernbase_setup, "sys CTL_KERN, KERN_RAWPARTITION, CTL_EOL); } +static int +sysctl_hw_machine_arch(SYSCTLFN_ARGS) +{ + struct sysctlnode node = *rnode; +#ifndef PROC_MACHINE_ARCH +#define PROC_MACHINE_ARCH(P) machine_arch +#endif + + node.sysctl_data = PROC_MACHINE_ARCH(l->l_proc); + node.sysctl_size = strlen(node.sysctl_data) + 1; + return sysctl_lookup(SYSCTLFN_CALL(&node)); +} + SYSCTL_SETUP(sysctl_hwbase_setup, "sysctl hw subtree base setup") { u_int u; @@ -202,10 +216,10 @@ SYSCTL_SETUP(sysctl_hwbase_setup, "sysct NULL, 0, machine, 0, CTL_HW, HW_MACHINE, CTL_EOL); sysctl_createv(clog, 0, NULL, NULL, - CTLFLAG_PERMANENT, + CTLFLAG_PERMANENT|CTLFLAG_READONLY, CTLTYPE_STRING, "machine_arch", SYSCTL_DESCR("Machine CPU class"), - NULL, 0, machine_arch, 0, + sysctl_hw_machine_arch, 0, NULL, 0, CTL_HW, HW_MACHINE_ARCH, CTL_EOL); sysctl_createv(clog, 0, NULL, NULL, CTLFLAG_PERMANENT,