sync with OpenBSD -current
This commit is contained in:
parent
57ecf9bd1d
commit
b5356a44af
156 changed files with 3600 additions and 2644 deletions
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: ociic.c,v 1.3 2022/04/06 18:59:28 naddy Exp $ */
|
||||
/* $OpenBSD: ociic.c,v 1.4 2024/05/15 22:54:03 kettenis Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2021 Mark Kettenis <kettenis@openbsd.org>
|
||||
*
|
||||
|
@ -53,6 +53,13 @@
|
|||
#define I2C_SR_TIP (1 << 1)
|
||||
#define I2C_SR_IF (1 << 0)
|
||||
|
||||
/*
|
||||
* OpenSBI on the SiFive HiFive Unmatched board implements reboot and
|
||||
* powerdown functionality through the Dialog DA9063 Power Management
|
||||
* IC over I2C. The code expects the I2C controller to be enabled so
|
||||
* we have to make sure we leave it in that state.
|
||||
*/
|
||||
|
||||
struct ociic_softc {
|
||||
struct device sc_dev;
|
||||
bus_space_tag_t sc_iot;
|
||||
|
@ -156,6 +163,8 @@ ociic_attach(struct device *parent, struct device *self, void *aux)
|
|||
ociic_write(sc, I2C_PRER_HI, div >> 8);
|
||||
}
|
||||
|
||||
ociic_set(sc, I2C_CTR, I2C_CTR_EN);
|
||||
|
||||
sc->sc_ic.ic_cookie = sc;
|
||||
sc->sc_ic.ic_acquire_bus = ociic_acquire_bus;
|
||||
sc->sc_ic.ic_release_bus = ociic_release_bus;
|
||||
|
@ -174,18 +183,12 @@ ociic_attach(struct device *parent, struct device *self, void *aux)
|
|||
int
|
||||
ociic_acquire_bus(void *cookie, int flags)
|
||||
{
|
||||
struct ociic_softc *sc = cookie;
|
||||
|
||||
ociic_set(sc, I2C_CTR, I2C_CTR_EN);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
ociic_release_bus(void *cookie, int flags)
|
||||
{
|
||||
struct ociic_softc *sc = cookie;
|
||||
|
||||
ociic_clr(sc, I2C_CTR, I2C_CTR_EN);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: virtio_mmio.c,v 1.12 2024/01/15 02:35:23 dv Exp $ */
|
||||
/* $OpenBSD: virtio_mmio.c,v 1.13 2024/05/17 16:37:10 sf Exp $ */
|
||||
/* $NetBSD: virtio.c,v 1.3 2011/11/02 23:05:52 njoly Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -97,6 +97,7 @@ void virtio_mmio_write_device_config_4(struct virtio_softc *, int, uint32_t);
|
|||
void virtio_mmio_write_device_config_8(struct virtio_softc *, int, uint64_t);
|
||||
uint16_t virtio_mmio_read_queue_size(struct virtio_softc *, uint16_t);
|
||||
void virtio_mmio_setup_queue(struct virtio_softc *, struct virtqueue *, uint64_t);
|
||||
int virtio_mmio_get_status(struct virtio_softc *);
|
||||
void virtio_mmio_set_status(struct virtio_softc *, int);
|
||||
int virtio_mmio_negotiate_features(struct virtio_softc *,
|
||||
const struct virtio_feature_name *);
|
||||
|
@ -144,6 +145,7 @@ struct virtio_ops virtio_mmio_ops = {
|
|||
virtio_mmio_write_device_config_8,
|
||||
virtio_mmio_read_queue_size,
|
||||
virtio_mmio_setup_queue,
|
||||
virtio_mmio_get_status,
|
||||
virtio_mmio_set_status,
|
||||
virtio_mmio_negotiate_features,
|
||||
virtio_mmio_intr,
|
||||
|
@ -194,6 +196,15 @@ virtio_mmio_setup_queue(struct virtio_softc *vsc, struct virtqueue *vq,
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
virtio_mmio_get_status(struct virtio_softc *vsc)
|
||||
{
|
||||
struct virtio_mmio_softc *sc = (struct virtio_mmio_softc *)vsc;
|
||||
|
||||
return bus_space_read_4(sc->sc_iot, sc->sc_ioh,
|
||||
VIRTIO_MMIO_STATUS);
|
||||
}
|
||||
|
||||
void
|
||||
virtio_mmio_set_status(struct virtio_softc *vsc, int status)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: ufshci.c,v 1.22 2024/05/15 18:01:10 mglocker Exp $ */
|
||||
/* $OpenBSD: ufshci.c,v 1.24 2024/05/16 10:52:11 mglocker Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2022 Marcus Glocker <mglocker@openbsd.org>
|
||||
|
@ -186,9 +186,6 @@ ufshci_attach(struct ufshci_softc *sc)
|
|||
DPRINTF(1, " BI=0x%04x\n", UFSHCI_REG_HCMID_BI(sc->sc_hcmid));
|
||||
DPRINTF(1, " MIC=0x%04x\n", UFSHCI_REG_HCMID_MIC(sc->sc_hcmid));
|
||||
|
||||
/* XXX: Using more than one slot currently causes OCS errors */
|
||||
sc->sc_nutrs = 1;
|
||||
|
||||
if (sc->sc_nutrs > 32) {
|
||||
printf("%s: NUTRS can't be >32 (is %d)!\n",
|
||||
sc->sc_dev.dv_xname, sc->sc_nutrs);
|
||||
|
@ -513,7 +510,7 @@ ufshci_utr_cmd_nop(struct ufshci_softc *sc, struct ufshci_ccb *ccb,
|
|||
ucd->cmd.hdr.tc = UPIU_TC_I2T_NOP_OUT;
|
||||
ucd->cmd.hdr.flags = 0;
|
||||
ucd->cmd.hdr.lun = 0;
|
||||
ucd->cmd.hdr.taskid = 0;
|
||||
ucd->cmd.hdr.task_tag = slot;
|
||||
ucd->cmd.hdr.cmd_set_type = 0; /* SCSI command */
|
||||
ucd->cmd.hdr.query = 0;
|
||||
ucd->cmd.hdr.response = 0;
|
||||
|
@ -603,7 +600,7 @@ ufshci_utr_cmd_lun(struct ufshci_softc *sc, struct ufshci_ccb *ccb,
|
|||
ucd->cmd.hdr.tc = UPIU_TC_I2T_COMMAND;
|
||||
ucd->cmd.hdr.flags = (1 << 6); /* Bit-5 = Write, Bit-6 = Read */
|
||||
ucd->cmd.hdr.lun = 0;
|
||||
ucd->cmd.hdr.taskid = 0;
|
||||
ucd->cmd.hdr.task_tag = slot;
|
||||
ucd->cmd.hdr.cmd_set_type = 0; /* SCSI command */
|
||||
ucd->cmd.hdr.query = 0;
|
||||
ucd->cmd.hdr.response = 0;
|
||||
|
@ -710,7 +707,7 @@ ufshci_utr_cmd_inquiry(struct ufshci_softc *sc, struct ufshci_ccb *ccb,
|
|||
ucd->cmd.hdr.tc = UPIU_TC_I2T_COMMAND;
|
||||
ucd->cmd.hdr.flags = (1 << 6); /* Bit-5 = Write, Bit-6 = Read */
|
||||
ucd->cmd.hdr.lun = 0;
|
||||
ucd->cmd.hdr.taskid = 0;
|
||||
ucd->cmd.hdr.task_tag = slot;
|
||||
ucd->cmd.hdr.cmd_set_type = 0; /* SCSI command */
|
||||
ucd->cmd.hdr.query = 0;
|
||||
ucd->cmd.hdr.response = 0;
|
||||
|
@ -815,7 +812,7 @@ ufshci_utr_cmd_capacity16(struct ufshci_softc *sc, struct ufshci_ccb *ccb,
|
|||
ucd->cmd.hdr.tc = UPIU_TC_I2T_COMMAND;
|
||||
ucd->cmd.hdr.flags = (1 << 6); /* Bit-5 = Write, Bit-6 = Read */
|
||||
ucd->cmd.hdr.lun = 0;
|
||||
ucd->cmd.hdr.taskid = 0;
|
||||
ucd->cmd.hdr.task_tag = slot;
|
||||
ucd->cmd.hdr.cmd_set_type = 0; /* SCSI command */
|
||||
ucd->cmd.hdr.query = 0;
|
||||
ucd->cmd.hdr.response = 0;
|
||||
|
@ -924,7 +921,7 @@ ufshci_utr_cmd_capacity(struct ufshci_softc *sc, struct ufshci_ccb *ccb,
|
|||
ucd->cmd.hdr.tc = UPIU_TC_I2T_COMMAND;
|
||||
ucd->cmd.hdr.flags = (1 << 6); /* Bit-5 = Write, Bit-6 = Read */
|
||||
ucd->cmd.hdr.lun = 0;
|
||||
ucd->cmd.hdr.taskid = 0;
|
||||
ucd->cmd.hdr.task_tag = slot;
|
||||
ucd->cmd.hdr.cmd_set_type = 0; /* SCSI command */
|
||||
ucd->cmd.hdr.query = 0;
|
||||
ucd->cmd.hdr.response = 0;
|
||||
|
@ -1003,6 +1000,8 @@ ufshci_utr_cmd_io(struct ufshci_softc *sc, struct ufshci_ccb *ccb,
|
|||
struct ufshci_utrd *utrd;
|
||||
struct ufshci_ucd *ucd;
|
||||
bus_dmamap_t dmap = ccb->ccb_dmamap;
|
||||
uint32_t blocks;
|
||||
uint64_t lba;
|
||||
|
||||
/* 7.2.1 Basic Steps when Building a UTP Transfer Request: 1) */
|
||||
slot = ccb->ccb_slot;
|
||||
|
@ -1038,7 +1037,7 @@ ufshci_utr_cmd_io(struct ufshci_softc *sc, struct ufshci_ccb *ccb,
|
|||
else
|
||||
ucd->cmd.hdr.flags = (1 << 5); /* Bit-5 = Write */
|
||||
ucd->cmd.hdr.lun = 0;
|
||||
ucd->cmd.hdr.taskid = 0;
|
||||
ucd->cmd.hdr.task_tag = slot;
|
||||
ucd->cmd.hdr.cmd_set_type = 0; /* SCSI command */
|
||||
ucd->cmd.hdr.query = 0;
|
||||
ucd->cmd.hdr.response = 0;
|
||||
|
@ -1047,7 +1046,16 @@ ufshci_utr_cmd_io(struct ufshci_softc *sc, struct ufshci_ccb *ccb,
|
|||
ucd->cmd.hdr.device_info = 0;
|
||||
ucd->cmd.hdr.ds_len = 0;
|
||||
|
||||
ucd->cmd.expected_xfer_len = htobe32(xs->datalen);
|
||||
/*
|
||||
* JESD220C-2_1.pdf, page 88, d) Expected Data Transfer Length:
|
||||
* "When the COMMAND UPIU encodes a SCSI WRITE or SCSI READ command
|
||||
* (specifically WRITE (6), READ (6), WRITE (10), READ (10),
|
||||
* WRITE (16), or READ (16)), the value of this field shall be the
|
||||
* product of the Logical Block Size (bLogicalBlockSize) and the
|
||||
* TRANSFER LENGTH field of the CDB."
|
||||
*/
|
||||
scsi_cmd_rw_decode(&xs->cmd, &lba, &blocks);
|
||||
ucd->cmd.expected_xfer_len = htobe32(UFSHCI_LBS * blocks);
|
||||
|
||||
memcpy(ucd->cmd.cdb, &xs->cmd, sizeof(ucd->cmd.cdb));
|
||||
|
||||
|
@ -1140,7 +1148,7 @@ ufshci_utr_cmd_sync(struct ufshci_softc *sc, struct ufshci_ccb *ccb,
|
|||
ucd->cmd.hdr.tc = UPIU_TC_I2T_COMMAND;
|
||||
ucd->cmd.hdr.flags = 0; /* No data transfer */
|
||||
ucd->cmd.hdr.lun = 0;
|
||||
ucd->cmd.hdr.taskid = 0;
|
||||
ucd->cmd.hdr.task_tag = slot;
|
||||
ucd->cmd.hdr.cmd_set_type = 0; /* SCSI command */
|
||||
ucd->cmd.hdr.query = 0;
|
||||
ucd->cmd.hdr.response = 0;
|
||||
|
@ -1207,16 +1215,19 @@ ufshci_xfer_complete(struct ufshci_softc *sc)
|
|||
{
|
||||
struct ufshci_ccb *ccb;
|
||||
uint32_t reg;
|
||||
int i;
|
||||
int i, timeout;
|
||||
|
||||
mtx_enter(&sc->sc_cmd_mtx);
|
||||
|
||||
/* Wait for all commands to complete. */
|
||||
while ((reg = ufshci_doorbell_read(sc))) {
|
||||
DPRINTF(3, "%s: doorbell reg=0x%x\n", __func__, reg);
|
||||
for (timeout = 5000; timeout != 0; timeout--) {
|
||||
reg = ufshci_doorbell_read(sc);
|
||||
if (reg == 0)
|
||||
break;
|
||||
delay(10);
|
||||
}
|
||||
if (timeout == 0)
|
||||
printf("%s: timeout (reg=0x%x)\n", __func__, reg);
|
||||
|
||||
for (i = 0; i < sc->sc_nutrs; i++) {
|
||||
ccb = &sc->sc_ccbs[i];
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: ufshcireg.h,v 1.7 2024/05/09 08:20:22 mglocker Exp $ */
|
||||
/* $OpenBSD: ufshcireg.h,v 1.9 2024/05/16 10:52:11 mglocker Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2022 Marcus Glocker <mglocker@openbsd.org>
|
||||
|
@ -21,8 +21,11 @@
|
|||
*/
|
||||
#define UFSHCI_UCD_PRDT_MAX_SEGS 64
|
||||
#define UFSHCI_UCD_PRDT_MAX_XFER (UFSHCI_UCD_PRDT_MAX_SEGS * PAGE_SIZE)
|
||||
#define UFSHCI_INTR_AGGR_TIMEOUT 0x64 /* 4ms */
|
||||
#define UFSHCI_INTR_AGGR_TIMEOUT 0x08 /* 320us (1 unit = 40us) */
|
||||
#define UFSHCI_MAX_UNITS 32
|
||||
#define UFSHCI_LBS 4096 /* UFS Logical Block Size:
|
||||
For UFS minimum size shall be
|
||||
4096 bytes */
|
||||
|
||||
/*
|
||||
* Controller Capabilities Registers
|
||||
|
@ -335,7 +338,7 @@ struct upiu_hdr {
|
|||
uint8_t tc; /* Transaction Code */
|
||||
uint8_t flags;
|
||||
uint8_t lun;
|
||||
uint8_t taskid;
|
||||
uint8_t task_tag;
|
||||
uint8_t cmd_set_type;
|
||||
uint8_t query;
|
||||
uint8_t response;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: ufshcivar.h,v 1.4 2024/05/09 08:06:42 mglocker Exp $ */
|
||||
/* $OpenBSD: ufshcivar.h,v 1.5 2024/05/15 20:15:33 mglocker Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2022 Marcus Glocker <mglocker@openbsd.org>
|
||||
|
@ -68,7 +68,6 @@ struct ufshci_softc {
|
|||
uint8_t sc_nutmrs;
|
||||
uint8_t sc_rtt;
|
||||
uint8_t sc_nutrs;
|
||||
uint8_t sc_taskid;
|
||||
|
||||
struct ufshci_dmamem *sc_dmamem_utmrd;
|
||||
struct ufshci_dmamem *sc_dmamem_utrd;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: azalia.c,v 1.286 2024/03/06 00:11:25 jsg Exp $ */
|
||||
/* $OpenBSD: azalia.c,v 1.287 2024/05/17 19:43:45 kettenis Exp $ */
|
||||
/* $NetBSD: azalia.c,v 1.20 2006/05/07 08:31:44 kent Exp $ */
|
||||
|
||||
/*-
|
||||
|
@ -176,6 +176,7 @@ typedef struct azalia_t {
|
|||
int nistreams, nostreams, nbstreams;
|
||||
stream_t pstream;
|
||||
stream_t rstream;
|
||||
uint32_t intctl;
|
||||
} azalia_t;
|
||||
#define XNAME(sc) ((sc)->dev.dv_xname)
|
||||
#define AZ_READ_1(z, r) bus_space_read_1((z)->iot, (z)->ioh, HDA_##r)
|
||||
|
@ -556,16 +557,6 @@ azalia_pci_attach(struct device *parent, struct device *self, void *aux)
|
|||
azalia_pci_write(sc->pc, sc->tag, ICH_PCI_MMC, reg);
|
||||
}
|
||||
|
||||
/* disable MSI for AMD Summit Ridge/Raven Ridge HD Audio */
|
||||
if (PCI_VENDOR(sc->pciid) == PCI_VENDOR_AMD) {
|
||||
switch (PCI_PRODUCT(sc->pciid)) {
|
||||
case PCI_PRODUCT_AMD_17_HDA:
|
||||
case PCI_PRODUCT_AMD_17_1X_HDA:
|
||||
case PCI_PRODUCT_AMD_HUDSON2_HDA:
|
||||
pa->pa_flags &= ~PCI_FLAGS_MSI_ENABLED;
|
||||
}
|
||||
}
|
||||
|
||||
/* interrupt */
|
||||
if (pci_intr_map_msi(pa, &ih) && pci_intr_map(pa, &ih)) {
|
||||
printf(": can't map interrupt\n");
|
||||
|
@ -684,7 +675,6 @@ azalia_pci_detach(struct device *self, int flags)
|
|||
AZ_WRITE_4(az, INTCTL, 0);
|
||||
|
||||
DPRINTF(("%s: clear interrupts\n", __func__));
|
||||
AZ_WRITE_4(az, INTSTS, HDA_INTSTS_CIS | HDA_INTSTS_GIS);
|
||||
AZ_WRITE_2(az, STATESTS, HDA_STATESTS_SDIWAKE);
|
||||
AZ_WRITE_1(az, RIRBSTS, HDA_RIRBSTS_RINTFL | HDA_RIRBSTS_RIRBOIS);
|
||||
}
|
||||
|
@ -711,29 +701,27 @@ azalia_intr(void *v)
|
|||
int ret = 0;
|
||||
|
||||
mtx_enter(&audio_lock);
|
||||
intsts = AZ_READ_4(az, INTSTS);
|
||||
if (intsts == 0 || intsts == 0xffffffff) {
|
||||
mtx_leave(&audio_lock);
|
||||
return (ret);
|
||||
}
|
||||
for (;;) {
|
||||
intsts = AZ_READ_4(az, INTSTS);
|
||||
if ((intsts & az->intctl) == 0 || intsts == 0xffffffff)
|
||||
break;
|
||||
|
||||
AZ_WRITE_4(az, INTSTS, intsts);
|
||||
if (intsts & az->pstream.intr_bit) {
|
||||
azalia_stream_intr(&az->pstream);
|
||||
ret = 1;
|
||||
}
|
||||
|
||||
if (intsts & az->pstream.intr_bit) {
|
||||
azalia_stream_intr(&az->pstream);
|
||||
ret = 1;
|
||||
}
|
||||
if (intsts & az->rstream.intr_bit) {
|
||||
azalia_stream_intr(&az->rstream);
|
||||
ret = 1;
|
||||
}
|
||||
|
||||
if (intsts & az->rstream.intr_bit) {
|
||||
azalia_stream_intr(&az->rstream);
|
||||
ret = 1;
|
||||
}
|
||||
|
||||
if ((intsts & HDA_INTSTS_CIS) &&
|
||||
(AZ_READ_1(az, RIRBCTL) & HDA_RIRBCTL_RINTCTL) &&
|
||||
(AZ_READ_1(az, RIRBSTS) & HDA_RIRBSTS_RINTFL)) {
|
||||
azalia_rirb_intr(az);
|
||||
ret = 1;
|
||||
if ((intsts & HDA_INTSTS_CIS) &&
|
||||
(AZ_READ_1(az, RIRBCTL) & HDA_RIRBCTL_RINTCTL) &&
|
||||
(AZ_READ_1(az, RIRBSTS) & HDA_RIRBSTS_RINTFL)) {
|
||||
azalia_rirb_intr(az);
|
||||
ret = 1;
|
||||
}
|
||||
}
|
||||
mtx_leave(&audio_lock);
|
||||
return (ret);
|
||||
|
@ -918,7 +906,6 @@ azalia_init(azalia_t *az, int resuming)
|
|||
/* clear interrupt status */
|
||||
AZ_WRITE_2(az, STATESTS, HDA_STATESTS_SDIWAKE);
|
||||
AZ_WRITE_1(az, RIRBSTS, HDA_RIRBSTS_RINTFL | HDA_RIRBSTS_RIRBOIS);
|
||||
AZ_WRITE_4(az, INTSTS, HDA_INTSTS_CIS | HDA_INTSTS_GIS);
|
||||
AZ_WRITE_4(az, DPLBASE, 0);
|
||||
AZ_WRITE_4(az, DPUBASE, 0);
|
||||
|
||||
|
@ -932,8 +919,8 @@ azalia_init(azalia_t *az, int resuming)
|
|||
if (err)
|
||||
return(err);
|
||||
|
||||
AZ_WRITE_4(az, INTCTL,
|
||||
AZ_READ_4(az, INTCTL) | HDA_INTCTL_CIE | HDA_INTCTL_GIE);
|
||||
az->intctl = HDA_INTCTL_CIE | HDA_INTCTL_GIE;
|
||||
AZ_WRITE_4(az, INTCTL, az->intctl);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
@ -1421,7 +1408,6 @@ azalia_suspend(azalia_t *az)
|
|||
|
||||
/* stop interrupts and clear status registers */
|
||||
AZ_WRITE_4(az, INTCTL, 0);
|
||||
AZ_WRITE_4(az, INTSTS, HDA_INTSTS_CIS | HDA_INTSTS_GIS);
|
||||
AZ_WRITE_2(az, STATESTS, HDA_STATESTS_SDIWAKE);
|
||||
AZ_WRITE_1(az, RIRBSTS, HDA_RIRBSTS_RINTFL | HDA_RIRBSTS_RIRBOIS);
|
||||
|
||||
|
@ -3723,7 +3709,6 @@ azalia_stream_start(stream_t *this)
|
|||
bdlist_entry_t *bdlist;
|
||||
bus_addr_t dmaaddr, dmaend;
|
||||
int err, index;
|
||||
uint32_t intctl;
|
||||
uint8_t ctl2;
|
||||
|
||||
err = azalia_stream_reset(this);
|
||||
|
@ -3768,9 +3753,8 @@ azalia_stream_start(stream_t *this)
|
|||
if (err)
|
||||
return EINVAL;
|
||||
|
||||
intctl = AZ_READ_4(this->az, INTCTL);
|
||||
intctl |= this->intr_bit;
|
||||
AZ_WRITE_4(this->az, INTCTL, intctl);
|
||||
this->az->intctl |= this->intr_bit;
|
||||
AZ_WRITE_4(this->az, INTCTL, this->az->intctl);
|
||||
|
||||
STR_WRITE_1(this, CTL, STR_READ_1(this, CTL) |
|
||||
HDA_SD_CTL_DEIE | HDA_SD_CTL_FEIE | HDA_SD_CTL_IOCE |
|
||||
|
@ -3786,8 +3770,8 @@ azalia_stream_halt(stream_t *this)
|
|||
ctl = STR_READ_2(this, CTL);
|
||||
ctl &= ~(HDA_SD_CTL_DEIE | HDA_SD_CTL_FEIE | HDA_SD_CTL_IOCE | HDA_SD_CTL_RUN);
|
||||
STR_WRITE_2(this, CTL, ctl);
|
||||
AZ_WRITE_4(this->az, INTCTL,
|
||||
AZ_READ_4(this->az, INTCTL) & ~this->intr_bit);
|
||||
this->az->intctl &= ~this->intr_bit;
|
||||
AZ_WRITE_4(this->az, INTCTL, this->az->intctl);
|
||||
azalia_codec_disconnect_stream(this);
|
||||
|
||||
return (0);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: virtio_pci.c,v 1.36 2024/01/15 02:35:23 dv Exp $ */
|
||||
/* $OpenBSD: virtio_pci.c,v 1.37 2024/05/17 16:37:10 sf Exp $ */
|
||||
/* $NetBSD: virtio.c,v 1.3 2011/11/02 23:05:52 njoly Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -72,6 +72,7 @@ void virtio_pci_write_device_config_4(struct virtio_softc *, int, uint32_t);
|
|||
void virtio_pci_write_device_config_8(struct virtio_softc *, int, uint64_t);
|
||||
uint16_t virtio_pci_read_queue_size(struct virtio_softc *, uint16_t);
|
||||
void virtio_pci_setup_queue(struct virtio_softc *, struct virtqueue *, uint64_t);
|
||||
int virtio_pci_get_status(struct virtio_softc *);
|
||||
void virtio_pci_set_status(struct virtio_softc *, int);
|
||||
int virtio_pci_negotiate_features(struct virtio_softc *, const struct virtio_feature_name *);
|
||||
int virtio_pci_negotiate_features_10(struct virtio_softc *, const struct virtio_feature_name *);
|
||||
|
@ -155,6 +156,7 @@ struct virtio_ops virtio_pci_ops = {
|
|||
virtio_pci_write_device_config_8,
|
||||
virtio_pci_read_queue_size,
|
||||
virtio_pci_setup_queue,
|
||||
virtio_pci_get_status,
|
||||
virtio_pci_set_status,
|
||||
virtio_pci_negotiate_features,
|
||||
virtio_pci_poll_intr,
|
||||
|
@ -275,6 +277,18 @@ virtio_pci_setup_queue(struct virtio_softc *vsc, struct virtqueue *vq,
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
virtio_pci_get_status(struct virtio_softc *vsc)
|
||||
{
|
||||
struct virtio_pci_softc *sc = (struct virtio_pci_softc *)vsc;
|
||||
|
||||
if (sc->sc_sc.sc_version_1)
|
||||
return CREAD(sc, device_status);
|
||||
else
|
||||
return bus_space_read_1(sc->sc_iot, sc->sc_ioh,
|
||||
VIRTIO_CONFIG_DEVICE_STATUS);
|
||||
}
|
||||
|
||||
void
|
||||
virtio_pci_set_status(struct virtio_softc *vsc, int status)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: if_vio.c,v 1.33 2024/05/07 18:35:23 jan Exp $ */
|
||||
/* $OpenBSD: if_vio.c,v 1.34 2024/05/17 16:37:10 sf Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2012 Stefan Fritsch, Alexander Fiveg.
|
||||
|
@ -252,6 +252,7 @@ struct vio_softc {
|
|||
#define VIRTIO_NET_TX_MAXNSEGS 16 /* for larger chains, defrag */
|
||||
#define VIRTIO_NET_CTRL_MAC_MC_ENTRIES 64 /* for more entries, use ALLMULTI */
|
||||
#define VIRTIO_NET_CTRL_MAC_UC_ENTRIES 1 /* one entry for own unicast addr */
|
||||
#define VIRTIO_NET_CTRL_TIMEOUT (5*1000*1000*1000ULL) /* 5 seconds */
|
||||
|
||||
#define VIO_CTRL_MAC_INFO_SIZE \
|
||||
(2*sizeof(struct virtio_net_ctrl_mac_tbl) + \
|
||||
|
@ -512,6 +513,17 @@ vio_put_lladdr(struct arpcom *ac, struct virtio_softc *vsc)
|
|||
}
|
||||
}
|
||||
|
||||
static int vio_needs_reset(struct vio_softc *sc)
|
||||
{
|
||||
if (virtio_get_status(sc->sc_virtio) &
|
||||
VIRTIO_CONFIG_DEVICE_STATUS_DEVICE_NEEDS_RESET) {
|
||||
printf("%s: device needs reset", sc->sc_dev.dv_xname);
|
||||
vio_ctrl_wakeup(sc, RESET);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
vio_attach(struct device *parent, struct device *self, void *aux)
|
||||
{
|
||||
|
@ -649,6 +661,7 @@ vio_config_change(struct virtio_softc *vsc)
|
|||
{
|
||||
struct vio_softc *sc = (struct vio_softc *)vsc->sc_child;
|
||||
vio_link_state(&sc->sc_ac.ac_if);
|
||||
vio_needs_reset(sc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -703,7 +716,7 @@ vio_stop(struct ifnet *ifp, int disable)
|
|||
virtio_reset(vsc);
|
||||
vio_rxeof(sc);
|
||||
if (vsc->sc_nvqs >= 3)
|
||||
vio_ctrleof(&sc->sc_vq[VQCTL]);
|
||||
vio_ctrl_wakeup(sc, RESET);
|
||||
vio_tx_drain(sc);
|
||||
if (disable)
|
||||
vio_rx_drain(sc);
|
||||
|
@ -714,11 +727,8 @@ vio_stop(struct ifnet *ifp, int disable)
|
|||
if (vsc->sc_nvqs >= 3)
|
||||
virtio_start_vq_intr(vsc, &sc->sc_vq[VQCTL]);
|
||||
virtio_reinit_end(vsc);
|
||||
if (vsc->sc_nvqs >= 3) {
|
||||
if (sc->sc_ctrl_inuse != FREE)
|
||||
sc->sc_ctrl_inuse = RESET;
|
||||
wakeup(&sc->sc_ctrl_inuse);
|
||||
}
|
||||
if (vsc->sc_nvqs >= 3)
|
||||
vio_ctrl_wakeup(sc, FREE);
|
||||
}
|
||||
|
||||
static inline uint16_t
|
||||
|
@ -1230,6 +1240,9 @@ vio_txeof(struct virtqueue *vq)
|
|||
int r = 0;
|
||||
int slot, len;
|
||||
|
||||
if (!ISSET(ifp->if_flags, IFF_RUNNING))
|
||||
return 0;
|
||||
|
||||
while (virtio_dequeue(vsc, vq, &slot, &len) == 0) {
|
||||
struct virtio_net_hdr *hdr = &sc->sc_tx_hdrs[slot];
|
||||
r++;
|
||||
|
@ -1363,32 +1376,15 @@ out:
|
|||
return r;
|
||||
}
|
||||
|
||||
/*
|
||||
* XXXSMP As long as some per-ifp ioctl(2)s are executed with the
|
||||
* NET_LOCK() deadlocks are possible. So release it here.
|
||||
*/
|
||||
static inline int
|
||||
vio_sleep(struct vio_softc *sc, const char *wmesg)
|
||||
{
|
||||
int status = rw_status(&netlock);
|
||||
|
||||
if (status != RW_WRITE && status != RW_READ)
|
||||
return tsleep_nsec(&sc->sc_ctrl_inuse, PRIBIO|PCATCH, wmesg,
|
||||
INFSLP);
|
||||
|
||||
return rwsleep_nsec(&sc->sc_ctrl_inuse, &netlock, PRIBIO|PCATCH, wmesg,
|
||||
INFSLP);
|
||||
}
|
||||
|
||||
int
|
||||
vio_wait_ctrl(struct vio_softc *sc)
|
||||
{
|
||||
int r = 0;
|
||||
|
||||
while (sc->sc_ctrl_inuse != FREE) {
|
||||
r = vio_sleep(sc, "viowait");
|
||||
if (r == EINTR)
|
||||
return r;
|
||||
if (sc->sc_ctrl_inuse == RESET || vio_needs_reset(sc))
|
||||
return ENXIO;
|
||||
r = tsleep_nsec(&sc->sc_ctrl_inuse, PRIBIO, "viowait", INFSLP);
|
||||
}
|
||||
sc->sc_ctrl_inuse = INUSE;
|
||||
|
||||
|
@ -1400,14 +1396,16 @@ vio_wait_ctrl_done(struct vio_softc *sc)
|
|||
{
|
||||
int r = 0;
|
||||
|
||||
while (sc->sc_ctrl_inuse != DONE && sc->sc_ctrl_inuse != RESET) {
|
||||
if (sc->sc_ctrl_inuse == RESET) {
|
||||
r = 1;
|
||||
break;
|
||||
while (sc->sc_ctrl_inuse != DONE) {
|
||||
if (sc->sc_ctrl_inuse == RESET || vio_needs_reset(sc))
|
||||
return ENXIO;
|
||||
r = tsleep_nsec(&sc->sc_ctrl_inuse, PRIBIO, "viodone",
|
||||
VIRTIO_NET_CTRL_TIMEOUT);
|
||||
if (r == EWOULDBLOCK) {
|
||||
printf("%s: ctrl queue timeout", sc->sc_dev.dv_xname);
|
||||
vio_ctrl_wakeup(sc, RESET);
|
||||
return ENXIO;
|
||||
}
|
||||
r = vio_sleep(sc, "viodone");
|
||||
if (r == EINTR)
|
||||
break;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: virtiovar.h,v 1.17 2024/05/13 01:15:51 jsg Exp $ */
|
||||
/* $OpenBSD: virtiovar.h,v 1.18 2024/05/17 16:37:10 sf Exp $ */
|
||||
/* $NetBSD: virtiovar.h,v 1.1 2011/10/30 12:12:21 hannken Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -154,6 +154,7 @@ struct virtio_ops {
|
|||
void (*write_dev_cfg_8)(struct virtio_softc *, int, uint64_t);
|
||||
uint16_t (*read_queue_size)(struct virtio_softc *, uint16_t);
|
||||
void (*setup_queue)(struct virtio_softc *, struct virtqueue *, uint64_t);
|
||||
int (*get_status)(struct virtio_softc *);
|
||||
void (*set_status)(struct virtio_softc *, int);
|
||||
int (*neg_features)(struct virtio_softc *, const struct virtio_feature_name *);
|
||||
int (*poll_intr)(void *);
|
||||
|
@ -197,9 +198,10 @@ struct virtio_softc {
|
|||
#define virtio_setup_queue(sc, i, v) (sc)->sc_ops->setup_queue(sc, i, v)
|
||||
#define virtio_negotiate_features(sc, n) (sc)->sc_ops->neg_features(sc, n)
|
||||
#define virtio_poll_intr(sc) (sc)->sc_ops->poll_intr(sc)
|
||||
#define virtio_get_status(sc) (sc)->sc_ops->get_status(sc)
|
||||
#define virtio_set_status(sc, i) (sc)->sc_ops->set_status(sc, i)
|
||||
|
||||
/* only for transport drivers */
|
||||
#define virtio_set_status(sc, i) (sc)->sc_ops->set_status(sc, i)
|
||||
#define virtio_device_reset(sc) virtio_set_status((sc), 0)
|
||||
|
||||
static inline int
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: esp_sbus.c,v 1.26 2022/03/13 13:34:54 mpi Exp $ */
|
||||
/* $OpenBSD: esp_sbus.c,v 1.27 2024/05/17 20:03:13 miod Exp $ */
|
||||
/* $NetBSD: esp_sbus.c,v 1.14 2001/04/25 17:53:37 bouyer Exp $ */
|
||||
|
||||
/*-
|
||||
|
@ -262,18 +262,14 @@ espattach_sbus(struct device *parent, struct device *self, void *aux)
|
|||
|
||||
/*
|
||||
* Find the DMA by poking around the dma device structures
|
||||
*
|
||||
* What happens here is that if the dma driver has not been
|
||||
* configured, then this returns a NULL pointer. Then when the
|
||||
* dma actually gets configured, it does the opposing test, and
|
||||
* if the sc->sc_esp field in its softc is NULL, then tries to
|
||||
* find the matching esp driver.
|
||||
* configured, then this returns a NULL pointer.
|
||||
*/
|
||||
esc->sc_dma = (struct lsi64854_softc *)
|
||||
getdevunit("dma", sc->sc_dev.dv_unit - esp_unit_offset);
|
||||
|
||||
/*
|
||||
* and a back pointer to us, for DMA
|
||||
* add a back pointer to us, for DMA
|
||||
*/
|
||||
if (esc->sc_dma)
|
||||
esc->sc_dma->sc_client = sc;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: wsmouse.c,v 1.71 2024/03/25 13:01:49 mvs Exp $ */
|
||||
/* $OpenBSD: wsmouse.c,v 1.72 2024/05/17 20:11:58 miod Exp $ */
|
||||
/* $NetBSD: wsmouse.c,v 1.35 2005/02/27 00:27:52 perry Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -1255,6 +1255,7 @@ wsmouse_matching(int *matrix, int m, int n, int *buffer)
|
|||
for (; p < mc; *p++ = 0) {}
|
||||
for (col = 0; col < n; col++) {
|
||||
delta = INT_MAX;
|
||||
row = 0;
|
||||
for (i = 0, p = matrix + col; i < m; i++, p += n) {
|
||||
d = *p - red[i];
|
||||
if (d < delta || (d == delta && r2c[i] < 0)) {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* $OpenBSD: init_sysent.c,v 1.280 2024/05/10 09:21:41 claudio Exp $ */
|
||||
/* $OpenBSD: init_sysent.c,v 1.281 2024/05/18 05:21:02 guenther Exp $ */
|
||||
|
||||
/*
|
||||
* System call switch table.
|
||||
*
|
||||
* DO NOT EDIT-- this file is automatically generated.
|
||||
* created from; OpenBSD: syscalls.master,v 1.263 2024/05/10 09:21:01 claudio Exp
|
||||
* created from; OpenBSD: syscalls.master,v 1.264 2024/05/18 05:20:22 guenther Exp
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
|
@ -417,8 +417,8 @@ const struct sysent sysent[] = {
|
|||
sys_nosys }, /* 188 = obsolete stat35 */
|
||||
{ 0, 0, 0,
|
||||
sys_nosys }, /* 189 = obsolete fstat35 */
|
||||
{ 0, 0, 0,
|
||||
sys_nosys }, /* 190 = obsolete lstat35 */
|
||||
{ 4, s(struct sys_pathconfat_args), 0,
|
||||
sys_pathconfat }, /* 190 = pathconfat */
|
||||
{ 2, s(struct sys_pathconf_args), 0,
|
||||
sys_pathconf }, /* 191 = pathconf */
|
||||
{ 2, s(struct sys_fpathconf_args), 0,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: kern_pledge.c,v 1.313 2024/04/05 13:55:26 deraadt Exp $ */
|
||||
/* $OpenBSD: kern_pledge.c,v 1.314 2024/05/18 05:20:22 guenther Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2015 Nicholas Marriott <nicm@openbsd.org>
|
||||
|
@ -340,6 +340,7 @@ const uint64_t pledge_syscalls[SYS_MAXSYSCALL] = {
|
|||
[SYS_statfs] = PLEDGE_RPATH,
|
||||
[SYS_fstatfs] = PLEDGE_RPATH,
|
||||
[SYS_pathconf] = PLEDGE_RPATH,
|
||||
[SYS_pathconfat] = PLEDGE_RPATH,
|
||||
|
||||
[SYS_utimes] = PLEDGE_FATTR,
|
||||
[SYS_futimes] = PLEDGE_FATTR,
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* $OpenBSD: syscalls.c,v 1.278 2024/05/10 09:21:41 claudio Exp $ */
|
||||
/* $OpenBSD: syscalls.c,v 1.279 2024/05/18 05:21:02 guenther Exp $ */
|
||||
|
||||
/*
|
||||
* System call names.
|
||||
*
|
||||
* DO NOT EDIT-- this file is automatically generated.
|
||||
* created from; OpenBSD: syscalls.master,v 1.263 2024/05/10 09:21:01 claudio Exp
|
||||
* created from; OpenBSD: syscalls.master,v 1.264 2024/05/18 05:20:22 guenther Exp
|
||||
*/
|
||||
|
||||
const char *const syscallnames[] = {
|
||||
|
@ -214,7 +214,7 @@ const char *const syscallnames[] = {
|
|||
"#187 (obsolete lfs_segwait)", /* 187 = obsolete lfs_segwait */
|
||||
"#188 (obsolete stat35)", /* 188 = obsolete stat35 */
|
||||
"#189 (obsolete fstat35)", /* 189 = obsolete fstat35 */
|
||||
"#190 (obsolete lstat35)", /* 190 = obsolete lstat35 */
|
||||
"pathconfat", /* 190 = pathconfat */
|
||||
"pathconf", /* 191 = pathconf */
|
||||
"fpathconf", /* 192 = fpathconf */
|
||||
"swapctl", /* 193 = swapctl */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
; $OpenBSD: syscalls.master,v 1.263 2024/05/10 09:21:01 claudio Exp $
|
||||
; $OpenBSD: syscalls.master,v 1.264 2024/05/18 05:20:22 guenther Exp $
|
||||
; $NetBSD: syscalls.master,v 1.32 1996/04/23 10:24:21 mycroft Exp $
|
||||
|
||||
; @(#)syscalls.master 8.2 (Berkeley) 1/13/94
|
||||
|
@ -346,7 +346,8 @@
|
|||
187 OBSOL lfs_segwait
|
||||
188 OBSOL stat35
|
||||
189 OBSOL fstat35
|
||||
190 OBSOL lstat35
|
||||
190 STD { long sys_pathconfat(int fd, const char *path, \
|
||||
int name, int flag); }
|
||||
191 STD { long sys_pathconf(const char *path, int name); }
|
||||
192 STD { long sys_fpathconf(int fd, int name); }
|
||||
193 STD { int sys_swapctl(int cmd, const void *arg, int misc); }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: uipc_socket.c,v 1.333 2024/05/03 17:43:09 mvs Exp $ */
|
||||
/* $OpenBSD: uipc_socket.c,v 1.335 2024/05/17 19:11:14 mvs Exp $ */
|
||||
/* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -66,7 +66,6 @@ void soreaper(void *);
|
|||
void soput(void *);
|
||||
int somove(struct socket *, int);
|
||||
void sorflush(struct socket *);
|
||||
void sorflush_locked(struct socket *);
|
||||
|
||||
void filt_sordetach(struct knote *kn);
|
||||
int filt_soread(struct knote *kn, long hint);
|
||||
|
@ -166,6 +165,7 @@ soalloc(const struct protosw *prp, int wait)
|
|||
break;
|
||||
}
|
||||
break;
|
||||
case AF_KEY:
|
||||
case AF_UNIX:
|
||||
so->so_snd.sb_flags |= SB_MTXLOCK;
|
||||
so->so_rcv.sb_flags |= SB_MTXLOCK;
|
||||
|
@ -606,11 +606,11 @@ sosend(struct socket *so, struct mbuf *addr, struct uio *uio, struct mbuf *top,
|
|||
|
||||
#define snderr(errno) { error = errno; goto release; }
|
||||
|
||||
restart:
|
||||
if ((error = sblock(&so->so_snd, SBLOCKWAIT(flags))) != 0)
|
||||
goto out;
|
||||
if (dosolock)
|
||||
solock_shared(so);
|
||||
restart:
|
||||
if ((error = sblock(so, &so->so_snd, SBLOCKWAIT(flags))) != 0)
|
||||
goto out;
|
||||
sb_mtx_lock(&so->so_snd);
|
||||
so->so_snd.sb_state |= SS_ISSENDING;
|
||||
do {
|
||||
|
@ -643,15 +643,12 @@ restart:
|
|||
(atomic || space < so->so_snd.sb_lowat))) {
|
||||
if (flags & MSG_DONTWAIT)
|
||||
snderr(EWOULDBLOCK);
|
||||
sbunlock(so, &so->so_snd);
|
||||
|
||||
if (so->so_snd.sb_flags & SB_MTXLOCK)
|
||||
error = sbwait_locked(so, &so->so_snd);
|
||||
else
|
||||
error = sbwait(so, &so->so_snd);
|
||||
|
||||
sbunlock(&so->so_snd);
|
||||
error = sbwait(so, &so->so_snd);
|
||||
so->so_snd.sb_state &= ~SS_ISSENDING;
|
||||
sb_mtx_unlock(&so->so_snd);
|
||||
if (dosolock)
|
||||
sounlock_shared(so);
|
||||
if (error)
|
||||
goto out;
|
||||
goto restart;
|
||||
|
@ -705,10 +702,10 @@ restart:
|
|||
release:
|
||||
so->so_snd.sb_state &= ~SS_ISSENDING;
|
||||
sb_mtx_unlock(&so->so_snd);
|
||||
sbunlock(so, &so->so_snd);
|
||||
out:
|
||||
if (dosolock)
|
||||
sounlock_shared(so);
|
||||
sbunlock(&so->so_snd);
|
||||
out:
|
||||
m_freem(top);
|
||||
m_freem(control);
|
||||
return (error);
|
||||
|
@ -875,11 +872,11 @@ bad:
|
|||
if (mp)
|
||||
*mp = NULL;
|
||||
|
||||
restart:
|
||||
if ((error = sblock(&so->so_rcv, SBLOCKWAIT(flags))) != 0)
|
||||
return (error);
|
||||
if (dosolock)
|
||||
solock_shared(so);
|
||||
restart:
|
||||
if ((error = sblock(so, &so->so_rcv, SBLOCKWAIT(flags))) != 0)
|
||||
goto out;
|
||||
sb_mtx_lock(&so->so_rcv);
|
||||
|
||||
m = so->so_rcv.sb_mb;
|
||||
|
@ -944,25 +941,13 @@ restart:
|
|||
SBLASTRECORDCHK(&so->so_rcv, "soreceive sbwait 1");
|
||||
SBLASTMBUFCHK(&so->so_rcv, "soreceive sbwait 1");
|
||||
|
||||
if (so->so_rcv.sb_flags & SB_MTXLOCK) {
|
||||
sbunlock_locked(so, &so->so_rcv);
|
||||
if (dosolock)
|
||||
sounlock_shared(so);
|
||||
error = sbwait_locked(so, &so->so_rcv);
|
||||
sb_mtx_unlock(&so->so_rcv);
|
||||
if (error)
|
||||
return (error);
|
||||
if (dosolock)
|
||||
solock_shared(so);
|
||||
} else {
|
||||
sb_mtx_unlock(&so->so_rcv);
|
||||
sbunlock(so, &so->so_rcv);
|
||||
error = sbwait(so, &so->so_rcv);
|
||||
if (error) {
|
||||
sounlock_shared(so);
|
||||
return (error);
|
||||
}
|
||||
}
|
||||
sbunlock(&so->so_rcv);
|
||||
error = sbwait(so, &so->so_rcv);
|
||||
sb_mtx_unlock(&so->so_rcv);
|
||||
if (dosolock)
|
||||
sounlock_shared(so);
|
||||
if (error)
|
||||
return (error);
|
||||
goto restart;
|
||||
}
|
||||
dontblock:
|
||||
|
@ -1202,21 +1187,12 @@ dontblock:
|
|||
break;
|
||||
SBLASTRECORDCHK(&so->so_rcv, "soreceive sbwait 2");
|
||||
SBLASTMBUFCHK(&so->so_rcv, "soreceive sbwait 2");
|
||||
if (dosolock) {
|
||||
if (sbwait(so, &so->so_rcv)) {
|
||||
sb_mtx_unlock(&so->so_rcv);
|
||||
error = sbwait(so, &so->so_rcv);
|
||||
if (error) {
|
||||
sbunlock(so, &so->so_rcv);
|
||||
if (dosolock)
|
||||
sounlock_shared(so);
|
||||
return (0);
|
||||
}
|
||||
sb_mtx_lock(&so->so_rcv);
|
||||
} else {
|
||||
if (sbwait_locked(so, &so->so_rcv)) {
|
||||
sb_mtx_unlock(&so->so_rcv);
|
||||
sbunlock(so, &so->so_rcv);
|
||||
return (0);
|
||||
}
|
||||
sbunlock(&so->so_rcv);
|
||||
return (0);
|
||||
}
|
||||
if ((m = so->so_rcv.sb_mb) != NULL)
|
||||
nextrecord = m->m_nextpkt;
|
||||
|
@ -1258,7 +1234,7 @@ dontblock:
|
|||
(flags & MSG_EOR) == 0 &&
|
||||
(so->so_rcv.sb_state & SS_CANTRCVMORE) == 0) {
|
||||
sb_mtx_unlock(&so->so_rcv);
|
||||
sbunlock(so, &so->so_rcv);
|
||||
sbunlock(&so->so_rcv);
|
||||
goto restart;
|
||||
}
|
||||
|
||||
|
@ -1269,10 +1245,9 @@ dontblock:
|
|||
*flagsp |= flags;
|
||||
release:
|
||||
sb_mtx_unlock(&so->so_rcv);
|
||||
sbunlock(so, &so->so_rcv);
|
||||
out:
|
||||
if (dosolock)
|
||||
sounlock_shared(so);
|
||||
sbunlock(&so->so_rcv);
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
@ -1302,48 +1277,33 @@ soshutdown(struct socket *so, int how)
|
|||
}
|
||||
|
||||
void
|
||||
sorflush_locked(struct socket *so)
|
||||
sorflush(struct socket *so)
|
||||
{
|
||||
struct sockbuf *sb = &so->so_rcv;
|
||||
struct mbuf *m;
|
||||
const struct protosw *pr = so->so_proto;
|
||||
int error;
|
||||
|
||||
if ((sb->sb_flags & SB_MTXLOCK) == 0)
|
||||
soassertlocked(so);
|
||||
|
||||
error = sblock(so, sb, SBL_WAIT | SBL_NOINTR);
|
||||
error = sblock(sb, SBL_WAIT | SBL_NOINTR);
|
||||
/* with SBL_WAIT and SLB_NOINTR sblock() must not fail */
|
||||
KASSERT(error == 0);
|
||||
|
||||
if (sb->sb_flags & SB_MTXLOCK)
|
||||
solock(so);
|
||||
solock_shared(so);
|
||||
socantrcvmore(so);
|
||||
if (sb->sb_flags & SB_MTXLOCK)
|
||||
sounlock(so);
|
||||
|
||||
mtx_enter(&sb->sb_mtx);
|
||||
m = sb->sb_mb;
|
||||
memset(&sb->sb_startzero, 0,
|
||||
(caddr_t)&sb->sb_endzero - (caddr_t)&sb->sb_startzero);
|
||||
sb->sb_timeo_nsecs = INFSLP;
|
||||
mtx_leave(&sb->sb_mtx);
|
||||
sbunlock(so, sb);
|
||||
sounlock_shared(so);
|
||||
sbunlock(sb);
|
||||
|
||||
if (pr->pr_flags & PR_RIGHTS && pr->pr_domain->dom_dispose)
|
||||
(*pr->pr_domain->dom_dispose)(m);
|
||||
m_purge(m);
|
||||
}
|
||||
|
||||
void
|
||||
sorflush(struct socket *so)
|
||||
{
|
||||
if ((so->so_rcv.sb_flags & SB_MTXLOCK) == 0)
|
||||
solock_shared(so);
|
||||
sorflush_locked(so);
|
||||
if ((so->so_rcv.sb_flags & SB_MTXLOCK) == 0)
|
||||
sounlock_shared(so);
|
||||
}
|
||||
|
||||
#ifdef SOCKET_SPLICE
|
||||
|
||||
#define so_splicelen so_sp->ssp_len
|
||||
|
@ -1355,7 +1315,7 @@ sorflush(struct socket *so)
|
|||
int
|
||||
sosplice(struct socket *so, int fd, off_t max, struct timeval *tv)
|
||||
{
|
||||
struct file *fp = NULL;
|
||||
struct file *fp;
|
||||
struct socket *sosp;
|
||||
struct taskq *tq;
|
||||
int error = 0;
|
||||
|
@ -1367,6 +1327,29 @@ sosplice(struct socket *so, int fd, off_t max, struct timeval *tv)
|
|||
if (tv && (tv->tv_sec < 0 || !timerisvalid(tv)))
|
||||
return (EINVAL);
|
||||
|
||||
/* If no fd is given, unsplice by removing existing link. */
|
||||
if (fd < 0) {
|
||||
if ((error = sblock(&so->so_rcv, SBL_WAIT)) != 0)
|
||||
return (error);
|
||||
solock(so);
|
||||
if (so->so_options & SO_ACCEPTCONN) {
|
||||
error = EOPNOTSUPP;
|
||||
goto out;
|
||||
}
|
||||
if ((so->so_state & (SS_ISCONNECTED|SS_ISCONNECTING)) == 0 &&
|
||||
(so->so_proto->pr_flags & PR_CONNREQUIRED)) {
|
||||
error = ENOTCONN;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (so->so_sp && so->so_sp->ssp_socket)
|
||||
sounsplice(so, so->so_sp->ssp_socket, 0);
|
||||
out:
|
||||
sounlock(so);
|
||||
sbunlock(&so->so_rcv);
|
||||
return (error);
|
||||
}
|
||||
|
||||
if (sosplice_taskq == NULL) {
|
||||
rw_enter_write(&sosplice_lock);
|
||||
if (sosplice_taskq == NULL) {
|
||||
|
@ -1386,65 +1369,47 @@ sosplice(struct socket *so, int fd, off_t max, struct timeval *tv)
|
|||
membar_consumer();
|
||||
}
|
||||
|
||||
if (so->so_rcv.sb_flags & SB_MTXLOCK) {
|
||||
if ((error = sblock(so, &so->so_rcv, SBL_WAIT)) != 0)
|
||||
return (error);
|
||||
solock(so);
|
||||
} else {
|
||||
solock(so);
|
||||
if ((error = sblock(so, &so->so_rcv, SBL_WAIT)) != 0) {
|
||||
sounlock(so);
|
||||
return (error);
|
||||
}
|
||||
/* Find sosp, the drain socket where data will be spliced into. */
|
||||
if ((error = getsock(curproc, fd, &fp)) != 0)
|
||||
return (error);
|
||||
sosp = fp->f_data;
|
||||
|
||||
if (sosp->so_proto->pr_usrreqs->pru_send !=
|
||||
so->so_proto->pr_usrreqs->pru_send) {
|
||||
error = EPROTONOSUPPORT;
|
||||
goto frele;
|
||||
}
|
||||
|
||||
if (so->so_options & SO_ACCEPTCONN) {
|
||||
if ((error = sblock(&so->so_rcv, SBL_WAIT)) != 0)
|
||||
goto frele;
|
||||
if ((error = sblock(&sosp->so_snd, SBL_WAIT)) != 0) {
|
||||
sbunlock(&so->so_rcv);
|
||||
goto frele;
|
||||
}
|
||||
solock(so);
|
||||
|
||||
if ((so->so_options & SO_ACCEPTCONN) ||
|
||||
(sosp->so_options & SO_ACCEPTCONN)) {
|
||||
error = EOPNOTSUPP;
|
||||
goto out;
|
||||
goto release;
|
||||
}
|
||||
if ((so->so_state & (SS_ISCONNECTED|SS_ISCONNECTING)) == 0 &&
|
||||
(so->so_proto->pr_flags & PR_CONNREQUIRED)) {
|
||||
error = ENOTCONN;
|
||||
goto out;
|
||||
}
|
||||
if (so->so_sp == NULL)
|
||||
so->so_sp = pool_get(&sosplice_pool, PR_WAITOK | PR_ZERO);
|
||||
|
||||
/* If no fd is given, unsplice by removing existing link. */
|
||||
if (fd < 0) {
|
||||
if (so->so_sp->ssp_socket)
|
||||
sounsplice(so, so->so_sp->ssp_socket, 0);
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Find sosp, the drain socket where data will be spliced into. */
|
||||
if ((error = getsock(curproc, fd, &fp)) != 0)
|
||||
goto out;
|
||||
sosp = fp->f_data;
|
||||
if (sosp->so_proto->pr_usrreqs->pru_send !=
|
||||
so->so_proto->pr_usrreqs->pru_send) {
|
||||
error = EPROTONOSUPPORT;
|
||||
goto out;
|
||||
}
|
||||
if (sosp->so_sp == NULL)
|
||||
sosp->so_sp = pool_get(&sosplice_pool, PR_WAITOK | PR_ZERO);
|
||||
|
||||
if ((error = sblock(sosp, &sosp->so_snd, SBL_WAIT)) != 0) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (so->so_sp->ssp_socket || sosp->so_sp->ssp_soback) {
|
||||
error = EBUSY;
|
||||
goto release;
|
||||
}
|
||||
if (sosp->so_options & SO_ACCEPTCONN) {
|
||||
error = EOPNOTSUPP;
|
||||
goto release;
|
||||
}
|
||||
if ((sosp->so_state & (SS_ISCONNECTED|SS_ISCONNECTING)) == 0) {
|
||||
error = ENOTCONN;
|
||||
goto release;
|
||||
}
|
||||
if (so->so_sp == NULL)
|
||||
so->so_sp = pool_get(&sosplice_pool, PR_WAITOK | PR_ZERO);
|
||||
if (sosp->so_sp == NULL)
|
||||
sosp->so_sp = pool_get(&sosplice_pool, PR_WAITOK | PR_ZERO);
|
||||
if (so->so_sp->ssp_socket || sosp->so_sp->ssp_soback) {
|
||||
error = EBUSY;
|
||||
goto release;
|
||||
}
|
||||
|
||||
/* Splice so and sosp together. */
|
||||
mtx_enter(&so->so_rcv.sb_mtx);
|
||||
|
@ -1472,18 +1437,11 @@ sosplice(struct socket *so, int fd, off_t max, struct timeval *tv)
|
|||
}
|
||||
|
||||
release:
|
||||
sbunlock(sosp, &sosp->so_snd);
|
||||
out:
|
||||
if (so->so_rcv.sb_flags & SB_MTXLOCK) {
|
||||
sounlock(so);
|
||||
sbunlock(so, &so->so_rcv);
|
||||
} else {
|
||||
sbunlock(so, &so->so_rcv);
|
||||
sounlock(so);
|
||||
}
|
||||
|
||||
if (fp)
|
||||
FRELE(fp, curproc);
|
||||
sounlock(so);
|
||||
sbunlock(&sosp->so_snd);
|
||||
sbunlock(&so->so_rcv);
|
||||
frele:
|
||||
FRELE(fp, curproc);
|
||||
|
||||
return (error);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: uipc_socket2.c,v 1.154 2024/05/07 15:54:23 claudio Exp $ */
|
||||
/* $OpenBSD: uipc_socket2.c,v 1.155 2024/05/17 19:11:14 mvs Exp $ */
|
||||
/* $NetBSD: uipc_socket2.c,v 1.11 1996/02/04 02:17:55 christos Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -511,24 +511,20 @@ sbmtxassertlocked(struct socket *so, struct sockbuf *sb)
|
|||
/*
|
||||
* Wait for data to arrive at/drain from a socket buffer.
|
||||
*/
|
||||
int
|
||||
sbwait_locked(struct socket *so, struct sockbuf *sb)
|
||||
{
|
||||
int prio = (sb->sb_flags & SB_NOINTR) ? PSOCK : PSOCK | PCATCH;
|
||||
|
||||
MUTEX_ASSERT_LOCKED(&sb->sb_mtx);
|
||||
|
||||
sb->sb_flags |= SB_WAIT;
|
||||
return msleep_nsec(&sb->sb_cc, &sb->sb_mtx, prio, "sbwait",
|
||||
sb->sb_timeo_nsecs);
|
||||
}
|
||||
|
||||
int
|
||||
sbwait(struct socket *so, struct sockbuf *sb)
|
||||
{
|
||||
uint64_t timeo_nsecs;
|
||||
int prio = (sb->sb_flags & SB_NOINTR) ? PSOCK : PSOCK | PCATCH;
|
||||
|
||||
if (sb->sb_flags & SB_MTXLOCK) {
|
||||
MUTEX_ASSERT_LOCKED(&sb->sb_mtx);
|
||||
|
||||
sb->sb_flags |= SB_WAIT;
|
||||
return msleep_nsec(&sb->sb_cc, &sb->sb_mtx, prio, "sbwait",
|
||||
sb->sb_timeo_nsecs);
|
||||
}
|
||||
|
||||
soassertlocked(so);
|
||||
|
||||
mtx_enter(&sb->sb_mtx);
|
||||
|
@ -540,81 +536,26 @@ sbwait(struct socket *so, struct sockbuf *sb)
|
|||
}
|
||||
|
||||
int
|
||||
sblock(struct socket *so, struct sockbuf *sb, int flags)
|
||||
sblock(struct sockbuf *sb, int flags)
|
||||
{
|
||||
int error = 0, prio = PSOCK;
|
||||
int rwflags = RW_WRITE, error;
|
||||
|
||||
if (sb->sb_flags & SB_MTXLOCK) {
|
||||
int rwflags = RW_WRITE;
|
||||
|
||||
if (!(flags & SBL_NOINTR || sb->sb_flags & SB_NOINTR))
|
||||
rwflags |= RW_INTR;
|
||||
if (!(flags & SBL_WAIT))
|
||||
rwflags |= RW_NOSLEEP;
|
||||
|
||||
error = rw_enter(&sb->sb_lock, rwflags);
|
||||
if (error == EBUSY)
|
||||
error = EWOULDBLOCK;
|
||||
return error;
|
||||
}
|
||||
|
||||
soassertlocked(so);
|
||||
|
||||
mtx_enter(&sb->sb_mtx);
|
||||
if ((sb->sb_flags & SB_LOCK) == 0) {
|
||||
sb->sb_flags |= SB_LOCK;
|
||||
goto out;
|
||||
}
|
||||
if ((flags & SBL_WAIT) == 0) {
|
||||
error = EWOULDBLOCK;
|
||||
goto out;
|
||||
}
|
||||
if (!(flags & SBL_NOINTR || sb->sb_flags & SB_NOINTR))
|
||||
prio |= PCATCH;
|
||||
rwflags |= RW_INTR;
|
||||
if (!(flags & SBL_WAIT))
|
||||
rwflags |= RW_NOSLEEP;
|
||||
|
||||
while (sb->sb_flags & SB_LOCK) {
|
||||
sb->sb_flags |= SB_WANT;
|
||||
mtx_leave(&sb->sb_mtx);
|
||||
error = sosleep_nsec(so, &sb->sb_flags, prio, "sblock", INFSLP);
|
||||
if (error)
|
||||
return (error);
|
||||
mtx_enter(&sb->sb_mtx);
|
||||
}
|
||||
sb->sb_flags |= SB_LOCK;
|
||||
out:
|
||||
mtx_leave(&sb->sb_mtx);
|
||||
error = rw_enter(&sb->sb_lock, rwflags);
|
||||
if (error == EBUSY)
|
||||
error = EWOULDBLOCK;
|
||||
|
||||
return (error);
|
||||
return error;
|
||||
}
|
||||
|
||||
void
|
||||
sbunlock_locked(struct socket *so, struct sockbuf *sb)
|
||||
sbunlock(struct sockbuf *sb)
|
||||
{
|
||||
if (sb->sb_flags & SB_MTXLOCK) {
|
||||
rw_exit(&sb->sb_lock);
|
||||
return;
|
||||
}
|
||||
|
||||
MUTEX_ASSERT_LOCKED(&sb->sb_mtx);
|
||||
|
||||
sb->sb_flags &= ~SB_LOCK;
|
||||
if (sb->sb_flags & SB_WANT) {
|
||||
sb->sb_flags &= ~SB_WANT;
|
||||
wakeup(&sb->sb_flags);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
sbunlock(struct socket *so, struct sockbuf *sb)
|
||||
{
|
||||
if (sb->sb_flags & SB_MTXLOCK) {
|
||||
rw_exit(&sb->sb_lock);
|
||||
return;
|
||||
}
|
||||
|
||||
mtx_enter(&sb->sb_mtx);
|
||||
sbunlock_locked(so, sb);
|
||||
mtx_leave(&sb->sb_mtx);
|
||||
rw_exit(&sb->sb_lock);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1128,7 +1069,7 @@ void
|
|||
sbflush(struct socket *so, struct sockbuf *sb)
|
||||
{
|
||||
KASSERT(sb == &so->so_rcv || sb == &so->so_snd);
|
||||
KASSERT((sb->sb_flags & SB_LOCK) == 0);
|
||||
rw_assert_unlocked(&sb->sb_lock);
|
||||
|
||||
while (sb->sb_mbcnt)
|
||||
sbdrop(so, sb, (int)sb->sb_cc);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: vfs_syscalls.c,v 1.364 2024/03/25 17:57:07 guenther Exp $ */
|
||||
/* $OpenBSD: vfs_syscalls.c,v 1.365 2024/05/18 05:20:22 guenther Exp $ */
|
||||
/* $NetBSD: vfs_syscalls.c,v 1.71 1996/04/23 10:29:02 mycroft Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -76,6 +76,7 @@ int dosymlinkat(struct proc *, const char *, int, const char *);
|
|||
int dounlinkat(struct proc *, int, const char *, int);
|
||||
int dofaccessat(struct proc *, int, const char *, int, int);
|
||||
int dofstatat(struct proc *, int, const char *, struct stat *, int);
|
||||
int dopathconfat(struct proc *, int, const char *, int, int, register_t *);
|
||||
int doreadlinkat(struct proc *, int, const char *, char *, size_t,
|
||||
register_t *);
|
||||
int dochflagsat(struct proc *, int, const char *, u_int, int);
|
||||
|
@ -2112,16 +2113,42 @@ sys_pathconf(struct proc *p, void *v, register_t *retval)
|
|||
syscallarg(const char *) path;
|
||||
syscallarg(int) name;
|
||||
} */ *uap = v;
|
||||
int error;
|
||||
|
||||
return dopathconfat(p, AT_FDCWD, SCARG(uap, path), SCARG(uap, name),
|
||||
0, retval);
|
||||
}
|
||||
|
||||
int
|
||||
sys_pathconfat(struct proc *p, void *v, register_t *retval)
|
||||
{
|
||||
struct sys_pathconfat_args /* {
|
||||
syscallarg(int) fd;
|
||||
syscallarg(const char *) path;
|
||||
syscallarg(int) name;
|
||||
syscallarg(int) flag;
|
||||
} */ *uap = v;
|
||||
|
||||
return dopathconfat(p, SCARG(uap, fd), SCARG(uap, path),
|
||||
SCARG(uap, name), SCARG(uap, flag), retval);
|
||||
}
|
||||
|
||||
int
|
||||
dopathconfat(struct proc *p, int fd, const char *path, int name, int flag,
|
||||
register_t *retval)
|
||||
{
|
||||
int follow, error;
|
||||
struct nameidata nd;
|
||||
|
||||
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE,
|
||||
SCARG(uap, path), p);
|
||||
if (flag & ~AT_SYMLINK_NOFOLLOW)
|
||||
return EINVAL;
|
||||
|
||||
follow = (flag & AT_SYMLINK_NOFOLLOW) ? NOFOLLOW : FOLLOW;
|
||||
NDINITAT(&nd, LOOKUP, follow | LOCKLEAF, UIO_USERSPACE, fd, path, p);
|
||||
nd.ni_pledge = PLEDGE_RPATH;
|
||||
nd.ni_unveil = UNVEIL_READ;
|
||||
if ((error = namei(&nd)) != 0)
|
||||
return (error);
|
||||
error = VOP_PATHCONF(nd.ni_vp, SCARG(uap, name), retval);
|
||||
error = VOP_PATHCONF(nd.ni_vp, name, retval);
|
||||
vput(nd.ni_vp);
|
||||
return (error);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: pfkeyv2.c,v 1.260 2024/01/11 14:15:11 bluhm Exp $ */
|
||||
/* $OpenBSD: pfkeyv2.c,v 1.262 2024/05/17 19:02:04 mvs Exp $ */
|
||||
|
||||
/*
|
||||
* @(#)COPYRIGHT 1.1 (NRL) 17 January 1995
|
||||
|
@ -443,8 +443,7 @@ pfkey_sendup(struct pkpcb *kp, struct mbuf *m0, int more)
|
|||
{
|
||||
struct socket *so = kp->kcb_socket;
|
||||
struct mbuf *m;
|
||||
|
||||
soassertlocked(so);
|
||||
int ret;
|
||||
|
||||
if (more) {
|
||||
if (!(m = m_dup_pkt(m0, 0, M_DONTWAIT)))
|
||||
|
@ -452,7 +451,11 @@ pfkey_sendup(struct pkpcb *kp, struct mbuf *m0, int more)
|
|||
} else
|
||||
m = m0;
|
||||
|
||||
if (!sbappendaddr(so, &so->so_rcv, &pfkey_addr, m, NULL)) {
|
||||
mtx_enter(&so->so_rcv.sb_mtx);
|
||||
ret = sbappendaddr(so, &so->so_rcv, &pfkey_addr, m, NULL);
|
||||
mtx_leave(&so->so_rcv.sb_mtx);
|
||||
|
||||
if (ret == 0) {
|
||||
m_freem(m);
|
||||
return (ENOBUFS);
|
||||
}
|
||||
|
@ -515,9 +518,7 @@ pfkeyv2_sendmessage(void **headers, int mode, struct socket *so,
|
|||
* Send message to the specified socket, plus all
|
||||
* promiscuous listeners.
|
||||
*/
|
||||
solock(so);
|
||||
pfkey_sendup(sotokeycb(so), packet, 0);
|
||||
sounlock(so);
|
||||
|
||||
/*
|
||||
* Promiscuous messages contain the original message
|
||||
|
@ -544,10 +545,8 @@ pfkeyv2_sendmessage(void **headers, int mode, struct socket *so,
|
|||
if (kp->kcb_socket == so || kp->kcb_rdomain != rdomain)
|
||||
continue;
|
||||
|
||||
keylock(kp);
|
||||
if (kp->kcb_flags & PFKEYV2_SOCKETFLAGS_PROMISC)
|
||||
pfkey_sendup(kp, packet, 1);
|
||||
keyunlock(kp);
|
||||
}
|
||||
SRPL_LEAVE(&sr);
|
||||
m_freem(packet);
|
||||
|
@ -562,18 +561,18 @@ pfkeyv2_sendmessage(void **headers, int mode, struct socket *so,
|
|||
if (kp->kcb_rdomain != rdomain)
|
||||
continue;
|
||||
|
||||
keylock(kp);
|
||||
if (kp->kcb_flags & PFKEYV2_SOCKETFLAGS_REGISTERED) {
|
||||
if (!satype) {
|
||||
/* Just send to everyone registered */
|
||||
pfkey_sendup(kp, packet, 1);
|
||||
} else {
|
||||
keylock(kp);
|
||||
/* Check for specified satype */
|
||||
if ((1 << satype) & kp->kcb_reg)
|
||||
pfkey_sendup(kp, packet, 1);
|
||||
keyunlock(kp);
|
||||
}
|
||||
}
|
||||
keyunlock(kp);
|
||||
}
|
||||
SRPL_LEAVE(&sr);
|
||||
/* Free last/original copy of the packet */
|
||||
|
@ -595,14 +594,14 @@ pfkeyv2_sendmessage(void **headers, int mode, struct socket *so,
|
|||
|
||||
/* Send to all registered promiscuous listeners */
|
||||
SRPL_FOREACH(kp, &sr, &pkptable.pkp_list, kcb_list) {
|
||||
int flags = READ_ONCE(kp->kcb_flags);
|
||||
|
||||
if (kp->kcb_rdomain != rdomain)
|
||||
continue;
|
||||
|
||||
keylock(kp);
|
||||
if ((kp->kcb_flags & PFKEYV2_SOCKETFLAGS_PROMISC) &&
|
||||
!(kp->kcb_flags & PFKEYV2_SOCKETFLAGS_REGISTERED))
|
||||
if ((flags & PFKEYV2_SOCKETFLAGS_PROMISC) &&
|
||||
!(flags & PFKEYV2_SOCKETFLAGS_REGISTERED))
|
||||
pfkey_sendup(kp, packet, 1);
|
||||
keyunlock(kp);
|
||||
}
|
||||
SRPL_LEAVE(&sr);
|
||||
m_freem(packet);
|
||||
|
@ -614,9 +613,7 @@ pfkeyv2_sendmessage(void **headers, int mode, struct socket *so,
|
|||
if (kp->kcb_rdomain != rdomain)
|
||||
continue;
|
||||
|
||||
keylock(kp);
|
||||
pfkey_sendup(kp, packet, 1);
|
||||
keyunlock(kp);
|
||||
}
|
||||
SRPL_LEAVE(&sr);
|
||||
m_freem(packet);
|
||||
|
@ -1196,10 +1193,8 @@ pfkeyv2_dosend(struct socket *so, void *message, int len)
|
|||
if (bkp->kcb_rdomain != kp->kcb_rdomain)
|
||||
continue;
|
||||
|
||||
keylock(bkp);
|
||||
if (bkp->kcb_flags & PFKEYV2_SOCKETFLAGS_PROMISC)
|
||||
pfkey_sendup(bkp, packet, 1);
|
||||
keyunlock(bkp);
|
||||
}
|
||||
SRPL_LEAVE(&sr);
|
||||
|
||||
|
@ -2049,14 +2044,13 @@ pfkeyv2_dosend(struct socket *so, void *message, int len)
|
|||
goto ret;
|
||||
|
||||
SRPL_FOREACH(bkp, &sr, &pkptable.pkp_list, kcb_list) {
|
||||
if (bkp == kp || bkp->kcb_rdomain != kp->kcb_rdomain)
|
||||
if (bkp == kp ||
|
||||
bkp->kcb_rdomain != kp->kcb_rdomain)
|
||||
continue;
|
||||
|
||||
if (!smsg->sadb_msg_seq ||
|
||||
(smsg->sadb_msg_seq == kp->kcb_pid)) {
|
||||
keylock(bkp);
|
||||
pfkey_sendup(bkp, packet, 1);
|
||||
keyunlock(bkp);
|
||||
}
|
||||
}
|
||||
SRPL_LEAVE(&sr);
|
||||
|
@ -2705,7 +2699,10 @@ pfkeyv2_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp,
|
|||
if (namelen < 1)
|
||||
return (EINVAL);
|
||||
w.w_op = name[0];
|
||||
w.w_satype = name[1];
|
||||
if (namelen >= 2)
|
||||
w.w_satype = name[1];
|
||||
else
|
||||
w.w_satype = SADB_SATYPE_UNSPEC;
|
||||
w.w_where = oldp;
|
||||
w.w_len = oldp ? *oldlenp : 0;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: ip_ipip.c,v 1.101 2024/02/11 01:27:45 bluhm Exp $ */
|
||||
/* $OpenBSD: ip_ipip.c,v 1.102 2024/05/17 20:44:36 bluhm Exp $ */
|
||||
/*
|
||||
* The authors of this code are John Ioannidis (ji@tla.org),
|
||||
* Angelos D. Keromytis (kermit@csd.uch.gr) and
|
||||
|
@ -481,7 +481,7 @@ ipip_output(struct mbuf **mp, struct tdb *tdb)
|
|||
ip6o->ip6_vfc &= ~IPV6_VERSION_MASK;
|
||||
ip6o->ip6_vfc |= IPV6_VERSION;
|
||||
ip6o->ip6_plen = htons(m->m_pkthdr.len - sizeof(*ip6o));
|
||||
ip6o->ip6_hlim = ip_defttl;
|
||||
ip6o->ip6_hlim = ip6_defhlim;
|
||||
in6_embedscope(&ip6o->ip6_src, &tdb->tdb_src.sin6, NULL, NULL);
|
||||
in6_embedscope(&ip6o->ip6_dst, &tdb->tdb_dst.sin6, NULL, NULL);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: ip_output.c,v 1.398 2024/04/17 20:48:51 bluhm Exp $ */
|
||||
/* $OpenBSD: ip_output.c,v 1.399 2024/05/16 13:01:04 bluhm Exp $ */
|
||||
/* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -428,8 +428,9 @@ sendit:
|
|||
#endif
|
||||
|
||||
#ifdef IPSEC
|
||||
if (ipsec_in_use && (flags & IP_FORWARDING) && (ipforwarding == 2) &&
|
||||
(m_tag_find(m, PACKET_TAG_IPSEC_IN_DONE, NULL) == NULL)) {
|
||||
if ((flags & IP_FORWARDING) && ipforwarding == 2 &&
|
||||
(!ipsec_in_use ||
|
||||
m_tag_find(m, PACKET_TAG_IPSEC_IN_DONE, NULL) == NULL)) {
|
||||
error = EHOSTUNREACH;
|
||||
goto bad;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: mutex.h,v 1.21 2024/03/26 18:18:30 bluhm Exp $ */
|
||||
/* $OpenBSD: mutex.h,v 1.22 2024/05/16 09:30:03 kettenis Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004 Artur Grabowski <art@openbsd.org>
|
||||
|
@ -33,6 +33,20 @@
|
|||
* "mtx_enter(foo); mtx_enter(bar); mtx_leave(foo); mtx_leave(bar);"
|
||||
*/
|
||||
|
||||
/*
|
||||
* To prevent lock ordering problems with the kernel lock, we need to
|
||||
* make sure we block all interrupts that can grab the kernel lock.
|
||||
* The simplest way to achieve this is to make sure mutexes always
|
||||
* raise the interrupt priority level to the highest level that has
|
||||
* interrupts that grab the kernel lock.
|
||||
*/
|
||||
#ifdef MULTIPROCESSOR
|
||||
#define __MUTEX_IPL(ipl) \
|
||||
(((ipl) < IPL_MPFLOOR) ? IPL_MPFLOOR : (ipl))
|
||||
#else
|
||||
#define __MUTEX_IPL(ipl) (ipl)
|
||||
#endif
|
||||
|
||||
#include <machine/mutex.h>
|
||||
|
||||
#ifdef __USE_MI_MUTEX
|
||||
|
@ -48,20 +62,6 @@ struct mutex {
|
|||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
* To prevent lock ordering problems with the kernel lock, we need to
|
||||
* make sure we block all interrupts that can grab the kernel lock.
|
||||
* The simplest way to achieve this is to make sure mutexes always
|
||||
* raise the interrupt priority level to the highest level that has
|
||||
* interrupts that grab the kernel lock.
|
||||
*/
|
||||
#ifdef MULTIPROCESSOR
|
||||
#define __MUTEX_IPL(ipl) \
|
||||
(((ipl) > IPL_NONE && (ipl) < IPL_MPFLOOR) ? IPL_MPFLOOR : (ipl))
|
||||
#else
|
||||
#define __MUTEX_IPL(ipl) (ipl)
|
||||
#endif
|
||||
|
||||
#ifdef WITNESS
|
||||
#define MUTEX_INITIALIZER_FLAGS(ipl, name, flags) \
|
||||
{ NULL, __MUTEX_IPL((ipl)), IPL_NONE, MTX_LO_INITIALIZER(name, flags) }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: socketvar.h,v 1.130 2024/05/03 17:43:09 mvs Exp $ */
|
||||
/* $OpenBSD: socketvar.h,v 1.131 2024/05/17 19:11:14 mvs Exp $ */
|
||||
/* $NetBSD: socketvar.h,v 1.18 1996/02/09 18:25:38 christos Exp $ */
|
||||
|
||||
/*-
|
||||
|
@ -128,13 +128,11 @@ struct socket {
|
|||
struct klist sb_klist; /* process selecting read/write */
|
||||
} so_rcv, so_snd;
|
||||
#define SB_MAX (2*1024*1024) /* default for max chars in sockbuf */
|
||||
#define SB_LOCK 0x0001 /* lock on data queue */
|
||||
#define SB_WANT 0x0002 /* someone is waiting to lock */
|
||||
#define SB_WAIT 0x0004 /* someone is waiting for data/space */
|
||||
#define SB_ASYNC 0x0010 /* ASYNC I/O, need signals */
|
||||
#define SB_SPLICE 0x0020 /* buffer is splice source or drain */
|
||||
#define SB_NOINTR 0x0040 /* operations not interruptible */
|
||||
#define SB_MTXLOCK 0x0080 /* sblock() doesn't need solock() */
|
||||
#define SB_WAIT 0x0001 /* someone is waiting for data/space */
|
||||
#define SB_ASYNC 0x0002 /* ASYNC I/O, need signals */
|
||||
#define SB_SPLICE 0x0004 /* buffer is splice source or drain */
|
||||
#define SB_NOINTR 0x0008 /* operations not interruptible */
|
||||
#define SB_MTXLOCK 0x0010 /* sblock() doesn't need solock() */
|
||||
|
||||
void (*so_upcall)(struct socket *so, caddr_t arg, int waitf);
|
||||
caddr_t so_upcallarg; /* Arg for above */
|
||||
|
@ -315,11 +313,10 @@ sbfree(struct socket *so, struct sockbuf *sb, struct mbuf *m)
|
|||
* sleep is interruptible. Returns error without lock if
|
||||
* sleep is interrupted.
|
||||
*/
|
||||
int sblock(struct socket *, struct sockbuf *, int);
|
||||
int sblock(struct sockbuf *, int);
|
||||
|
||||
/* release lock on sockbuf sb */
|
||||
void sbunlock(struct socket *, struct sockbuf *);
|
||||
void sbunlock_locked(struct socket *, struct sockbuf *);
|
||||
void sbunlock(struct sockbuf *);
|
||||
|
||||
#define SB_EMPTY_FIXUP(sb) do { \
|
||||
if ((sb)->sb_mb == NULL) { \
|
||||
|
@ -367,7 +364,6 @@ int sbcheckreserve(u_long, u_long);
|
|||
int sbchecklowmem(void);
|
||||
int sbreserve(struct socket *, struct sockbuf *, u_long);
|
||||
int sbwait(struct socket *, struct sockbuf *);
|
||||
int sbwait_locked(struct socket *, struct sockbuf *);
|
||||
void soinit(void);
|
||||
void soabort(struct socket *);
|
||||
int soaccept(struct socket *, struct mbuf *);
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* $OpenBSD: syscall.h,v 1.277 2024/05/10 09:21:41 claudio Exp $ */
|
||||
/* $OpenBSD: syscall.h,v 1.278 2024/05/18 05:21:02 guenther Exp $ */
|
||||
|
||||
/*
|
||||
* System call numbers.
|
||||
*
|
||||
* DO NOT EDIT-- this file is automatically generated.
|
||||
* created from; OpenBSD: syscalls.master,v 1.263 2024/05/10 09:21:01 claudio Exp
|
||||
* created from; OpenBSD: syscalls.master,v 1.264 2024/05/18 05:20:22 guenther Exp
|
||||
*/
|
||||
|
||||
/* syscall: "exit" ret: "void" args: "int" */
|
||||
|
@ -497,7 +497,9 @@
|
|||
/* 187 is obsolete lfs_segwait */
|
||||
/* 188 is obsolete stat35 */
|
||||
/* 189 is obsolete fstat35 */
|
||||
/* 190 is obsolete lstat35 */
|
||||
/* syscall: "pathconfat" ret: "long" args: "int" "const char *" "int" "int" */
|
||||
#define SYS_pathconfat 190
|
||||
|
||||
/* syscall: "pathconf" ret: "long" args: "const char *" "int" */
|
||||
#define SYS_pathconf 191
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* $OpenBSD: syscallargs.h,v 1.280 2024/05/10 09:21:41 claudio Exp $ */
|
||||
/* $OpenBSD: syscallargs.h,v 1.281 2024/05/18 05:21:02 guenther Exp $ */
|
||||
|
||||
/*
|
||||
* System call argument lists.
|
||||
*
|
||||
* DO NOT EDIT-- this file is automatically generated.
|
||||
* created from; OpenBSD: syscalls.master,v 1.263 2024/05/10 09:21:01 claudio Exp
|
||||
* created from; OpenBSD: syscalls.master,v 1.264 2024/05/18 05:20:22 guenther Exp
|
||||
*/
|
||||
|
||||
#ifdef syscallarg
|
||||
|
@ -828,6 +828,13 @@ struct sys_seteuid_args {
|
|||
syscallarg(uid_t) euid;
|
||||
};
|
||||
|
||||
struct sys_pathconfat_args {
|
||||
syscallarg(int) fd;
|
||||
syscallarg(const char *) path;
|
||||
syscallarg(int) name;
|
||||
syscallarg(int) flag;
|
||||
};
|
||||
|
||||
struct sys_pathconf_args {
|
||||
syscallarg(const char *) path;
|
||||
syscallarg(int) name;
|
||||
|
@ -1320,6 +1327,7 @@ int sys_pwritev(struct proc *, void *, register_t *);
|
|||
int sys_setgid(struct proc *, void *, register_t *);
|
||||
int sys_setegid(struct proc *, void *, register_t *);
|
||||
int sys_seteuid(struct proc *, void *, register_t *);
|
||||
int sys_pathconfat(struct proc *, void *, register_t *);
|
||||
int sys_pathconf(struct proc *, void *, register_t *);
|
||||
int sys_fpathconf(struct proc *, void *, register_t *);
|
||||
int sys_swapctl(struct proc *, void *, register_t *);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue