sync with OpenBSD -current

This commit is contained in:
purplerain 2025-01-10 03:18:05 +00:00
parent df306e9b72
commit 6dadaa4a5d
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
44 changed files with 503 additions and 207 deletions

View file

@ -1,4 +1,4 @@
vers(a, {-$OpenBSD: MAKEDEV.common,v 1.121 2024/09/03 09:35:46 bluhm Exp $-})dnl vers(a, {-$OpenBSD: MAKEDEV.common,v 1.122 2025/01/08 23:09:25 kirill Exp $-})dnl
dnl dnl
dnl Copyright (c) 2001-2006 Todd T. Fries <todd@OpenBSD.org> dnl Copyright (c) 2001-2006 Todd T. Fries <todd@OpenBSD.org>
dnl dnl
@ -144,7 +144,7 @@ twrget(all, lpt, lpa, 0, 1, 2)dnl
target(all, joy, 0, 1)dnl target(all, joy, 0, 1)dnl
twrget(all, rnd, random)dnl twrget(all, rnd, random)dnl
target(all, uk, 0)dnl target(all, uk, 0)dnl
twrget(all, vi, video, 0, 1)dnl twrget(all, vi, video, 0, 1, 2, 3)dnl
twrget(all, speak, speaker)dnl twrget(all, speak, speaker)dnl
target(all, asc, 0)dnl target(all, asc, 0)dnl
target(all, radio, 0)dnl target(all, radio, 0)dnl

View file

@ -4,7 +4,7 @@
# generated from: # generated from:
# #
# OpenBSD: etc.amd64/MAKEDEV.md,v 1.83 2024/09/03 09:35:46 bluhm Exp # OpenBSD: etc.amd64/MAKEDEV.md,v 1.83 2024/09/03 09:35:46 bluhm Exp
# OpenBSD: MAKEDEV.common,v 1.121 2024/09/03 09:35:46 bluhm Exp # OpenBSD: MAKEDEV.common,v 1.122 2025/01/08 23:09:25 kirill Exp
# OpenBSD: MAKEDEV.mi,v 1.83 2016/09/11 03:06:31 deraadt Exp # OpenBSD: MAKEDEV.mi,v 1.83 2016/09/11 03:06:31 deraadt Exp
# OpenBSD: MAKEDEV.sub,v 1.14 2005/02/07 06:14:18 david Exp # OpenBSD: MAKEDEV.sub,v 1.14 2005/02/07 06:14:18 david Exp
# #
@ -612,11 +612,11 @@ all)
R ch0 audio0 audio1 audio2 audio3 psp kstat dt kcov bpf pvbus0 R ch0 audio0 audio1 audio2 audio3 psp kstat dt kcov bpf pvbus0
R pvbus1 vmm fuse pppac pppx hotplug ptm local wscons pci0 R pvbus1 vmm fuse pppac pppx hotplug ptm local wscons pci0
R pci1 pci2 pci3 uall rmidi0 rmidi1 rmidi2 rmidi3 rmidi4 R pci1 pci2 pci3 uall rmidi0 rmidi1 rmidi2 rmidi3 rmidi4
R rmidi5 rmidi6 rmidi7 tuner0 radio0 speaker video0 video1 uk0 R rmidi5 rmidi6 rmidi7 tuner0 radio0 speaker video0 video1
R random lpa0 lpa1 lpa2 lpt0 lpt1 lpt2 tty00 tty01 tty02 tty03 R video2 video3 uk0 random lpa0 lpa1 lpa2 lpt0 lpt1 lpt2 tty00
R tty04 tty05 tty06 tty07 tty08 tty09 tty0a tty0b ttyc0 ttyc1 R tty01 tty02 tty03 tty04 tty05 tty06 tty07 tty08 tty09 tty0a
R ttyc2 ttyc3 ttyc4 ttyc5 ttyc6 ttyc7 apm pf pctr wd0 wd1 wd2 R tty0b ttyc0 ttyc1 ttyc2 ttyc3 ttyc4 ttyc5 ttyc6 ttyc7 apm pf
R wd3 std st0 st1 fd R pctr wd0 wd1 wd2 wd3 std st0 st1 fd
;; ;;
wd*|sd*) wd*|sd*)

View file

@ -4,7 +4,7 @@
# generated from: # generated from:
# #
# OpenBSD: etc.arm64/MAKEDEV.md,v 1.16 2023/01/14 12:15:12 kettenis Exp # OpenBSD: etc.arm64/MAKEDEV.md,v 1.16 2023/01/14 12:15:12 kettenis Exp
# OpenBSD: MAKEDEV.common,v 1.120 2023/01/28 11:04:47 phessler Exp # OpenBSD: MAKEDEV.common,v 1.122 2025/01/08 23:09:25 kirill Exp
# OpenBSD: MAKEDEV.mi,v 1.83 2016/09/11 03:06:31 deraadt Exp # OpenBSD: MAKEDEV.mi,v 1.83 2016/09/11 03:06:31 deraadt Exp
# OpenBSD: MAKEDEV.sub,v 1.14 2005/02/07 06:14:18 david Exp # OpenBSD: MAKEDEV.sub,v 1.14 2005/02/07 06:14:18 david Exp
# #
@ -514,9 +514,9 @@ all)
R ch0 audio0 audio1 audio2 audio3 kstat dt bpf fuse pppac pppx R ch0 audio0 audio1 audio2 audio3 kstat dt bpf fuse pppac pppx
R hotplug ptm local wscons pci0 pci1 pci2 pci3 uall rmidi0 R hotplug ptm local wscons pci0 pci1 pci2 pci3 uall rmidi0
R rmidi1 rmidi2 rmidi3 rmidi4 rmidi5 rmidi6 rmidi7 tuner0 R rmidi1 rmidi2 rmidi3 rmidi4 rmidi5 rmidi6 rmidi7 tuner0
R radio0 video0 video1 uk0 random tty00 tty01 tty02 tty03 R radio0 video0 video1 video2 video3 uk0 random tty00 tty01
R tty04 tty05 tty06 tty07 tty08 tty09 tty0a tty0b apm pf wd0 R tty02 tty03 tty04 tty05 tty06 tty07 tty08 tty09 tty0a tty0b
R wd1 wd2 wd3 std fd R apm pf wd0 wd1 wd2 wd3 std fd
;; ;;
wd*|sd*) wd*|sd*)

View file

@ -4,7 +4,7 @@
# generated from: # generated from:
# #
# OpenBSD: etc.armv7/MAKEDEV.md,v 1.22 2022/11/09 19:35:23 krw Exp # OpenBSD: etc.armv7/MAKEDEV.md,v 1.22 2022/11/09 19:35:23 krw Exp
# OpenBSD: MAKEDEV.common,v 1.120 2023/01/28 11:04:47 phessler Exp # OpenBSD: MAKEDEV.common,v 1.122 2025/01/08 23:09:25 kirill Exp
# OpenBSD: MAKEDEV.mi,v 1.83 2016/09/11 03:06:31 deraadt Exp # OpenBSD: MAKEDEV.mi,v 1.83 2016/09/11 03:06:31 deraadt Exp
# OpenBSD: MAKEDEV.sub,v 1.14 2005/02/07 06:14:18 david Exp # OpenBSD: MAKEDEV.sub,v 1.14 2005/02/07 06:14:18 david Exp
# #
@ -497,9 +497,9 @@ all)
R diskmap vscsi0 ch0 audio0 audio1 audio2 kstat dt bpf fuse R diskmap vscsi0 ch0 audio0 audio1 audio2 kstat dt bpf fuse
R pppac pppx hotplug ptm local wscons pci0 pci1 pci2 pci3 uall R pppac pppx hotplug ptm local wscons pci0 pci1 pci2 pci3 uall
R rmidi0 rmidi1 rmidi2 rmidi3 rmidi4 rmidi5 rmidi6 rmidi7 R rmidi0 rmidi1 rmidi2 rmidi3 rmidi4 rmidi5 rmidi6 rmidi7
R tuner0 radio0 video0 video1 uk0 random tty00 tty01 tty02 R tuner0 radio0 video0 video1 video2 video3 uk0 random tty00
R tty03 tty04 tty05 tty06 tty07 tty08 tty09 tty0a tty0b apm pf R tty01 tty02 tty03 tty04 tty05 tty06 tty07 tty08 tty09 tty0a
R wd0 wd1 wd2 wd3 std st0 st1 fd R tty0b apm pf wd0 wd1 wd2 wd3 std st0 st1 fd
;; ;;
wd*|sd*) wd*|sd*)

View file

@ -4,7 +4,7 @@
# generated from: # generated from:
# #
# OpenBSD: etc.i386/MAKEDEV.md,v 1.96 2022/11/09 19:35:23 krw Exp # OpenBSD: etc.i386/MAKEDEV.md,v 1.96 2022/11/09 19:35:23 krw Exp
# OpenBSD: MAKEDEV.common,v 1.120 2023/01/28 11:04:47 phessler Exp # OpenBSD: MAKEDEV.common,v 1.122 2025/01/08 23:09:25 kirill Exp
# OpenBSD: MAKEDEV.mi,v 1.83 2016/09/11 03:06:31 deraadt Exp # OpenBSD: MAKEDEV.mi,v 1.83 2016/09/11 03:06:31 deraadt Exp
# OpenBSD: MAKEDEV.sub,v 1.14 2005/02/07 06:14:18 david Exp # OpenBSD: MAKEDEV.sub,v 1.14 2005/02/07 06:14:18 david Exp
# #
@ -602,11 +602,11 @@ all)
R audio3 kstat dt kcov bpf pvbus0 pvbus1 fuse pppac pppx R audio3 kstat dt kcov bpf pvbus0 pvbus1 fuse pppac pppx
R hotplug ptm local wscons pci0 pci1 pci2 pci3 uall rmidi0 R hotplug ptm local wscons pci0 pci1 pci2 pci3 uall rmidi0
R rmidi1 rmidi2 rmidi3 rmidi4 rmidi5 rmidi6 rmidi7 tuner0 R rmidi1 rmidi2 rmidi3 rmidi4 rmidi5 rmidi6 rmidi7 tuner0
R radio0 speaker video0 video1 uk0 random joy0 joy1 lpa0 lpa1 R radio0 speaker video0 video1 video2 video3 uk0 random joy0
R lpa2 lpt0 lpt1 lpt2 tty00 tty01 tty02 tty03 tty04 tty05 R joy1 lpa0 lpa1 lpa2 lpt0 lpt1 lpt2 tty00 tty01 tty02 tty03
R tty06 tty07 tty08 tty09 tty0a tty0b ttyc0 ttyc1 ttyc2 ttyc3 R tty04 tty05 tty06 tty07 tty08 tty09 tty0a tty0b ttyc0 ttyc1
R ttyc4 ttyc5 ttyc6 ttyc7 apm pf pctr wd0 wd1 wd2 wd3 std st0 R ttyc2 ttyc3 ttyc4 ttyc5 ttyc6 ttyc7 apm pf pctr wd0 wd1 wd2
R st1 fd R wd3 std st0 st1 fd
;; ;;
wd*|sd*) wd*|sd*)

View file

@ -1,4 +1,4 @@
.\" $OpenBSD: crypt.3,v 1.45 2015/04/06 20:49:41 tedu Exp $ .\" $OpenBSD: crypt.3,v 1.46 2025/01/09 23:18:08 jsg Exp $
.\" .\"
.\" FreeSec: libcrypt .\" FreeSec: libcrypt
.\" .\"
@ -31,7 +31,7 @@
.\" .\"
.\" Manual page, using -mandoc macros .\" Manual page, using -mandoc macros
.\" .\"
.Dd $Mdocdate: April 6 2015 $ .Dd $Mdocdate: January 9 2025 $
.Dt CRYPT 3 .Dt CRYPT 3
.Os .Os
.Sh NAME .Sh NAME
@ -125,7 +125,7 @@ on failure.
.Xr getpass 3 , .Xr getpass 3 ,
.Xr passwd 5 .Xr passwd 5
.Sh HISTORY .Sh HISTORY
A rotor-based An M-209 based
.Fn crypt .Fn crypt
function appeared in function appeared in
.At v3 . .At v3 .

View file

