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
SUBDIR+= xray-profiling
.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_PARALLEL=
......
......@@ -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);
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) {
explicit_bzero(&gkey, sizeof(gkey));
......
......@@ -36,7 +36,7 @@
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)
{
keyInstance aeskey;
cipherInstance cipher;
......@@ -81,7 +81,7 @@ geliboot_crypt(u_int algo, geli_op_t enc, u_char *data, size_t datasize,
ctxp = &xtsctx;
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) {
case GELI_DECRYPT:
......@@ -106,11 +106,10 @@ static int
g_eli_crypto_cipher(u_int algo, geli_op_t enc, u_char *data, size_t datasize,
const u_char *key, size_t keysize)
{
u_char iv[keysize];
u_char iv[G_ELI_IVKEYLEN];
explicit_bzero(iv, sizeof(iv));
return (geliboot_crypt(algo, enc, data, datasize, key, keysize, iv,
sizeof(iv)));
return (geliboot_crypt(algo, enc, data, datasize, key, keysize, iv));
}
int
......
......@@ -68,6 +68,6 @@ struct geli_dev {
};
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_ */
......@@ -339,7 +339,7 @@ freebsd32_swapcontext(struct thread *td, struct freebsd32_swapcontext_args *uap)
static void
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 thread *td;
struct sigacts *psp;
......@@ -359,11 +359,11 @@ ia32_osendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
/* Allocate space for the signal handler context. */
if ((td->td_pflags & TDP_ALTSTACK) && !oonstack &&
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_flags |= SS_ONSTACK;
} 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. */
sf.sf_signum = sig;
......@@ -441,7 +441,7 @@ ia32_osendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
static void
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 proc *p;
struct thread *td;
......@@ -497,10 +497,10 @@ freebsd4_ia32_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
/* Allocate space for the signal handler context. */
if ((td->td_pflags & TDP_ALTSTACK) != 0 && !oonstack &&
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));
} else
sfp = (struct ia32_sigframe4 *)regs->tf_rsp - 1;
sfp = (struct ia32_freebsd4_sigframe *)regs->tf_rsp - 1;
PROC_UNLOCK(p);
/* Build the argument list for the signal handler. */
......@@ -696,7 +696,7 @@ ia32_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
int
ofreebsd32_sigreturn(struct thread *td, struct ofreebsd32_sigreturn_args *uap)
{
struct ia32_sigcontext3 sc, *scp;
struct ia32_osigcontext sc, *scp;
struct trapframe *regs;
int eflags, error;
ksiginfo_t ksi;
......@@ -754,9 +754,9 @@ int
freebsd4_freebsd32_sigreturn(struct thread *td,
struct freebsd4_freebsd32_sigreturn_args *uap)
{
struct ia32_ucontext4 uc;
struct ia32_freebsd4_ucontext uc;
struct trapframe *regs;
struct ia32_ucontext4 *ucp;
struct ia32_freebsd4_ucontext *ucp;
int cs, eflags, error;
ksiginfo_t ksi;
......
......@@ -39,16 +39,16 @@
#include <sys/sysctl.h>
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 subenclosure; /* subenclosure id */
uint8_t type_elm_idx; /* index of element within type */
uint8_t svalid; /* enclosure information valid */
uint16_t priv; /* private data, per object */
uint8_t encstat[4]; /* state && stats */
uint8_t *physical_path; /* Device physical path data. */
u_int physical_path_len; /* Length of device path data. */
uint8_t *physical_path; /* Device physical path data. */
void *elm_private; /* per-type object data */
uint16_t priv;
} enc_element_t;
typedef enum {
......
......@@ -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_GSBASE, offsetof(struct ia32_ucontext, uc_mcontext.mc_gsbase));
#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
#ifdef COMPAT_FREEBSD4
ASSYM(IA32_SIGF_UC4, offsetof(struct ia32_sigframe4, sf_uc));
ASSYM(IA32_UC4_GS, offsetof(struct ia32_ucontext4, uc_mcontext.mc_gs));
ASSYM(IA32_UC4_FS, offsetof(struct ia32_ucontext4, uc_mcontext.mc_fs));
ASSYM(IA32_UC4_ES, offsetof(struct ia32_ucontext4, uc_mcontext.mc_es));
ASSYM(IA32_UC4_DS, offsetof(struct ia32_ucontext4, uc_mcontext.mc_ds));
ASSYM(IA32_SIGF_UC4, offsetof(struct ia32_freebsd4_sigframe, sf_uc));
ASSYM(IA32_UC4_GS, offsetof(struct ia32_freebsd4_ucontext, uc_mcontext.mc_gs));
ASSYM(IA32_UC4_FS, offsetof(struct ia32_freebsd4_ucontext, uc_mcontext.mc_fs));
ASSYM(IA32_UC4_ES, offsetof(struct ia32_freebsd4_ucontext, uc_mcontext.mc_es));
ASSYM(IA32_UC4_DS, offsetof(struct ia32_freebsd4_ucontext, uc_mcontext.mc_ds));
#endif
......@@ -88,8 +88,7 @@ struct ia32_ucontext {
uint32_t __spare__[4];
};
#if defined(COMPAT_FREEBSD4)
struct ia32_mcontext4 {
struct ia32_freebsd4_mcontext {
uint32_t mc_onstack; /* XXX - sigcontext compat. */
uint32_t mc_gs; /* machine state (struct trapframe) */
uint32_t mc_fs;
......@@ -114,17 +113,15 @@ struct ia32_mcontext4 {
uint32_t __spare__[17];
};
struct ia32_ucontext4 {
struct ia32_freebsd4_ucontext {
sigset_t uc_sigmask;
struct ia32_mcontext4 uc_mcontext;
struct ia32_freebsd4_mcontext uc_mcontext;
uint32_t uc_link;
struct sigaltstack32 uc_stack;
uint32_t __spare__[8];
};
#endif
#ifdef COMPAT_43
struct ia32_sigcontext3 {
struct ia32_osigcontext {
uint32_t sc_onstack;
uint32_t sc_mask;
uint32_t sc_esp;
......@@ -147,23 +144,20 @@ struct ia32_sigcontext3 {
uint32_t sc_trapno;
uint32_t sc_err;
};
#endif
/*
* Signal frames, arguments passed to application signal handlers.
*/
#ifdef COMPAT_FREEBSD4
struct ia32_sigframe4 {
struct ia32_freebsd4_sigframe {
uint32_t sf_signum;
uint32_t sf_siginfo; /* code or pointer to sf_si */
uint32_t sf_ucontext; /* points to sf_uc */
uint32_t sf_addr; /* undocumented 4th arg */
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) */
};
#endif
struct ia32_sigframe {
uint32_t sf_signum;
......@@ -176,22 +170,20 @@ struct ia32_sigframe {
struct siginfo32 sf_si; /* = *sf_siginfo (SA_SIGINFO case) */
};
#ifdef COMPAT_43
struct ia32_siginfo3 {
struct ia32_sigcontext3 si_sc;
struct ia32_osiginfo {
struct ia32_osigcontext si_sc;
int si_signo;
int si_code;
union sigval32 si_value;
};
struct ia32_sigframe3 {
struct ia32_osigframe {
int sf_signum;
uint32_t sf_arg2; /* int or siginfo_t */
uint32_t sf_scp;
uint32_t sf_addr;
uint32_t sf_ah; /* action/handler pointer */
struct ia32_siginfo3 sf_siginfo;
struct ia32_osiginfo sf_siginfo;
};
#endif
struct ksiginfo;
struct image_params;
......
......@@ -81,9 +81,9 @@ CTASSERT(sizeof(struct ia32_ucontext) == 704);
CTASSERT(sizeof(struct ia32_sigframe) == 800);
CTASSERT(sizeof(struct siginfo32) == 64);
#ifdef COMPAT_FREEBSD4
CTASSERT(sizeof(struct ia32_mcontext4) == 260);
CTASSERT(sizeof(struct ia32_ucontext4) == 324);
CTASSERT(sizeof(struct ia32_sigframe4) == 408);
CTASSERT(sizeof(struct ia32_freebsd4_mcontext) == 260);
CTASSERT(sizeof(struct ia32_freebsd4_ucontext) == 324);
CTASSERT(sizeof(struct ia32_freebsd4_sigframe) == 408);
#endif
#include "vdso_ia32_offsets.h"
......
......@@ -112,7 +112,7 @@ g_eli_crypto_cipher(u_int algo, int enc, u_char *data, size_t datasize,
{
EVP_CIPHER_CTX *ctx;
const EVP_CIPHER *type;
u_char iv[keysize];
u_char iv[G_ELI_IVKEYLEN];
int outsize;
assert(algo != CRYPTO_AES_XTS);
......
......@@ -256,7 +256,7 @@ osendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
static void
freebsd4_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
{
struct sigframe4 sf, *sfp;
struct freebsd4_sigframe sf, *sfp;
struct proc *p;
struct thread *td;
struct sigacts *psp;
......@@ -291,13 +291,13 @@ freebsd4_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
/* Allocate space for the signal handler context. */
if ((td->td_pflags & TDP_ALTSTACK) != 0 && !oonstack &&
SIGISMEMBER(psp->ps_sigonstack, sig)) {
sfp = (struct sigframe4 *)((uintptr_t)td->td_sigstk.ss_sp +
td->td_sigstk.ss_size - sizeof(struct sigframe4));
sfp = (struct freebsd4_sigframe *)((uintptr_t)td->td_sigstk.ss_sp +
td->td_sigstk.ss_size - sizeof(struct freebsd4_sigframe));
#if defined(COMPAT_43)
td->td_sigstk.ss_flags |= SS_ONSTACK;
#endif
} else
sfp = (struct sigframe4 *)regs->tf_esp - 1;
sfp = (struct freebsd4_sigframe *)regs->tf_esp - 1;
/* Build the argument list for the signal handler. */
sf.sf_signum = sig;
......
......@@ -162,7 +162,7 @@ ASSYM(SIGF_SC, offsetof(struct osigframe, sf_siginfo.si_sc));
#endif
ASSYM(SIGF_UC, offsetof(struct sigframe, sf_uc));
#ifdef COMPAT_FREEBSD4
ASSYM(SIGF_UC4, offsetof(struct sigframe4, sf_uc));
ASSYM(SIGF_UC4, offsetof(struct freebsd4_sigframe, sf_uc));
#endif
#ifdef COMPAT_43
ASSYM(SC_PS, offsetof(struct osigcontext, sc_ps));
......
......@@ -75,7 +75,7 @@ struct osigframe {
#endif
#ifdef COMPAT_FREEBSD4
/* FreeBSD 4.x */
struct sigframe4 {
struct freebsd4_sigframe {
register_t sf_signum;
register_t sf_siginfo; /* code or pointer to sf_si */
register_t sf_ucontext; /* points to sf_uc */
......
......@@ -34,7 +34,7 @@
#define _MACHINE_UCONTEXT_H_
#if defined(_KERNEL) && defined(COMPAT_FREEBSD4)
struct mcontext4 {
struct freebsd4_mcontext {
__register_t mc_onstack; /* XXX - sigcontext compat. */
__register_t mc_gs; /* machine state (struct trapframe) */
__register_t mc_fs;
......@@ -58,6 +58,14 @@ struct mcontext4 {
__register_t mc_fpregs[28]; /* env87 + fpacc87 + u_long */
__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
#include <x86/ucontext.h>
......
......@@ -31,6 +31,7 @@ options MAMBO # IBM Mambo Full System Simulator
options QEMU # QEMU processor emulator
options PSERIES # PAPR-compliant systems (e.g. IBM p)
options POWERNV # Non-virtualized OpenPOWER systems
options ISA_206_ATOMICS # PowerISA v2.06 optimized subword atomics
options FDT # Flattened Device Tree
options SCHED_ULE # ULE scheduler
......
......@@ -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)
#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");
return (res != 0);
}
#else
static __inline int
atomic_testandset_long(volatile u_long *p, u_int v)
{
return (atomic_testandset_int((volatile u_int *)p, v);
}
static __inline int
atomic_testandclear_long(volatile u_long *p, u_int v)
{
return (atomic_testandclear_int((volatile u_int *)p, v);
}
#endif
#define atomic_testandclear_32 atomic_testandclear_int
#define atomic_testandset_32 atomic_testandset_int
static __inline int
atomic_testandset_acq_long(volatile u_long *p, u_int v)
{
u_int a = atomic_testandset_long(p, v);
__ATOMIC_ACQ();
return (a);
}
#define atomic_testandclear_int atomic_testandclear_int
#define atomic_testandset_int atomic_testandset_int
#define atomic_testandclear_long atomic_testandclear_long
#define atomic_testandset_long atomic_testandset_long
#define atomic_testandset_acq_long atomic_testandset_acq_long
static __inline void
atomic_thread_fence_acq(void)
{
......
......@@ -39,20 +39,6 @@
#define UCF_SWAPPED 0x00000001 /* Used by swapcontext(3). */
#if defined(_KERNEL) && defined(COMPAT_FREEBSD4)
#if defined(__i386__)
struct freebsd4_ucontext {
sigset_t uc_sigmask;
struct mcontext4 uc_mcontext;
struct freebsd4_ucontext *uc_link;
stack_t uc_stack;
int __spare__[8];
};
#else /* __i386__ */
#define freebsd4_ucontext ucontext
#endif /* __i386__ */
#endif /* _KERNEL */
#ifndef _KERNEL
__BEGIN_DECLS
......
......@@ -79,6 +79,7 @@ MTX_SYSINIT(atrtc_time_lock_init, &atrtc_time_lock, "atrtc_time", MTX_DEF);
int atrtcclock_disable = 0;
static int rtc_century = 0;
static int rtc_reg = -1;
static u_char rtc_statusa = RTCSA_DIVIDER | RTCSA_NOPROF;
static u_char rtc_statusb = RTCSB_24HR;
......@@ -420,6 +421,31 @@ atrtc_acpi_disabled(void)
#endif
}
static int
rtc_acpi_century_get(void)
{
#ifdef DEV_ACPI
ACPI_TABLE_FADT *fadt;
vm_paddr_t physaddr;
int century;
physaddr = acpi_find_table(ACPI_SIG_FADT);
if (physaddr == 0)
return (0);
fadt = acpi_map_table(physaddr, ACPI_SIG_FADT);
if (fadt == NULL)
return (0);
century = fadt->Century;
acpi_unmap_table(fadt);
return (century);
#else
return (0);
#endif
}
static int
atrtc_probe(device_t dev)
{
......@@ -435,6 +461,7 @@ atrtc_probe(device_t dev)
device_set_desc(dev, "AT realtime clock");
return (BUS_PROBE_LOW_PRIORITY);
}
rtc_century = rtc_acpi_century_get();
return (result);
}
......@@ -548,9 +575,8 @@ atrtc_settime(device_t dev __unused, struct timespec *ts)
rtcout_locked(RTC_DAY, bct.day);
rtcout_locked(RTC_MONTH, bct.mon);
rtcout_locked(RTC_YEAR, bct.year & 0xff);
#ifdef USE_RTC_CENTURY
rtcout_locked(RTC_CENTURY, bct.year >> 8);
#endif
if (rtc_century)
rtcout_locked(rtc_century, bct.year >> 8);
/*
* Re-enable RTC updates and interrupts.
......@@ -592,9 +618,8 @@ atrtc_gettime(device_t dev, struct timespec *ts)
bct.day = rtcin_locked(RTC_DAY);
bct.mon = rtcin_locked(RTC_MONTH);
bct.year = rtcin_locked(RTC_YEAR);
#ifdef USE_RTC_CENTURY
bct.year |= rtcin_locked(RTC_CENTURY) << 8;
#endif
if (rtc_century)
bct.year |= rtcin_locked(rtc_century) << 8;
mtx_unlock_spin(&atrtc_lock);
mtx_unlock(&atrtc_time_lock);
/* dow is unused in timespec conversion and we have no nsec info. */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment