sync with OpenBSD -current

This commit is contained in:
purplerain 2023-12-29 01:31:20 +00:00
parent 11b1e48835
commit 505632e9be
Signed by: purplerain
GPG Key ID: F42C07F07E2E35B7
25 changed files with 37303 additions and 192 deletions

View File

@ -1,4 +1,4 @@
/* $OpenBSD: cm_pmeth.c,v 1.11 2023/11/29 21:35:57 tb Exp $ */
/* $OpenBSD: cm_pmeth.c,v 1.12 2023/12/28 21:56:12 tb Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2010.
*/
@ -92,18 +92,23 @@ pkey_cmac_cleanup(EVP_PKEY_CTX *ctx)
static int
pkey_cmac_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
{
CMAC_CTX *cmkey = CMAC_CTX_new();
CMAC_CTX *cmctx = ctx->data;
CMAC_CTX *cmkey;
int ret = 0;
if (!cmkey)
return 0;
if (!CMAC_CTX_copy(cmkey, cmctx)) {
CMAC_CTX_free(cmkey);
return 0;
}
EVP_PKEY_assign(pkey, EVP_PKEY_CMAC, cmkey);
if ((cmkey = CMAC_CTX_new()) == NULL)
goto err;
if (!CMAC_CTX_copy(cmkey, ctx->data))
goto err;
if (!EVP_PKEY_assign(pkey, EVP_PKEY_CMAC, cmkey))
goto err;
cmkey = NULL;
return 1;
ret = 1;
err:
CMAC_CTX_free(cmkey);
return ret;
}
static int

View File

@ -1,4 +1,4 @@
/* $OpenBSD: dh_pmeth.c,v 1.13 2022/11/26 16:08:51 tb Exp $ */
/* $OpenBSD: dh_pmeth.c,v 1.15 2023/12/28 22:10:33 tb Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2006.
*/
@ -189,25 +189,28 @@ out_of_range:
static int
pkey_dh_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
{
DH *dh = NULL;
DH *dh;
DH_PKEY_CTX *dctx = ctx->data;
BN_GENCB *pcb, cb;
int ret;
BN_GENCB *pcb = NULL;
BN_GENCB cb = {0};
int ret = 0;
if (ctx->pkey_gencb) {
if ((dh = DH_new()) == NULL)
goto err;
if (ctx->pkey_gencb != NULL) {
pcb = &cb;
evp_pkey_set_cb_translate(pcb, ctx);
} else
pcb = NULL;
dh = DH_new();
if (!dh)
return 0;
ret = DH_generate_parameters_ex(dh, dctx->prime_len, dctx->generator,
pcb);
if (ret)
EVP_PKEY_assign_DH(pkey, dh);
else
DH_free(dh);
}
if (!DH_generate_parameters_ex(dh, dctx->prime_len, dctx->generator, pcb))
goto err;
if (!EVP_PKEY_assign_DH(pkey, dh))
goto err;
dh = NULL;
ret = 1;
err:
DH_free(dh);
return ret;
}
@ -215,19 +218,29 @@ static int
pkey_dh_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
{
DH *dh = NULL;
int ret = 0;
if (ctx->pkey == NULL) {
DHerror(DH_R_NO_PARAMETERS_SET);
return 0;
goto err;
}
dh = DH_new();
if (!dh)
return 0;
EVP_PKEY_assign_DH(pkey, dh);
/* Note: if error return, pkey is freed by parent routine */
if ((dh = DH_new()) == NULL)
goto err;
if (!EVP_PKEY_set1_DH(pkey, dh))
goto err;
if (!EVP_PKEY_copy_parameters(pkey, ctx->pkey))
return 0;
return DH_generate_key(pkey->pkey.dh);
goto err;
if (!DH_generate_key(dh))
goto err;
ret = 1;
err:
DH_free(dh);
return ret;
}
static int

View File