@ -1,4 +1,4 @@
/* $OpenBSD: bn_recp.c,v 1.21 2025/01/06 13:47:37 tb Exp $ */ /* $OpenBSD: bn_recp.c,v 1.25 2025/01/08 20:21:28 tb Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved. * All rights reserved.
* *
@ -65,8 +65,8 @@
void void
BN_RECP_CTX_init(BN_RECP_CTX *recp) BN_RECP_CTX_init(BN_RECP_CTX *recp)
{ {
BN_init(&(recp->N)); BN_init(&recp->N);
BN_init(&(recp->Nr)); BN_init(&recp->Nr);
recp->num_bits = 0; recp->num_bits = 0;
recp->flags = 0; recp->flags = 0;
} }
@ -77,11 +77,11 @@ BN_RECP_CTX_new(void)
BN_RECP_CTX *ret; BN_RECP_CTX *ret;
if ((ret = malloc(sizeof(BN_RECP_CTX))) == NULL) if ((ret = malloc(sizeof(BN_RECP_CTX))) == NULL)
return (NULL); return NULL;
BN_RECP_CTX_init(ret); BN_RECP_CTX_init(ret);
ret->flags = BN_FLG_MALLOCED; ret->flags = BN_FLG_MALLOCED;
return (ret); return ret;
} }
void void
@ -90,8 +90,8 @@ BN_RECP_CTX_free(BN_RECP_CTX *recp)
if (recp == NULL) if (recp == NULL)
return; return;
BN_free(&(recp->N)); BN_free(&recp->N);
BN_free(&(recp->Nr)); BN_free(&recp->Nr);
if (recp->flags & BN_FLG_MALLOCED) if (recp->flags & BN_FLG_MALLOCED)
free(recp); free(recp);
} }
@ -99,12 +99,14 @@ BN_RECP_CTX_free(BN_RECP_CTX *recp)
int int
BN_RECP_CTX_set(BN_RECP_CTX *recp, const BIGNUM *d, BN_CTX *ctx) BN_RECP_CTX_set(BN_RECP_CTX *recp, const BIGNUM *d, BN_CTX *ctx)
{ {
if (!bn_copy(&(recp->N), d)) if (!bn_copy(&recp->N, d))
return 0; return 0;
BN_zero(&(recp->Nr)); recp->num_bits = BN_num_bits(&recp->N);
recp->num_bits = BN_num_bits(d);
BN_zero(&recp->Nr);
recp->shift = 0; recp->shift = 0;
return (1);
return 1;
} }
/* len is the expected size of the result /* len is the expected size of the result
@ -132,7 +134,7 @@ BN_reciprocal(BIGNUM *r, const BIGNUM *m, int len, BN_CTX *ctx)
err: err:
BN_CTX_end(ctx); BN_CTX_end(ctx);
return (ret); return ret;
} }
int int
@ -156,14 +158,14 @@ BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, BN_RECP_CTX *recp,
if (a == NULL || b == NULL || d == NULL || r == NULL) if (a == NULL || b == NULL || d == NULL || r == NULL)
goto err; goto err;
if (BN_ucmp(m, &(recp->N)) < 0) { if (BN_ucmp(m, &recp->N) < 0) {
BN_zero(d); BN_zero(d);
if (!bn_copy(r, m)) { if (!bn_copy(r, m)) {
BN_CTX_end(ctx); BN_CTX_end(ctx);
return 0; return 0;
} }
BN_CTX_end(ctx); BN_CTX_end(ctx);
return (1); return 1;
} }
/* We want the remainder /* We want the remainder
@ -180,7 +182,7 @@ BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, BN_RECP_CTX *recp,
/* Nr := round(2^i / N) */ /* Nr := round(2^i / N) */
if (i != recp->shift) if (i != recp->shift)
recp->shift = BN_reciprocal(&(recp->Nr), &(recp->N), i, ctx); recp->shift = BN_reciprocal(&recp->Nr, &recp->N, i, ctx);
/* BN_reciprocal returns i, or -1 for an error */ /* BN_reciprocal returns i, or -1 for an error */
if (recp->shift == -1) if (recp->shift == -1)
@ -193,13 +195,13 @@ BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, BN_RECP_CTX *recp,
*/ */
if (!BN_rshift(a, m, recp->num_bits)) if (!BN_rshift(a, m, recp->num_bits))
goto err; goto err;
if (!BN_mul(b, a,&(recp->Nr), ctx)) if (!BN_mul(b, a, &recp->Nr, ctx))
goto err; goto err;
if (!BN_rshift(d, b, i - recp->num_bits)) if (!BN_rshift(d, b, i - recp->num_bits))
goto err; goto err;
d->neg = 0; d->neg = 0;
if (!BN_mul(b, &(recp->N), d, ctx)) if (!BN_mul(b, &recp->N, d, ctx))
goto err; goto err;
if (!BN_usub(r, m, b)) if (!BN_usub(r, m, b))
goto err; goto err;
@ -207,12 +209,12 @@ BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, BN_RECP_CTX *recp,
#if 1 #if 1
j = 0; j = 0;
while (BN_ucmp(r, &(recp->N)) >= 0) { while (BN_ucmp(r, &recp->N) >= 0) {
if (j++ > 2) { if (j++ > 2) {
BNerror(BN_R_BAD_RECIPROCAL); BNerror(BN_R_BAD_RECIPROCAL);
goto err; goto err;
} }
if (!BN_usub(r, r, &(recp->N))) if (!BN_usub(r, r, &recp->N))
goto err; goto err;
if (!BN_add_word(d, 1)) if (!BN_add_word(d, 1))
goto err; goto err;
@ -226,10 +228,9 @@ BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, BN_RECP_CTX *recp,
err: err:
BN_CTX_end(ctx); BN_CTX_end(ctx);
return (ret); return ret;
} }
int int
BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *x, const BIGNUM *y, BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *x, const BIGNUM *y,
BN_RECP_CTX *recp, BN_CTX *ctx) BN_RECP_CTX *recp, BN_CTX *ctx)
@ -257,5 +258,5 @@ BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *x, const BIGNUM *y,
err: err:
BN_CTX_end(ctx); BN_CTX_end(ctx);
return (ret); return ret;
} }

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ec_lib.c,v 1.103 2025/01/07 08:30:52 tb Exp $ */ /* $OpenBSD: ec_lib.c,v 1.105 2025/01/09 11:35:46 tb Exp $ */
/* /*
* Originally written by Bodo Moeller for the OpenSSL project. * Originally written by Bodo Moeller for the OpenSSL project.
*/ */
@ -623,7 +623,8 @@ EC_GROUP_check_discriminant(const EC_GROUP *group, BN_CTX *ctx_in)
goto err; goto err;
/* /*
* Check that the discriminant 4a^3 + 27b^2 is non-zero modulo p. * Check that the discriminant 4a^3 + 27b^2 is non-zero modulo p
* assuming that p > 3 is prime and that a and b are in [0, p).
*/ */
if (BN_is_zero(a) && BN_is_zero(b)) if (BN_is_zero(a) && BN_is_zero(b))
@ -1425,4 +1426,3 @@ EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group,
return 0; return 0;
} }
LCRYPTO_ALIAS(EC_POINT_get_Jprojective_coordinates_GFp); LCRYPTO_ALIAS(EC_POINT_get_Jprojective_coordinates_GFp);

View file

@ -0,0 +1,26 @@
# test EPROTO for unsplicing non-spliced sockets
use strict;
use warnings;
use IO::Socket::IP;
use BSD::Socket::Splice "SO_SPLICE";
our %args = (
errno => 'EPROTO',
func => sub {
my $sl = IO::Socket::IP->new(
Proto => "tcp",
Listen => 5,
LocalAddr => "127.0.0.1",
) or die "socket listen failed: $!";
my $s = IO::Socket::IP->new(
Proto => "tcp",
PeerAddr => $sl->sockhost(),
PeerPort => $sl->sockport(),
) or die "socket failed: $!";
$s->setsockopt(SOL_SOCKET, SO_SPLICE, pack('i', -1))
and die "unsplice non spliced socket succeeded";
},
);

View file

@ -1,4 +1,4 @@
.\" $OpenBSD: sosplice.9,v 1.10 2019/07/04 17:42:17 bluhm Exp $ .\" $OpenBSD: sosplice.9,v 1.11 2025/01/09 17:42:38 mvs Exp $
.\" .\"
.\" Copyright (c) 2011-2013 Alexander Bluhm <bluhm@openbsd.org> .\" Copyright (c) 2011-2013 Alexander Bluhm <bluhm@openbsd.org>
.\" .\"
@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\" .\"
.Dd $Mdocdate: July 4 2019 $ .Dd $Mdocdate: January 9 2025 $
.Dt SOSPLICE 9 .Dt SOSPLICE 9
.Os .Os
.Sh NAME .Sh NAME
@ -238,6 +238,8 @@ nor in the process of connecting to a peer.
.It Bq Er ENOTCONN .It Bq Er ENOTCONN
The drain socket is neither connected nor in the process of connecting The drain socket is neither connected nor in the process of connecting
to a peer. to a peer.
.It Bq Er EPROTO
The source socket is not spliced with the drain socket.
.It Bq Er ENOTSOCK .It Bq Er ENOTSOCK
The given file descriptor The given file descriptor
.Fa fd .Fa fd

View file

@ -1,4 +1,4 @@
# $OpenBSD: airport,v 1.99 2024/11/07 08:43:18 sthen Exp $ # $OpenBSD: airport,v 1.100 2025/01/08 22:26:22 kn Exp $
# @(#)airport 8.1 (Berkeley) 6/8/93 # @(#)airport 8.1 (Berkeley) 6/8/93
# #
# Some of this information from the Airport Search Engine at # Some of this information from the Airport Search Engine at
@ -1346,6 +1346,7 @@ PKB:Wood County, Parkersburg / Marietta, West Virginia, USA
PKE:Parkes, New South Wales, Australia PKE:Parkes, New South Wales, Australia
PKR:Pokhara, Nepal PKR:Pokhara, Nepal
PKU:Simpang Tiga, Pekanbaru, Indonesia PKU:Simpang Tiga, Pekanbaru, Indonesia
PKV:Pskov, Russia
PLB:Plattsburgh, New York, USA PLB:Plattsburgh, New York, USA
PLH:Plymouth, England, United Kingdom PLH:Plymouth, England, United Kingdom
PLM:Sultan Mahmud Badaruddin Ii, Palembang, Indonesia PLM:Sultan Mahmud Badaruddin Ii, Palembang, Indonesia

View file

