From bf0d2e284c333282c40fd5bbcedec342d9b00f5c Mon Sep 17 00:00:00 2001 From: purplerain Date: Tue, 27 Aug 2024 19:23:27 +0000 Subject: [PATCH] sync with OpenBSD -current --- bin/ksh/history.c | 19 ++++--- games/caesar/caesar.6 | 10 ++-- games/fortune/Notes | 18 +++---- games/fortune/README | 7 +-- games/fortune/datfiles/Makefile | 20 ++----- .../datfiles/{fortunes-o.real => fortunes-o} | 0 lib/libcrypto/cms/cms_att.c | 10 ++-- lib/libcrypto/dh/dh_pmeth.c | 32 ++++------- lib/libcrypto/dsa/dsa_pmeth.c | 33 ++++-------- lib/libcrypto/ec/ec_pmeth.c | 14 +++-- lib/libcrypto/rsa/rsa_pmeth.c | 30 +++++++++-- lib/libcrypto/ts/ts_conf.c | 36 ++++++++++--- sbin/dhcpleased/dhcpleased.c | 22 ++++---- sys/arch/amd64/amd64/identcpu.c | 4 +- sys/arch/amd64/amd64/vmm_machdep.c | 54 ++++++++++++------- sys/arch/amd64/include/cpu.h | 3 +- sys/arch/amd64/include/vmmvar.h | 9 +++- sys/dev/fdt/virtio_mmio.c | 11 ++-- sys/dev/pci/drm/amd/amdgpu/amdgpu_drv.c | 2 +- sys/dev/pci/drm/radeon/radeon_drv.c | 2 +- sys/dev/pci/virtio_pci.c | 48 +++++++++++------ sys/dev/pv/if_vio.c | 21 ++++---- sys/dev/pv/vioblk.c | 10 ++-- sys/dev/pv/viocon.c | 12 ++--- sys/dev/pv/viogpu.c | 12 ++--- sys/dev/pv/viomb.c | 14 ++--- sys/dev/pv/viornd.c | 9 ++-- sys/dev/pv/vioscsi.c | 10 ++-- sys/dev/pv/virtio.c | 4 +- sys/dev/pv/virtiovar.h | 15 +++--- sys/dev/pv/vmmci.c | 6 +-- sys/dev/usb/usb_quirks.c | 18 +++++-- sys/dev/usb/usbdevs | 12 ++++- sys/dev/usb/usbdevs.h | 14 ++++- sys/dev/usb/usbdevs_data.h | 32 ++++++++++- sys/dev/vmm/vmm.c | 8 +-- sys/dev/vmm/vmm.h | 5 +- sys/net/pfvar.h | 6 +-- usr.bin/openssl/ts.c | 4 +- usr.bin/telnet/commands.c | 21 +++----- usr.bin/tmux/hyperlinks.c | 18 +++++-- usr.bin/tmux/server-client.c | 5 +- usr.bin/tmux/tmux.1 | 7 ++- usr.bin/tmux/tmux.h | 3 +- usr.bin/tmux/window-copy.c | 25 ++++++++- usr.sbin/radiusd/radiusd_ipcp.c | 14 ++--- usr.sbin/yppoll/yppoll.c | 21 ++++---- usr.sbin/ypset/ypset.c | 36 +++++++------ 48 files changed, 439 insertions(+), 307 deletions(-) rename games/fortune/datfiles/{fortunes-o.real => fortunes-o} (100%) diff --git a/bin/ksh/history.c b/bin/ksh/history.c index c76856349..dea44ad44 100644 --- a/bin/ksh/history.c +++ b/bin/ksh/history.c @@ -1,4 +1,4 @@ -/* $OpenBSD: history.c,v 1.84 2019/10/27 15:02:19 jca Exp $ */ +/* $OpenBSD: history.c,v 1.86 2024/08/27 19:27:19 op Exp $ */ /* * command history @@ -507,20 +507,19 @@ findhist(int start, int fwd, const char *str, int anchored) int findhistrel(const char *str) { + const char *errstr; int maxhist = histptr - history; - int start = maxhist - 1; - int rec = atoi(str); + int rec; + + rec = strtonum(str, -maxhist, maxhist, &errstr); + if (errstr) + return -1; if (rec == 0) return -1; - if (rec > 0) { - if (rec > maxhist) - return -1; + if (rec > 0) return rec - 1; - } - if (rec > maxhist) - return -1; - return start + rec + 1; + return maxhist + rec; } void diff --git a/games/caesar/caesar.6 b/games/caesar/caesar.6 index 9dc040a7a..eb9a7be11 100644 --- a/games/caesar/caesar.6 +++ b/games/caesar/caesar.6 @@ -1,4 +1,4 @@ -.\" $OpenBSD: caesar.6,v 1.9 2015/01/15 19:06:31 schwarze Exp $ +.\" $OpenBSD: caesar.6,v 1.10 2024/08/26 20:12:33 jmc Exp $ .\" .\" Copyright (c) 1989, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)caesar.6 8.2 (Berkeley) 11/16/93 .\" -.Dd $Mdocdate: January 15 2015 $ +.Dd $Mdocdate: August 26 2024 $ .Dt CAESAR 6 .Os .Sh NAME @@ -56,11 +56,9 @@ If this utility is invoked as .Nm rot13 , it will rotate by 13 characters. This format is commonly used on USENET -and in some of the databases used by the -.Xr fortune 6 -program to +to .Dq disguise -their content. +content. .Pp The frequency (from most common to least) of English letters is as follows: .Bd -filled -offset indent diff --git a/games/fortune/Notes b/games/fortune/Notes index 475af87e8..4247d1f14 100644 --- a/games/fortune/Notes +++ b/games/fortune/Notes @@ -1,4 +1,4 @@ -# $OpenBSD: Notes,v 1.5 2018/09/15 09:44:19 bentley Exp $ +# $OpenBSD: Notes,v 1.6 2024/08/26 20:10:53 jmc Exp $ # $NetBSD: Notes,v 1.2 1995/03/23 08:28:26 cgd Exp $ # @(#)Notes 8.1 (Berkeley) 5/31/93 @@ -25,18 +25,18 @@ database, and "fort.dat" is the data file which describes it. See strfile(8) for more information on creating the data files. Fortunes are split into potentially offensive and not potentially offensive parts. The offensive version of a file has the same name as the -non-offensive version with "-o" concatenated, i.e. "fort" is the standard -fortune database, and "fort-o" is the standard offensive database. The +non-offensive version with "-o" concatenated, i.e. "fortune" is the standard +fortune database, and "fortune-o" is the standard offensive database. The fortune program automatically assumes that any file with a name ending in "-o" is potentially offensive, and should therefore only be displayed if explicitly requested, either with the -o option or by specifying a file name on the command line. - Potentially offensive fortune files should NEVER be maintained in -clear text on the system. They are rotated (see caesar(6)) 13 positions. -To create a new, potentially offensive database, use caesar to rotate it, -and then create its data file with the -x option to strfile(8). The fortune -program automatically decrypts the text when it prints entries from such -databases. + Potentially offensive fortune files are maintained in +clear text on the system. If this is a concern, they can be rotated +13 positions: to create a new, rotated database, use a utility such +as rot13(6) or tr(1) to rotate it, and then create its data file +with the -x option to strfile(8). The fortune program automatically +decrypts the text when it prints entries from such databases. Anything which would not make it onto network prime time programming (or which would only be broadcast if some discredited kind of guy said it) MUST be in the potentially offensive database. Fortunes containing any diff --git a/games/fortune/README b/games/fortune/README index 0fad125af..2870ce28d 100644 --- a/games/fortune/README +++ b/games/fortune/README @@ -1,12 +1,7 @@ -# $OpenBSD: README,v 1.3 2002/04/02 02:06:25 pjanzen Exp $ +# $OpenBSD: README,v 1.4 2024/08/26 20:10:53 jmc Exp $ # $NetBSD: README,v 1.2 1995/03/23 08:28:29 cgd Exp $ # @(#)README 8.1 (Berkeley) 5/31/93 -The potentially offensive fortunes ARE installed by default. To avoid -installing them, whack the Makefile in the subdirectory datfiles, and -do "make all install". - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Some years ago, my neighbor Avery said to me: "There has not been an adequate jokebook published since "Joe_Miller", which came out in 1739 and which, incidentally, was the most miserable no-good ... jokebook in the diff --git a/games/fortune/datfiles/Makefile b/games/fortune/datfiles/Makefile index 6766c3ce7..e1701d001 100644 --- a/games/fortune/datfiles/Makefile +++ b/games/fortune/datfiles/Makefile @@ -1,14 +1,10 @@ -# $OpenBSD: Makefile,v 1.8 2024/08/23 03:25:32 deraadt Exp $ +# $OpenBSD: Makefile,v 1.9 2024/08/26 20:10:53 jmc Exp $ # $NetBSD: Makefile,v 1.15 1996/02/29 00:21:16 jtc Exp $ # @(#)Makefile 8.2 (Berkeley) 4/19/94 -SRCS= fortunes fortunes2 startrek zippy recipes -BLDS= fortunes.dat fortunes2.dat startrek.dat zippy.dat \ - fortunes-o fortunes-o.dat recipes.dat - -SRCS+= fortunes2-o limerick -BLDS+= fortunes2-o.dat limerick.dat -TYPE= real +SRCS= fortunes fortunes-o fortunes2 fortunes2-o limerick recipes startrek zippy +BLDS= fortunes.dat fortunes-o.dat fortunes2.dat fortunes2-o.dat \ + limerick.dat recipes.dat startrek.dat zippy.dat CLEANFILES+=${BLDS} @@ -24,13 +20,7 @@ install: ${SRCS} ${BLDS} ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m 444 ${BLDS} \ ${DESTDIR}/usr/share/games/fortune -fortunes.dat fortunes2.dat fortunes2-o.dat limerick.dat startrek.dat zippy.dat recipes.dat: +fortunes.dat fortunes-o.dat fortunes2.dat fortunes2-o.dat limerick.dat recipes.dat startrek.dat zippy.dat: ${STRFILE} -s ${.CURDIR}/${.TARGET:R} ${.TARGET} -fortunes-o.dat: fortunes-o - ${STRFILE} -sx fortunes-o ${.TARGET} - -fortunes-o: fortunes-o.${TYPE} - tr [a-zA-Z] [n-za-mN-ZA-M] < ${.ALLSRC} > ${.TARGET} - .include diff --git a/games/fortune/datfiles/fortunes-o.real b/games/fortune/datfiles/fortunes-o similarity index 100% rename from games/fortune/datfiles/fortunes-o.real rename to games/fortune/datfiles/fortunes-o diff --git a/lib/libcrypto/cms/cms_att.c b/lib/libcrypto/cms/cms_att.c index 390ad6e74..5dbaf3cb2 100644 --- a/lib/libcrypto/cms/cms_att.c +++ b/lib/libcrypto/cms/cms_att.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_att.c,v 1.12 2024/07/26 13:23:52 tb Exp $ */ +/* $OpenBSD: cms_att.c,v 1.13 2024/08/27 01:19:27 tb Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. @@ -52,12 +52,12 @@ * ==================================================================== */ -#include -#include -#include -#include +#include #include +#include + #include "cms_local.h" +#include "x509_local.h" /* CMS SignedData Attribute utilities */ diff --git a/lib/libcrypto/dh/dh_pmeth.c b/lib/libcrypto/dh/dh_pmeth.c index ee90ffe73..1e5327b11 100644 --- a/lib/libcrypto/dh/dh_pmeth.c +++ b/lib/libcrypto/dh/dh_pmeth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dh_pmeth.c,v 1.16 2024/01/01 16:01:48 tb Exp $ */ +/* $OpenBSD: dh_pmeth.c,v 1.17 2024/08/26 22:00:47 op Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -58,6 +58,7 @@ #include #include +#include #include #include @@ -153,36 +154,21 @@ pkey_dh_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) static int pkey_dh_ctrl_str(EVP_PKEY_CTX *ctx, const char *type, const char *value) { - long lval; - char *ep; + const char *errstr; int len; if (!strcmp(type, "dh_paramgen_prime_len")) { - errno = 0; - lval = strtol(value, &ep, 10); - if (value[0] == '\0' || *ep != '\0') - goto not_a_number; - if ((errno == ERANGE && - (lval == LONG_MAX || lval == LONG_MIN)) || - (lval > INT_MAX || lval < INT_MIN)) - goto out_of_range; - len = lval; + len = strtonum(value, INT_MIN, INT_MAX, &errstr); + if (errstr != NULL) + return -2; return EVP_PKEY_CTX_set_dh_paramgen_prime_len(ctx, len); } else if (!strcmp(type, "dh_paramgen_generator")) { - errno = 0; - lval = strtol(value, &ep, 10); - if (value[0] == '\0' || *ep != '\0') - goto not_a_number; - if ((errno == ERANGE && - (lval == LONG_MAX || lval == LONG_MIN)) || - (lval > INT_MAX || lval < INT_MIN)) - goto out_of_range; - len = lval; + len = strtonum(value, INT_MIN, INT_MAX, &errstr); + if (errstr != NULL) + return -2; return EVP_PKEY_CTX_set_dh_paramgen_generator(ctx, len); } -not_a_number: -out_of_range: return -2; } diff --git a/lib/libcrypto/dsa/dsa_pmeth.c b/lib/libcrypto/dsa/dsa_pmeth.c index 001bdec20..019bee68b 100644 --- a/lib/libcrypto/dsa/dsa_pmeth.c +++ b/lib/libcrypto/dsa/dsa_pmeth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsa_pmeth.c,v 1.19 2023/12/28 22:11:26 tb Exp $ */ +/* $OpenBSD: dsa_pmeth.c,v 1.20 2024/08/26 22:00:47 op Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -58,6 +58,7 @@ #include #include +#include #include #include @@ -244,34 +245,21 @@ pkey_dsa_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) static int pkey_dsa_ctrl_str(EVP_PKEY_CTX *ctx, const char *type, const char *value) { - long lval; - char *ep; + const char *errstr; if (!strcmp(type, "dsa_paramgen_bits")) { int nbits; - errno = 0; - lval = strtol(value, &ep, 10); - if (value[0] == '\0' || *ep != '\0') - goto not_a_number; - if ((errno == ERANGE && - (lval == LONG_MAX || lval == LONG_MIN)) || - (lval > INT_MAX || lval < INT_MIN)) - goto out_of_range; - nbits = lval; + nbits = strtonum(value, INT_MIN, INT_MAX, &errstr); + if (errstr != NULL) + return -2; return EVP_PKEY_CTX_set_dsa_paramgen_bits(ctx, nbits); } else if (!strcmp(type, "dsa_paramgen_q_bits")) { int qbits; - errno = 0; - lval = strtol(value, &ep, 10); - if (value[0] == '\0' || *ep != '\0') - goto not_a_number; - if ((errno == ERANGE && - (lval == LONG_MAX || lval == LONG_MIN)) || - (lval > INT_MAX || lval < INT_MIN)) - goto out_of_range; - qbits = lval; + qbits = strtonum(value, INT_MIN, INT_MAX, &errstr); + if (errstr != NULL) + return -2; return EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DSA, EVP_PKEY_OP_PARAMGEN, EVP_PKEY_CTRL_DSA_PARAMGEN_Q_BITS, qbits, NULL); @@ -280,8 +268,7 @@ pkey_dsa_ctrl_str(EVP_PKEY_CTX *ctx, const char *type, const char *value) EVP_PKEY_OP_PARAMGEN, EVP_PKEY_CTRL_DSA_PARAMGEN_MD, 0, (void *)EVP_get_digestbyname(value)); } -not_a_number: -out_of_range: + return -2; } diff --git a/lib/libcrypto/ec/ec_pmeth.c b/lib/libcrypto/ec/ec_pmeth.c index 16fc07642..d422765b0 100644 --- a/lib/libcrypto/ec/ec_pmeth.c +++ b/lib/libcrypto/ec/ec_pmeth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_pmeth.c,v 1.21 2023/12/28 22:12:37 tb Exp $ */ +/* $OpenBSD: ec_pmeth.c,v 1.22 2024/08/26 22:01:28 op Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -57,6 +57,7 @@ */ #include +#include #include #include @@ -445,10 +446,15 @@ pkey_ec_ctrl_str(EVP_PKEY_CTX *ctx, const char *type, const char *value) } return EVP_PKEY_CTX_set_ecdh_kdf_md(ctx, md); } else if (strcmp(type, "ecdh_cofactor_mode") == 0) { - int co_mode; - co_mode = atoi(value); - return EVP_PKEY_CTX_set_ecdh_cofactor_mode(ctx, co_mode); + int cofactor_mode; + const char *errstr; + + cofactor_mode = strtonum(value, -1, 1, &errstr); + if (errstr != NULL) + return -2; + return EVP_PKEY_CTX_set_ecdh_cofactor_mode(ctx, cofactor_mode); } + return -2; } diff --git a/lib/libcrypto/rsa/rsa_pmeth.c b/lib/libcrypto/rsa/rsa_pmeth.c index 9be907961..a1bdeb3b3 100644 --- a/lib/libcrypto/rsa/rsa_pmeth.c +++ b/lib/libcrypto/rsa/rsa_pmeth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsa_pmeth.c,v 1.40 2023/12/28 21:59:07 tb Exp $ */ +/* $OpenBSD: rsa_pmeth.c,v 1.41 2024/08/26 22:01:28 op Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -58,6 +58,7 @@ #include #include +#include #include #include @@ -630,6 +631,8 @@ pkey_rsa_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) static int pkey_rsa_ctrl_str(EVP_PKEY_CTX *ctx, const char *type, const char *value) { + const char *errstr; + if (!value) { RSAerror(RSA_R_VALUE_MISSING); return 0; @@ -664,13 +667,24 @@ pkey_rsa_ctrl_str(EVP_PKEY_CTX *ctx, const char *type, const char *value) saltlen = RSA_PSS_SALTLEN_MAX; else if (!strcmp(value, "auto")) saltlen = RSA_PSS_SALTLEN_AUTO; - else - saltlen = atoi(value); + else { + saltlen = strtonum(value, 0, INT_MAX, &errstr); + if (errstr != NULL) { + RSAerror(RSA_R_INVALID_PSS_SALTLEN); + return -2; + } + } return EVP_PKEY_CTX_set_rsa_pss_saltlen(ctx, saltlen); } if (strcmp(type, "rsa_keygen_bits") == 0) { - int nbits = atoi(value); + int nbits; + + nbits = strtonum(value, 0, INT_MAX, &errstr); + if (errstr != NULL) { + RSAerror(RSA_R_INVALID_KEYBITS); + return -2; + } return EVP_PKEY_CTX_set_rsa_keygen_bits(ctx, nbits); } @@ -702,7 +716,13 @@ pkey_rsa_ctrl_str(EVP_PKEY_CTX *ctx, const char *type, const char *value) EVP_PKEY_CTRL_MD, value); if (strcmp(type, "rsa_pss_keygen_saltlen") == 0) { - int saltlen = atoi(value); + int saltlen; + + saltlen = strtonum(value, 0, INT_MAX, &errstr); + if (errstr != NULL) { + RSAerror(RSA_R_INVALID_PSS_SALTLEN); + return -2; + } return EVP_PKEY_CTX_set_rsa_pss_keygen_saltlen(ctx, saltlen); } diff --git a/lib/libcrypto/ts/ts_conf.c b/lib/libcrypto/ts/ts_conf.c index ef8569ef0..bd499238f 100644 --- a/lib/libcrypto/ts/ts_conf.c +++ b/lib/libcrypto/ts/ts_conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ts_conf.c,v 1.14 2024/03/26 00:39:22 beck Exp $ */ +/* $OpenBSD: ts_conf.c,v 1.15 2024/08/26 22:01:28 op Exp $ */ /* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL * project 2002. */ @@ -56,6 +56,8 @@ * */ +#include +#include #include #include @@ -394,6 +396,7 @@ TS_CONF_set_accuracy(CONF *conf, const char *section, TS_RESP_CTX *ctx) int secs = 0, millis = 0, micros = 0; STACK_OF(CONF_VALUE) *list = NULL; char *accuracy = NCONF_get_string(conf, section, ENV_ACCURACY); + const char *errstr; if (accuracy && !(list = X509V3_parse_list(accuracy))) { TS_CONF_invalid(section, ENV_ACCURACY); @@ -402,14 +405,33 @@ TS_CONF_set_accuracy(CONF *conf, const char *section, TS_RESP_CTX *ctx) for (i = 0; i < sk_CONF_VALUE_num(list); ++i) { CONF_VALUE *val = sk_CONF_VALUE_value(list, i); if (strcmp(val->name, ENV_VALUE_SECS) == 0) { - if (val->value) - secs = atoi(val->value); + if (val->value) { + secs = strtonum(val->value, 0, INT_MAX, + &errstr); + if (errstr != NULL) { + TS_CONF_invalid(section, + ENV_VALUE_SECS); + goto err; + } + } } else if (strcmp(val->name, ENV_VALUE_MILLISECS) == 0) { - if (val->value) - millis = atoi(val->value); + if (val->value) { + millis = strtonum(val->value, 1, 999, &errstr); + if (errstr != NULL) { + TS_CONF_invalid(section, + ENV_VALUE_MILLISECS); + goto err; + } + } } else if (strcmp(val->name, ENV_VALUE_MICROSECS) == 0) { - if (val->value) - micros = atoi(val->value); + if (val->value) { + micros = strtonum(val->value, 1, 999, &errstr); + if (errstr != NULL) { + TS_CONF_invalid(section, + ENV_VALUE_MICROSECS); + goto err; + } + } } else { TS_CONF_invalid(section, ENV_ACCURACY); goto err; diff --git a/sbin/dhcpleased/dhcpleased.c b/sbin/dhcpleased/dhcpleased.c index 0a6a7e594..d3ff1cefa 100644 --- a/sbin/dhcpleased/dhcpleased.c +++ b/sbin/dhcpleased/dhcpleased.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcpleased.c,v 1.31 2024/08/25 09:53:53 florian Exp $ */ +/* $OpenBSD: dhcpleased.c,v 1.32 2024/08/27 05:55:39 florian Exp $ */ /* * Copyright (c) 2017, 2021 Florian Obser @@ -733,14 +733,18 @@ main_imsg_send_config(struct dhcpleased_conf *xconf) sizeof(*iface_conf)); main_imsg_compose_engine(IMSG_RECONF_IFACE, -1, iface_conf, sizeof(*iface_conf)); - main_imsg_compose_frontend(IMSG_RECONF_VC_ID, -1, - iface_conf->vc_id, iface_conf->vc_id_len); - main_imsg_compose_engine(IMSG_RECONF_VC_ID, -1, - iface_conf->vc_id, iface_conf->vc_id_len); - main_imsg_compose_frontend(IMSG_RECONF_C_ID, -1, - iface_conf->c_id, iface_conf->c_id_len); - main_imsg_compose_engine(IMSG_RECONF_C_ID, -1, - iface_conf->c_id, iface_conf->c_id_len); + if (iface_conf->vc_id_len) { + main_imsg_compose_frontend(IMSG_RECONF_VC_ID, -1, + iface_conf->vc_id, iface_conf->vc_id_len); + main_imsg_compose_engine(IMSG_RECONF_VC_ID, -1, + iface_conf->vc_id, iface_conf->vc_id_len); + } + if (iface_conf->c_id_len) { + main_imsg_compose_frontend(IMSG_RECONF_C_ID, -1, + iface_conf->c_id, iface_conf->c_id_len); + main_imsg_compose_engine(IMSG_RECONF_C_ID, -1, + iface_conf->c_id, iface_conf->c_id_len); + } if (iface_conf->h_name != NULL) main_imsg_compose_frontend(IMSG_RECONF_H_NAME, -1, iface_conf->h_name, strlen(iface_conf->h_name) + 1); diff --git a/sys/arch/amd64/amd64/identcpu.c b/sys/arch/amd64/amd64/identcpu.c index a6e31e502..755e0eeaa 100644 --- a/sys/arch/amd64/amd64/identcpu.c +++ b/sys/arch/amd64/amd64/identcpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: identcpu.c,v 1.146 2024/07/08 14:46:47 mpi Exp $ */ +/* $OpenBSD: identcpu.c,v 1.147 2024/08/27 09:16:03 bluhm Exp $ */ /* $NetBSD: identcpu.c,v 1.1 2003/04/26 18:39:28 fvdl Exp $ */ /* @@ -66,7 +66,7 @@ char cpu_model[48]; int cpuspeed; int amd64_has_xcrypt; -int amd64_pos_cbit; +int amd64_pos_cbit; /* C bit position for SEV */ int has_rdrand; int has_rdseed; diff --git a/sys/arch/amd64/amd64/vmm_machdep.c b/sys/arch/amd64/amd64/vmm_machdep.c index 0df3d8b07..c84fbb327 100644 --- a/sys/arch/amd64/amd64/vmm_machdep.c +++ b/sys/arch/amd64/amd64/vmm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmm_machdep.c,v 1.32 2024/08/22 04:53:07 mlarkin Exp $ */ +/* $OpenBSD: vmm_machdep.c,v 1.33 2024/08/27 09:16:03 bluhm Exp $ */ /* * Copyright (c) 2014 Mike Larkin * @@ -82,9 +82,9 @@ int vcpu_reset_regs(struct vcpu *, struct vcpu_reg_state *); int vcpu_reset_regs_vmx(struct vcpu *, struct vcpu_reg_state *); int vcpu_reset_regs_svm(struct vcpu *, struct vcpu_reg_state *); int vcpu_reload_vmcs_vmx(struct vcpu *); -int vcpu_init(struct vcpu *); +int vcpu_init(struct vcpu *, struct vm_create_params *); int vcpu_init_vmx(struct vcpu *); -int vcpu_init_svm(struct vcpu *); +int vcpu_init_svm(struct vcpu *, struct vm_create_params *); int vcpu_run_vmx(struct vcpu *, struct vm_run_params *); int vcpu_run_svm(struct vcpu *, struct vm_run_params *); void vcpu_deinit(struct vcpu *); @@ -1890,7 +1890,6 @@ vcpu_reset_regs_svm(struct vcpu *vcpu, struct vcpu_reg_state *vrs) { struct vmcb *vmcb; int ret; - uint16_t asid; vmcb = (struct vmcb *)vcpu->vc_control_va; @@ -1963,14 +1962,7 @@ vcpu_reset_regs_svm(struct vcpu *vcpu, struct vcpu_reg_state *vrs) svm_setmsrbr(vcpu, MSR_PSTATEDEF(0)); /* Guest VCPU ASID */ - if (vmm_alloc_vpid(&asid)) { - DPRINTF("%s: could not allocate asid\n", __func__); - ret = EINVAL; - goto exit; - } - - vmcb->v_asid = asid; - vcpu->vc_vpid = asid; + vmcb->v_asid = vcpu->vc_vpid; /* TLB Control - First time in, flush all*/ vmcb->v_tlb_control = SVM_TLB_CONTROL_FLUSH_ALL; @@ -1985,9 +1977,13 @@ vcpu_reset_regs_svm(struct vcpu *vcpu, struct vcpu_reg_state *vrs) PATENTRY(6, PAT_UCMINUS) | PATENTRY(7, PAT_UC); /* NPT */ - vmcb->v_np_enable = 1; + vmcb->v_np_enable = SVM_ENABLE_NP; vmcb->v_n_cr3 = vcpu->vc_parent->vm_map->pmap->pm_pdirpa; + /* SEV */ + if (vcpu->vc_sev) + vmcb->v_np_enable |= SVM_ENABLE_SEV; + /* Enable SVME in EFER (must always be set) */ vmcb->v_efer |= EFER_SVME; @@ -1998,7 +1994,6 @@ vcpu_reset_regs_svm(struct vcpu *vcpu, struct vcpu_reg_state *vrs) vcpu->vc_parent->vm_map->pmap->eptp = 0; -exit: return ret; } @@ -3086,6 +3081,7 @@ vcpu_reset_regs(struct vcpu *vcpu, struct vcpu_reg_state *vrs) * * Parameters: * vcpu: the VCPU structure being initialized + * vcp: parameters provided by vmd(8) * * Return values: * 0: the VCPU was initialized successfully @@ -3093,8 +3089,9 @@ vcpu_reset_regs(struct vcpu *vcpu, struct vcpu_reg_state *vrs) * EINVAL: an error occurred during VCPU initialization */ int -vcpu_init_svm(struct vcpu *vcpu) +vcpu_init_svm(struct vcpu *vcpu, struct vm_create_params *vcp) { + uint16_t asid; int ret = 0; /* Allocate VMCB VA */ @@ -3176,6 +3173,21 @@ vcpu_init_svm(struct vcpu *vcpu) (uint64_t)vcpu->vc_svm_ioio_va, (uint64_t)vcpu->vc_svm_ioio_pa); + /* Guest VCPU ASID */ + if (vmm_alloc_vpid(&asid)) { + DPRINTF("%s: could not allocate asid\n", __func__); + ret = EINVAL; + goto exit; + } + vcpu->vc_vpid = asid; + + /* Shall we enable SEV? */ + vcpu->vc_sev = vcp->vcp_sev; + + /* Inform vmd(8) about ASID and C bit position. */ + vcp->vcp_poscbit = amd64_pos_cbit; + vcp->vcp_asid[vcpu->vc_id] = vcpu->vc_vpid; + exit: if (ret) vcpu_deinit_svm(vcpu); @@ -3189,7 +3201,7 @@ exit: * Calls the architecture-specific VCPU init routine */ int -vcpu_init(struct vcpu *vcpu) +vcpu_init(struct vcpu *vcpu, struct vm_create_params *vcp) { int ret = 0; @@ -3207,7 +3219,7 @@ vcpu_init(struct vcpu *vcpu) if (vmm_softc->mode == VMM_MODE_EPT) ret = vcpu_init_vmx(vcpu); else if (vmm_softc->mode == VMM_MODE_RVI) - ret = vcpu_init_svm(vcpu); + ret = vcpu_init_svm(vcpu, vcp); else panic("%s: unknown vmm mode: %d", __func__, vmm_softc->mode); @@ -6285,7 +6297,7 @@ vmm_handle_cpuid(struct vcpu *vcpu) *rdx = 0; break; case 0x80000000: /* Extended function level */ - *rax = 0x80000008; /* curcpu()->ci_pnfeatset */ + *rax = 0x8000001f; /* curcpu()->ci_pnfeatset */ *rbx = 0; *rcx = 0; *rdx = 0; @@ -6345,6 +6357,12 @@ vmm_handle_cpuid(struct vcpu *vcpu) *rcx = ecx; *rdx = edx; break; + case 0x8000001f: /* encryption features (AMD) */ + *rax = eax; + *rbx = ebx; + *rcx = ecx; + *rdx = edx; + break; default: DPRINTF("%s: unsupported rax=0x%llx\n", __func__, *rax); *rax = 0; diff --git a/sys/arch/amd64/include/cpu.h b/sys/arch/amd64/include/cpu.h index f5aada4d4..ca198b24a 100644 --- a/sys/arch/amd64/include/cpu.h +++ b/sys/arch/amd64/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.175 2024/07/21 19:41:31 bluhm Exp $ */ +/* $OpenBSD: cpu.h,v 1.176 2024/08/27 09:16:03 bluhm Exp $ */ /* $NetBSD: cpu.h,v 1.1 2003/04/26 18:39:39 fvdl Exp $ */ /*- @@ -415,6 +415,7 @@ void x86_print_cacheinfo(struct cpu_info *); void identifycpu(struct cpu_info *); int cpu_amd64speed(int *); extern int cpuspeed; +extern int amd64_pos_cbit; /* machdep.c */ void dumpconf(void); diff --git a/sys/arch/amd64/include/vmmvar.h b/sys/arch/amd64/include/vmmvar.h index 3f35e5209..f652bc1b8 100644 --- a/sys/arch/amd64/include/vmmvar.h +++ b/sys/arch/amd64/include/vmmvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: vmmvar.h,v 1.104 2024/07/14 07:57:42 dv Exp $ */ +/* $OpenBSD: vmmvar.h,v 1.105 2024/08/27 09:16:03 bluhm Exp $ */ /* * Copyright (c) 2014 Mike Larkin * @@ -624,6 +624,7 @@ enum { /* Forward declarations */ struct vm; +struct vm_create_params; /* * Implementation-specific cpu state @@ -636,6 +637,9 @@ struct vmcb_segment { uint64_t vs_base; /* 008h */ }; +#define SVM_ENABLE_NP (1ULL << 0) +#define SVM_ENABLE_SEV (1ULL << 1) + struct vmcb { union { struct { @@ -893,6 +897,7 @@ struct vcpu { paddr_t vc_svm_hsa_pa; vaddr_t vc_svm_ioio_va; paddr_t vc_svm_ioio_pa; + int vc_sev; /* [I] */ }; SLIST_HEAD(vcpu_head, vcpu); @@ -921,7 +926,7 @@ int vmm_start(void); int vmm_stop(void); int vm_impl_init(struct vm *, struct proc *); void vm_impl_deinit(struct vm *); -int vcpu_init(struct vcpu *); +int vcpu_init(struct vcpu *, struct vm_create_params *); void vcpu_deinit(struct vcpu *); int vm_rwregs(struct vm_rwregs_params *, int); int vcpu_reset_regs(struct vcpu *, struct vcpu_reg_state *); diff --git a/sys/dev/fdt/virtio_mmio.c b/sys/dev/fdt/virtio_mmio.c index c88d58e3e..212614f98 100644 --- a/sys/dev/fdt/virtio_mmio.c +++ b/sys/dev/fdt/virtio_mmio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: virtio_mmio.c,v 1.14 2024/08/20 07:04:29 sf Exp $ */ +/* $OpenBSD: virtio_mmio.c,v 1.16 2024/08/27 19:01:11 sf Exp $ */ /* $NetBSD: virtio.c,v 1.3 2011/11/02 23:05:52 njoly Exp $ */ /* @@ -133,7 +133,7 @@ const struct cfattach virtio_mmio_fdt_ca = { NULL }; -struct virtio_ops virtio_mmio_ops = { +const struct virtio_ops virtio_mmio_ops = { virtio_mmio_kick, virtio_mmio_read_device_config_1, virtio_mmio_read_device_config_2, @@ -241,6 +241,7 @@ virtio_mmio_attach(struct device *parent, struct device *self, void *aux) struct virtio_mmio_softc *sc = (struct virtio_mmio_softc *)self; struct virtio_softc *vsc = &sc->sc_sc; uint32_t id, magic; + struct virtio_attach_args va = { 0 }; if (faa->fa_nreg < 1) { printf(": no register data\n"); @@ -289,10 +290,10 @@ virtio_mmio_attach(struct device *parent, struct device *self, void *aux) virtio_mmio_set_status(vsc, VIRTIO_CONFIG_DEVICE_STATUS_ACK); virtio_mmio_set_status(vsc, VIRTIO_CONFIG_DEVICE_STATUS_DRIVER); - /* XXX: use softc as aux... */ - vsc->sc_childdevid = id; + va.va_devid = id; + va.va_nintr = 1; vsc->sc_child = NULL; - config_found(self, sc, NULL); + config_found(self, &va, NULL); if (vsc->sc_child == NULL) { printf("%s: no matching child driver; not configured\n", vsc->sc_dev.dv_xname); diff --git a/sys/dev/pci/drm/amd/amdgpu/amdgpu_drv.c b/sys/dev/pci/drm/amd/amdgpu/amdgpu_drv.c index 941f9f245..e730e3a6c 100644 --- a/sys/dev/pci/drm/amd/amdgpu/amdgpu_drv.c +++ b/sys/dev/pci/drm/amd/amdgpu/amdgpu_drv.c @@ -3103,7 +3103,7 @@ amdgpu_attach(struct device *parent, struct device *self, void *aux) if (PCI_MAPREG_TYPE(type) != PCI_MAPREG_TYPE_MEM || pci_mapreg_info(pa->pa_pc, pa->pa_tag, AMDGPU_PCI_MEM, type, &adev->fb_aper_offset, &adev->fb_aper_size, NULL)) { - printf(": can't get frambuffer info\n"); + printf(": can't get framebuffer info\n"); return; } diff --git a/sys/dev/pci/drm/radeon/radeon_drv.c b/sys/dev/pci/drm/radeon/radeon_drv.c index 8b92de60f..2e0c5f261 100644 --- a/sys/dev/pci/drm/radeon/radeon_drv.c +++ b/sys/dev/pci/drm/radeon/radeon_drv.c @@ -1009,7 +1009,7 @@ radeondrm_attach_kms(struct device *parent, struct device *self, void *aux) if (PCI_MAPREG_TYPE(type) != PCI_MAPREG_TYPE_MEM || pci_mapreg_info(pa->pa_pc, pa->pa_tag, RADEON_PCI_MEM, type, &rdev->fb_aper_offset, &rdev->fb_aper_size, NULL)) { - printf(": can't get frambuffer info\n"); + printf(": can't get framebuffer info\n"); return; } if (rdev->fb_aper_offset == 0) { diff --git a/sys/dev/pci/virtio_pci.c b/sys/dev/pci/virtio_pci.c index f069df688..f7b2acda1 100644 --- a/sys/dev/pci/virtio_pci.c +++ b/sys/dev/pci/virtio_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: virtio_pci.c,v 1.38 2024/06/26 01:40:49 jsg Exp $ */ +/* $OpenBSD: virtio_pci.c,v 1.40 2024/08/27 19:01:11 sf Exp $ */ /* $NetBSD: virtio.c,v 1.3 2011/11/02 23:05:52 njoly Exp $ */ /* @@ -53,6 +53,7 @@ #define MAX_MSIX_VECS 8 struct virtio_pci_softc; +struct virtio_pci_attach_args; int virtio_pci_match(struct device *, void *, void *); void virtio_pci_attach(struct device *, struct device *, void *); @@ -78,8 +79,8 @@ int virtio_pci_negotiate_features(struct virtio_softc *, const struct virtio_fe int virtio_pci_negotiate_features_10(struct virtio_softc *, const struct virtio_feature_name *); void virtio_pci_set_msix_queue_vector(struct virtio_pci_softc *, uint32_t, uint16_t); void virtio_pci_set_msix_config_vector(struct virtio_pci_softc *, uint16_t); -int virtio_pci_msix_establish(struct virtio_pci_softc *, struct pci_attach_args *, int, int (*)(void *), void *); -int virtio_pci_setup_msix(struct virtio_pci_softc *, struct pci_attach_args *, int); +int virtio_pci_msix_establish(struct virtio_pci_softc *, struct virtio_pci_attach_args *, int, int (*)(void *), void *); +int virtio_pci_setup_msix(struct virtio_pci_softc *, struct virtio_pci_attach_args *, int); void virtio_pci_free_irqs(struct virtio_pci_softc *); int virtio_pci_poll_intr(void *); int virtio_pci_legacy_intr(void *); @@ -136,6 +137,12 @@ struct virtio_pci_softc { enum irq_type sc_irq_type; }; +struct virtio_pci_attach_args { + struct virtio_attach_args vpa_va; + struct pci_attach_args *vpa_pa; +}; + + const struct cfattach virtio_pci_ca = { sizeof(struct virtio_pci_softc), virtio_pci_match, @@ -144,7 +151,7 @@ const struct cfattach virtio_pci_ca = { NULL }; -struct virtio_ops virtio_pci_ops = { +const struct virtio_ops virtio_pci_ops = { virtio_pci_kick, virtio_pci_read_device_config_1, virtio_pci_read_device_config_2, @@ -577,6 +584,8 @@ virtio_pci_attach(struct device *parent, struct device *self, void *aux) pcireg_t id; char const *intrstr; pci_intr_handle_t ih; + struct virtio_pci_attach_args vpa = { { 0 }, pa }; + int n; revision = PCI_REVISION(pa->pa_class); switch (revision) { @@ -608,6 +617,10 @@ virtio_pci_attach(struct device *parent, struct device *self, void *aux) virtio_pci_dump_caps(sc); #endif + n = MIN(MAX_MSIX_VECS, pci_intr_msix_count(pa)); + n = MAX(n, 1); + vpa.vpa_va.va_nintr = n; + vsc->sc_ops = &virtio_pci_ops; if ((vsc->sc_dev.dv_cfdata->cf_flags & VIRTIO_CF_NO_VERSION_1) == 0 && (revision == 1 || @@ -633,9 +646,9 @@ virtio_pci_attach(struct device *parent, struct device *self, void *aux) virtio_set_status(vsc, VIRTIO_CONFIG_DEVICE_STATUS_DRIVER); printf("\n"); - vsc->sc_childdevid = id; + vpa.vpa_va.va_devid = id; vsc->sc_child = NULL; - config_found(self, sc, NULL); + config_found(self, &vpa, NULL); if (vsc->sc_child == NULL) { printf("%s: no matching child driver; not configured\n", vsc->sc_dev.dv_xname); @@ -647,10 +660,10 @@ virtio_pci_attach(struct device *parent, struct device *self, void *aux) goto fail_1; } - if (virtio_pci_setup_msix(sc, pa, 0) == 0) { + if (virtio_pci_setup_msix(sc, &vpa, 0) == 0) { sc->sc_irq_type = IRQ_MSIX_PER_VQ; intrstr = "msix per-VQ"; - } else if (virtio_pci_setup_msix(sc, pa, 1) == 0) { + } else if (virtio_pci_setup_msix(sc, &vpa, 1) == 0) { sc->sc_irq_type = IRQ_MSIX_SHARED; intrstr = "msix shared"; } else { @@ -910,12 +923,13 @@ virtio_pci_write_device_config_8(struct virtio_softc *vsc, int virtio_pci_msix_establish(struct virtio_pci_softc *sc, - struct pci_attach_args *pa, int idx, int (*handler)(void *), void *ih_arg) + struct virtio_pci_attach_args *vpa, int idx, + int (*handler)(void *), void *ih_arg) { struct virtio_softc *vsc = &sc->sc_sc; pci_intr_handle_t ih; - if (pci_intr_map_msix(pa, idx, &ih) != 0) { + if (pci_intr_map_msix(vpa->vpa_pa, idx, &ih) != 0) { #if VIRTIO_DEBUG printf("%s[%d]: pci_intr_map_msix failed\n", vsc->sc_dev.dv_xname, idx); @@ -983,27 +997,27 @@ virtio_pci_free_irqs(struct virtio_pci_softc *sc) } int -virtio_pci_setup_msix(struct virtio_pci_softc *sc, struct pci_attach_args *pa, - int shared) +virtio_pci_setup_msix(struct virtio_pci_softc *sc, + struct virtio_pci_attach_args *vpa, int shared) { struct virtio_softc *vsc = &sc->sc_sc; int i; /* Shared needs config + queue */ - if (shared && pci_intr_msix_count(pa) < 1 + 1) + if (shared && vpa->vpa_va.va_nintr < 1 + 1) return 1; /* Per VQ needs config + N * queue */ - if (!shared && pci_intr_msix_count(pa) < 1 + vsc->sc_nvqs) + if (!shared && vpa->vpa_va.va_nintr < 1 + vsc->sc_nvqs) return 1; - if (virtio_pci_msix_establish(sc, pa, 0, virtio_pci_config_intr, vsc)) + if (virtio_pci_msix_establish(sc, vpa, 0, virtio_pci_config_intr, vsc)) return 1; sc->sc_devcfg_offset = VIRTIO_CONFIG_DEVICE_CONFIG_MSI; virtio_pci_adjust_config_region(sc); virtio_pci_set_msix_config_vector(sc, 0); if (shared) { - if (virtio_pci_msix_establish(sc, pa, 1, + if (virtio_pci_msix_establish(sc, vpa, 1, virtio_pci_shared_queue_intr, vsc)) { goto fail; } @@ -1012,7 +1026,7 @@ virtio_pci_setup_msix(struct virtio_pci_softc *sc, struct pci_attach_args *pa, virtio_pci_set_msix_queue_vector(sc, i, 1); } else { for (i = 0; i < vsc->sc_nvqs; i++) { - if (virtio_pci_msix_establish(sc, pa, i + 1, + if (virtio_pci_msix_establish(sc, vpa, i + 1, virtio_pci_queue_intr, &vsc->sc_vqs[i])) { goto fail; } diff --git a/sys/dev/pv/if_vio.c b/sys/dev/pv/if_vio.c index 490131401..ffc98ff79 100644 --- a/sys/dev/pv/if_vio.c +++ b/sys/dev/pv/if_vio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vio.c,v 1.46 2024/08/16 13:02:44 jan Exp $ */ +/* $OpenBSD: if_vio.c,v 1.50 2024/08/27 19:11:20 sf Exp $ */ /* * Copyright (c) 2012 Stefan Fritsch, Alexander Fiveg. @@ -330,9 +330,9 @@ void vio_dump(struct vio_softc *); int vio_match(struct device *parent, void *match, void *aux) { - struct virtio_softc *va = aux; + struct virtio_attach_args *va = aux; - if (va->sc_childdevid == PCI_PRODUCT_VIRTIO_NETWORK) + if (va->va_devid == PCI_PRODUCT_VIRTIO_NETWORK) return 1; return 0; @@ -443,7 +443,7 @@ vio_alloc_mem(struct vio_softc *sc) if (vio_alloc_dmamem(sc) != 0) { printf("unable to allocate dma region\n"); - return -1; + return -1; } kva = sc->sc_dma_kva; @@ -588,7 +588,7 @@ vio_attach(struct device *parent, struct device *self, void *aux) ether_fakeaddr(ifp); vio_put_lladdr(&sc->sc_ac, vsc); } - printf(": address %s\n", ether_sprintf(sc->sc_ac.ac_enaddr)); + printf(", address %s\n", ether_sprintf(sc->sc_ac.ac_enaddr)); if (virtio_has_feature(vsc, VIRTIO_NET_F_MRG_RXBUF) || vsc->sc_version_1) { @@ -599,14 +599,13 @@ vio_attach(struct device *parent, struct device *self, void *aux) if (virtio_has_feature(vsc, VIRTIO_NET_F_MRG_RXBUF)) ifp->if_hardmtu = MAXMCLBYTES; else - ifp->if_hardmtu = MAXMCLBYTES - sc->sc_hdr_size - ETHER_HDR_LEN; + ifp->if_hardmtu = MCLBYTES - sc->sc_hdr_size - ETHER_HDR_LEN; - if (virtio_alloc_vq(vsc, &sc->sc_vq[VQRX], 0, MCLBYTES, 2, "rx") != 0) + if (virtio_alloc_vq(vsc, &sc->sc_vq[VQRX], 0, 2, "rx") != 0) goto err; vsc->sc_nvqs = 1; sc->sc_vq[VQRX].vq_done = vio_rx_intr; if (virtio_alloc_vq(vsc, &sc->sc_vq[VQTX], 1, - sc->sc_hdr_size + ifp->if_hardmtu + ETHER_HDR_LEN, VIRTIO_NET_TX_MAXNSEGS + 1, "tx") != 0) { goto err; } @@ -618,7 +617,7 @@ vio_attach(struct device *parent, struct device *self, void *aux) else virtio_stop_vq_intr(vsc, &sc->sc_vq[VQTX]); if (virtio_has_feature(vsc, VIRTIO_NET_F_CTRL_VQ)) { - if (virtio_alloc_vq(vsc, &sc->sc_vq[VQCTL], 2, NBPG, 1, + if (virtio_alloc_vq(vsc, &sc->sc_vq[VQCTL], 2, 1, "control") == 0) { sc->sc_vq[VQCTL].vq_done = vio_ctrleof; virtio_start_vq_intr(vsc, &sc->sc_vq[VQCTL]); @@ -1503,8 +1502,8 @@ vio_ctrl_guest_offloads(struct vio_softc *sc, uint64_t features) if (sc->sc_ctrl_status->ack == VIRTIO_NET_OK) { r = 0; } else { - printf("%s: features 0x%llx failed\n", sc->sc_dev.dv_xname, - features); + printf("%s: offload features 0x%llx failed\n", + sc->sc_dev.dv_xname, features); r = EIO; } diff --git a/sys/dev/pv/vioblk.c b/sys/dev/pv/vioblk.c index 108309f4a..153a27621 100644 --- a/sys/dev/pv/vioblk.c +++ b/sys/dev/pv/vioblk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vioblk.c,v 1.41 2024/08/01 11:13:19 sf Exp $ */ +/* $OpenBSD: vioblk.c,v 1.43 2024/08/27 18:44:12 sf Exp $ */ /* * Copyright (c) 2012 Stefan Fritsch. @@ -156,8 +156,8 @@ const struct scsi_adapter vioblk_switch = { int vioblk_match(struct device *parent, void *match, void *aux) { - struct virtio_softc *va = aux; - if (va->sc_childdevid == PCI_PRODUCT_VIRTIO_BLOCK) + struct virtio_attach_args *va = aux; + if (va->va_devid == PCI_PRODUCT_VIRTIO_BLOCK) return 1; return 0; } @@ -208,8 +208,8 @@ vioblk_attach(struct device *parent, struct device *self, void *aux) sc->sc_capacity = virtio_read_device_config_8(vsc, VIRTIO_BLK_CONFIG_CAPACITY); - if (virtio_alloc_vq(vsc, &sc->sc_vq[0], 0, MAXPHYS, ALLOC_SEGS, - "I/O request") != 0) { + if (virtio_alloc_vq(vsc, &sc->sc_vq[0], 0, ALLOC_SEGS, "I/O request") + != 0) { printf("\nCan't alloc virtqueue\n"); goto err; } diff --git a/sys/dev/pv/viocon.c b/sys/dev/pv/viocon.c index 409922285..681a842cd 100644 --- a/sys/dev/pv/viocon.c +++ b/sys/dev/pv/viocon.c @@ -1,4 +1,4 @@ -/* $OpenBSD: viocon.c,v 1.13 2024/08/01 11:13:19 sf Exp $ */ +/* $OpenBSD: viocon.c,v 1.15 2024/08/27 18:44:12 sf Exp $ */ /* * Copyright (c) 2013-2015 Stefan Fritsch @@ -162,8 +162,8 @@ dev2port(dev_t dev) int viocon_match(struct device *parent, void *match, void *aux) { - struct virtio_softc *va = aux; - if (va->sc_childdevid == PCI_PRODUCT_VIRTIO_CONSOLE) + struct virtio_attach_args *va = aux; + if (va->va_devid == PCI_PRODUCT_VIRTIO_CONSOLE) return 1; return 0; } @@ -235,8 +235,7 @@ viocon_port_create(struct viocon_softc *sc, int portidx) txidx = rxidx + 1; snprintf(name, sizeof(name), "p%drx", portidx); - if (virtio_alloc_vq(vsc, &vsc->sc_vqs[rxidx], rxidx, BUFSIZE, 1, - name) != 0) { + if (virtio_alloc_vq(vsc, &vsc->sc_vqs[rxidx], rxidx, 1, name) != 0) { printf("\nCan't alloc %s virtqueue\n", name); goto err; } @@ -246,8 +245,7 @@ viocon_port_create(struct viocon_softc *sc, int portidx) DPRINTF("%s: rx: %p\n", __func__, vp->vp_rx); snprintf(name, sizeof(name), "p%dtx", portidx); - if (virtio_alloc_vq(vsc, &vsc->sc_vqs[txidx], txidx, BUFSIZE, 1, - name) != 0) { + if (virtio_alloc_vq(vsc, &vsc->sc_vqs[txidx], txidx, 1, name) != 0) { printf("\nCan't alloc %s virtqueue\n", name); goto err; } diff --git a/sys/dev/pv/viogpu.c b/sys/dev/pv/viogpu.c index aa9f1596e..7f3be0954 100644 --- a/sys/dev/pv/viogpu.c +++ b/sys/dev/pv/viogpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: viogpu.c,v 1.7 2024/08/01 11:13:19 sf Exp $ */ +/* $OpenBSD: viogpu.c,v 1.9 2024/08/27 18:44:12 sf Exp $ */ /* * Copyright (c) 2021-2023 joshua stein @@ -137,9 +137,9 @@ struct cfdriver viogpu_cd = { int viogpu_match(struct device *parent, void *match, void *aux) { - struct virtio_softc *va = aux; + struct virtio_attach_args *va = aux; - if (va->sc_childdevid == PCI_PRODUCT_VIRTIO_GPU) + if (va->va_devid == PCI_PRODUCT_VIRTIO_GPU) return 1; return 0; @@ -173,15 +173,13 @@ viogpu_attach(struct device *parent, struct device *self, void *aux) /* allocate command and cursor virtqueues */ vsc->sc_vqs = sc->sc_vqs; - if (virtio_alloc_vq(vsc, &sc->sc_vqs[VQCTRL], VQCTRL, NBPG, 1, - "control")) { + if (virtio_alloc_vq(vsc, &sc->sc_vqs[VQCTRL], VQCTRL, 1, "control")) { printf(": alloc_vq failed\n"); return; } sc->sc_vqs[VQCTRL].vq_done = viogpu_vq_done; - if (virtio_alloc_vq(vsc, &sc->sc_vqs[VQCURS], VQCURS, NBPG, 1, - "cursor")) { + if (virtio_alloc_vq(vsc, &sc->sc_vqs[VQCURS], VQCURS, 1, "cursor")) { printf(": alloc_vq failed\n"); return; } diff --git a/sys/dev/pv/viomb.c b/sys/dev/pv/viomb.c index a8906ecaa..e8d16c581 100644 --- a/sys/dev/pv/viomb.c +++ b/sys/dev/pv/viomb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: viomb.c,v 1.10 2024/05/24 10:05:55 jsg Exp $ */ +/* $OpenBSD: viomb.c,v 1.12 2024/08/27 18:44:12 sf Exp $ */ /* $NetBSD: viomb.c,v 1.1 2011/10/30 12:12:21 hannken Exp $ */ /* @@ -124,8 +124,8 @@ struct cfdriver viomb_cd = { int viomb_match(struct device *parent, void *match, void *aux) { - struct virtio_softc *va = aux; - if (va->sc_childdevid == PCI_PRODUCT_VIRTIO_BALLOON) + struct virtio_attach_args *va = aux; + if (va->va_devid == PCI_PRODUCT_VIRTIO_BALLOON) return (1); return (0); } @@ -161,12 +161,12 @@ viomb_attach(struct device *parent, struct device *self, void *aux) if (virtio_negotiate_features(vsc, viomb_feature_names) != 0) goto err; - if ((virtio_alloc_vq(vsc, &sc->sc_vq[VQ_INFLATE], VQ_INFLATE, - sizeof(u_int32_t) * PGS_PER_REQ, 1, "inflate") != 0)) + if ((virtio_alloc_vq(vsc, &sc->sc_vq[VQ_INFLATE], VQ_INFLATE, 1, + "inflate") != 0)) goto err; vsc->sc_nvqs++; - if ((virtio_alloc_vq(vsc, &sc->sc_vq[VQ_DEFLATE], VQ_DEFLATE, - sizeof(u_int32_t) * PGS_PER_REQ, 1, "deflate") != 0)) + if ((virtio_alloc_vq(vsc, &sc->sc_vq[VQ_DEFLATE], VQ_DEFLATE, 1, + "deflate") != 0)) goto err; vsc->sc_nvqs++; diff --git a/sys/dev/pv/viornd.c b/sys/dev/pv/viornd.c index cc652ba5e..8139b4a6a 100644 --- a/sys/dev/pv/viornd.c +++ b/sys/dev/pv/viornd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: viornd.c,v 1.9 2024/06/26 01:40:49 jsg Exp $ */ +/* $OpenBSD: viornd.c,v 1.11 2024/08/27 18:44:12 sf Exp $ */ /* * Copyright (c) 2014 Stefan Fritsch @@ -72,8 +72,8 @@ struct cfdriver viornd_cd = { int viornd_match(struct device *parent, void *match, void *aux) { - struct virtio_softc *va = aux; - if (va->sc_childdevid == PCI_PRODUCT_VIRTIO_ENTROPY) + struct virtio_attach_args *va = aux; + if (va->va_devid == PCI_PRODUCT_VIRTIO_ENTROPY) return 1; return 0; } @@ -125,8 +125,7 @@ viornd_attach(struct device *parent, struct device *self, void *aux) goto err2; } - if (virtio_alloc_vq(vsc, &sc->sc_vq, 0, VIORND_BUFSIZE, 1, - "Entropy request") != 0) { + if (virtio_alloc_vq(vsc, &sc->sc_vq, 0, 1, "Entropy request") != 0) { printf(": Can't alloc virtqueue\n"); goto err2; } diff --git a/sys/dev/pv/vioscsi.c b/sys/dev/pv/vioscsi.c index a9246eb23..41dbc113d 100644 --- a/sys/dev/pv/vioscsi.c +++ b/sys/dev/pv/vioscsi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vioscsi.c,v 1.32 2023/05/29 08:13:35 sf Exp $ */ +/* $OpenBSD: vioscsi.c,v 1.34 2024/08/27 18:44:12 sf Exp $ */ /* * Copyright (c) 2013 Google Inc. * @@ -93,9 +93,9 @@ const char *const vioscsi_vq_names[] = { int vioscsi_match(struct device *parent, void *self, void *aux) { - struct virtio_softc *va = (struct virtio_softc *)aux; + struct virtio_attach_args *va = aux; - if (va->sc_childdevid == PCI_PRODUCT_VIRTIO_SCSI) + if (va->va_devid == PCI_PRODUCT_VIRTIO_SCSI) return (1); return (0); } @@ -134,8 +134,8 @@ vioscsi_attach(struct device *parent, struct device *self, void *aux) } for (i = 0; i < nitems(sc->sc_vqs); i++) { - rv = virtio_alloc_vq(vsc, &sc->sc_vqs[i], i, MAXPHYS, - ALLOC_SEGS, vioscsi_vq_names[i]); + rv = virtio_alloc_vq(vsc, &sc->sc_vqs[i], i, ALLOC_SEGS, + vioscsi_vq_names[i]); if (rv) { printf(": failed to allocate virtqueue %d\n", i); goto err; diff --git a/sys/dev/pv/virtio.c b/sys/dev/pv/virtio.c index 51725029f..394546ecf 100644 --- a/sys/dev/pv/virtio.c +++ b/sys/dev/pv/virtio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: virtio.c,v 1.30 2024/08/13 08:47:28 sf Exp $ */ +/* $OpenBSD: virtio.c,v 1.31 2024/08/27 18:44:12 sf Exp $ */ /* $NetBSD: virtio.c,v 1.3 2011/11/02 23:05:52 njoly Exp $ */ /* @@ -329,7 +329,7 @@ virtio_init_vq(struct virtio_softc *sc, struct virtqueue *vq) */ int virtio_alloc_vq(struct virtio_softc *sc, struct virtqueue *vq, int index, - int maxsegsize, int maxnsegs, const char *name) + int maxnsegs, const char *name) { int vq_size, allocsize1, allocsize2, allocsize3, allocsize = 0; int rsegs, r, hdrlen; diff --git a/sys/dev/pv/virtiovar.h b/sys/dev/pv/virtiovar.h index 887bc2363..367e166f2 100644 --- a/sys/dev/pv/virtiovar.h +++ b/sys/dev/pv/virtiovar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: virtiovar.h,v 1.18 2024/05/17 16:37:10 sf Exp $ */ +/* $OpenBSD: virtiovar.h,v 1.21 2024/08/27 19:01:11 sf Exp $ */ /* $NetBSD: virtiovar.h,v 1.1 2011/10/30 12:12:21 hannken Exp $ */ /* @@ -85,6 +85,11 @@ #define VIRTIO_CF_PREFER_VERSION_1 4 #define VIRTIO_CF_NO_VERSION_1 8 +struct virtio_attach_args { + int va_devid; /* virtio device id */ + unsigned int va_nintr; /* number of intr vectors */ +}; + struct vq_entry { SLIST_ENTRY(vq_entry) qe_list; /* free list */ uint16_t qe_index; /* index in vq_desc array */ @@ -122,14 +127,11 @@ struct virtqueue { /* free entry management */ struct vq_entry *vq_entries; SLIST_HEAD(, vq_entry) vq_freelist; - struct mutex *vq_freelist_lock; /* enqueue/dequeue status */ uint16_t vq_avail_idx; uint16_t vq_used_idx; int vq_queued; - struct mutex *vq_aring_lock; - struct mutex *vq_uring_lock; /* interrupt handler */ int (*vq_done)(struct virtqueue*); @@ -165,7 +167,7 @@ struct virtio_ops { struct virtio_softc { struct device sc_dev; bus_dma_tag_t sc_dmat; /* set by transport */ - struct virtio_ops *sc_ops; /* set by transport */ + const struct virtio_ops *sc_ops; /* set by transport */ int sc_ipl; /* set by child */ @@ -177,7 +179,6 @@ struct virtio_softc { int sc_nvqs; /* set by child */ struct virtqueue *sc_vqs; /* set by child */ - int sc_childdevid; /* set by transport */ struct device *sc_child; /* set by child, * VIRTIO_CHILD_ERROR on error */ @@ -212,7 +213,7 @@ virtio_has_feature(struct virtio_softc *sc, uint64_t fbit) return 0; } -int virtio_alloc_vq(struct virtio_softc*, struct virtqueue*, int, int, int, +int virtio_alloc_vq(struct virtio_softc*, struct virtqueue*, int, int, const char*); int virtio_free_vq(struct virtio_softc*, struct virtqueue*); void virtio_reset(struct virtio_softc *); diff --git a/sys/dev/pv/vmmci.c b/sys/dev/pv/vmmci.c index 1ee9e110a..acf5482b7 100644 --- a/sys/dev/pv/vmmci.c +++ b/sys/dev/pv/vmmci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmmci.c,v 1.11 2024/05/24 10:05:55 jsg Exp $ */ +/* $OpenBSD: vmmci.c,v 1.12 2024/08/26 19:37:54 sf Exp $ */ /* * Copyright (c) 2017 Reyk Floeter @@ -78,8 +78,8 @@ struct cfdriver vmmci_cd = { int vmmci_match(struct device *parent, void *match, void *aux) { - struct virtio_softc *va = aux; - if (va->sc_childdevid == PCI_PRODUCT_VIRTIO_VMMCI) + struct virtio_attach_args *va = aux; + if (va->va_devid == PCI_PRODUCT_VIRTIO_VMMCI) return (1); return (0); } diff --git a/sys/dev/usb/usb_quirks.c b/sys/dev/usb/usb_quirks.c index 4574e736f..11f7b25ca 100644 --- a/sys/dev/usb/usb_quirks.c +++ b/sys/dev/usb/usb_quirks.c @@ -1,4 +1,4 @@ -/* $OpenBSD: usb_quirks.c,v 1.78 2021/03/24 02:49:57 jcs Exp $ */ +/* $OpenBSD: usb_quirks.c,v 1.79 2024/08/27 12:41:18 sthen Exp $ */ /* $NetBSD: usb_quirks.c,v 1.45 2003/05/10 17:47:14 hamajima Exp $ */ /* $FreeBSD: src/sys/dev/usb/usb_quirks.c,v 1.30 2003/01/02 04:15:55 imp Exp $ */ @@ -154,12 +154,24 @@ const struct usbd_quirk_entry { ANY, { UQ_MS_VENDOR_BUTTONS }}, /* Devices that need their data pipe held open */ + { USB_VENDOR_CHICONY, USB_PRODUCT_CHICONY_OPTMOUSE, + ANY, { UQ_ALWAYS_OPEN }}, { USB_VENDOR_HAILUCK, USB_PRODUCT_HAILUCK_KEYBOARD, ANY, { UQ_ALWAYS_OPEN }}, + { USB_VENDOR_LENOVO, USB_PRODUCT_LENOVO_OPTUSBMOUSE, + ANY, { UQ_ALWAYS_OPEN }}, + { USB_VENDOR_LOGITECH, USB_PRODUCT_LOGITECH_B100_1, + ANY, { UQ_ALWAYS_OPEN }}, + { USB_VENDOR_LOGITECH, USB_PRODUCT_LOGITECH_B100_2, + ANY, { UQ_ALWAYS_OPEN }}, + { USB_VENDOR_MICROSOFT, USB_PRODUCT_MICROSOFT_PIXARTMOUSE, + ANY, { UQ_ALWAYS_OPEN }}, { USB_VENDOR_MICROSOFT, USB_PRODUCT_MICROSOFT_TYPECOVER, - ANY, { UQ_ALWAYS_OPEN }}, + ANY, { UQ_ALWAYS_OPEN }}, { USB_VENDOR_MICROSOFT, USB_PRODUCT_MICROSOFT_TYPECOVER2, - ANY, { UQ_ALWAYS_OPEN }}, + ANY, { UQ_ALWAYS_OPEN }}, + { USB_VENDOR_PIXART, USB_PRODUCT_PIXART_RPIMOUSE, + ANY, { UQ_ALWAYS_OPEN }}, { 0, 0, 0, { 0 } } }; diff --git a/sys/dev/usb/usbdevs b/sys/dev/usb/usbdevs index 6f3e8e45c..86ed8606f 100644 --- a/sys/dev/usb/usbdevs +++ b/sys/dev/usb/usbdevs @@ -1,4 +1,4 @@ -$OpenBSD: usbdevs,v 1.767 2024/08/08 05:09:09 deraadt Exp $ +$OpenBSD: usbdevs,v 1.768 2024/08/27 12:31:18 sthen Exp $ /* $NetBSD: usbdevs,v 1.322 2003/05/10 17:47:14 hamajima Exp $ */ /* @@ -365,6 +365,7 @@ vendor GARMIN 0x091e Garmin International vendor GOHUBS 0x0921 GoHubs vendor BIOMETRIC 0x0929 American Biometric Company vendor TOSHIBA 0x0930 Toshiba Corp +vendor PIXART 0x093a PixArt vendor INTREPIDCS 0x093c Intrepid vendor YANO 0x094f Yano vendor KINGSTON 0x0951 Kingston Technology @@ -1347,6 +1348,7 @@ product CHIC CYPRESS 0x0003 Cypress /* Chicony products */ product CHICONY KB8933 0x0001 KB-8933 keyboard +product CHICONY OPTMOUSE 0x0939 Optical Mouse product CHICONY CAMERA 0x480c Integrated Camera product CHICONY RTL8188CUS_1 0xaff7 RTL8188CUS product CHICONY RTL8188CUS_2 0xaff8 RTL8188CUS @@ -2638,6 +2640,7 @@ product LENOVO RTL8153B_2 0x3098 RTL8153B product LENOVO RTL8153B_3 0x309b RTL8153B product LENOVO RTL8153B_4 0x309c RTL8153B product LENOVO RTL8153B_5 0x309d RTL8153B +product LENOVO OPTUSBMOUSE 0x600e Optical Mouse product LENOVO ETHERNET 0x7203 USB 2.0 Ethernet product LENOVO RTL8153_1 0x7205 RTL8153 product LENOVO ONELINK 0x720a OneLink @@ -2753,6 +2756,8 @@ product LOGITECH MBA47 0xc002 M-BA47 mouse product LOGITECH WMMOUSE 0xc004 WingMan Gaming Mouse product LOGITECH BD58 0xc00c BD58 mouse product LOGITECH UN58A 0xc030 iFeel Mouse +product LOGITECH B100_1 0xc05a B100 mouse +product LOGITECH B100_2 0xc077 B100 mouse product LOGITECH WMPAD 0xc208 WingMan GamePad Extreme product LOGITECH WMRPAD 0xc20a WingMan RumblePad product LOGITECH WMJOY 0xc281 WingMan Force joystick @@ -3139,6 +3144,7 @@ product MICROSOFT INETPRO 0x001c Internet Keyboard Pro product MICROSOFT TBEXPLORER 0x0024 Trackball Explorer product MICROSOFT INTELLIEYE 0x0025 IntelliEye mouse product MICROSOFT INETPRO2 0x002b Internet Keyboard Pro +product MICROSOFT PIXARTMOUSE 0x00cb Optical Mouse product MICROSOFT MN510 0x006e MN510 Wireless product MICROSOFT 700WX 0x0079 Palm 700WX product MICROSOFT MN110 0x007a 10/100 Ethernet @@ -3600,6 +3606,10 @@ product PILOTECH CRW600 0x0001 CRW-600 6-in-1 product PIONEERDJ RTL8152B 0x0007 RTL8152B product PIONEERDJ RTL8153B 0x0031 RTL8153B +/* PixArt products */ + +product PIXART RPIMOUSE 0x2510 Raspberry Pi Mouse + /* Planex Communications products */ product PLANEX GW_US11H 0x14ea GW-US11H WLAN product PLANEX2 RTL8188CUS 0x1201 RTL8188CUS diff --git a/sys/dev/usb/usbdevs.h b/sys/dev/usb/usbdevs.h index 80524949b..98ff0d3a8 100644 --- a/sys/dev/usb/usbdevs.h +++ b/sys/dev/usb/usbdevs.h @@ -1,10 +1,10 @@ -/* $OpenBSD: usbdevs.h,v 1.779 2024/08/08 05:09:33 deraadt Exp $ */ +/* $OpenBSD: usbdevs.h,v 1.780 2024/08/27 12:31:43 sthen Exp $ */ /* * THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. * * generated from: - * OpenBSD: usbdevs,v 1.767 2024/08/08 05:09:09 deraadt Exp + * OpenBSD: usbdevs,v 1.768 2024/08/27 12:31:18 sthen Exp */ /* $NetBSD: usbdevs,v 1.322 2003/05/10 17:47:14 hamajima Exp $ */ @@ -372,6 +372,7 @@ #define USB_VENDOR_GOHUBS 0x0921 /* GoHubs */ #define USB_VENDOR_BIOMETRIC 0x0929 /* American Biometric Company */ #define USB_VENDOR_TOSHIBA 0x0930 /* Toshiba Corp */ +#define USB_VENDOR_PIXART 0x093a /* PixArt */ #define USB_VENDOR_INTREPIDCS 0x093c /* Intrepid */ #define USB_VENDOR_YANO 0x094f /* Yano */ #define USB_VENDOR_KINGSTON 0x0951 /* Kingston Technology */ @@ -1354,6 +1355,7 @@ /* Chicony products */ #define USB_PRODUCT_CHICONY_KB8933 0x0001 /* KB-8933 keyboard */ +#define USB_PRODUCT_CHICONY_OPTMOUSE 0x0939 /* Optical Mouse */ #define USB_PRODUCT_CHICONY_CAMERA 0x480c /* Integrated Camera */ #define USB_PRODUCT_CHICONY_RTL8188CUS_1 0xaff7 /* RTL8188CUS */ #define USB_PRODUCT_CHICONY_RTL8188CUS_2 0xaff8 /* RTL8188CUS */ @@ -2645,6 +2647,7 @@ #define USB_PRODUCT_LENOVO_RTL8153B_3 0x309b /* RTL8153B */ #define USB_PRODUCT_LENOVO_RTL8153B_4 0x309c /* RTL8153B */ #define USB_PRODUCT_LENOVO_RTL8153B_5 0x309d /* RTL8153B */ +#define USB_PRODUCT_LENOVO_OPTUSBMOUSE 0x600e /* Optical Mouse */ #define USB_PRODUCT_LENOVO_ETHERNET 0x7203 /* USB 2.0 Ethernet */ #define USB_PRODUCT_LENOVO_RTL8153_1 0x7205 /* RTL8153 */ #define USB_PRODUCT_LENOVO_ONELINK 0x720a /* OneLink */ @@ -2760,6 +2763,8 @@ #define USB_PRODUCT_LOGITECH_WMMOUSE 0xc004 /* WingMan Gaming Mouse */ #define USB_PRODUCT_LOGITECH_BD58 0xc00c /* BD58 mouse */ #define USB_PRODUCT_LOGITECH_UN58A 0xc030 /* iFeel Mouse */ +#define USB_PRODUCT_LOGITECH_B100_1 0xc05a /* B100 mouse */ +#define USB_PRODUCT_LOGITECH_B100_2 0xc077 /* B100 mouse */ #define USB_PRODUCT_LOGITECH_WMPAD 0xc208 /* WingMan GamePad Extreme */ #define USB_PRODUCT_LOGITECH_WMRPAD 0xc20a /* WingMan RumblePad */ #define USB_PRODUCT_LOGITECH_WMJOY 0xc281 /* WingMan Force joystick */ @@ -3146,6 +3151,7 @@ #define USB_PRODUCT_MICROSOFT_TBEXPLORER 0x0024 /* Trackball Explorer */ #define USB_PRODUCT_MICROSOFT_INTELLIEYE 0x0025 /* IntelliEye mouse */ #define USB_PRODUCT_MICROSOFT_INETPRO2 0x002b /* Internet Keyboard Pro */ +#define USB_PRODUCT_MICROSOFT_PIXARTMOUSE 0x00cb /* Optical Mouse */ #define USB_PRODUCT_MICROSOFT_MN510 0x006e /* MN510 Wireless */ #define USB_PRODUCT_MICROSOFT_700WX 0x0079 /* Palm 700WX */ #define USB_PRODUCT_MICROSOFT_MN110 0x007a /* 10/100 Ethernet */ @@ -3607,6 +3613,10 @@ #define USB_PRODUCT_PIONEERDJ_RTL8152B 0x0007 /* RTL8152B */ #define USB_PRODUCT_PIONEERDJ_RTL8153B 0x0031 /* RTL8153B */ +/* PixArt products */ + +#define USB_PRODUCT_PIXART_RPIMOUSE 0x2510 /* Raspberry Pi Mouse */ + /* Planex Communications products */ #define USB_PRODUCT_PLANEX_GW_US11H 0x14ea /* GW-US11H WLAN */ #define USB_PRODUCT_PLANEX2_RTL8188CUS 0x1201 /* RTL8188CUS */ diff --git a/sys/dev/usb/usbdevs_data.h b/sys/dev/usb/usbdevs_data.h index 6cb37aa37..3a7644ade 100644 --- a/sys/dev/usb/usbdevs_data.h +++ b/sys/dev/usb/usbdevs_data.h @@ -1,10 +1,10 @@ -/* $OpenBSD: usbdevs_data.h,v 1.773 2024/08/08 05:09:33 deraadt Exp $ */ +/* $OpenBSD: usbdevs_data.h,v 1.774 2024/08/27 12:31:43 sthen Exp $ */ /* * THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. * * generated from: - * OpenBSD: usbdevs,v 1.767 2024/08/08 05:09:09 deraadt Exp + * OpenBSD: usbdevs,v 1.768 2024/08/27 12:31:18 sthen Exp */ /* $NetBSD: usbdevs,v 1.322 2003/05/10 17:47:14 hamajima Exp $ */ @@ -1941,6 +1941,10 @@ const struct usb_known_product usb_known_products[] = { USB_VENDOR_CHICONY, USB_PRODUCT_CHICONY_KB8933, "KB-8933 keyboard", }, + { + USB_VENDOR_CHICONY, USB_PRODUCT_CHICONY_OPTMOUSE, + "Optical Mouse", + }, { USB_VENDOR_CHICONY, USB_PRODUCT_CHICONY_CAMERA, "Integrated Camera", @@ -5841,6 +5845,10 @@ const struct usb_known_product usb_known_products[] = { USB_VENDOR_LENOVO, USB_PRODUCT_LENOVO_RTL8153B_5, "RTL8153B", }, + { + USB_VENDOR_LENOVO, USB_PRODUCT_LENOVO_OPTUSBMOUSE, + "Optical Mouse", + }, { USB_VENDOR_LENOVO, USB_PRODUCT_LENOVO_ETHERNET, "USB 2.0 Ethernet", @@ -6229,6 +6237,14 @@ const struct usb_known_product usb_known_products[] = { USB_VENDOR_LOGITECH, USB_PRODUCT_LOGITECH_UN58A, "iFeel Mouse", }, + { + USB_VENDOR_LOGITECH, USB_PRODUCT_LOGITECH_B100_1, + "B100 mouse", + }, + { + USB_VENDOR_LOGITECH, USB_PRODUCT_LOGITECH_B100_2, + "B100 mouse", + }, { USB_VENDOR_LOGITECH, USB_PRODUCT_LOGITECH_WMPAD, "WingMan GamePad Extreme", @@ -7605,6 +7621,10 @@ const struct usb_known_product usb_known_products[] = { USB_VENDOR_MICROSOFT, USB_PRODUCT_MICROSOFT_INETPRO2, "Internet Keyboard Pro", }, + { + USB_VENDOR_MICROSOFT, USB_PRODUCT_MICROSOFT_PIXARTMOUSE, + "Optical Mouse", + }, { USB_VENDOR_MICROSOFT, USB_PRODUCT_MICROSOFT_MN510, "MN510 Wireless", @@ -8881,6 +8901,10 @@ const struct usb_known_product usb_known_products[] = { USB_VENDOR_PIONEERDJ, USB_PRODUCT_PIONEERDJ_RTL8153B, "RTL8153B", }, + { + USB_VENDOR_PIXART, USB_PRODUCT_PIXART_RPIMOUSE, + "Raspberry Pi Mouse", + }, { USB_VENDOR_PLANEX, USB_PRODUCT_PLANEX_GW_US11H, "GW-US11H WLAN", @@ -13597,6 +13621,10 @@ const struct usb_known_vendor usb_known_vendors[] = { USB_VENDOR_TOSHIBA, "Toshiba Corp", }, + { + USB_VENDOR_PIXART, + "PixArt", + }, { USB_VENDOR_INTREPIDCS, "Intrepid", diff --git a/sys/dev/vmm/vmm.c b/sys/dev/vmm/vmm.c index 4d4866f70..24e168383 100644 --- a/sys/dev/vmm/vmm.c +++ b/sys/dev/vmm/vmm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmm.c,v 1.2 2023/05/13 23:15:28 dv Exp $ */ +/* $OpenBSD: vmm.c,v 1.3 2024/08/27 09:16:03 bluhm Exp $ */ /* * Copyright (c) 2014-2023 Mike Larkin * @@ -399,13 +399,13 @@ vm_create(struct vm_create_params *vcp, struct proc *p) vcpu = pool_get(&vcpu_pool, PR_WAITOK | PR_ZERO); vcpu->vc_parent = vm; - if ((ret = vcpu_init(vcpu)) != 0) { + vcpu->vc_id = vm->vm_vcpu_ct; + vm->vm_vcpu_ct++; + if ((ret = vcpu_init(vcpu, vcp)) != 0) { printf("failed to init vcpu %d for vm %p\n", i, vm); vm_teardown(&vm); return (ret); } - vcpu->vc_id = vm->vm_vcpu_ct; - vm->vm_vcpu_ct++; /* Publish vcpu to list, inheriting the reference. */ SLIST_INSERT_HEAD(&vm->vm_vcpu_list, vcpu, vc_vcpu_link); } diff --git a/sys/dev/vmm/vmm.h b/sys/dev/vmm/vmm.h index ac682bc2c..ca5a152f5 100644 --- a/sys/dev/vmm/vmm.h +++ b/sys/dev/vmm/vmm.h @@ -1,4 +1,4 @@ -/* $OpenBSD: vmm.h,v 1.6 2024/07/10 10:41:19 dv Exp $ */ +/* $OpenBSD: vmm.h,v 1.7 2024/08/27 09:16:03 bluhm Exp $ */ /* * Copyright (c) 2014-2023 Mike Larkin * @@ -49,9 +49,12 @@ struct vm_create_params { size_t vcp_ncpus; struct vm_mem_range vcp_memranges[VMM_MAX_MEM_RANGES]; char vcp_name[VMM_MAX_NAME_LEN]; + int vcp_sev; /* Output parameter from VMM_IOC_CREATE */ uint32_t vcp_id; + uint32_t vcp_poscbit; + uint32_t vcp_asid[VMM_MAX_VCPUS]; }; struct vm_info_result { diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index 13c315fb6..242237714 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pfvar.h,v 1.538 2024/05/13 01:15:53 jsg Exp $ */ +/* $OpenBSD: pfvar.h,v 1.539 2024/08/27 13:52:41 aisha Exp $ */ /* * Copyright (c) 2001 Daniel Hartmeier @@ -1034,10 +1034,6 @@ struct pfr_ktable { #define pfrkt_nomatch pfrkt_ts.pfrts_nomatch #define pfrkt_tzero pfrkt_ts.pfrts_tzero -RB_HEAD(pf_state_tree_ext_gwy, pf_state_key); -RB_PROTOTYPE(pf_state_tree_ext_gwy, pf_state_key, - entry_ext_gwy, pf_state_compare_ext_gwy) - RB_HEAD(pfi_ifhead, pfi_kif); /* state tables */ diff --git a/usr.bin/openssl/ts.c b/usr.bin/openssl/ts.c index dfcf5dd92..2bb35d84a 100644 --- a/usr.bin/openssl/ts.c +++ b/usr.bin/openssl/ts.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ts.c,v 1.28 2024/03/25 10:16:02 tb Exp $ */ +/* $OpenBSD: ts.c,v 1.29 2024/08/26 18:40:50 tb Exp $ */ /* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL * project 2002. */ @@ -950,7 +950,7 @@ create_response(CONF *conf, const char *section, char *queryfile, char *passin, if (!TS_CONF_set_clock_precision_digits(conf, section, resp_ctx)) goto end; - /* Setting the ordering flaf if requested. */ + /* Setting the ordering flag if requested. */ if (!TS_CONF_set_ordering(conf, section, resp_ctx)) goto end; diff --git a/usr.bin/telnet/commands.c b/usr.bin/telnet/commands.c index f91c20c3d..6aebe61d6 100644 --- a/usr.bin/telnet/commands.c +++ b/usr.bin/telnet/commands.c @@ -1,4 +1,4 @@ -/* $OpenBSD: commands.c,v 1.88 2022/12/26 19:16:03 jmc Exp $ */ +/* $OpenBSD: commands.c,v 1.89 2024/08/26 21:34:32 op Exp $ */ /* $NetBSD: commands.c,v 1.14 1996/03/24 22:03:48 jtk Exp $ */ /* @@ -358,6 +358,7 @@ send_tncmd(void (*func)(int, int), char *cmd, char *name) { char **cpp; extern char *telopts[]; + const char *errstr; int val = 0; if (isprefix(name, "help") || isprefix(name, "?")) { @@ -389,20 +390,10 @@ send_tncmd(void (*func)(int, int), char *cmd, char *name) if (cpp) { val = cpp - telopts; } else { - char *cp = name; - - while (*cp >= '0' && *cp <= '9') { - val *= 10; - val += *cp - '0'; - cp++; - } - if (*cp != 0) { - fprintf(stderr, "'%s': unknown argument ('send %s ?' for help).\r\n", - name, cmd); - return 0; - } else if (val < 0 || val > 255) { - fprintf(stderr, "'%s': bad value ('send %s ?' for help).\r\n", - name, cmd); + val = strtonum(name, 0, 255, &errstr); + if (errstr) { + fprintf(stderr, "'%s': %s ('send %s ?' for help).\r\n", + name, errstr, cmd); return 0; } } diff --git a/usr.bin/tmux/hyperlinks.c b/usr.bin/tmux/hyperlinks.c index ea0e7db73..4f3ed7348 100644 --- a/usr.bin/tmux/hyperlinks.c +++ b/usr.bin/tmux/hyperlinks.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hyperlinks.c,v 1.3 2023/06/30 13:19:32 nicm Exp $ */ +/* $OpenBSD: hyperlinks.c,v 1.4 2024/08/27 07:49:07 nicm Exp $ */ /* * Copyright (c) 2021 Will @@ -69,6 +69,7 @@ struct hyperlinks { u_int next_inner; struct hyperlinks_by_inner_tree by_inner; struct hyperlinks_by_uri_tree by_uri; + u_int references; }; static int @@ -206,6 +207,15 @@ hyperlinks_init(void) hl->next_inner = 1; RB_INIT(&hl->by_uri); RB_INIT(&hl->by_inner); + hl->references = 1; + return (hl); +} + +/* Copy hyperlink set. */ +struct hyperlinks * +hyperlinks_copy(struct hyperlinks *hl) +{ + hl->references++; return (hl); } @@ -223,6 +233,8 @@ hyperlinks_reset(struct hyperlinks *hl) void hyperlinks_free(struct hyperlinks *hl) { - hyperlinks_reset(hl); - free(hl); + if (--hl->references == 0) { + hyperlinks_reset(hl); + free(hl); + } } diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c index 3dace5bb8..7d89aee8d 100644 --- a/usr.bin/tmux/server-client.c +++ b/usr.bin/tmux/server-client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server-client.c,v 1.406 2024/08/26 07:30:46 nicm Exp $ */ +/* $OpenBSD: server-client.c,v 1.407 2024/08/27 07:25:27 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott @@ -783,8 +783,7 @@ have_event: log_debug("mouse on pane %%%u border", wp->id); m->wp = wp->id; m->w = wp->window->id; - } else - m->wp = -1; + } /* Stop dragging if needed. */ if (type != DRAG && type != WHEEL && c->tty.mouse_drag_flag != 0) { diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index 2a905aae6..9165234df 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.952 2024/08/26 07:09:34 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.954 2024/08/27 07:49:07 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott .\" @@ -14,7 +14,7 @@ .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING .\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: August 26 2024 $ +.Dd $Mdocdate: August 27 2024 $ .Dt TMUX 1 .Os .Sh NAME @@ -5498,6 +5498,7 @@ The following variables are available, where appropriate: .It Li "command_list_name" Ta "" Ta "Command name if listing commands" .It Li "command_list_usage" Ta "" Ta "Command usage if listing commands" .It Li "config_files" Ta "" Ta "List of configuration files loaded" +.It Li "copy_cursor_hyperlink" Ta "" Ta "Hyperlink under cursor in copy mode" .It Li "copy_cursor_line" Ta "" Ta "Line the cursor is on in copy mode" .It Li "copy_cursor_word" Ta "" Ta "Word under cursor in copy mode" .It Li "copy_cursor_x" Ta "" Ta "Cursor X position in copy mode" @@ -5584,6 +5585,8 @@ The following variables are available, where appropriate: .It Li "scroll_position" Ta "" Ta "Scroll position in copy mode" .It Li "scroll_region_lower" Ta "" Ta "Bottom of scroll region in pane" .It Li "scroll_region_upper" Ta "" Ta "Top of scroll region in pane" +.It Li "search_count" Ta "" Ta "Count of search results" +.It Li "search_count_partial" Ta "" Ta "1 if search count is partial count" .It Li "search_match" Ta "" Ta "Search match if any" .It Li "search_present" Ta "" Ta "1 if search started in copy mode" .It Li "selection_active" Ta "" Ta "1 if selection started and changes with the cursor in copy mode" diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index f8e7c5275..99f5343b5 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.1225 2024/08/26 07:30:46 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.1226 2024/08/27 07:49:07 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -3434,6 +3434,7 @@ u_int hyperlinks_put(struct hyperlinks *, const char *, int hyperlinks_get(struct hyperlinks *, u_int, const char **, const char **, const char **); struct hyperlinks *hyperlinks_init(void); +struct hyperlinks *hyperlinks_copy(struct hyperlinks *); void hyperlinks_reset(struct hyperlinks *); void hyperlinks_free(struct hyperlinks *); diff --git a/usr.bin/tmux/window-copy.c b/usr.bin/tmux/window-copy.c index 8d0ab7524..eb830948d 100644 --- a/usr.bin/tmux/window-copy.c +++ b/usr.bin/tmux/window-copy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window-copy.c,v 1.351 2024/08/26 07:09:34 nicm Exp $ */ +/* $OpenBSD: window-copy.c,v 1.353 2024/08/27 07:49:07 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -450,6 +450,8 @@ window_copy_init(struct window_mode_entry *wme, data->scroll_exit = args_has(args, 'e'); data->hide_position = args_has(args, 'H'); + if (base->hyperlinks != NULL) + data->screen.hyperlinks = hyperlinks_copy(base->hyperlinks); data->screen.cx = data->cx; data->screen.cy = data->cy; data->mx = data->cx; @@ -764,6 +766,18 @@ window_copy_get_line(struct window_pane *wp, u_int y) return (format_grid_line(gd, gd->hsize + y)); } +static void * +window_copy_cursor_hyperlink_cb(struct format_tree *ft) +{ + struct window_pane *wp = format_get_pane(ft); + struct window_mode_entry *wme = TAILQ_FIRST(&wp->modes); + struct window_copy_mode_data *data = wme->data; + struct grid *gd = data->screen.grid; + + return (format_grid_hyperlink(gd, data->cx, gd->hsize + data->cy, + &data->screen)); +} + static void * window_copy_cursor_word_cb(struct format_tree *ft) { @@ -825,10 +839,16 @@ window_copy_formats(struct window_mode_entry *wme, struct format_tree *ft) } format_add(ft, "search_present", "%d", data->searchmark != NULL); + if (data->searchcount != -1) { + format_add(ft, "search_count", "%d", data->searchcount); + format_add(ft, "search_count_partial", "%d", data->searchmore); + } format_add_cb(ft, "search_match", window_copy_search_match_cb); format_add_cb(ft, "copy_cursor_word", window_copy_cursor_word_cb); format_add_cb(ft, "copy_cursor_line", window_copy_cursor_line_cb); + format_add_cb(ft, "copy_cursor_hyperlink", + window_copy_cursor_hyperlink_cb); } static void @@ -2482,7 +2502,8 @@ window_copy_cmd_refresh_from_pane(struct window_copy_cmd_state *cs) screen_free(data->backing); free(data->backing); - data->backing = window_copy_clone_screen(&wp->base, &data->screen, NULL, NULL, wme->swp != wme->wp); + data->backing = window_copy_clone_screen(&wp->base, &data->screen, NULL, + NULL, wme->swp != wme->wp); window_copy_size_changed(wme); return (WINDOW_COPY_CMD_REDRAW); diff --git a/usr.sbin/radiusd/radiusd_ipcp.c b/usr.sbin/radiusd/radiusd_ipcp.c index 55c0332f9..4f0200f39 100644 --- a/usr.sbin/radiusd/radiusd_ipcp.c +++ b/usr.sbin/radiusd/radiusd_ipcp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: radiusd_ipcp.c,v 1.13 2024/08/23 01:23:50 jsg Exp $ */ +/* $OpenBSD: radiusd_ipcp.c,v 1.14 2024/08/27 06:06:14 florian Exp $ */ /* * Copyright (c) 2024 Internet Initiative Japan Inc. @@ -447,7 +447,7 @@ ipcp_config_set(void *ctx, const char *name, int argc, char * const * argv) SYNTAX_ASSERT(argc == 1 || argc == 2, "specify 1 or 2 addresses for `name-server'"); for (i = 0; i < argc; i++) { - if (inet_aton(argv[i], &ina) != 1) { + if (inet_pton(AF_INET, argv[i], &ina) != 1) { module_send_message(module->base, IMSG_NG, "Invalid IP address: %s", argv[i]); return; @@ -464,7 +464,7 @@ ipcp_config_set(void *ctx, const char *name, int argc, char * const * argv) SYNTAX_ASSERT(argc == 1 || argc == 2, "specify 1 or 2 addresses for `name-server'"); for (i = 0; i < argc; i++) { - if (inet_aton(argv[i], &ina) != 1) { + if (inet_pton(AF_INET, argv[i], &ina) != 1) { module_send_message(module->base, IMSG_NG, "Invalid IP address: %s", argv[i]); return; @@ -1735,22 +1735,22 @@ parse_address_range(const char *range) goto error; if ((sep = strchr(buf, '-')) != NULL) { *sep = '\0'; - if (inet_aton(buf, &start) != 1) + if (inet_pton(AF_INET, buf, &start) != 1) goto error; - else if (inet_aton(++sep, &end) != 1) + else if (inet_pton(AF_INET, ++sep, &end) != 1) goto error; start.s_addr = ntohl(start.s_addr); end.s_addr = ntohl(end.s_addr); } else { if ((sep = strchr(buf, '/')) != NULL) { *sep = '\0'; - if (inet_aton(buf, &start) != 1) + if (inet_pton(AF_INET, buf, &start) != 1) goto error; masklen = strtonum(++sep, 0, 32, &errstr); if (errstr != NULL) goto error; } else { - if (inet_aton(buf, &start) != 1) + if (inet_pton(AF_INET, buf, &start) != 1) goto error; masklen = 32; } diff --git a/usr.sbin/yppoll/yppoll.c b/usr.sbin/yppoll/yppoll.c index 266f88b60..169d9ade4 100644 --- a/usr.sbin/yppoll/yppoll.c +++ b/usr.sbin/yppoll/yppoll.c @@ -1,4 +1,4 @@ -/* $OpenBSD: yppoll.c,v 1.15 2015/01/16 06:40:22 deraadt Exp $ */ +/* $OpenBSD: yppoll.c,v 1.16 2024/08/27 06:03:20 florian Exp $ */ /* $NetBSD: yppoll.c,v 1.5 1996/05/13 02:46:36 thorpej Exp $ */ /* @@ -65,7 +65,7 @@ get_remote_info(char *indomain, char *inmap, char *server, int *outorder, struct sockaddr_in rsrv_sin; int rsrv_sock; CLIENT *client; - struct hostent *h; + struct addrinfo hints, *res; int r; bzero((char *)&rsrv_sin, sizeof rsrv_sin); @@ -73,14 +73,15 @@ get_remote_info(char *indomain, char *inmap, char *server, int *outorder, rsrv_sin.sin_family = AF_INET; rsrv_sock = RPC_ANYSOCK; - h = gethostbyname(server); - if (h == NULL) { - if (inet_aton(server, &rsrv_sin.sin_addr) == 0) { - fprintf(stderr, "unknown host %s\n", server); - exit(1); - } - } else - rsrv_sin.sin_addr.s_addr = *(u_int32_t *)h->h_addr; + memset(&hints, 0, sizeof(hints)); + hints.ai_family = AF_INET; + + if (getaddrinfo(server, NULL, &hints, &res) != 0) { + fprintf(stderr, "unknown host %s\n", server); + exit(1); + } + rsrv_sin.sin_addr = ((struct sockaddr_in *)res->ai_addr)->sin_addr; + freeaddrinfo(res); tv.tv_sec = 10; tv.tv_usec = 0; diff --git a/usr.sbin/ypset/ypset.c b/usr.sbin/ypset/ypset.c index ebd86597f..a31d8ecd7 100644 --- a/usr.sbin/ypset/ypset.c +++ b/usr.sbin/ypset/ypset.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ypset.c,v 1.20 2015/01/16 06:40:23 deraadt Exp $ */ +/* $OpenBSD: ypset.c,v 1.21 2024/08/27 06:04:03 florian Exp $ */ /* $NetBSD: ypset.c,v 1.8 1996/05/13 02:46:33 thorpej Exp $ */ /* @@ -54,7 +54,7 @@ bind_tohost(struct sockaddr_in *sin, char *dom, char *server) { struct ypbind_setdom ypsd; struct in_addr iaddr; - struct hostent *hp; + struct addrinfo hints, *res; struct timeval tv; CLIENT *client; int sock, port, r; @@ -66,12 +66,14 @@ bind_tohost(struct sockaddr_in *sin, char *dom, char *server) memset(&ypsd, 0, sizeof ypsd); - if (inet_aton(server, &iaddr) == 0) { - hp = gethostbyname(server); - if (hp == NULL) - errx(1, "can't find address for %s", server); - memmove(&iaddr.s_addr, hp->h_addr, sizeof(iaddr.s_addr)); - } + memset(&hints, 0, sizeof(hints)); + hints.ai_family = AF_INET; + + if (getaddrinfo(server, NULL, &hints, &res) != 0) + errx(1, "can't find address for %s", server); + iaddr = ((struct sockaddr_in *)res->ai_addr)->sin_addr; + freeaddrinfo(res); + ypsd.ypsetdom_domain = dom; bcopy(&iaddr.s_addr, &ypsd.ypsetdom_binding.ypbind_binding_addr, sizeof(ypsd.ypsetdom_binding.ypbind_binding_addr)); @@ -105,7 +107,7 @@ int main(int argc, char *argv[]) { struct sockaddr_in sin; - struct hostent *hent; + struct addrinfo hints, *res; extern char *optarg; extern int optind; char *domainname; @@ -123,13 +125,15 @@ main(int argc, char *argv[]) domainname = optarg; break; case 'h': - if (inet_aton(optarg, &sin.sin_addr) == 0) { - hent = gethostbyname(optarg); - if (hent == NULL) - errx(1, "host %s unknown\n", optarg); - bcopy(hent->h_addr, &sin.sin_addr, - sizeof(sin.sin_addr)); - } + memset(&hints, 0, sizeof(hints)); + hints.ai_family = AF_INET; + + if (getaddrinfo(optarg, NULL, &hints, &res) != 0) + errx(1, "host %s unknown\n", optarg); + + sin.sin_addr = + ((struct sockaddr_in *)res->ai_addr)->sin_addr; + freeaddrinfo(res); break; default: usage();