Commit a1564371 authored by HardenedBSD Sync Service's avatar HardenedBSD Sync Service
Browse files

Merge branch 'freebsd/current/main' into hardened/current/master

parents dabbe191 48736535
...@@ -32,6 +32,16 @@ SUBDIR+= xray-fdr ...@@ -32,6 +32,16 @@ SUBDIR+= xray-fdr
SUBDIR+= xray-profiling SUBDIR+= xray-profiling
.endif # amd64 .endif # amd64
.if ${MACHINE_CPUARCH} == "riscv"
SUBDIR+= asan
SUBDIR+= asan-preinit
SUBDIR+= asan_cxx
SUBDIR+= asan_dynamic
SUBDIR+= ubsan_minimal
SUBDIR+= ubsan_standalone
SUBDIR+= ubsan_standalone_cxx
.endif # riscv
SUBDIR+= profile SUBDIR+= profile
SUBDIR_PARALLEL= SUBDIR_PARALLEL=
......
...@@ -345,7 +345,7 @@ geli_io(struct geli_dev *gdev, geli_op_t enc, off_t offset, u_char *buf, ...@@ -345,7 +345,7 @@ geli_io(struct geli_dev *gdev, geli_op_t enc, off_t offset, u_char *buf,
g_eli_key_fill(&gdev->sc, &gkey, keyno); g_eli_key_fill(&gdev->sc, &gkey, keyno);
error = geliboot_crypt(gdev->sc.sc_ealgo, enc, pbuf, secsize, error = geliboot_crypt(gdev->sc.sc_ealgo, enc, pbuf, secsize,
gkey.gek_key, gdev->sc.sc_ekeylen, iv, sizeof(iv)); gkey.gek_key, gdev->sc.sc_ekeylen, iv);
if (error != 0) { if (error != 0) {
explicit_bzero(&gkey, sizeof(gkey)); explicit_bzero(&gkey, sizeof(gkey));
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
int int
geliboot_crypt(u_int algo, geli_op_t enc, u_char *data, size_t datasize, geliboot_crypt(u_int algo, geli_op_t enc, u_char *data, size_t datasize,
const u_char *key, size_t keysize, u_char *iv, size_t ivlen) const u_char *key, size_t keysize, u_char *iv)
{ {
keyInstance aeskey; keyInstance aeskey;
cipherInstance cipher; cipherInstance cipher;
...@@ -81,7 +81,7 @@ geliboot_crypt(u_int algo, geli_op_t enc, u_char *data, size_t datasize, ...@@ -81,7 +81,7 @@ geliboot_crypt(u_int algo, geli_op_t enc, u_char *data, size_t datasize,
ctxp = &xtsctx; ctxp = &xtsctx;
enc_xform_aes_xts.setkey(ctxp, key, xts_len / 8); enc_xform_aes_xts.setkey(ctxp, key, xts_len / 8);
enc_xform_aes_xts.reinit(ctxp, iv, ivlen); enc_xform_aes_xts.reinit(ctxp, iv, AES_XTS_IV_LEN);
switch (enc) { switch (enc) {
case GELI_DECRYPT: case GELI_DECRYPT:
...@@ -106,11 +106,10 @@ static int ...@@ -106,11 +106,10 @@ static int
g_eli_crypto_cipher(u_int algo, geli_op_t enc, u_char *data, size_t datasize, g_eli_crypto_cipher(u_int algo, geli_op_t enc, u_char *data, size_t datasize,
const u_char *key, size_t keysize) const u_char *key, size_t keysize)
{ {
u_char iv[keysize]; u_char iv[G_ELI_IVKEYLEN];
explicit_bzero(iv, sizeof(iv)); explicit_bzero(iv, sizeof(iv));
return (geliboot_crypt(algo, enc, data, datasize, key, keysize, iv, return (geliboot_crypt(algo, enc, data, datasize, key, keysize, iv));
sizeof(iv)));
} }
int int
......
...@@ -68,6 +68,6 @@ struct geli_dev { ...@@ -68,6 +68,6 @@ struct geli_dev {
}; };
int geliboot_crypt(u_int algo, geli_op_t enc, u_char *data, size_t datasize, int geliboot_crypt(u_int algo, geli_op_t enc, u_char *data, size_t datasize,
const u_char *key, size_t keysize, u_char *iv, size_t ivlen); const u_char *key, size_t keysize, u_char *iv);
#endif /* _GELIBOOT_INTERNAL_H_ */ #endif /* _GELIBOOT_INTERNAL_H_ */
...@@ -339,7 +339,7 @@ freebsd32_swapcontext(struct thread *td, struct freebsd32_swapcontext_args *uap) ...@@ -339,7 +339,7 @@ freebsd32_swapcontext(struct thread *td, struct freebsd32_swapcontext_args *uap)
static void static void
ia32_osendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) ia32_osendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
{ {
struct ia32_sigframe3 sf, *fp; struct ia32_osigframe sf, *fp;
struct proc *p; struct proc *p;
struct thread *td; struct thread *td;
struct sigacts *psp; struct sigacts *psp;
...@@ -359,11 +359,11 @@ ia32_osendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) ...@@ -359,11 +359,11 @@ ia32_osendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
/* Allocate space for the signal handler context. */ /* Allocate space for the signal handler context. */
if ((td->td_pflags & TDP_ALTSTACK) && !oonstack && if ((td->td_pflags & TDP_ALTSTACK) && !oonstack &&
SIGISMEMBER(psp->ps_sigonstack, sig)) { SIGISMEMBER(psp->ps_sigonstack, sig)) {
fp = (struct ia32_sigframe3 *)((uintptr_t)td->td_sigstk.ss_sp + fp = (struct ia32_osigframe *)((uintptr_t)td->td_sigstk.ss_sp +
td->td_sigstk.ss_size - sizeof(sf)); td->td_sigstk.ss_size - sizeof(sf));
td->td_sigstk.ss_flags |= SS_ONSTACK; td->td_sigstk.ss_flags |= SS_ONSTACK;
} else } else
fp = (struct ia32_sigframe3 *)regs->tf_rsp - 1; fp = (struct ia32_osigframe *)regs->tf_rsp - 1;
/* Build the argument list for the signal handler. */ /* Build the argument list for the signal handler. */
sf.sf_signum = sig; sf.sf_signum = sig;
...@@ -441,7 +441,7 @@ ia32_osendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) ...@@ -441,7 +441,7 @@ ia32_osendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
static void static void
freebsd4_ia32_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) freebsd4_ia32_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
{ {
struct ia32_sigframe4 sf, *sfp; struct ia32_freebsd4_sigframe sf, *sfp;
struct siginfo32 siginfo; struct siginfo32 siginfo;
struct proc *p; struct proc *p;
struct thread *td; struct thread *td;
...@@ -497,10 +497,10 @@ freebsd4_ia32_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) ...@@ -497,10 +497,10 @@ freebsd4_ia32_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
/* Allocate space for the signal handler context. */ /* Allocate space for the signal handler context. */
if ((td->td_pflags & TDP_ALTSTACK) != 0 && !oonstack && if ((td->td_pflags & TDP_ALTSTACK) != 0 && !oonstack &&
SIGISMEMBER(psp->ps_sigonstack, sig)) { SIGISMEMBER(psp->ps_sigonstack, sig)) {
sfp = (struct ia32_sigframe4 *)((uintptr_t)td->td_sigstk.ss_sp + sfp = (struct ia32_freebsd4_sigframe *)((uintptr_t)td->td_sigstk.ss_sp +
td->td_sigstk.ss_size - sizeof(sf)); td->td_sigstk.ss_size - sizeof(sf));
} else } else
sfp = (struct ia32_sigframe4 *)regs->tf_rsp - 1; sfp = (struct ia32_freebsd4_sigframe *)regs->tf_rsp - 1;
PROC_UNLOCK(p); PROC_UNLOCK(p);
/* Build the argument list for the signal handler. */ /* Build the argument list for the signal handler. */
...@@ -696,7 +696,7 @@ ia32_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) ...@@ -696,7 +696,7 @@ ia32_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
int int
ofreebsd32_sigreturn(struct thread *td, struct ofreebsd32_sigreturn_args *uap) ofreebsd32_sigreturn(struct thread *td, struct ofreebsd32_sigreturn_args *uap)
{ {
struct ia32_sigcontext3 sc, *scp; struct ia32_osigcontext sc, *scp;
struct trapframe *regs; struct trapframe *regs;
int eflags, error; int eflags, error;
ksiginfo_t ksi; ksiginfo_t ksi;
...@@ -754,9 +754,9 @@ int ...@@ -754,9 +754,9 @@ int
freebsd4_freebsd32_sigreturn(struct thread *td, freebsd4_freebsd32_sigreturn(struct thread *td,
struct freebsd4_freebsd32_sigreturn_args *uap) struct freebsd4_freebsd32_sigreturn_args *uap)
{ {
struct ia32_ucontext4 uc; struct ia32_freebsd4_ucontext uc;
struct trapframe *regs; struct trapframe *regs;
struct ia32_ucontext4 *ucp; struct ia32_freebsd4_ucontext *ucp;
int cs, eflags, error; int cs, eflags, error;
ksiginfo_t ksi; ksiginfo_t ksi;
......
...@@ -39,16 +39,16 @@ ...@@ -39,16 +39,16 @@
#include <sys/sysctl.h> #include <sys/sysctl.h>
typedef struct enc_element { typedef struct enc_element {
uint8_t elm_idx; /* index of element */ u_int elm_idx; /* index of element */
uint8_t elm_type; /* element type */ uint8_t elm_type; /* element type */
uint8_t subenclosure; /* subenclosure id */ uint8_t subenclosure; /* subenclosure id */
uint8_t type_elm_idx; /* index of element within type */ uint8_t type_elm_idx; /* index of element within type */
uint8_t svalid; /* enclosure information valid */ uint8_t svalid; /* enclosure information valid */
uint16_t priv; /* private data, per object */
uint8_t encstat[4]; /* state && stats */ uint8_t encstat[4]; /* state && stats */
u_int physical_path_len; /* Length of device path data. */
uint8_t *physical_path; /* Device physical path data. */ uint8_t *physical_path; /* Device physical path data. */
u_int physical_path_len; /* Length of device path data. */
void *elm_private; /* per-type object data */ void *elm_private; /* per-type object data */
uint16_t priv;
} enc_element_t; } enc_element_t;
typedef enum { typedef enum {
......
...@@ -30,12 +30,12 @@ ASSYM(IA32_UC_SS, offsetof(struct ia32_ucontext, uc_mcontext.mc_ss)); ...@@ -30,12 +30,12 @@ ASSYM(IA32_UC_SS, offsetof(struct ia32_ucontext, uc_mcontext.mc_ss));
ASSYM(IA32_UC_FSBASE, offsetof(struct ia32_ucontext, uc_mcontext.mc_fsbase)); ASSYM(IA32_UC_FSBASE, offsetof(struct ia32_ucontext, uc_mcontext.mc_fsbase));
ASSYM(IA32_UC_GSBASE, offsetof(struct ia32_ucontext, uc_mcontext.mc_gsbase)); ASSYM(IA32_UC_GSBASE, offsetof(struct ia32_ucontext, uc_mcontext.mc_gsbase));
#ifdef COMPAT_43 #ifdef COMPAT_43
ASSYM(IA32_SIGF_SC, offsetof(struct ia32_sigframe3, sf_siginfo.si_sc)); ASSYM(IA32_SIGF_SC, offsetof(struct ia32_osigframe, sf_siginfo.si_sc));
#endif #endif
#ifdef COMPAT_FREEBSD4 #ifdef COMPAT_FREEBSD4
ASSYM(IA32_SIGF_UC4, offsetof(struct ia32_sigframe4, sf_uc)); ASSYM(IA32_SIGF_UC4, offsetof(struct ia32_freebsd4_sigframe, sf_uc));
ASSYM(IA32_UC4_GS, offsetof(struct ia32_ucontext4, uc_mcontext.mc_gs)); ASSYM(IA32_UC4_GS, offsetof(struct ia32_freebsd4_ucontext, uc_mcontext.mc_gs));
ASSYM(IA32_UC4_FS, offsetof(struct ia32_ucontext4, uc_mcontext.mc_fs)); ASSYM(IA32_UC4_FS, offsetof(struct ia32_freebsd4_ucontext, uc_mcontext.mc_fs));
ASSYM(IA32_UC4_ES, offsetof(struct ia32_ucontext4, uc_mcontext.mc_es)); ASSYM(IA32_UC4_ES, offsetof(struct ia32_freebsd4_ucontext, uc_mcontext.mc_es));
ASSYM(IA32_UC4_DS, offsetof(struct ia32_ucontext4, uc_mcontext.mc_ds)); ASSYM(IA32_UC4_DS, offsetof(struct ia32_freebsd4_ucontext, uc_mcontext.mc_ds));
#endif #endif
...@@ -88,8 +88,7 @@ struct ia32_ucontext { ...@@ -88,8 +88,7 @@ struct ia32_ucontext {
uint32_t __spare__[4]; uint32_t __spare__[4];
}; };
#if defined(COMPAT_FREEBSD4) struct ia32_freebsd4_mcontext {
struct ia32_mcontext4 {
uint32_t mc_onstack; /* XXX - sigcontext compat. */ uint32_t mc_onstack; /* XXX - sigcontext compat. */
uint32_t mc_gs; /* machine state (struct trapframe) */ uint32_t mc_gs; /* machine state (struct trapframe) */
uint32_t mc_fs; uint32_t mc_fs;
...@@ -114,17 +113,15 @@ struct ia32_mcontext4 { ...@@ -114,17 +113,15 @@ struct ia32_mcontext4 {
uint32_t __spare__[17]; uint32_t __spare__[17];
}; };
struct ia32_ucontext4 { struct ia32_freebsd4_ucontext {
sigset_t uc_sigmask; sigset_t uc_sigmask;
struct ia32_mcontext4 uc_mcontext; struct ia32_freebsd4_mcontext uc_mcontext;
uint32_t uc_link; uint32_t uc_link;
struct sigaltstack32 uc_stack; struct sigaltstack32 uc_stack;
uint32_t __spare__[8]; uint32_t __spare__[8];
}; };
#endif
#ifdef COMPAT_43 struct ia32_osigcontext {
struct ia32_sigcontext3 {
uint32_t sc_onstack; uint32_t sc_onstack;
uint32_t sc_mask; uint32_t sc_mask;
uint32_t sc_esp; uint32_t sc_esp;
...@@ -147,23 +144,20 @@ struct ia32_sigcontext3 { ...@@ -147,23 +144,20 @@ struct ia32_sigcontext3 {
uint32_t sc_trapno; uint32_t sc_trapno;
uint32_t sc_err; uint32_t sc_err;
}; };
#endif
/* /*
* Signal frames, arguments passed to application signal handlers. * Signal frames, arguments passed to application signal handlers.
*/ */
#ifdef COMPAT_FREEBSD4 struct ia32_freebsd4_sigframe {
struct ia32_sigframe4 {
uint32_t sf_signum; uint32_t sf_signum;
uint32_t sf_siginfo; /* code or pointer to sf_si */ uint32_t sf_siginfo; /* code or pointer to sf_si */
uint32_t sf_ucontext; /* points to sf_uc */ uint32_t sf_ucontext; /* points to sf_uc */
uint32_t sf_addr; /* undocumented 4th arg */ uint32_t sf_addr; /* undocumented 4th arg */
uint32_t sf_ah; /* action/handler pointer */ uint32_t sf_ah; /* action/handler pointer */
struct ia32_ucontext4 sf_uc; /* = *sf_ucontext */ struct ia32_freebsd4_ucontext sf_uc; /* = *sf_ucontext */
struct siginfo32 sf_si; /* = *sf_siginfo (SA_SIGINFO case) */ struct siginfo32 sf_si; /* = *sf_siginfo (SA_SIGINFO case) */
}; };
#endif
struct ia32_sigframe { struct ia32_sigframe {
uint32_t sf_signum; uint32_t sf_signum;
...@@ -176,22 +170,20 @@ struct ia32_sigframe { ...@@ -176,22 +170,20 @@ struct ia32_sigframe {
struct siginfo32 sf_si; /* = *sf_siginfo (SA_SIGINFO case) */ struct siginfo32 sf_si; /* = *sf_siginfo (SA_SIGINFO case) */
}; };
#ifdef COMPAT_43 struct ia32_osiginfo {
struct ia32_siginfo3 { struct ia32_osigcontext si_sc;
struct ia32_sigcontext3 si_sc;
int si_signo; int si_signo;
int si_code; int si_code;
union sigval32 si_value; union sigval32 si_value;
}; };
struct ia32_sigframe3 { struct ia32_osigframe {
int sf_signum; int sf_signum;
uint32_t sf_arg2; /* int or siginfo_t */ uint32_t sf_arg2; /* int or siginfo_t */
uint32_t sf_scp; uint32_t sf_scp;
uint32_t sf_addr; uint32_t sf_addr;
uint32_t sf_ah; /* action/handler pointer */ uint32_t sf_ah; /* action/handler pointer */
struct ia32_siginfo3 sf_siginfo; struct ia32_osiginfo sf_siginfo;
}; };
#endif
struct ksiginfo; struct ksiginfo;
struct image_params; struct image_params;
......
...@@ -81,9 +81,9 @@ CTASSERT(sizeof(struct ia32_ucontext) == 704); ...@@ -81,9 +81,9 @@ CTASSERT(sizeof(struct ia32_ucontext) == 704);
CTASSERT(sizeof(struct ia32_sigframe) == 800); CTASSERT(sizeof(struct ia32_sigframe) == 800);
CTASSERT(sizeof(struct siginfo32) == 64); CTASSERT(sizeof(struct siginfo32) == 64);
#ifdef COMPAT_FREEBSD4 #ifdef COMPAT_FREEBSD4
CTASSERT(sizeof(struct ia32_mcontext4) == 260); CTASSERT(sizeof(struct ia32_freebsd4_mcontext) == 260);
CTASSERT(sizeof(struct ia32_ucontext4) == 324); CTASSERT(sizeof(struct ia32_freebsd4_ucontext) == 324);
CTASSERT(sizeof(struct ia32_sigframe4) == 408); CTASSERT(sizeof(struct ia32_freebsd4_sigframe) == 408);
#endif #endif
#include "vdso_ia32_offsets.h" #include "vdso_ia32_offsets.h"
......
...@@ -112,7 +112,7 @@ g_eli_crypto_cipher(u_int algo, int enc, u_char *data, size_t datasize, ...@@ -112,7 +112,7 @@ g_eli_crypto_cipher(u_int algo, int enc, u_char *data, size_t datasize,
{ {
EVP_CIPHER_CTX *ctx; EVP_CIPHER_CTX *ctx;
const EVP_CIPHER *type; const EVP_CIPHER *type;
u_char iv[keysize]; u_char iv[G_ELI_IVKEYLEN];
int outsize; int outsize;
assert(algo != CRYPTO_AES_XTS); assert(algo != CRYPTO_AES_XTS);
......
...@@ -256,7 +256,7 @@ osendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) ...@@ -256,7 +256,7 @@ osendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
static void static void
freebsd4_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) freebsd4_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
{ {
struct sigframe4 sf, *sfp; struct freebsd4_sigframe sf, *sfp;
struct proc *p; struct proc *p;
struct thread *td; struct thread *td;
struct sigacts *psp; struct sigacts *psp;
...@@ -291,13 +291,13 @@ freebsd4_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) ...@@ -291,13 +291,13 @@ freebsd4_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
/* Allocate space for the signal handler context. */ /* Allocate space for the signal handler context. */
if ((td->td_pflags & TDP_ALTSTACK) != 0 && !oonstack && if ((td->td_pflags & TDP_ALTSTACK) != 0 && !oonstack &&
SIGISMEMBER(psp->ps_sigonstack, sig)) { SIGISMEMBER(psp->ps_sigonstack, sig)) {
sfp = (struct sigframe4 *)((uintptr_t)td->td_sigstk.ss_sp + sfp = (struct freebsd4_sigframe *)((uintptr_t)td->td_sigstk.ss_sp +
td->td_sigstk.ss_size - sizeof(struct sigframe4)); td->td_sigstk.ss_size - sizeof(struct freebsd4_sigframe));
#if defined(COMPAT_43) #if defined(COMPAT_43)
td->td_sigstk.ss_flags |= SS_ONSTACK; td->td_sigstk.ss_flags |= SS_ONSTACK;
#endif #endif
} else } else
sfp = (struct sigframe4 *)regs->tf_esp - 1; sfp = (struct freebsd4_sigframe *)regs->tf_esp - 1;
/* Build the argument list for the signal handler. */ /* Build the argument list for the signal handler. */
sf.sf_signum = sig; sf.sf_signum = sig;
......
...@@ -162,7 +162,7 @@ ASSYM(SIGF_SC, offsetof(struct osigframe, sf_siginfo.si_sc)); ...@@ -162,7 +162,7 @@ ASSYM(SIGF_SC, offsetof(struct osigframe, sf_siginfo.si_sc));
#endif #endif
ASSYM(SIGF_UC, offsetof(struct sigframe, sf_uc)); ASSYM(SIGF_UC, offsetof(struct sigframe, sf_uc));
#ifdef COMPAT_FREEBSD4 #ifdef COMPAT_FREEBSD4
ASSYM(SIGF_UC4, offsetof(struct sigframe4, sf_uc)); ASSYM(SIGF_UC4, offsetof(struct freebsd4_sigframe, sf_uc));
#endif #endif
#ifdef COMPAT_43 #ifdef COMPAT_43
ASSYM(SC_PS, offsetof(struct osigcontext, sc_ps)); ASSYM(SC_PS, offsetof(struct osigcontext, sc_ps));
......
...@@ -75,7 +75,7 @@ struct osigframe { ...@@ -75,7 +75,7 @@ struct osigframe {
#endif #endif
#ifdef COMPAT_FREEBSD4 #ifdef COMPAT_FREEBSD4
/* FreeBSD 4.x */ /* FreeBSD 4.x */
struct sigframe4 { struct freebsd4_sigframe {
register_t sf_signum; register_t sf_signum;
register_t sf_siginfo; /* code or pointer to sf_si */ register_t sf_siginfo; /* code or pointer to sf_si */
register_t sf_ucontext; /* points to sf_uc */ register_t sf_ucontext; /* points to sf_uc */
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#define _MACHINE_UCONTEXT_H_ #define _MACHINE_UCONTEXT_H_
#if defined(_KERNEL) && defined(COMPAT_FREEBSD4) #if defined(_KERNEL) && defined(COMPAT_FREEBSD4)
struct mcontext4 { struct freebsd4_mcontext {
__register_t mc_onstack; /* XXX - sigcontext compat. */ __register_t mc_onstack; /* XXX - sigcontext compat. */
__register_t mc_gs; /* machine state (struct trapframe) */ __register_t mc_gs; /* machine state (struct trapframe) */
__register_t mc_fs; __register_t mc_fs;
...@@ -58,6 +58,14 @@ struct mcontext4 { ...@@ -58,6 +58,14 @@ struct mcontext4 {
__register_t mc_fpregs[28]; /* env87 + fpacc87 + u_long */ __register_t mc_fpregs[28]; /* env87 + fpacc87 + u_long */
__register_t __spare__[17]; __register_t __spare__[17];
}; };
struct freebsd4_ucontext {
sigset_t uc_sigmask;
struct freebsd4_mcontext uc_mcontext;
struct freebsd4_ucontext *uc_link;
stack_t uc_stack;
int __spare__[8];
};
#endif #endif
#include <x86/ucontext.h> #include <x86/ucontext.h>
......
...@@ -31,6 +31,7 @@ options MAMBO # IBM Mambo Full System Simulator ...@@ -31,6 +31,7 @@ options MAMBO # IBM Mambo Full System Simulator
options QEMU # QEMU processor emulator options QEMU # QEMU processor emulator
options PSERIES # PAPR-compliant systems (e.g. IBM p) options PSERIES # PAPR-compliant systems (e.g. IBM p)
options POWERNV # Non-virtualized OpenPOWER systems options POWERNV # Non-virtualized OpenPOWER systems
options ISA_206_ATOMICS # PowerISA v2.06 optimized subword atomics
options FDT # Flattened Device Tree options FDT # Flattened Device Tree
options SCHED_ULE # ULE scheduler options SCHED_ULE # ULE scheduler
......
...@@ -994,6 +994,117 @@ atomic_swap_64(volatile u_long *p, u_long v) ...@@ -994,6 +994,117 @@ atomic_swap_64(volatile u_long *p, u_long v)
#define atomic_swap_ptr(p,v) atomic_swap_32((volatile u_int *)(p), v) #define atomic_swap_ptr(p,v) atomic_swap_32((volatile u_int *)(p), v)
#endif #endif
static __inline int
atomic_testandset_int(volatile u_int *p, u_int v)
{
u_int m = (1 << (v & 0x1f));
u_int res;
u_int tmp;
__asm __volatile(
"1: lwarx %0,0,%3\n"
" and. %1,%0,%4\n"
" or %0,%0,%4\n"
" stwcx. %0,0,%3\n"
" bne- 1b\n"
: "=&r"(tmp), "=&r"(res), "+m"(*p)
: "r"(p), "r"(m)
: "cr0", "memory");
return (res != 0);
}
static __inline int
atomic_testandclear_int(volatile u_int *p, u_int v)
{
u_int m = (1 << (v & 0x1f));
u_int res;
u_int tmp;
__asm __volatile(
"1: lwarx %0,0,%3\n"
" and. %1,%0,%4\n"
" andc %0,%0,%4\n"
" stwcx. %0,0,%3\n"
" bne- 1b\n"
: "=&r"(tmp), "=&r"(res), "+m"(*p)
: "r"(p), "r"(m)
: "cr0", "memory");
return (res != 0);
}
#ifdef __powerpc64__
static __inline int
atomic_testandset_long(volatile u_long *p, u_int v)
{
u_long m = (1 << (v & 0x3f));
u_long res;
u_long tmp;
__asm __volatile(
"1: ldarx %0,0,%3\n"
" and. %1,%0,%4\n"
" or %0,%0,%4\n"
" stdcx. %0,0,%3\n"
" bne- 1b\n"
: "=&r"(tmp), "=&r"(res), "+m"(*(volatile u_long *)p)
: "r"(p), "r"(m)
: "cr0", "memory");
return (res != 0);
}
static __inline int
atomic_testandclear_long(volatile u_long *p, u_int v)
{
u_long m = (1 << (v & 0x3f));
u_long res;
u_long tmp;
__asm __volatile(
"1: ldarx %0,0,%3\n"
" and. %1,%0,%4\n"
" andc %0,%0,%4\n"
" stdcx. %0,0,%3\n"
" bne- 1b\n"
: "=&r"(tmp), "=&r"(res), "+m"(*p)
: "r"(p), "r"(m)
: "cr0", "memory");