From 222e583e28c2e2acc7d9ad13bd8f2737a3c9a8dd Mon Sep 17 00:00:00 2001 From: purplerain Date: Wed, 29 May 2024 01:16:43 +0000 Subject: [PATCH] sync with OpenBSD -current --- distrib/sets/lists/comp/mi | 1 - lib/libcrypto/man/HMAC.3 | 17 +- lib/libcrypto/man/MD5.3 | 19 +- lib/libcrypto/man/RIPEMD160.3 | 17 +- lib/libcrypto/man/SHA1.3 | 22 +- lib/libcrypto/ossl_typ.h | 9 +- lib/libcrypto/x509/x509_lib.c | 142 ++-- lib/libssl/ssl.h | 7 +- lib/libz/compress.3 | 10 +- regress/lib/libcrypto/asn1/asn1time.c | 30 +- regress/lib/libcrypto/x509/Makefile | 4 +- .../lib/libcrypto/x509/x509_extensions_test.c | 655 ++++++++++++++++ share/man/man5/changelist.5 | 6 +- share/man/man5/python-module.5 | 19 +- sys/arch/amd64/amd64/acpi_machdep.c | 5 +- sys/arch/amd64/amd64/intr.c | 52 +- sys/arch/amd64/include/intr.h | 4 +- sys/arch/amd64/include/intrdefs.h | 3 +- sys/arch/arm64/arm64/cpu.c | 39 +- sys/arch/arm64/arm64/intr.c | 6 +- sys/arch/arm64/arm64/pmap.c | 27 +- sys/arch/arm64/dev/apm.c | 7 +- sys/arch/arm64/include/armreg.h | 32 +- sys/arch/i386/i386/machdep.c | 16 +- sys/arch/i386/include/intr.h | 4 +- sys/dev/acpi/acpi_x86.c | 15 +- sys/dev/ata/ata.c | 9 +- sys/dev/ata/ata_wdc.c | 6 +- sys/dev/ata/atascsi.c | 5 +- sys/dev/ata/wd.c | 6 +- sys/dev/atapiscsi/atapiscsi.c | 12 +- sys/dev/fdt/bcm2835_mbox.c | 11 +- sys/dev/fdt/dwmshc.c | 2 +- sys/dev/fdt/fanpwr.c | 2 +- sys/dev/fdt/rkpmic.c | 191 +++-- sys/dev/i2c/pca9532.c | 10 +- sys/dev/ic/ahci.c | 6 +- sys/dev/ic/nvme.c | 17 +- sys/dev/ic/qwx.c | 715 ++++++++++++++++-- sys/dev/ic/qwxvar.h | 38 +- sys/dev/ic/ufshci.c | 26 +- sys/dev/isa/ad1848.c | 3 +- sys/dev/isa/addcom_isa.c | 17 +- sys/dev/isa/boca.c | 18 +- sys/dev/isa/cs4231var.h | 51 -- sys/dev/isa/gus.c | 3 +- sys/dev/isa/gus_isa.c | 3 +- sys/dev/isa/gus_isapnp.c | 3 +- sys/dev/isa/hsq.c | 18 +- sys/dev/mii/txphy.c | 3 +- sys/dev/mii/xmphy.c | 4 +- sys/dev/mii/xmphyreg.h | 50 -- sys/dev/pci/drm/amd/amdgpu/amdgpu_ras.c | 3 + sys/dev/pci/drm/amd/display/dc/dsc/dc_dsc.c | 7 +- sys/dev/pci/if_qwx_pci.c | 25 +- sys/dev/pcmcia/aic_pcmcia.c | 3 +- sys/dev/pcmcia/cfxga.c | 6 +- sys/dev/pcmcia/com_pcmcia.c | 9 +- sys/dev/pcmcia/if_an_pcmcia.c | 5 +- sys/dev/pcmcia/if_ep_pcmcia.c | 15 +- sys/dev/pcmcia/if_malo.c | 5 +- sys/dev/pcmcia/if_ne_pcmcia.c | 5 +- sys/dev/pcmcia/if_sm_pcmcia.c | 14 +- sys/dev/pcmcia/if_wi_pcmcia.c | 5 +- sys/dev/pcmcia/if_xe.c | 4 +- sys/dev/pcmcia/wdc_pcmcia.c | 13 +- sys/dev/pv/if_vio.c | 6 +- sys/dev/usb/ums.c | 6 +- sys/dev/usb/umt.c | 6 +- sys/kern/subr_suspend.c | 8 +- sys/sys/device.h | 3 +- sys/sys/systm.h | 3 +- sys/uvm/uvm_swap_encrypt.h | 3 +- usr.bin/openssl/Makefile | 4 +- usr.bin/openssl/x509.c | 28 +- usr.bin/ssh/auth2-methods.c | 1 - usr.bin/ssh/ssh.1 | 6 +- usr.sbin/smtpd/smtpd.h | 3 +- usr.sbin/smtpd/table.c | 5 +- usr.sbin/smtpd/table_proc.c | 3 +- 80 files changed, 1944 insertions(+), 657 deletions(-) create mode 100644 regress/lib/libcrypto/x509/x509_extensions_test.c delete mode 100644 sys/dev/isa/cs4231var.h delete mode 100644 sys/dev/mii/xmphyreg.h diff --git a/distrib/sets/lists/comp/mi b/distrib/sets/lists/comp/mi index 325ca8133..187a2d1df 100644 --- a/distrib/sets/lists/comp/mi +++ b/distrib/sets/lists/comp/mi @@ -486,7 +486,6 @@ ./usr/include/dev/mii/tlphyvar.h ./usr/include/dev/mii/tqphyreg.h ./usr/include/dev/mii/urlphyreg.h -./usr/include/dev/mii/xmphyreg.h ./usr/include/dev/mulaw.h ./usr/include/dev/ofw ./usr/include/dev/ofw/fdt.h diff --git a/lib/libcrypto/man/HMAC.3 b/lib/libcrypto/man/HMAC.3 index a0af270c4..fa853bb4a 100644 --- a/lib/libcrypto/man/HMAC.3 +++ b/lib/libcrypto/man/HMAC.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: HMAC.3,v 1.20 2022/01/25 17:55:39 tb Exp $ +.\" $OpenBSD: HMAC.3,v 1.21 2024/05/26 09:54:16 tb Exp $ .\" full merge up to: OpenSSL crypto/hmac a528d4f0 Oct 27 13:40:11 2015 -0400 .\" selective merge up to: OpenSSL man3/HMAC b3696a55 Sep 2 09:35:50 2017 -0400 .\" @@ -52,7 +52,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: January 25 2022 $ +.Dd $Mdocdate: May 26 2024 $ .Dt HMAC 3 .Os .Sh NAME @@ -160,11 +160,6 @@ which must have space for the output of the hash function, which is no more than .Dv EVP_MAX_MD_SIZE bytes. -If -.Fa md -is -.Dv NULL , -the digest is placed in a static array, which is not thread safe. The size of the output is placed in .Fa md_len , unless it is @@ -329,3 +324,11 @@ and .Fn HMAC_CTX_get_md first appeared in OpenSSL 1.1.0 and have been available since .Ox 6.3 . +.Sh CAVEATS +Other implementations allow +.Fa md +in +.Fn HMAC +to be +.Dv NULL +and return a static array, which is not thread safe. diff --git a/lib/libcrypto/man/MD5.3 b/lib/libcrypto/man/MD5.3 index 1e4a62859..01e715f40 100644 --- a/lib/libcrypto/man/MD5.3 +++ b/lib/libcrypto/man/MD5.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: MD5.3,v 1.8 2018/03/27 17:35:50 schwarze Exp $ +.\" $OpenBSD: MD5.3,v 1.9 2024/05/26 09:54:16 tb Exp $ .\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 .\" .\" This file was written by Ulf Moeller and @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 27 2018 $ +.Dd $Mdocdate: May 26 2024 $ .Dt MD5 3 .Os .Sh NAME @@ -123,11 +123,6 @@ and place it in which must have space for .Dv MD4_DIGEST_LENGTH No == Dv MD5_DIGEST_LENGTH No == 16 bytes of output. -If -.Fa md -is -.Dv NULL , -the digest is placed in a static array. .Pp The following functions may be used if the message is not completely stored in memory: @@ -194,3 +189,13 @@ and .Fn MD4_Final first appeared in OpenSSL 0.9.6 and have been available since .Ox 2.9 . +.Sh CAVEATS +Other implementations allow +.Fa md +in +.Fn MD4 +and +.Fn MD5 +to be +.Dv NULL +and return a static array, which is not thread safe. diff --git a/lib/libcrypto/man/RIPEMD160.3 b/lib/libcrypto/man/RIPEMD160.3 index 6fadb56ce..43c669403 100644 --- a/lib/libcrypto/man/RIPEMD160.3 +++ b/lib/libcrypto/man/RIPEMD160.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: RIPEMD160.3,v 1.7 2019/08/25 15:17:19 schwarze Exp $ +.\" $OpenBSD: RIPEMD160.3,v 1.8 2024/05/26 09:54:16 tb Exp $ .\" full merge up to: OpenSSL 72a7a702 Feb 26 14:05:09 2019 +0000 .\" .\" This file was written by Ulf Moeller . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: August 25 2019 $ +.Dd $Mdocdate: May 26 2024 $ .Dt RIPEMD160 3 .Os .Sh NAME @@ -93,11 +93,6 @@ and places it in which must have space for .Dv RIPEMD160_DIGEST_LENGTH == 20 bytes of output. -If -.Fa md -is -.Dv NULL , -the digest is placed in a static array. .Pp The following functions may be used if the message is not completely stored in memory: @@ -149,3 +144,11 @@ and .Fn RIPEMD160_Final first appeared in SSLeay 0.9.0 and have been available since .Ox 2.4 . +.Sh CAVEATS +Other implementations allow +.Fa md +in +.Fn RIPEMD160 +to be +.Dv NULL +and return a static array, which is not thread safe. diff --git a/lib/libcrypto/man/SHA1.3 b/lib/libcrypto/man/SHA1.3 index f5061e56e..722c10b14 100644 --- a/lib/libcrypto/man/SHA1.3 +++ b/lib/libcrypto/man/SHA1.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SHA1.3,v 1.7 2018/03/27 17:35:50 schwarze Exp $ +.\" $OpenBSD: SHA1.3,v 1.8 2024/05/26 09:54:16 tb Exp $ .\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 .\" .\" This file was written by Ulf Moeller and @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 27 2018 $ +.Dd $Mdocdate: May 26 2024 $ .Dt SHA1 3 .Os .Sh NAME @@ -195,11 +195,6 @@ and places it in which must have space for .Dv SHA_DIGEST_LENGTH == 20 bytes of output. -If -.Fa md -is -.Dv NULL , -the digest is placed in a static array, which is not thread safe. .Pp The following functions may be used if the message is not completely stored in memory: @@ -274,3 +269,16 @@ first appeared in SSLeay 0.5.1 and have been available since The other functions first appeared in OpenSSL 0.9.8 and have been available since .Ox 4.5 . +.Sh CAVEATS +Other implementations allow +.Fa md +in +.Fn SHA1 , +.Fn SHA224 , +.Fn SHA256 , +.Fn SHA384 , +and +.Fn SHA512 +to be +.Dv NULL +and return a static array, which is not thread safe. diff --git a/lib/libcrypto/ossl_typ.h b/lib/libcrypto/ossl_typ.h index 237a8d967..2d8e6674d 100644 --- a/lib/libcrypto/ossl_typ.h +++ b/lib/libcrypto/ossl_typ.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ossl_typ.h,v 1.30 2023/08/11 05:10:35 tb Exp $ */ +/* $OpenBSD: ossl_typ.h,v 1.31 2024/05/27 09:12:32 jsg Exp $ */ /* ==================================================================== * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. * @@ -94,9 +94,6 @@ typedef struct bn_gencb_st BN_GENCB; typedef struct bio_st BIO; typedef struct buf_mem_st BUF_MEM; -typedef struct comp_ctx_st COMP_CTX; -typedef struct comp_method_st COMP_METHOD; - typedef struct evp_cipher_st EVP_CIPHER; typedef struct evp_cipher_ctx_st EVP_CIPHER_CTX; typedef struct evp_md_st EVP_MD; @@ -130,7 +127,6 @@ typedef struct rand_meth_st RAND_METHOD; typedef struct x509_st X509; typedef struct X509_algor_st X509_ALGOR; typedef struct X509_crl_st X509_CRL; -typedef struct x509_crl_method_st X509_CRL_METHOD; typedef struct x509_revoked_st X509_REVOKED; typedef struct X509_name_st X509_NAME; typedef struct X509_pubkey_st X509_PUBKEY; @@ -147,9 +143,6 @@ typedef struct pkcs8_priv_key_info_st PKCS8_PRIV_KEY_INFO; typedef struct v3_ext_ctx X509V3_CTX; typedef struct conf_st CONF; -typedef struct store_st STORE; -typedef struct store_method_st STORE_METHOD; - typedef struct ui_st UI; typedef struct ui_method_st UI_METHOD; diff --git a/lib/libcrypto/x509/x509_lib.c b/lib/libcrypto/x509/x509_lib.c index 578f55ec5..434787588 100644 --- a/lib/libcrypto/x509/x509_lib.c +++ b/lib/libcrypto/x509/x509_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_lib.c,v 1.20 2024/05/11 18:59:39 tb Exp $ */ +/* $OpenBSD: x509_lib.c,v 1.21 2024/05/28 15:40:38 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -244,85 +244,117 @@ X509V3_get_d2i(const STACK_OF(X509_EXTENSION) *x, int nid, int *crit, int *idx) } LCRYPTO_ALIAS(X509V3_get_d2i); -/* This function is a general extension append, replace and delete utility. - * The precise operation is governed by the 'flags' value. The 'crit' and - * 'value' arguments (if relevant) are the extensions internal structure. - */ - int X509V3_add1_i2d(STACK_OF(X509_EXTENSION) **x, int nid, void *value, int crit, unsigned long flags) { - int extidx = -1; - int errcode; - X509_EXTENSION *ext, *extmp; - unsigned long ext_op = flags & X509V3_ADD_OP_MASK; + STACK_OF(X509_EXTENSION) *exts = *x; + X509_EXTENSION *ext = NULL; + X509_EXTENSION *existing; + int extidx; + int errcode = 0; + int ret = 0; - /* If appending we don't care if it exists, otherwise - * look for existing extension. - */ - if (ext_op != X509V3_ADD_APPEND) - extidx = X509v3_get_ext_by_NID(*x, nid, -1); + /* See if the extension already exists. */ + extidx = X509v3_get_ext_by_NID(*x, nid, -1); - /* See if extension exists */ - if (extidx >= 0) { - /* If keep existing, nothing to do */ - if (ext_op == X509V3_ADD_KEEP_EXISTING) - return 1; - /* If default then its an error */ - if (ext_op == X509V3_ADD_DEFAULT) { + switch (flags & X509V3_ADD_OP_MASK) { + case X509V3_ADD_DEFAULT: + /* If the extension exists, adding another one is an error. */ + if (extidx >= 0) { errcode = X509V3_R_EXTENSION_EXISTS; goto err; } - /* If delete, just delete it */ - if (ext_op == X509V3_ADD_DELETE) { - if ((extmp = sk_X509_EXTENSION_delete(*x, extidx)) == NULL) - return -1; - X509_EXTENSION_free(extmp); - return 1; - } - } else { - /* If replace existing or delete, error since - * extension must exist + break; + case X509V3_ADD_APPEND: + /* + * XXX - Total misfeature. If the extension exists, appending + * another one will invalidate the certificate. Unfortunately + * things use this, in particular Viktor's DANE code. */ - if ((ext_op == X509V3_ADD_REPLACE_EXISTING) || - (ext_op == X509V3_ADD_DELETE)) { + /* Pretend the extension didn't exist and append the new one. */ + extidx = -1; + break; + case X509V3_ADD_REPLACE: + /* Replace existing extension, otherwise append the new one. */ + break; + case X509V3_ADD_REPLACE_EXISTING: + /* Can't replace a non-existent extension. */ + if (extidx < 0) { errcode = X509V3_R_EXTENSION_NOT_FOUND; goto err; } + break; + case X509V3_ADD_KEEP_EXISTING: + /* If the extension exists, there's nothing to do. */ + if (extidx >= 0) + goto done; + break; + case X509V3_ADD_DELETE: + /* Can't delete a non-existent extension. */ + if (extidx < 0) { + errcode = X509V3_R_EXTENSION_NOT_FOUND; + goto err; + } + if ((existing = sk_X509_EXTENSION_delete(*x, extidx)) == NULL) { + ret = -1; + goto err; + } + X509_EXTENSION_free(existing); + existing = NULL; + goto done; + default: + errcode = X509V3_R_UNSUPPORTED_OPTION; /* XXX */ + ret = -1; + goto err; } - /* If we get this far then we have to create an extension: - * could have some flags for alternative encoding schemes... - */ - - ext = X509V3_EXT_i2d(nid, crit, value); - - if (!ext) { + if ((ext = X509V3_EXT_i2d(nid, crit, value)) == NULL) { X509V3error(X509V3_R_ERROR_CREATING_EXTENSION); - return 0; + goto err; } - /* If extension exists replace it.. */ + /* From here, errors are fatal. */ + ret = -1; + + /* If extension exists, replace it. */ if (extidx >= 0) { - extmp = sk_X509_EXTENSION_value(*x, extidx); - X509_EXTENSION_free(extmp); - if (!sk_X509_EXTENSION_set(*x, extidx, ext)) - return -1; - return 1; + existing = sk_X509_EXTENSION_value(*x, extidx); + X509_EXTENSION_free(existing); + existing = NULL; + if (sk_X509_EXTENSION_set(*x, extidx, ext) == NULL) { + /* + * XXX - Can't happen. If it did happen, |existing| is + * now a freed pointer. Nothing we can do here. + */ + goto err; + } + goto done; } - if (!*x && !(*x = sk_X509_EXTENSION_new_null())) - return -1; - if (!sk_X509_EXTENSION_push(*x, ext)) - return -1; + if (exts == NULL) + exts = sk_X509_EXTENSION_new_null(); + if (exts == NULL) + goto err; + if (!sk_X509_EXTENSION_push(exts, ext)) + goto err; + ext = NULL; + + *x = exts; + + done: return 1; -err: - if (!(flags & X509V3_ADD_SILENT)) + err: + if ((flags & X509V3_ADD_SILENT) == 0 && errcode != 0) X509V3error(errcode); - return 0; + + if (exts != *x) + sk_X509_EXTENSION_pop_free(exts, X509_EXTENSION_free); + X509_EXTENSION_free(ext); + + return ret; } LCRYPTO_ALIAS(X509V3_add1_i2d); diff --git a/lib/libssl/ssl.h b/lib/libssl/ssl.h index 9a5f8d025..22d480986 100644 --- a/lib/libssl/ssl.h +++ b/lib/libssl/ssl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl.h,v 1.236 2024/03/02 11:48:55 tb Exp $ */ +/* $OpenBSD: ssl.h,v 1.237 2024/05/27 09:12:31 jsg Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -510,11 +510,6 @@ int SSL_CTX_set_num_tickets(SSL_CTX *ctx, size_t num_tickets); size_t SSL_CTX_get_num_tickets(const SSL_CTX *ctx); STACK_OF(X509) *SSL_get0_verified_chain(const SSL *s); -#ifndef LIBRESSL_INTERNAL -struct ssl_aead_ctx_st; -typedef struct ssl_aead_ctx_st SSL_AEAD_CTX; -#endif - #define SSL_MAX_CERT_LIST_DEFAULT 1024*100 /* 100k max cert list :-) */ #define SSL_SESSION_CACHE_MAX_SIZE_DEFAULT (1024*20) diff --git a/lib/libz/compress.3 b/lib/libz/compress.3 index 73d21d573..2c4ec47b3 100644 --- a/lib/libz/compress.3 +++ b/lib/libz/compress.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: compress.3,v 1.27 2024/02/07 20:51:38 tb Exp $ +.\" $OpenBSD: compress.3,v 1.28 2024/05/28 13:42:06 tb Exp $ .\" .\" Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler .\" @@ -21,9 +21,7 @@ .\" Converted to mdoc format for the OpenBSD project .\" by Jason McIntyre .\" -.\" This page corresponds to zlib version 1.2.3 -.\" -.Dd $Mdocdate: February 7 2024 $ +.Dd $Mdocdate: May 28 2024 $ .Dt COMPRESS 3 .Os .Sh NAME @@ -256,10 +254,6 @@ Checksum functions .Fn crc32_combine_gen "z_off_t len2" .Fn crc32_combine_op "uLong crc1" "uLong crc2" "uLong op" .Sh DESCRIPTION -This manual page describes the -.Nm zlib -general purpose compression library, version 1.2.11. -.Pp The .Nm zlib compression library provides in-memory compression and decompression functions, diff --git a/regress/lib/libcrypto/asn1/asn1time.c b/regress/lib/libcrypto/asn1/asn1time.c index 95c5d24db..b11a89230 100644 --- a/regress/lib/libcrypto/asn1/asn1time.c +++ b/regress/lib/libcrypto/asn1/asn1time.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asn1time.c,v 1.28 2024/05/25 12:47:25 tb Exp $ */ +/* $OpenBSD: asn1time.c,v 1.29 2024/05/25 18:59:03 tb Exp $ */ /* * Copyright (c) 2015 Joel Sing * Copyright (c) 2024 Google Inc. @@ -121,6 +121,18 @@ static const struct asn1_time_test asn1_gentime_tests[] = { 0x5a, }, }, + { + /* 1 second after the 32-bit epoch wraps. */ + .str = "20380119031408Z", + .data = "20380119031408Z", + .time = 2147483648LL, + .der = { + 0x18, 0x0f, 0x32, 0x30, 0x33, 0x38, 0x30, 0x31, + 0x31, 0x39, 0x30, 0x33, 0x31, 0x34, 0x30, 0x38, + 0x5a, + }, + + }, }; static const struct asn1_time_test asn1_utctime_tests[] = { @@ -280,6 +292,7 @@ asn1_gentime_test(int test_no, const struct asn1_time_test *att) const unsigned char *der; unsigned char *p = NULL; ASN1_GENERALIZEDTIME *gt = NULL; + time_t t; int failure = 1; int len; struct tm tm; @@ -307,11 +320,18 @@ asn1_gentime_test(int test_no, const struct asn1_time_test *att) goto done; } - if (timegm(&tm) != att->time) { + if (!OPENSSL_timegm(&tm, &t)) { /* things with crappy time_t should die in fire */ - int64_t a = timegm(&tm); - int64_t b = att->time; - fprintf(stderr, "FAIL: test %d - times don't match, expected %lld got %lld\n", + fprintf(stderr, "FAIL: test %d - OPENSSL_timegm failed\n", + test_no); + } + + if (t != att->time) { + /* things with crappy time_t should die in fire */ + int64_t a = t, b = att->time; + + fprintf(stderr, "FAIL: test %d - times don't match, " + "expected %lld got %lld\n", test_no, (long long)b, (long long)a); goto done; } diff --git a/regress/lib/libcrypto/x509/Makefile b/regress/lib/libcrypto/x509/Makefile index 283e3379d..5a90facb2 100644 --- a/regress/lib/libcrypto/x509/Makefile +++ b/regress/lib/libcrypto/x509/Makefile @@ -1,7 +1,7 @@ -# $OpenBSD: Makefile,v 1.21 2023/04/30 05:02:59 tb Exp $ +# $OpenBSD: Makefile,v 1.22 2024/05/28 15:33:35 tb Exp $ PROGS = constraints verify x509attribute x509name x509req_ext callback -PROGS += expirecallback callbackfailures x509_asn1 +PROGS += expirecallback callbackfailures x509_asn1 x509_extensions_test LDADD = -lcrypto DPADD = ${LIBCRYPTO} diff --git a/regress/lib/libcrypto/x509/x509_extensions_test.c b/regress/lib/libcrypto/x509/x509_extensions_test.c new file mode 100644 index 000000000..9005333fe --- /dev/null +++ b/regress/lib/libcrypto/x509/x509_extensions_test.c @@ -0,0 +1,655 @@ +/* $OpenBSD: x509_extensions_test.c,v 1.2 2024/05/28 15:42:09 tb Exp $ */ + +/* + * Copyright (c) 2024 Theo Buehler + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include + +#include +#include +#include +#include + +#define ASN1_BOOLEAN_TRUE 0xff +#define ASN1_BOOLEAN_FALSE 0x00 + +static BASIC_CONSTRAINTS * +create_basic_constraints(int ca) +{ + BASIC_CONSTRAINTS *bc; + + if ((bc = BASIC_CONSTRAINTS_new()) == NULL) + errx(1, "BASIC_CONSTRAINTS_new"); + + bc->ca = ca ? ASN1_BOOLEAN_TRUE : ASN1_BOOLEAN_FALSE; + + return bc; +} + +static int +test_x509v3_add1_i2d_empty_stack(STACK_OF(X509_EXTENSION) **extensions) +{ + unsigned long error; + int op, got; + int nid = NID_basic_constraints; + int failed = 1; + + if (X509v3_get_ext_count(*extensions) != 0) { + fprintf(stderr, "%s: FAIL: need empty stack\n", __func__); + goto err; + } + + ERR_clear_error(); + + op = X509V3_ADD_REPLACE_EXISTING; + + if ((got = X509V3_add1_i2d(extensions, nid, NULL, 0, op)) != 0) { + fprintf(stderr, "%s: FAIL: X509V3_ADD_REPLACE_EXISTING " + "want %d, got %d.\n", __func__, 0, got); + goto err; + } + + error = ERR_get_error(); + if (ERR_GET_REASON(error) != X509V3_R_EXTENSION_NOT_FOUND) { + fprintf(stderr, "%s: FAIL: X509V3_ADD_REPLACE_EXISTING " + "pushed %d for empty stack, want %d.\n", __func__, + ERR_GET_REASON(error), X509V3_R_EXTENSION_NOT_FOUND); + goto err; + } + if ((error = ERR_get_error()) != 0) { + fprintf(stderr, "%s: FAIL: X509V3_ADD_REPLACE_EXISTING " + "expected exactly one error.\n", __func__); + goto err; + } + + op = X509V3_ADD_REPLACE_EXISTING | X509V3_ADD_SILENT; + + if ((got = X509V3_add1_i2d(extensions, nid, NULL, 0, op)) != 0) { + fprintf(stderr, "%s: FAIL: silent X509V3_ADD_REPLACE_EXISTING " + "want %d, got %d.\n", __func__, 0, got); + goto err; + } + if ((error = ERR_get_error()) != 0) { + fprintf(stderr, "%s: FAIL: silent X509V3_ADD_REPLACE_EXISTING " + "added error %d, want %d.\n", __func__, + ERR_GET_REASON(error), 0); + goto err; + } + + op = X509V3_ADD_DELETE; + if ((got = X509V3_add1_i2d(extensions, nid, NULL, 0, op)) != 0) { + fprintf(stderr, "%s: FAIL: X509V3_ADD_DELETE " + "want %d, got %d.\n", __func__, 0, got); + goto err; + } + + error = ERR_get_error(); + if (ERR_GET_REASON(error) != X509V3_R_EXTENSION_NOT_FOUND) { + fprintf(stderr, "%s: FAIL: X509V3_ADD_DELETE " + "pushed %d for empty stack, want %d.\n", __func__, + ERR_GET_REASON(error), X509V3_R_EXTENSION_NOT_FOUND); + goto err; + } + + if ((error = ERR_get_error()) != 0) { + fprintf(stderr, "%s: FAIL: X509V3_ADD_DELETE " + "expected exactly one error.\n", __func__); + goto err; + } + + failed = 0; + + err: + + return failed; +} + +static int +test_x509v3_add1_i2d_single_nid(STACK_OF(X509_EXTENSION) **extensions) +{ + BASIC_CONSTRAINTS *bc = NULL; + unsigned long error; + int crit, got, nid, op; + int failed = 1; + + if (X509v3_get_ext_count(*extensions) != 0) { + fprintf(stderr, "%s: FAIL: need an empty stack.\n", __func__); + goto err; + } + + /* + * Add basic ca constraints. + */ + + nid = NID_basic_constraints; + bc = create_basic_constraints(1); + op = X509V3_ADD_DEFAULT; + if ((got = X509V3_add1_i2d(extensions, nid, bc, 1, op)) != 1) { + fprintf(stderr, "%s: FAIL: X509V3_ADD_DEFAULT failed to add " + "basic constraints to empty stack: want %d, got %d.\n", + __func__, 1, got); + goto err; + } + BASIC_CONSTRAINTS_free(bc); + bc = NULL; + + if ((got = X509v3_get_ext_count(*extensions)) != 1) { + fprintf(stderr, "%s: FAIL: expected 1 extension, have %d.\n", + __func__, got); + goto err; + } + + /* + * Can't delete or replace non-existent extension. + */ + + nid = NID_policy_constraints; + op = X509V3_ADD_DELETE; + if ((got = X509V3_add1_i2d(extensions, nid, NULL, 0, op)) != 0) { + fprintf(stderr, "%s: FAIL: X509V3_ADD_DELETE non-existent " + "want %d, got %d,\n", __func__, 0, got); + goto err; + } + nid = NID_policy_constraints; + op = X509V3_ADD_REPLACE_EXISTING; + if ((got = X509V3_add1_i2d(extensions, nid, NULL, 0, op)) != 0) { + fprintf(stderr, "%s: FAIL: X509V3_ADD_REPLACE_EXISTING non-existent " + "want %d, got %d.\n", __func__, 0, got); + goto err; + } + + /* + * X509V3_ADD_DEFAULT refuses to add second basic constraints extension. + */ + + ERR_clear_error(); + + nid = NID_basic_constraints; + bc = create_basic_constraints(0); + op = X509V3_ADD_DEFAULT; + if ((got = X509V3_add1_i2d(extensions, nid, bc, 1, op)) != 0) { + fprintf(stderr, "%s: FAIL: X509V3_ADD_DEFAULT second constraints " + "want %d, got %d.\n", __func__, 0, got); + goto err; + } + BASIC_CONSTRAINTS_free(bc); + bc = NULL; + + error = ERR_get_error(); + if (ERR_GET_REASON(error) != X509V3_R_EXTENSION_EXISTS) { + fprintf(stderr, "%s: FAIL: X509V3_ADD_DEFAULT second constraints " + " pushed %d, want %d.\n", __func__, + ERR_GET_REASON(error), X509V3_R_EXTENSION_EXISTS); + goto err; + } + + if ((got = X509v3_get_ext_count(*extensions)) != 1) { + fprintf(stderr, "%s: FAIL: X509V3_ADD_DEFAULT second contraints " + "expected 1 extension, have %d.\n", __func__, got); + goto err; + } + + /* + * We can replace existing basic constraints using X509V3_ADD_REPLACE. + */ + + nid = NID_basic_constraints; + bc = create_basic_constraints(0); + op = X509V3_ADD_REPLACE; + if ((got = X509V3_add1_i2d(extensions, nid, bc, 1, op)) != 1) { + fprintf(stderr, "%s: FAIL: X509V3_ADD_REPLACE " + "want %d, got %d.\n", __func__, 1, got); + goto err; + } + BASIC_CONSTRAINTS_free(bc); + bc = NULL; + + if ((got = X509v3_get_ext_count(*extensions)) != 1) { + fprintf(stderr, "%s: FAIL: X509V3_ADD_REPLACE " + "expected 1 extension, have %d.\n", __func__, got); + goto err; + } + + /* Check that the extension was actually replaced. */ + nid = NID_basic_constraints; + if ((bc = X509V3_get_d2i(*extensions, nid, &crit, NULL)) == NULL) { + if (crit != -1) + errx(1, "X509V3_get_d2i"); + fprintf(stderr, "%s: FAIL: X509V3_ADD_REPLACE " + "expected basic constraints\n", __func__); + goto err; + } + if (bc->ca != ASN1_BOOLEAN_FALSE) { + fprintf(stderr, "%s: FAIL: X509V3_ADD_REPLACE " + "expected cA = false in basic constraints\n", __func__); + goto err; + } + BASIC_CONSTRAINTS_free(bc); + bc = NULL; + + /* + * X509V3_ADD_KEEP_EXISTING existing does what it is supposed to do + * if basic constraints are already present. + */ + + nid = NID_basic_constraints; + bc = create_basic_constraints(1); + op = X509V3_ADD_KEEP_EXISTING; + if ((got = X509V3_add1_i2d(extensions, nid, bc, 1, op)) != 1) { + fprintf(stderr, "%s: FAIL: X509V3_ADD_KEEP_EXISTING " + "want %d, got %d.\n", __func__, 1, got); + goto err; + } + BASIC_CONSTRAINTS_free(bc); + bc = NULL; + + /* + * Check we still have non-ca basic constraints. + */ + + nid = NID_basic_constraints; + if ((bc = X509V3_get_d2i(*extensions, nid, &crit, NULL)) == NULL) { + if (crit != -1) + errx(1, "X509V3_get_d2i"); + fprintf(stderr, "%s: FAIL: X509V3_ADD_KEEP_EXISTING " + "expected basic constraints\n", __func__); + goto err; + } + if (bc->ca != ASN1_BOOLEAN_FALSE) { + fprintf(stderr, "%s: FAIL: X509V3_ADD_KEEP_EXISTING " + "expected non-ca basic constraints\n", __func__); + goto err; + } + BASIC_CONSTRAINTS_free(bc); + bc = NULL; + + /* + * X509V3_ADD_REPLACE_EXISTING also works. + */ + + nid = NID_basic_constraints; + bc = create_basic_constraints(1); + op = X509V3_ADD_REPLACE_EXISTING; + if ((got = X509V3_add1_i2d(extensions, nid, bc, 1, op)) != 1) { + fprintf(stderr, "%s: FAIL: X509V3_ADD_REPLACE_EXISTING " + "want %d, got %d.\n", __func__, 1, got); + goto err; + } + BASIC_CONSTRAINTS_free(bc); + bc = NULL; + + /* + * Check we again have ca basic constraints. + */ + + nid = NID_basic_constraints; + if ((bc = X509V3_get_d2i(*extensions, nid, &crit, NULL)) == NULL) { + if (crit != -1) + errx(1, "X509V3_get_d2i"); + fprintf(stderr, "%s: FAIL: X509V3_ADD_REPLACE_EXISTING " + "expected basic constraints\n", __func__); + goto err; + } + if (bc->ca != ASN1_BOOLEAN_TRUE) { + fprintf(stderr, "%s: FAIL: X509V3_ADD_REPLACE_EXISTING " + "expected ca basic constraints\n", __func__); + goto err; + } + BASIC_CONSTRAINTS_free(bc); + bc = NULL; + + /* + * And X509V3_ADD_DELETE now works. + */ + + nid = NID_basic_constraints; + op = X509V3_ADD_DELETE; + if ((got = X509V3_add1_i2d(extensions, nid, NULL, 0, op)) != 1) { + fprintf(stderr, "%s: FAIL: X509V3_ADD_DELETE " + "want %d, got %d.\n", __func__, 0, got); + goto err; + } + + if ((got = X509v3_get_ext_count(*extensions)) != 0) { + fprintf(stderr, "%s: FAIL: X509V3_ADD_DELETE " + "expected 0 extensions, have %d.\n", __func__, got); + goto err; + } + + /* + * X509V3_ADD_REPLACE adds the extension to empty stack as it should. + */ + + nid = NID_basic_constraints; + bc = create_basic_constraints(0); + op = X509V3_ADD_REPLACE; + if ((got = X509V3_add1_i2d(extensions, nid, bc, 1, op)) != 1) { + fprintf(stderr, "%s: FAIL: X509V3_ADD_REPLACE on empty stack " + "want %d, got %d.\n", __func__, 1, got); + goto err; + } + BASIC_CONSTRAINTS_free(bc); + bc = NULL; + + if ((got = X509v3_get_ext_count(*extensions)) != 1) { + fprintf(stderr, "%s: FAIL: X509V3_ADD_REPLACE " + "expected 1 extension, have %d.\n", __func__, got); + goto err; + } + + /* + * And X509V3_ADD_DELETE works again. + */ + + nid = NID_basic_constraints; + op = X509V3_ADD_DELETE; + if ((got = X509V3_add1_i2d(extensions, nid, NULL, 0, op)) != 1) { + fprintf(stderr, "%s: FAIL: X509V3_ADD_DELETE after add replace " + "want %d, got %d.\n", __func__, 0, got); + goto err; + } + + if ((got = X509v3_get_ext_count(*extensions)) != 0) { + fprintf(stderr, "%s: FAIL: X509V3_ADD_DELETE " + "expected 0 extensions, have %d.\n", __func__, got); + goto err; + } + + failed = 0; + + err: + BASIC_CONSTRAINTS_free(bc); + + return failed; +} + +static int +test_x509v3_add1_i2d_add_append(STACK_OF(X509_EXTENSION) **extensions) +{ + BASIC_CONSTRAINTS *bc = NULL; + int crit, got, idx, nid, op; + int failed = 1; + + if (X509v3_get_ext_count(*extensions) != 0) { + fprintf(stderr, "%s: FAIL: need empty stack.\n", __func__); + goto err; + } + + /* + * Let the toolkit add two basic constraints extensions. + */ + + nid = NID_basic_constraints; + bc = create_basic_constraints(1); + crit = 1; + op = X509V3_ADD_APPEND; + if ((got = X509V3_add1_i2d(extensions, nid, bc, crit, op)) != 1) { + fprintf(stderr, "%s: FAIL: first X509V3_ADD_APPEND " + "want %d, got %d.\n", __func__, 0, got); + goto err; + } + BASIC_CONSTRAINTS_free(bc); + bc = NULL; + + nid = NID_basic_constraints; + bc = create_basic_constraints(0); + crit = 1; + op = X509V3_ADD_APPEND; + if ((got = X509V3_add1_i2d(extensions, nid, bc, crit, op)) != 1) { + fprintf(stderr, "%s: FAIL: second X509V3_ADD_APPEND " + "want %d, got %d.\n", __func__, 0, got); + goto err; + } + BASIC_CONSTRAINTS_free(bc); + bc = NULL; + + if ((got = X509v3_get_ext_count(*extensions)) != 2) { + fprintf(stderr, "%s: FAIL: second X509V3_ADD_APPEND " + "expected 2 extensions, have %d.\n", __func__, got); + goto err; + } + + /* + * Inspect the extensions on the stack. First we should get the one + * with the ca bit set and it should be critical. + */ + + nid = NID_basic_constraints; + idx = -1; + if ((bc = X509V3_get_d2i(*extensions, nid, &crit, &idx)) == NULL) { + fprintf(stderr, "%s: FAIL: X509V3_ADD_APPEND " + "expected basic constraints.\n", __func__); + goto err; + } + if (bc->ca != ASN1_BOOLEAN_TRUE) { + fprintf(stderr, "%s: FAIL: X509V3_ADD_APPEND " + "expected ca basic constraints.\n", __func__); + goto err; + } + if (crit != 1) { + fprintf(stderr, "%s: FAIL: X509V3_ADD_APPEND " + "expected critical basic constraints.\n", __func__); + goto err; + } + BASIC_CONSTRAINTS_free(bc); + bc = NULL; + + /* Redo the exercise and get the basic constraints with ca bit unset. */ + nid = NID_basic_constraints; + if ((bc = X509V3_get_d2i(*extensions, nid, &crit, &idx)) == NULL) { + fprintf(stderr, "%s: FAIL: second X509V3_ADD_APPEND " + "expected basic constraints.\n", __func__); + goto err; + } + if (bc->ca != ASN1_BOOLEAN_FALSE) { + fprintf(stderr, "%s: FAIL: second X509V3_ADD_APPEND " + "expected basic constraints to be non-ca.\n", __func__); + goto err; + } + if (crit != 1) { + fprintf(stderr, "%s: FAIL: second X509V3_ADD_APPEND " + "expected critical basic constraints.\n", __func__); + goto err; + } + BASIC_CONSTRAINTS_free(bc); + bc = NULL; + + /* + * Now X509V3_ADD_REPLACE non-critical ca constraints. They should + * replace the critical ca constraints we added before. + */ + + nid = NID_basic_constraints; + bc = create_basic_constraints(1); + crit = 0; + op = X509V3_ADD_REPLACE; + if ((got = X509V3_add1_i2d(extensions, nid, bc, crit, op)) != 1) { + fprintf(stderr, "%s: FAIL: X509V3_ADD_REPLACE " + "want %d, got %d\n", __func__, 1, got); + goto err; + } + BASIC_CONSTRAINTS_free(bc); + bc = NULL; + + /* + * If we get basic constraints now, we get the non-critical one with the + * ca bit set. + */ + + nid = NID_basic_constraints; + idx = -1; + if ((bc = X509V3_get_d2i(*extensions, nid, &crit, &idx)) == NULL) { + fprintf(stderr, "%s: FAIL: X509V3_ADD_REPLACE " + "expected basic constraints.\n", __func__); + goto err; + } + if (bc->ca != ASN1_BOOLEAN_TRUE) { + fprintf(stderr, "%s: FAIL: X509V3_ADD_REPLACE " + "expected ca basic constraints.\n", __func__); + goto err; + } + if (crit != 0) { + fprintf(stderr, "%s: FAIL: X509V3_ADD_REPLACE " + "expected non-critical basic constraints.\n", __func__); + goto err; + } + BASIC_CONSTRAINTS_free(bc); + bc = NULL; + + if ((got = X509v3_get_ext_count(*extensions)) != 2) { + fprintf(stderr, "%s: FAIL: X509V3_ADD_REPLACE " + "expected 2 extensions, got %d.\n", __func__, got); + goto err; + } + + nid = NID_basic_constraints; + op = X509V3_ADD_DELETE; + if ((got = X509V3_add1_i2d(extensions, nid, NULL, 0, op)) != 1) { + fprintf(stderr, "%s: FAIL: X509V3_ADD_DELETE " + "want %d, got %d\n", __func__, 1, got); + goto err; + } + + if ((got = X509v3_get_ext_count(*extensions)) != 1) { + fprintf(stderr, "%s: FAIL: X509V3_ADD_DELETE " + "expected 1 extension, got %d.\n", __func__, got); + goto err; + } + + /* The last deletion will have left the critical non-ca constraints. */ + nid = NID_basic_constraints; + idx = -1; + if ((bc = X509V3_get_d2i(*extensions, nid, &crit, &idx)) == NULL) { + fprintf(stderr, "%s: FAIL: X509V3_ADD_DELETE " + "expected basic constraints.\n", __func__); + goto err; + } + if (bc->ca != ASN1_BOOLEAN_FALSE) { + fprintf(stderr, "%s: FAIL: X509V3_ADD_DELETE " + "expected ca basic constraints.\n", __func__); + goto err; + } + if (crit != 1) { + fprintf(stderr, "%s: FAIL: X509V3_ADD_DELETE " + "expected critical basic constraints.\n", __func__); + goto err; + } + BASIC_CONSTRAINTS_free(bc); + bc = NULL; + + /* Now delete the last extension. */ + nid = NID_basic_constraints; + op = X509V3_ADD_DELETE; + if ((got = X509V3_add1_i2d(extensions, nid, NULL, 0, op)) != 1) { + fprintf(stderr, "%s: FAIL: second X509V3_ADD_DELETE " + "want %d, got %d\n", __func__, 1, got); + goto err; + } + + if ((got = X509v3_get_ext_count(*extensions)) != 0) { + fprintf(stderr, "%s: FAIL: second X509V3_ADD_DELETE " + "expected 0 extensions, got %d.\n", __func__, got); + goto err; + } + + failed = 0; + + err: + BASIC_CONSTRAINTS_free(bc); + + return failed; +} + +static int +test_x509v3_add1_i2d_invalid_operations(STACK_OF(X509_EXTENSION) **extensions) +{ + BASIC_CONSTRAINTS *bc = NULL; + long error; + int crit, got, nid, op; + int failed = 1; + + if (X509v3_get_ext_count(*extensions) != 0) { + fprintf(stderr, "%s: FAIL: need empty stack.\n", __func__); + goto err; + } + + /* + * Attempt to add a basic constraint extension with invalid operations + */ + + nid = NID_basic_constraints; + bc = create_basic_constraints(1); + crit = 1; + for (op = X509V3_ADD_DELETE + 1; op <= X509V3_ADD_OP_MASK; op++) { + if ((got = X509V3_add1_i2d(extensions, nid, bc, crit, op)) != -1) { + fprintf(stderr, "%s: FAIL: operation %d " + "want %d, got %d.\n", __func__, op, -1, got); + goto err; + } + error = ERR_get_error(); + if (ERR_GET_REASON(error) != X509V3_R_UNSUPPORTED_OPTION) { + fprintf(stderr, "%s: FAIL: invalid operation %d " + " pushed %d, want %d.\n", __func__, op, + ERR_GET_REASON(error), X509V3_R_EXTENSION_EXISTS); + goto err; + } + } + BASIC_CONSTRAINTS_free(bc); + bc = NULL; + + if ((got = X509v3_get_ext_count(*extensions)) != 0) { + fprintf(stderr, "%s: FAIL: expected 0 extensions, have %d.\n", + __func__, got); + goto err; + } + + failed = 0; + + err: + BASIC_CONSTRAINTS_free(bc); + + return failed; +} + +static int +test_x509v3_add1_i2d(void) +{ + STACK_OF(X509_EXTENSION) *extensions; + int failed = 0; + + if ((extensions = sk_X509_EXTENSION_new_null()) == NULL) + errx(1, "sk_X509_EXTENSION_new_null"); + + failed |= test_x509v3_add1_i2d_empty_stack(&extensions); + failed |= test_x509v3_add1_i2d_single_nid(&extensions); + failed |= test_x509v3_add1_i2d_add_append(&extensions); + failed |= test_x509v3_add1_i2d_invalid_operations(&extensions); + + sk_X509_EXTENSION_pop_free(extensions, X509_EXTENSION_free); + + return failed; +} + +int +main(void) +{ + int failed = 0; + + failed |= test_x509v3_add1_i2d(); + + return failed; +} diff --git a/share/man/man5/changelist.5 b/share/man/man5/changelist.5 index 2d72217ea..0e7a729ba 100644 --- a/share/man/man5/changelist.5 +++ b/share/man/man5/changelist.5 @@ -1,4 +1,4 @@ -.\" $OpenBSD: changelist.5,v 1.9 2017/07/13 19:16:33 jmc Exp $ +.\" $OpenBSD: changelist.5,v 1.10 2024/05/28 05:09:19 jmc Exp $ .\" .\" Copyright (c) 2003 Jason McIntyre .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: July 13 2017 $ +.Dd $Mdocdate: May 28 2024 $ .Dt CHANGELIST 5 .Os .Sh NAME @@ -88,7 +88,7 @@ checksums. Results are mailed in the following format: .Bd -unfilled -offset indent ====== -/etc/ssh/ssh_host_key SHA-256 checksums +/etc/ssh/ssh_host_ed25519_key SHA-256 checksums ====== OLD: NEW: diff --git a/share/man/man5/python-module.5 b/share/man/man5/python-module.5 index a05f97830..681765671 100644 --- a/share/man/man5/python-module.5 +++ b/share/man/man5/python-module.5 @@ -1,4 +1,4 @@ -.\" $OpenBSD: python-module.5,v 1.11 2024/04/17 13:34:23 sthen Exp $ +.\" $OpenBSD: python-module.5,v 1.12 2024/05/28 16:05:39 sthen Exp $ .\" .\" Copyright (c) 2008 Marc Espie .\" @@ -24,7 +24,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: April 17 2024 $ +.Dd $Mdocdate: May 28 2024 $ .Dt PYTHON-MODULE 5 .Os .Sh NAME @@ -165,6 +165,11 @@ to disable certain test scripts with .Sq --ignore , or to disable certain individual tests with .Sq -k . +User setting +.Ev MODPY_PYTEST_USERARGS , +if present, is passed on the command line. +This allows setting py.test flags to increase verbosity, +show test durations, enable colours, etc. .Pp All ports that generate egg-info or dist-info files should set .Ev MODPY_EGG_VERSION @@ -182,6 +187,16 @@ These filenames can be relative to ${WRKSRC} and will be modified at the end of .Cm pre-configure . .Pp +For ports not using standard Python build infrastructure, +it may be necessary to bytecode-compile installed .py files. +This can be done by using +.Ev ${MODPY_COMPILEALL} , +usually in a post-install target. +This passes flags to use MAKE_JOBS, strip off WRKINST, and use +standard optimization passes. +File or directory names can be given. +Directories are handled recursively. +.Pp This module also affects .Ev CATEGORIES , .Ev MAKE_ENV , diff --git a/sys/arch/amd64/amd64/acpi_machdep.c b/sys/arch/amd64/amd64/acpi_machdep.c index ee5a5b131..98d370daf 100644 --- a/sys/arch/amd64/amd64/acpi_machdep.c +++ b/sys/arch/amd64/amd64/acpi_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpi_machdep.c,v 1.108 2023/06/07 04:46:09 deraadt Exp $ */ +/* $OpenBSD: acpi_machdep.c,v 1.109 2024/05/26 13:37:31 kettenis Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert * @@ -333,7 +333,8 @@ acpi_attach_machdep(struct acpi_softc *sc) extern void (*cpuresetfn)(void); sc->sc_interrupt = isa_intr_establish(NULL, sc->sc_fadt->sci_int, - IST_LEVEL, IPL_BIO, acpi_interrupt, sc, sc->sc_dev.dv_xname); + IST_LEVEL, IPL_BIO | IPL_WAKEUP, acpi_interrupt, + sc, sc->sc_dev.dv_xname); cpuresetfn = acpi_reset; #ifndef SMALL_KERNEL diff --git a/sys/arch/amd64/amd64/intr.c b/sys/arch/amd64/amd64/intr.c index 8b4d8abc9..8bd6dbe68 100644 --- a/sys/arch/amd64/amd64/intr.c +++ b/sys/arch/amd64/amd64/intr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.c,v 1.56 2024/01/19 18:38:16 kettenis Exp $ */ +/* $OpenBSD: intr.c,v 1.57 2024/05/26 13:37:31 kettenis Exp $ */ /* $NetBSD: intr.c,v 1.3 2003/03/03 22:16:20 fvdl Exp $ */ /* @@ -354,8 +354,8 @@ intr_establish(int legacy_irq, struct pic *pic, int pin, int type, int level, panic("intr_establish: non-legacy IRQ on i8259"); #endif - flags = level & IPL_MPSAFE; - level &= ~IPL_MPSAFE; + flags = level & (IPL_MPSAFE | IPL_WAKEUP); + level &= ~(IPL_MPSAFE | IPL_WAKEUP); KASSERT(level <= IPL_TTY || level >= IPL_CLOCK || flags & IPL_MPSAFE); @@ -694,6 +694,52 @@ intr_barrier(void *cookie) sched_barrier(ih->ih_cpu); } +#ifdef SUSPEND + +void +intr_enable_wakeup(void) +{ + struct cpu_info *ci = curcpu(); + struct pic *pic; + int irq, pin; + + for (irq = 0; irq < MAX_INTR_SOURCES; irq++) { + if (ci->ci_isources[irq] == NULL) + continue; + + if (ci->ci_isources[irq]->is_handlers->ih_flags & IPL_WAKEUP) + continue; + + pic = ci->ci_isources[irq]->is_pic; + pin = ci->ci_isources[irq]->is_pin; + if (pic->pic_hwmask) + pic->pic_hwmask(pic, pin); + } +} + +void +intr_disable_wakeup(void) +{ + struct cpu_info *ci = curcpu(); + struct pic *pic; + int irq, pin; + + for (irq = 0; irq < MAX_INTR_SOURCES; irq++) { + if (ci->ci_isources[irq] == NULL) + continue; + + if (ci->ci_isources[irq]->is_handlers->ih_flags & IPL_WAKEUP) + continue; + + pic = ci->ci_isources[irq]->is_pic; + pin = ci->ci_isources[irq]->is_pin; + if (pic->pic_hwunmask) + pic->pic_hwunmask(pic, pin); + } +} + +#endif + /* * Add a mask to cpl, and return the old value of cpl. */ diff --git a/sys/arch/amd64/include/intr.h b/sys/arch/amd64/include/intr.h index 2fe24d36f..9f0c717da 100644 --- a/sys/arch/amd64/include/intr.h +++ b/sys/arch/amd64/include/intr.h @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.h,v 1.33 2021/12/14 18:16:14 deraadt Exp $ */ +/* $OpenBSD: intr.h,v 1.34 2024/05/26 13:37:31 kettenis Exp $ */ /* $NetBSD: intr.h,v 1.2 2003/05/04 22:01:56 fvdl Exp $ */ /*- @@ -206,6 +206,8 @@ int intr_handler(struct intrframe *, struct intrhand *); void cpu_intr_init(struct cpu_info *); void intr_printconfig(void); void intr_barrier(void *); +void intr_enable_wakeup(void); +void intr_disable_wakeup(void); #ifdef MULTIPROCESSOR void x86_send_ipi(struct cpu_info *, int); diff --git a/sys/arch/amd64/include/intrdefs.h b/sys/arch/amd64/include/intrdefs.h index 8673f4724..55b1a7858 100644 --- a/sys/arch/amd64/include/intrdefs.h +++ b/sys/arch/amd64/include/intrdefs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: intrdefs.h,v 1.23 2024/01/04 20:50:43 kettenis Exp $ */ +/* $OpenBSD: intrdefs.h,v 1.24 2024/05/26 13:37:31 kettenis Exp $ */ /* $NetBSD: intrdefs.h,v 1.2 2003/05/04 22:01:56 fvdl Exp $ */ #ifndef _AMD64_INTRDEFS_H @@ -36,6 +36,7 @@ #define IPL_MPFLOOR IPL_TTY #define IPL_MPSAFE 0x100 +#define IPL_WAKEUP 0x200 /* Interrupt sharing types. */ #define IST_NONE 0 /* none */ diff --git a/sys/arch/arm64/arm64/cpu.c b/sys/arch/arm64/arm64/cpu.c index bc7e74fb0..4683092f7 100644 --- a/sys/arch/arm64/arm64/cpu.c +++ b/sys/arch/arm64/arm64/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.114 2024/04/13 14:19:39 kettenis Exp $ */ +/* $OpenBSD: cpu.c,v 1.116 2024/05/27 06:20:59 kettenis Exp $ */ /* * Copyright (c) 2016 Dale Rahn @@ -742,6 +742,37 @@ cpu_identify(struct cpu_info *ci) */ id = READ_SPECIALREG(id_aa64isar1_el1); + if (ID_AA64ISAR1_LS64(id) >= ID_AA64ISAR1_LS64_BASE) { + printf("%sLS64", sep); + sep = ","; + } + if (ID_AA64ISAR1_LS64(id) >= ID_AA64ISAR1_LS64_V) + printf("+V"); + if (ID_AA64ISAR1_LS64(id) >= ID_AA64ISAR1_LS64_ACCDATA) + printf("+ACCDATA"); + + if (ID_AA64ISAR1_XS(id) >= ID_AA64ISAR1_XS_IMPL) { + printf("%sXS", sep); + sep = ","; + } + + if (ID_AA64ISAR1_I8MM(id) >= ID_AA64ISAR1_I8MM_IMPL) { + printf("%sI8MM", sep); + sep = ","; + } + + if (ID_AA64ISAR1_DGH(id) >= ID_AA64ISAR1_DGH_IMPL) { + printf("%sDGH", sep); + sep = ","; + } + + if (ID_AA64ISAR1_BF16(id) >= ID_AA64ISAR1_BF16_BASE) { + printf("%sBF16", sep); + sep = ","; + } + if (ID_AA64ISAR1_BF16(id) >= ID_AA64ISAR1_BF16_EBF) + printf("+EBF"); + if (ID_AA64ISAR1_SPECRES(id) >= ID_AA64ISAR1_SPECRES_IMPL) { printf("%sSPECRES", sep); sep = ","; @@ -1526,7 +1557,8 @@ cpu_suspend_primary(void) * wake us up by clearing the flag. */ cpu_suspended = 1; - intr_enable_wakeup(); + arm_intr_func.setipl(IPL_NONE); + intr_enable(); while (cpu_suspended) { #if NPSCI > 0 @@ -1542,7 +1574,8 @@ cpu_suspend_primary(void) } resume: - intr_disable_wakeup(); + intr_disable(); + arm_intr_func.setipl(IPL_HIGH); /* Unmask clock interrupts. */ WRITE_SPECIALREG(cntv_ctl_el0, diff --git a/sys/arch/arm64/arm64/intr.c b/sys/arch/arm64/arm64/intr.c index 34dd9c536..9e69fd001 100644 --- a/sys/arch/arm64/arm64/intr.c +++ b/sys/arch/arm64/arm64/intr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.c,v 1.27 2022/12/21 22:30:42 kettenis Exp $ */ +/* $OpenBSD: intr.c,v 1.28 2024/05/26 13:37:31 kettenis Exp $ */ /* * Copyright (c) 2011 Dale Rahn * @@ -888,15 +888,11 @@ intr_enable_wakeup(void) { if (arm_intr_func.enable_wakeup) arm_intr_func.enable_wakeup(); - arm_intr_func.setipl(IPL_NONE); - intr_enable(); } void intr_disable_wakeup(void) { - intr_disable(); - arm_intr_func.setipl(IPL_HIGH); if (arm_intr_func.disable_wakeup) arm_intr_func.disable_wakeup(); } diff --git a/sys/arch/arm64/arm64/pmap.c b/sys/arch/arm64/arm64/pmap.c index e768344ae..ecb70109c 100644 --- a/sys/arch/arm64/arm64/pmap.c +++ b/sys/arch/arm64/arm64/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.102 2024/03/27 15:40:50 kurt Exp $ */ +/* $OpenBSD: pmap.c,v 1.103 2024/05/28 15:16:45 claudio Exp $ */ /* * Copyright (c) 2008-2009,2014-2016 Dale Rahn * @@ -217,7 +217,7 @@ const uint64_t ap_bits_kern[8] = { int pmap_nasid = (1 << 8); uint32_t pmap_asid[PMAP_MAX_NASID / 32]; -uint64_t pmap_asid_gen = PMAP_MAX_NASID; +unsigned long pmap_asid_gen = PMAP_MAX_NASID; struct mutex pmap_asid_mtx = MUTEX_INITIALIZER(IPL_HIGH); int @@ -227,6 +227,8 @@ pmap_find_asid(pmap_t pm) int asid, bit; int retry; + MUTEX_ASSERT_LOCKED(&pmap_asid_mtx); + /* Attempt to re-use the old ASID. */ asid = pm->pm_asid & PMAP_ASID_MASK; bit = asid & (32 - 1); @@ -262,23 +264,26 @@ pmap_rollover_asid(pmap_t pm) { struct cpu_info *ci; CPU_INFO_ITERATOR cii; + unsigned long gen; int asid, bit; - SCHED_ASSERT_LOCKED(); MUTEX_ASSERT_LOCKED(&pmap_asid_mtx); /* Start a new generation. Mark ASID 0 as in-use again. */ - pmap_asid_gen += PMAP_MAX_NASID; + gen = atomic_add_long_nv(&pmap_asid_gen, PMAP_MAX_NASID); memset(pmap_asid, 0, (pmap_nasid / 32) * sizeof(uint32_t)); pmap_asid[0] |= (3U << 0); /* * Carry over all the ASIDs that are currently active into the * new generation and reserve them. + * CPUs in cpu_switchto() will spin in pmap_setttb() waiting for + * the mutex. In that case an old ASID will be carried over but + * that is not problematic. */ CPU_INFO_FOREACH(cii, ci) { asid = ci->ci_curpm->pm_asid & PMAP_ASID_MASK; - ci->ci_curpm->pm_asid = asid | pmap_asid_gen; + ci->ci_curpm->pm_asid = asid | gen; bit = (asid & (32 - 1)); pmap_asid[asid / 32] |= (3U << bit); } @@ -286,7 +291,7 @@ pmap_rollover_asid(pmap_t pm) /* Flush the TLBs on all CPUs. */ cpu_tlb_flush(); - if ((pm->pm_asid & ~PMAP_ASID_MASK) == pmap_asid_gen) + if ((pm->pm_asid & ~PMAP_ASID_MASK) == gen) return pm->pm_asid & PMAP_ASID_MASK; return pmap_find_asid(pm); @@ -1397,13 +1402,9 @@ void pmap_activate(struct proc *p) { pmap_t pm = p->p_vmspace->vm_map.pmap; - int s; - if (p == curproc && pm != curcpu()->ci_curpm) { - SCHED_LOCK(s); + if (p == curproc && pm != curcpu()->ci_curpm) pmap_setttb(p); - SCHED_UNLOCK(s); - } } /* @@ -2274,14 +2275,12 @@ pmap_setttb(struct proc *p) struct cpu_info *ci = curcpu(); pmap_t pm = p->p_vmspace->vm_map.pmap; - SCHED_ASSERT_LOCKED(); - /* * If the generation of the ASID for the new pmap doesn't * match the current generation, allocate a new ASID. */ if (pm != pmap_kernel() && - (pm->pm_asid & ~PMAP_ASID_MASK) != pmap_asid_gen) + (pm->pm_asid & ~PMAP_ASID_MASK) != READ_ONCE(pmap_asid_gen)) pmap_allocate_asid(pm); if (pm != pmap_kernel()) diff --git a/sys/arch/arm64/dev/apm.c b/sys/arch/arm64/dev/apm.c index 903b35535..49d4e1a66 100644 --- a/sys/arch/arm64/dev/apm.c +++ b/sys/arch/arm64/dev/apm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apm.c,v 1.24 2023/07/08 14:44:43 tobhe Exp $ */ +/* $OpenBSD: apm.c,v 1.25 2024/05/28 09:40:40 kettenis Exp $ */ /*- * Copyright (c) 2001 Alexander Guy. All rights reserved. @@ -444,11 +444,6 @@ gosleep(void *v) return cpu_suspend_primary(); } -void -sleep_abort(void *v) -{ -} - int sleep_resume(void *v) { diff --git a/sys/arch/arm64/include/armreg.h b/sys/arch/arm64/include/armreg.h index 445c07ac2..3aa58ef38 100644 --- a/sys/arch/arm64/include/armreg.h +++ b/sys/arch/arm64/include/armreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: armreg.h,v 1.33 2024/03/18 18:35:21 kettenis Exp $ */ +/* $OpenBSD: armreg.h,v 1.34 2024/05/27 06:20:59 kettenis Exp $ */ /*- * Copyright (c) 2013, 2014 Andrew Turner * Copyright (c) 2015 The FreeBSD Foundation @@ -337,7 +337,7 @@ #define ID_AA64ISAR0_RNDR_IMPL (0x1ULL << ID_AA64ISAR0_RNDR_SHIFT) /* ID_AA64ISAR1_EL1 */ -#define ID_AA64ISAR1_MASK 0x00000fffffffffffULL +#define ID_AA64ISAR1_MASK 0xffffffffffffffffULL #define ID_AA64ISAR1_DPB_SHIFT 0 #define ID_AA64ISAR1_DPB_MASK (0xfULL << ID_AA64ISAR1_DPB_SHIFT) #define ID_AA64ISAR1_DPB(x) ((x) & ID_AA64ISAR1_DPB_MASK) @@ -396,6 +396,34 @@ #define ID_AA64ISAR1_SPECRES(x) ((x) & ID_AA64ISAR1_SPECRES_MASK) #define ID_AA64ISAR1_SPECRES_NONE (0x0ULL << ID_AA64ISAR1_SPECRES_SHIFT) #define ID_AA64ISAR1_SPECRES_IMPL (0x1ULL << ID_AA64ISAR1_SPECRES_SHIFT) +#define ID_AA64ISAR1_BF16_SHIFT 44 +#define ID_AA64ISAR1_BF16_MASK (0xfULL << ID_AA64ISAR1_BF16_SHIFT) +#define ID_AA64ISAR1_BF16(x) ((x) & ID_AA64ISAR1_BF16_MASK) +#define ID_AA64ISAR1_BF16_NONE (0x0ULL << ID_AA64ISAR1_BF16_SHIFT) +#define ID_AA64ISAR1_BF16_BASE (0x1ULL << ID_AA64ISAR1_BF16_SHIFT) +#define ID_AA64ISAR1_BF16_EBF (0x2ULL << ID_AA64ISAR1_BF16_SHIFT) +#define ID_AA64ISAR1_DGH_SHIFT 48 +#define ID_AA64ISAR1_DGH_MASK (0xfULL << ID_AA64ISAR1_DGH_SHIFT) +#define ID_AA64ISAR1_DGH(x) ((x) & ID_AA64ISAR1_DGH_MASK) +#define ID_AA64ISAR1_DGH_NONE (0x0ULL << ID_AA64ISAR1_DGH_SHIFT) +#define ID_AA64ISAR1_DGH_IMPL (0x1ULL << ID_AA64ISAR1_DGH_SHIFT) +#define ID_AA64ISAR1_I8MM_SHIFT 52 +#define ID_AA64ISAR1_I8MM_MASK (0xfULL << ID_AA64ISAR1_I8MM_SHIFT) +#define ID_AA64ISAR1_I8MM(x) ((x) & ID_AA64ISAR1_I8MM_MASK) +#define ID_AA64ISAR1_I8MM_NONE (0x0ULL << ID_AA64ISAR1_I8MM_SHIFT) +#define ID_AA64ISAR1_I8MM_IMPL (0x1ULL << ID_AA64ISAR1_I8MM_SHIFT) +#define ID_AA64ISAR1_XS_SHIFT 56 +#define ID_AA64ISAR1_XS_MASK (0xfULL << ID_AA64ISAR1_XS_SHIFT) +#define ID_AA64ISAR1_XS(x) ((x) & ID_AA64ISAR1_XS_MASK) +#define ID_AA64ISAR1_XS_NONE (0x0ULL << ID_AA64ISAR1_XS_SHIFT) +#define ID_AA64ISAR1_XS_IMPL (0x1ULL << ID_AA64ISAR1_XS_SHIFT) +#define ID_AA64ISAR1_LS64_SHIFT 60 +#define ID_AA64ISAR1_LS64_MASK (0xfULL << ID_AA64ISAR1_LS64_SHIFT) +#define ID_AA64ISAR1_LS64(x) ((x) & ID_AA64ISAR1_LS64_MASK) +#define ID_AA64ISAR1_LS64_NONE (0x0ULL << ID_AA64ISAR1_LS64_SHIFT) +#define ID_AA64ISAR1_LS64_BASE (0x1ULL << ID_AA64ISAR1_LS64_SHIFT) +#define ID_AA64ISAR1_LS64_V (0x2ULL << ID_AA64ISAR1_LS64_SHIFT) +#define ID_AA64ISAR1_LS64_ACCDATA (0x3ULL << ID_AA64ISAR1_LS64_SHIFT) /* ID_AA64ISAR2_EL1 */ #define ID_AA64ISAR2_MASK 0x00000000f0000000ULL diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c index 28f72deaa..26e524330 100644 --- a/sys/arch/i386/i386/machdep.c +++ b/sys/arch/i386/i386/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.670 2024/04/29 00:29:48 jsg Exp $ */ +/* $OpenBSD: machdep.c,v 1.671 2024/05/26 13:37:32 kettenis Exp $ */ /* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */ /*- @@ -3966,6 +3966,20 @@ intr_barrier(void *ih) sched_barrier(NULL); } +#ifdef SUSPEND + +void +intr_enable_wakeup(void) +{ +} + +void +intr_disable_wakeup(void) +{ +} + +#endif + unsigned int cpu_rnd_messybits(void) { diff --git a/sys/arch/i386/include/intr.h b/sys/arch/i386/include/intr.h index 60fe6dcca..9682673ac 100644 --- a/sys/arch/i386/include/intr.h +++ b/sys/arch/i386/include/intr.h @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.h,v 1.49 2021/12/14 18:16:14 deraadt Exp $ */ +/* $OpenBSD: intr.h,v 1.50 2024/05/26 13:37:32 kettenis Exp $ */ /* $NetBSD: intr.h,v 1.5 1996/05/13 06:11:28 mycroft Exp $ */ /* @@ -128,6 +128,8 @@ void splassert_check(int, const char *); struct cpu_info; void intr_barrier(void *); +void intr_enable_wakeup(void); +void intr_disable_wakeup(void); #ifdef MULTIPROCESSOR void i386_send_ipi(struct cpu_info *, int); diff --git a/sys/dev/acpi/acpi_x86.c b/sys/dev/acpi/acpi_x86.c index 78140b245..6a439828d 100644 --- a/sys/dev/acpi/acpi_x86.c +++ b/sys/dev/acpi/acpi_x86.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpi_x86.c,v 1.18 2024/05/13 19:56:37 kettenis Exp $ */ +/* $OpenBSD: acpi_x86.c,v 1.20 2024/05/28 09:40:40 kettenis Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert * Copyright (c) 2005 Jordan Hargrave @@ -96,19 +96,10 @@ gosleep(void *v) ret = acpi_sleep_cpu(sc, sc->sc_state); acpi_resume_cpu(sc, sc->sc_state); - sc->sc_state = ACPI_STATE_S0; return ret; } -void -sleep_abort(void *v) -{ - struct acpi_softc *sc = v; - - sc->sc_state = ACPI_STATE_S0; -} - int sleep_resume(void *v) { @@ -119,7 +110,7 @@ sleep_resume(void *v) acpibtn_disable_psw(); /* disable _LID for wakeup */ /* 3rd resume AML step: _TTS(runstate) */ - if (aml_node_setval(sc, sc->sc_tts, sc->sc_state) != 0) + if (aml_node_setval(sc, sc->sc_tts, ACPI_STATE_S0) != 0) return (EINVAL); acpi_indicator(sc, ACPI_SST_WAKING); /* blink */ return 0; @@ -147,6 +138,8 @@ suspend_finish(void *v) acpi_record_event(sc, APM_NORMAL_RESUME); acpi_indicator(sc, ACPI_SST_WORKING); + sc->sc_state = ACPI_STATE_S0; + /* If we woke up but all the lids are closed, go back to sleep */ return checklids(sc); } diff --git a/sys/dev/ata/ata.c b/sys/dev/ata/ata.c index 6940aba83..1cf2a24aa 100644 --- a/sys/dev/ata/ata.c +++ b/sys/dev/ata/ata.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ata.c,v 1.36 2017/12/30 20:46:59 guenther Exp $ */ +/* $OpenBSD: ata.c,v 1.37 2024/05/26 10:01:01 jsg Exp $ */ /* $NetBSD: ata.c,v 1.9 1999/04/15 09:41:09 bouyer Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -26,15 +26,8 @@ #include #include -#include -#include -#include -#include -#include #include -#include - #include #include #include diff --git a/sys/dev/ata/ata_wdc.c b/sys/dev/ata/ata_wdc.c index d165d92a7..f2731090b 100644 --- a/sys/dev/ata/ata_wdc.c +++ b/sys/dev/ata/ata_wdc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ata_wdc.c,v 1.52 2018/11/02 09:59:36 fcambus Exp $ */ +/* $OpenBSD: ata_wdc.c,v 1.53 2024/05/26 10:01:01 jsg Exp $ */ /* $NetBSD: ata_wdc.c,v 1.21 1999/08/09 09:43:11 bouyer Exp $ */ /* @@ -57,16 +57,12 @@ #include #include -#include #include #include -#include #include #include #include -#include -#include #include #include diff --git a/sys/dev/ata/atascsi.c b/sys/dev/ata/atascsi.c index 029354e13..24d60fedf 100644 --- a/sys/dev/ata/atascsi.c +++ b/sys/dev/ata/atascsi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: atascsi.c,v 1.154 2024/05/13 01:15:50 jsg Exp $ */ +/* $OpenBSD: atascsi.c,v 1.155 2024/05/26 10:01:01 jsg Exp $ */ /* * Copyright (c) 2007 David Gwynne @@ -20,11 +20,8 @@ #include #include -#include -#include #include #include -#include #include #include diff --git a/sys/dev/ata/wd.c b/sys/dev/ata/wd.c index 94947661f..e6d41d7e5 100644 --- a/sys/dev/ata/wd.c +++ b/sys/dev/ata/wd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wd.c,v 1.130 2022/10/23 14:39:19 krw Exp $ */ +/* $OpenBSD: wd.c,v 1.131 2024/05/26 10:01:01 jsg Exp $ */ /* $NetBSD: wd.c,v 1.193 1999/02/28 17:15:27 explorer Exp $ */ /* @@ -60,12 +60,9 @@ #include #include -#include #include #include #include -#include -#include #include #include #include @@ -74,7 +71,6 @@ #include #include #include -#include #include #include diff --git a/sys/dev/atapiscsi/atapiscsi.c b/sys/dev/atapiscsi/atapiscsi.c index 5a2d58f7e..19e11a79e 100644 --- a/sys/dev/atapiscsi/atapiscsi.c +++ b/sys/dev/atapiscsi/atapiscsi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: atapiscsi.c,v 1.120 2022/04/16 19:19:58 naddy Exp $ */ +/* $OpenBSD: atapiscsi.c,v 1.121 2024/05/26 10:01:01 jsg Exp $ */ /* * This code is derived from code with the copyright below. @@ -30,19 +30,12 @@ * */ - #include #include #include #include -#include -#include -#include -#include -#include #include #include -#include #include #include @@ -134,9 +127,6 @@ void wdc_atapi_reset_2(struct channel_softc *, struct wdc_xfer *, void wdc_atapi_tape_done(struct channel_softc *, struct wdc_xfer *, int, struct atapi_return_args *); -struct atapiscsi_softc; -struct atapiscsi_xfer; - int atapiscsi_match(struct device *, void *, void *); void atapiscsi_attach(struct device *, struct device *, void *); int atapiscsi_activate(struct device *, int); diff --git a/sys/dev/fdt/bcm2835_mbox.c b/sys/dev/fdt/bcm2835_mbox.c index 65114d8ad..c58741d70 100644 --- a/sys/dev/fdt/bcm2835_mbox.c +++ b/sys/dev/fdt/bcm2835_mbox.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bcm2835_mbox.c,v 1.4 2022/08/27 20:31:45 mglocker Exp $ */ +/* $OpenBSD: bcm2835_mbox.c,v 1.5 2024/05/28 09:19:04 claudio Exp $ */ /* * Copyright (c) 2020 Tobias Heider @@ -153,15 +153,6 @@ bcmmbox_attach(struct device *parent, struct device *self, void *aux) printf("\n"); - bcmmbox_write(BCMMBOX_CHANPM, ( - (1 << VCPROP_POWER_SDCARD) | - (1 << VCPROP_POWER_UART0) | - (1 << VCPROP_POWER_USB) | - (1 << VCPROP_POWER_I2C0) | - (1 << VCPROP_POWER_I2C1) | - (1 << VCPROP_POWER_SPI) | - 0) << 4); - return; clean_dmamap: diff --git a/sys/dev/fdt/dwmshc.c b/sys/dev/fdt/dwmshc.c index 34df2ed9c..4497dc4a3 100644 --- a/sys/dev/fdt/dwmshc.c +++ b/sys/dev/fdt/dwmshc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dwmshc.c,v 1.5 2023/06/20 09:26:36 kettenis Exp $ */ +/* $OpenBSD: dwmshc.c,v 1.7 2024/05/26 22:04:52 kettenis Exp $ */ /* * Copyright (c) 2023 David Gwynne diff --git a/sys/dev/fdt/fanpwr.c b/sys/dev/fdt/fanpwr.c index 5101e9823..ad184e9a7 100644 --- a/sys/dev/fdt/fanpwr.c +++ b/sys/dev/fdt/fanpwr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fanpwr.c,v 1.8 2023/11/12 12:41:43 patrick Exp $ */ +/* $OpenBSD: fanpwr.c,v 1.10 2024/05/26 22:04:52 kettenis Exp $ */ /* * Copyright (c) 2018 Mark Kettenis * diff --git a/sys/dev/fdt/rkpmic.c b/sys/dev/fdt/rkpmic.c index 2b560a4a5..c3479794c 100644 --- a/sys/dev/fdt/rkpmic.c +++ b/sys/dev/fdt/rkpmic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rkpmic.c,v 1.15 2024/05/12 20:02:13 kettenis Exp $ */ +/* $OpenBSD: rkpmic.c,v 1.17 2024/05/26 18:06:21 kettenis Exp $ */ /* * Copyright (c) 2017 Mark Kettenis * @@ -76,7 +76,8 @@ struct rkpmic_vsel_range { struct rkpmic_regdata { const char *name; - uint8_t reg, mask; + uint8_t vreg, vmask; + uint8_t sreg, smask; const struct rkpmic_vsel_range *vsel_range; }; @@ -112,12 +113,12 @@ const struct rkpmic_vsel_range rk805_vsel_range3[] = { }; const struct rkpmic_regdata rk805_regdata[] = { - { "DCDC_REG1", 0x2f, 0x3f, rk805_vsel_range1 }, - { "DCDC_REG2", 0x33, 0x3f, rk805_vsel_range1 }, - { "DCDC_REG4", 0x38, 0x1f, rk805_vsel_range2 }, - { "LDO_REG1", 0x3b, 0x1f, rk805_vsel_range3 }, - { "LDO_REG2", 0x3d, 0x1f, rk805_vsel_range3 }, - { "LDO_REG3", 0x3f, 0x1f, rk805_vsel_range3 }, + { "DCDC_REG1", 0x2f, 0x3f, 0, 0, rk805_vsel_range1 }, + { "DCDC_REG2", 0x33, 0x3f, 0, 0, rk805_vsel_range1 }, + { "DCDC_REG4", 0x38, 0x1f, 0, 0, rk805_vsel_range2 }, + { "LDO_REG1", 0x3b, 0x1f, 0, 0, rk805_vsel_range3 }, + { "LDO_REG2", 0x3d, 0x1f, 0, 0, rk805_vsel_range3 }, + { "LDO_REG3", 0x3f, 0x1f, 0, 0, rk805_vsel_range3 }, { } }; @@ -146,27 +147,27 @@ const struct rkpmic_vsel_range rk806_vsel_range2[] = { }; const struct rkpmic_regdata rk806_regdata[] = { - { "dcdc-reg1", 0x1a, 0xff, rk806_vsel_range1 }, - { "dcdc-reg2", 0x1b, 0xff, rk806_vsel_range1 }, - { "dcdc-reg3", 0x1c, 0xff, rk806_vsel_range1 }, - { "dcdc-reg4", 0x1d, 0xff, rk806_vsel_range1 }, - { "dcdc-reg5", 0x1e, 0xff, rk806_vsel_range1 }, - { "dcdc-reg6", 0x1f, 0xff, rk806_vsel_range1 }, - { "dcdc-reg7", 0x20, 0xff, rk806_vsel_range1 }, - { "dcdc-reg8", 0x21, 0xff, rk806_vsel_range1 }, - { "dcdc-reg9", 0x22, 0xff, rk806_vsel_range1 }, - { "dcdc-reg10", 0x23, 0xff, rk806_vsel_range1 }, - { "nldo-reg1", 0x43, 0xff, rk806_vsel_range2 }, - { "nldo-reg2", 0x44, 0xff, rk806_vsel_range2 }, - { "nldo-reg3", 0x45, 0xff, rk806_vsel_range2 }, - { "nldo-reg4", 0x46, 0xff, rk806_vsel_range2 }, - { "nldo-reg5", 0x47, 0xff, rk806_vsel_range2 }, - { "pldo-reg1", 0x4e, 0xff, rk806_vsel_range2 }, - { "pldo-reg2", 0x4f, 0xff, rk806_vsel_range2 }, - { "pldo-reg3", 0x50, 0xff, rk806_vsel_range2 }, - { "pldo-reg4", 0x51, 0xff, rk806_vsel_range2 }, - { "pldo-reg5", 0x52, 0xff, rk806_vsel_range2 }, - { "pldo-reg6", 0x53, 0xff, rk806_vsel_range2 }, + { "dcdc-reg1", 0x1a, 0xff, 0, 0, rk806_vsel_range1 }, + { "dcdc-reg2", 0x1b, 0xff, 0, 0, rk806_vsel_range1 }, + { "dcdc-reg3", 0x1c, 0xff, 0, 0, rk806_vsel_range1 }, + { "dcdc-reg4", 0x1d, 0xff, 0, 0, rk806_vsel_range1 }, + { "dcdc-reg5", 0x1e, 0xff, 0, 0, rk806_vsel_range1 }, + { "dcdc-reg6", 0x1f, 0xff, 0, 0, rk806_vsel_range1 }, + { "dcdc-reg7", 0x20, 0xff, 0, 0, rk806_vsel_range1 }, + { "dcdc-reg8", 0x21, 0xff, 0, 0, rk806_vsel_range1 }, + { "dcdc-reg9", 0x22, 0xff, 0, 0, rk806_vsel_range1 }, + { "dcdc-reg10", 0x23, 0xff, 0, 0, rk806_vsel_range1 }, + { "nldo-reg1", 0x43, 0xff, 0, 0, rk806_vsel_range2 }, + { "nldo-reg2", 0x44, 0xff, 0, 0, rk806_vsel_range2 }, + { "nldo-reg3", 0x45, 0xff, 0, 0, rk806_vsel_range2 }, + { "nldo-reg4", 0x46, 0xff, 0, 0, rk806_vsel_range2 }, + { "nldo-reg5", 0x47, 0xff, 0, 0, rk806_vsel_range2 }, + { "pldo-reg1", 0x4e, 0xff, 0, 0, rk806_vsel_range2 }, + { "pldo-reg2", 0x4f, 0xff, 0, 0, rk806_vsel_range2 }, + { "pldo-reg3", 0x50, 0xff, 0, 0, rk806_vsel_range2 }, + { "pldo-reg4", 0x51, 0xff, 0, 0, rk806_vsel_range2 }, + { "pldo-reg5", 0x52, 0xff, 0, 0, rk806_vsel_range2 }, + { "pldo-reg6", 0x53, 0xff, 0, 0, rk806_vsel_range2 }, { } }; @@ -220,17 +221,17 @@ const struct rkpmic_vsel_range rk808_vsel_range5[] = { }; const struct rkpmic_regdata rk808_regdata[] = { - { "DCDC_REG1", 0x2f, 0x3f, rk808_vsel_range1 }, - { "DCDC_REG2", 0x33, 0x3f, rk808_vsel_range1 }, - { "DCDC_REG4", 0x38, 0x0f, rk808_vsel_range2 }, - { "LDO_REG1", 0x3b, 0x1f, rk808_vsel_range3 }, - { "LDO_REG2", 0x3d, 0x1f, rk808_vsel_range3 }, - { "LDO_REG3", 0x3f, 0x0f, rk808_vsel_range4 }, - { "LDO_REG4", 0x41, 0x1f, rk808_vsel_range3 }, - { "LDO_REG5", 0x43, 0x1f, rk808_vsel_range3 }, - { "LDO_REG6", 0x45, 0x1f, rk808_vsel_range5 }, - { "LDO_REG7", 0x47, 0x1f, rk808_vsel_range5 }, - { "LDO_REG8", 0x49, 0x1f, rk808_vsel_range3 }, + { "DCDC_REG1", 0x2f, 0x3f, 0, 0, rk808_vsel_range1 }, + { "DCDC_REG2", 0x33, 0x3f, 0, 0, rk808_vsel_range1 }, + { "DCDC_REG4", 0x38, 0x0f, 0, 0, rk808_vsel_range2 }, + { "LDO_REG1", 0x3b, 0x1f, 0, 0, rk808_vsel_range3 }, + { "LDO_REG2", 0x3d, 0x1f, 0, 0, rk808_vsel_range3 }, + { "LDO_REG3", 0x3f, 0x0f, 0, 0, rk808_vsel_range4 }, + { "LDO_REG4", 0x41, 0x1f, 0, 0, rk808_vsel_range3 }, + { "LDO_REG5", 0x43, 0x1f, 0, 0, rk808_vsel_range3 }, + { "LDO_REG6", 0x45, 0x1f, 0, 0, rk808_vsel_range5 }, + { "LDO_REG7", 0x47, 0x1f, 0, 0, rk808_vsel_range5 }, + { "LDO_REG8", 0x49, 0x1f, 0, 0, rk808_vsel_range3 }, { } }; @@ -281,20 +282,22 @@ const struct rkpmic_vsel_range rk809_vsel_range4[] = { }; const struct rkpmic_regdata rk809_regdata[] = { - { "DCDC_REG1", 0xbb, 0x7f, rk809_vsel_range1 }, - { "DCDC_REG2", 0xbe, 0x7f, rk809_vsel_range1 }, - { "DCDC_REG3", 0xc1, 0x7f, rk809_vsel_range1 }, - { "DCDC_REG4", 0xc4, 0x7f, rk809_vsel_range2 }, - { "DCDC_REG5", 0xde, 0x0f, rk809_vsel_range3}, - { "LDO_REG1", 0xcc, 0x7f, rk809_vsel_range4 }, - { "LDO_REG2", 0xce, 0x7f, rk809_vsel_range4 }, - { "LDO_REG3", 0xd0, 0x7f, rk809_vsel_range4 }, - { "LDO_REG4", 0xd2, 0x7f, rk809_vsel_range4 }, - { "LDO_REG5", 0xd4, 0x7f, rk809_vsel_range4 }, - { "LDO_REG6", 0xd6, 0x7f, rk809_vsel_range4 }, - { "LDO_REG7", 0xd8, 0x7f, rk809_vsel_range4 }, - { "LDO_REG8", 0xda, 0x7f, rk809_vsel_range4 }, - { "LDO_REG9", 0xdc, 0x7f, rk809_vsel_range4 }, + { "DCDC_REG1", 0xbb, 0x7f, 0xb5, 0x01, rk809_vsel_range1 }, + { "DCDC_REG2", 0xbe, 0x7f, 0xb5, 0x02, rk809_vsel_range1 }, + { "DCDC_REG3", 0xc1, 0x7f, 0xb5, 0x04, rk809_vsel_range1 }, + { "DCDC_REG4", 0xc4, 0x7f, 0xb5, 0x08, rk809_vsel_range2 }, + { "DCDC_REG5", 0xde, 0x0f, 0xb5, 0x20, rk809_vsel_range3 }, + { "LDO_REG1", 0xcc, 0x7f, 0xb6, 0x01, rk809_vsel_range4 }, + { "LDO_REG2", 0xce, 0x7f, 0xb6, 0x02, rk809_vsel_range4 }, + { "LDO_REG3", 0xd0, 0x7f, 0xb6, 0x04, rk809_vsel_range4 }, + { "LDO_REG4", 0xd2, 0x7f, 0xb6, 0x08, rk809_vsel_range4 }, + { "LDO_REG5", 0xd4, 0x7f, 0xb6, 0x10, rk809_vsel_range4 }, + { "LDO_REG6", 0xd6, 0x7f, 0xb6, 0x20, rk809_vsel_range4 }, + { "LDO_REG7", 0xd8, 0x7f, 0xb6, 0x40, rk809_vsel_range4 }, + { "LDO_REG8", 0xda, 0x7f, 0xb6, 0x80, rk809_vsel_range4 }, + { "LDO_REG9", 0xdc, 0x7f, 0xb5, 0x10, rk809_vsel_range4 }, + { "SWITCH_REG1", 0, 0, 0xb5, 0x40, NULL }, + { "SWITCH_REG2", 0, 0, 0xb5, 0x80, NULL }, { } }; @@ -308,20 +311,20 @@ const struct rkpmic_vsel_range rk817_boost_range[] = { }; const struct rkpmic_regdata rk817_regdata[] = { - { "DCDC_REG1", 0xbb, 0x7f, rk809_vsel_range1 }, - { "DCDC_REG2", 0xbe, 0x7f, rk809_vsel_range1 }, - { "DCDC_REG3", 0xc1, 0x7f, rk809_vsel_range1 }, - { "DCDC_REG4", 0xc4, 0x7f, rk809_vsel_range2 }, - { "LDO_REG1", 0xcc, 0x7f, rk809_vsel_range4 }, - { "LDO_REG2", 0xce, 0x7f, rk809_vsel_range4 }, - { "LDO_REG3", 0xd0, 0x7f, rk809_vsel_range4 }, - { "LDO_REG4", 0xd2, 0x7f, rk809_vsel_range4 }, - { "LDO_REG5", 0xd4, 0x7f, rk809_vsel_range4 }, - { "LDO_REG6", 0xd6, 0x7f, rk809_vsel_range4 }, - { "LDO_REG7", 0xd8, 0x7f, rk809_vsel_range4 }, - { "LDO_REG8", 0xda, 0x7f, rk809_vsel_range4 }, - { "LDO_REG9", 0xdc, 0x7f, rk809_vsel_range4 }, - { "BOOST", 0xde, 0x07, rk817_boost_range }, + { "DCDC_REG1", 0xbb, 0x7f, 0, 0, rk809_vsel_range1 }, + { "DCDC_REG2", 0xbe, 0x7f, 0, 0, rk809_vsel_range1 }, + { "DCDC_REG3", 0xc1, 0x7f, 0, 0, rk809_vsel_range1 }, + { "DCDC_REG4", 0xc4, 0x7f, 0, 0, rk809_vsel_range2 }, + { "LDO_REG1", 0xcc, 0x7f, 0, 0, rk809_vsel_range4 }, + { "LDO_REG2", 0xce, 0x7f, 0, 0, rk809_vsel_range4 }, + { "LDO_REG3", 0xd0, 0x7f, 0, 0, rk809_vsel_range4 }, + { "LDO_REG4", 0xd2, 0x7f, 0, 0, rk809_vsel_range4 }, + { "LDO_REG5", 0xd4, 0x7f, 0, 0, rk809_vsel_range4 }, + { "LDO_REG6", 0xd6, 0x7f, 0, 0, rk809_vsel_range4 }, + { "LDO_REG7", 0xd8, 0x7f, 0, 0, rk809_vsel_range4 }, + { "LDO_REG8", 0xda, 0x7f, 0, 0, rk809_vsel_range4 }, + { "LDO_REG9", 0xdc, 0x7f, 0, 0, rk809_vsel_range4 }, + { "BOOST", 0xde, 0x07, 0, 0, rk817_boost_range }, { } }; @@ -531,6 +534,7 @@ rkpmic_activate(struct device *self, int act) val &= ~RK809_PMIC_SYS_CFG3_SLP_FUN_MASK; val |= RK809_PMIC_SYS_CFG3_SLP_FUN_NONE; rkpmic_reg_write(sc, RK809_PMIC_SYS_CFG3, val); + rkpmic_reg_write(sc, RK809_PMIC_INT_STS0, 0xff); } break; } @@ -556,7 +560,7 @@ rkpmic_intr(void *arg) struct rkpmic_regulator { struct rkpmic_softc *rr_sc; - uint8_t rr_reg, rr_mask; + uint8_t rr_vreg, rr_vmask; const struct rkpmic_vsel_range *rr_vsel_range; struct regulator_device rr_rd; @@ -564,13 +568,16 @@ struct rkpmic_regulator { uint32_t rkpmic_get_voltage(void *); int rkpmic_set_voltage(void *, uint32_t); +int rkpmic_do_set_voltage(struct rkpmic_regulator *, uint32_t, int); void rkpmic_attach_regulator(struct rkpmic_softc *sc, int node) { struct rkpmic_regulator *rr; char name[32]; - int i; + uint32_t voltage; + int i, snode; + uint8_t val; name[0] = 0; OF_getprop(node, "name", name, sizeof(name)); @@ -585,8 +592,8 @@ rkpmic_attach_regulator(struct rkpmic_softc *sc, int node) rr = malloc(sizeof(*rr), M_DEVBUF, M_WAITOK | M_ZERO); rr->rr_sc = sc; - rr->rr_reg = sc->sc_regdata[i].reg; - rr->rr_mask = sc->sc_regdata[i].mask; + rr->rr_vreg = sc->sc_regdata[i].vreg; + rr->rr_vmask = sc->sc_regdata[i].vmask; rr->rr_vsel_range = sc->sc_regdata[i].vsel_range; rr->rr_rd.rd_node = node; @@ -594,6 +601,25 @@ rkpmic_attach_regulator(struct rkpmic_softc *sc, int node) rr->rr_rd.rd_get_voltage = rkpmic_get_voltage; rr->rr_rd.rd_set_voltage = rkpmic_set_voltage; regulator_register(&rr->rr_rd); + + if (sc->sc_regdata[i].smask) { + snode = OF_getnodebyname(node, "regulator-state-mem"); + if (snode) { + val = rkpmic_reg_read(sc, sc->sc_regdata[i].sreg); + if (OF_getpropbool(snode, "regulator-on-in-suspend")) + val |= sc->sc_regdata[i].smask; + if (OF_getpropbool(snode, "regulator-off-in-suspend")) + val &= ~sc->sc_regdata[i].smask; + rkpmic_reg_write(sc, sc->sc_regdata[i].sreg, val); + + voltage = OF_getpropint(snode, + "regulator-suspend-min-microvolt", 0); + voltage = OF_getpropint(snode, + "regulator-suspend-microvolt", voltage); + if (voltage > 0) + rkpmic_do_set_voltage(rr, voltage, 1); + } + } } uint32_t @@ -604,7 +630,10 @@ rkpmic_get_voltage(void *cookie) uint8_t vsel; uint32_t ret = 0; - vsel = rkpmic_reg_read(rr->rr_sc, rr->rr_reg) & rr->rr_mask; + if (vsel_range == NULL) + return 0; + + vsel = rkpmic_reg_read(rr->rr_sc, rr->rr_vreg) & rr->rr_vmask; while (vsel_range->base) { ret = vsel_range->base; @@ -626,11 +655,19 @@ rkpmic_get_voltage(void *cookie) int rkpmic_set_voltage(void *cookie, uint32_t voltage) { - struct rkpmic_regulator *rr = cookie; + return rkpmic_do_set_voltage(cookie, voltage, 0); +} + +int +rkpmic_do_set_voltage(struct rkpmic_regulator *rr, uint32_t voltage, int sleep) +{ const struct rkpmic_vsel_range *vsel_range = rr->rr_vsel_range; uint32_t vmin, vmax, volt; uint8_t reg, vsel; + if (vsel_range == NULL) + return ENODEV; + while (vsel_range->base) { vmin = vsel_range->base; vmax = vmin + (vsel_range->vsel_max - vsel_range->vsel_min) * @@ -658,10 +695,10 @@ rkpmic_set_voltage(void *cookie, uint32_t voltage) if (vsel_range->base == 0) return EINVAL; - reg = rkpmic_reg_read(rr->rr_sc, rr->rr_reg); - reg &= ~rr->rr_mask; + reg = rkpmic_reg_read(rr->rr_sc, rr->rr_vreg + sleep); + reg &= ~rr->rr_vmask; reg |= vsel; - rkpmic_reg_write(rr->rr_sc, rr->rr_reg, reg); + rkpmic_reg_write(rr->rr_sc, rr->rr_vreg + sleep, reg); return 0; } diff --git a/sys/dev/i2c/pca9532.c b/sys/dev/i2c/pca9532.c index 38a570037..23e2ba42c 100644 --- a/sys/dev/i2c/pca9532.c +++ b/sys/dev/i2c/pca9532.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pca9532.c,v 1.4 2022/04/06 18:59:28 naddy Exp $ */ +/* $OpenBSD: pca9532.c,v 1.5 2024/05/28 13:21:13 jsg Exp $ */ /* * Copyright (c) 2006 Dale Rahn * @@ -48,8 +48,8 @@ struct pcaled_softc { int pcaled_match(struct device *, void *, void *); void pcaled_attach(struct device *, struct device *, void *); int pcaled_gpio_pin_read(void *arg, int pin); -void pcaled_gpio_pin_write (void *arg, int pin, int value); -void pcaled_gpio_pin_ctl (void *arg, int pin, int flags); +void pcaled_gpio_pin_write(void *arg, int pin, int value); +void pcaled_gpio_pin_ctl(void *arg, int pin, int flags); const struct cfattach pcaled_ca = { sizeof(struct pcaled_softc), pcaled_match, pcaled_attach @@ -150,7 +150,7 @@ fail: } void -pcaled_gpio_pin_write (void *arg, int pin, int value) +pcaled_gpio_pin_write(void *arg, int pin, int value) { struct pcaled_softc *sc = arg; uint8_t cmd, data; @@ -177,7 +177,7 @@ fail: } void -pcaled_gpio_pin_ctl (void *arg, int pin, int flags) +pcaled_gpio_pin_ctl(void *arg, int pin, int flags) { /* XXX all pins are inout */ } diff --git a/sys/dev/ic/ahci.c b/sys/dev/ic/ahci.c index 225b57eac..0f7ac5dec 100644 --- a/sys/dev/ic/ahci.c +++ b/sys/dev/ic/ahci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ahci.c,v 1.40 2024/04/23 13:09:21 jsg Exp $ */ +/* $OpenBSD: ahci.c,v 1.41 2024/05/28 01:37:53 jsg Exp $ */ /* * Copyright (c) 2006 David Gwynne @@ -2350,9 +2350,9 @@ failall: sizeof(struct ata_fis_d2h)); } - ccb->ccb_done(ccb); - processed |= 1 << ccb->ccb_slot; + + ccb->ccb_done(ccb); } if (need_restart) { diff --git a/sys/dev/ic/nvme.c b/sys/dev/ic/nvme.c index b04ab4d19..106889186 100644 --- a/sys/dev/ic/nvme.c +++ b/sys/dev/ic/nvme.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nvme.c,v 1.112 2024/05/24 12:04:07 krw Exp $ */ +/* $OpenBSD: nvme.c,v 1.115 2024/05/28 00:24:44 jsg Exp $ */ /* * Copyright (c) 2014 David Gwynne @@ -156,6 +156,7 @@ static const struct nvme_ops nvme_ops = { }; #define NVME_TIMO_QOP 5000 /* ms to create/delete queue */ +#define NVME_TIMO_PT 5000 /* ms to complete passthrough */ #define NVME_TIMO_IDENT 10000 /* ms to probe/identify */ #define NVME_TIMO_DELAYNS 10 /* ns to delay() in poll loop */ @@ -978,7 +979,7 @@ nvme_passthrough_cmd(struct nvme_softc *sc, struct nvme_pt_cmd *pt, int dv_unit, nvme_dmamem_sync(sc, mem, BUS_DMASYNC_PREREAD); } - flags = nvme_poll(sc, sc->sc_admin_q, ccb, nvme_sqe_fill, NVME_TIMO_QOP); + flags = nvme_poll(sc, sc->sc_admin_q, ccb, nvme_sqe_fill, NVME_TIMO_PT); if (pt->pt_databuflen > 0) { nvme_dmamem_sync(sc, mem, BUS_DMASYNC_POSTREAD); @@ -1896,12 +1897,12 @@ nvme_bioctl_sdname(const struct nvme_softc *sc, int target) const struct sd_softc *sd; link = scsi_get_link(sc->sc_scsibus, target, 0); - if (link) { - sd = (struct sd_softc *)(link->device_softc); - if (ISSET(link->state, SDEV_S_DYING) || sd == NULL || - ISSET(sd->flags, SDF_DYING)) - return NULL; - } + if (link == NULL) + return NULL; + sd = (struct sd_softc *)(link->device_softc); + if (ISSET(link->state, SDEV_S_DYING) || sd == NULL || + ISSET(sd->flags, SDF_DYING)) + return NULL; if (nvme_read4(sc, NVME_VS) == 0xffffffff) return NULL; diff --git a/sys/dev/ic/qwx.c b/sys/dev/ic/qwx.c index 97c935c7d..f8c475ed9 100644 --- a/sys/dev/ic/qwx.c +++ b/sys/dev/ic/qwx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: qwx.c,v 1.59 2024/05/03 14:32:11 stsp Exp $ */ +/* $OpenBSD: qwx.c,v 1.61 2024/05/28 13:02:45 jsg Exp $ */ /* * Copyright 2023 Stefan Sperling @@ -152,6 +152,11 @@ int qwx_dp_tx_send_reo_cmd(struct qwx_softc *, struct dp_rx_tid *, void (*func)(struct qwx_dp *, void *, enum hal_reo_cmd_status)); void qwx_dp_rx_deliver_msdu(struct qwx_softc *, struct qwx_rx_msdu *); void qwx_dp_service_mon_ring(void *); +void qwx_peer_frags_flush(struct qwx_softc *, struct ath11k_peer *); +int qwx_wmi_vdev_install_key(struct qwx_softc *, + struct wmi_vdev_install_key_arg *, uint8_t); +int qwx_dp_peer_rx_pn_replay_config(struct qwx_softc *, struct qwx_vif *, + struct ieee80211_node *, struct ieee80211_key *, int); int qwx_scan(struct qwx_softc *); void qwx_scan_abort(struct qwx_softc *); @@ -178,7 +183,7 @@ qwx_init(struct ifnet *ifp) struct ieee80211com *ic = &sc->sc_ic; sc->fw_mode = ATH11K_FIRMWARE_MODE_NORMAL; - sc->crypto_mode = ATH11K_CRYPT_MODE_SW; + sc->crypto_mode = ATH11K_CRYPT_MODE_HW; sc->frame_mode = ATH11K_HW_TXRX_NATIVE_WIFI; ic->ic_state = IEEE80211_S_INIT; sc->ns_nstate = IEEE80211_S_INIT; @@ -283,6 +288,7 @@ qwx_stop(struct ifnet *ifp) /* Cancel scheduled tasks and let any stale tasks finish up. */ task_del(systq, &sc->init_task); qwx_del_task(sc, sc->sc_nswq, &sc->newstate_task); + qwx_del_task(sc, systq, &sc->setkey_task); refcnt_finalize(&sc->task_refs, "qwxstop"); clear_bit(ATH11K_FLAG_CRASH_FLUSH, sc->sc_flags); @@ -495,6 +501,262 @@ qwx_media_change(struct ifnet *ifp) return err; } +int +qwx_queue_setkey_cmd(struct ieee80211com *ic, struct ieee80211_node *ni, + struct ieee80211_key *k, int cmd) +{ + struct qwx_softc *sc = ic->ic_softc; + struct qwx_setkey_task_arg *a; + + if (sc->setkey_nkeys >= nitems(sc->setkey_arg) || + k->k_id > WMI_MAX_KEY_INDEX) + return ENOSPC; + + a = &sc->setkey_arg[sc->setkey_cur]; + a->ni = ieee80211_ref_node(ni); + a->k = k; + a->cmd = cmd; + sc->setkey_cur = (sc->setkey_cur + 1) % nitems(sc->setkey_arg); + sc->setkey_nkeys++; + qwx_add_task(sc, systq, &sc->setkey_task); + return EBUSY; +} + +int +qwx_set_key(struct ieee80211com *ic, struct ieee80211_node *ni, + struct ieee80211_key *k) +{ + struct qwx_softc *sc = ic->ic_softc; + + if (test_bit(ATH11K_FLAG_HW_CRYPTO_DISABLED, sc->sc_flags) || + (k->k_cipher != IEEE80211_CIPHER_CCMP && + k->k_cipher != IEEE80211_CIPHER_TKIP)) + return ieee80211_set_key(ic, ni, k); + + return qwx_queue_setkey_cmd(ic, ni, k, QWX_ADD_KEY); +} + +void +qwx_delete_key(struct ieee80211com *ic, struct ieee80211_node *ni, + struct ieee80211_key *k) +{ + struct qwx_softc *sc = ic->ic_softc; + + if (test_bit(ATH11K_FLAG_HW_CRYPTO_DISABLED, sc->sc_flags) || + (k->k_cipher != IEEE80211_CIPHER_CCMP && + k->k_cipher != IEEE80211_CIPHER_TKIP)) { + ieee80211_delete_key(ic, ni, k); + return; + } + + if (ic->ic_state != IEEE80211_S_RUN) { + /* Keys removed implicitly when firmware station is removed. */ + return; + } + + /* + * net80211 calls us with a NULL node when deleting group keys, + * but firmware expects a MAC address in the command. + */ + if (ni == NULL) + ni = ic->ic_bss; + + qwx_queue_setkey_cmd(ic, ni, k, QWX_DEL_KEY); +} + +int +qwx_wmi_install_key_cmd(struct qwx_softc *sc, struct qwx_vif *arvif, + uint8_t *macaddr, struct ieee80211_key *k, uint32_t flags, + int delete_key) +{ + int ret; + struct wmi_vdev_install_key_arg arg = { + .vdev_id = arvif->vdev_id, + .key_idx = k->k_id, + .key_len = k->k_len, + .key_data = k->k_key, + .key_flags = flags, + .macaddr = macaddr, + }; + uint8_t pdev_id = 0; /* TODO: derive pdev ID somehow? */ +#ifdef notyet + lockdep_assert_held(&arvif->ar->conf_mutex); + + reinit_completion(&ar->install_key_done); +#endif + if (test_bit(ATH11K_FLAG_HW_CRYPTO_DISABLED, sc->sc_flags)) + return 0; + + if (delete_key) { + arg.key_cipher = WMI_CIPHER_NONE; + arg.key_data = NULL; + } else { + switch (k->k_cipher) { + case IEEE80211_CIPHER_CCMP: + arg.key_cipher = WMI_CIPHER_AES_CCM; +#if 0 + /* TODO: Re-check if flag is valid */ + key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV_MGMT; +#endif + break; + case IEEE80211_CIPHER_TKIP: + arg.key_cipher = WMI_CIPHER_TKIP; + arg.key_txmic_len = 8; + arg.key_rxmic_len = 8; + break; +#if 0 + case WLAN_CIPHER_SUITE_CCMP_256: + arg.key_cipher = WMI_CIPHER_AES_CCM; + break; + case WLAN_CIPHER_SUITE_GCMP: + case WLAN_CIPHER_SUITE_GCMP_256: + arg.key_cipher = WMI_CIPHER_AES_GCM; + break; +#endif + default: + printf("%s: cipher %u is not supported\n", + sc->sc_dev.dv_xname, k->k_cipher); + return EOPNOTSUPP; + } +#if 0 + if (test_bit(ATH11K_FLAG_RAW_MODE, &ar->ab->dev_flags)) + key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV | + IEEE80211_KEY_FLAG_RESERVE_TAILROOM; +#endif + } + + sc->install_key_done = 0; + ret = qwx_wmi_vdev_install_key(sc, &arg, pdev_id); + if (ret) + return ret; + + while (!sc->install_key_done) { + ret = tsleep_nsec(&sc->install_key_done, 0, "qwxinstkey", + SEC_TO_NSEC(1)); + if (ret) { + printf("%s: install key timeout\n", + sc->sc_dev.dv_xname); + return -1; + } + } + + return sc->install_key_status; +} + +int +qwx_add_sta_key(struct qwx_softc *sc, struct ieee80211_node *ni, + struct ieee80211_key *k) +{ + struct ieee80211com *ic = &sc->sc_ic; + struct qwx_node *nq = (struct qwx_node *)ni; + struct ath11k_peer *peer = &nq->peer; + struct qwx_vif *arvif = TAILQ_FIRST(&sc->vif_list); /* XXX */ + int ret = 0; + uint32_t flags = 0; + const int want_keymask = (QWX_NODE_FLAG_HAVE_PAIRWISE_KEY | + QWX_NODE_FLAG_HAVE_GROUP_KEY); + + /* + * Flush the fragments cache during key (re)install to + * ensure all frags in the new frag list belong to the same key. + */ + qwx_peer_frags_flush(sc, peer); + + if (k->k_flags & IEEE80211_KEY_GROUP) + flags |= WMI_KEY_GROUP; + else + flags |= WMI_KEY_PAIRWISE; + + ret = qwx_wmi_install_key_cmd(sc, arvif, ni->ni_macaddr, k, flags, 0); + if (ret) { + printf("%s: installing crypto key failed (%d)\n", + sc->sc_dev.dv_xname, ret); + return ret; + } + + ret = qwx_dp_peer_rx_pn_replay_config(sc, arvif, ni, k, 0); + if (ret) { + printf("%s: failed to offload PN replay detection %d\n", + sc->sc_dev.dv_xname, ret); + return ret; + } + + if (k->k_flags & IEEE80211_KEY_GROUP) + nq->flags |= QWX_NODE_FLAG_HAVE_GROUP_KEY; + else + nq->flags |= QWX_NODE_FLAG_HAVE_PAIRWISE_KEY; + + if ((nq->flags & want_keymask) == want_keymask) { + DPRINTF("marking port %s valid\n", + ether_sprintf(ni->ni_macaddr)); + ni->ni_port_valid = 1; + ieee80211_set_link_state(ic, LINK_STATE_UP); + } + + return 0; +} + +int +qwx_del_sta_key(struct qwx_softc *sc, struct ieee80211_node *ni, + struct ieee80211_key *k) +{ + struct qwx_node *nq = (struct qwx_node *)ni; + struct qwx_vif *arvif = TAILQ_FIRST(&sc->vif_list); /* XXX */ + int ret = 0; + + ret = qwx_wmi_install_key_cmd(sc, arvif, ni->ni_macaddr, k, 0, 1); + if (ret) { + printf("%s: deleting crypto key failed (%d)\n", + sc->sc_dev.dv_xname, ret); + return ret; + } + + ret = qwx_dp_peer_rx_pn_replay_config(sc, arvif, ni, k, 1); + if (ret) { + printf("%s: failed to disable PN replay detection %d\n", + sc->sc_dev.dv_xname, ret); + return ret; + } + + if (k->k_flags & IEEE80211_KEY_GROUP) + nq->flags &= ~QWX_NODE_FLAG_HAVE_GROUP_KEY; + else + nq->flags &= ~QWX_NODE_FLAG_HAVE_PAIRWISE_KEY; + + return 0; +} + +void +qwx_setkey_task(void *arg) +{ + struct qwx_softc *sc = arg; + struct ieee80211com *ic = &sc->sc_ic; + struct qwx_setkey_task_arg *a; + int err = 0, s = splnet(); + + while (sc->setkey_nkeys > 0) { + if (err || test_bit(ATH11K_FLAG_CRASH_FLUSH, sc->sc_flags)) + break; + a = &sc->setkey_arg[sc->setkey_tail]; + KASSERT(a->cmd == QWX_ADD_KEY || a->cmd == QWX_DEL_KEY); + if (ic->ic_state == IEEE80211_S_RUN) { + if (a->cmd == QWX_ADD_KEY) + err = qwx_add_sta_key(sc, a->ni, a->k); + else + err = qwx_del_sta_key(sc, a->ni, a->k); + } + ieee80211_release_node(ic, a->ni); + a->ni = NULL; + a->k = NULL; + sc->setkey_tail = (sc->setkey_tail + 1) % + nitems(sc->setkey_arg); + sc->setkey_nkeys--; + } + + refcnt_rele_wake(&sc->task_refs); + splx(s); +} + int qwx_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg) { @@ -510,15 +772,27 @@ qwx_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg) if (sc->ns_nstate == nstate && nstate != IEEE80211_S_SCAN && nstate != IEEE80211_S_AUTH) return 0; -#if 0 if (ic->ic_state == IEEE80211_S_RUN) { + struct qwx_setkey_task_arg *a; +#if 0 qwx_del_task(sc, systq, &sc->ba_task); +#endif qwx_del_task(sc, systq, &sc->setkey_task); + while (sc->setkey_nkeys > 0) { + a = &sc->setkey_arg[sc->setkey_tail]; + ieee80211_release_node(ic, a->ni); + a->ni = NULL; + sc->setkey_tail = (sc->setkey_tail + 1) % + nitems(sc->setkey_arg); + sc->setkey_nkeys--; + } memset(sc->setkey_arg, 0, sizeof(sc->setkey_arg)); sc->setkey_cur = sc->setkey_tail = sc->setkey_nkeys = 0; +#if 0 qwx_del_task(sc, systq, &sc->bgscan_done_task); - } #endif + } + sc->ns_nstate = nstate; sc->ns_arg = arg; @@ -636,7 +910,8 @@ struct cfdriver qwx_cd = { NULL, "qwx", DV_IFNET }; -void qwx_init_wmi_config_qca6390(struct qwx_softc *sc, +void +qwx_init_wmi_config_qca6390(struct qwx_softc *sc, struct target_resource_config *config) { config->num_vdevs = 4; @@ -726,7 +1001,8 @@ qwx_hw_ipq8074_reo_setup(struct qwx_softc *sc) FIELD_PREP(HAL_REO_DEST_RING_CTRL_HASH_RING_MAP, ring_hash_map)); } -void qwx_init_wmi_config_ipq8074(struct qwx_softc *sc, +void +qwx_init_wmi_config_ipq8074(struct qwx_softc *sc, struct target_resource_config *config) { config->num_vdevs = sc->num_radios * TARGET_NUM_VDEVS(sc); @@ -882,7 +1158,8 @@ qwx_hw_mac_id_to_srng_id_ipq8074(struct ath11k_hw_params *hw, int mac_id) return 0; } -int qwx_hw_mac_id_to_pdev_id_qca6390(struct ath11k_hw_params *hw, int mac_id) +int +qwx_hw_mac_id_to_pdev_id_qca6390(struct ath11k_hw_params *hw, int mac_id) { return 0; } @@ -893,6 +1170,13 @@ qwx_hw_mac_id_to_srng_id_qca6390(struct ath11k_hw_params *hw, int mac_id) return mac_id; } +int +qwx_hw_ipq8074_rx_desc_get_first_msdu(struct hal_rx_desc *desc) +{ + return !!FIELD_GET(RX_MSDU_END_INFO2_FIRST_MSDU, + le32toh(desc->u.ipq8074.msdu_end.info2)); +} + uint8_t qwx_hw_ipq8074_rx_desc_get_l3_pad_bytes(struct hal_rx_desc *desc) { @@ -1059,6 +1343,12 @@ qwx_hw_ipq8074_rx_desc_set_msdu_len(struct hal_rx_desc *desc, uint16_t len) desc->u.ipq8074.msdu_start.info1 = htole32(info); } +int +qwx_dp_rx_h_msdu_end_first_msdu(struct qwx_softc *sc, struct hal_rx_desc *desc) +{ + return sc->hw_params.hw_ops->rx_desc_get_first_msdu(desc); +} + int qwx_hw_ipq8074_rx_desc_mac_addr2_valid(struct hal_rx_desc *desc) { @@ -1503,7 +1793,8 @@ qwx_hw_ipq8074_mac_from_pdev_id(int pdev_idx) } } -uint8_t qwx_hw_ipq6018_mac_from_pdev_id(int pdev_idx) +uint8_t +qwx_hw_ipq6018_mac_from_pdev_id(int pdev_idx) { return pdev_idx; } @@ -1524,7 +1815,9 @@ const struct ath11k_hw_ops ipq8074_ops = { .mac_id_to_srng_id = qwx_hw_mac_id_to_srng_id_ipq8074, #if notyet .tx_mesh_enable = ath11k_hw_ipq8074_tx_mesh_enable, - .rx_desc_get_first_msdu = ath11k_hw_ipq8074_rx_desc_get_first_msdu, +#endif + .rx_desc_get_first_msdu = qwx_hw_ipq8074_rx_desc_get_first_msdu, +#if notyet .rx_desc_get_last_msdu = ath11k_hw_ipq8074_rx_desc_get_last_msdu, #endif .rx_desc_get_l3_pad_bytes = qwx_hw_ipq8074_rx_desc_get_l3_pad_bytes, @@ -1576,7 +1869,9 @@ const struct ath11k_hw_ops ipq6018_ops = { .mac_id_to_srng_id = qwx_hw_mac_id_to_srng_id_ipq8074, #if notyet .tx_mesh_enable = ath11k_hw_ipq8074_tx_mesh_enable, - .rx_desc_get_first_msdu = ath11k_hw_ipq8074_rx_desc_get_first_msdu, +#endif + .rx_desc_get_first_msdu = qwx_hw_ipq8074_rx_desc_get_first_msdu, +#if notyet .rx_desc_get_last_msdu = ath11k_hw_ipq8074_rx_desc_get_last_msdu, #endif .rx_desc_get_l3_pad_bytes = qwx_hw_ipq8074_rx_desc_get_l3_pad_bytes, @@ -1628,7 +1923,9 @@ const struct ath11k_hw_ops qca6390_ops = { .mac_id_to_srng_id = qwx_hw_mac_id_to_srng_id_qca6390, #if notyet .tx_mesh_enable = ath11k_hw_ipq8074_tx_mesh_enable, - .rx_desc_get_first_msdu = ath11k_hw_ipq8074_rx_desc_get_first_msdu, +#endif + .rx_desc_get_first_msdu = qwx_hw_ipq8074_rx_desc_get_first_msdu, +#if notyet .rx_desc_get_last_msdu = ath11k_hw_ipq8074_rx_desc_get_last_msdu, #endif .rx_desc_get_l3_pad_bytes = qwx_hw_ipq8074_rx_desc_get_l3_pad_bytes, @@ -1680,7 +1977,9 @@ const struct ath11k_hw_ops qcn9074_ops = { .mac_id_to_srng_id = qwx_hw_mac_id_to_srng_id_ipq8074, #if notyet .tx_mesh_enable = ath11k_hw_qcn9074_tx_mesh_enable, - .rx_desc_get_first_msdu = ath11k_hw_qcn9074_rx_desc_get_first_msdu, +#endif + .rx_desc_get_first_msdu = qwx_hw_qcn9074_rx_desc_get_first_msdu, +#if notyet .rx_desc_get_last_msdu = ath11k_hw_qcn9074_rx_desc_get_last_msdu, #endif .rx_desc_get_l3_pad_bytes = qwx_hw_qcn9074_rx_desc_get_l3_pad_bytes, @@ -1732,7 +2031,9 @@ const struct ath11k_hw_ops wcn6855_ops = { .mac_id_to_srng_id = qwx_hw_mac_id_to_srng_id_qca6390, #if notyet .tx_mesh_enable = ath11k_hw_wcn6855_tx_mesh_enable, - .rx_desc_get_first_msdu = ath11k_hw_wcn6855_rx_desc_get_first_msdu, +#endif + .rx_desc_get_first_msdu = qwx_hw_wcn6855_rx_desc_get_first_msdu, +#if notyet .rx_desc_get_last_msdu = ath11k_hw_wcn6855_rx_desc_get_last_msdu, #endif .rx_desc_get_l3_pad_bytes = qwx_hw_wcn6855_rx_desc_get_l3_pad_bytes, @@ -1784,7 +2085,9 @@ const struct ath11k_hw_ops wcn6750_ops = { .mac_id_to_srng_id = qwx_hw_mac_id_to_srng_id_qca6390, #if notyet .tx_mesh_enable = ath11k_hw_qcn9074_tx_mesh_enable, - .rx_desc_get_first_msdu = ath11k_hw_qcn9074_rx_desc_get_first_msdu, +#endif + .rx_desc_get_first_msdu = qwx_hw_qcn9074_rx_desc_get_first_msdu, +#if notyet .rx_desc_get_last_msdu = ath11k_hw_qcn9074_rx_desc_get_last_msdu, #endif .rx_desc_get_l3_pad_bytes = qwx_hw_qcn9074_rx_desc_get_l3_pad_bytes, @@ -11826,8 +12129,8 @@ qwx_print_reg_rule(struct qwx_softc *sc, const char *band, } } -struct cur_reg_rule -*qwx_create_reg_rules_from_wmi(uint32_t num_reg_rules, +struct cur_reg_rule * +qwx_create_reg_rules_from_wmi(uint32_t num_reg_rules, struct wmi_regulatory_rule_struct *wmi_reg_rule) { struct cur_reg_rule *reg_rule_ptr; @@ -12990,6 +13293,84 @@ qwx_roam_event(struct qwx_softc *sc, struct mbuf *m) } } +int +qwx_pull_vdev_install_key_compl_ev(struct qwx_softc *sc, struct mbuf *m, + struct wmi_vdev_install_key_complete_arg *arg) +{ + const void **tb; + const struct wmi_vdev_install_key_compl_event *ev; + int ret; + + tb = qwx_wmi_tlv_parse_alloc(sc, mtod(m, void *), m->m_pkthdr.len); + if (tb == NULL) { + ret = ENOMEM; + printf("%s: failed to parse tlv: %d\n", + sc->sc_dev.dv_xname, ret); + return ret; + } + + ev = tb[WMI_TAG_VDEV_INSTALL_KEY_COMPLETE_EVENT]; + if (!ev) { + printf("%s: failed to fetch vdev install key compl ev\n", + sc->sc_dev.dv_xname); + free(tb, M_DEVBUF, WMI_TAG_MAX * sizeof(*tb)); + return EPROTO; + } + + arg->vdev_id = ev->vdev_id; + arg->macaddr = ev->peer_macaddr.addr; + arg->key_idx = ev->key_idx; + arg->key_flags = ev->key_flags; + arg->status = ev->status; + + free(tb, M_DEVBUF, WMI_TAG_MAX * sizeof(*tb)); + return 0; +} + +void +qwx_vdev_install_key_compl_event(struct qwx_softc *sc, struct mbuf *m) +{ + struct wmi_vdev_install_key_complete_arg install_key_compl = { 0 }; + struct qwx_vif *arvif; + + if (qwx_pull_vdev_install_key_compl_ev(sc, m, + &install_key_compl) != 0) { + printf("%s: failed to extract install key compl event\n", + sc->sc_dev.dv_xname); + return; + } + + DNPRINTF(QWX_D_WMI, "%s: event vdev install key ev idx %d flags %08x " + "macaddr %s status %d\n", __func__, install_key_compl.key_idx, + install_key_compl.key_flags, + ether_sprintf((u_char *)install_key_compl.macaddr), + install_key_compl.status); + + TAILQ_FOREACH(arvif, &sc->vif_list, entry) { + if (arvif->vdev_id == install_key_compl.vdev_id) + break; + } + if (!arvif) { + printf("%s: invalid vdev id in install key compl ev %d\n", + sc->sc_dev.dv_xname, install_key_compl.vdev_id); + return; + } + + sc->install_key_status = 0; + + if (install_key_compl.status != + WMI_VDEV_INSTALL_KEY_COMPL_STATUS_SUCCESS) { + printf("%s: install key failed for %s status %d\n", + sc->sc_dev.dv_xname, + ether_sprintf((u_char *)install_key_compl.macaddr), + install_key_compl.status); + sc->install_key_status = install_key_compl.status; + } + + sc->install_key_done = 1; + wakeup(&sc->install_key_done); +} + void qwx_wmi_tlv_op_rx(struct qwx_softc *sc, struct mbuf *m) { @@ -13060,10 +13441,10 @@ qwx_wmi_tlv_op_rx(struct qwx_softc *sc, struct mbuf *m) case WMI_PDEV_BSS_CHAN_INFO_EVENTID: ath11k_pdev_bss_chan_info_event(ab, skb); break; - case WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID: - ath11k_vdev_install_key_compl_event(ab, skb); - break; #endif + case WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID: + qwx_vdev_install_key_compl_event(sc, m); + break; case WMI_SERVICE_AVAILABLE_EVENTID: qwx_service_available_event(sc, m); break; @@ -15813,6 +16194,16 @@ qwx_dp_rx_get_attention(struct qwx_softc *sc, struct hal_rx_desc *desc) return sc->hw_params.hw_ops->rx_desc_get_attention(desc); } +int +qwx_dp_rx_h_attn_is_mcbc(struct qwx_softc *sc, struct hal_rx_desc *desc) +{ + struct rx_attention *attn = qwx_dp_rx_get_attention(sc, desc); + + return qwx_dp_rx_h_msdu_end_first_msdu(sc, desc) && + (!!FIELD_GET(RX_ATTENTION_INFO1_MCAST_BCAST, + le32toh(attn->info1))); +} + static inline uint8_t qwx_dp_rx_h_msdu_end_l3pad(struct qwx_softc *sc, struct hal_rx_desc *desc) { @@ -15873,6 +16264,13 @@ qwx_dp_rx_h_attn_msdu_len_err(struct qwx_softc *sc, struct hal_rx_desc *desc) return errmap & DP_RX_MPDU_ERR_MSDU_LEN; } +int +qwx_dp_rx_h_attn_is_decrypted(struct rx_attention *attn) +{ + return (FIELD_GET(RX_ATTENTION_INFO2_DCRYPT_STATUS_CODE, + le32toh(attn->info2)) == RX_DESC_DECRYPT_STATUS_CODE_OK); +} + int qwx_dp_rx_msdu_coalesce(struct qwx_softc *sc, struct qwx_rx_msdu_list *msdu_list, struct qwx_rx_msdu *first, struct qwx_rx_msdu *last, uint8_t l3pad_bytes, @@ -15908,7 +16306,13 @@ void qwx_dp_rx_h_undecap_nwifi(struct qwx_softc *sc, struct qwx_rx_msdu *msdu, uint8_t *first_hdr, enum hal_encrypt_type enctype) { - printf("%s: not implemented\n", __func__); + /* + * This function will need to do some work once we are receiving + * aggregated frames. For now, it needs to do nothing. + */ + + if (!msdu->is_first_msdu) + printf("%s: not implemented\n", __func__); } void @@ -16034,28 +16438,28 @@ qwx_dp_rx_h_undecap(struct qwx_softc *sc, struct qwx_rx_msdu *msdu, } } - -void +int qwx_dp_rx_h_mpdu(struct qwx_softc *sc, struct qwx_rx_msdu *msdu, struct hal_rx_desc *rx_desc) { -#if 0 - bool fill_crypto_hdr; -#endif + struct ieee80211com *ic = &sc->sc_ic; + int fill_crypto_hdr = 0; enum hal_encrypt_type enctype; int is_decrypted = 0; #if 0 struct ath11k_skb_rxcb *rxcb; - struct ieee80211_hdr *hdr; +#endif + struct ieee80211_frame *wh; +#if 0 struct ath11k_peer *peer; +#endif struct rx_attention *rx_attention; - u32 err_bitmap; - - /* PN for multicast packets will be checked in mac80211 */ - rxcb = ATH11K_SKB_RXCB(msdu); - fill_crypto_hdr = ath11k_dp_rx_h_attn_is_mcbc(ar->ab, rx_desc); - rxcb->is_mcbc = fill_crypto_hdr; + uint32_t err_bitmap; + /* PN for multicast packets will be checked in net80211 */ + fill_crypto_hdr = qwx_dp_rx_h_attn_is_mcbc(sc, rx_desc); + msdu->is_mcbc = fill_crypto_hdr; +#if 0 if (rxcb->is_mcbc) { rxcb->peer_id = ath11k_dp_rx_h_mpdu_start_peer_id(ar->ab, rx_desc); rxcb->seq_no = ath11k_dp_rx_h_mpdu_start_seq_no(ar->ab, rx_desc); @@ -16074,12 +16478,12 @@ qwx_dp_rx_h_mpdu(struct qwx_softc *sc, struct qwx_rx_msdu *msdu, #if 0 } spin_unlock_bh(&ar->ab->base_lock); - - rx_attention = ath11k_dp_rx_get_attention(ar->ab, rx_desc); - err_bitmap = ath11k_dp_rx_h_attn_mpdu_err(rx_attention); +#endif + rx_attention = qwx_dp_rx_get_attention(sc, rx_desc); + err_bitmap = qwx_dp_rx_h_attn_mpdu_err(rx_attention); if (enctype != HAL_ENCRYPT_TYPE_OPEN && !err_bitmap) - is_decrypted = ath11k_dp_rx_h_attn_is_decrypted(rx_attention); - + is_decrypted = qwx_dp_rx_h_attn_is_decrypted(rx_attention); +#if 0 /* Clear per-MPDU flags while leaving per-PPDU flags intact */ rx_status->flag &= ~(RX_FLAG_FAILED_FCS_CRC | RX_FLAG_MMIC_ERROR | @@ -16087,12 +16491,23 @@ qwx_dp_rx_h_mpdu(struct qwx_softc *sc, struct qwx_rx_msdu *msdu, RX_FLAG_IV_STRIPPED | RX_FLAG_MMIC_STRIPPED); - if (err_bitmap & DP_RX_MPDU_ERR_FCS) - rx_status->flag |= RX_FLAG_FAILED_FCS_CRC; +#endif + if (err_bitmap & DP_RX_MPDU_ERR_FCS) { + if (ic->ic_flags & IEEE80211_F_RSNON) + ic->ic_stats.is_rx_decryptcrc++; + else + ic->ic_stats.is_rx_decap++; + } + + /* XXX Trusting firmware to handle Michael MIC counter-measures... */ if (err_bitmap & DP_RX_MPDU_ERR_TKIP_MIC) - rx_status->flag |= RX_FLAG_MMIC_ERROR; + ic->ic_stats.is_rx_locmicfail++; + + if (err_bitmap & DP_RX_MPDU_ERR_DECRYPT) + ic->ic_stats.is_rx_wepfail++; if (is_decrypted) { +#if 0 rx_status->flag |= RX_FLAG_DECRYPTED | RX_FLAG_MMIC_STRIPPED; if (fill_crypto_hdr) @@ -16101,21 +16516,23 @@ qwx_dp_rx_h_mpdu(struct qwx_softc *sc, struct qwx_rx_msdu *msdu, else rx_status->flag |= RX_FLAG_IV_STRIPPED | RX_FLAG_PN_VALIDATED; +#endif + msdu->rxi.rxi_flags |= IEEE80211_RXI_HWDEC; } - +#if 0 ath11k_dp_rx_h_csum_offload(ar, msdu); #endif qwx_dp_rx_h_undecap(sc, msdu, rx_desc, enctype, is_decrypted); -#if 0 - if (!is_decrypted || fill_crypto_hdr) - return; - if (ath11k_dp_rx_h_msdu_start_decap_type(ar->ab, rx_desc) != + if (is_decrypted && !fill_crypto_hdr && + qwx_dp_rx_h_msdu_start_decap_type(sc, rx_desc) != DP_RX_DECAP_TYPE_ETHERNET2_DIX) { - hdr = (void *)msdu->data; - hdr->frame_control &= ~__cpu_to_le16(IEEE80211_FCTL_PROTECTED); + /* Hardware has stripped the IV. */ + wh = mtod(msdu->m, struct ieee80211_frame *); + wh->i_fc[1] &= ~IEEE80211_FC1_PROTECTED; } -#endif + + return err_bitmap ? EIO : 0; } int @@ -16189,9 +16606,8 @@ qwx_dp_rx_process_msdu(struct qwx_softc *sc, struct qwx_rx_msdu *msdu, memset(&msdu->rxi, 0, sizeof(msdu->rxi)); qwx_dp_rx_h_ppdu(sc, rx_desc, &msdu->rxi); - qwx_dp_rx_h_mpdu(sc, msdu, rx_desc); - return 0; + return qwx_dp_rx_h_mpdu(sc, msdu, rx_desc); } void @@ -18003,6 +18419,65 @@ qwx_wmi_send_peer_delete_cmd(struct qwx_softc *sc, const uint8_t *peer_addr, return 0; } +int +qwx_wmi_vdev_install_key(struct qwx_softc *sc, + struct wmi_vdev_install_key_arg *arg, uint8_t pdev_id) +{ + struct qwx_pdev_wmi *wmi = &sc->wmi.wmi[pdev_id]; + struct wmi_vdev_install_key_cmd *cmd; + struct wmi_tlv *tlv; + struct mbuf *m; + int ret, len; + int key_len_aligned = roundup(arg->key_len, sizeof(uint32_t)); + + len = sizeof(*cmd) + TLV_HDR_SIZE + key_len_aligned; + + m = qwx_wmi_alloc_mbuf(len); + if (m == NULL) + return -ENOMEM; + + cmd = (struct wmi_vdev_install_key_cmd *)(mtod(m, uint8_t *) + + sizeof(struct ath11k_htc_hdr) + sizeof(struct wmi_cmd_hdr)); + cmd->tlv_header = FIELD_PREP(WMI_TLV_TAG, + WMI_TAG_VDEV_INSTALL_KEY_CMD) | + FIELD_PREP(WMI_TLV_LEN, sizeof(*cmd) - TLV_HDR_SIZE); + cmd->vdev_id = arg->vdev_id; + IEEE80211_ADDR_COPY(cmd->peer_macaddr.addr, arg->macaddr); + cmd->key_idx = arg->key_idx; + cmd->key_flags = arg->key_flags; + cmd->key_cipher = arg->key_cipher; + cmd->key_len = arg->key_len; + cmd->key_txmic_len = arg->key_txmic_len; + cmd->key_rxmic_len = arg->key_rxmic_len; + + if (arg->key_rsc_counter) + memcpy(&cmd->key_rsc_counter, &arg->key_rsc_counter, + sizeof(struct wmi_key_seq_counter)); + + tlv = (struct wmi_tlv *)(mtod(m, uint8_t *) + + sizeof(struct ath11k_htc_hdr) + sizeof(struct wmi_cmd_hdr) + + sizeof(*cmd)); + tlv->header = FIELD_PREP(WMI_TLV_TAG, WMI_TAG_ARRAY_BYTE) | + FIELD_PREP(WMI_TLV_LEN, key_len_aligned); + if (arg->key_data) + memcpy(tlv->value, (uint8_t *)arg->key_data, + key_len_aligned); + + ret = qwx_wmi_cmd_send(wmi, m, WMI_VDEV_INSTALL_KEY_CMDID); + if (ret) { + printf("%s: failed to send WMI_VDEV_INSTALL_KEY cmd\n", + sc->sc_dev.dv_xname); + m_freem(m); + return ret; + } + + DNPRINTF(QWX_D_WMI, + "%s: cmd vdev install key idx %d cipher %d len %d\n", + __func__, arg->key_idx, arg->key_cipher, arg->key_len); + + return ret; +} + void qwx_wmi_copy_peer_flags(struct wmi_peer_assoc_complete_cmd *cmd, struct peer_assoc_params *param, int hw_crypto_disabled) @@ -23302,6 +23777,26 @@ qwx_dp_rx_frags_cleanup(struct qwx_softc *sc, struct dp_rx_tid *rx_tid, #endif } +void +qwx_peer_frags_flush(struct qwx_softc *sc, struct ath11k_peer *peer) +{ + struct dp_rx_tid *rx_tid; + int i; +#ifdef notyet + lockdep_assert_held(&ar->ab->base_lock); +#endif + for (i = 0; i < IEEE80211_NUM_TID; i++) { + rx_tid = &peer->rx_tid[i]; + + qwx_dp_rx_frags_cleanup(sc, rx_tid, 1); +#if 0 + spin_unlock_bh(&ar->ab->base_lock); + del_timer_sync(&rx_tid->frag_timer); + spin_lock_bh(&ar->ab->base_lock); +#endif + } +} + void qwx_peer_rx_tid_cleanup(struct qwx_softc *sc, struct ath11k_peer *peer) { @@ -23556,6 +24051,70 @@ peer_clean: return ret; } +int +qwx_dp_peer_rx_pn_replay_config(struct qwx_softc *sc, struct qwx_vif *arvif, + struct ieee80211_node *ni, struct ieee80211_key *k, int delete_key) +{ + struct ath11k_hal_reo_cmd cmd = {0}; + struct qwx_node *nq = (struct qwx_node *)ni; + struct ath11k_peer *peer = &nq->peer; + struct dp_rx_tid *rx_tid; + uint8_t tid; + int ret = 0; + + /* + * NOTE: Enable PN/TSC replay check offload only for unicast frames. + * We use net80211 PN/TSC replay check functionality for bcast/mcast + * for now. + */ + if (k->k_flags & IEEE80211_KEY_GROUP) + return 0; + + cmd.flag |= HAL_REO_CMD_FLG_NEED_STATUS; + cmd.upd0 |= HAL_REO_CMD_UPD0_PN | + HAL_REO_CMD_UPD0_PN_SIZE | + HAL_REO_CMD_UPD0_PN_VALID | + HAL_REO_CMD_UPD0_PN_CHECK | + HAL_REO_CMD_UPD0_SVLD; + + switch (k->k_cipher) { + case IEEE80211_CIPHER_TKIP: + case IEEE80211_CIPHER_CCMP: +#if 0 + case WLAN_CIPHER_SUITE_CCMP_256: + case WLAN_CIPHER_SUITE_GCMP: + case WLAN_CIPHER_SUITE_GCMP_256: +#endif + if (!delete_key) { + cmd.upd1 |= HAL_REO_CMD_UPD1_PN_CHECK; + cmd.pn_size = 48; + } + break; + default: + printf("%s: cipher %u is not supported\n", + sc->sc_dev.dv_xname, k->k_cipher); + return EOPNOTSUPP; + } + + for (tid = 0; tid < IEEE80211_NUM_TID; tid++) { + rx_tid = &peer->rx_tid[tid]; + if (!rx_tid->active) + continue; + cmd.addr_lo = rx_tid->paddr & 0xffffffff; + cmd.addr_hi = (rx_tid->paddr >> 32); + ret = qwx_dp_tx_send_reo_cmd(sc, rx_tid, + HAL_REO_CMD_UPDATE_RX_QUEUE, &cmd, NULL); + if (ret) { + printf("%s: failed to configure rx tid %d queue " + "for pn replay detection %d\n", + sc->sc_dev.dv_xname, tid, ret); + break; + } + } + + return ret; +} + enum hal_tcl_encap_type qwx_dp_tx_get_encap_type(struct qwx_softc *sc) { @@ -23676,20 +24235,25 @@ qwx_dp_tx(struct qwx_softc *sc, struct qwx_vif *arvif, uint8_t pdev_id, ti.meta_data_flags = arvif->tcl_metadata; - if (ti.encap_type == HAL_TCL_ENCAP_TYPE_RAW) { -#if 0 - if (skb_cb->flags & ATH11K_SKB_CIPHER_SET) { - ti.encrypt_type = - ath11k_dp_tx_get_encrypt_type(skb_cb->cipher); - - if (ieee80211_has_protected(hdr->frame_control)) - skb_put(skb, IEEE80211_CCMP_MIC_LEN); - } else -#endif + if ((wh->i_fc[1] & IEEE80211_FC1_PROTECTED) && + ti.encap_type == HAL_TCL_ENCAP_TYPE_RAW) { + k = ieee80211_get_txkey(ic, wh, ni); + switch (k->k_cipher) { + case IEEE80211_CIPHER_CCMP: + ti.encrypt_type = HAL_ENCRYPT_TYPE_CCMP_128; + m->m_pkthdr.len += IEEE80211_CCMP_MICLEN; + break; + case IEEE80211_CIPHER_TKIP: + ti.encrypt_type = HAL_ENCRYPT_TYPE_TKIP_MIC; + m->m_pkthdr.len += IEEE80211_TKIP_MICLEN; + break; + default: + /* Fallback to software crypto for other ciphers. */ ti.encrypt_type = HAL_ENCRYPT_TYPE_OPEN; + break; + } - if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) { - k = ieee80211_get_txkey(ic, wh, ni); + if (ti.encrypt_type == HAL_ENCRYPT_TYPE_OPEN) { if ((m = ieee80211_encrypt(ic, m, k)) == NULL) return ENOBUFS; /* 802.11 header may have moved. */ @@ -24582,6 +25146,25 @@ qwx_peer_assoc_h_basic(struct qwx_softc *sc, struct qwx_vif *arvif, arg->peer_caps = ni->ni_capinfo; } +void +qwx_peer_assoc_h_crypto(struct qwx_softc *sc, struct qwx_vif *arvif, + struct ieee80211_node *ni, struct peer_assoc_params *arg) +{ + struct ieee80211com *ic = &sc->sc_ic; + + if (ic->ic_flags & IEEE80211_F_RSNON) { + arg->need_ptk_4_way = 1; + if (ni->ni_rsnprotos == IEEE80211_PROTO_WPA) + arg->need_gtk_2_way = 1; + } +#if 0 + if (sta->mfp) { + /* TODO: Need to check if FW supports PMF? */ + arg->is_pmf_enabled = true; + } +#endif +} + int qwx_mac_rate_is_cck(uint8_t rate) { @@ -24641,9 +25224,7 @@ qwx_peer_assoc_prepare(struct qwx_softc *sc, struct qwx_vif *arvif, arg->peer_new_assoc = !reassoc; qwx_peer_assoc_h_basic(sc, arvif, ni, arg); -#if 0 qwx_peer_assoc_h_crypto(sc, arvif, ni, arg); -#endif qwx_peer_assoc_h_rates(ni, arg); qwx_peer_assoc_h_phymode(sc, ni, arg); #if 0 @@ -24757,12 +25338,15 @@ qwx_run_stop(struct qwx_softc *sc) struct ieee80211com *ic = &sc->sc_ic; struct qwx_vif *arvif = TAILQ_FIRST(&sc->vif_list); /* XXX */ uint8_t pdev_id = 0; /* TODO: derive pdev ID somehow? */ + struct qwx_node *nq = (void *)ic->ic_bss; int ret; sc->ops.irq_disable(sc); - if (ic->ic_opmode == IEEE80211_M_STA) + if (ic->ic_opmode == IEEE80211_M_STA) { ic->ic_bss->ni_txrate = 0; + nq->flags = 0; + } ret = qwx_wmi_vdev_down(sc, arvif->vdev_id, pdev_id); if (ret) @@ -24801,6 +25385,7 @@ qwx_attach(struct qwx_softc *sc) task_set(&sc->init_task, qwx_init_task, sc); task_set(&sc->newstate_task, qwx_newstate_task, sc); + task_set(&sc->setkey_task, qwx_setkey_task, sc); timeout_set_proc(&sc->scan.timeout, qwx_scan_timeout, sc); #if NBPFILTER > 0 qwx_radiotap_attach(sc); diff --git a/sys/dev/ic/qwxvar.h b/sys/dev/ic/qwxvar.h index 29eeb66af..9b82013b8 100644 --- a/sys/dev/ic/qwxvar.h +++ b/sys/dev/ic/qwxvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: qwxvar.h,v 1.25 2024/05/13 01:15:50 jsg Exp $ */ +/* $OpenBSD: qwxvar.h,v 1.26 2024/05/28 08:34:52 stsp Exp $ */ /* * Copyright (c) 2018-2019 The Linux Foundation. @@ -264,7 +264,9 @@ struct ath11k_hw_ops { #if notyet void (*tx_mesh_enable)(struct ath11k_base *ab, struct hal_tcl_data_cmd *tcl_cmd); - bool (*rx_desc_get_first_msdu)(struct hal_rx_desc *desc); +#endif + int (*rx_desc_get_first_msdu)(struct hal_rx_desc *desc); +#if notyet bool (*rx_desc_get_last_msdu)(struct hal_rx_desc *desc); #endif uint8_t (*rx_desc_get_l3_pad_bytes)(struct hal_rx_desc *desc); @@ -1745,6 +1747,14 @@ struct qwx_tx_radiotap_header { #define IWX_TX_RADIOTAP_PRESENT 0 /* TODO add more information */ +struct qwx_setkey_task_arg { + struct ieee80211_node *ni; + struct ieee80211_key *k; + int cmd; +#define QWX_ADD_KEY 1 +#define QWX_DEL_KEY 2 +}; + struct qwx_softc { struct device sc_dev; struct ieee80211com sc_ic; @@ -1762,6 +1772,23 @@ struct qwx_softc { enum ieee80211_state ns_nstate; int ns_arg; + /* Task for setting encryption keys and its arguments. */ + struct task setkey_task; + /* + * At present we need to process at most two keys at once: + * Our pairwise key and a group key. + * When hostap mode is implemented this array needs to grow or + * it might become a bottleneck for associations that occur at + * roughly the same time. + */ + struct qwx_setkey_task_arg setkey_arg[2]; + int setkey_cur; + int setkey_tail; + int setkey_nkeys; + + int install_key_done; + int install_key_status; + enum ath11k_11d_state state_11d; int completed_11d_scan; uint32_t vdev_id_11d_scan; @@ -1962,9 +1989,16 @@ struct ath11k_peer { struct qwx_node { struct ieee80211_node ni; struct ath11k_peer peer; + unsigned int flags; +#define QWX_NODE_FLAG_HAVE_PAIRWISE_KEY 0x01 +#define QWX_NODE_FLAG_HAVE_GROUP_KEY 0x02 }; struct ieee80211_node *qwx_node_alloc(struct ieee80211com *); +int qwx_set_key(struct ieee80211com *, struct ieee80211_node *, + struct ieee80211_key *); +void qwx_delete_key(struct ieee80211com *, struct ieee80211_node *, + struct ieee80211_key *); void qwx_qrtr_recv_msg(struct qwx_softc *, struct mbuf *); diff --git a/sys/dev/ic/ufshci.c b/sys/dev/ic/ufshci.c index 7d8d23f18..a91aaa5cc 100644 --- a/sys/dev/ic/ufshci.c +++ b/sys/dev/ic/ufshci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ufshci.c,v 1.32 2024/05/24 20:34:06 mglocker Exp $ */ +/* $OpenBSD: ufshci.c,v 1.33 2024/05/27 10:27:58 mglocker Exp $ */ /* * Copyright (c) 2022 Marcus Glocker @@ -62,7 +62,8 @@ void ufshci_dmamem_free(struct ufshci_softc *, int ufshci_init(struct ufshci_softc *); int ufshci_doorbell_read(struct ufshci_softc *); void ufshci_doorbell_write(struct ufshci_softc *, int); -int ufshci_doorbell_poll(struct ufshci_softc *, int); +int ufshci_doorbell_poll(struct ufshci_softc *, int, + uint32_t); int ufshci_utr_cmd_nop(struct ufshci_softc *, struct ufshci_ccb *, struct scsi_xfer *); int ufshci_utr_cmd_lun(struct ufshci_softc *, @@ -502,20 +503,21 @@ ufshci_doorbell_write(struct ufshci_softc *sc, int slot) } int -ufshci_doorbell_poll(struct ufshci_softc *sc, int slot) +ufshci_doorbell_poll(struct ufshci_softc *sc, int slot, uint32_t timeout_ms) { uint32_t reg; - int i, retry = 25; + uint64_t timeout_us; DPRINTF(3, "%s\n", __func__); - for (i = 0; i < retry; i++) { + for (timeout_us = timeout_ms * 1000; timeout_us != 0; + timeout_us -= 1000) { reg = UFSHCI_READ_4(sc, UFSHCI_REG_UTRLDBR); if ((reg & (1U << slot)) == 0) break; - delay(10); + delay(1000); } - if (i == retry) { + if (timeout_us == 0) { printf("%s: %s: timeout\n", sc->sc_dev.dv_xname, __func__); return -1; } @@ -1620,7 +1622,7 @@ ufshci_scsi_inquiry(struct scsi_xfer *xs) goto error2; if (ISSET(xs->flags, SCSI_POLL)) { - if (ufshci_doorbell_poll(sc, ccb->ccb_slot) == 0) { + if (ufshci_doorbell_poll(sc, ccb->ccb_slot, xs->timeout) == 0) { ccb->ccb_done(sc, ccb); return; } @@ -1675,7 +1677,7 @@ ufshci_scsi_capacity16(struct scsi_xfer *xs) goto error2; if (ISSET(xs->flags, SCSI_POLL)) { - if (ufshci_doorbell_poll(sc, ccb->ccb_slot) == 0) { + if (ufshci_doorbell_poll(sc, ccb->ccb_slot, xs->timeout) == 0) { ccb->ccb_done(sc, ccb); return; } @@ -1730,7 +1732,7 @@ ufshci_scsi_capacity(struct scsi_xfer *xs) goto error2; if (ISSET(xs->flags, SCSI_POLL)) { - if (ufshci_doorbell_poll(sc, ccb->ccb_slot) == 0) { + if (ufshci_doorbell_poll(sc, ccb->ccb_slot, xs->timeout) == 0) { ccb->ccb_done(sc, ccb); return; } @@ -1775,7 +1777,7 @@ ufshci_scsi_sync(struct scsi_xfer *xs) goto error; if (ISSET(xs->flags, SCSI_POLL)) { - if (ufshci_doorbell_poll(sc, ccb->ccb_slot) == 0) { + if (ufshci_doorbell_poll(sc, ccb->ccb_slot, xs->timeout) == 0) { ccb->ccb_done(sc, ccb); return; } @@ -1831,7 +1833,7 @@ ufshci_scsi_io(struct scsi_xfer *xs, int dir) goto error2; if (ISSET(xs->flags, SCSI_POLL)) { - if (ufshci_doorbell_poll(sc, ccb->ccb_slot) == 0) { + if (ufshci_doorbell_poll(sc, ccb->ccb_slot, xs->timeout) == 0) { ccb->ccb_done(sc, ccb); return; } diff --git a/sys/dev/isa/ad1848.c b/sys/dev/isa/ad1848.c index d7f3f6741..bd4a46466 100644 --- a/sys/dev/isa/ad1848.c +++ b/sys/dev/isa/ad1848.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ad1848.c,v 1.49 2024/04/13 23:44:11 jsg Exp $ */ +/* $OpenBSD: ad1848.c,v 1.50 2024/05/28 09:27:08 jsg Exp $ */ /* $NetBSD: ad1848.c,v 1.45 1998/01/30 02:02:38 augustss Exp $ */ /* @@ -89,7 +89,6 @@ #include #include #include -#include #ifdef AUDIO_DEBUG #define DPRINTF(x) do { if (ad1848debug) printf x; } while (0); diff --git a/sys/dev/isa/addcom_isa.c b/sys/dev/isa/addcom_isa.c index 65752117b..da5afd185 100644 --- a/sys/dev/isa/addcom_isa.c +++ b/sys/dev/isa/addcom_isa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: addcom_isa.c,v 1.7 2022/04/06 18:59:28 naddy Exp $ */ +/* $OpenBSD: addcom_isa.c,v 1.8 2024/05/28 05:46:32 jsg Exp $ */ /* $NetBSD: addcom_isa.c,v 1.2 2000/04/21 20:13:41 explorer Exp $ */ /* @@ -120,9 +120,7 @@ struct cfdriver addcom_cd = { }; int -addcomprobe(parent, self, aux) - struct device *parent; - void *self, *aux; +addcomprobe(struct device *parent, void *self, void *aux) { struct isa_attach_args *ia = aux; int iobase = ia->ia_iobase; @@ -175,9 +173,7 @@ out: } int -addcomprint(aux, pnp) - void *aux; - const char *pnp; +addcomprint(void *aux, const char *pnp) { struct commulti_attach_args *ca = aux; @@ -188,9 +184,7 @@ addcomprint(aux, pnp) } void -addcomattach(parent, self, aux) - struct device *parent, *self; - void *aux; +addcomattach(struct device *parent, struct device *self, void *aux) { struct addcom_softc *sc = (void *)self; struct isa_attach_args *ia = aux; @@ -253,8 +247,7 @@ addcomattach(parent, self, aux) } int -addcomintr(arg) - void *arg; +addcomintr(void *arg) { struct addcom_softc *sc = arg; int intrd, r = 0, i; diff --git a/sys/dev/isa/boca.c b/sys/dev/isa/boca.c index 111dea29e..414634ee9 100644 --- a/sys/dev/isa/boca.c +++ b/sys/dev/isa/boca.c @@ -1,4 +1,4 @@ -/* $OpenBSD: boca.c,v 1.17 2022/04/06 18:59:28 naddy Exp $ */ +/* $OpenBSD: boca.c,v 1.18 2024/05/28 05:46:32 jsg Exp $ */ /* $NetBSD: boca.c,v 1.15 1996/05/12 23:51:50 mycroft Exp $ */ /* @@ -74,10 +74,7 @@ struct cfdriver boca_cd = { }; int -bocaprobe(parent, self, aux) - struct device *parent; - void *self; - void *aux; +bocaprobe(struct device *parent, void *self, void *aux) { struct isa_attach_args *ia = aux; int iobase = ia->ia_iobase; @@ -126,9 +123,7 @@ out: } int -bocaprint(aux, pnp) - void *aux; - const char *pnp; +bocaprint(void *aux, const char *pnp) { struct commulti_attach_args *ca = aux; @@ -139,9 +134,7 @@ bocaprint(aux, pnp) } void -bocaattach(parent, self, aux) - struct device *parent, *self; - void *aux; +bocaattach(struct device *parent, struct device *self, void *aux) { struct boca_softc *sc = (void *)self; struct isa_attach_args *ia = aux; @@ -177,8 +170,7 @@ bocaattach(parent, self, aux) } int -bocaintr(arg) - void *arg; +bocaintr(void *arg) { struct boca_softc *sc = arg; bus_space_tag_t iot = sc->sc_iot; diff --git a/sys/dev/isa/cs4231var.h b/sys/dev/isa/cs4231var.h deleted file mode 100644 index 7c552ea3b..000000000 --- a/sys/dev/isa/cs4231var.h +++ /dev/null @@ -1,51 +0,0 @@ -/* $OpenBSD: cs4231var.h,v 1.4 2008/06/26 05:42:16 ray Exp $ */ -/* $NetBSD: cs4231var.h,v 1.2 1996/02/05 02:21:51 jtc Exp $ */ - -/*- - * Copyright (c) 1996 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Ken Hornstein and John Kohl. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Software gunk for CS4231, as used in Gravis UltraSound MAX. - */ - -struct cs4231_softc { - int in_port; /* which MUX input port? */ -#define CS4231_MUX_MIXED_IN 0 -#define CS4231_MUX_MIC_IN 1 -#define CS4231_MUX_AUX1_IN 2 -#define CS4231_MUX_LINE_IN 3 -}; - -int cs4231_set_linein_gain(struct ad1848_softc *, struct ad1848_volume *); -int cs4231_get_linein_gain(struct ad1848_softc *, struct ad1848_volume *); -int cs4231_set_mono_gain(struct ad1848_softc *, struct ad1848_volume *); -int cs4231_get_mono_gain(struct ad1848_softc *, struct ad1848_volume *); -void cs4231_mute_mono(struct ad1848_softc *, int /* onoff */); -void cs4231_mute_line(struct ad1848_softc *, int /* onoff */); -void cs4231_mute_monitor(struct ad1848_softc *, int /* onoff */); diff --git a/sys/dev/isa/gus.c b/sys/dev/isa/gus.c index 48be233b0..a72f12f4a 100644 --- a/sys/dev/isa/gus.c +++ b/sys/dev/isa/gus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gus.c,v 1.55 2022/11/02 10:41:34 kn Exp $ */ +/* $OpenBSD: gus.c,v 1.56 2024/05/28 09:27:08 jsg Exp $ */ /* $NetBSD: gus.c,v 1.51 1998/01/25 23:48:06 mycroft Exp $ */ /*- @@ -115,7 +115,6 @@ #include #include #include -#include #include "gusreg.h" #include "gusvar.h" diff --git a/sys/dev/isa/gus_isa.c b/sys/dev/isa/gus_isa.c index 28886f791..54e7c1ed5 100644 --- a/sys/dev/isa/gus_isa.c +++ b/sys/dev/isa/gus_isa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gus_isa.c,v 1.9 2022/04/06 18:59:28 naddy Exp $ */ +/* $OpenBSD: gus_isa.c,v 1.10 2024/05/28 09:27:08 jsg Exp $ */ /* $NetBSD: gus.c,v 1.51 1998/01/25 23:48:06 mycroft Exp $ */ /*- @@ -115,7 +115,6 @@ #include #include #include -#include #include "gusreg.h" #include "gusvar.h" diff --git a/sys/dev/isa/gus_isapnp.c b/sys/dev/isa/gus_isapnp.c index 56277cc3d..62fa3c1c0 100644 --- a/sys/dev/isa/gus_isapnp.c +++ b/sys/dev/isa/gus_isapnp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gus_isapnp.c,v 1.10 2022/04/06 18:59:28 naddy Exp $ */ +/* $OpenBSD: gus_isapnp.c,v 1.11 2024/05/28 09:27:08 jsg Exp $ */ /* $NetBSD: gus.c,v 1.51 1998/01/25 23:48:06 mycroft Exp $ */ /*- @@ -115,7 +115,6 @@ #include #include #include -#include #include "gusreg.h" #include "gusvar.h" diff --git a/sys/dev/isa/hsq.c b/sys/dev/isa/hsq.c index e9509c3a5..5bfc16b0c 100644 --- a/sys/dev/isa/hsq.c +++ b/sys/dev/isa/hsq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hsq.c,v 1.7 2022/04/06 18:59:28 naddy Exp $ */ +/* $OpenBSD: hsq.c,v 1.8 2024/05/28 05:46:32 jsg Exp $ */ /*- * Copyright (c) 1999 Denis A. Doroshenko. All rights reserved. @@ -120,10 +120,7 @@ struct cfdriver hsq_cd = { }; int -hsqprobe(parent, self, aux) - struct device *parent; - void *self; - void *aux; +hsqprobe(struct device *parent, void *self, void *aux) { struct isa_attach_args *ia = aux; int iobase = ia->ia_iobase; @@ -174,9 +171,7 @@ out: } int -hsqprint(aux, pnp) - void *aux; - const char *pnp; +hsqprint(void *aux, const char *pnp) { struct commulti_attach_args *ca = aux; @@ -187,9 +182,7 @@ hsqprint(aux, pnp) } void -hsqattach(parent, self, aux) - struct device *parent, *self; - void *aux; +hsqattach(struct device *parent, struct device *self, void *aux) { struct hsq_softc *sc = (void *)self; struct isa_attach_args *ia = aux; @@ -225,8 +218,7 @@ hsqattach(parent, self, aux) } int -hsqintr(arg) - void *arg; +hsqintr(void *arg) { struct hsq_softc *sc = arg; bus_space_tag_t iot = sc->sc_iot; diff --git a/sys/dev/mii/txphy.c b/sys/dev/mii/txphy.c index 175078581..7d8f923b2 100644 --- a/sys/dev/mii/txphy.c +++ b/sys/dev/mii/txphy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: txphy.c,v 1.13 2023/03/30 09:24:22 kevlo Exp $ */ +/* $OpenBSD: txphy.c,v 1.14 2024/05/27 03:56:59 jsg Exp $ */ /* * Copyright (c) 1999 Jason L. Wright (jason@thought.net) @@ -38,6 +38,7 @@ #include #include +#include #include #include diff --git a/sys/dev/mii/xmphy.c b/sys/dev/mii/xmphy.c index 4256ade8a..fdc537ac3 100644 --- a/sys/dev/mii/xmphy.c +++ b/sys/dev/mii/xmphy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xmphy.c,v 1.24 2022/04/06 18:59:29 naddy Exp $ */ +/* $OpenBSD: xmphy.c,v 1.25 2024/05/27 04:58:43 jsg Exp $ */ /* * Copyright (c) 2000 @@ -54,8 +54,6 @@ #include #include -#include - int xmphy_probe(struct device *, void *, void *); void xmphy_attach(struct device *, struct device *, void *); diff --git a/sys/dev/mii/xmphyreg.h b/sys/dev/mii/xmphyreg.h deleted file mode 100644 index 15d1d3ad0..000000000 --- a/sys/dev/mii/xmphyreg.h +++ /dev/null @@ -1,50 +0,0 @@ -/* $OpenBSD: xmphyreg.h,v 1.6 2015/07/19 06:28:12 yuo Exp $ */ -/* - * Copyright (c) 2000 - * Bill Paul . All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Bill Paul. - * 4. Neither the name of the author nor the names of any co-contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD: src/sys/dev/mii/xmphyreg.h,v 1.1 2000/04/22 01:58:18 wpaul Exp $ - */ - -#ifndef _DEV_MII_XMPHYREG_H_ -#define _DEV_MII_XMPHYREG_H_ - -/* - * XaQti XMAC II PHY registers - */ - -#define XMPHY_MII_RESAB 0x10 /* Resolved ability */ -#define XMPHY_RESAB_PAUSEBITS 0x0180 /* Pause bits */ -#define XMPHY_RESAB_HDX 0x0040 /* Half duplex selected */ -#define XMPHY_RESAB_FDX 0x0020 /* Full duplex selected */ -#define XMPHY_RESAB_ABLMIS 0x0010 /* Ability mismatch */ -#define XMPHY_RESAB_PAUSEMIS 0x0008 /* Pause mismatch */ - -#endif /* _DEV_MII_XMPHYREG_H_ */ diff --git a/sys/dev/pci/drm/amd/amdgpu/amdgpu_ras.c b/sys/dev/pci/drm/amd/amdgpu/amdgpu_ras.c index 65db7e29c..36af1f4e4 100644 --- a/sys/dev/pci/drm/amd/amdgpu/amdgpu_ras.c +++ b/sys/dev/pci/drm/amd/amdgpu/amdgpu_ras.c @@ -1029,6 +1029,9 @@ int amdgpu_ras_query_error_status(struct amdgpu_device *adev, if (!obj) return -EINVAL; + if (!info || info->head.block == AMDGPU_RAS_BLOCK_COUNT) + return -EINVAL; + if (info->head.block == AMDGPU_RAS_BLOCK__UMC) { amdgpu_ras_get_ecc_info(adev, &err_data); } else { diff --git a/sys/dev/pci/drm/amd/display/dc/dsc/dc_dsc.c b/sys/dev/pci/drm/amd/display/dc/dsc/dc_dsc.c index 3966845c7..230be292f 100644 --- a/sys/dev/pci/drm/amd/display/dc/dsc/dc_dsc.c +++ b/sys/dev/pci/drm/amd/display/dc/dsc/dc_dsc.c @@ -1033,7 +1033,12 @@ static bool setup_dsc_config( if (!is_dsc_possible) goto done; - dsc_cfg->num_slices_v = pic_height/slice_height; + if (slice_height > 0) { + dsc_cfg->num_slices_v = pic_height / slice_height; + } else { + is_dsc_possible = false; + goto done; + } if (target_bandwidth_kbps > 0) { is_dsc_possible = decide_dsc_target_bpp_x16( diff --git a/sys/dev/pci/if_qwx_pci.c b/sys/dev/pci/if_qwx_pci.c index 61cbc7dd5..0dc2a2872 100644 --- a/sys/dev/pci/if_qwx_pci.c +++ b/sys/dev/pci/if_qwx_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_qwx_pci.c,v 1.16 2024/05/24 06:02:56 jsg Exp $ */ +/* $OpenBSD: if_qwx_pci.c,v 1.19 2024/05/28 09:26:55 stsp Exp $ */ /* * Copyright 2023 Stefan Sperling @@ -96,6 +96,7 @@ #include #include +#ifdef QWX_DEBUG /* Headers needed for RDDM dump */ #include #include @@ -103,6 +104,7 @@ #include #include #include +#endif #define ATH11K_PCI_IRQ_CE0_OFFSET 3 #define ATH11K_PCI_IRQ_DP_OFFSET 14 @@ -452,7 +454,9 @@ void qwx_mhi_init_mmio(struct qwx_pci_softc *); int qwx_mhi_fw_load_bhi(struct qwx_pci_softc *, uint8_t *, size_t); int qwx_mhi_fw_load_bhie(struct qwx_pci_softc *, uint8_t *, size_t); void qwx_rddm_prepare(struct qwx_pci_softc *); +#ifdef QWX_DEBUG void qwx_rddm_task(void *); +#endif void * qwx_pci_event_ring_get_elem(struct qwx_pci_event_ring *, uint64_t); void qwx_pci_intr_ctrl_event_mhi(struct qwx_pci_softc *, uint32_t); void qwx_pci_intr_ctrl_event_ee(struct qwx_pci_softc *, uint32_t); @@ -1042,8 +1046,9 @@ unsupported_wcn6855_soc: goto err_irq_affinity_cleanup; } #endif +#ifdef QWX_DEBUG task_set(&psc->rddm_task, qwx_rddm_task, psc); - +#endif ic->ic_phytype = IEEE80211_T_OFDM; /* not only, but not used */ ic->ic_opmode = IEEE80211_M_STA; /* default to BSS mode */ ic->ic_state = IEEE80211_S_INIT; @@ -1086,6 +1091,8 @@ unsupported_wcn6855_soc: /* Override 802.11 state transition machine. */ sc->sc_newstate = ic->ic_newstate; ic->ic_newstate = qwx_newstate; + ic->ic_set_key = qwx_set_key; + ic->ic_delete_key = qwx_delete_key; #if 0 ic->ic_updatechan = qwx_updatechan; ic->ic_updateprot = qwx_updateprot; @@ -3466,6 +3473,7 @@ qwx_rddm_prepare(struct qwx_pci_softc *psc) psc->rddm_vec = vec_adm; } +#ifdef QWX_DEBUG void qwx_rddm_task(void *arg) { @@ -3560,6 +3568,7 @@ done: psc->rddm_vec = NULL; DPRINTF("%s: done, error %d\n", __func__, error); } +#endif void * qwx_pci_event_ring_get_elem(struct qwx_pci_event_ring *ring, uint64_t rp) @@ -4071,11 +4080,23 @@ qwx_pci_intr(void *arg) sc->sc_dev.dv_xname, psc->bhi_ee, ee, psc->mhi_state, state); if (ee == MHI_EE_RDDM) { + /* Firmware crash, e.g. due to invalid DMA memory access. */ psc->bhi_ee = ee; +#ifdef QWX_DEBUG if (!psc->rddm_triggered) { + /* Write fw memory dump to root's home directory. */ task_add(systq, &psc->rddm_task); psc->rddm_triggered = 1; } +#else + printf("%s: fatal firmware error\n", + sc->sc_dev.dv_xname); + if (!test_bit(ATH11K_FLAG_CRASH_FLUSH, sc->sc_flags)) { + /* Try to reset the device. */ + set_bit(ATH11K_FLAG_CRASH_FLUSH, sc->sc_flags); + task_add(systq, &sc->init_task); + } +#endif return 1; } else if (psc->bhi_ee == MHI_EE_PBL || psc->bhi_ee == MHI_EE_SBL) { int new_ee = -1, new_mhi_state = -1; diff --git a/sys/dev/pcmcia/aic_pcmcia.c b/sys/dev/pcmcia/aic_pcmcia.c index e0bd83291..a5b9f982d 100644 --- a/sys/dev/pcmcia/aic_pcmcia.c +++ b/sys/dev/pcmcia/aic_pcmcia.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aic_pcmcia.c,v 1.20 2023/09/11 08:41:27 mvs Exp $ */ +/* $OpenBSD: aic_pcmcia.c,v 1.21 2024/05/26 08:46:28 jsg Exp $ */ /* $NetBSD: aic_pcmcia.c,v 1.6 1998/07/19 17:28:15 christos Exp $ */ /* @@ -34,7 +34,6 @@ #include #include -#include #include #include diff --git a/sys/dev/pcmcia/cfxga.c b/sys/dev/pcmcia/cfxga.c index b4d8fdc7b..2c0b36d76 100644 --- a/sys/dev/pcmcia/cfxga.c +++ b/sys/dev/pcmcia/cfxga.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cfxga.c,v 1.33 2022/07/15 17:57:26 kettenis Exp $ */ +/* $OpenBSD: cfxga.c,v 1.35 2024/05/26 08:46:28 jsg Exp $ */ /* * Copyright (c) 2005, 2006, Matthieu Herrb and Miodrag Vallat @@ -31,11 +31,9 @@ */ #include -#include #include #include #include -#include #include #include @@ -324,7 +322,7 @@ cfxga_activate(struct device *dev, int act) pcmcia_function_disable(sc->sc_pf); break; default: - rv = config_activate_children(self, act); + rv = config_activate_children(dev, act); break; } return (rv); diff --git a/sys/dev/pcmcia/com_pcmcia.c b/sys/dev/pcmcia/com_pcmcia.c index dd0c493f0..6157c256e 100644 --- a/sys/dev/pcmcia/com_pcmcia.c +++ b/sys/dev/pcmcia/com_pcmcia.c @@ -1,4 +1,4 @@ -/* $OpenBSD: com_pcmcia.c,v 1.61 2024/05/13 01:15:51 jsg Exp $ */ +/* $OpenBSD: com_pcmcia.c,v 1.62 2024/05/26 08:46:28 jsg Exp $ */ /* $NetBSD: com_pcmcia.c,v 1.15 1998/08/22 17:47:58 msaitoh Exp $ */ /* @@ -90,12 +90,7 @@ #include #include -#include #include -#include -#include -#include -#include #include #include @@ -104,8 +99,6 @@ #include #include -#include "com.h" - #include #include #include diff --git a/sys/dev/pcmcia/if_an_pcmcia.c b/sys/dev/pcmcia/if_an_pcmcia.c index c6146cbcf..0a1d6ba38 100644 --- a/sys/dev/pcmcia/if_an_pcmcia.c +++ b/sys/dev/pcmcia/if_an_pcmcia.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_an_pcmcia.c,v 1.27 2022/04/06 18:59:30 naddy Exp $ */ +/* $OpenBSD: if_an_pcmcia.c,v 1.28 2024/05/26 08:46:28 jsg Exp $ */ /* * Copyright (c) 1999 Michael Shalayeff @@ -29,9 +29,6 @@ #include #include #include -#include -#include -#include #include #include diff --git a/sys/dev/pcmcia/if_ep_pcmcia.c b/sys/dev/pcmcia/if_ep_pcmcia.c index b4edd3f13..fb760a7f9 100644 --- a/sys/dev/pcmcia/if_ep_pcmcia.c +++ b/sys/dev/pcmcia/if_ep_pcmcia.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ep_pcmcia.c,v 1.51 2023/09/11 08:41:27 mvs Exp $ */ +/* $OpenBSD: if_ep_pcmcia.c,v 1.52 2024/05/26 08:46:28 jsg Exp $ */ /* $NetBSD: if_ep_pcmcia.c,v 1.16 1998/08/17 23:20:40 thorpej Exp $ */ /*- @@ -60,15 +60,8 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "bpfilter.h" - #include #include -#include -#include -#include -#include -#include #include #include @@ -78,14 +71,8 @@ #include #include -#if NBPFILTER > 0 -#include -#endif - -#include #include -#include #include #include diff --git a/sys/dev/pcmcia/if_malo.c b/sys/dev/pcmcia/if_malo.c index 0403f2409..efd01b5bd 100644 --- a/sys/dev/pcmcia/if_malo.c +++ b/sys/dev/pcmcia/if_malo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_malo.c,v 1.99 2022/04/06 18:59:30 naddy Exp $ */ +/* $OpenBSD: if_malo.c,v 1.100 2024/05/26 08:46:28 jsg Exp $ */ /* * Copyright (c) 2007 Marcus Glocker @@ -20,11 +20,8 @@ #include #include -#include #include #include -#include -#include #include #include #include diff --git a/sys/dev/pcmcia/if_ne_pcmcia.c b/sys/dev/pcmcia/if_ne_pcmcia.c index 130ef733f..d037f03b7 100644 --- a/sys/dev/pcmcia/if_ne_pcmcia.c +++ b/sys/dev/pcmcia/if_ne_pcmcia.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ne_pcmcia.c,v 1.102 2023/09/11 08:41:27 mvs Exp $ */ +/* $OpenBSD: if_ne_pcmcia.c,v 1.103 2024/05/26 08:46:28 jsg Exp $ */ /* $NetBSD: if_ne_pcmcia.c,v 1.17 1998/08/15 19:00:04 thorpej Exp $ */ /* @@ -33,7 +33,6 @@ #include #include #include -#include #include #include @@ -42,12 +41,10 @@ #include -#include #include #include #include -#include #include #include diff --git a/sys/dev/pcmcia/if_sm_pcmcia.c b/sys/dev/pcmcia/if_sm_pcmcia.c index 905a4d5b8..f335b1a39 100644 --- a/sys/dev/pcmcia/if_sm_pcmcia.c +++ b/sys/dev/pcmcia/if_sm_pcmcia.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_sm_pcmcia.c,v 1.40 2023/09/11 08:41:27 mvs Exp $ */ +/* $OpenBSD: if_sm_pcmcia.c,v 1.41 2024/05/26 08:46:28 jsg Exp $ */ /* $NetBSD: if_sm_pcmcia.c,v 1.11 1998/08/15 20:47:32 thorpej Exp $ */ /*- @@ -31,15 +31,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "bpfilter.h" - #include #include -#include -#include -#include -#include -#include #include #include @@ -49,14 +42,9 @@ #include #include -#if NBPFILTER > 0 -#include -#endif - #include #include -#include #include #include diff --git a/sys/dev/pcmcia/if_wi_pcmcia.c b/sys/dev/pcmcia/if_wi_pcmcia.c index ac83d2d9a..8ebebd027 100644 --- a/sys/dev/pcmcia/if_wi_pcmcia.c +++ b/sys/dev/pcmcia/if_wi_pcmcia.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_wi_pcmcia.c,v 1.76 2022/04/06 18:59:30 naddy Exp $ */ +/* $OpenBSD: if_wi_pcmcia.c,v 1.77 2024/05/26 08:46:28 jsg Exp $ */ /* $NetBSD: if_wi_pcmcia.c,v 1.14 2001/11/26 04:34:56 ichiro Exp $ */ /* @@ -46,9 +46,7 @@ #include #include #include -#include #include -#include #include #include @@ -61,7 +59,6 @@ #include -#include #include #include diff --git a/sys/dev/pcmcia/if_xe.c b/sys/dev/pcmcia/if_xe.c index 6df8473fc..68d7457c7 100644 --- a/sys/dev/pcmcia/if_xe.c +++ b/sys/dev/pcmcia/if_xe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_xe.c,v 1.63 2023/05/30 08:30:01 jsg Exp $ */ +/* $OpenBSD: if_xe.c,v 1.64 2024/05/26 08:46:28 jsg Exp $ */ /* * Copyright (c) 1999 Niklas Hallqvist, Brandon Creighton, Job de Haas @@ -52,8 +52,6 @@ #include #include #include -#include -#include #include #include diff --git a/sys/dev/pcmcia/wdc_pcmcia.c b/sys/dev/pcmcia/wdc_pcmcia.c index fe728c9bd..8e0dd910e 100644 --- a/sys/dev/pcmcia/wdc_pcmcia.c +++ b/sys/dev/pcmcia/wdc_pcmcia.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wdc_pcmcia.c,v 1.34 2022/04/06 18:59:30 naddy Exp $ */ +/* $OpenBSD: wdc_pcmcia.c,v 1.35 2024/05/26 08:46:28 jsg Exp $ */ /* $NetBSD: wdc_pcmcia.c,v 1.19 1999/02/19 21:49:43 abs Exp $ */ /*- @@ -32,19 +32,8 @@ #include #include -#include -#include -#include -#include -#include -#include -#include #include -#include -#include -#include -#include #include #include diff --git a/sys/dev/pv/if_vio.c b/sys/dev/pv/if_vio.c index 3d0a4f521..2f750c271 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.35 2024/05/24 10:05:55 jsg Exp $ */ +/* $OpenBSD: if_vio.c,v 1.36 2024/05/28 12:11:26 jan Exp $ */ /* * Copyright (c) 2012 Stefan Fritsch, Alexander Fiveg. @@ -1118,8 +1118,6 @@ vio_rxeof(struct vio_softc *sc) bufs_left = hdr->num_buffers - 1; else bufs_left = 0; - if (virtio_has_feature(vsc, VIRTIO_NET_F_GUEST_CSUM)) - vio_rx_offload(m, hdr); } else { m->m_flags &= ~M_PKTHDR; m0->m_pkthdr.len += m->m_len; @@ -1129,6 +1127,8 @@ vio_rxeof(struct vio_softc *sc) } if (bufs_left == 0) { + if (virtio_has_feature(vsc, VIRTIO_NET_F_GUEST_CSUM)) + vio_rx_offload(m0, hdr); ml_enqueue(&ml, m0); m0 = NULL; } diff --git a/sys/dev/usb/ums.c b/sys/dev/usb/ums.c index 239e853fa..537636556 100644 --- a/sys/dev/usb/ums.c +++ b/sys/dev/usb/ums.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ums.c,v 1.52 2024/05/23 03:21:09 jsg Exp $ */ +/* $OpenBSD: ums.c,v 1.53 2024/05/26 20:06:27 mglocker Exp $ */ /* $NetBSD: ums.c,v 1.60 2003/03/11 16:44:00 augustss Exp $ */ /* @@ -178,14 +178,14 @@ ums_attach(struct device *parent, struct device *self, void *aux) ms->sc_loc_btn[2].pos = 2; } - hidms_attach(ms, &ums_accessops); - if (sc->sc_quirks & UQ_ALWAYS_OPEN) { /* open uhidev and keep it open */ ums_enable(sc); /* but mark the hidms not in use */ ums_disable(sc); } + + hidms_attach(ms, &ums_accessops); } int diff --git a/sys/dev/usb/umt.c b/sys/dev/usb/umt.c index aea4412e5..35ebfb596 100644 --- a/sys/dev/usb/umt.c +++ b/sys/dev/usb/umt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: umt.c,v 1.7 2024/05/23 03:21:09 jsg Exp $ */ +/* $OpenBSD: umt.c,v 1.8 2024/05/26 20:06:27 mglocker Exp $ */ /* * USB multitouch touchpad driver for devices conforming to * Windows Precision Touchpad standard @@ -181,14 +181,14 @@ umt_attach(struct device *parent, struct device *self, void *aux) if (hidmt_setup(self, mt, desc, size) != 0) return; - hidmt_attach(mt, &umt_accessops); - if (sc->sc_quirks & UQ_ALWAYS_OPEN) { /* open uhidev and keep it open */ umt_enable(sc); /* but mark the hidmt not in use */ umt_disable(sc); } + + hidmt_attach(mt, &umt_accessops); } int diff --git a/sys/kern/subr_suspend.c b/sys/kern/subr_suspend.c index 1b4f40629..883274dee 100644 --- a/sys/kern/subr_suspend.c +++ b/sys/kern/subr_suspend.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_suspend.c,v 1.16 2023/07/12 18:40:06 cheloha Exp $ */ +/* $OpenBSD: subr_suspend.c,v 1.18 2024/05/28 09:40:40 kettenis Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert * Copyright (c) 2005 Jordan Hargrave @@ -84,7 +84,6 @@ top: uvmpd_hibernate(); if (hibernate_alloc()) { printf("failed to allocate hibernate memory\n"); - sleep_abort(v); error = ENOMEM; goto fail_hiballoc; } @@ -93,7 +92,6 @@ top: sensor_quiesce(); if (config_suspend_all(DVACT_QUIESCE)) { - sleep_abort(v); error = EIO; goto fail_quiesce; } @@ -132,15 +130,14 @@ top: s = splhigh(); intr_disable(); /* PSL_I for resume; PIC/APIC broken until repair */ cold = 2; /* Force other code to delay() instead of tsleep() */ + intr_enable_wakeup(); if (config_suspend_all(DVACT_SUSPEND) != 0) { - sleep_abort(v); error = EDEADLK; goto fail_suspend; } suspend_randomness(); if (sleep_setstate(v)) { - sleep_abort(v); error = ENOTBLK; goto fail_pts; } @@ -172,6 +169,7 @@ fail_pts: config_suspend_all(DVACT_RESUME); fail_suspend: + intr_disable_wakeup(); cold = 0; intr_enable(); splx(s); diff --git a/sys/sys/device.h b/sys/sys/device.h index 77fc2b1b2..712bcb4e3 100644 --- a/sys/sys/device.h +++ b/sys/sys/device.h @@ -1,4 +1,4 @@ -/* $OpenBSD: device.h,v 1.66 2023/07/08 14:44:43 tobhe Exp $ */ +/* $OpenBSD: device.h,v 1.67 2024/05/28 09:40:40 kettenis Exp $ */ /* $NetBSD: device.h,v 1.15 1996/04/09 20:55:24 cgd Exp $ */ /* @@ -208,7 +208,6 @@ void resume_mp(void); int sleep_showstate(void *v, int sleepmode); int sleep_setstate(void *v); int sleep_resume(void *v); -void sleep_abort(void *v); int gosleep(void *v); int suspend_finish(void *v); diff --git a/sys/sys/systm.h b/sys/sys/systm.h index d831a461c..541d83d1a 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -1,4 +1,4 @@ -/* $OpenBSD: systm.h,v 1.170 2023/10/30 07:04:36 claudio Exp $ */ +/* $OpenBSD: systm.h,v 1.171 2024/05/28 12:50:23 jsg Exp $ */ /* $NetBSD: systm.h,v 1.50 1996/06/09 04:55:09 briggs Exp $ */ /*- @@ -91,7 +91,6 @@ extern int ncpusfound; /* number of CPUs found */ extern int nblkdev; /* number of entries in bdevsw */ extern int nchrdev; /* number of entries in cdevsw */ -extern int maxmem; /* max memory per process */ extern int physmem; /* physical memory */ extern dev_t dumpdev; /* dump device */ diff --git a/sys/uvm/uvm_swap_encrypt.h b/sys/uvm/uvm_swap_encrypt.h index cb3c00e98..354461339 100644 --- a/sys/uvm/uvm_swap_encrypt.h +++ b/sys/uvm/uvm_swap_encrypt.h @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_swap_encrypt.h,v 1.11 2024/05/12 09:27:13 jsg Exp $ */ +/* $OpenBSD: uvm_swap_encrypt.h,v 1.12 2024/05/28 12:31:24 jsg Exp $ */ /* * Copyright 1999 Niels Provos @@ -79,7 +79,6 @@ void swap_key_create(struct swap_key *); void swap_key_delete(struct swap_key *); extern int uvm_doswapencrypt; /* swapencrypt enabled/disabled */ -extern u_int uvm_swpkeyexpire; /* expiry time for keys (tR) */ extern int swap_encrypt_initialized; #endif /* _UVM_SWAP_ENCRYPT_H */ diff --git a/usr.bin/openssl/Makefile b/usr.bin/openssl/Makefile index 47199c10e..ac4236193 100644 --- a/usr.bin/openssl/Makefile +++ b/usr.bin/openssl/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.12 2023/04/25 16:11:02 tb Exp $ +# $OpenBSD: Makefile,v 1.13 2024/05/27 16:11:43 tb Exp $ .include @@ -11,12 +11,12 @@ CFLAGS+= -Wformat CFLAGS+= -Wformat-security CFLAGS+= -Wimplicit CFLAGS+= -Wreturn-type -#CFLAGS+= -Wshadow CFLAGS+= -Wtrigraphs CFLAGS+= -Wuninitialized CFLAGS+= -Wunused .if ${COMPILER_VERSION:L} == "clang" CFLAGS+= -Werror +CFLAGS+= -Wshadow .endif CFLAGS+= -DLIBRESSL_INTERNAL diff --git a/usr.bin/openssl/x509.c b/usr.bin/openssl/x509.c index 0d5cf5d03..1ebdfb005 100644 --- a/usr.bin/openssl/x509.c +++ b/usr.bin/openssl/x509.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509.c,v 1.37 2024/01/26 11:58:37 job Exp $ */ +/* $OpenBSD: x509.c,v 1.39 2024/05/27 16:12:55 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -1142,44 +1142,42 @@ x509_main(int argc, char **argv) purpose_print(STDout, x, ptmp); } } else if (cfg.modulus == i) { - EVP_PKEY *pkey; + EVP_PKEY *pubkey; - pkey = X509_get0_pubkey(x); - if (pkey == NULL) { + if ((pubkey = X509_get0_pubkey(x)) == NULL) { BIO_printf(bio_err, "Modulus=unavailable\n"); ERR_print_errors(bio_err); goto end; } BIO_printf(STDout, "Modulus="); - if (EVP_PKEY_id(pkey) == EVP_PKEY_RSA) { - RSA *rsa = EVP_PKEY_get0_RSA(pkey); + if (EVP_PKEY_id(pubkey) == EVP_PKEY_RSA) { + RSA *rsa = EVP_PKEY_get0_RSA(pubkey); const BIGNUM *n = NULL; RSA_get0_key(rsa, &n, NULL, NULL); BN_print(STDout, n); - } else if (EVP_PKEY_id(pkey) == EVP_PKEY_DSA) { - DSA *dsa = EVP_PKEY_get0_DSA(pkey); - const BIGNUM *pub_key = NULL; + } else if (EVP_PKEY_id(pubkey) == EVP_PKEY_DSA) { + DSA *dsa = EVP_PKEY_get0_DSA(pubkey); + const BIGNUM *dsa_pub_key = NULL; - DSA_get0_key(dsa, &pub_key, NULL); + DSA_get0_key(dsa, &dsa_pub_key, NULL); - BN_print(STDout, pub_key); + BN_print(STDout, dsa_pub_key); } else BIO_printf(STDout, "Wrong Algorithm type"); BIO_printf(STDout, "\n"); } else if (cfg.pubkey == i) { - EVP_PKEY *pkey; + EVP_PKEY *pubkey; - pkey = X509_get0_pubkey(x); - if (pkey == NULL) { + if ((pubkey = X509_get0_pubkey(x)) == NULL) { BIO_printf(bio_err, "Error getting public key\n"); ERR_print_errors(bio_err); goto end; } - PEM_write_bio_PUBKEY(STDout, pkey); + PEM_write_bio_PUBKEY(STDout, pubkey); } else if (cfg.C == i) { unsigned char *d; char *m; diff --git a/usr.bin/ssh/auth2-methods.c b/usr.bin/ssh/auth2-methods.c index 15c69697d..4043b0958 100644 --- a/usr.bin/ssh/auth2-methods.c +++ b/usr.bin/ssh/auth2-methods.c @@ -15,7 +15,6 @@ */ #include -#include #include #include diff --git a/usr.bin/ssh/ssh.1 b/usr.bin/ssh/ssh.1 index 4f5fd07a6..61a154c2a 100644 --- a/usr.bin/ssh/ssh.1 +++ b/usr.bin/ssh/ssh.1 @@ -33,8 +33,8 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.\" $OpenBSD: ssh.1,v 1.439 2024/03/14 06:23:14 job Exp $ -.Dd $Mdocdate: March 14 2024 $ +.\" $OpenBSD: ssh.1,v 1.440 2024/05/26 20:35:12 naddy Exp $ +.Dd $Mdocdate: May 26 2024 $ .Dt SSH 1 .Os .Sh NAME @@ -1633,8 +1633,6 @@ Systemwide configuration file. The file format and configuration options are described in .Xr ssh_config 5 . .Pp -.It Pa /etc/ssh/ssh_host_key -.It Pa /etc/ssh/ssh_host_dsa_key .It Pa /etc/ssh/ssh_host_ecdsa_key .It Pa /etc/ssh/ssh_host_ed25519_key .It Pa /etc/ssh/ssh_host_rsa_key diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h index 0ab99d7f4..e7ff0e3ca 100644 --- a/usr.sbin/smtpd/smtpd.h +++ b/usr.sbin/smtpd/smtpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.h,v 1.684 2024/05/07 12:10:06 op Exp $ */ +/* $OpenBSD: smtpd.h,v 1.685 2024/05/28 07:10:30 op Exp $ */ /* * Copyright (c) 2008 Gilles Chehade @@ -356,6 +356,7 @@ struct table { enum table_type t_type; char t_config[PATH_MAX]; + unsigned int t_services; void *t_handle; struct table_backend *t_backend; }; diff --git a/usr.sbin/smtpd/table.c b/usr.sbin/smtpd/table.c index d24892ede..2b9c9cf25 100644 --- a/usr.sbin/smtpd/table.c +++ b/usr.sbin/smtpd/table.c @@ -1,4 +1,4 @@ -/* $OpenBSD: table.c,v 1.52 2024/05/07 12:10:06 op Exp $ */ +/* $OpenBSD: table.c,v 1.53 2024/05/28 07:10:30 op Exp $ */ /* * Copyright (c) 2013 Eric Faurot @@ -245,6 +245,7 @@ table_create(struct smtpd *conf, const char *backend, const char *name, fatalx("table_create: backend \"%s\" does not exist", backend); t = xcalloc(1, sizeof(*t)); + t->t_services = tb->services; t->t_backend = tb; if (config) { @@ -341,7 +342,7 @@ table_check_type(struct table *t, uint32_t mask) int table_check_service(struct table *t, uint32_t mask) { - return t->t_backend->services & mask; + return t->t_services & mask; } int diff --git a/usr.sbin/smtpd/table_proc.c b/usr.sbin/smtpd/table_proc.c index e7f2a736b..07598ca69 100644 --- a/usr.sbin/smtpd/table_proc.c +++ b/usr.sbin/smtpd/table_proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: table_proc.c,v 1.22 2024/05/23 17:10:00 op Exp $ */ +/* $OpenBSD: table_proc.c,v 1.23 2024/05/28 07:10:30 op Exp $ */ /* * Copyright (c) 2024 Omar Polo @@ -172,6 +172,7 @@ table_proc_open(struct table *table) if (services == 0) fatalx("table-proc: no services registered"); + table->t_services = services; table->t_handle = priv; return (1);