@ -1,4 +1,4 @@
/* $OpenBSD: dt_prov_static.c,v 1.23 2024/04/06 11:18:02 mpi Exp $ */ /* $OpenBSD: dt_prov_static.c,v 1.24 2025/01/09 17:43:33 mvs Exp $ */
/* /*
* Copyright (c) 2019 Martin Pieuchot <mpi@openbsd.org> * Copyright (c) 2019 Martin Pieuchot <mpi@openbsd.org>
@ -100,6 +100,7 @@ DT_STATIC_PROBE3(refcnt, ifaddr, "void *", "int", "int");
DT_STATIC_PROBE3(refcnt, ifmaddr, "void *", "int", "int"); DT_STATIC_PROBE3(refcnt, ifmaddr, "void *", "int", "int");
DT_STATIC_PROBE3(refcnt, inpcb, "void *", "int", "int"); DT_STATIC_PROBE3(refcnt, inpcb, "void *", "int", "int");
DT_STATIC_PROBE3(refcnt, rtentry, "void *", "int", "int"); DT_STATIC_PROBE3(refcnt, rtentry, "void *", "int", "int");
DT_STATIC_PROBE3(refcnt, socket, "void *", "int", "int");
DT_STATIC_PROBE3(refcnt, syncache, "void *", "int", "int"); DT_STATIC_PROBE3(refcnt, syncache, "void *", "int", "int");
DT_STATIC_PROBE3(refcnt, tdb, "void *", "int", "int"); DT_STATIC_PROBE3(refcnt, tdb, "void *", "int", "int");
@ -153,6 +154,7 @@ struct dt_probe *const dtps_static[] = {
&_DT_STATIC_P(refcnt, ifmaddr), &_DT_STATIC_P(refcnt, ifmaddr),
&_DT_STATIC_P(refcnt, inpcb), &_DT_STATIC_P(refcnt, inpcb),
&_DT_STATIC_P(refcnt, rtentry), &_DT_STATIC_P(refcnt, rtentry),
&_DT_STATIC_P(refcnt, socket),
&_DT_STATIC_P(refcnt, syncache), &_DT_STATIC_P(refcnt, syncache),
&_DT_STATIC_P(refcnt, tdb), &_DT_STATIC_P(refcnt, tdb),
}; };

View file

@ -1,4 +1,4 @@
/* $OpenBSD: gpiokeys.c,v 1.3 2023/03/31 12:07:54 kn Exp $ */ /* $OpenBSD: gpiokeys.c,v 1.5 2025/01/09 22:03:38 kettenis Exp $ */
/* /*
* Copyright (c) 2021 Klemens Nanni <kn@openbsd.org> * Copyright (c) 2021 Klemens Nanni <kn@openbsd.org>
* *
@ -54,12 +54,13 @@ struct gpiokeys_key {
uint32_t key_input_type; uint32_t key_input_type;
uint32_t key_code; uint32_t key_code;
struct ksensor key_sensor; struct ksensor key_sensor;
SLIST_ENTRY(gpiokeys_key) entries; SLIST_ENTRY(gpiokeys_key) key_next;
void (*key_func)(void *);
void *key_ih;
}; };
struct gpiokeys_softc { struct gpiokeys_softc {
struct device sc_dev; struct device sc_dev;
int sc_node;
struct ksensordev sc_sensordev; struct ksensordev sc_sensordev;
SLIST_HEAD(, gpiokeys_key) sc_keys; SLIST_HEAD(, gpiokeys_key) sc_keys;
}; };
@ -76,6 +77,7 @@ struct cfdriver gpiokeys_cd = {
}; };
void gpiokeys_update_key(void *); void gpiokeys_update_key(void *);
int gpiokeys_intr(void *);
int int
gpiokeys_match(struct device *parent, void *match, void *aux) gpiokeys_match(struct device *parent, void *match, void *aux)
@ -131,8 +133,9 @@ gpiokeys_attach(struct device *parent, struct device *self, void *aux)
strlcpy(key->key_sensor.desc, "lid open", strlcpy(key->key_sensor.desc, "lid open",
sizeof(key->key_sensor.desc)); sizeof(key->key_sensor.desc));
key->key_sensor.type = SENSOR_INDICATOR; key->key_sensor.type = SENSOR_INDICATOR;
sensor_attach(&sc->sc_sensordev, &key->key_sensor); sensor_attach(&sc->sc_sensordev,
sensor_task_register(key, gpiokeys_update_key, 1); &key->key_sensor);
key->key_func = gpiokeys_update_key;
have_sensors = 1; have_sensors = 1;
break; break;
} }
@ -145,7 +148,21 @@ gpiokeys_attach(struct device *parent, struct device *self, void *aux)
have_labels = 1; have_labels = 1;
} }
SLIST_INSERT_HEAD(&sc->sc_keys, key, entries); SLIST_INSERT_HEAD(&sc->sc_keys, key, key_next);
}
SLIST_FOREACH(key, &sc->sc_keys, key_next) {
if (!key->key_func)
continue;
if (OF_is_compatible(faa->fa_node, "gpio-keys")) {
key->key_ih = gpio_controller_intr_establish(key->key_pin,
IPL_BIO, NULL, gpiokeys_intr, key, DEVNAME(sc));
}
if (key->key_ih == NULL)
sensor_task_register(key, gpiokeys_update_key, 1);
else
gpiokeys_update_key(key);
} }
if (have_sensors) { if (have_sensors) {
@ -181,3 +198,12 @@ gpiokeys_update_key(void *arg)
break; break;
} }
} }
int
gpiokeys_intr(void *arg)
{
struct gpiokeys_key *key = arg;
key->key_func(key);
return 1;
}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: qcgpio_fdt.c,v 1.4 2024/07/02 19:43:52 patrick Exp $ */ /* $OpenBSD: qcgpio_fdt.c,v 1.5 2025/01/09 21:52:25 kettenis Exp $ */
/* /*
* Copyright (c) 2022 Mark Kettenis <kettenis@openbsd.org> * Copyright (c) 2022 Mark Kettenis <kettenis@openbsd.org>
* *
@ -86,6 +86,8 @@ const struct cfattach qcgpio_fdt_ca = {
void qcgpio_fdt_config_pin(void *, uint32_t *, int); void qcgpio_fdt_config_pin(void *, uint32_t *, int);
int qcgpio_fdt_get_pin(void *, uint32_t *); int qcgpio_fdt_get_pin(void *, uint32_t *);
void qcgpio_fdt_set_pin(void *, uint32_t *, int); void qcgpio_fdt_set_pin(void *, uint32_t *, int);
void *qcgpio_fdt_intr_establish_pin(void *, uint32_t *, int,
struct cpu_info *, int (*)(void *), void *, char *);
void *qcgpio_fdt_intr_establish(void *, int *, int, struct cpu_info *, void *qcgpio_fdt_intr_establish(void *, int *, int, struct cpu_info *,
int (*)(void *), void *, char *); int (*)(void *), void *, char *);
@ -136,6 +138,7 @@ qcgpio_fdt_attach(struct device *parent, struct device *self, void *aux)
sc->sc_gc.gc_config_pin = qcgpio_fdt_config_pin; sc->sc_gc.gc_config_pin = qcgpio_fdt_config_pin;
sc->sc_gc.gc_get_pin = qcgpio_fdt_get_pin; sc->sc_gc.gc_get_pin = qcgpio_fdt_get_pin;
sc->sc_gc.gc_set_pin = qcgpio_fdt_set_pin; sc->sc_gc.gc_set_pin = qcgpio_fdt_set_pin;
sc->sc_gc.gc_intr_establish = qcgpio_fdt_intr_establish_pin;
gpio_controller_register(&sc->sc_gc); gpio_controller_register(&sc->sc_gc);
sc->sc_ic.ic_node = faa->fa_node; sc->sc_ic.ic_node = faa->fa_node;
@ -213,6 +216,19 @@ qcgpio_fdt_set_pin(void *cookie, uint32_t *cells, int val)
} }
} }
void *
qcgpio_fdt_intr_establish_pin(void *cookie, uint32_t *cells, int ipl,
struct cpu_info *ci, int (*func)(void *), void *arg, char *name)
{
struct qcgpio_softc *sc = cookie;
uint32_t icells[2];
icells[0] = cells[0];
icells[1] = 3; /* both edges */
return qcgpio_fdt_intr_establish(sc, icells, ipl, ci, func, arg, name);
}
void * void *
qcgpio_fdt_intr_establish(void *cookie, int *cells, int ipl, qcgpio_fdt_intr_establish(void *cookie, int *cells, int ipl,
struct cpu_info *ci, int (*func)(void *), void *arg, char *name) struct cpu_info *ci, int (*func)(void *), void *arg, char *name)

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ofw_gpio.c,v 1.3 2019/08/26 09:22:27 kettenis Exp $ */ /* $OpenBSD: ofw_gpio.c,v 1.4 2025/01/09 19:38:13 kettenis Exp $ */
/* /*
* Copyright (c) 2016, 2019 Mark Kettenis * Copyright (c) 2016, 2019 Mark Kettenis
* *
@ -19,6 +19,8 @@
#include <sys/systm.h> #include <sys/systm.h>
#include <sys/malloc.h> #include <sys/malloc.h>
#include <machine/fdt.h>
#include <dev/ofw/openfirm.h> #include <dev/ofw/openfirm.h>
#include <dev/ofw/ofw_gpio.h> #include <dev/ofw/ofw_gpio.h>
@ -141,3 +143,29 @@ gpio_controller_next_pin(uint32_t *cells)
return NULL; return NULL;
} }
void *
gpio_controller_intr_establish(uint32_t *cells, int ipl, struct cpu_info *ci,
int (*func)(void *), void *arg, char *name)
{
struct gpio_controller *gc;
uint32_t phandle = cells[0];
LIST_FOREACH(gc, &gpio_controllers, gc_list) {
if (gc->gc_phandle == phandle)
break;
}
if (gc && gc->gc_intr_establish) {
return gc->gc_intr_establish(gc->gc_cookie, &cells[1], ipl,
ci, func, arg, name);
}
return NULL;
}
void
gpio_controller_intr_disestablish(void *ih)
{
fdt_intr_disestablish(ih);
}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ofw_gpio.h,v 1.5 2020/12/18 22:14:13 kettenis Exp $ */ /* $OpenBSD: ofw_gpio.h,v 1.6 2025/01/09 19:38:13 kettenis Exp $ */
/* /*
* Copyright (c) 2016 Mark Kettenis * Copyright (c) 2016 Mark Kettenis
* *
@ -34,6 +34,8 @@ struct gpio_controller {
void (*gc_config_pin)(void *, uint32_t *, int); void (*gc_config_pin)(void *, uint32_t *, int);
int (*gc_get_pin)(void *, uint32_t *); int (*gc_get_pin)(void *, uint32_t *);
void (*gc_set_pin)(void *, uint32_t *, int); void (*gc_set_pin)(void *, uint32_t *, int);
void *(*gc_intr_establish)(void *, uint32_t *, int,
struct cpu_info *, int (*)(void *), void *, char *);
LIST_ENTRY(gpio_controller) gc_list; LIST_ENTRY(gpio_controller) gc_list;
uint32_t gc_phandle; uint32_t gc_phandle;
@ -56,4 +58,8 @@ int gpio_controller_get_pin(uint32_t *);
void gpio_controller_set_pin(uint32_t *, int); void gpio_controller_set_pin(uint32_t *, int);
uint32_t *gpio_controller_next_pin(uint32_t *); uint32_t *gpio_controller_next_pin(uint32_t *);
void *gpio_controller_intr_establish(uint32_t *, int, struct cpu_info *,
int (*)(void *), void *, char *);
void gpio_controller_intr_disestablish(void *);
#endif /* _DEV_OFW_GPIO_H_ */ #endif /* _DEV_OFW_GPIO_H_ */

View file

@ -3255,9 +3255,13 @@ static int amdgpu_device_ip_resume_phase3(struct amdgpu_device *adev)
continue; continue;
if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_DCE) { if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_DCE) {
r = adev->ip_blocks[i].version->funcs->resume(adev); r = adev->ip_blocks[i].version->funcs->resume(adev);
if (r) if (r) {
DRM_ERROR("resume of IP block <%s> failed %d\n",
adev->ip_blocks[i].version->funcs->name, r);
return r; return r;
} }
adev->ip_blocks[i].status.hw = true;
}
} }
return 0; return 0;

View file

