Export CPU capability of unaligned memory access to userland

as machdep.no_unaligned sysctl(7) variable.

This will be used for ld.so.conf in order to provide strictly-
aligned versions of libc routines.
This commit is contained in:
rin 2022-05-30 14:48:08 +00:00
parent 2ca271943c
commit 3f93e51ec6
2 changed files with 16 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: cpu.h,v 1.121 2022/05/30 14:05:36 rin Exp $ */
/* $NetBSD: cpu.h,v 1.122 2022/05/30 14:48:08 rin Exp $ */
/*
* Copyright (C) 1999 Wolfgang Solfrank.
@ -511,5 +511,6 @@ void __syncicache(void *, size_t);
#define CPU_BOOTED_KERNEL 10 /* string: kernel we booted */
#define CPU_EXECPROT 11 /* bool: PROT_EXEC works */
#define CPU_FPU 12
#define CPU_NO_UNALIGNED 13 /* No HW support for unaligned access */
#endif /* _POWERPC_CPU_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: powerpc_machdep.c,v 1.85 2022/05/20 19:34:22 andvar Exp $ */
/* $NetBSD: powerpc_machdep.c,v 1.86 2022/05/30 14:48:08 rin Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: powerpc_machdep.c,v 1.85 2022/05/20 19:34:22 andvar Exp $");
__KERNEL_RCSID(0, "$NetBSD: powerpc_machdep.c,v 1.86 2022/05/30 14:48:08 rin Exp $");
#ifdef _KERNEL_OPT
#include "opt_altivec.h"
@ -40,6 +40,7 @@ __KERNEL_RCSID(0, "$NetBSD: powerpc_machdep.c,v 1.85 2022/05/20 19:34:22 andvar
#include "opt_modular.h"
#include "opt_multiprocessor.h"
#include "opt_ppcarch.h"
#include "opt_ppcopts.h"
#endif
#include <sys/param.h>
@ -301,6 +302,17 @@ SYSCTL_SETUP(sysctl_machdep_setup, "sysctl machdep subtree setup")
#endif
NULL, 0,
CTL_MACHDEP, CPU_FPU, CTL_EOL);
sysctl_createv(clog, 0, NULL, NULL,
CTLFLAG_PERMANENT|CTLFLAG_IMMEDIATE,
CTLTYPE_INT, "no_unaligned", NULL,
NULL,
#if defined(PPC_NO_UNALIGNED)
1,
#else
0,
#endif
NULL, 0,
CTL_MACHDEP, CPU_NO_UNALIGNED, CTL_EOL);
}
/*