summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorHans Petter Selasky <hselasky@FreeBSD.org>2017-11-24 12:13:27 +0000
committerHans Petter Selasky <hselasky@FreeBSD.org>2017-11-24 12:13:27 +0000
commit8a53e1340fd98452420e717589e5a99c1578211e (patch)
tree69b9bd70fa6f8f376d971b6b4f5ef1f16b700417 /sys
parentc3125bc5bf12af535c984d0eabd99be5f7114503 (diff)
parent322f006ecce27c190a375cd4b2bcdde4d1257277 (diff)
Notes
Diffstat (limited to 'sys')
-rw-r--r--sys/amd64/amd64/machdep.c1
-rw-r--r--sys/amd64/ia32/ia32_signal.c1
-rw-r--r--sys/amd64/linux32/linux32_sysvec.c1
-rw-r--r--sys/amd64/vmm/amd/amdvi_hw.c28
-rwxr-xr-xsys/amd64/vmm/amd/amdvi_priv.h4
-rwxr-xr-xsys/amd64/vmm/amd/ivrs_drv.c30
-rw-r--r--sys/arm/allwinner/clkng/aw_ccung.c16
-rw-r--r--sys/arm/arm/machdep.c24
-rw-r--r--sys/arm/cloudabi32/cloudabi32_sysvec.c2
-rw-r--r--sys/arm64/arm64/machdep.c27
-rw-r--r--sys/arm64/cloudabi64/cloudabi64_sysvec.c2
-rw-r--r--sys/arm64/include/armreg.h1
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c22
-rw-r--r--sys/compat/linux/linux_emul.c4
-rw-r--r--sys/geom/mirror/g_mirror.c4
-rw-r--r--sys/geom/mirror/g_mirror.h2
-rw-r--r--sys/i386/i386/machdep.c8
-rw-r--r--sys/i386/include/atomic.h12
-rw-r--r--sys/kern/init_main.c2
-rw-r--r--sys/kern/kern_exec.c10
-rw-r--r--sys/netinet/sctp_ss_functions.c2
-rw-r--r--sys/powerpc/powerpc/exec_machdep.c13
-rw-r--r--sys/riscv/riscv/machdep.c7
-rw-r--r--sys/sparc64/sparc64/machdep.c3
24 files changed, 120 insertions, 106 deletions
diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c
index 3175616d0ce05..0c16da1327dc7 100644
--- a/sys/amd64/amd64/machdep.c
+++ b/sys/amd64/amd64/machdep.c
@@ -604,7 +604,6 @@ exec_setregs(struct thread *td, struct image_params *imgp, u_long stack)
regs->tf_fs = _ufssel;
regs->tf_gs = _ugssel;
regs->tf_flags = TF_HASSEGS;
- td->td_retval[1] = 0;
/*
* Reset the hardware debug registers if they were in use.
diff --git a/sys/amd64/ia32/ia32_signal.c b/sys/amd64/ia32/ia32_signal.c
index 79131f3f561ce..b1fc8debc1f95 100644
--- a/sys/amd64/ia32/ia32_signal.c
+++ b/sys/amd64/ia32/ia32_signal.c
@@ -967,5 +967,4 @@ ia32_setregs(struct thread *td, struct image_params *imgp, u_long stack)
/* Return via doreti so that we can change to a different %cs */
set_pcb_flags(pcb, PCB_32BIT | PCB_FULL_IRET);
- td->td_retval[1] = 0;
}
diff --git a/sys/amd64/linux32/linux32_sysvec.c b/sys/amd64/linux32/linux32_sysvec.c
index 8b0a35ea0bfae..1a0dc1c954b7a 100644
--- a/sys/amd64/linux32/linux32_sysvec.c
+++ b/sys/amd64/linux32/linux32_sysvec.c
@@ -832,7 +832,6 @@ exec_linux_setregs(struct thread *td, struct image_params *imgp, u_long stack)
/* Do full restore on return so that we can change to a different %cs */
set_pcb_flags(pcb, PCB_32BIT | PCB_FULL_IRET);
- td->td_retval[1] = 0;
}
/*
diff --git a/sys/amd64/vmm/amd/amdvi_hw.c b/sys/amd64/vmm/amd/amdvi_hw.c
index 22d4a12e32103..3478262a73468 100644
--- a/sys/amd64/vmm/amd/amdvi_hw.c
+++ b/sys/amd64/vmm/amd/amdvi_hw.c
@@ -582,7 +582,7 @@ amdvi_decode_evt_flag(uint16_t flag)
{
flag &= AMDVI_EVENT_FLAG_MASK;
- printf("0x%b]\n", flag,
+ printf(" 0x%b]\n", flag,
"\020"
"\001GN"
"\002NX"
@@ -692,7 +692,7 @@ amdvi_decode_evt(struct amdvi_event *evt)
case AMDVI_EVENT_ILLEGAL_CMD:
/* FALL THROUGH */
case AMDVI_EVENT_CMD_HW_ERROR:
- printf("\t[%s EVT]", (evt->opcode == AMDVI_EVENT_ILLEGAL_CMD) ?
+ printf("\t[%s EVT]\n", (evt->opcode == AMDVI_EVENT_ILLEGAL_CMD) ?
"ILLEGAL CMD" : "CMD HW ERR");
cmd = (struct amdvi_cmd *)PHYS_TO_DMAP(evt->addr);
printf("\tCMD opcode= 0x%x 0x%x 0x%x 0x%lx\n",
@@ -700,13 +700,14 @@ amdvi_decode_evt(struct amdvi_event *evt)
break;
case AMDVI_EVENT_IOTLB_TIMEOUT:
- printf("\t[IOTLB_INV_TIMEOUT devid:0x%x addr:0x%lx",
+ printf("\t[IOTLB_INV_TIMEOUT devid:0x%x addr:0x%lx]\n",
evt->devid, evt->addr);
break;
case AMDVI_EVENT_INVALID_DTE_REQ:
- printf("\t[INV_DTE devid:0x%x addr:0x%lx",
- evt->devid, evt->addr);
+ printf("\t[INV_DTE devid:0x%x addr:0x%lx type:0x%x tr:%d]\n",
+ evt->devid, evt->addr, evt->flag >> 9,
+ (evt->flag >> 8) & 1);
break;
case AMDVI_EVENT_INVALID_PPR_REQ:
@@ -715,7 +716,7 @@ amdvi_decode_evt(struct amdvi_event *evt)
break;
default:
- printf("Unsupported AMD-Vi event:%d", evt->opcode);
+ printf("Unsupported AMD-Vi event:%d\n", evt->opcode);
}
}
@@ -988,15 +989,12 @@ amdvi_add_sysctl(struct amdvi_softc *softc)
&softc->event_intr_cnt, "Event interrupt count");
SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "command_count", CTLFLAG_RD,
&softc->total_cmd, "Command submitted count");
- SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "pci_rid", CTLFLAG_RD,
- (int *)&softc->pci_rid, 0,
- "IOMMU RID");
- SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "start_dev_rid", CTLFLAG_RD,
- (int *)&softc->start_dev_rid, 0,
- "Start of device under this IOMMU");
- SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "end_dev_rid", CTLFLAG_RD,
- (int *)&softc->end_dev_rid, 0,
- "End of device under this IOMMU");
+ SYSCTL_ADD_U16(ctx, child, OID_AUTO, "pci_rid", CTLFLAG_RD,
+ &softc->pci_rid, 0, "IOMMU RID");
+ SYSCTL_ADD_U16(ctx, child, OID_AUTO, "start_dev_rid", CTLFLAG_RD,
+ &softc->start_dev_rid, 0, "Start of device under this IOMMU");
+ SYSCTL_ADD_U16(ctx, child, OID_AUTO, "end_dev_rid", CTLFLAG_RD,
+ &softc->end_dev_rid, 0, "End of device under this IOMMU");
SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "command_head",
CTLTYPE_UINT | CTLFLAG_RD, softc, 0,
amdvi_handle_sysctl, "IU", "Command head");
diff --git a/sys/amd64/vmm/amd/amdvi_priv.h b/sys/amd64/vmm/amd/amdvi_priv.h
index c292d3ef9881c..8d4553fe1a3c7 100755
--- a/sys/amd64/vmm/amd/amdvi_priv.h
+++ b/sys/amd64/vmm/amd/amdvi_priv.h
@@ -230,8 +230,8 @@ struct amdvi_ctrl {
uint64_t :45;
uint32_t evt_tail:19;
uint64_t :45;
- uint64_t :56;
- uint8_t status:8;
+ uint32_t status:19;
+ uint64_t :45;
uint64_t pad2;
uint8_t :4;
uint16_t ppr_head:15;
diff --git a/sys/amd64/vmm/amd/ivrs_drv.c b/sys/amd64/vmm/amd/ivrs_drv.c
index dc47717006a05..bc30d83c6ca5a 100755
--- a/sys/amd64/vmm/amd/ivrs_drv.c
+++ b/sys/amd64/vmm/amd/ivrs_drv.c
@@ -88,7 +88,7 @@ ivrs_hdr_iterate_tbl(ivhd_iter_t iter, void *arg)
if (!iter(ivrs_hdr, arg))
return;
break;
-
+
case ACPI_IVRS_TYPE_MEMORY1:
case ACPI_IVRS_TYPE_MEMORY2:
case ACPI_IVRS_TYPE_MEMORY3:
@@ -96,7 +96,7 @@ ivrs_hdr_iterate_tbl(ivhd_iter_t iter, void *arg)
return;
break;
-
+
default:
printf("AMD-Vi:Not IVHD/IVMD type(%d)", ivrs_hdr->Type);
@@ -186,7 +186,8 @@ ivhd_dev_add_entry(struct amdvi_softc *softc, uint32_t start_id,
static int
ivhd_dev_parse(ACPI_IVRS_HARDWARE * ivhd, struct amdvi_softc *softc)
{
- ACPI_IVRS_DE_HEADER *de, *end;
+ ACPI_IVRS_DE_HEADER *de;
+ uint8_t *p, *end;
int range_start_id = 0, range_end_id = 0;
uint32_t *extended;
uint8_t all_data = 0, range_data = 0;
@@ -195,12 +196,15 @@ ivhd_dev_parse(ACPI_IVRS_HARDWARE * ivhd, struct amdvi_softc *softc)
softc->start_dev_rid = ~0;
softc->end_dev_rid = 0;
- de = (ACPI_IVRS_DE_HEADER *) ((uint8_t *)ivhd +
- sizeof(ACPI_IVRS_HARDWARE));
- end = (ACPI_IVRS_DE_HEADER *) ((uint8_t *)ivhd +
- ivhd->Header.Length);
+ /*
+ * XXX The following actually depends on Header.Type and
+ * is only true for 0x10.
+ */
+ p = (uint8_t *)ivhd + sizeof(ACPI_IVRS_HARDWARE);
+ end = (uint8_t *)ivhd + ivhd->Header.Length;
- while (de < (ACPI_IVRS_DE_HEADER *) end) {
+ while (p < end) {
+ de = (ACPI_IVRS_DE_HEADER *)p;
softc->start_dev_rid = MIN(softc->start_dev_rid, de->Id);
softc->end_dev_rid = MAX(softc->end_dev_rid, de->Id);
switch (de->Type) {
@@ -263,7 +267,15 @@ ivhd_dev_parse(ACPI_IVRS_HARDWARE * ivhd, struct amdvi_softc *softc)
"WARN Too many device entries.\n");
return (EINVAL);
}
- de++;
+ if (de->Type < 0x40)
+ p += sizeof(ACPI_IVRS_DEVICE4);
+ else if (de->Type < 0x80)
+ p += sizeof(ACPI_IVRS_DEVICE8A);
+ else {
+ printf("Variable size IVHD type 0x%x not supported\n",
+ de->Type);
+ break;
+ }
}
KASSERT((softc->end_dev_rid >= softc->start_dev_rid),
diff --git a/sys/arm/allwinner/clkng/aw_ccung.c b/sys/arm/allwinner/clkng/aw_ccung.c
index 416a3c08bcf95..41ee55b4baf2e 100644
--- a/sys/arm/allwinner/clkng/aw_ccung.c
+++ b/sys/arm/allwinner/clkng/aw_ccung.c
@@ -76,6 +76,10 @@ __FBSDID("$FreeBSD$");
#include <arm/allwinner/clkng/ccu_sun8i_r.h>
#endif
+#if defined(SOC_ALLWINNER_A83T)
+#include <arm/allwinner/clkng/ccu_a83t.h>
+#endif
+
#include "clkdev_if.h"
#include "hwreset_if.h"
@@ -102,6 +106,10 @@ static struct resource_spec aw_ccung_spec[] = {
#define A13_CCU 6
#endif
+#if defined(SOC_ALLWINNER_A83T)
+#define A83T_CCU 7
+#endif
+
static struct ofw_compat_data compat_data[] = {
#if defined(SOC_ALLWINNER_A31)
{ "allwinner,sun5i-a13-ccu", A13_CCU},
@@ -117,6 +125,9 @@ static struct ofw_compat_data compat_data[] = {
{ "allwinner,sun50i-a64-ccu", A64_CCU },
{ "allwinner,sun50i-a64-r-ccu", A64_R_CCU },
#endif
+#if defined(SOC_ALLWINNER_A83T)
+ { "allwinner,sun8i-a83t-ccu", A83T_CCU },
+#endif
{NULL, 0 }
};
@@ -359,6 +370,11 @@ aw_ccung_attach(device_t dev)
ccu_sun8i_r_register_clocks(sc);
break;
#endif
+#if defined(SOC_ALLWINNER_A83T)
+ case A83T_CCU:
+ ccu_a83t_register_clocks(sc);
+ break;
+#endif
}
if (sc->gates)
diff --git a/sys/arm/arm/machdep.c b/sys/arm/arm/machdep.c
index 689f7686d4c9b..04fd482170e74 100644
--- a/sys/arm/arm/machdep.c
+++ b/sys/arm/arm/machdep.c
@@ -518,6 +518,16 @@ set_mcontext(struct thread *td, mcontext_t *mcp)
mcontext_vfp_t mc_vfp, *vfp;
struct trapframe *tf = td->td_frame;
const __greg_t *gr = mcp->__gregs;
+ int spsr;
+
+ /*
+ * Make sure the processor mode has not been tampered with and
+ * interrupts have not been disabled.
+ */
+ spsr = gr[_REG_CPSR];
+ if ((spsr & PSR_MODE) != PSR_USR32_MODE ||
+ (spsr & (PSR_I | PSR_F)) != 0)
+ return (EINVAL);
#ifdef WITNESS
if (mcp->mc_vfp_size != 0 && mcp->mc_vfp_size != sizeof(mc_vfp)) {
@@ -677,22 +687,16 @@ sys_sigreturn(td, uap)
} */ *uap;
{
ucontext_t uc;
- int spsr;
+ int error;
if (uap == NULL)
return (EFAULT);
if (copyin(uap->sigcntxp, &uc, sizeof(uc)))
return (EFAULT);
- /*
- * Make sure the processor mode has not been tampered with and
- * interrupts have not been disabled.
- */
- spsr = uc.uc_mcontext.__gregs[_REG_CPSR];
- if ((spsr & PSR_MODE) != PSR_USR32_MODE ||
- (spsr & (PSR_I | PSR_F)) != 0)
- return (EINVAL);
/* Restore register context. */
- set_mcontext(td, &uc.uc_mcontext);
+ error = set_mcontext(td, &uc.uc_mcontext);
+ if (error != 0)
+ return (error);
/* Restore signal mask. */
kern_sigprocmask(td, SIG_SETMASK, &uc.uc_sigmask, NULL, 0);
diff --git a/sys/arm/cloudabi32/cloudabi32_sysvec.c b/sys/arm/cloudabi32/cloudabi32_sysvec.c
index a0bebcc996414..eeeb93c188c79 100644
--- a/sys/arm/cloudabi32/cloudabi32_sysvec.c
+++ b/sys/arm/cloudabi32/cloudabi32_sysvec.c
@@ -61,7 +61,7 @@ cloudabi32_proc_setregs(struct thread *td, struct image_params *imgp,
* tpidrurw to the TCB.
*/
regs = td->td_frame;
- regs->tf_r0 = td->td_retval[0] =
+ regs->tf_r0 =
stack + roundup(sizeof(cloudabi32_tcb_t), sizeof(register_t));
(void)cpu_set_user_tls(td, (void *)stack);
}
diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c
index 886792a9681db..452f224797af4 100644
--- a/sys/arm64/arm64/machdep.c
+++ b/sys/arm64/arm64/machdep.c
@@ -211,7 +211,8 @@ set_regs(struct thread *td, struct reg *regs)
frame->tf_sp = regs->sp;
frame->tf_lr = regs->lr;
frame->tf_elr = regs->elr;
- frame->tf_spsr = regs->spsr;
+ frame->tf_spsr &= ~PSR_FLAGS;
+ frame->tf_spsr |= regs->spsr & PSR_FLAGS;
memcpy(frame->tf_x, regs->x, sizeof(frame->tf_x));
@@ -310,12 +311,7 @@ exec_setregs(struct thread *td, struct image_params *imgp, u_long stack)
memset(tf, 0, sizeof(struct trapframe));
- /*
- * We need to set x0 for init as it doesn't call
- * cpu_set_syscall_retval to copy the value. We also
- * need to set td_retval for the cases where we do.
- */
- tf->tf_x[0] = td->td_retval[0] = stack;
+ tf->tf_x[0] = stack;
tf->tf_sp = STACKALIGN(stack);
tf->tf_lr = imgp->entry_addr;
tf->tf_elr = imgp->entry_addr;
@@ -354,6 +350,12 @@ int
set_mcontext(struct thread *td, mcontext_t *mcp)
{
struct trapframe *tf = td->td_frame;
+ uint32_t spsr;
+
+ spsr = mcp->mc_gpregs.gp_spsr;
+ if ((spsr & PSR_M_MASK) != PSR_M_EL0t ||
+ (spsr & (PSR_F | PSR_I | PSR_A | PSR_D)) != 0)
+ return (EINVAL);
memcpy(tf->tf_x, mcp->mc_gpregs.gp_x, sizeof(tf->tf_x));
@@ -530,19 +532,16 @@ int
sys_sigreturn(struct thread *td, struct sigreturn_args *uap)
{
ucontext_t uc;
- uint32_t spsr;
+ int error;
if (uap == NULL)
return (EFAULT);
if (copyin(uap->sigcntxp, &uc, sizeof(uc)))
return (EFAULT);
- spsr = uc.uc_mcontext.mc_gpregs.gp_spsr;
- if ((spsr & PSR_M_MASK) != PSR_M_EL0t ||
- (spsr & (PSR_F | PSR_I | PSR_A | PSR_D)) != 0)
- return (EINVAL);
-
- set_mcontext(td, &uc.uc_mcontext);
+ error = set_mcontext(td, &uc.uc_mcontext);
+ if (error != 0)
+ return (error);
set_fpcontext(td, &uc.uc_mcontext);
/* Restore signal mask. */
diff --git a/sys/arm64/cloudabi64/cloudabi64_sysvec.c b/sys/arm64/cloudabi64/cloudabi64_sysvec.c
index f6e75f563668b..a98ff0e2c305f 100644
--- a/sys/arm64/cloudabi64/cloudabi64_sysvec.c
+++ b/sys/arm64/cloudabi64/cloudabi64_sysvec.c
@@ -61,7 +61,7 @@ cloudabi64_proc_setregs(struct thread *td, struct image_params *imgp,
* tpidr_el0 to the TCB.
*/
regs = td->td_frame;
- regs->tf_x[0] = td->td_retval[0] =
+ regs->tf_x[0] =
stack + roundup(sizeof(cloudabi64_tcb_t), sizeof(register_t));
(void)cpu_set_user_tls(td, (void *)stack);
}
diff --git a/sys/arm64/include/armreg.h b/sys/arm64/include/armreg.h
index a7a15fc87850c..cf24fadf16239 100644
--- a/sys/arm64/include/armreg.h
+++ b/sys/arm64/include/armreg.h
@@ -572,6 +572,7 @@
#define PSR_C 0x20000000
#define PSR_Z 0x40000000
#define PSR_N 0x80000000
+#define PSR_FLAGS 0xf0000000
/* TCR_EL1 - Translation Control Register */
#define TCR_ASID_16 (1 << 36)
diff --git a/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c b/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c
index 82353cbb235df..9e6bde2eac482 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c
@@ -601,8 +601,8 @@ fasttrap_fork(proc_t *p, proc_t *cp)
pid_t ppid = p->p_pid;
int i;
-#ifdef illumos
ASSERT(curproc == p);
+#ifdef illumos
ASSERT(p->p_proc_flag & P_PR_LOCK);
#else
PROC_LOCK_ASSERT(p, MA_OWNED);
@@ -610,26 +610,15 @@ fasttrap_fork(proc_t *p, proc_t *cp)
#ifdef illumos
ASSERT(p->p_dtrace_count > 0);
#else
- if (p->p_dtrace_helpers) {
- /*
- * dtrace_helpers_duplicate() allocates memory.
- */
- _PHOLD(cp);
- PROC_UNLOCK(p);
- PROC_UNLOCK(cp);
- dtrace_helpers_duplicate(p, cp);
- PROC_LOCK(cp);
- PROC_LOCK(p);
- _PRELE(cp);
- }
/*
* This check is purposely here instead of in kern_fork.c because,
* for legal resons, we cannot include the dtrace_cddl.h header
* inside kern_fork.c and insert if-clause there.
*/
- if (p->p_dtrace_count == 0)
+ if (p->p_dtrace_count == 0 && p->p_dtrace_helpers == NULL)
return;
#endif
+
ASSERT(cp->p_dtrace_count == 0);
/*
@@ -658,6 +647,8 @@ fasttrap_fork(proc_t *p, proc_t *cp)
_PHOLD(cp);
PROC_UNLOCK(cp);
PROC_UNLOCK(p);
+ if (p->p_dtrace_count == 0)
+ goto dup_helpers;
#endif
/*
@@ -711,6 +702,9 @@ fasttrap_fork(proc_t *p, proc_t *cp)
mutex_enter(&cp->p_lock);
sprunlock(cp);
#else
+dup_helpers:
+ if (p->p_dtrace_helpers != NULL)
+ dtrace_helpers_duplicate(p, cp);
PROC_LOCK(p);
PROC_LOCK(cp);
_PRELE(cp);
diff --git a/sys/compat/linux/linux_emul.c b/sys/compat/linux/linux_emul.c
index b244eea3b677d..8be4fa2df0c93 100644
--- a/sys/compat/linux/linux_emul.c
+++ b/sys/compat/linux/linux_emul.c
@@ -186,7 +186,7 @@ linux_common_execve(struct thread *td, struct image_args *eargs)
error = kern_execve(td, eargs, NULL);
post_execve(td, error, oldvmspace);
- if (error != 0)
+ if (error != EJUSTRETURN)
return (error);
/*
@@ -213,7 +213,7 @@ linux_common_execve(struct thread *td, struct image_args *eargs)
free(em, M_TEMP);
free(pem, M_LINUX);
}
- return (0);
+ return (EJUSTRETURN);
}
void
diff --git a/sys/geom/mirror/g_mirror.c b/sys/geom/mirror/g_mirror.c
index 7f8f670d7461a..4a5f542c1de52 100644
--- a/sys/geom/mirror/g_mirror.c
+++ b/sys/geom/mirror/g_mirror.c
@@ -54,8 +54,8 @@ static MALLOC_DEFINE(M_MIRROR, "mirror_data", "GEOM_MIRROR Data");
SYSCTL_DECL(_kern_geom);
static SYSCTL_NODE(_kern_geom, OID_AUTO, mirror, CTLFLAG_RW, 0,
"GEOM_MIRROR stuff");
-u_int g_mirror_debug = 0;
-SYSCTL_UINT(_kern_geom_mirror, OID_AUTO, debug, CTLFLAG_RWTUN, &g_mirror_debug, 0,
+int g_mirror_debug = 0;
+SYSCTL_INT(_kern_geom_mirror, OID_AUTO, debug, CTLFLAG_RWTUN, &g_mirror_debug, 0,
"Debug level");
static u_int g_mirror_timeout = 4;
SYSCTL_UINT(_kern_geom_mirror, OID_AUTO, timeout, CTLFLAG_RWTUN, &g_mirror_timeout,
diff --git a/sys/geom/mirror/g_mirror.h b/sys/geom/mirror/g_mirror.h
index f3a4a00700936..3b9664035c984 100644
--- a/sys/geom/mirror/g_mirror.h
+++ b/sys/geom/mirror/g_mirror.h
@@ -72,7 +72,7 @@
G_MIRROR_DEVICE_FLAG_NOFAILSYNC)
#ifdef _KERNEL
-extern u_int g_mirror_debug;
+extern int g_mirror_debug;
#define G_MIRROR_DEBUG(lvl, ...) do { \
if (g_mirror_debug >= (lvl)) { \
diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c
index 68a4522085826..dac5fd6967ec4 100644
--- a/sys/i386/i386/machdep.c
+++ b/sys/i386/i386/machdep.c
@@ -1126,6 +1126,7 @@ exec_setregs(struct thread *td, struct image_params *imgp, u_long stack)
set_fsbase(td, 0);
set_gsbase(td, 0);
+ /* Make sure edx is 0x0 on entry. Linux binaries depend on it. */
bzero((char *)regs, sizeof(struct trapframe));
regs->tf_eip = imgp->entry_addr;
regs->tf_esp = stack;
@@ -1168,13 +1169,6 @@ exec_setregs(struct thread *td, struct image_params *imgp, u_long stack)
* clean FP state if it uses the FPU again.
*/
fpstate_drop(td);
-
- /*
- * XXX - Linux emulator
- * Make sure sure edx is 0x0 on entry. Linux binaries depend
- * on it.
- */
- td->td_retval[1] = 0;
}
void
diff --git a/sys/i386/include/atomic.h b/sys/i386/include/atomic.h
index c167cf5c0fae1..7cd5b0d2a7e46 100644
--- a/sys/i386/include/atomic.h
+++ b/sys/i386/include/atomic.h
@@ -129,6 +129,7 @@ int atomic_cmpset_64(volatile uint64_t *, uint64_t, uint64_t);
uint64_t atomic_load_acq_64(volatile uint64_t *);
void atomic_store_rel_64(volatile uint64_t *, uint64_t);
uint64_t atomic_swap_64(volatile uint64_t *, uint64_t);
+uint64_t atomic_fetchadd_64(volatile uint64_t *, uint64_t);
#else /* !KLD_MODULE && __GNUCLIKE_ASM */
@@ -565,6 +566,17 @@ atomic_swap_64(volatile uint64_t *p, uint64_t v)
return (atomic_swap_64_i586(p, v));
}
+static __inline uint64_t
+atomic_fetchadd_64(volatile uint64_t *p, uint64_t v)
+{
+
+ for (;;) {
+ uint64_t t = *p;
+ if (atomic_cmpset_64(p, t, t + v))
+ return (t);
+ }
+}
+
#endif /* _KERNEL */
#endif /* KLD_MODULE || !__GNUCLIKE_ASM */
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c
index 645d120d9807d..dbd7a4ac07c76 100644
--- a/sys/kern/init_main.c
+++ b/sys/kern/init_main.c
@@ -797,7 +797,7 @@ start_init(void *dummy)
* Otherwise, return via fork_trampoline() all the way
* to user mode as init!
*/
- if ((error = sys_execve(td, &args)) == 0) {
+ if ((error = sys_execve(td, &args)) == EJUSTRETURN) {
mtx_unlock(&Giant);
return;
}
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index f844a61967c64..284e08a801afd 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -318,7 +318,7 @@ post_execve(struct thread *td, int error, struct vmspace *oldvmspace)
* If success, we upgrade to SINGLE_EXIT state to
* force other threads to suicide.
*/
- if (error == 0)
+ if (error == EJUSTRETURN)
thread_single(p, SINGLE_EXIT);
else
thread_single_end(p, SINGLE_BOUNDARY);
@@ -962,7 +962,13 @@ exec_fail:
ktrprocctor(p);
#endif
- return (error);
+ /*
+ * We don't want cpu_set_syscall_retval() to overwrite any of
+ * the register values put in place by exec_setregs().
+ * Implementations of cpu_set_syscall_retval() will leave
+ * registers unmodified when returning EJUSTRETURN.
+ */
+ return (error == 0 ? EJUSTRETURN : error);
}
int
diff --git a/sys/netinet/sctp_ss_functions.c b/sys/netinet/sctp_ss_functions.c
index 22d3deb58fd93..3099c4893c478 100644
--- a/sys/netinet/sctp_ss_functions.c
+++ b/sys/netinet/sctp_ss_functions.c
@@ -1,4 +1,6 @@
/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
* Copyright (c) 2010-2012, by Michael Tuexen. All rights reserved.
* Copyright (c) 2010-2012, by Randall Stewart. All rights reserved.
* Copyright (c) 2010-2012, by Robin Seggelmann. All rights reserved.
diff --git a/sys/powerpc/powerpc/exec_machdep.c b/sys/powerpc/powerpc/exec_machdep.c
index 596ae8079f19b..724ae849a0699 100644
--- a/sys/powerpc/powerpc/exec_machdep.c
+++ b/sys/powerpc/powerpc/exec_machdep.c
@@ -520,22 +520,11 @@ exec_setregs(struct thread *td, struct image_params *imgp, u_long stack)
* - ps_strings is a NetBSD extention, and will be
* ignored by executables which are strictly
* compliant with the SVR4 ABI.
- *
- * XXX We have to set both regs and retval here due to different
- * XXX calling convention in trap.c and init_main.c.
*/
/* Collect argc from the user stack */
argc = fuword((void *)stack);
- /*
- * XXX PG: these get overwritten in the syscall return code.
- * execve() should return EJUSTRETURN, like it does on NetBSD.
- * Emulate by setting the syscall return value cells. The
- * registers still have to be set for init's fork trampoline.
- */
- td->td_retval[0] = argc;
- td->td_retval[1] = stack + sizeof(register_t);
tf->fixreg[3] = argc;
tf->fixreg[4] = stack + sizeof(register_t);
tf->fixreg[5] = stack + (2 + argc)*sizeof(register_t);
@@ -572,8 +561,6 @@ ppc32_setregs(struct thread *td, struct image_params *imgp, u_long stack)
argc = fuword32((void *)stack);
- td->td_retval[0] = argc;
- td->td_retval[1] = stack + sizeof(uint32_t);
tf->fixreg[3] = argc;
tf->fixreg[4] = stack + sizeof(uint32_t);
tf->fixreg[5] = stack + (2 + argc)*sizeof(uint32_t);
diff --git a/sys/riscv/riscv/machdep.c b/sys/riscv/riscv/machdep.c
index d8a968791a050..de1a71e4d2eb8 100644
--- a/sys/riscv/riscv/machdep.c
+++ b/sys/riscv/riscv/machdep.c
@@ -279,12 +279,7 @@ exec_setregs(struct thread *td, struct image_params *imgp, u_long stack)
memset(tf, 0, sizeof(struct trapframe));
- /*
- * We need to set a0 for init as it doesn't call
- * cpu_set_syscall_retval to copy the value. We also
- * need to set td_retval for the cases where we do.
- */
- tf->tf_a[0] = td->td_retval[0] = stack;
+ tf->tf_a[0] = stack;
tf->tf_sp = STACKALIGN(stack);
tf->tf_ra = imgp->entry_addr;
tf->tf_sepc = imgp->entry_addr;
diff --git a/sys/sparc64/sparc64/machdep.c b/sys/sparc64/sparc64/machdep.c
index 9d917afafbbd6..d450d436379e9 100644
--- a/sys/sparc64/sparc64/machdep.c
+++ b/sys/sparc64/sparc64/machdep.c
@@ -1009,9 +1009,6 @@ exec_setregs(struct thread *td, struct image_params *imgp, u_long stack)
* header, it turns out that just always using TSO performs best.
*/
tf->tf_tstate = TSTATE_IE | TSTATE_PEF | TSTATE_MM_TSO;
-
- td->td_retval[0] = tf->tf_out[0];
- td->td_retval[1] = tf->tf_out[1];
}
int