@ -1,4 +1,4 @@
/* $OpenBSD: dsa_pmeth.c,v 1.17 2023/04/25 15:48:48 tb Exp $ */
/* $OpenBSD: dsa_pmeth.c,v 1.19 2023/12/28 22:11:26 tb Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2006.
*/
@ -288,25 +288,30 @@ out_of_range:
static int
pkey_dsa_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
{
DSA *dsa = NULL;
DSA *dsa;
DSA_PKEY_CTX *dctx = ctx->data;
BN_GENCB *pcb, cb;
int ret;
BN_GENCB *pcb = NULL;
BN_GENCB cb = {0};
int ret = 0;
if (ctx->pkey_gencb) {
if ((dsa = DSA_new()) == NULL)
goto err;
if (ctx->pkey_gencb != NULL) {
pcb = &cb;
evp_pkey_set_cb_translate(pcb, ctx);
} else
pcb = NULL;
dsa = DSA_new();
if (!dsa)
return 0;
ret = dsa_builtin_paramgen(dsa, dctx->nbits, dctx->qbits, dctx->pmd,
NULL, 0, NULL, NULL, NULL, pcb);
if (ret)
EVP_PKEY_assign_DSA(pkey, dsa);
else
DSA_free(dsa);
}
if (!dsa_builtin_paramgen(dsa, dctx->nbits, dctx->qbits, dctx->pmd,
NULL, 0, NULL, NULL, NULL, pcb))
goto err;
if (!EVP_PKEY_assign_DSA(pkey, dsa))
goto err;
dsa = NULL;
ret = 1;
err:
DSA_free(dsa);
return ret;
}
@ -314,19 +319,28 @@ static int
pkey_dsa_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
{
DSA *dsa = NULL;
int ret = 0;
if (ctx->pkey == NULL) {
DSAerror(DSA_R_NO_PARAMETERS_SET);
return 0;
goto err;
}
dsa = DSA_new();
if (!dsa)
return 0;
EVP_PKEY_assign_DSA(pkey, dsa);
/* Note: if error return, pkey is freed by parent routine */
if ((dsa = DSA_new()) == NULL)
goto err;
if (!EVP_PKEY_set1_DSA(pkey, dsa))
goto err;
if (!EVP_PKEY_copy_parameters(pkey, ctx->pkey))
return 0;
return DSA_generate_key(pkey->pkey.dsa);
goto err;
if (!DSA_generate_key(dsa))
goto err;
ret = 1;
err:
DSA_free(dsa);
return ret;
}
const EVP_PKEY_METHOD dsa_pkey_meth = {

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ec_pmeth.c,v 1.19 2023/07/28 15:50:33 tb Exp $ */
/* $OpenBSD: ec_pmeth.c,v 1.21 2023/12/28 22:12:37 tb Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2006.
*/
@ -458,18 +458,25 @@ pkey_ec_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
EC_KEY *ec = NULL;
EC_PKEY_CTX *dctx = ctx->data;
int ret = 0;
if (dctx->gen_group == NULL) {
ECerror(EC_R_NO_PARAMETERS_SET);
return 0;
goto err;
}
ec = EC_KEY_new();
if (!ec)
return 0;
ret = EC_KEY_set_group(ec, dctx->gen_group);
if (ret)
EVP_PKEY_assign_EC_KEY(pkey, ec);
else
EC_KEY_free(ec);
if ((ec = EC_KEY_new()) == NULL)
goto err;
if (!EC_KEY_set_group(ec, dctx->gen_group))
goto err;
if (!EVP_PKEY_assign_EC_KEY(pkey, ec))
goto err;
ec = NULL;
ret = 1;
err:
EC_KEY_free(ec);
return ret;
}
@ -478,28 +485,35 @@ pkey_ec_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
{
EC_KEY *ec = NULL;
EC_PKEY_CTX *dctx = ctx->data;
int ret = 0;
if (ctx->pkey == NULL && dctx->gen_group == NULL) {
ECerror(EC_R_NO_PARAMETERS_SET);
return 0;
}
ec = EC_KEY_new();
if (ec == NULL)
return 0;
if (!EVP_PKEY_assign_EC_KEY(pkey, ec)) {
EC_KEY_free(ec);
return 0;
}
/* Note: if error is returned, we count on caller to free pkey->pkey.ec */
if (ctx->pkey != NULL) {
if (!EVP_PKEY_copy_parameters(pkey, ctx->pkey))
return 0;
} else {
if (!EC_KEY_set_group(ec, dctx->gen_group))
return 0;
goto err;
}
return EC_KEY_generate_key(ec);
if ((ec = EC_KEY_new()) == NULL)
goto err;
if (!EVP_PKEY_set1_EC_KEY(pkey, ec))
goto err;
if (ctx->pkey != NULL) {
if (!EVP_PKEY_copy_parameters(pkey, ctx->pkey))
goto err;
} else {
if (!EC_KEY_set_group(ec, dctx->gen_group))
goto err;
}
if (!EC_KEY_generate_key(ec))
goto err;
ret = 1;
err:
EC_KEY_free(ec);
return ret;
}
const EVP_PKEY_METHOD ec_pkey_meth = {

View File

@ -1,4 +1,4 @@
/* $OpenBSD: gost89imit_pmeth.c,v 1.5 2022/11/26 16:08:53 tb Exp $ */
/* $OpenBSD: gost89imit_pmeth.c,v 1.6 2023/12/28 21:47:17 tb Exp $ */
/*
* Copyright (c) 2014 Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
* Copyright (c) 2005-2006 Cryptocom LTD
@ -107,22 +107,29 @@ static int
pkey_gost_mac_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
{
struct gost_mac_pmeth_data *data = EVP_PKEY_CTX_get_data(ctx);
unsigned char *keydata;
unsigned char *keydata = NULL;
int ret = 0;
if (!data->key_set) {
GOSTerror(GOST_R_MAC_KEY_NOT_SET);
return 0;
goto err;
}
keydata = malloc(32);
if (keydata == NULL) {
if ((keydata = malloc(32)) == NULL) {
GOSTerror(ERR_R_MALLOC_FAILURE);
return 0;
goto err;
}
memcpy(keydata, data->key, 32);
EVP_PKEY_assign(pkey, NID_id_Gost28147_89_MAC, keydata);
if (!EVP_PKEY_assign(pkey, NID_id_Gost28147_89_MAC, keydata))
goto err;
keydata = NULL;
return 1;
ret = 1;
err:
freezero(keydata, 32);
return ret;
}
static int

View File

@ -1,4 +1,4 @@
/* $OpenBSD: gostr341001_ameth.c,v 1.20 2022/11/26 16:08:53 tb Exp $ */
/* $OpenBSD: gostr341001_ameth.c,v 1.22 2023/12/28 21:53:09 tb Exp $ */
/*
* Copyright (c) 2014 Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
* Copyright (c) 2005-2006 Cryptocom LTD
@ -101,8 +101,10 @@ decode_gost01_algor_params(EVP_PKEY *pkey, const unsigned char **p, int len)
GOSTerror(ERR_R_MALLOC_FAILURE);
return 0;
}
if (EVP_PKEY_assign_GOST(pkey, ec) == 0)
if (EVP_PKEY_assign_GOST(pkey, ec) == 0) {
GOST_KEY_free(ec);
return 0;
}
}
group = EC_GROUP_new_by_curve_name(param_nid);
@ -205,7 +207,9 @@ pub_decode_gost01(EVP_PKEY *pk, X509_PUBKEY *pub)
if (X509_PUBKEY_get0_param(&palgobj, &pubkey_buf, &pub_len, &palg, pub)
== 0)
return 0;
(void)EVP_PKEY_assign_GOST(pk, NULL);
/* Called for the side effect of freeing pk->pkey. */
if (!EVP_PKEY_set_type(pk, EVP_PKEY_GOSTR01))
return 0;
X509_ALGOR_get0(NULL, &ptype, (const void **)&pval, palg);
if (ptype != V_ASN1_SEQUENCE) {
GOSTerror(GOST_R_BAD_KEY_PARAMETERS_FORMAT);
@ -418,7 +422,9 @@ priv_decode_gost01(EVP_PKEY *pk, const PKCS8_PRIV_KEY_INFO *p8inf)
GOSTerror(GOST_R_BAD_KEY_PARAMETERS_FORMAT);
return 0;
}
(void)EVP_PKEY_assign_GOST(pk, NULL);
/* Called for the side effect of freeing pk->pkey. */
if (!EVP_PKEY_set_type(pk, EVP_PKEY_GOSTR01))
return 0;
X509_ALGOR_get0(NULL, &ptype, (const void **)&pval, palg);
if (ptype != V_ASN1_SEQUENCE) {
GOSTerror(GOST_R_BAD_KEY_PARAMETERS_FORMAT);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: hm_pmeth.c,v 1.16 2023/11/29 21:35:57 tb Exp $ */
/* $OpenBSD: hm_pmeth.c,v 1.17 2023/12/28 22:00:56 tb Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2007.
*/
@ -131,15 +131,22 @@ pkey_hmac_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
{
ASN1_OCTET_STRING *hkey = NULL;
HMAC_PKEY_CTX *hctx = ctx->data;
int ret = 0;
if (!hctx->ktmp.data)
return 0;
hkey = ASN1_OCTET_STRING_dup(&hctx->ktmp);
if (!hkey)
return 0;
EVP_PKEY_assign(pkey, EVP_PKEY_HMAC, hkey);
if (hctx->ktmp.data == NULL)
goto err;
if ((hkey = ASN1_OCTET_STRING_dup(&hctx->ktmp)) == NULL)
goto err;
if (!EVP_PKEY_assign(pkey, EVP_PKEY_HMAC, hkey))
goto err;
hkey = NULL;
return 1;
ret = 1;
err:
ASN1_OCTET_STRING_free(hkey);
return ret;
}
static int

View File

@ -1,4 +1,4 @@
/* $OpenBSD: rsa_ameth.c,v 1.51 2023/11/09 08:29:53 tb Exp $ */
/* $OpenBSD: rsa_ameth.c,v 1.53 2023/12/28 21:58:12 tb Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2006.
*/
@ -204,13 +204,22 @@ static int
old_rsa_priv_decode(EVP_PKEY *pkey, const unsigned char **pder, int derlen)
{
RSA *rsa;
int ret = 0;
if ((rsa = d2i_RSAPrivateKey(NULL, pder, derlen)) == NULL) {
RSAerror(ERR_R_RSA_LIB);
return 0;
goto err;
}
EVP_PKEY_assign(pkey, pkey->ameth->pkey_id, rsa);
return 1;
if (!EVP_PKEY_assign(pkey, pkey->ameth->pkey_id, rsa))
goto err;
rsa = NULL;
ret = 1;
err:
RSA_free(rsa);
return ret;
}
static int
@ -255,24 +264,27 @@ static int
rsa_priv_decode(EVP_PKEY *pkey, const PKCS8_PRIV_KEY_INFO *p8)
{
const unsigned char *p;
RSA *rsa;
RSA *rsa = NULL;
int pklen;
const X509_ALGOR *alg;
int ret = 0;
if (!PKCS8_pkey_get0(NULL, &p, &pklen, &alg, p8))
return 0;
rsa = d2i_RSAPrivateKey(NULL, &p, pklen);
if (rsa == NULL) {
RSAerror(ERR_R_RSA_LIB);
return 0;
}
if (!rsa_param_decode(rsa, alg)) {
RSA_free(rsa);
return 0;
}
EVP_PKEY_assign(pkey, pkey->ameth->pkey_id, rsa);
goto err;
if ((rsa = d2i_RSAPrivateKey(NULL, &p, pklen)) == NULL)
goto err;
if (!rsa_param_decode(rsa, alg))
goto err;
if (!EVP_PKEY_assign(pkey, pkey->ameth->pkey_id, rsa))
goto err;
rsa = NULL;
return 1;
ret = 1;
err:
RSA_free(rsa);
return ret;
}
static int

View File

@ -1,4 +1,4 @@
/* $OpenBSD: rsa_pmeth.c,v 1.39 2023/07/08 12:26:45 beck Exp $ */
/* $OpenBSD: rsa_pmeth.c,v 1.40 2023/12/28 21:59:07 tb Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2006.
*/
@ -756,32 +756,36 @@ pkey_rsa_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
{
RSA *rsa = NULL;
RSA_PKEY_CTX *rctx = ctx->data;
BN_GENCB *pcb, cb;
int ret;
BN_GENCB *pcb = NULL;
BN_GENCB cb = {0};
int ret = 0;
if (rctx->pub_exp == NULL) {
if ((rctx->pub_exp = BN_new()) == NULL)
return 0;
goto err;
if (!BN_set_word(rctx->pub_exp, RSA_F4))
return 0;
goto err;
}
if ((rsa = RSA_new()) == NULL)
return 0;
goto err;
if (ctx->pkey_gencb != NULL) {
pcb = &cb;
evp_pkey_set_cb_translate(pcb, ctx);
} else {
pcb = NULL;
}
ret = RSA_generate_key_ex(rsa, rctx->nbits, rctx->pub_exp, pcb);
if (ret > 0 && !rsa_set_pss_param(rsa, ctx)) {
RSA_free(rsa);
return 0;
}
if (ret > 0)
EVP_PKEY_assign(pkey, ctx->pmeth->pkey_id, rsa);
else
RSA_free(rsa);
if (!RSA_generate_key_ex(rsa, rctx->nbits, rctx->pub_exp, pcb))
goto err;
if (!rsa_set_pss_param(rsa, ctx))
goto err;
if (!EVP_PKEY_assign(pkey, ctx->pmeth->pkey_id, rsa))
goto err;
rsa = NULL;
ret = 1;
err:
RSA_free(rsa);
return ret;
}

View File

@ -1,4 +1,4 @@
# $OpenBSD: GENERIC,v 1.520 2023/10/11 12:52:00 stsp Exp $
# $OpenBSD: GENERIC,v 1.521 2023/12/28 17:36:28 stsp Exp $
#
# For further information on compiling SecBSD kernels, see the config(8)
# man page.
@ -586,6 +586,7 @@ wpi* at pci? # Intel PRO/Wireless 3945ABG
iwn* at pci? # Intel WiFi Link 4965/5000/1000/6000
iwm* at pci? # Intel WiFi Link 7xxx
iwx* at pci? # Intel WiFi Link 22xxx
#qwx* at pci? # Qualcomm 802.11ax
ral* at pci? # Ralink RT2500/RT2501/RT2600
ral* at cardbus? # Ralink RT2500/RT2501/RT2600
rtw* at pci? # Realtek 8180

View File

@ -1,4 +1,4 @@
# $OpenBSD: RAMDISK_CD,v 1.203 2023/10/13 13:52:08 stsp Exp $
# $OpenBSD: RAMDISK_CD,v 1.204 2023/12/28 17:36:28 stsp Exp $
machine amd64
maxusers 4
@ -287,6 +287,7 @@ wpi* at pci? # Intel PRO/Wireless 3945ABG
iwn* at pci? # Intel Wireless WiFi Link 4965AGN
iwm* at pci? # Intel WiFi Link 7xxx
iwx* at pci? # Intel WiFi Link 22xxx
#qwx* at pci? # Qualcomm 802.11ax
ral* at pci? # Ralink RT2500/RT2501/RT2600
ral* at cardbus? # Ralink RT2500/RT2501/RT2600
rtw* at pci? # Realtek 8180

View File

@ -1,4 +1,4 @@
# $OpenBSD: GENERIC,v 1.278 2023/12/11 11:15:44 claudio Exp $
# $OpenBSD: GENERIC,v 1.279 2023/12/28 17:36:29 stsp Exp $
#
# GENERIC machine description file
#
@ -394,6 +394,7 @@ vmx* at pci? # VMware VMXNET3 virtual interface
athn* at pci? # Atheros AR9k (802.11a/g/n)
bwfm* at pci? # Broadcom FullMAC
iwx* at pci? # Intel WiFi Link 22xxx
#qwx* at pci? # Qualcomm 802.11ax
# PCI SCSI
ahci* at pci? flags 0x0000 # AHCI SATA controllers

View File

@ -1,4 +1,4 @@
# $OpenBSD: RAMDISK,v 1.211 2023/11/13 12:49:41 jsg Exp $
# $OpenBSD: RAMDISK,v 1.212 2023/12/28 17:36:29 stsp Exp $
machine arm64
maxusers 4
@ -315,6 +315,7 @@ vmx* at pci? # VMware VMXNET3 virtual interface
athn* at pci? # Atheros AR9k (802.11a/g/n)
bwfm* at pci? # Broadcom FullMAC
iwx* at pci? # Intel WiFi Link 22xxx
#qwx* at pci? # Qualcomm 802.11ax
# PCI SCSI
ahci* at pci? flags 0x0000 # AHCI SATA controllers

View File

@ -1,4 +1,4 @@
/* $OpenBSD: aplpcie.c,v 1.17 2023/09/21 20:26:17 kettenis Exp $ */
/* $OpenBSD: aplpcie.c,v 1.18 2023/12/28 13:32:56 kettenis Exp $ */
/*
* Copyright (c) 2021 Mark Kettenis <kettenis@openbsd.org>
*
@ -74,10 +74,13 @@
#define PCIE_PORT_RID2SID_VALID (1U << 31)
#define PCIE_PORT_RID2SID_SID_SHIFT 16
#define PCIE_PORT_RID2SID_RID_MASK 0x0000ffff
#define PCIE_PORT_MAX_RID2SID 64
#define PCIE_T6020_PORT_MSI_DOORBELL_LO 0x016c
#define PCIE_T6020_PORT_MSI_DOORBELL_HI 0x0170
#define PCIE_T6020_PORT_PERST 0x082c
#define PCIE_T6020_PORT_RID2SID(idx) (0x3000 + (idx) * 4)
#define PCIE_T6020_PORT_MAX_RID2SID 512
#define PCIE_T6020_PORT_MSI_MAP(idx) (0x3800 + (idx) * 4)
#define PCIE_T6020_PORT_MSI_MAP_ENABLE (1U << 31)
@ -472,7 +475,7 @@ aplpcie_init_port(struct aplpcie_softc *sc, int node)
/*
* Clear stream ID mappings.
*/
for (idx = 0; idx < 16; idx++)
for (idx = 0; idx < PCIE_PORT_MAX_RID2SID; idx++)
PWRITE4(sc, port, PCIE_PORT_RID2SID(idx), 0);
/* Check if the link is already up. */
@ -565,7 +568,7 @@ aplpcie_t6020_init_port(struct aplpcie_softc *sc, int node)
uint32_t *reset_gpio;
int pwren_gpiolen, reset_gpiolen;
uint32_t stat;
int msi, port, timo;
int idx, msi, port, timo;
if (OF_getprop(node, "status", status, sizeof(status)) > 0 &&
strcmp(status, "disabled") == 0)
@ -596,6 +599,12 @@ aplpcie_t6020_init_port(struct aplpcie_softc *sc, int node)
PWRITE4(sc, port, PCIE_T6020_PORT_MSI_DOORBELL_HI,
sc->sc_msi_doorbell >> 32);
/*
* Clear stream ID mappings.
*/
for (idx = 0; idx < PCIE_T6020_PORT_MAX_RID2SID; idx++)
PWRITE4(sc, port, PCIE_T6020_PORT_RID2SID(idx), 0);
/* Check if the link is already up. */
stat = PREAD4(sc, port, PCIE_PORT_LINK_STAT);
if (stat & PCIE_PORT_LINK_STAT_UP)
@ -782,13 +791,76 @@ aplpcie_find_port(struct aplpcie_softc *sc, int bus)
return -1;
}
int
aplpcie_map_rid(struct aplpcie_softc *sc, int port, uint16_t rid, uint32_t sid)
{
uint32_t reg;
int idx;
for (idx = 0; idx < PCIE_PORT_MAX_RID2SID; idx++) {
reg = PREAD4(sc, port, PCIE_PORT_RID2SID(idx));
/* If already mapped, we're done. */
if ((reg & PCIE_PORT_RID2SID_RID_MASK) == rid)
return 0;
/* Is this an empty slot? */
if (reg & PCIE_PORT_RID2SID_VALID)
continue;
/* Map using this slot. */
reg = (sid << PCIE_PORT_RID2SID_SID_SHIFT) | rid |
PCIE_PORT_RID2SID_VALID;
PWRITE4(sc, port, PCIE_PORT_RID2SID(idx), reg);
/* Read back to check the slot is implemented. */
if (PREAD4(sc, port, PCIE_PORT_RID2SID(idx)) != reg)
return ENODEV;
return 0;
}
return ENODEV;
}
int
aplpcie_t6020_map_rid(struct aplpcie_softc *sc, int port, uint16_t rid,
uint32_t sid)
{
uint32_t reg;
int idx;
for (idx = 0; idx < PCIE_T6020_PORT_MAX_RID2SID; idx++) {
reg = PREAD4(sc, port, PCIE_T6020_PORT_RID2SID(idx));
/* If already mapped, we're done. */
if ((reg & PCIE_PORT_RID2SID_RID_MASK) == rid)
return 0;
/* Is this an empty slot? */
if (reg & PCIE_PORT_RID2SID_VALID)
continue;
/* Map using this slot. */
reg = (sid << PCIE_PORT_RID2SID_SID_SHIFT) | rid |
PCIE_PORT_RID2SID_VALID;
PWRITE4(sc, port, PCIE_T6020_PORT_RID2SID(idx), reg);
/* Read back to check the slot is implemented. */
if (PREAD4(sc, port, PCIE_T6020_PORT_RID2SID(idx)) != reg)
return ENODEV;
return 0;
}
return ENODEV;
}
int
aplpcie_probe_device_hook(void *v, struct pci_attach_args *pa)
{
struct aplpcie_softc *sc = v;
uint32_t phandle, reg, sid;
uint32_t phandle, sid;
uint16_t rid;
int idx, port;
int error, port;
rid = pci_requester_id(pa->pa_pc, pa->pa_tag);
pa->pa_dmat = iommu_device_map_pci(sc->sc_node, rid, pa->pa_dmat);
@ -807,26 +879,19 @@ aplpcie_probe_device_hook(void *v, struct pci_attach_args *pa)
if (port == -1)
return EINVAL;
for (idx = 0; idx < 16; idx++) {
reg = PREAD4(sc, port, PCIE_PORT_RID2SID(idx));
/* If already mapped, we're done. */
if ((reg & PCIE_PORT_RID2SID_RID_MASK) == rid)
return 0;
/* Is this an empty slot? */
if (reg & PCIE_PORT_RID2SID_VALID)
continue;
/* Map using this slot. */
reg = (sid << PCIE_PORT_RID2SID_SID_SHIFT) | rid |
PCIE_PORT_RID2SID_VALID;
PWRITE4(sc, port, PCIE_PORT_RID2SID(idx), reg);
return 0;
if (OF_is_compatible(sc->sc_node, "apple,t6020-pcie"))
error = aplpcie_t6020_map_rid(sc, port, rid, sid);
else
error = aplpcie_map_rid(sc, port, rid, sid);
if (error) {
printf("%s: out of stream ID mapping slots\n",
sc->sc_dev.dv_xname);
}
printf("%s: out of stream ID mapping slots\n",
sc->sc_dev.dv_xname);
/*
* Not all PCI devices do DMA, so don't return an error if we
* ran out of stream ID mapping slots.
*/
return 0;
}

View File

@ -1,4 +1,4 @@
# $OpenBSD: files,v 1.727 2023/12/21 02:57:14 jsg Exp $
# $OpenBSD: files,v 1.728 2023/12/28 17:36:29 stsp Exp $
# $NetBSD: files,v 1.87 1996/05/19 17:17:50 jonathan Exp $
# @(#)files.newconf 7.5 (Berkeley) 5/10/93
@ -424,6 +424,10 @@ file dev/ic/malo.c malo
device bwi: ether, ifnet, ifmedia, firmload, wlan
file dev/ic/bwi.c bwi
# Qualcomm 802.11ax
device qwx: ether, ifnet, ifmedia, firmload, wlan
file dev/ic/qwx.c qwx
# Intel OnChip System Fabric
device iosf
file dev/ic/iosf.c iosf needs-flag

View File

@ -1,4 +1,4 @@
/* $OpenBSD: dwqe.c,v 1.15 2023/11/10 15:51:20 bluhm Exp $ */
/* $OpenBSD: dwqe.c,v 1.16 2023/12/28 14:30:28 uwe Exp $ */
/*
* Copyright (c) 2008, 2019 Mark Kettenis <kettenis@openbsd.org>
* Copyright (c) 2017, 2022 Patrick Wildt <patrick@blueri.se>
@ -338,11 +338,18 @@ dwqe_start(struct ifqueue *ifq)
#endif
}
if (sc->sc_tx_prod != idx) {
if (used > 0) {
sc->sc_tx_prod = idx;
/* Set a timeout in case the chip goes out to lunch. */
ifp->if_timer = 5;
/*
* Start the transmit process after the last in-use Tx
* descriptor's OWN bit has been updated.
*/
dwqe_write(sc, GMAC_CHAN_TX_END_ADDR(0), DWQE_DMA_DVA(sc->sc_txring) +
idx * sizeof(struct dwqe_desc));
}
}
@ -1055,9 +1062,6 @@ dwqe_encap(struct dwqe_softc *sc, struct mbuf *m, int *idx, int *used)
bus_dmamap_sync(sc->sc_dmat, DWQE_DMA_MAP(sc->sc_txring),
*idx * sizeof(*txd), sizeof(*txd), BUS_DMASYNC_PREWRITE);
dwqe_write(sc, GMAC_CHAN_TX_END_ADDR(0), DWQE_DMA_DVA(sc->sc_txring) +
frag * sizeof(*txd));
KASSERT(sc->sc_txbuf[cur].tb_m == NULL);
sc->sc_txbuf[*idx].tb_map = sc->sc_txbuf[cur].tb_map;
sc->sc_txbuf[cur].tb_map = map;