@ -1,4 +1,4 @@
$OpenBSD: pcidevs,v 1.2094 2024/11/09 10:23:06 miod Exp $ $OpenBSD: pcidevs,v 1.2095 2025/01/08 02:12:24 jsg Exp $
/* $NetBSD: pcidevs,v 1.30 1997/06/24 06:20:24 thorpej Exp $ */ /* $NetBSD: pcidevs,v 1.30 1997/06/24 06:20:24 thorpej Exp $ */
/* /*
@ -6460,9 +6460,13 @@ product INTEL MTL_U_HB_1 0x7d16 Core Ultra Host
product INTEL MTL_IPU 0x7d19 Core Ultra IPU product INTEL MTL_IPU 0x7d19 Core Ultra IPU
product INTEL MTL_NPU 0x7d1d Core Ultra NPU product INTEL MTL_NPU 0x7d1d Core Ultra NPU
product INTEL MTL_U4_GT_1 0x7d40 Graphics product INTEL MTL_U4_GT_1 0x7d40 Graphics
product INTEL ARL_U_GT_1 0x7d41 Graphics
product INTEL MTL_U_GT_1 0x7d45 Graphics product INTEL MTL_U_GT_1 0x7d45 Graphics
product INTEL ARL_H_GT_1 0x7d51 Graphics
product INTEL MTL_H_GT_1 0x7d55 Arc Graphics product INTEL MTL_H_GT_1 0x7d55 Arc Graphics
product INTEL MTL_U_GT_2 0x7d60 Graphics product INTEL MTL_U_GT_2 0x7d60 Graphics
product INTEL ARL_S_GT_1 0x7d67 Graphics
product INTEL ARL_H_GT_2 0x7dd1 Graphics
product INTEL MTL_H_GT_2 0x7dd5 Graphics product INTEL MTL_H_GT_2 0x7dd5 Graphics
product INTEL MTL_H_ESPI 0x7e02 Core Ultra eSPI product INTEL MTL_H_ESPI 0x7e02 Core Ultra eSPI
product INTEL MTL_U_ESPI 0x7e03 Core Ultra eSPI product INTEL MTL_U_ESPI 0x7e03 Core Ultra eSPI
@ -7349,6 +7353,7 @@ product INTEL LNL_XHCI 0xa87d Core Ultra xHCI
product INTEL LNL_SRAM 0xa87f Core Ultra SRAM product INTEL LNL_SRAM 0xa87f Core Ultra SRAM
product INTEL 21152 0xb152 S21152BB product INTEL 21152 0xb152 S21152BB
product INTEL 21154 0xb154 21154AE/BE product INTEL 21154 0xb154 21154AE/BE
product INTEL ARL_S_GT_2 0xb640 Graphics
product INTEL CORE_DMI_0 0xd130 Core DMI product INTEL CORE_DMI_0 0xd130 Core DMI
product INTEL CORE_DMI_1 0xd131 Core DMI product INTEL CORE_DMI_1 0xd131 Core DMI
product INTEL CORE_DMI_2 0xd132 Core DMI product INTEL CORE_DMI_2 0xd132 Core DMI

View file

@ -2,7 +2,7 @@
* THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT. * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.
* *
* generated from: * generated from:
* OpenBSD: pcidevs,v 1.2094 2024/11/09 10:23:06 miod Exp * OpenBSD: pcidevs,v 1.2095 2025/01/08 02:12:24 jsg Exp
*/ */
/* $NetBSD: pcidevs,v 1.30 1997/06/24 06:20:24 thorpej Exp $ */ /* $NetBSD: pcidevs,v 1.30 1997/06/24 06:20:24 thorpej Exp $ */
@ -6465,9 +6465,13 @@
#define PCI_PRODUCT_INTEL_MTL_IPU 0x7d19 /* Core Ultra IPU */ #define PCI_PRODUCT_INTEL_MTL_IPU 0x7d19 /* Core Ultra IPU */
#define PCI_PRODUCT_INTEL_MTL_NPU 0x7d1d /* Core Ultra NPU */ #define PCI_PRODUCT_INTEL_MTL_NPU 0x7d1d /* Core Ultra NPU */
#define PCI_PRODUCT_INTEL_MTL_U4_GT_1 0x7d40 /* Graphics */ #define PCI_PRODUCT_INTEL_MTL_U4_GT_1 0x7d40 /* Graphics */
#define PCI_PRODUCT_INTEL_ARL_U_GT_1 0x7d41 /* Graphics */
#define PCI_PRODUCT_INTEL_MTL_U_GT_1 0x7d45 /* Graphics */ #define PCI_PRODUCT_INTEL_MTL_U_GT_1 0x7d45 /* Graphics */
#define PCI_PRODUCT_INTEL_ARL_H_GT_1 0x7d51 /* Graphics */
#define PCI_PRODUCT_INTEL_MTL_H_GT_1 0x7d55 /* Arc Graphics */ #define PCI_PRODUCT_INTEL_MTL_H_GT_1 0x7d55 /* Arc Graphics */
#define PCI_PRODUCT_INTEL_MTL_U_GT_2 0x7d60 /* Graphics */ #define PCI_PRODUCT_INTEL_MTL_U_GT_2 0x7d60 /* Graphics */
#define PCI_PRODUCT_INTEL_ARL_S_GT_1 0x7d67 /* Graphics */
#define PCI_PRODUCT_INTEL_ARL_H_GT_2 0x7dd1 /* Graphics */
#define PCI_PRODUCT_INTEL_MTL_H_GT_2 0x7dd5 /* Graphics */ #define PCI_PRODUCT_INTEL_MTL_H_GT_2 0x7dd5 /* Graphics */
#define PCI_PRODUCT_INTEL_MTL_H_ESPI 0x7e02 /* Core Ultra eSPI */ #define PCI_PRODUCT_INTEL_MTL_H_ESPI 0x7e02 /* Core Ultra eSPI */
#define PCI_PRODUCT_INTEL_MTL_U_ESPI 0x7e03 /* Core Ultra eSPI */ #define PCI_PRODUCT_INTEL_MTL_U_ESPI 0x7e03 /* Core Ultra eSPI */
@ -7354,6 +7358,7 @@
#define PCI_PRODUCT_INTEL_LNL_SRAM 0xa87f /* Core Ultra SRAM */ #define PCI_PRODUCT_INTEL_LNL_SRAM 0xa87f /* Core Ultra SRAM */
#define PCI_PRODUCT_INTEL_21152 0xb152 /* S21152BB */ #define PCI_PRODUCT_INTEL_21152 0xb152 /* S21152BB */
#define PCI_PRODUCT_INTEL_21154 0xb154 /* 21154AE/BE */ #define PCI_PRODUCT_INTEL_21154 0xb154 /* 21154AE/BE */
#define PCI_PRODUCT_INTEL_ARL_S_GT_2 0xb640 /* Graphics */
#define PCI_PRODUCT_INTEL_CORE_DMI_0 0xd130 /* Core DMI */ #define PCI_PRODUCT_INTEL_CORE_DMI_0 0xd130 /* Core DMI */
#define PCI_PRODUCT_INTEL_CORE_DMI_1 0xd131 /* Core DMI */ #define PCI_PRODUCT_INTEL_CORE_DMI_1 0xd131 /* Core DMI */
#define PCI_PRODUCT_INTEL_CORE_DMI_2 0xd132 /* Core DMI */ #define PCI_PRODUCT_INTEL_CORE_DMI_2 0xd132 /* Core DMI */

View file

