sync with OpenBSD -current

This commit is contained in:
purplerain 2024-08-01 19:31:36 +00:00
parent 6c1791ec4e
commit d56bde2791
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
27 changed files with 162 additions and 54 deletions

View file

@ -1,4 +1,4 @@
.\" $OpenBSD: cat.1,v 1.36 2016/07/10 00:15:39 tedu Exp $ .\" $OpenBSD: cat.1,v 1.37 2024/08/01 14:08:07 jmc Exp $
.\" $NetBSD: cat.1,v 1.12 1995/09/27 05:38:55 cgd Exp $ .\" $NetBSD: cat.1,v 1.12 1995/09/27 05:38:55 cgd Exp $
.\" .\"
.\" Copyright (c) 1989, 1990, 1993 .\" Copyright (c) 1989, 1990, 1993
@ -33,7 +33,7 @@
.\" .\"
.\" @(#)cat.1 8.3 (Berkeley) 5/2/95 .\" @(#)cat.1 8.3 (Berkeley) 5/2/95
.\" .\"
.Dd $Mdocdate: July 10 2016 $ .Dd $Mdocdate: August 1 2024 $
.Dt CAT 1 .Dt CAT 1
.Os .Os
.Sh NAME .Sh NAME
@ -157,7 +157,7 @@ operand.
The The
.Nm .Nm
utility is compliant with the utility is compliant with the
.St -p1003.1-2008 .St -p1003.1-2024
specification. specification.
.Pp .Pp
The flags The flags

View file

@ -1,4 +1,4 @@
.\" $OpenBSD: chgrp.1,v 1.18 2019/09/02 21:18:41 deraadt Exp $ .\" $OpenBSD: chgrp.1,v 1.19 2024/08/01 14:08:38 jmc Exp $
.\" .\"
.\" Copyright (c) 1983, 1990, 1993, 1994 .\" Copyright (c) 1983, 1990, 1993, 1994
.\" The Regents of the University of California. All rights reserved. .\" The Regents of the University of California. All rights reserved.
@ -32,7 +32,7 @@
.\" .\"
.\" from: @(#)chgrp.1 8.3 (Berkeley) 3/31/94 .\" from: @(#)chgrp.1 8.3 (Berkeley) 3/31/94
.\" .\"
.Dd $Mdocdate: September 2 2019 $ .Dd $Mdocdate: August 1 2024 $
.Dt CHGRP 1 .Dt CHGRP 1
.Os .Os
.Sh NAME .Sh NAME
@ -136,5 +136,5 @@ group ID file
The The
.Nm .Nm
utility is compliant with the utility is compliant with the
.St -p1003.1-2008 .St -p1003.1-2024
specification. specification.

View file

@ -1,4 +1,4 @@
.\" $OpenBSD: chmod.1,v 1.43 2019/09/02 21:18:41 deraadt Exp $ .\" $OpenBSD: chmod.1,v 1.44 2024/08/01 14:30:17 jmc Exp $
.\" $NetBSD: chmod.1,v 1.8 1995/03/21 09:02:07 cgd Exp $ .\" $NetBSD: chmod.1,v 1.8 1995/03/21 09:02:07 cgd Exp $
.\" .\"
.\" Copyright (c) 1989, 1990, 1993, 1994 .\" Copyright (c) 1989, 1990, 1993, 1994
@ -33,7 +33,7 @@
.\" .\"
.\" @(#)chmod.1 8.4 (Berkeley) 3/31/94 .\" @(#)chmod.1 8.4 (Berkeley) 3/31/94
.\" .\"
.Dd $Mdocdate: September 2 2019 $ .Dd $Mdocdate: August 1 2024 $
.Dt CHMOD 1 .Dt CHMOD 1
.Os .Os
.Sh NAME .Sh NAME
@ -363,17 +363,17 @@ Set the group bits equal to the user bits, but clear the group write bit:
The The
.Nm .Nm
utility is compliant with the utility is compliant with the
.St -p1003.1-2008 .St -p1003.1-2024
specification. specification.
.Pp .Pp
The flags The flags
.Op Fl HLP .Op Fl HhLP
are extensions to that specification. are extensions to that specification.
.Pp .Pp
The The
.Sq t .Sq t
perm symbol (sticky bit) is marked by perm symbol (sticky bit) is marked by
.St -p1003.1-2008 .St -p1003.1-2024
as being an as being an
X/Open System Interfaces X/Open System Interfaces
option. option.

View file

@ -1,4 +1,4 @@
.\" $OpenBSD: chown.8,v 1.23 2019/09/06 19:25:08 schwarze Exp $ .\" $OpenBSD: chown.8,v 1.24 2024/08/01 14:44:34 jmc Exp $
.\" .\"
.\" Copyright (c) 1990, 1991, 1993, 1994 .\" Copyright (c) 1990, 1991, 1993, 1994
.\" The Regents of the University of California. All rights reserved. .\" The Regents of the University of California. All rights reserved.
@ -29,7 +29,7 @@
.\" .\"
.\" from: @(#)chown.8 8.3 (Berkeley) 3/31/94 .\" from: @(#)chown.8 8.3 (Berkeley) 3/31/94
.\" .\"
.Dd $Mdocdate: September 6 2019 $ .Dd $Mdocdate: August 1 2024 $
.Dt CHOWN 8 .Dt CHOWN 8
.Os .Os
.Sh NAME .Sh NAME
@ -147,7 +147,7 @@ Only the superuser is permitted to change the owner of a file.
The The
.Nm .Nm
utility is compliant with the utility is compliant with the
.St -p1003.1-2008 .St -p1003.1-2024
specification. specification.
.Pp .Pp
The ability to specify The ability to specify