18404
sys/dev/ic/qwx.c Normal file

File diff suppressed because it is too large Load Diff

13140
sys/dev/ic/qwxreg.h Normal file

File diff suppressed because it is too large Load Diff

1523
sys/dev/ic/qwxvar.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/* $OpenBSD: eephy.c,v 1.62 2023/12/07 09:46:58 uwe Exp $ */
/* $OpenBSD: eephy.c,v 1.63 2023/12/28 14:03:21 uwe Exp $ */
/*
* Principal Author: Parag Patel
* Copyright (c) 2001
@ -188,16 +188,28 @@ eephy_attach(struct device *parent, struct device *self, void *aux)
PHY_WRITE(sc, E1000_EADR, page);
}
/* Switch to SGMII-to-copper mode if necessary. */
if (sc->mii_model == MII_MODEL_MARVELL_E1512 &&
sc->mii_flags & MIIF_SGMII) {
/*
* GCR1 MII mode defaults to an invalid value on E1512/E1514
* and must be programmed with the desired mode of operation.
*/
if (sc->mii_model == MII_MODEL_MARVELL_E1512) {
uint32_t mode;
page = PHY_READ(sc, E1000_EADR);
PHY_WRITE(sc, E1000_EADR, 18);
reg = PHY_READ(sc, E1000_GCR1);
mode = reg & E1000_GCR1_MODE_MASK;
if (mode == E1000_GCR1_MODE_UNSET)
mode = E1000_GCR1_MODE_RGMII;
if (sc->mii_flags & MIIF_SGMII)
mode = E1000_GCR1_MODE_SGMII;
reg &= ~E1000_GCR1_MODE_MASK;
reg |= E1000_GCR1_MODE_SGMII;
reg |= E1000_GCR1_RESET;
reg |= E1000_GCR1_RESET | mode;
PHY_WRITE(sc, E1000_GCR1, reg);
PHY_WRITE(sc, E1000_EADR, page);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: eephyreg.h,v 1.10 2023/12/07 09:46:58 uwe Exp $ */
/* $OpenBSD: eephyreg.h,v 1.11 2023/12/28 14:03:21 uwe Exp $ */
/*
* Principal Author: Parag Patel
* Copyright (c) 2001
@ -331,4 +331,9 @@
#define E1000_GCR1 0x14 /* General Control Register 1 */
#define E1000_GCR1_RESET 0x8000
#define E1000_GCR1_MODE_MASK 0x0007
#define E1000_GCR1_MODE_RGMII 0x0000
#define E1000_GCR1_MODE_SGMII 0x0001
#define E1000_GCR1_MODE_RGMII_1000X 0x0002
#define E1000_GCR1_MODE_RGMII_100FX 0x0003
#define E1000_GCR1_MODE_RGMII_TO_SGMII 0x0004
#define E1000_GCR1_MODE_UNSET 0x0007

View File

@ -1,4 +1,4 @@
# $OpenBSD: files.pci,v 1.362 2023/10/11 12:52:00 stsp Exp $
# $OpenBSD: files.pci,v 1.363 2023/12/28 17:36:29 stsp Exp $
# $NetBSD: files.pci,v 1.20 1996/09/24 17:47:15 christos Exp $
#
# Config file and device description for machine-independent PCI code.
@ -555,6 +555,10 @@ device iwx: ifnet, wlan, firmload
attach iwx at pci
file dev/pci/if_iwx.c iwx
# Qualcomm 802.11ax
attach qwx at pci with qwx_pci
file dev/pci/if_qwx_pci.c qwx_pci
# C-Media CMI8x38 Audio Chip
device cmpci {}: audio
attach cmpci at pci

3857
sys/dev/pci/if_qwx_pci.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/* $OpenBSD: pf.c,v 1.1189 2023/12/01 10:28:32 sashan Exp $ */
/* $OpenBSD: pf.c,v 1.1190 2023/12/28 16:21:08 aisha Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
@ -1731,11 +1731,8 @@ pf_purge_expired_src_nodes(void)
PF_ASSERT_LOCKED();
for (cur = RB_MIN(pf_src_tree, &tree_src_tracking); cur; cur = next) {
next = RB_NEXT(pf_src_tree, &tree_src_tracking, cur);
RB_FOREACH_SAFE(cur, pf_src_tree, &tree_src_tracking, next) {
if (cur->states == 0 && cur->expire <= getuptime()) {
next = RB_NEXT(pf_src_tree, &tree_src_tracking, cur);
pf_remove_src_node(cur);
}
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: server_file.c,v 1.75 2022/08/15 09:40:14 op Exp $ */
/* $OpenBSD: server_file.c,v 1.76 2023/12/28 18:05:32 espie Exp $ */
/*
* Copyright (c) 2006 - 2017 Reyk Floeter <reyk@openbsd.org>
@ -49,6 +49,7 @@ int server_file_modified_since(struct http_descriptor *,
int server_file_method(struct client *);
int parse_range_spec(char *, size_t, struct range *);
int parse_ranges(struct client *, char *, size_t);
static int select_visible(const struct dirent *);
int
server_file_access(struct httpd *env, struct client *clt,
@ -466,6 +467,17 @@ server_partial_file_request(struct httpd *env, struct client *clt, char *path,
return (-1);
}
/* ignore hidden files starting with a dot */
static int
select_visible(const struct dirent *dp)
{
if (dp->d_name[0] == '.' &&
!(dp->d_name[1] == '.' && dp->d_name[2] == '\0'))
return 0;
else
return 1;
}
int
server_file_index(struct httpd *env, struct client *clt)
{
@ -536,7 +548,8 @@ server_file_index(struct httpd *env, struct client *clt)
free(escapedpath);
if ((namesize = scandir(path, &namelist, NULL, alphasort)) == -1)
if ((namesize = scandir(path, &namelist, select_visible,
alphasort)) == -1)
goto abort;
/* Indicate failure but continue going through the list */
@ -570,10 +583,7 @@ server_file_index(struct httpd *env, struct client *clt)
continue;
}
if (dp->d_name[0] == '.' &&
!(dp->d_name[1] == '.' && dp->d_name[2] == '\0')) {
/* ignore hidden files starting with a dot */
} else if (S_ISDIR(subst.st_mode)) {
if (S_ISDIR(subst.st_mode)) {
namewidth -= 1; /* trailing slash */
if (evbuffer_add_printf(evb,
"<a href=\"%s%s/\">%s/</a>%*s%s%20s\n",