@ -2,7 +2,7 @@
* THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT. * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.
* *
* generated from: * generated from:
* OpenBSD: pcidevs,v 1.2094 2024/11/09 10:23:06 miod Exp * OpenBSD: pcidevs,v 1.2095 2025/01/08 02:12:24 jsg Exp
*/ */
/* $NetBSD: pcidevs,v 1.30 1997/06/24 06:20:24 thorpej Exp $ */ /* $NetBSD: pcidevs,v 1.30 1997/06/24 06:20:24 thorpej Exp $ */
@ -23187,10 +23187,18 @@ static const struct pci_known_product pci_known_products[] = {
PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_MTL_U4_GT_1, PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_MTL_U4_GT_1,
"Graphics", "Graphics",
}, },
{
PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ARL_U_GT_1,
"Graphics",
},
{ {
PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_MTL_U_GT_1, PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_MTL_U_GT_1,
"Graphics", "Graphics",
}, },
{
PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ARL_H_GT_1,
"Graphics",
},
{ {
PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_MTL_H_GT_1, PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_MTL_H_GT_1,
"Arc Graphics", "Arc Graphics",
@ -23199,6 +23207,14 @@ static const struct pci_known_product pci_known_products[] = {
PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_MTL_U_GT_2, PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_MTL_U_GT_2,
"Graphics", "Graphics",
}, },
{
PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ARL_S_GT_1,
"Graphics",
},
{
PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ARL_H_GT_2,
"Graphics",
},
{ {
PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_MTL_H_GT_2, PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_MTL_H_GT_2,
"Graphics", "Graphics",
@ -26743,6 +26759,10 @@ static const struct pci_known_product pci_known_products[] = {
PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_21154, PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_21154,
"21154AE/BE", "21154AE/BE",
}, },
{
PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_ARL_S_GT_2,
"Graphics",
},
{ {
PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE_DMI_0, PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE_DMI_0,
"Core DMI", "Core DMI",

View file

@ -1,4 +1,4 @@
/* $OpenBSD: virtio.c,v 1.36 2024/12/20 22:18:27 sf Exp $ */ /* $OpenBSD: virtio.c,v 1.37 2025/01/09 10:55:22 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 $ */
/* /*
@ -167,6 +167,8 @@ virtio_attach_finish(struct virtio_softc *sc, struct virtio_attach_args *va)
for (i = 0; i < sc->sc_nvqs; i++) { for (i = 0; i < sc->sc_nvqs; i++) {
struct virtqueue *vq = &sc->sc_vqs[i]; struct virtqueue *vq = &sc->sc_vqs[i];
if (vq->vq_num == 0)
continue;
virtio_setup_queue(sc, vq, vq->vq_dmamap->dm_segs[0].ds_addr); virtio_setup_queue(sc, vq, vq->vq_dmamap->dm_segs[0].ds_addr);
} }
virtio_set_status(sc, VIRTIO_CONFIG_DEVICE_STATUS_DRIVER_OK); virtio_set_status(sc, VIRTIO_CONFIG_DEVICE_STATUS_DRIVER_OK);
@ -185,9 +187,9 @@ virtio_reinit_start(struct virtio_softc *sc)
for (i = 0; i < sc->sc_nvqs; i++) { for (i = 0; i < sc->sc_nvqs; i++) {
int n; int n;
struct virtqueue *vq = &sc->sc_vqs[i]; struct virtqueue *vq = &sc->sc_vqs[i];
n = virtio_read_queue_size(sc, vq->vq_index); if (vq->vq_num == 0) /* not used */
if (n == 0) /* vq disappeared */
continue; continue;
n = virtio_read_queue_size(sc, vq->vq_index);
if (n != vq->vq_num) { if (n != vq->vq_num) {
panic("%s: virtqueue size changed, vq index %d", panic("%s: virtqueue size changed, vq index %d",
sc->sc_dev.dv_xname, vq->vq_index); sc->sc_dev.dv_xname, vq->vq_index);
@ -274,8 +276,11 @@ virtio_check_vqs(struct virtio_softc *sc)
int i, r = 0; int i, r = 0;
/* going backwards is better for if_vio */ /* going backwards is better for if_vio */
for (i = sc->sc_nvqs - 1; i >= 0; i--) for (i = sc->sc_nvqs - 1; i >= 0; i--) {
if (sc->sc_vqs[i].vq_num == 0) /* not used */
continue;
r |= virtio_check_vq(sc, &sc->sc_vqs[i]); r |= virtio_check_vq(sc, &sc->sc_vqs[i]);
}
return r; return r;
} }
@ -305,6 +310,7 @@ virtio_init_vq(struct virtio_softc *sc, struct virtqueue *vq)
int i, j; int i, j;
int vq_size = vq->vq_num; int vq_size = vq->vq_num;
VIRTIO_ASSERT(vq_size > 0);
memset(vq->vq_vaddr, 0, vq->vq_bytesize); memset(vq->vq_vaddr, 0, vq->vq_bytesize);
/* build the indirect descriptor chain */ /* build the indirect descriptor chain */
@ -468,6 +474,11 @@ virtio_free_vq(struct virtio_softc *sc, struct virtqueue *vq)
struct vq_entry *qe; struct vq_entry *qe;
int i = 0; int i = 0;
if (vq->vq_num == 0) {
/* virtio_alloc_vq() was never called */
return 0;
}
/* device must be already deactivated */ /* device must be already deactivated */
/* confirm the vq is empty */ /* confirm the vq is empty */
SLIST_FOREACH(qe, &vq->vq_freelist, qe_list) { SLIST_FOREACH(qe, &vq->vq_freelist, qe_list) {
@ -1017,6 +1028,10 @@ virtio_vq_dump(struct virtqueue *vq)
#endif #endif
/* Common fields */ /* Common fields */
printf(" + addr: %p\n", vq); printf(" + addr: %p\n", vq);
if (vq->vq_num == 0) {
printf(" + vq is unused\n");
return;
}
printf(" + vq num: %d\n", vq->vq_num); printf(" + vq num: %d\n", vq->vq_num);
printf(" + vq mask: 0x%X\n", vq->vq_mask); printf(" + vq mask: 0x%X\n", vq->vq_mask);
printf(" + vq index: %d\n", vq->vq_index); printf(" + vq index: %d\n", vq->vq_index);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: virtiovar.h,v 1.26 2024/12/20 22:18:27 sf Exp $ */ /* $OpenBSD: virtiovar.h,v 1.27 2025/01/09 10:55:22 sf Exp $ */
/* $NetBSD: virtiovar.h,v 1.1 2011/10/30 12:12:21 hannken Exp $ */ /* $NetBSD: virtiovar.h,v 1.1 2011/10/30 12:12:21 hannken Exp $ */
/* /*
@ -103,7 +103,8 @@ struct vq_entry {
struct virtqueue { struct virtqueue {
struct virtio_softc *vq_owner; struct virtio_softc *vq_owner;
unsigned int vq_num; /* queue size (# of entries) */ unsigned int vq_num; /* queue size (# of entries),
* 0 if unused/non-existant */
unsigned int vq_mask; /* (1 << vq_num - 1) */ unsigned int vq_mask; /* (1 << vq_num - 1) */
int vq_index; /* queue number (0, 1, ...) */ int vq_index; /* queue number (0, 1, ...) */
@ -180,7 +181,7 @@ struct virtio_softc {
int sc_indirect; int sc_indirect;
int sc_version_1; int sc_version_1;
int sc_nvqs; /* set by child */ int sc_nvqs; /* size of sc_vqs, set by child */
struct virtqueue *sc_vqs; /* set by child */ struct virtqueue *sc_vqs; /* set by child */
struct device *sc_child; /* set by child, struct device *sc_child; /* set by child,

View file

@ -1,4 +1,4 @@
/* $OpenBSD: softraid.c,v 1.432 2024/12/24 19:19:18 krw Exp $ */ /* $OpenBSD: softraid.c,v 1.433 2025/01/08 23:40:40 lucas Exp $ */
/* /*
* Copyright (c) 2007, 2008, 2009 Marco Peereboom <marco@peereboom.us> * Copyright (c) 2007, 2008, 2009 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org> * Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org>
@ -5148,7 +5148,8 @@ sr_hibernate_io(dev_t dev, daddr_t blkno, vaddr_t addr, size_t size, int op, voi
/* Initialize the sub-device */ /* Initialize the sub-device */
return my->subfn(my->subdev, sub_raidoff + blkno, return my->subfn(my->subdev, sub_raidoff + blkno,
addr, size, op, page); addr, size, op, page);
} } else if (op == HIB_DONE)
return my->subfn(my->subdev, blkno, addr, size, op, page);
/* Hibernate only uses (and we only support) writes */ /* Hibernate only uses (and we only support) writes */
if (op != HIB_W) if (op != HIB_W)

View file

@ -1,4 +1,4 @@
/* $OpenBSD: subr_hibernate.c,v 1.149 2025/01/06 21:37:16 krw Exp $ */ /* $OpenBSD: subr_hibernate.c,v 1.150 2025/01/09 19:22:39 mglocker Exp $ */
/* /*
* Copyright (c) 2011 Ariane van der Steldt <ariane@stack.nl> * Copyright (c) 2011 Ariane van der Steldt <ariane@stack.nl>
@ -2019,7 +2019,8 @@ hibernate_suspend(void)
* Give the device-specific I/O function a notification that we're * Give the device-specific I/O function a notification that we're
* done, and that it can clean up or shutdown as needed. * done, and that it can clean up or shutdown as needed.
*/ */
hib->io_func(hib->dev, 0, (vaddr_t)NULL, 0, HIB_DONE, hib->io_page); if (hib->io_func(hib->dev, 0, (vaddr_t)NULL, 0, HIB_DONE, hib->io_page))
printf("Warning: hibernate done failed\n");
return (0); return (0);
} }

View file

@ -1,4 +1,4 @@
/* $OpenBSD: uipc_socket.c,v 1.357 2025/01/07 23:13:46 mvs Exp $ */ /* $OpenBSD: uipc_socket.c,v 1.359 2025/01/09 17:43:33 mvs 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 $ */
/* /*
@ -154,7 +154,7 @@ soalloc(const struct protosw *prp, int wait)
} }
#endif #endif
refcnt_init(&so->so_refcnt); refcnt_init_trace(&so->so_refcnt, DT_REFCNT_IDX_SOCKET);
rw_init_flags(&so->so_lock, dom_name, RWL_DUPOK); rw_init_flags(&so->so_lock, dom_name, RWL_DUPOK);
rw_init(&so->so_rcv.sb_lock, "sbufrcv"); rw_init(&so->so_rcv.sb_lock, "sbufrcv");
rw_init(&so->so_snd.sb_lock, "sbufsnd"); rw_init(&so->so_snd.sb_lock, "sbufsnd");
@ -1388,9 +1388,10 @@ sosplice(struct socket *so, int fd, off_t max, struct timeval *tv)
sosp = soref(so->so_sp->ssp_socket); sosp = soref(so->so_sp->ssp_socket);
sounsplice(so, so->so_sp->ssp_socket, 0); sounsplice(so, so->so_sp->ssp_socket, 0);
sorele(sosp); sorele(sosp);
} } else
error = EPROTO;
sbunlock(&so->so_rcv); sbunlock(&so->so_rcv);
return (0); return (error);
} }
if (sosplice_taskq == NULL) { if (sosplice_taskq == NULL) {

View file

@ -1,4 +1,4 @@
/* $OpenBSD: rtsock.c,v 1.376 2025/01/03 21:27:40 bluhm Exp $ */ /* $OpenBSD: rtsock.c,v 1.377 2025/01/09 18:20:29 bluhm Exp $ */
/* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */ /* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */
/* /*
@ -359,7 +359,7 @@ int
route_peeraddr(struct socket *so, struct mbuf *nam) route_peeraddr(struct socket *so, struct mbuf *nam)
{ {
/* minimal support, just implement a fake peer address */ /* minimal support, just implement a fake peer address */
bcopy(&route_src, mtod(nam, caddr_t), route_src.sa_len); memcpy(mtod(nam, caddr_t), &route_src, route_src.sa_len);
nam->m_len = route_src.sa_len; nam->m_len = route_src.sa_len;
return (0); return (0);
} }

View file

@ -1,4 +1,4 @@
/* $OpenBSD: in_pcb.c,v 1.309 2025/01/03 12:56:15 mvs Exp $ */ /* $OpenBSD: in_pcb.c,v 1.310 2025/01/09 16:47:24 bluhm Exp $ */
/* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */ /* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */
/* /*
@ -623,7 +623,7 @@ in_pcbdetach(struct inpcb *inp)
} }
struct socket * struct socket *
in_pcbsolock(struct inpcb *inp) in_pcbsolock_ref(struct inpcb *inp)
{ {
struct socket *so; struct socket *so;
@ -634,18 +634,18 @@ in_pcbsolock(struct inpcb *inp)
mtx_leave(&inp->inp_sofree_mtx); mtx_leave(&inp->inp_sofree_mtx);
if (so == NULL) if (so == NULL)
return NULL; return NULL;
rw_enter_write(&so->so_lock); rw_enter_write(&so->so_lock);
sorele(so);
return so; return so;
} }
void void
in_pcbsounlock(struct inpcb *inp, struct socket *so) in_pcbsounlock_rele(struct inpcb *inp, struct socket *so)
{ {
KASSERT(inp->inp_socket == so); if (so == NULL)
return;
KASSERT(inp->inp_socket == NULL || inp->inp_socket == so);
rw_exit_write(&so->so_lock); rw_exit_write(&so->so_lock);
sorele(so);
} }
struct inpcb * struct inpcb *

View file

@ -1,4 +1,4 @@
/* $OpenBSD: in_pcb.h,v 1.163 2025/01/05 12:10:39 bluhm Exp $ */ /* $OpenBSD: in_pcb.h,v 1.164 2025/01/09 16:47:24 bluhm Exp $ */
/* $NetBSD: in_pcb.h,v 1.14 1996/02/13 23:42:00 christos Exp $ */ /* $NetBSD: in_pcb.h,v 1.14 1996/02/13 23:42:00 christos Exp $ */
/* /*
@ -311,8 +311,8 @@ int in_pcbaddrisavail(const struct inpcb *, struct sockaddr_in *, int,
int in_pcbconnect(struct inpcb *, struct mbuf *); int in_pcbconnect(struct inpcb *, struct mbuf *);
void in_pcbdetach(struct inpcb *); void in_pcbdetach(struct inpcb *);
struct socket * struct socket *
in_pcbsolock(struct inpcb *); in_pcbsolock_ref(struct inpcb *);
void in_pcbsounlock(struct inpcb *, struct socket *); void in_pcbsounlock_rele(struct inpcb *, struct socket *);
struct inpcb * struct inpcb *
in_pcbref(struct inpcb *); in_pcbref(struct inpcb *);
void in_pcbunref(struct inpcb *); void in_pcbunref(struct inpcb *);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: tcp_input.c,v 1.420 2025/01/05 12:18:48 bluhm Exp $ */ /* $OpenBSD: tcp_input.c,v 1.421 2025/01/09 16:47:24 bluhm Exp $ */
/* $NetBSD: tcp_input.c,v 1.23 1996/02/13 23:43:44 christos Exp $ */ /* $NetBSD: tcp_input.c,v 1.23 1996/02/13 23:43:44 christos Exp $ */
/* /*
@ -3410,7 +3410,7 @@ syn_cache_timer(void *arg)
mtx_leave(&syn_cache_mtx); mtx_leave(&syn_cache_mtx);
NET_LOCK_SHARED(); NET_LOCK_SHARED();
so = in_pcbsolock(inp); so = in_pcbsolock_ref(inp);
if (so != NULL) { if (so != NULL) {
now = tcp_now(); now = tcp_now();
#ifdef TCP_ECN #ifdef TCP_ECN
@ -3418,8 +3418,8 @@ syn_cache_timer(void *arg)
#endif #endif
(void) syn_cache_respond(sc, NULL, now, do_ecn); (void) syn_cache_respond(sc, NULL, now, do_ecn);
tcpstat_inc(tcps_sc_retransmitted); tcpstat_inc(tcps_sc_retransmitted);
in_pcbsounlock(inp, so);
} }
in_pcbsounlock_rele(inp, so);
NET_UNLOCK_SHARED(); NET_UNLOCK_SHARED();
in_pcbunref(inp); in_pcbunref(inp);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: tcp_usrreq.c,v 1.238 2025/01/05 12:23:38 bluhm Exp $ */ /* $OpenBSD: tcp_usrreq.c,v 1.239 2025/01/09 16:47:24 bluhm Exp $ */
/* $NetBSD: tcp_usrreq.c,v 1.20 1996/02/13 23:44:16 christos Exp $ */ /* $NetBSD: tcp_usrreq.c,v 1.20 1996/02/13 23:44:16 christos Exp $ */
/* /*
@ -1122,15 +1122,13 @@ tcp_ident(void *oldp, size_t *oldlenp, void *newp, size_t newlen, int dodrop)
int error = 0; int error = 0;
struct tcp_ident_mapping tir; struct tcp_ident_mapping tir;
struct inpcb *inp; struct inpcb *inp;
struct tcpcb *tp = NULL; struct socket *so = NULL;
struct sockaddr_in *fin, *lin; struct sockaddr_in *fin, *lin;
#ifdef INET6 #ifdef INET6
struct sockaddr_in6 *fin6, *lin6; struct sockaddr_in6 *fin6, *lin6;
struct in6_addr f6, l6; struct in6_addr f6, l6;
#endif #endif
NET_ASSERT_LOCKED();
if (dodrop) { if (dodrop) {
if (oldp != NULL || *oldlenp != 0) if (oldp != NULL || *oldlenp != 0)
return (EINVAL); return (EINVAL);
@ -1150,25 +1148,41 @@ tcp_ident(void *oldp, size_t *oldlenp, void *newp, size_t newlen, int dodrop)
if ((error = copyin(oldp, &tir, sizeof (tir))) != 0 ) if ((error = copyin(oldp, &tir, sizeof (tir))) != 0 )
return (error); return (error);
} }
NET_LOCK_SHARED();
switch (tir.faddr.ss_family) { switch (tir.faddr.ss_family) {
#ifdef INET6 #ifdef INET6
case AF_INET6: case AF_INET6:
if (tir.laddr.ss_family != AF_INET6) {
NET_UNLOCK_SHARED();
return (EAFNOSUPPORT);
}
fin6 = (struct sockaddr_in6 *)&tir.faddr; fin6 = (struct sockaddr_in6 *)&tir.faddr;
error = in6_embedscope(&f6, fin6, NULL, NULL); error = in6_embedscope(&f6, fin6, NULL, NULL);
if (error) if (error) {
NET_UNLOCK_SHARED();
return EINVAL; /*?*/ return EINVAL; /*?*/
}
lin6 = (struct sockaddr_in6 *)&tir.laddr; lin6 = (struct sockaddr_in6 *)&tir.laddr;
error = in6_embedscope(&l6, lin6, NULL, NULL); error = in6_embedscope(&l6, lin6, NULL, NULL);
if (error) if (error) {
NET_UNLOCK_SHARED();
return EINVAL; /*?*/ return EINVAL; /*?*/
}
break; break;
#endif #endif
case AF_INET: case AF_INET:
if (tir.laddr.ss_family != AF_INET) {
NET_UNLOCK_SHARED();
return (EAFNOSUPPORT);
}
fin = (struct sockaddr_in *)&tir.faddr; fin = (struct sockaddr_in *)&tir.faddr;
lin = (struct sockaddr_in *)&tir.laddr; lin = (struct sockaddr_in *)&tir.laddr;
break; break;
default: default:
return (EINVAL); NET_UNLOCK_SHARED();
return (EAFNOSUPPORT);
} }
switch (tir.faddr.ss_family) { switch (tir.faddr.ss_family) {
@ -1187,11 +1201,20 @@ tcp_ident(void *oldp, size_t *oldlenp, void *newp, size_t newlen, int dodrop)
} }
if (dodrop) { if (dodrop) {
if (inp && (tp = intotcpcb(inp)) && struct tcpcb *tp = NULL;
((inp->inp_socket->so_options & SO_ACCEPTCONN) == 0))
if (inp != NULL) {
so = in_pcbsolock_ref(inp);
if (so != NULL)
tp = intotcpcb(inp);
}
if (tp != NULL && !ISSET(so->so_options, SO_ACCEPTCONN))
tp = tcp_drop(tp, ECONNABORTED); tp = tcp_drop(tp, ECONNABORTED);
else else
error = ESRCH; error = ESRCH;
in_pcbsounlock_rele(inp, so);
NET_UNLOCK_SHARED();
in_pcbunref(inp); in_pcbunref(inp);
return (error); return (error);
} }
@ -1212,18 +1235,23 @@ tcp_ident(void *oldp, size_t *oldlenp, void *newp, size_t newlen, int dodrop)
} }
} }
if (inp != NULL && (inp->inp_socket->so_state & SS_CONNECTOUT)) { if (inp != NULL)
tir.ruid = inp->inp_socket->so_ruid; so = in_pcbsolock_ref(inp);
tir.euid = inp->inp_socket->so_euid;
if (so != NULL && ISSET(so->so_state, SS_CONNECTOUT)) {
tir.ruid = so->so_ruid;
tir.euid = so->so_euid;
} else { } else {
tir.ruid = -1; tir.ruid = -1;
tir.euid = -1; tir.euid = -1;
} }
*oldlenp = sizeof (tir); in_pcbsounlock_rele(inp, so);
error = copyout((void *)&tir, oldp, sizeof (tir)); NET_UNLOCK_SHARED();
in_pcbunref(inp); in_pcbunref(inp);
return (error);
*oldlenp = sizeof(tir);
return copyout(&tir, oldp, sizeof(tir));
} }
int int
@ -1428,16 +1456,10 @@ tcp_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
return (error); return (error);
case TCPCTL_IDENT: case TCPCTL_IDENT:
NET_LOCK(); return tcp_ident(oldp, oldlenp, newp, newlen, 0);
error = tcp_ident(oldp, oldlenp, newp, newlen, 0);
NET_UNLOCK();
return (error);
case TCPCTL_DROP: case TCPCTL_DROP:
NET_LOCK(); return tcp_ident(oldp, oldlenp, newp, newlen, 1);
error = tcp_ident(oldp, oldlenp, newp, newlen, 1);
NET_UNLOCK();
return (error);
case TCPCTL_REASS_LIMIT: case TCPCTL_REASS_LIMIT:
NET_LOCK(); NET_LOCK();
@ -1506,9 +1528,8 @@ tcp_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
return (error); return (error);
default: default:
error = sysctl_bounded_arr(tcpctl_vars, nitems(tcpctl_vars), return sysctl_bounded_arr(tcpctl_vars, nitems(tcpctl_vars),
name, namelen, oldp, oldlenp, newp, newlen); name, namelen, oldp, oldlenp, newp, newlen);
return (error);
} }
/* NOTREACHED */ /* NOTREACHED */
} }