View file

@ -19,6 +19,7 @@
#define _KERNEL #define _KERNEL
#include <machine/cpu.h> #include <machine/cpu.h>
#include <sys/proc.h> #include <sys/proc.h>
#include <sys/exec_elf.h>
#undef _KERNEL #undef _KERNEL
#endif #endif
@ -60,6 +61,14 @@ lldb::ProcessSP ProcessOpenBSDKernel::CreateInstance(lldb::TargetSP target_sp,
ModuleSP executable = target_sp->GetExecutableModule(); ModuleSP executable = target_sp->GetExecutableModule();
if (crash_file && !can_connect && executable) { if (crash_file && !can_connect && executable) {
#if defined(__OpenBSD__) #if defined(__OpenBSD__)
char buf[4];
FILE *fp = fopen(crash_file->GetPath().c_str(), "r");
if (fp == NULL)
return nullptr;
size_t r = fread(buf, 1, sizeof(buf), fp);
fclose(fp);
if (r != sizeof(buf) || memcmp(buf, ELFMAG, sizeof(buf)) == 0)
return nullptr;
kvm_t *kvm = kvm_t *kvm =
kvm_open(executable->GetFileSpec().GetPath().c_str(), kvm_open(executable->GetFileSpec().GetPath().c_str(),
crash_file->GetPath().c_str(), nullptr, O_RDONLY, nullptr); crash_file->GetPath().c_str(), nullptr, O_RDONLY, nullptr);

View file

@ -5,7 +5,7 @@ includedir=${prefix}/include
Name: sndio Name: sndio
Description: sndio library Description: sndio library
Version: 1.9.0 Version: 1.10.0
Requires: Requires:
Libs: -L${libdir} -lsndio Libs: -L${libdir} -lsndio
Cflags: -I${includedir} Cflags: -I${includedir}

View file

@ -715,6 +715,14 @@ int ZEXPORT deflatePending(z_streamp strm, unsigned *pending, int *bits) {
return Z_OK; return Z_OK;
} }
/* ========================================================================= */
int ZEXPORT deflateUsed(z_streamp strm, int *bits) {
if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
if (bits != Z_NULL)
*bits = strm->state->bi_used;
return Z_OK;
}
/* ========================================================================= */ /* ========================================================================= */
int ZEXPORT deflatePrime(z_streamp strm, int bits, int value) { int ZEXPORT deflatePrime(z_streamp strm, int bits, int value) {
deflate_state *s; deflate_state *s;
@ -1742,8 +1750,10 @@ local block_state deflate_stored(deflate_state *s, int flush) {
s->high_water = s->strstart; s->high_water = s->strstart;
/* If the last block was written to next_out, then done. */ /* If the last block was written to next_out, then done. */
if (last) if (last) {
s->bi_used = 8;
return finish_done; return finish_done;
}
/* If flushing and all input has been consumed, then done. */ /* If flushing and all input has been consumed, then done. */
if (flush != Z_NO_FLUSH && flush != Z_FINISH && if (flush != Z_NO_FLUSH && flush != Z_FINISH &&
@ -1795,6 +1805,8 @@ local block_state deflate_stored(deflate_state *s, int flush) {
} }
/* We've done all we can with the available input and output. */ /* We've done all we can with the available input and output. */
if (last)
s->bi_used = 8;
return last ? finish_started : need_more; return last ? finish_started : need_more;
} }

View file

@ -269,6 +269,9 @@ typedef struct internal_state {
/* Number of valid bits in bi_buf. All bits above the last valid bit /* Number of valid bits in bi_buf. All bits above the last valid bit
* are always zero. * are always zero.
*/ */
int bi_used;
/* Last number of used bits when going to a byte boundary.
*/
ulg high_water; ulg high_water;
/* High water mark offset in window for initialized bytes -- bytes above /* High water mark offset in window for initialized bytes -- bytes above

View file

@ -182,6 +182,7 @@ local void bi_windup(deflate_state *s) {
} else if (s->bi_valid > 0) { } else if (s->bi_valid > 0) {
put_byte(s, (Byte)s->bi_buf); put_byte(s, (Byte)s->bi_buf);
} }
s->bi_used = ((s->bi_valid - 1) & 7) + 1;
s->bi_buf = 0; s->bi_buf = 0;
s->bi_valid = 0; s->bi_valid = 0;
#ifdef ZLIB_DEBUG #ifdef ZLIB_DEBUG
@ -464,6 +465,7 @@ void ZLIB_INTERNAL _tr_init(deflate_state *s) {
s->bi_buf = 0; s->bi_buf = 0;
s->bi_valid = 0; s->bi_valid = 0;
s->bi_used = 0;
#ifdef ZLIB_DEBUG #ifdef ZLIB_DEBUG
s->compressed_len = 0L; s->compressed_len = 0L;
s->bits_sent = 0L; s->bits_sent = 0L;

View file

@ -57,6 +57,7 @@
# define deflateSetDictionary z_deflateSetDictionary # define deflateSetDictionary z_deflateSetDictionary
# define deflateSetHeader z_deflateSetHeader # define deflateSetHeader z_deflateSetHeader
# define deflateTune z_deflateTune # define deflateTune z_deflateTune
# define deflateUsed z_deflateUsed
# define deflate_copyright z_deflate_copyright # define deflate_copyright z_deflate_copyright
# define get_crc_table z_get_crc_table # define get_crc_table z_get_crc_table
# ifndef Z_SOLO # ifndef Z_SOLO

View file

@ -791,6 +791,18 @@ ZEXTERN int ZEXPORT deflatePending(z_streamp strm,
stream state was inconsistent. stream state was inconsistent.
*/ */
ZEXTERN int ZEXPORT deflateUsed(z_streamp strm,
int *bits);
/*
deflateUsed() returns in *bits the most recent number of deflate bits used
in the last byte when flushing to a byte boundary. The result is in 1..8, or
0 if there has not yet been a flush. This helps determine the location of
the last bit of a deflate stream.
deflateUsed returns Z_OK if success, or Z_STREAM_ERROR if the source
stream state was inconsistent.
*/
ZEXTERN int ZEXPORT deflatePrime(z_streamp strm, ZEXTERN int ZEXPORT deflatePrime(z_streamp strm,
int bits, int bits,
int value); int value);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: efiboot.c,v 1.57 2024/07/10 18:46:42 patrick Exp $ */ /* $OpenBSD: efiboot.c,v 1.58 2024/08/01 11:53:03 mglocker Exp $ */
/* /*
* Copyright (c) 2015 YASUOKA Masahiko <yasuoka@yasuoka.net> * Copyright (c) 2015 YASUOKA Masahiko <yasuoka@yasuoka.net>
@ -1123,6 +1123,8 @@ struct smbios_dtb {
"qcom/sc8280xp-lenovo-thinkpad-x13s.dtb" }, "qcom/sc8280xp-lenovo-thinkpad-x13s.dtb" },
{ "LENOVO", "83ED", { "LENOVO", "83ED",
"qcom/x1e80100-lenovo-yoga-slim7x.dtb" }, "qcom/x1e80100-lenovo-yoga-slim7x.dtb" },
{ "SAMSUNG", "Galaxy Book4 Edge",
"qcom/x1e80100-samsung-galaxy-book4-edge.dtb" },
}; };
void * void *

View file

@ -1,4 +1,4 @@
/* $OpenBSD: if_vio.c,v 1.44 2024/07/26 07:55:23 sf Exp $ */ /* $OpenBSD: if_vio.c,v 1.45 2024/08/01 11:13:19 sf Exp $ */
/* /*
* Copyright (c) 2012 Stefan Fritsch, Alexander Fiveg. * Copyright (c) 2012 Stefan Fritsch, Alexander Fiveg.
@ -1303,7 +1303,7 @@ vio_txtick(void *arg)
{ {
struct virtqueue *vq = arg; struct virtqueue *vq = arg;
int s = splnet(); int s = splnet();
vio_tx_intr(vq); virtio_check_vq(vq->vq_owner, vq);
splx(s); splx(s);
} }

View file

@ -1,4 +1,4 @@
/* $OpenBSD: vioblk.c,v 1.40 2024/07/26 07:55:23 sf Exp $ */ /* $OpenBSD: vioblk.c,v 1.41 2024/08/01 11:13:19 sf Exp $ */
/* /*
* Copyright (c) 2012 Stefan Fritsch. * Copyright (c) 2012 Stefan Fritsch.
@ -375,7 +375,7 @@ vioblk_reset(struct vioblk_softc *sc)
virtio_reset(sc->sc_virtio); virtio_reset(sc->sc_virtio);
/* finish requests that have been completed */ /* finish requests that have been completed */
vioblk_vq_done(&sc->sc_vq[0]); virtio_check_vq(sc->sc_virtio, &sc->sc_vq[0]);
/* abort all remaining requests */ /* abort all remaining requests */
for (i = 0; i < sc->sc_nreqs; i++) { for (i = 0; i < sc->sc_nreqs; i++) {
@ -535,7 +535,7 @@ vioblk_scsi_cmd(struct scsi_xfer *xs)
if (!ISSET(xs->flags, SCSI_POLL)) { if (!ISSET(xs->flags, SCSI_POLL)) {
/* check if some xfers are done: */ /* check if some xfers are done: */
if (sc->sc_queued > 1) if (sc->sc_queued > 1)
vioblk_vq_done(vq); virtio_check_vq(sc->sc_virtio, vq);
splx(s); splx(s);
return; return;
} }

View file

@ -1,4 +1,4 @@
/* $OpenBSD: viocon.c,v 1.12 2024/06/26 01:40:49 jsg Exp $ */ /* $OpenBSD: viocon.c,v 1.13 2024/08/01 11:13:19 sf Exp $ */
/* /*
* Copyright (c) 2013-2015 Stefan Fritsch <sf@sfritsch.de> * Copyright (c) 2013-2015 Stefan Fritsch <sf@sfritsch.de>
@ -463,7 +463,7 @@ vioconhwiflow(struct tty *tp, int stop)
virtio_stop_vq_intr(vp->vp_sc->sc_virtio, vp->vp_rx); virtio_stop_vq_intr(vp->vp_sc->sc_virtio, vp->vp_rx);
} else { } else {
virtio_start_vq_intr(vp->vp_sc->sc_virtio, vp->vp_rx); virtio_start_vq_intr(vp->vp_sc->sc_virtio, vp->vp_rx);
softintr_schedule(vp->vp_si); virtio_check_vq(vp->vp_sc->sc_virtio, vp->vp_rx);
} }
splx(s); splx(s);
return 1; return 1;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: viogpu.c,v 1.6 2024/05/24 10:05:55 jsg Exp $ */ /* $OpenBSD: viogpu.c,v 1.7 2024/08/01 11:13:19 sf Exp $ */
/* /*
* Copyright (c) 2021-2023 joshua stein <jcs@openbsd.org> * Copyright (c) 2021-2023 joshua stein <jcs@openbsd.org>
@ -42,7 +42,7 @@ struct viogpu_softc;
int viogpu_match(struct device *, void *, void *); int viogpu_match(struct device *, void *, void *);
void viogpu_attach(struct device *, struct device *, void *); void viogpu_attach(struct device *, struct device *, void *);
int viogpu_send_cmd(struct viogpu_softc *, void *, size_t, void *, size_t); int viogpu_send_cmd(struct viogpu_softc *, void *, size_t, void *, size_t);
int viogpu_vq_wait(struct virtqueue *vq); int viogpu_vq_done(struct virtqueue *vq);
void viogpu_rx_soft(void *arg); void viogpu_rx_soft(void *arg);
int viogpu_get_display_info(struct viogpu_softc *); int viogpu_get_display_info(struct viogpu_softc *);
@ -178,7 +178,7 @@ viogpu_attach(struct device *parent, struct device *self, void *aux)
printf(": alloc_vq failed\n"); printf(": alloc_vq failed\n");
return; return;
} }
sc->sc_vqs[VQCTRL].vq_done = viogpu_vq_wait; sc->sc_vqs[VQCTRL].vq_done = viogpu_vq_done;
if (virtio_alloc_vq(vsc, &sc->sc_vqs[VQCURS], VQCURS, NBPG, 1, if (virtio_alloc_vq(vsc, &sc->sc_vqs[VQCURS], VQCURS, NBPG, 1,
"cursor")) { "cursor")) {
@ -211,6 +211,8 @@ viogpu_attach(struct device *parent, struct device *self, void *aux)
goto unmap; goto unmap;
} }
virtio_set_status(vsc, VIRTIO_CONFIG_DEVICE_STATUS_DRIVER_OK);
if (viogpu_get_display_info(sc) != 0) if (viogpu_get_display_info(sc) != 0)
goto unmap; goto unmap;
@ -230,8 +232,6 @@ viogpu_attach(struct device *parent, struct device *self, void *aux)
sc->sc_fb_dma_kva, sc->sc_fb_dma_size, NULL, BUS_DMA_NOWAIT) != 0) sc->sc_fb_dma_kva, sc->sc_fb_dma_size, NULL, BUS_DMA_NOWAIT) != 0)
goto fb_unmap; goto fb_unmap;
virtio_set_status(vsc, VIRTIO_CONFIG_DEVICE_STATUS_DRIVER_OK);
if (viogpu_create_2d(sc, 1, sc->sc_fb_width, sc->sc_fb_height) != 0) if (viogpu_create_2d(sc, 1, sc->sc_fb_width, sc->sc_fb_height) != 0)
goto fb_unmap; goto fb_unmap;
@ -325,14 +325,14 @@ viogpu_repaint(void *arg)
} }
int int
viogpu_vq_wait(struct virtqueue *vq) viogpu_vq_done(struct virtqueue *vq)
{ {
struct virtio_softc *vsc = vq->vq_owner; struct virtio_softc *vsc = vq->vq_owner;
struct viogpu_softc *sc = (struct viogpu_softc *)vsc->sc_child; struct viogpu_softc *sc = (struct viogpu_softc *)vsc->sc_child;
int slot, len; int slot, len;
while (virtio_dequeue(vsc, vq, &slot, &len) != 0) if (virtio_dequeue(vsc, vq, &slot, &len) != 0)
; return 0;
bus_dmamap_sync(vsc->sc_dmat, sc->sc_dma_map, 0, sc->sc_dma_size, bus_dmamap_sync(vsc->sc_dmat, sc->sc_dma_map, 0, sc->sc_dma_size,
BUS_DMASYNC_POSTREAD); BUS_DMASYNC_POSTREAD);
@ -402,7 +402,8 @@ viogpu_send_cmd(struct viogpu_softc *sc, void *cmd, size_t cmd_size, void *ret,
virtio_enqueue_p(vq, slot, sc->sc_dma_map, cmd_size, ret_size, 0); virtio_enqueue_p(vq, slot, sc->sc_dma_map, cmd_size, ret_size, 0);
virtio_enqueue_commit(vsc, vq, slot, 1); virtio_enqueue_commit(vsc, vq, slot, 1);
viogpu_vq_wait(vq); while (virtio_check_vq(vsc, vq) == 0)
;
bus_dmamap_sync(vsc->sc_dmat, sc->sc_dma_map, 0, cmd_size, bus_dmamap_sync(vsc->sc_dmat, sc->sc_dma_map, 0, cmd_size,
BUS_DMASYNC_POSTWRITE); BUS_DMASYNC_POSTWRITE);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: virtio.c,v 1.28 2024/07/26 07:55:23 sf Exp $ */ /* $OpenBSD: virtio.c,v 1.29 2024/08/01 11:13:19 sf Exp $ */
/* $NetBSD: virtio.c,v 1.3 2011/11/02 23:05:52 njoly Exp $ */ /* $NetBSD: virtio.c,v 1.3 2011/11/02 23:05:52 njoly Exp $ */
/* /*
@ -185,6 +185,9 @@ virtio_reinit_end(struct virtio_softc *sc)
/* /*
* dmamap sync operations for a virtqueue. * dmamap sync operations for a virtqueue.
*
* XXX These should be more fine grained. Syncing the whole ring if we
* XXX only need a few bytes is inefficient if we use bounce buffers.
*/ */
static inline void static inline void
vq_sync_descs(struct virtio_softc *sc, struct virtqueue *vq, int ops) vq_sync_descs(struct virtio_softc *sc, struct virtqueue *vq, int ops)
@ -202,6 +205,15 @@ vq_sync_aring(struct virtio_softc *sc, struct virtqueue *vq, int ops)
ops); ops);
} }
static inline void
vq_sync_aring_used_event(struct virtio_softc *sc, struct virtqueue *vq, int ops)
{
bus_dmamap_sync(sc->sc_dmat, vq->vq_dmamap, vq->vq_availoffset +
offsetof(struct vring_avail, ring) + vq->vq_num * sizeof(uint16_t),
sizeof(uint16_t), ops);
}
static inline void static inline void
vq_sync_uring(struct virtio_softc *sc, struct virtqueue *vq, int ops) vq_sync_uring(struct virtio_softc *sc, struct virtqueue *vq, int ops)
{ {
@ -210,6 +222,16 @@ vq_sync_uring(struct virtio_softc *sc, struct virtqueue *vq, int ops)
sizeof(struct vring_used_elem), ops); sizeof(struct vring_used_elem), ops);
} }
static inline void
vq_sync_uring_avail_event(struct virtio_softc *sc, struct virtqueue *vq, int ops)
{
bus_dmamap_sync(sc->sc_dmat, vq->vq_dmamap,
vq->vq_usedoffset + offsetof(struct vring_used, ring) +
vq->vq_num * sizeof(struct vring_used_elem), sizeof(uint16_t),
ops);
}
static inline void static inline void
vq_sync_indirect(struct virtio_softc *sc, struct virtqueue *vq, int slot, vq_sync_indirect(struct virtio_softc *sc, struct virtqueue *vq, int slot,
int ops) int ops)
@ -672,11 +694,13 @@ virtio_enqueue_p(struct virtqueue *vq, int slot, bus_dmamap_t dmamap,
static void static void
publish_avail_idx(struct virtio_softc *sc, struct virtqueue *vq) publish_avail_idx(struct virtio_softc *sc, struct virtqueue *vq)
{ {
/* first make sure the avail ring entries are visible to the device */
vq_sync_aring(sc, vq, BUS_DMASYNC_PREWRITE); vq_sync_aring(sc, vq, BUS_DMASYNC_PREWRITE);
virtio_membar_producer(); virtio_membar_producer();
vq->vq_avail->idx = vq->vq_avail_idx; vq->vq_avail->idx = vq->vq_avail_idx;
vq_sync_aring(sc, vq, BUS_DMASYNC_POSTWRITE); /* make the avail idx visible to the device */
vq_sync_aring(sc, vq, BUS_DMASYNC_PREWRITE);
vq->vq_queued = 1; vq->vq_queued = 1;
} }
@ -706,6 +730,7 @@ notify:
publish_avail_idx(sc, vq); publish_avail_idx(sc, vq);
virtio_membar_sync(); virtio_membar_sync();
vq_sync_uring_avail_event(sc, vq, BUS_DMASYNC_POSTREAD);
t = VQ_AVAIL_EVENT(vq) + 1; t = VQ_AVAIL_EVENT(vq) + 1;
if ((uint16_t)(n - t) < (uint16_t)(n - o)) if ((uint16_t)(n - t) < (uint16_t)(n - o))
sc->sc_ops->kick(sc, vq->vq_index); sc->sc_ops->kick(sc, vq->vq_index);
@ -713,6 +738,7 @@ notify:
publish_avail_idx(sc, vq); publish_avail_idx(sc, vq);
virtio_membar_sync(); virtio_membar_sync();
vq_sync_uring(sc, vq, BUS_DMASYNC_POSTREAD);
if (!(vq->vq_used->flags & VRING_USED_F_NO_NOTIFY)) if (!(vq->vq_used->flags & VRING_USED_F_NO_NOTIFY))
sc->sc_ops->kick(sc, vq->vq_index); sc->sc_ops->kick(sc, vq->vq_index);
} }
@ -781,8 +807,10 @@ virtio_enqueue_trim(struct virtqueue *vq, int slot, int nsegs)
* Dequeue a request. * Dequeue a request.
*/ */
/* /*
* dequeue: dequeue a request from uring; dmamap_sync for uring is * dequeue: dequeue a request from uring; bus_dmamap_sync for uring must
* already done in the interrupt handler. * already have been done, usually by virtio_check_vq()
* in the interrupt handler. This means that polling virtio_dequeue()
* repeatedly until it returns 0 does not work.
*/ */
int int
virtio_dequeue(struct virtio_softc *sc, struct virtqueue *vq, virtio_dequeue(struct virtio_softc *sc, struct virtqueue *vq,
@ -797,6 +825,7 @@ virtio_dequeue(struct virtio_softc *sc, struct virtqueue *vq,
usedidx &= vq->vq_mask; usedidx &= vq->vq_mask;
virtio_membar_consumer(); virtio_membar_consumer();
vq_sync_uring(sc, vq, BUS_DMASYNC_POSTREAD);
slot = vq->vq_used->ring[usedidx].id; slot = vq->vq_used->ring[usedidx].id;
qe = &vq->vq_entries[slot]; qe = &vq->vq_entries[slot];
@ -852,7 +881,7 @@ virtio_postpone_intr(struct virtqueue *vq, uint16_t nslots)
VQ_USED_EVENT(vq) = idx; VQ_USED_EVENT(vq) = idx;
virtio_membar_sync(); virtio_membar_sync();
vq_sync_aring(vq->vq_owner, vq, BUS_DMASYNC_PREWRITE); vq_sync_aring_used_event(vq->vq_owner, vq, BUS_DMASYNC_PREWRITE);
vq->vq_queued++; vq->vq_queued++;
if (nslots < virtio_nused(vq)) if (nslots < virtio_nused(vq))
@ -905,6 +934,7 @@ virtio_stop_vq_intr(struct virtio_softc *sc, struct virtqueue *vq)
* interrupt. * interrupt.
*/ */
VQ_USED_EVENT(vq) = vq->vq_used_idx + 0x8000; VQ_USED_EVENT(vq) = vq->vq_used_idx + 0x8000;
vq_sync_aring_used_event(sc, vq, BUS_DMASYNC_PREWRITE);
} else { } else {
vq->vq_avail->flags |= VRING_AVAIL_F_NO_INTERRUPT; vq->vq_avail->flags |= VRING_AVAIL_F_NO_INTERRUPT;
} }
@ -920,16 +950,19 @@ virtio_start_vq_intr(struct virtio_softc *sc, struct virtqueue *vq)
* interrupts is done through setting the latest * interrupts is done through setting the latest
* consumed index in the used_event field * consumed index in the used_event field
*/ */
if (virtio_has_feature(sc, VIRTIO_F_RING_EVENT_IDX)) if (virtio_has_feature(sc, VIRTIO_F_RING_EVENT_IDX)) {
VQ_USED_EVENT(vq) = vq->vq_used_idx; VQ_USED_EVENT(vq) = vq->vq_used_idx;
else vq_sync_aring_used_event(sc, vq, BUS_DMASYNC_PREWRITE);
} else {
vq->vq_avail->flags &= ~VRING_AVAIL_F_NO_INTERRUPT; vq->vq_avail->flags &= ~VRING_AVAIL_F_NO_INTERRUPT;
vq_sync_aring(sc, vq, BUS_DMASYNC_PREWRITE);
}
virtio_membar_sync(); virtio_membar_sync();
vq_sync_aring(sc, vq, BUS_DMASYNC_PREWRITE);
vq->vq_queued++; vq->vq_queued++;
vq_sync_uring(sc, vq, BUS_DMASYNC_POSTREAD);
if (vq->vq_used_idx != vq->vq_used->idx) if (vq->vq_used_idx != vq->vq_used->idx)
return 1; return 1;
@ -945,6 +978,7 @@ virtio_nused(struct virtqueue *vq)
{ {
uint16_t n; uint16_t n;
vq_sync_uring(vq->vq_owner, vq, BUS_DMASYNC_POSTREAD);
n = (uint16_t)(vq->vq_used->idx - vq->vq_used_idx); n = (uint16_t)(vq->vq_used->idx - vq->vq_used_idx);
VIRTIO_ASSERT(n <= vq->vq_num); VIRTIO_ASSERT(n <= vq->vq_num);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: uipc_socket.c,v 1.340 2024/07/29 10:35:22 mvs Exp $ */ /* $OpenBSD: uipc_socket.c,v 1.341 2024/08/01 17:19:01 bluhm Exp $ */
/* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */ /* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */
/* /*
@ -361,7 +361,8 @@ sofree(struct socket *so, int keep_lock)
#ifdef SOCKET_SPLICE #ifdef SOCKET_SPLICE
if (so->so_sp) { if (so->so_sp) {
/* Reuse splice idle, sounsplice() has been called before. */ /* Reuse splice idle, sounsplice() has been called before. */
timeout_set_proc(&so->so_sp->ssp_idleto, soreaper, so); timeout_set_flags(&so->so_sp->ssp_idleto, soreaper, so,
KCLOCK_NONE, TIMEOUT_PROC | TIMEOUT_MPSAFE);
timeout_add(&so->so_sp->ssp_idleto, 0); timeout_add(&so->so_sp->ssp_idleto, 0);
} else } else
#endif /* SOCKET_SPLICE */ #endif /* SOCKET_SPLICE */
@ -1487,7 +1488,8 @@ sosplice(struct socket *so, int fd, off_t max, struct timeval *tv)
so->so_idletv = *tv; so->so_idletv = *tv;
else else
timerclear(&so->so_idletv); timerclear(&so->so_idletv);
timeout_set_proc(&so->so_idleto, soidle, so); timeout_set_flags(&so->so_idleto, soidle, so,
KCLOCK_NONE, TIMEOUT_PROC | TIMEOUT_MPSAFE);
task_set(&so->so_splicetask, sotask, so); task_set(&so->so_splicetask, sotask, so);
/* /*

View file

@ -715,6 +715,14 @@ int ZEXPORT deflatePending(z_streamp strm, unsigned *pending, int *bits) {
return Z_OK; return Z_OK;
} }
/* ========================================================================= */
int ZEXPORT deflateUsed(z_streamp strm, int *bits) {
if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
if (bits != Z_NULL)
*bits = strm->state->bi_used;
return Z_OK;
}
/* ========================================================================= */ /* ========================================================================= */
int ZEXPORT deflatePrime(z_streamp strm, int bits, int value) { int ZEXPORT deflatePrime(z_streamp strm, int bits, int value) {
deflate_state *s; deflate_state *s;
@ -1744,8 +1752,10 @@ local block_state deflate_stored(deflate_state *s, int flush) {
s->high_water = s->strstart; s->high_water = s->strstart;
/* If the last block was written to next_out, then done. */ /* If the last block was written to next_out, then done. */
if (last) if (last) {
s->bi_used = 8;
return finish_done; return finish_done;
}
/* If flushing and all input has been consumed, then done. */ /* If flushing and all input has been consumed, then done. */
if (flush != Z_NO_FLUSH && flush != Z_FINISH && if (flush != Z_NO_FLUSH && flush != Z_FINISH &&
@ -1797,6 +1807,8 @@ local block_state deflate_stored(deflate_state *s, int flush) {
} }
/* We've done all we can with the available input and output. */ /* We've done all we can with the available input and output. */
if (last)
s->bi_used = 8;
return last ? finish_started : need_more; return last ? finish_started : need_more;
} }

View file

@ -269,6 +269,9 @@ typedef struct internal_state {
/* Number of valid bits in bi_buf. All bits above the last valid bit /* Number of valid bits in bi_buf. All bits above the last valid bit
* are always zero. * are always zero.
*/ */
int bi_used;
/* Last number of used bits when going to a byte boundary.
*/
ulg high_water; ulg high_water;
/* High water mark offset in window for initialized bytes -- bytes above /* High water mark offset in window for initialized bytes -- bytes above

View file

@ -182,6 +182,7 @@ local void bi_windup(deflate_state *s) {
} else if (s->bi_valid > 0) { } else if (s->bi_valid > 0) {
put_byte(s, (Byte)s->bi_buf); put_byte(s, (Byte)s->bi_buf);
} }
s->bi_used = ((s->bi_valid - 1) & 7) + 1;
s->bi_buf = 0; s->bi_buf = 0;
s->bi_valid = 0; s->bi_valid = 0;
#ifdef ZLIB_DEBUG #ifdef ZLIB_DEBUG
@ -464,6 +465,7 @@ void ZLIB_INTERNAL _tr_init(deflate_state *s) {
s->bi_buf = 0; s->bi_buf = 0;
s->bi_valid = 0; s->bi_valid = 0;
s->bi_used = 0;
#ifdef ZLIB_DEBUG #ifdef ZLIB_DEBUG
s->compressed_len = 0L; s->compressed_len = 0L;
s->bits_sent = 0L; s->bits_sent = 0L;

View file

@ -57,6 +57,7 @@
# define deflateSetDictionary z_deflateSetDictionary # define deflateSetDictionary z_deflateSetDictionary
# define deflateSetHeader z_deflateSetHeader # define deflateSetHeader z_deflateSetHeader
# define deflateTune z_deflateTune # define deflateTune z_deflateTune
# define deflateUsed z_deflateUsed
# define deflate_copyright z_deflate_copyright # define deflate_copyright z_deflate_copyright
# define get_crc_table z_get_crc_table # define get_crc_table z_get_crc_table
# ifndef Z_SOLO # ifndef Z_SOLO

View file

@ -791,6 +791,18 @@ ZEXTERN int ZEXPORT deflatePending(z_streamp strm,
stream state was inconsistent. stream state was inconsistent.
*/ */
ZEXTERN int ZEXPORT deflateUsed(z_streamp strm,
int *bits);
/*
deflateUsed() returns in *bits the most recent number of deflate bits used
in the last byte when flushing to a byte boundary. The result is in 1..8, or
0 if there has not yet been a flush. This helps determine the location of
the last bit of a deflate stream.
deflateUsed returns Z_OK if success, or Z_STREAM_ERROR if the source
stream state was inconsistent.
*/
ZEXTERN int ZEXPORT deflatePrime(z_streamp strm, ZEXTERN int ZEXPORT deflatePrime(z_streamp strm,
int bits, int bits,
int value); int value);

View file

@ -41,7 +41,7 @@ typedef long ptrdiff_t;
#endif #endif
#ifdef Z_SOLO #ifdef Z_SOLO
typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */ typedef long ptrdiff_t;
#endif #endif
#ifndef local #ifndef local

View file

@ -1,4 +1,4 @@
/* $OpenBSD: sock.c,v 1.49 2024/05/24 15:16:09 ratchov Exp $ */ /* $OpenBSD: sock.c,v 1.50 2024/08/01 14:36:27 ratchov Exp $ */
/* /*
* Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org> * Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org>
* *
@ -986,7 +986,7 @@ sock_execmsg(struct sock *f)
struct slot *s = f->slot; struct slot *s = f->slot;
struct amsg *m = &f->rmsg; struct amsg *m = &f->rmsg;
unsigned char *data; unsigned char *data;
int size, ctl; unsigned int size, ctl;
int cmd; int cmd;
cmd = ntohl(m->cmd); cmd = ntohl(m->cmd);
@ -1020,7 +1020,7 @@ sock_execmsg(struct sock *f)
return 0; return 0;
} }
size = ntohl(m->u.data.size); size = ntohl(m->u.data.size);
if (size <= 0) { if (size == 0) {
#ifdef DEBUG #ifdef DEBUG
if (log_level >= 1) { if (log_level >= 1) {
sock_log(f); sock_log(f);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: npppd.c,v 1.54 2024/07/11 14:05:59 yasuoka Exp $ */ /* $OpenBSD: npppd.c,v 1.55 2024/08/01 00:05:16 yasuoka Exp $ */
/*- /*-
* Copyright (c) 2005-2008,2009 Internet Initiative Japan Inc. * Copyright (c) 2005-2008,2009 Internet Initiative Japan Inc.
@ -29,7 +29,7 @@
* Next pppd(nppd). This file provides a npppd daemon process and operations * Next pppd(nppd). This file provides a npppd daemon process and operations
* for npppd instance. * for npppd instance.
* @author Yasuoka Masahiko * @author Yasuoka Masahiko
* $Id: npppd.c,v 1.54 2024/07/11 14:05:59 yasuoka Exp $ * $Id: npppd.c,v 1.55 2024/08/01 00:05:16 yasuoka Exp $
*/ */
#include "version.h" #include "version.h"
#include <sys/param.h> /* ALIGNED_POINTER */ #include <sys/param.h> /* ALIGNED_POINTER */
@ -608,7 +608,7 @@ npppd_reset_routing_table(npppd *_this, int pool_only)
if (is_first) if (is_first)
in_route_add(&snp->snp_addr, in_route_add(&snp->snp_addr,
&snp->snp_mask, &loop, &snp->snp_mask, &loop,
LOOPBACK_IFNAME, RTF_BLACKHOLE, 0); LOOPBACK_IFNAME, RTF_REJECT, 0);
break; break;
case SNP_PPP: case SNP_PPP:

View file

@ -1,4 +1,4 @@
/* $OpenBSD: radiusd_ipcp.c,v 1.7 2024/07/22 10:00:16 yasuoka Exp $ */ /* $OpenBSD: radiusd_ipcp.c,v 1.8 2024/08/01 00:58:14 yasuoka Exp $ */
/* /*
* Copyright (c) 2024 Internet Initiative Japan Inc. * Copyright (c) 2024 Internet Initiative Japan Inc.
@ -794,7 +794,7 @@ ipcp_resdeco(void *ctx, u_int q_id, const u_char *req, size_t reqlen,
if (!found) if (!found)
goto reject; goto reject;
} else { } else {
n = arc4random() % self->npools; n = arc4random_uniform(self->npools);
i = 0; i = 0;
TAILQ_FOREACH(addr, &self->addrs, next) { TAILQ_FOREACH(addr, &self->addrs, next) {
if (addr->type == ADDRESS_TYPE_POOL) { if (addr->type == ADDRESS_TYPE_POOL) {