View file

@ -1,4 +1,4 @@
/* $OpenBSD: refcnt.h,v 1.12 2023/08/28 14:50:02 bluhm Exp $ */ /* $OpenBSD: refcnt.h,v 1.13 2025/01/09 17:43:33 mvs Exp $ */
/* /*
* Copyright (c) 2015 David Gwynne <dlg@openbsd.org> * Copyright (c) 2015 David Gwynne <dlg@openbsd.org>
@ -49,8 +49,9 @@ unsigned int refcnt_read(struct refcnt *);
#define DT_REFCNT_IDX_IFMADDR 3 #define DT_REFCNT_IDX_IFMADDR 3
#define DT_REFCNT_IDX_INPCB 4 #define DT_REFCNT_IDX_INPCB 4
#define DT_REFCNT_IDX_RTENTRY 5 #define DT_REFCNT_IDX_RTENTRY 5
#define DT_REFCNT_IDX_SYNCACHE 6 #define DT_REFCNT_IDX_SOCKET 6
#define DT_REFCNT_IDX_TDB 7 #define DT_REFCNT_IDX_SYNCACHE 7
#define DT_REFCNT_IDX_TDB 8
#endif /* _KERNEL */ #endif /* _KERNEL */

View file

@ -1,4 +1,4 @@
.\" $OpenBSD: bgpd.conf.5,v 1.246 2025/01/07 12:11:45 claudio Exp $ .\" $OpenBSD: bgpd.conf.5,v 1.247 2025/01/09 15:57:31 claudio Exp $
.\" .\"
.\" Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org> .\" Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org>
.\" Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> .\" Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -16,7 +16,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\" .\"
.Dd $Mdocdate: January 7 2025 $ .Dd $Mdocdate: January 9 2025 $
.Dt BGPD.CONF 5 .Dt BGPD.CONF 5
.Os .Os
.Sh NAME .Sh NAME
@ -1103,7 +1103,7 @@ The default is
.Ic no . .Ic no .
.Pp .Pp
.It Xo .It Xo
.Ic announce extended .Ic announce extended message
.Pq Ic yes Ns | Ns Ic no Ns | Ns Ic enforce .Pq Ic yes Ns | Ns Ic no Ns | Ns Ic enforce
.Xc .Xc
If set to If set to

View file

@ -1,4 +1,4 @@
/* $OpenBSD: bgpd.h,v 1.507 2025/01/07 17:43:31 denis Exp $ */ /* $OpenBSD: bgpd.h,v 1.508 2025/01/09 12:16:21 claudio Exp $ */
/* /*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -415,6 +415,7 @@ struct capabilities {
} grestart; } grestart;
int8_t mp[AID_MAX]; /* multiprotocol extensions, RFC 4760 */ int8_t mp[AID_MAX]; /* multiprotocol extensions, RFC 4760 */
int8_t add_path[AID_MAX]; /* ADD_PATH, RFC 7911 */ int8_t add_path[AID_MAX]; /* ADD_PATH, RFC 7911 */
int8_t ext_nexthop[AID_MAX]; /* Ext Nexthop Encoding, RFC 8950 */
int8_t refresh; /* route refresh, RFC 2918 */ int8_t refresh; /* route refresh, RFC 2918 */
int8_t as4byte; /* 4-byte ASnum, RFC 4893 */ int8_t as4byte; /* 4-byte ASnum, RFC 4893 */
int8_t enhanced_rr; /* enhanced route refresh, RFC 7313 */ int8_t enhanced_rr; /* enhanced route refresh, RFC 7313 */
@ -426,6 +427,7 @@ enum capa_codes {
CAPA_NONE = 0, CAPA_NONE = 0,
CAPA_MP = 1, CAPA_MP = 1,
CAPA_REFRESH = 2, CAPA_REFRESH = 2,
CAPA_EXT_NEXTHOP = 5,
CAPA_EXT_MSG = 6, CAPA_EXT_MSG = 6,
CAPA_ROLE = 9, CAPA_ROLE = 9,
CAPA_RESTART = 64, CAPA_RESTART = 64,

View file

@ -1,4 +1,4 @@
/* $OpenBSD: parse.y,v 1.474 2024/12/14 21:24:31 denis Exp $ */ /* $OpenBSD: parse.y,v 1.475 2025/01/09 15:57:31 claudio Exp $ */
/* /*
* Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org> * Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -249,7 +249,7 @@ typedef struct {
%token FLOWSPEC PROTO FLAGS FRAGMENT TOS LENGTH ICMPTYPE CODE %token FLOWSPEC PROTO FLAGS FRAGMENT TOS LENGTH ICMPTYPE CODE
%token LOCALAS REMOTEAS DESCR LOCALADDR MULTIHOP PASSIVE MAXPREFIX RESTART %token LOCALAS REMOTEAS DESCR LOCALADDR MULTIHOP PASSIVE MAXPREFIX RESTART
%token ANNOUNCE REFRESH AS4BYTE CONNECTRETRY ENHANCED ADDPATH EXTENDED %token ANNOUNCE REFRESH AS4BYTE CONNECTRETRY ENHANCED ADDPATH EXTENDED
%token SEND RECV PLUS POLICY ROLE GRACEFUL NOTIFICATION %token SEND RECV PLUS POLICY ROLE GRACEFUL NOTIFICATION MESSAGE
%token DEMOTE ENFORCE NEIGHBORAS ASOVERRIDE REFLECTOR DEPEND DOWN %token DEMOTE ENFORCE NEIGHBORAS ASOVERRIDE REFLECTOR DEPEND DOWN
%token DUMP IN OUT SOCKET RESTRICTED %token DUMP IN OUT SOCKET RESTRICTED
%token LOG TRANSPARENT FILTERED %token LOG TRANSPARENT FILTERED
@ -2030,8 +2030,8 @@ peeropts : REMOTEAS as4number {
| ANNOUNCE POLICY yesnoenforce { | ANNOUNCE POLICY yesnoenforce {
curpeer->conf.capabilities.policy = $3; curpeer->conf.capabilities.policy = $3;
} }
| ANNOUNCE EXTENDED yesnoenforce { | ANNOUNCE EXTENDED MESSAGE yesnoenforce {
curpeer->conf.capabilities.ext_msg = $3; curpeer->conf.capabilities.ext_msg = $4;
} }
| ROLE STRING { | ROLE STRING {
if (strcmp($2, "provider") == 0) { if (strcmp($2, "provider") == 0) {
@ -3596,6 +3596,7 @@ lookup(char *s)
{ "maxlen", MAXLEN }, { "maxlen", MAXLEN },
{ "md5sig", MD5SIG }, { "md5sig", MD5SIG },
{ "med", MED }, { "med", MED },
{ "message", MESSAGE },
{ "metric", METRIC }, { "metric", METRIC },
{ "min", YMIN }, { "min", YMIN },
{ "min-version", MINVERSION }, { "min-version", MINVERSION },

View file

@ -1,4 +1,4 @@
/* $OpenBSD: printconf.c,v 1.178 2024/12/13 19:21:03 claudio Exp $ */ /* $OpenBSD: printconf.c,v 1.179 2025/01/09 15:57:31 claudio Exp $ */
/* /*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -969,9 +969,9 @@ print_announce(struct peer_config *p, const char *c)
printf("%s\tannounce as4byte no\n", c); printf("%s\tannounce as4byte no\n", c);
if (p->capabilities.ext_msg == 2) if (p->capabilities.ext_msg == 2)
printf("%s\tannounce extended enforce\n", c); printf("%s\tannounce extended message enforce\n", c);
else if (p->capabilities.ext_msg == 1) else if (p->capabilities.ext_msg == 1)
printf("%s\tannounce extended yes\n", c); printf("%s\tannounce extended message yes\n", c);
if (p->capabilities.add_path[AID_MIN] & CAPA_AP_RECV_ENFORCE) if (p->capabilities.add_path[AID_MIN] & CAPA_AP_RECV_ENFORCE)
printf("%s\tannounce add-path recv enforce\n", c); printf("%s\tannounce add-path recv enforce\n", c);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: rde.c,v 1.647 2025/01/04 16:58:46 denis Exp $ */ /* $OpenBSD: rde.c,v 1.648 2025/01/09 12:16:21 claudio Exp $ */
/* /*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -1560,6 +1560,12 @@ rde_update_dispatch(struct rde_peer *peer, struct ibuf *buf)
pathid = 0; pathid = 0;
switch (aid) { switch (aid) {
case AID_INET:
log_peer_warnx(&peer->conf,
"bad MP withdraw for %s", aid2str(aid));
rde_update_err(peer, ERR_UPDATE,
ERR_UPD_OPTATTR, &unreachbuf);
goto done;
case AID_INET6: case AID_INET6:
if (nlri_get_prefix6(&unreachbuf, if (nlri_get_prefix6(&unreachbuf,
&prefix, &prefixlen) == -1) { &prefix, &prefixlen) == -1) {
@ -1689,7 +1695,7 @@ rde_update_dispatch(struct rde_peer *peer, struct ibuf *buf)
goto done; goto done;
} }
if (aid == AID_INET6) { if (aid == AID_INET6 || aid == AID_INET) {
/* inject open policy OTC attribute if needed */ /* inject open policy OTC attribute if needed */
if ((state.aspath.flags & F_ATTR_OTC) == 0) { if ((state.aspath.flags & F_ATTR_OTC) == 0) {
uint32_t tmp; uint32_t tmp;
@ -1740,6 +1746,20 @@ rde_update_dispatch(struct rde_peer *peer, struct ibuf *buf)
pathid = 0; pathid = 0;
switch (aid) { switch (aid) {
case AID_INET:
/*
* rde_get_mp_nexthop already enforces that
* this is only used for RFC 8950.
*/
if (nlri_get_prefix(&reachbuf,
&prefix, &prefixlen) == -1) {
log_peer_warnx(&peer->conf,
"bad IPv4 MP nlri prefix");
rde_update_err(peer, ERR_UPDATE,
ERR_UPD_OPTATTR, &reachbuf);
goto done;
}
break;
case AID_INET6: case AID_INET6:
if (nlri_get_prefix6(&reachbuf, if (nlri_get_prefix6(&reachbuf,
&prefix, &prefixlen) == -1) { &prefix, &prefixlen) == -1) {
@ -2411,8 +2431,19 @@ rde_get_mp_nexthop(struct ibuf *buf, uint8_t aid,
if (ibuf_skip(buf, 1) == -1) if (ibuf_skip(buf, 1) == -1)
return (-1); return (-1);
if (aid == AID_INET && peer_has_ext_nexthop(peer, AID_INET) &&
(nhlen == 16 || nhlen == 32))
aid = AID_INET6;
if (aid == AID_VPN_IPv4 && peer_has_ext_nexthop(peer, AID_VPN_IPv4) &&
(nhlen == 24 || nhlen == 48))
aid = AID_VPN_IPv6;
memset(&nexthop, 0, sizeof(nexthop)); memset(&nexthop, 0, sizeof(nexthop));
switch (aid) { switch (aid) {
case AID_INET:
log_peer_warnx(&peer->conf, "bad multiprotocol nexthop, "
"IPv4 unexpected");
return (-1);
case AID_INET6: case AID_INET6:
/* /*
* RFC2545 describes that there may be a link-local * RFC2545 describes that there may be a link-local
@ -2466,7 +2497,7 @@ rde_get_mp_nexthop(struct ibuf *buf, uint8_t aid,
nexthop.aid = AID_INET; nexthop.aid = AID_INET;
break; break;
case AID_VPN_IPv6: case AID_VPN_IPv6:
if (nhlen != 24) { if (nhlen != 24 && nhlen != 48) {
log_peer_warnx(&peer->conf, "bad %s nexthop, " log_peer_warnx(&peer->conf, "bad %s nexthop, "
"bad size %d", aid2str(aid), nhlen); "bad size %d", aid2str(aid), nhlen);
return (-1); return (-1);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: rde.h,v 1.311 2025/01/07 17:43:31 denis Exp $ */ /* $OpenBSD: rde.h,v 1.312 2025/01/09 12:16:21 claudio Exp $ */
/* /*
* Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> and * Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> and
@ -355,6 +355,8 @@ int rde_match_peer(struct rde_peer *, struct ctl_neighbor *);
/* rde_peer.c */ /* rde_peer.c */
int peer_has_as4byte(struct rde_peer *); int peer_has_as4byte(struct rde_peer *);
int peer_has_add_path(struct rde_peer *, uint8_t, int); int peer_has_add_path(struct rde_peer *, uint8_t, int);
int peer_has_ext_msg(struct rde_peer *);
int peer_has_ext_nexthop(struct rde_peer *, uint8_t);
int peer_accept_no_as_set(struct rde_peer *); int peer_accept_no_as_set(struct rde_peer *);
void peer_init(struct filter_head *); void peer_init(struct filter_head *);
void peer_shutdown(void); void peer_shutdown(void);

View file

@ -1,4 +1,4 @@
/* $OpenBSD: rde_peer.c,v 1.43 2025/01/07 17:43:31 denis Exp $ */ /* $OpenBSD: rde_peer.c,v 1.44 2025/01/09 12:16:21 claudio Exp $ */
/* /*
* Copyright (c) 2019 Claudio Jeker <claudio@openbsd.org> * Copyright (c) 2019 Claudio Jeker <claudio@openbsd.org>
@ -42,7 +42,7 @@ struct iq {
int int
peer_has_as4byte(struct rde_peer *peer) peer_has_as4byte(struct rde_peer *peer)
{ {
return (peer->capa.as4byte); return peer->capa.as4byte;
} }
/* /*
@ -54,13 +54,27 @@ peer_has_add_path(struct rde_peer *peer, uint8_t aid, int mode)
{ {
if (aid >= AID_MAX) if (aid >= AID_MAX)
return 0; return 0;
return (peer->capa.add_path[aid] & mode); return peer->capa.add_path[aid] & mode;
}
int
peer_has_ext_msg(struct rde_peer *peer)
{
return peer->capa.ext_msg;
}
int
peer_has_ext_nexthop(struct rde_peer *peer, uint8_t aid)
{
if (aid >= AID_MAX)
return 0;
return peer->capa.ext_nexthop[aid];
} }
int int
peer_accept_no_as_set(struct rde_peer *peer) peer_accept_no_as_set(struct rde_peer *peer)
{ {
return (peer->flags & PEERFLAG_NO_AS_SET); return peer->flags & PEERFLAG_NO_AS_SET;
} }
void void
@ -147,7 +161,7 @@ peer_add(uint32_t id, struct peer_config *p_conf, struct filter_head *rules)
if ((peer = peer_get(id))) { if ((peer = peer_get(id))) {
memcpy(&peer->conf, p_conf, sizeof(struct peer_config)); memcpy(&peer->conf, p_conf, sizeof(struct peer_config));
return (peer); return peer;
} }
peer = calloc(1, sizeof(struct rde_peer)); peer = calloc(1, sizeof(struct rde_peer));
@ -188,7 +202,7 @@ peer_add(uint32_t id, struct peer_config *p_conf, struct filter_head *rules)
if (RB_INSERT(peer_tree, &peertable, peer) != NULL) if (RB_INSERT(peer_tree, &peertable, peer) != NULL)
fatalx("rde peer table corrupted"); fatalx("rde peer table corrupted");
return (peer); return peer;
} }
struct filter_head * struct filter_head *

View file

@ -1,4 +1,4 @@
/* $OpenBSD: rde_update.c,v 1.172 2025/01/07 12:11:45 claudio Exp $ */ /* $OpenBSD: rde_update.c,v 1.173 2025/01/09 12:16:21 claudio Exp $ */
/* /*
* Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org> * Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org>
@ -877,7 +877,7 @@ up_generate_mp_reach(struct ibuf *buf, struct rde_peer *peer,
struct nexthop *nh, uint8_t aid) struct nexthop *nh, uint8_t aid)
{ {
struct bgpd_addr *nexthop; struct bgpd_addr *nexthop;
size_t off; size_t off, nhoff;
uint16_t len, afi; uint16_t len, afi;
uint8_t safi; uint8_t safi;
@ -898,59 +898,59 @@ up_generate_mp_reach(struct ibuf *buf, struct rde_peer *peer,
return -1; return -1;
if (ibuf_add_n8(buf, safi) == -1) if (ibuf_add_n8(buf, safi) == -1)
return -1; return -1;
nhoff = ibuf_size(buf);
if (ibuf_add_zero(buf, 1) == -1)
return -1;
if (aid == AID_VPN_IPv4 || aid == AID_VPN_IPv6) {
/* write zero rd */
if (ibuf_add_zero(buf, sizeof(uint64_t)) == -1)
return -1;
}
switch (aid) { switch (aid) {
case AID_INET6: case AID_INET:
if (nh == NULL)
return -1;
/* NH LEN */
if (ibuf_add_n8(buf, sizeof(struct in6_addr)) == -1)
return -1;
/* write nexthop */
nexthop = &nh->exit_nexthop;
if (ibuf_add(buf, &nexthop->v6, sizeof(struct in6_addr)) == -1)
return -1;
break;
case AID_VPN_IPv4: case AID_VPN_IPv4:
if (nh == NULL) if (nh == NULL)
return -1; return -1;
/* NH LEN */
if (ibuf_add_n8(buf,
sizeof(uint64_t) + sizeof(struct in_addr)) == -1)
return -1;
/* write zero rd */
if (ibuf_add_zero(buf, sizeof(uint64_t)) == -1)
return -1;
/* write nexthop */
nexthop = &nh->exit_nexthop; nexthop = &nh->exit_nexthop;
if (ibuf_add(buf, &nexthop->v4, sizeof(struct in_addr)) == -1) /* AID_INET must only use this path with an IPv6 nexthop */
if (nexthop->aid == AID_INET && aid != AID_INET) {
if (ibuf_add(buf, &nexthop->v4,
sizeof(nexthop->v4)) == -1)
return -1; return -1;
break; break;
} else if (nexthop->aid == AID_INET6 &&
peer_has_ext_nexthop(peer, aid)) {
if (ibuf_add(buf, &nexthop->v6,
sizeof(nexthop->v6)) == -1)
return -1;
} else {
/* can't encode nexthop, give up and withdraw prefix */
return -1;
}
break;
case AID_INET6:
case AID_VPN_IPv6: case AID_VPN_IPv6:
if (nh == NULL) if (nh == NULL)
return -1; return -1;
/* NH LEN */
if (ibuf_add_n8(buf,
sizeof(uint64_t) + sizeof(struct in6_addr)) == -1)
return -1;
/* write zero rd */
if (ibuf_add_zero(buf, sizeof(uint64_t)) == -1)
return -1;
/* write nexthop */
nexthop = &nh->exit_nexthop; nexthop = &nh->exit_nexthop;
if (ibuf_add(buf, &nexthop->v6, sizeof(struct in6_addr)) == -1) if (ibuf_add(buf, &nexthop->v6, sizeof(nexthop->v6)) == -1)
return -1; return -1;
break; break;
case AID_FLOWSPECv4: case AID_FLOWSPECv4:
case AID_FLOWSPECv6: case AID_FLOWSPECv6:
if (ibuf_add_zero(buf, 1) == -1) /* NH LEN MUST be 0 */
return -1;
/* no NH */ /* no NH */
break; break;
default: default:
fatalx("up_generate_mp_reach: unknown AID"); fatalx("up_generate_mp_reach: unknown AID");
} }
/* update nexthop len */
len = ibuf_size(buf) - nhoff - 1;
if (ibuf_set_n8(buf, nhoff, len) == -1)
return -1;
if (ibuf_add_zero(buf, 1) == -1) /* Reserved must be 0 */ if (ibuf_add_zero(buf, 1) == -1) /* Reserved must be 0 */
return -1; return -1;
@ -999,7 +999,7 @@ up_dump_withdraws(struct rde_peer *peer, uint8_t aid)
uint16_t afi, len; uint16_t afi, len;
uint8_t safi; uint8_t safi;
if (peer->capa.ext_msg) if (peer_has_ext_msg(peer))
pkgsize = MAX_EXT_PKTSIZE; pkgsize = MAX_EXT_PKTSIZE;
if ((buf = ibuf_dynamic(4, pkgsize - MSGSIZE_HEADER)) == NULL) if ((buf = ibuf_dynamic(4, pkgsize - MSGSIZE_HEADER)) == NULL)
@ -1148,14 +1148,21 @@ up_dump_update(struct rde_peer *peer, uint8_t aid)
struct prefix *p; struct prefix *p;
size_t off, pkgsize = MAX_PKTSIZE; size_t off, pkgsize = MAX_PKTSIZE;
uint16_t len; uint16_t len;
int force_ip4mp = 0;
p = RB_MIN(prefix_tree, &peer->updates[aid]); p = RB_MIN(prefix_tree, &peer->updates[aid]);
if (p == NULL) if (p == NULL)
return NULL; return NULL;
if (peer->capa.ext_msg) if (peer_has_ext_msg(peer))
pkgsize = MAX_EXT_PKTSIZE; pkgsize = MAX_EXT_PKTSIZE;
if (aid == AID_INET && peer_has_ext_nexthop(peer, AID_INET)) {
struct nexthop *nh = prefix_nexthop(p);
if (nh != NULL && nh->exit_nexthop.aid == AID_INET6)
force_ip4mp = 1;
}
if ((buf = ibuf_dynamic(4, pkgsize - MSGSIZE_HEADER)) == NULL) if ((buf = ibuf_dynamic(4, pkgsize - MSGSIZE_HEADER)) == NULL)
goto fail; goto fail;
@ -1172,7 +1179,7 @@ up_dump_update(struct rde_peer *peer, uint8_t aid)
prefix_communities(p), prefix_nexthop(p), aid) == -1) prefix_communities(p), prefix_nexthop(p), aid) == -1)
goto drop; goto drop;
if (aid != AID_INET) { if (aid != AID_INET || force_ip4mp) {
/* write mp attribute including nlri */ /* write mp attribute including nlri */
/* /*
@ -1191,7 +1198,7 @@ up_dump_update(struct rde_peer *peer, uint8_t aid)
if (ibuf_set_n16(buf, off, len) == -1) if (ibuf_set_n16(buf, off, len) == -1)
goto fail; goto fail;
if (aid == AID_INET) { if (aid == AID_INET && !force_ip4mp) {
/* last but not least dump the IPv4 nlri */ /* last but not least dump the IPv4 nlri */
if (up_dump_prefix(buf, &peer->updates[aid], peer, 0) == -1) if (up_dump_prefix(buf, &peer->updates[aid], peer, 0) == -1)
goto drop; goto drop;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: rtr_proto.c,v 1.47 2024/11/26 13:59:54 claudio Exp $ */ /* $OpenBSD: rtr_proto.c,v 1.48 2025/01/09 12:07:49 claudio Exp $ */
/* /*
* Copyright (c) 2020 Claudio Jeker <claudio@openbsd.org> * Copyright (c) 2020 Claudio Jeker <claudio@openbsd.org>
@ -42,7 +42,7 @@ struct rtr_header {
uint32_t length; uint32_t length;
} __packed; } __packed;
#define RTR_MAX_PDU_SIZE 49152 /* XXX < IBUF_READ_SIZE */ #define RTR_MAX_PDU_SIZE 65535
#define RTR_MAX_PDU_ERROR_SIZE 256 #define RTR_MAX_PDU_ERROR_SIZE 256
#define RTR_DEFAULT_REFRESH 3600 #define RTR_DEFAULT_REFRESH 3600
#define RTR_DEFAULT_RETRY 600 #define RTR_DEFAULT_RETRY 600

View file

@ -1,4 +1,4 @@
/* $OpenBSD: util.c,v 1.90 2025/01/07 19:24:53 claudio Exp $ */ /* $OpenBSD: util.c,v 1.91 2025/01/09 12:16:21 claudio Exp $ */
/* /*
* Copyright (c) 2006 Claudio Jeker <claudio@openbsd.org> * Copyright (c) 2006 Claudio Jeker <claudio@openbsd.org>
@ -323,6 +323,8 @@ log_capability(uint8_t capa)
return "Multiprotocol Extensions"; return "Multiprotocol Extensions";
case CAPA_REFRESH: case CAPA_REFRESH:
return "Route Refresh"; return "Route Refresh";
case CAPA_EXT_NEXTHOP:
return "Extended Nexhop Encoding";
case CAPA_EXT_MSG: case CAPA_EXT_MSG:
return "Extended Message"; return "Extended Message";
case CAPA_ROLE: case CAPA_ROLE:

View file

@ -1,4 +1,4 @@
/* $OpenBSD: virtio.c,v 1.122 2024/11/21 13:39:34 claudio Exp $ */ /* $OpenBSD: virtio.c,v 1.123 2025/01/08 15:46:10 dv Exp $ */
/* /*
* Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org> * Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org>
@ -68,6 +68,7 @@ static int virtio_dev_launch(struct vmd_vm *, struct virtio_dev *);
static void virtio_dispatch_dev(int, short, void *); static void virtio_dispatch_dev(int, short, void *);
static int handle_dev_msg(struct viodev_msg *, struct virtio_dev *); static int handle_dev_msg(struct viodev_msg *, struct virtio_dev *);
static int virtio_dev_closefds(struct virtio_dev *); static int virtio_dev_closefds(struct virtio_dev *);
static void vmmci_pipe_dispatch(int, short, void *);
const char * const char *
virtio_reg_name(uint8_t reg) virtio_reg_name(uint8_t reg)
@ -275,17 +276,29 @@ virtio_rnd_io(int dir, uint16_t reg, uint32_t *data, uint8_t *intr,
return (0); return (0);
} }
/*
* vmmci_ctl
*
* Inject a command into the vmmci device, potentially delivering interrupt.
*
* Called by the vm process's event(3) loop.
*/
int int
vmmci_ctl(unsigned int cmd) vmmci_ctl(unsigned int cmd)
{ {
int ret = 0;
struct timeval tv = { 0, 0 }; struct timeval tv = { 0, 0 };
mutex_lock(&vmmci.mutex);
if ((vmmci.cfg.device_status & if ((vmmci.cfg.device_status &
VIRTIO_CONFIG_DEVICE_STATUS_DRIVER_OK) == 0) VIRTIO_CONFIG_DEVICE_STATUS_DRIVER_OK) == 0) {
return (-1); ret = -1;
goto unlock;
}
if (cmd == vmmci.cmd) if (cmd == vmmci.cmd)
return (0); goto unlock;
switch (cmd) { switch (cmd) {
case VMMCI_NONE: case VMMCI_NONE:
@ -307,7 +320,7 @@ vmmci_ctl(unsigned int cmd)
vcpu_assert_irq(vmmci.vm_id, 0, vmmci.irq); vcpu_assert_irq(vmmci.vm_id, 0, vmmci.irq);
/* Add ACK timeout */ /* Add ACK timeout */
tv.tv_sec = VMMCI_TIMEOUT; tv.tv_sec = VMMCI_TIMEOUT_SHORT;
evtimer_add(&vmmci.timeout, &tv); evtimer_add(&vmmci.timeout, &tv);
break; break;
case VMMCI_SYNCRTC: case VMMCI_SYNCRTC:
@ -326,14 +339,22 @@ vmmci_ctl(unsigned int cmd)
fatalx("invalid vmmci command: %d", cmd); fatalx("invalid vmmci command: %d", cmd);
} }
return (0); unlock:
mutex_unlock(&vmmci.mutex);
return (ret);
} }
/*
* vmmci_ack
*
* Process a write to the command register.
*
* Called by the vcpu thread. Must be called with the mutex held.
*/
void void
vmmci_ack(unsigned int cmd) vmmci_ack(unsigned int cmd)
{ {
struct timeval tv = { 0, 0 };
switch (cmd) { switch (cmd) {
case VMMCI_NONE: case VMMCI_NONE:
break; break;
@ -347,8 +368,7 @@ vmmci_ack(unsigned int cmd)
if (vmmci.cmd == 0) { if (vmmci.cmd == 0) {
log_debug("%s: vm %u requested shutdown", __func__, log_debug("%s: vm %u requested shutdown", __func__,
vmmci.vm_id); vmmci.vm_id);
tv.tv_sec = VMMCI_TIMEOUT; vm_pipe_send(&vmmci.dev_pipe, VMMCI_SET_TIMEOUT_SHORT);
evtimer_add(&vmmci.timeout, &tv);
return; return;
} }
/* FALLTHROUGH */ /* FALLTHROUGH */
@ -360,12 +380,10 @@ vmmci_ack(unsigned int cmd)
* rc.shutdown on the VM), so increase the timeout before * rc.shutdown on the VM), so increase the timeout before
* killing it forcefully. * killing it forcefully.
*/ */
if (cmd == vmmci.cmd && if (cmd == vmmci.cmd) {
evtimer_pending(&vmmci.timeout, NULL)) {
log_debug("%s: vm %u acknowledged shutdown request", log_debug("%s: vm %u acknowledged shutdown request",
__func__, vmmci.vm_id); __func__, vmmci.vm_id);
tv.tv_sec = VMMCI_SHUTDOWN_TIMEOUT; vm_pipe_send(&vmmci.dev_pipe, VMMCI_SET_TIMEOUT_LONG);
evtimer_add(&vmmci.timeout, &tv);
} }
break; break;
case VMMCI_SYNCRTC: case VMMCI_SYNCRTC:
@ -392,6 +410,7 @@ vmmci_io(int dir, uint16_t reg, uint32_t *data, uint8_t *intr,
{ {
*intr = 0xFF; *intr = 0xFF;
mutex_lock(&vmmci.mutex);
if (dir == 0) { if (dir == 0) {
switch (reg) { switch (reg) {
case VIRTIO_CONFIG_DEVICE_FEATURES: case VIRTIO_CONFIG_DEVICE_FEATURES:
@ -466,6 +485,8 @@ vmmci_io(int dir, uint16_t reg, uint32_t *data, uint8_t *intr,
break; break;
} }
} }
mutex_unlock(&vmmci.mutex);
return (0); return (0);
} }
@ -482,6 +503,27 @@ virtio_get_base(int fd, char *path, size_t npath, int type, const char *dpath)
return -1; return -1;
} }
static void
vmmci_pipe_dispatch(int fd, short event, void *arg)
{
enum pipe_msg_type msg;
struct timeval tv = { 0, 0 };
msg = vm_pipe_recv(&vmmci.dev_pipe);
switch (msg) {
case VMMCI_SET_TIMEOUT_SHORT:
tv.tv_sec = VMMCI_TIMEOUT_SHORT;
evtimer_add(&vmmci.timeout, &tv);
break;
case VMMCI_SET_TIMEOUT_LONG:
tv.tv_sec = VMMCI_TIMEOUT_LONG;
evtimer_add(&vmmci.timeout, &tv);
break;
default:
log_warnx("%s: invalid pipe message type %d", __func__, msg);
}
}
void void
virtio_init(struct vmd_vm *vm, int child_cdrom, virtio_init(struct vmd_vm *vm, int child_cdrom,
int child_disks[][VM_MAX_BASE_PER_DISK], int *child_taps) int child_disks[][VM_MAX_BASE_PER_DISK], int *child_taps)
@ -491,6 +533,7 @@ virtio_init(struct vmd_vm *vm, int child_cdrom,
struct virtio_dev *dev; struct virtio_dev *dev;
uint8_t id; uint8_t id;
uint8_t i, j; uint8_t i, j;
int ret = 0;
/* Virtio entropy device */ /* Virtio entropy device */
if (pci_add_device(&id, PCI_VENDOR_QUMRANET, if (pci_add_device(&id, PCI_VENDOR_QUMRANET,
@ -745,8 +788,15 @@ virtio_init(struct vmd_vm *vm, int child_cdrom,
vmmci.vm_id = vcp->vcp_id; vmmci.vm_id = vcp->vcp_id;
vmmci.irq = pci_get_dev_irq(id); vmmci.irq = pci_get_dev_irq(id);
vmmci.pci_id = id; vmmci.pci_id = id;
ret = pthread_mutex_init(&vmmci.mutex, NULL);
if (ret) {
errno = ret;
fatal("could not initialize vmmci mutex");
}
evtimer_set(&vmmci.timeout, vmmci_timeout, NULL); evtimer_set(&vmmci.timeout, vmmci_timeout, NULL);
vm_pipe_init(&vmmci.dev_pipe, vmmci_pipe_dispatch);
event_add(&vmmci.dev_pipe.read_ev, NULL);
} }
/* /*

View file

@ -1,4 +1,4 @@
/* $OpenBSD: virtio.h,v 1.52 2024/07/10 09:27:33 dv Exp $ */ /* $OpenBSD: virtio.h,v 1.53 2025/01/08 15:46:10 dv Exp $ */
/* /*
* Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org> * Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org>
@ -53,8 +53,8 @@
#define VIONET_MAX_TXLEN VIONET_HARD_MTU + ETHER_HDR_LEN #define VIONET_MAX_TXLEN VIONET_HARD_MTU + ETHER_HDR_LEN
/* VMM Control Interface shutdown timeout (in seconds) */ /* VMM Control Interface shutdown timeout (in seconds) */
#define VMMCI_TIMEOUT 3 #define VMMCI_TIMEOUT_SHORT 3
#define VMMCI_SHUTDOWN_TIMEOUT 120 #define VMMCI_TIMEOUT_LONG 120
/* All the devices we support have either 1, 2 or 3 queues */ /* All the devices we support have either 1, 2 or 3 queues */
/* viornd - 1 queue /* viornd - 1 queue
@ -321,8 +321,10 @@ struct vmmci_dev {
enum vmmci_cmd cmd; enum vmmci_cmd cmd;
uint32_t vm_id; uint32_t vm_id;
int irq; int irq;
uint8_t pci_id; uint8_t pci_id;
pthread_mutex_t mutex;
struct vm_dev_pipe dev_pipe;
}; };
/* XXX to be removed once vioscsi is adapted to vectorized io. */ /* XXX to be removed once vioscsi is adapted to vectorized io. */

View file

@ -1,4 +1,4 @@
/* $OpenBSD: vmd.h,v 1.131 2024/11/06 23:04:45 bluhm Exp $ */ /* $OpenBSD: vmd.h,v 1.132 2025/01/08 15:46:10 dv Exp $ */
/* /*
* Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org> * Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org>
@ -424,6 +424,8 @@ enum pipe_msg_type {
VIRTIO_THREAD_PAUSE, VIRTIO_THREAD_PAUSE,
VIRTIO_THREAD_STOP, VIRTIO_THREAD_STOP,
VIRTIO_THREAD_ACK, VIRTIO_THREAD_ACK,
VMMCI_SET_TIMEOUT_SHORT,
VMMCI_SET_TIMEOUT_LONG,
}; };
static inline struct sockaddr_in * static inline struct sockaddr_in *