sync with OpenBSD -current

This commit is contained in:
purplerain 2024-04-12 02:10:46 +00:00
parent 0e1b66badd
commit 7514c4f262
Signed by: purplerain
GPG Key ID: F42C07F07E2E35B7
20 changed files with 438 additions and 166 deletions

View File

@ -1,4 +1,4 @@
/* $OpenBSD: a_time_tm.c,v 1.36 2024/04/10 14:55:12 beck Exp $ */ /* $OpenBSD: a_time_tm.c,v 1.38 2024/04/11 06:49:19 tb Exp $ */
/* /*
* Copyright (c) 2015 Bob Beck <beck@openbsd.org> * Copyright (c) 2015 Bob Beck <beck@openbsd.org>
* *
@ -35,29 +35,29 @@ int
ASN1_time_tm_cmp(struct tm *tm1, struct tm *tm2) ASN1_time_tm_cmp(struct tm *tm1, struct tm *tm2)
{ {
if (tm1->tm_year < tm2->tm_year) if (tm1->tm_year < tm2->tm_year)
return (-1); return -1;
if (tm1->tm_year > tm2->tm_year) if (tm1->tm_year > tm2->tm_year)
return (1); return 1;
if (tm1->tm_mon < tm2->tm_mon) if (tm1->tm_mon < tm2->tm_mon)
return (-1); return -1;
if (tm1->tm_mon > tm2->tm_mon) if (tm1->tm_mon > tm2->tm_mon)
return (1); return 1;
if (tm1->tm_mday < tm2->tm_mday) if (tm1->tm_mday < tm2->tm_mday)
return (-1); return -1;
if (tm1->tm_mday > tm2->tm_mday) if (tm1->tm_mday > tm2->tm_mday)
return (1); return 1;
if (tm1->tm_hour < tm2->tm_hour) if (tm1->tm_hour < tm2->tm_hour)
return (-1); return -1;
if (tm1->tm_hour > tm2->tm_hour) if (tm1->tm_hour > tm2->tm_hour)
return (1); return 1;
if (tm1->tm_min < tm2->tm_min) if (tm1->tm_min < tm2->tm_min)
return (-1); return -1;
if (tm1->tm_min > tm2->tm_min) if (tm1->tm_min > tm2->tm_min)
return (1); return 1;
if (tm1->tm_sec < tm2->tm_sec) if (tm1->tm_sec < tm2->tm_sec)
return (-1); return -1;
if (tm1->tm_sec > tm2->tm_sec) if (tm1->tm_sec > tm2->tm_sec)
return (1); return 1;
return 0; return 0;
} }
@ -78,31 +78,24 @@ ASN1_time_tm_clamp_notafter(struct tm *tm)
} }
/* Convert time to GeneralizedTime, X.690, 11.7. */ /* Convert time to GeneralizedTime, X.690, 11.7. */
ASN1_TIME * static int
tm_to_gentime(struct tm *tm, ASN1_TIME *atime) tm_to_gentime(struct tm *tm, ASN1_TIME *atime)
{ {
char *time_str = NULL; char *time_str = NULL;
int year;
year = tm->tm_year + 1900; if (tm->tm_year < -1900 || tm->tm_year > 9999 - 1900) {
if (year < 0 || year > 9999) {
ASN1error(ASN1_R_ILLEGAL_TIME_VALUE); ASN1error(ASN1_R_ILLEGAL_TIME_VALUE);
goto err; return 0;
}
if (asprintf(&time_str, "%04u%02u%02u%02u%02u%02uZ", year,
tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min,
tm->tm_sec) == -1) {
time_str = NULL;
ASN1error(ERR_R_MALLOC_FAILURE);
goto err;
} }
if (atime == NULL) if (atime == NULL)
atime = ASN1_TIME_new(); return 1;
if (atime == NULL) {
if (asprintf(&time_str, "%04u%02u%02u%02u%02u%02uZ", tm->tm_year + 1900,
tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min,
tm->tm_sec) == -1) {
ASN1error(ERR_R_MALLOC_FAILURE); ASN1error(ERR_R_MALLOC_FAILURE);
goto err; return 0;
} }
free(atime->data); free(atime->data);
@ -110,38 +103,28 @@ tm_to_gentime(struct tm *tm, ASN1_TIME *atime)
atime->length = GENTIME_LENGTH; atime->length = GENTIME_LENGTH;
atime->type = V_ASN1_GENERALIZEDTIME; atime->type = V_ASN1_GENERALIZEDTIME;
return (atime); return 1;
err:
free(time_str);
return (NULL);
} }
/* Convert time to UTCTime, X.690, 11.8. */ /* Convert time to UTCTime, X.690, 11.8. */
ASN1_TIME * static int
tm_to_utctime(struct tm *tm, ASN1_TIME *atime) tm_to_utctime(struct tm *tm, ASN1_TIME *atime)
{ {
char *time_str = NULL; char *time_str = NULL;
if (tm->tm_year >= 150 || tm->tm_year < 50) { if (tm->tm_year >= 150 || tm->tm_year < 50) {
ASN1error(ASN1_R_ILLEGAL_TIME_VALUE); ASN1error(ASN1_R_ILLEGAL_TIME_VALUE);
goto err; return 0;
} }
if (atime == NULL)
return 1;
if (asprintf(&time_str, "%02u%02u%02u%02u%02u%02uZ", if (asprintf(&time_str, "%02u%02u%02u%02u%02u%02uZ",
tm->tm_year % 100, tm->tm_mon + 1, tm->tm_mday, tm->tm_year % 100, tm->tm_mon + 1, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec) == -1) { tm->tm_hour, tm->tm_min, tm->tm_sec) == -1) {
time_str = NULL;
ASN1error(ERR_R_MALLOC_FAILURE); ASN1error(ERR_R_MALLOC_FAILURE);
goto err; return 0;
}
if (atime == NULL)
atime = ASN1_TIME_new();
if (atime == NULL) {
ASN1error(ERR_R_MALLOC_FAILURE);
goto err;
} }
free(atime->data); free(atime->data);
@ -149,21 +132,16 @@ tm_to_utctime(struct tm *tm, ASN1_TIME *atime)
atime->length = UTCTIME_LENGTH; atime->length = UTCTIME_LENGTH;
atime->type = V_ASN1_UTCTIME; atime->type = V_ASN1_UTCTIME;
return (atime); return 1;
err:
free(time_str);
return (NULL);
} }
ASN1_TIME * static int
tm_to_rfc5280_time(struct tm *tm, ASN1_TIME *atime) tm_to_rfc5280_time(struct tm *tm, ASN1_TIME *atime)
{ {
if (tm->tm_year >= 50 && tm->tm_year < 150) if (tm->tm_year >= 50 && tm->tm_year < 150)
return (tm_to_utctime(tm, atime)); return tm_to_utctime(tm, atime);
return (tm_to_gentime(tm, atime)); return tm_to_gentime(tm, atime);
} }
@ -320,7 +298,7 @@ ASN1_time_parse(const char *bytes, size_t len, struct tm *tm, int mode)
CBS cbs; CBS cbs;
if (bytes == NULL) if (bytes == NULL)
return (-1); return -1;
CBS_init(&cbs, bytes, len); CBS_init(&cbs, bytes, len);
@ -344,71 +322,80 @@ ASN1_time_parse(const char *bytes, size_t len, struct tm *tm, int mode)
static int static int
ASN1_TIME_set_string_internal(ASN1_TIME *s, const char *str, int mode) ASN1_TIME_set_string_internal(ASN1_TIME *s, const char *str, int mode)
{ {
ASN1_TIME *atime = s;
struct tm tm; struct tm tm;
int type; int type;
int ret = 0;
if ((type = ASN1_time_parse(str, strlen(str), &tm, mode)) == -1) if ((type = ASN1_time_parse(str, strlen(str), &tm, mode)) == -1)
return (0); return 0;
switch (mode) { switch (mode) {
case V_ASN1_UTCTIME: case V_ASN1_UTCTIME:
ret = (type == mode && (atime = tm_to_utctime(&tm, s)) != NULL); return type == mode && tm_to_utctime(&tm, s);
break;
case V_ASN1_GENERALIZEDTIME: case V_ASN1_GENERALIZEDTIME:
ret = (type == mode && (atime = tm_to_gentime(&tm, s)) != NULL); return type == mode && tm_to_gentime(&tm, s);
break;
case RFC5280: case RFC5280:
ret = ((atime = tm_to_rfc5280_time(&tm, s)) != NULL); return tm_to_rfc5280_time(&tm, s);
break;
default: default:
ret = 0; return 0;
break;
} }
if (atime != s)
ASN1_TIME_free(atime);
return ret;
} }
static ASN1_TIME * static ASN1_TIME *
ASN1_TIME_adj_internal(ASN1_TIME *s, time_t t, int offset_day, long offset_sec, ASN1_TIME_adj_internal(ASN1_TIME *s, time_t t, int offset_day, long offset_sec,
int mode) int mode)
{ {
ASN1_TIME *atime = s;
struct tm tm; struct tm tm;
if (!asn1_time_time_t_to_tm(&t, &tm)) if (!asn1_time_time_t_to_tm(&t, &tm))
return (NULL); goto err;
if (offset_day != 0 || offset_sec != 0) { if (offset_day != 0 || offset_sec != 0) {
if (!OPENSSL_gmtime_adj(&tm, offset_day, offset_sec)) if (!OPENSSL_gmtime_adj(&tm, offset_day, offset_sec))
return (NULL); goto err;
} }
if (atime == NULL)
atime = ASN1_TIME_new();
if (atime == NULL)
goto err;
switch (mode) { switch (mode) {
case V_ASN1_UTCTIME: case V_ASN1_UTCTIME:
return (tm_to_utctime(&tm, s)); if (!tm_to_utctime(&tm, atime))
goto err;
break;
case V_ASN1_GENERALIZEDTIME: case V_ASN1_GENERALIZEDTIME:
return (tm_to_gentime(&tm, s)); if (!tm_to_gentime(&tm, atime))
goto err;
break;
case RFC5280: case RFC5280:
return (tm_to_rfc5280_time(&tm, s)); if (!tm_to_rfc5280_time(&tm, atime))
goto err;
break;
default: default:
return (NULL); goto err;
} }
return atime;
err:
if (atime != s)
ASN1_TIME_free(atime);
return NULL;
} }
ASN1_TIME * ASN1_TIME *
ASN1_TIME_set(ASN1_TIME *s, time_t t) ASN1_TIME_set(ASN1_TIME *s, time_t t)
{ {
return (ASN1_TIME_adj(s, t, 0, 0)); return ASN1_TIME_adj(s, t, 0, 0);
} }
LCRYPTO_ALIAS(ASN1_TIME_set); LCRYPTO_ALIAS(ASN1_TIME_set);
ASN1_TIME * ASN1_TIME *
ASN1_TIME_adj(ASN1_TIME *s, time_t t, int offset_day, long offset_sec) ASN1_TIME_adj(ASN1_TIME *s, time_t t, int offset_day, long offset_sec)
{ {
return (ASN1_TIME_adj_internal(s, t, offset_day, offset_sec, RFC5280)); return ASN1_TIME_adj_internal(s, t, offset_day, offset_sec, RFC5280);
} }
LCRYPTO_ALIAS(ASN1_TIME_adj); LCRYPTO_ALIAS(ASN1_TIME_adj);
@ -416,8 +403,8 @@ int
ASN1_TIME_check(const ASN1_TIME *t) ASN1_TIME_check(const ASN1_TIME *t)
{ {
if (t->type != V_ASN1_GENERALIZEDTIME && t->type != V_ASN1_UTCTIME) if (t->type != V_ASN1_GENERALIZEDTIME && t->type != V_ASN1_UTCTIME)
return (0); return 0;
return (t->type == ASN1_time_parse(t->data, t->length, NULL, t->type)); return t->type == ASN1_time_parse(t->data, t->length, NULL, t->type);
} }
LCRYPTO_ALIAS(ASN1_TIME_check); LCRYPTO_ALIAS(ASN1_TIME_check);
@ -428,26 +415,36 @@ ASN1_TIME_to_generalizedtime(const ASN1_TIME *t, ASN1_GENERALIZEDTIME **out)
struct tm tm; struct tm tm;
if (t->type != V_ASN1_GENERALIZEDTIME && t->type != V_ASN1_UTCTIME) if (t->type != V_ASN1_GENERALIZEDTIME && t->type != V_ASN1_UTCTIME)
return (NULL); goto err;
if (t->type != ASN1_time_parse(t->data, t->length, &tm, t->type)) if (t->type != ASN1_time_parse(t->data, t->length, &tm, t->type))
return (NULL); goto err;
if (out == NULL || (agt = *out) == NULL)
agt = ASN1_TIME_new();
if (agt == NULL)
goto err;
if (!tm_to_gentime(&tm, agt))
goto err;
if (out != NULL)
agt = *out;
if ((agt = tm_to_gentime(&tm, agt)) == NULL)
return (NULL);
if (out != NULL) if (out != NULL)
*out = agt; *out = agt;
return (agt); return agt;
err:
if (out == NULL || *out != agt)
ASN1_TIME_free(agt);
return NULL;
} }
LCRYPTO_ALIAS(ASN1_TIME_to_generalizedtime); LCRYPTO_ALIAS(ASN1_TIME_to_generalizedtime);
int int
ASN1_TIME_set_string(ASN1_TIME *s, const char *str) ASN1_TIME_set_string(ASN1_TIME *s, const char *str)
{ {
return (ASN1_TIME_set_string_internal(s, str, RFC5280)); return ASN1_TIME_set_string_internal(s, str, RFC5280);
} }
LCRYPTO_ALIAS(ASN1_TIME_set_string); LCRYPTO_ALIAS(ASN1_TIME_set_string);
@ -516,8 +513,8 @@ int
ASN1_UTCTIME_check(const ASN1_UTCTIME *d) ASN1_UTCTIME_check(const ASN1_UTCTIME *d)
{ {
if (d->type != V_ASN1_UTCTIME) if (d->type != V_ASN1_UTCTIME)
return (0); return 0;
return (d->type == ASN1_time_parse(d->data, d->length, NULL, d->type)); return d->type == ASN1_time_parse(d->data, d->length, NULL, d->type);
} }
LCRYPTO_ALIAS(ASN1_UTCTIME_check); LCRYPTO_ALIAS(ASN1_UTCTIME_check);
@ -525,23 +522,23 @@ int
ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str) ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str)
{ {
if (s != NULL && s->type != V_ASN1_UTCTIME) if (s != NULL && s->type != V_ASN1_UTCTIME)
return (0); return 0;
return (ASN1_TIME_set_string_internal(s, str, V_ASN1_UTCTIME)); return ASN1_TIME_set_string_internal(s, str, V_ASN1_UTCTIME);
} }
LCRYPTO_ALIAS(ASN1_UTCTIME_set_string); LCRYPTO_ALIAS(ASN1_UTCTIME_set_string);
ASN1_UTCTIME * ASN1_UTCTIME *
ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t) ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t)
{ {
return (ASN1_UTCTIME_adj(s, t, 0, 0)); return ASN1_UTCTIME_adj(s, t, 0, 0);
} }
LCRYPTO_ALIAS(ASN1_UTCTIME_set); LCRYPTO_ALIAS(ASN1_UTCTIME_set);
ASN1_UTCTIME * ASN1_UTCTIME *
ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t, int offset_day, long offset_sec) ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t, int offset_day, long offset_sec)
{ {
return (ASN1_TIME_adj_internal(s, t, offset_day, offset_sec, return ASN1_TIME_adj_internal(s, t, offset_day, offset_sec,
V_ASN1_UTCTIME)); V_ASN1_UTCTIME);
} }
LCRYPTO_ALIAS(ASN1_UTCTIME_adj); LCRYPTO_ALIAS(ASN1_UTCTIME_adj);
@ -562,8 +559,8 @@ int
ASN1_GENERALIZEDTIME_check(const ASN1_GENERALIZEDTIME *d) ASN1_GENERALIZEDTIME_check(const ASN1_GENERALIZEDTIME *d)
{ {
if (d->type != V_ASN1_GENERALIZEDTIME) if (d->type != V_ASN1_GENERALIZEDTIME)
return (0); return 0;
return (d->type == ASN1_time_parse(d->data, d->length, NULL, d->type)); return d->type == ASN1_time_parse(d->data, d->length, NULL, d->type);
} }
LCRYPTO_ALIAS(ASN1_GENERALIZEDTIME_check); LCRYPTO_ALIAS(ASN1_GENERALIZEDTIME_check);
@ -571,15 +568,15 @@ int
ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str) ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str)
{ {
if (s != NULL && s->type != V_ASN1_GENERALIZEDTIME) if (s != NULL && s->type != V_ASN1_GENERALIZEDTIME)
return (0); return 0;
return (ASN1_TIME_set_string_internal(s, str, V_ASN1_GENERALIZEDTIME)); return ASN1_TIME_set_string_internal(s, str, V_ASN1_GENERALIZEDTIME);
} }
LCRYPTO_ALIAS(ASN1_GENERALIZEDTIME_set_string); LCRYPTO_ALIAS(ASN1_GENERALIZEDTIME_set_string);
ASN1_GENERALIZEDTIME * ASN1_GENERALIZEDTIME *
ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s, time_t t) ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s, time_t t)
{ {
return (ASN1_GENERALIZEDTIME_adj(s, t, 0, 0)); return ASN1_GENERALIZEDTIME_adj(s, t, 0, 0);
} }
LCRYPTO_ALIAS(ASN1_GENERALIZEDTIME_set); LCRYPTO_ALIAS(ASN1_GENERALIZEDTIME_set);
@ -587,8 +584,8 @@ ASN1_GENERALIZEDTIME *
ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s, time_t t, int offset_day, ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s, time_t t, int offset_day,
long offset_sec) long offset_sec)
{ {
return (ASN1_TIME_adj_internal(s, t, offset_day, offset_sec, return ASN1_TIME_adj_internal(s, t, offset_day, offset_sec,
V_ASN1_GENERALIZEDTIME)); V_ASN1_GENERALIZEDTIME);
} }
LCRYPTO_ALIAS(ASN1_GENERALIZEDTIME_adj); LCRYPTO_ALIAS(ASN1_GENERALIZEDTIME_adj);
@ -601,7 +598,7 @@ ASN1_TIME_normalize(ASN1_TIME *t)
return 0; return 0;
if (!ASN1_TIME_to_tm(t, &tm)) if (!ASN1_TIME_to_tm(t, &tm))
return 0; return 0;
return tm_to_rfc5280_time(&tm, t) != NULL; return tm_to_rfc5280_time(&tm, t);
} }
LCRYPTO_ALIAS(ASN1_TIME_normalize); LCRYPTO_ALIAS(ASN1_TIME_normalize);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: kvm_sparc64.c,v 1.13 2021/12/01 21:45:19 deraadt Exp $ */ /* $OpenBSD: kvm_sparc64.c,v 1.14 2024/04/11 18:58:44 miod Exp $ */
/* $NetBSD: kvm_sparc64.c,v 1.7 2001/08/05 03:33:15 matt Exp $ */ /* $NetBSD: kvm_sparc64.c,v 1.7 2001/08/05 03:33:15 matt Exp $ */
/*- /*-
@ -53,7 +53,7 @@
#include <machine/param.h> #include <machine/param.h>
#include <machine/vmparam.h> #include <machine/vmparam.h>
#include <machine/pmap.h> #include <machine/pte.h>
#include <machine/kcore.h> #include <machine/kcore.h>
#include <limits.h> #include <limits.h>

View File

@ -1,4 +1,4 @@
/* $OpenBSD: specialreg.h,v 1.110 2024/03/17 05:49:41 guenther Exp $ */ /* $OpenBSD: specialreg.h,v 1.111 2024/04/11 23:00:13 jsg Exp $ */
/* $NetBSD: specialreg.h,v 1.1 2003/04/26 18:39:48 fvdl Exp $ */ /* $NetBSD: specialreg.h,v 1.1 2003/04/26 18:39:48 fvdl Exp $ */
/* $NetBSD: x86/specialreg.h,v 1.2 2003/04/25 21:54:30 fvdl Exp $ */ /* $NetBSD: x86/specialreg.h,v 1.2 2003/04/25 21:54:30 fvdl Exp $ */
@ -116,7 +116,7 @@
#define XFEATURE_HWP 0x00010000 /* HW P-states */ #define XFEATURE_HWP 0x00010000 /* HW P-states */
#define XFEATURE_TILECFG 0x00020000 /* AMX state */ #define XFEATURE_TILECFG 0x00020000 /* AMX state */
#define XFEATURE_TILEDATA 0x00040000 /* AMX state */ #define XFEATURE_TILEDATA 0x00040000 /* AMX state */
#define XFEATURE_AMX (XFEATURE_TILEDATA | XFEATURE_TILEDATA) #define XFEATURE_AMX (XFEATURE_TILECFG | XFEATURE_TILEDATA)
/* valid only in xcomp_bv field: */ /* valid only in xcomp_bv field: */
#define XFEATURE_COMPRESSED (1ULL << 63) /* compressed format */ #define XFEATURE_COMPRESSED (1ULL << 63) /* compressed format */

View File

@ -4228,6 +4228,8 @@ int amdgpu_device_prepare(struct drm_device *dev)
if (r) if (r)
return r; return r;
flush_delayed_work(&adev->gfx.gfx_off_delay_work);
for (i = 0; i < adev->num_ip_blocks; i++) { for (i = 0; i < adev->num_ip_blocks; i++) {
if (!adev->ip_blocks[i].status.valid) if (!adev->ip_blocks[i].status.valid)
continue; continue;

View File

@ -586,7 +586,16 @@ int drm_gem_map_attach(struct dma_buf *dma_buf,
{ {
struct drm_gem_object *obj = dma_buf->priv; struct drm_gem_object *obj = dma_buf->priv;
/*
* drm_gem_map_dma_buf() requires obj->get_sg_table(), but drivers
* that implement their own ->map_dma_buf() do not.
*/
#ifdef notyet
if (dma_buf->ops->map_dma_buf == drm_gem_map_dma_buf &&
!obj->funcs->get_sg_table)
#else
if (!obj->funcs->get_sg_table) if (!obj->funcs->get_sg_table)
#endif
return -ENOSYS; return -ENOSYS;
return drm_gem_pin(obj); return drm_gem_pin(obj);

View File

@ -1,4 +1,4 @@
# $OpenBSD: files.drm,v 1.62 2024/01/22 18:54:01 kettenis Exp $ # $OpenBSD: files.drm,v 1.63 2024/04/11 03:40:05 jsg Exp $
#file dev/pci/drm/aperture.c drm #file dev/pci/drm/aperture.c drm
file dev/pci/drm/dma-resv.c drm file dev/pci/drm/dma-resv.c drm
@ -292,6 +292,7 @@ file dev/pci/drm/i915/gt/intel_ggtt_gmch.c inteldrm
file dev/pci/drm/i915/gt/intel_gsc.c inteldrm file dev/pci/drm/i915/gt/intel_gsc.c inteldrm
file dev/pci/drm/i915/gt/intel_gt.c inteldrm file dev/pci/drm/i915/gt/intel_gt.c inteldrm
file dev/pci/drm/i915/gt/intel_gt_buffer_pool.c inteldrm file dev/pci/drm/i915/gt/intel_gt_buffer_pool.c inteldrm
file dev/pci/drm/i915/gt/intel_gt_ccs_mode.c inteldrm
file dev/pci/drm/i915/gt/intel_gt_clock_utils.c inteldrm file dev/pci/drm/i915/gt/intel_gt_clock_utils.c inteldrm
file dev/pci/drm/i915/gt/intel_gt_debugfs.c inteldrm file dev/pci/drm/i915/gt/intel_gt_debugfs.c inteldrm
file dev/pci/drm/i915/gt/intel_gt_engines_debugfs.c inteldrm file dev/pci/drm/i915/gt/intel_gt_engines_debugfs.c inteldrm

View File

@ -916,6 +916,23 @@ static intel_engine_mask_t init_engine_mask(struct intel_gt *gt)
info->engine_mask &= ~BIT(GSC0); info->engine_mask &= ~BIT(GSC0);
} }
/*
* Do not create the command streamer for CCS slices beyond the first.
* All the workload submitted to the first engine will be shared among
* all the slices.
*
* Once the user will be allowed to customize the CCS mode, then this
* check needs to be removed.
*/
if (IS_DG2(gt->i915)) {
u8 first_ccs = __ffs(CCS_MASK(gt));
/* Mask off all the CCS engine */
info->engine_mask &= ~GENMASK(CCS3, CCS0);
/* Put back in the first CCS engine */
info->engine_mask |= BIT(_CCS(first_ccs));
}
return info->engine_mask; return info->engine_mask;
} }

View File

@ -0,0 +1,39 @@
// SPDX-License-Identifier: MIT
/*
* Copyright © 2024 Intel Corporation
*/
#include "i915_drv.h"
#include "intel_gt.h"
#include "intel_gt_ccs_mode.h"
#include "intel_gt_regs.h"
void intel_gt_apply_ccs_mode(struct intel_gt *gt)
{
int cslice;
u32 mode = 0;
int first_ccs = __ffs(CCS_MASK(gt));
if (!IS_DG2(gt->i915))
return;
/* Build the value for the fixed CCS load balancing */
for (cslice = 0; cslice < I915_MAX_CCS; cslice++) {
if (CCS_MASK(gt) & BIT(cslice))
/*
* If available, assign the cslice
* to the first available engine...
*/
mode |= XEHP_CCS_MODE_CSLICE(cslice, first_ccs);
else
/*
* ... otherwise, mark the cslice as
* unavailable if no CCS dispatches here
*/
mode |= XEHP_CCS_MODE_CSLICE(cslice,
XEHP_CCS_MODE_CSLICE_MASK);
}
intel_uncore_write(gt->uncore, XEHP_CCS_MODE, mode);
}

View File

@ -0,0 +1,13 @@
/* SPDX-License-Identifier: MIT */
/*
* Copyright © 2024 Intel Corporation
*/
#ifndef __INTEL_GT_CCS_MODE_H__
#define __INTEL_GT_CCS_MODE_H__
struct intel_gt;
void intel_gt_apply_ccs_mode(struct intel_gt *gt);
#endif /* __INTEL_GT_CCS_MODE_H__ */

View File

@ -1468,8 +1468,14 @@
#define ECOBITS_PPGTT_CACHE4B (0 << 8) #define ECOBITS_PPGTT_CACHE4B (0 << 8)
#define GEN12_RCU_MODE _MMIO(0x14800) #define GEN12_RCU_MODE _MMIO(0x14800)
#define XEHP_RCU_MODE_FIXED_SLICE_CCS_MODE REG_BIT(1)
#define GEN12_RCU_MODE_CCS_ENABLE REG_BIT(0) #define GEN12_RCU_MODE_CCS_ENABLE REG_BIT(0)
#define XEHP_CCS_MODE _MMIO(0x14804)
#define XEHP_CCS_MODE_CSLICE_MASK REG_GENMASK(2, 0) /* CCS0-3 + rsvd */
#define XEHP_CCS_MODE_CSLICE_WIDTH ilog2(XEHP_CCS_MODE_CSLICE_MASK + 1)
#define XEHP_CCS_MODE_CSLICE(cslice, ccs) (ccs << (cslice * XEHP_CCS_MODE_CSLICE_WIDTH))
#define CHV_FUSE_GT _MMIO(VLV_GUNIT_BASE + 0x2168) #define CHV_FUSE_GT _MMIO(VLV_GUNIT_BASE + 0x2168)
#define CHV_FGT_DISABLE_SS0 (1 << 10) #define CHV_FGT_DISABLE_SS0 (1 << 10)
#define CHV_FGT_DISABLE_SS1 (1 << 11) #define CHV_FGT_DISABLE_SS1 (1 << 11)

View File

@ -10,6 +10,7 @@
#include "intel_engine_regs.h" #include "intel_engine_regs.h"
#include "intel_gpu_commands.h" #include "intel_gpu_commands.h"
#include "intel_gt.h" #include "intel_gt.h"
#include "intel_gt_ccs_mode.h"
#include "intel_gt_mcr.h" #include "intel_gt_mcr.h"
#include "intel_gt_regs.h" #include "intel_gt_regs.h"
#include "intel_ring.h" #include "intel_ring.h"
@ -50,7 +51,8 @@
* registers belonging to BCS, VCS or VECS should be implemented in * registers belonging to BCS, VCS or VECS should be implemented in
* xcs_engine_wa_init(). Workarounds for registers not belonging to a specific * xcs_engine_wa_init(). Workarounds for registers not belonging to a specific
* engine's MMIO range but that are part of of the common RCS/CCS reset domain * engine's MMIO range but that are part of of the common RCS/CCS reset domain
* should be implemented in general_render_compute_wa_init(). * should be implemented in general_render_compute_wa_init(). The settings
* about the CCS load balancing should be added in ccs_engine_wa_mode().
* *
* - GT workarounds: the list of these WAs is applied whenever these registers * - GT workarounds: the list of these WAs is applied whenever these registers
* revert to their default values: on GPU reset, suspend/resume [1]_, etc. * revert to their default values: on GPU reset, suspend/resume [1]_, etc.
@ -2823,6 +2825,28 @@ add_render_compute_tuning_settings(struct intel_gt *gt,
wa_write_clr(wal, GEN8_GARBCNTL, GEN12_BUS_HASH_CTL_BIT_EXC); wa_write_clr(wal, GEN8_GARBCNTL, GEN12_BUS_HASH_CTL_BIT_EXC);
} }
static void ccs_engine_wa_mode(struct intel_engine_cs *engine, struct i915_wa_list *wal)
{
struct intel_gt *gt = engine->gt;
if (!IS_DG2(gt->i915))
return;
/*
* Wa_14019159160: This workaround, along with others, leads to
* significant challenges in utilizing load balancing among the
* CCS slices. Consequently, an architectural decision has been
* made to completely disable automatic CCS load balancing.
*/
wa_masked_en(wal, GEN12_RCU_MODE, XEHP_RCU_MODE_FIXED_SLICE_CCS_MODE);
/*
* After having disabled automatic load balancing we need to
* assign all slices to a single CCS. We will call it CCS mode 1
*/
intel_gt_apply_ccs_mode(gt);
}
/* /*
* The workarounds in this function apply to shared registers in * The workarounds in this function apply to shared registers in
* the general render reset domain that aren't tied to a * the general render reset domain that aren't tied to a
@ -2970,8 +2994,10 @@ engine_init_workarounds(struct intel_engine_cs *engine, struct i915_wa_list *wal
* to a single RCS/CCS engine's workaround list since * to a single RCS/CCS engine's workaround list since
* they're reset as part of the general render domain reset. * they're reset as part of the general render domain reset.
*/ */
if (engine->flags & I915_ENGINE_FIRST_RENDER_COMPUTE) if (engine->flags & I915_ENGINE_FIRST_RENDER_COMPUTE) {
general_render_compute_wa_init(engine, wal); general_render_compute_wa_init(engine, wal);
ccs_engine_wa_mode(engine, wal);
}
if (engine->class == COMPUTE_CLASS) if (engine->class == COMPUTE_CLASS)
ccs_engine_wa_init(engine, wal); ccs_engine_wa_init(engine, wal);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: if_mcx.c,v 1.111 2023/11/10 15:51:20 bluhm Exp $ */ /* $OpenBSD: if_mcx.c,v 1.113 2024/04/11 06:42:12 jmatthew Exp $ */
/* /*
* Copyright (c) 2017 David Gwynne <dlg@openbsd.org> * Copyright (c) 2017 David Gwynne <dlg@openbsd.org>
@ -199,6 +199,19 @@ CTASSERT(MCX_MAX_QUEUES * MCX_WQ_DOORBELL_STRIDE <
#define MCX_ETHER_CAP_50G_CR2 30 #define MCX_ETHER_CAP_50G_CR2 30
#define MCX_ETHER_CAP_50G_KR2 31 #define MCX_ETHER_CAP_50G_KR2 31
#define MCX_ETHER_EXT_CAP_SGMII_100 0
#define MCX_ETHER_EXT_CAP_1000_X 1
#define MCX_ETHER_EXT_CAP_5G_R 3
#define MCX_ETHER_EXT_CAP_XAUI 4
#define MCX_ETHER_EXT_CAP_XLAUI 5
#define MCX_ETHER_EXT_CAP_25G_AUI1 6
#define MCX_ETHER_EXT_CAP_50G_AUI2 7
#define MCX_ETHER_EXT_CAP_50G_AUI1 8
#define MCX_ETHER_EXT_CAP_CAUI4 9
#define MCX_ETHER_EXT_CAP_100G_AUI2 10
#define MCX_ETHER_EXT_CAP_200G_AUI4 12
#define MCX_ETHER_EXT_CAP_400G_AUI8 15
#define MCX_MAX_CQE 32 #define MCX_MAX_CQE 32
#define MCX_CMD_QUERY_HCA_CAP 0x100 #define MCX_CMD_QUERY_HCA_CAP 0x100
@ -406,11 +419,14 @@ struct mcx_reg_ptys {
uint8_t rp_reserved2; uint8_t rp_reserved2;
uint8_t rp_proto_mask; uint8_t rp_proto_mask;
#define MCX_REG_PTYS_PROTO_MASK_ETH (1 << 2) #define MCX_REG_PTYS_PROTO_MASK_ETH (1 << 2)
uint8_t rp_reserved3[8]; uint8_t rp_reserved3[4];
uint32_t rp_ext_eth_proto_cap;
uint32_t rp_eth_proto_cap; uint32_t rp_eth_proto_cap;
uint8_t rp_reserved4[8]; uint8_t rp_reserved4[4];
uint32_t rp_ext_eth_proto_admin;
uint32_t rp_eth_proto_admin; uint32_t rp_eth_proto_admin;
uint8_t rp_reserved5[8]; uint8_t rp_reserved5[4];
uint32_t rp_ext_eth_proto_oper;
uint32_t rp_eth_proto_oper; uint32_t rp_eth_proto_oper;
uint8_t rp_reserved6[24]; uint8_t rp_reserved6[24];
} __packed __aligned(4); } __packed __aligned(4);
@ -2657,6 +2673,7 @@ static const struct pci_matchid mcx_devices[] = {
{ PCI_VENDOR_MELLANOX, PCI_PRODUCT_MELLANOX_MT28800 }, { PCI_VENDOR_MELLANOX, PCI_PRODUCT_MELLANOX_MT28800 },
{ PCI_VENDOR_MELLANOX, PCI_PRODUCT_MELLANOX_MT28800VF }, { PCI_VENDOR_MELLANOX, PCI_PRODUCT_MELLANOX_MT28800VF },
{ PCI_VENDOR_MELLANOX, PCI_PRODUCT_MELLANOX_MT28908 }, { PCI_VENDOR_MELLANOX, PCI_PRODUCT_MELLANOX_MT28908 },
{ PCI_VENDOR_MELLANOX, PCI_PRODUCT_MELLANOX_MT28908VF },
{ PCI_VENDOR_MELLANOX, PCI_PRODUCT_MELLANOX_MT2892 }, { PCI_VENDOR_MELLANOX, PCI_PRODUCT_MELLANOX_MT2892 },
{ PCI_VENDOR_MELLANOX, PCI_PRODUCT_MELLANOX_MT2894 }, { PCI_VENDOR_MELLANOX, PCI_PRODUCT_MELLANOX_MT2894 },
}; };
@ -2691,6 +2708,21 @@ static const struct mcx_eth_proto_capability mcx_eth_cap_map[] = {
[MCX_ETHER_CAP_50G_KR2] = { IFM_50G_KR2, IF_Gbps(50) }, [MCX_ETHER_CAP_50G_KR2] = { IFM_50G_KR2, IF_Gbps(50) },
}; };
static const struct mcx_eth_proto_capability mcx_ext_eth_cap_map[] = {
[MCX_ETHER_EXT_CAP_SGMII_100] = { IFM_100_FX, IF_Mbps(100) },
[MCX_ETHER_EXT_CAP_1000_X] = { IFM_1000_SX, IF_Gbps(1) },
[MCX_ETHER_EXT_CAP_5G_R] = { IFM_5000_T, IF_Gbps(5) },
[MCX_ETHER_EXT_CAP_XAUI] = { IFM_10G_SFI, IF_Gbps(10) },
[MCX_ETHER_EXT_CAP_XLAUI] = { IFM_40G_XLPPI, IF_Gbps(40) },
[MCX_ETHER_EXT_CAP_25G_AUI1] = { 0 /*IFM_25G_AUI*/, IF_Gbps(25) },
[MCX_ETHER_EXT_CAP_50G_AUI2] = { 0 /*IFM_50G_AUI*/, IF_Gbps(50) },
[MCX_ETHER_EXT_CAP_50G_AUI1] = { 0 /*IFM_50G_AUI*/, IF_Gbps(50) },
[MCX_ETHER_EXT_CAP_CAUI4] = { 0 /*IFM_100G_AUI*/, IF_Gbps(100) },
[MCX_ETHER_EXT_CAP_100G_AUI2] = { 0 /*IFM_100G_AUI*/, IF_Gbps(100) },
[MCX_ETHER_EXT_CAP_200G_AUI4] = { 0 /*IFM_200G_AUI*/, IF_Gbps(200) },
[MCX_ETHER_EXT_CAP_400G_AUI8] = { 0 /*IFM_400G_AUI*/, IF_Gbps(400) },
};
static int static int
mcx_get_id(uint32_t val) mcx_get_id(uint32_t val)
{ {
@ -7956,6 +7988,19 @@ mcx_media_add_types(struct mcx_softc *sc)
ifmedia_add(&sc->sc_media, IFM_ETHER | cap->cap_media, 0, NULL); ifmedia_add(&sc->sc_media, IFM_ETHER | cap->cap_media, 0, NULL);
} }
proto_cap = betoh32(ptys.rp_ext_eth_proto_cap);
for (i = 0; i < nitems(mcx_ext_eth_cap_map); i++) {
const struct mcx_eth_proto_capability *cap;
if (!ISSET(proto_cap, 1 << i))
continue;
cap = &mcx_ext_eth_cap_map[i];
if (cap->cap_media == 0)
continue;
ifmedia_add(&sc->sc_media, IFM_ETHER | cap->cap_media, 0, NULL);
}
} }
static void static void
@ -7965,6 +8010,7 @@ mcx_media_status(struct ifnet *ifp, struct ifmediareq *ifmr)
struct mcx_reg_ptys ptys; struct mcx_reg_ptys ptys;
int i; int i;
uint32_t proto_oper; uint32_t proto_oper;
uint32_t ext_proto_oper;
uint64_t media_oper; uint64_t media_oper;
memset(&ptys, 0, sizeof(ptys)); memset(&ptys, 0, sizeof(ptys));
@ -7979,6 +8025,7 @@ mcx_media_status(struct ifnet *ifp, struct ifmediareq *ifmr)
} }
proto_oper = betoh32(ptys.rp_eth_proto_oper); proto_oper = betoh32(ptys.rp_eth_proto_oper);
ext_proto_oper = betoh32(ptys.rp_ext_eth_proto_oper);
media_oper = 0; media_oper = 0;
@ -7993,8 +8040,21 @@ mcx_media_status(struct ifnet *ifp, struct ifmediareq *ifmr)
media_oper = cap->cap_media; media_oper = cap->cap_media;
} }
if (media_oper == 0) {
for (i = 0; i < nitems(mcx_ext_eth_cap_map); i++) {
const struct mcx_eth_proto_capability *cap;
if (!ISSET(ext_proto_oper, 1 << i))
continue;
cap = &mcx_ext_eth_cap_map[i];
if (cap->cap_media != 0)
media_oper = cap->cap_media;
}
}
ifmr->ifm_status = IFM_AVALID; ifmr->ifm_status = IFM_AVALID;
if (proto_oper != 0) { if ((proto_oper | ext_proto_oper) != 0) {
ifmr->ifm_status |= IFM_ACTIVE; ifmr->ifm_status |= IFM_ACTIVE;
ifmr->ifm_active = IFM_ETHER | IFM_AUTO | media_oper; ifmr->ifm_active = IFM_ETHER | IFM_AUTO | media_oper;
/* txpause, rxpause, duplex? */ /* txpause, rxpause, duplex? */
@ -8010,6 +8070,7 @@ mcx_media_change(struct ifnet *ifp)
struct mcx_reg_ptys ptys; struct mcx_reg_ptys ptys;
struct mcx_reg_paos paos; struct mcx_reg_paos paos;
uint32_t media; uint32_t media;
uint32_t ext_media;
int i, error; int i, error;
if (IFM_TYPE(sc->sc_media.ifm_media) != IFM_ETHER) if (IFM_TYPE(sc->sc_media.ifm_media) != IFM_ETHER)
@ -8032,6 +8093,7 @@ mcx_media_change(struct ifnet *ifp)
} }
media = betoh32(ptys.rp_eth_proto_cap); media = betoh32(ptys.rp_eth_proto_cap);
ext_media = betoh32(ptys.rp_ext_eth_proto_cap);
} else { } else {
/* map media type */ /* map media type */
media = 0; media = 0;
@ -8045,6 +8107,17 @@ mcx_media_change(struct ifnet *ifp)
break; break;
} }
} }
for (i = 0; i < nitems(mcx_ext_eth_cap_map); i++) {
const struct mcx_eth_proto_capability *cap;
cap = &mcx_ext_eth_cap_map[i];
if (cap->cap_media ==
IFM_SUBTYPE(sc->sc_media.ifm_media)) {
media = (1 << i);
break;
}
}
} }
/* disable the port */ /* disable the port */
@ -8063,6 +8136,7 @@ mcx_media_change(struct ifnet *ifp)
ptys.rp_local_port = 1; ptys.rp_local_port = 1;
ptys.rp_proto_mask = MCX_REG_PTYS_PROTO_MASK_ETH; ptys.rp_proto_mask = MCX_REG_PTYS_PROTO_MASK_ETH;
ptys.rp_eth_proto_admin = htobe32(media); ptys.rp_eth_proto_admin = htobe32(media);
ptys.rp_ext_eth_proto_admin = htobe32(ext_media);
if (mcx_access_hca_reg(sc, MCX_REG_PTYS, MCX_REG_OP_WRITE, &ptys, if (mcx_access_hca_reg(sc, MCX_REG_PTYS, MCX_REG_OP_WRITE, &ptys,
sizeof(ptys), MCX_CMDQ_SLOT_IOCTL) != 0) { sizeof(ptys), MCX_CMDQ_SLOT_IOCTL) != 0) {
printf("%s: unable to set port media type/speed\n", printf("%s: unable to set port media type/speed\n",
@ -8107,10 +8181,11 @@ mcx_port_change(void *xsc)
if (mcx_access_hca_reg(sc, MCX_REG_PTYS, MCX_REG_OP_READ, &ptys, if (mcx_access_hca_reg(sc, MCX_REG_PTYS, MCX_REG_OP_READ, &ptys,
sizeof(ptys), slot) == 0) { sizeof(ptys), slot) == 0) {
uint32_t proto_oper = betoh32(ptys.rp_eth_proto_oper); uint32_t proto_oper = betoh32(ptys.rp_eth_proto_oper);
uint32_t ext_proto_oper = betoh32(ptys.rp_ext_eth_proto_oper);
uint64_t baudrate = 0; uint64_t baudrate = 0;
unsigned int i; unsigned int i;
if (proto_oper != 0) if ((proto_oper | ext_proto_oper) != 0)
link_state = LINK_STATE_FULL_DUPLEX; link_state = LINK_STATE_FULL_DUPLEX;
for (i = 0; i < nitems(mcx_eth_cap_map); i++) { for (i = 0; i < nitems(mcx_eth_cap_map); i++) {
@ -8126,6 +8201,21 @@ mcx_port_change(void *xsc)
break; break;
} }
if (baudrate == 0) {
for (i = 0; i < nitems(mcx_ext_eth_cap_map); i++) {
const struct mcx_eth_proto_capability *cap;
if (!ISSET(ext_proto_oper, 1 << i))
continue;
cap = &mcx_ext_eth_cap_map[i];
if (cap->cap_baudrate == 0)
continue;
baudrate = cap->cap_baudrate;
break;
}
}
ifp->if_baudrate = baudrate; ifp->if_baudrate = baudrate;
} }

View File

@ -1,4 +1,4 @@
/* $OpenBSD: sys_socket.c,v 1.63 2024/03/31 13:50:00 mvs Exp $ */ /* $OpenBSD: sys_socket.c,v 1.64 2024/04/11 08:33:37 mvs Exp $ */
/* $NetBSD: sys_socket.c,v 1.13 1995/08/12 23:59:09 mycroft Exp $ */ /* $NetBSD: sys_socket.c,v 1.13 1995/08/12 23:59:09 mycroft Exp $ */
/* /*
@ -145,7 +145,7 @@ soo_stat(struct file *fp, struct stat *ub, struct proc *p)
memset(ub, 0, sizeof (*ub)); memset(ub, 0, sizeof (*ub));
ub->st_mode = S_IFSOCK; ub->st_mode = S_IFSOCK;
solock(so); solock_shared(so);
mtx_enter(&so->so_rcv.sb_mtx); mtx_enter(&so->so_rcv.sb_mtx);
if ((so->so_rcv.sb_state & SS_CANTRCVMORE) == 0 || if ((so->so_rcv.sb_state & SS_CANTRCVMORE) == 0 ||
so->so_rcv.sb_cc != 0) so->so_rcv.sb_cc != 0)
@ -156,7 +156,7 @@ soo_stat(struct file *fp, struct stat *ub, struct proc *p)
ub->st_uid = so->so_euid; ub->st_uid = so->so_euid;
ub->st_gid = so->so_egid; ub->st_gid = so->so_egid;
(void)pru_sense(so, ub); (void)pru_sense(so, ub);
sounlock(so); sounlock_shared(so);
return (0); return (0);
} }

View File

@ -1,4 +1,4 @@
/* $OpenBSD: uipc_socket.c,v 1.328 2024/04/10 12:04:41 mvs Exp $ */ /* $OpenBSD: uipc_socket.c,v 1.329 2024/04/11 13:32:51 mvs Exp $ */
/* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */ /* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */
/* /*
@ -66,6 +66,7 @@ void soreaper(void *);
void soput(void *); void soput(void *);
int somove(struct socket *, int); int somove(struct socket *, int);
void sorflush(struct socket *); void sorflush(struct socket *);
void sorflush_locked(struct socket *);
void filt_sordetach(struct knote *kn); void filt_sordetach(struct knote *kn);
int filt_soread(struct knote *kn, long hint); int filt_soread(struct knote *kn, long hint);
@ -143,6 +144,8 @@ soalloc(const struct protosw *prp, int wait)
return (NULL); return (NULL);
rw_init_flags(&so->so_lock, dp->dom_name, RWL_DUPOK); rw_init_flags(&so->so_lock, dp->dom_name, RWL_DUPOK);
refcnt_init(&so->so_refcnt); refcnt_init(&so->so_refcnt);
rw_init(&so->so_rcv.sb_lock, "sbufrcv");
rw_init(&so->so_snd.sb_lock, "sbufsnd");
mtx_init(&so->so_rcv.sb_mtx, IPL_MPFLOOR); mtx_init(&so->so_rcv.sb_mtx, IPL_MPFLOOR);
mtx_init(&so->so_snd.sb_mtx, IPL_MPFLOOR); mtx_init(&so->so_snd.sb_mtx, IPL_MPFLOOR);
klist_init_mutex(&so->so_rcv.sb_klist, &so->so_rcv.sb_mtx); klist_init_mutex(&so->so_rcv.sb_klist, &so->so_rcv.sb_mtx);
@ -156,15 +159,15 @@ soalloc(const struct protosw *prp, int wait)
case AF_INET6: case AF_INET6:
switch (prp->pr_type) { switch (prp->pr_type) {
case SOCK_DGRAM: case SOCK_DGRAM:
so->so_rcv.sb_flags |= SB_OWNLOCK;
/* FALLTHROUGH */
case SOCK_RAW:
so->so_rcv.sb_flags |= SB_MTXLOCK; so->so_rcv.sb_flags |= SB_MTXLOCK;
break; break;
case SOCK_RAW:
so->so_rcv.sb_flags |= SB_MTXLOCK | SB_OWNLOCK;
break;
} }
break; break;
case AF_UNIX: case AF_UNIX:
so->so_rcv.sb_flags |= SB_MTXLOCK | SB_OWNLOCK; so->so_rcv.sb_flags |= SB_MTXLOCK;
break; break;
} }
@ -346,9 +349,22 @@ sofree(struct socket *so, int keep_lock)
} }
#endif /* SOCKET_SPLICE */ #endif /* SOCKET_SPLICE */
sbrelease(so, &so->so_snd); sbrelease(so, &so->so_snd);
sorflush(so);
if (!keep_lock) /*
* Regardless on '_locked' postfix, must release solock() before
* call sorflush_locked() for SB_OWNLOCK marked socket. Can't
* release solock() and call sorflush() because solock() release
* is unwanted for tcp(4) socket.
*/
if (so->so_rcv.sb_flags & SB_OWNLOCK)
sounlock(so); sounlock(so);
sorflush_locked(so);
if (!((so->so_rcv.sb_flags & SB_OWNLOCK) || keep_lock))
sounlock(so);
#ifdef SOCKET_SPLICE #ifdef SOCKET_SPLICE
if (so->so_sp) { if (so->so_sp) {
/* Reuse splice idle, sounsplice() has been called before. */ /* Reuse splice idle, sounsplice() has been called before. */
@ -807,6 +823,7 @@ soreceive(struct socket *so, struct mbuf **paddr, struct uio *uio,
const struct protosw *pr = so->so_proto; const struct protosw *pr = so->so_proto;
struct mbuf *nextrecord; struct mbuf *nextrecord;
size_t resid, orig_resid = uio->uio_resid; size_t resid, orig_resid = uio->uio_resid;
int dosolock = ((so->so_rcv.sb_flags & SB_OWNLOCK) == 0);
mp = mp0; mp = mp0;
if (paddr) if (paddr)
@ -836,12 +853,11 @@ bad:
if (mp) if (mp)
*mp = NULL; *mp = NULL;
if (dosolock)
solock_shared(so); solock_shared(so);
restart: restart:
if ((error = sblock(so, &so->so_rcv, SBLOCKWAIT(flags))) != 0) { if ((error = sblock(so, &so->so_rcv, SBLOCKWAIT(flags))) != 0)
sounlock_shared(so); goto out;
return (error);
}
sb_mtx_lock(&so->so_rcv); sb_mtx_lock(&so->so_rcv);
m = so->so_rcv.sb_mb; m = so->so_rcv.sb_mb;
@ -906,13 +922,15 @@ restart:
SBLASTRECORDCHK(&so->so_rcv, "soreceive sbwait 1"); SBLASTRECORDCHK(&so->so_rcv, "soreceive sbwait 1");
SBLASTMBUFCHK(&so->so_rcv, "soreceive sbwait 1"); SBLASTMBUFCHK(&so->so_rcv, "soreceive sbwait 1");
if (so->so_rcv.sb_flags & SB_OWNLOCK) { if (so->so_rcv.sb_flags & (SB_MTXLOCK | SB_OWNLOCK)) {
sbunlock_locked(so, &so->so_rcv); sbunlock_locked(so, &so->so_rcv);
if (dosolock)
sounlock_shared(so); sounlock_shared(so);
error = sbwait_locked(so, &so->so_rcv); error = sbwait_locked(so, &so->so_rcv);
sb_mtx_unlock(&so->so_rcv); sb_mtx_unlock(&so->so_rcv);
if (error) if (error)
return (error); return (error);
if (dosolock)
solock_shared(so); solock_shared(so);
} else { } else {
sb_mtx_unlock(&so->so_rcv); sb_mtx_unlock(&so->so_rcv);
@ -990,10 +1008,12 @@ dontblock:
if (controlp) { if (controlp) {
if (pr->pr_domain->dom_externalize) { if (pr->pr_domain->dom_externalize) {
sb_mtx_unlock(&so->so_rcv); sb_mtx_unlock(&so->so_rcv);
if (dosolock)
sounlock_shared(so); sounlock_shared(so);
error = error =
(*pr->pr_domain->dom_externalize) (*pr->pr_domain->dom_externalize)
(cm, controllen, flags); (cm, controllen, flags);
if (dosolock)
solock_shared(so); solock_shared(so);
sb_mtx_lock(&so->so_rcv); sb_mtx_lock(&so->so_rcv);
} }
@ -1073,8 +1093,10 @@ dontblock:
SBLASTMBUFCHK(&so->so_rcv, "soreceive uiomove"); SBLASTMBUFCHK(&so->so_rcv, "soreceive uiomove");
resid = uio->uio_resid; resid = uio->uio_resid;
sb_mtx_unlock(&so->so_rcv); sb_mtx_unlock(&so->so_rcv);
if (dosolock)
sounlock_shared(so); sounlock_shared(so);
uio_error = uiomove(mtod(m, caddr_t) + moff, len, uio); uio_error = uiomove(mtod(m, caddr_t) + moff, len, uio);
if (dosolock)
solock_shared(so); solock_shared(so);
sb_mtx_lock(&so->so_rcv); sb_mtx_lock(&so->so_rcv);
if (uio_error) if (uio_error)
@ -1158,6 +1180,7 @@ dontblock:
break; break;
SBLASTRECORDCHK(&so->so_rcv, "soreceive sbwait 2"); SBLASTRECORDCHK(&so->so_rcv, "soreceive sbwait 2");
SBLASTMBUFCHK(&so->so_rcv, "soreceive sbwait 2"); SBLASTMBUFCHK(&so->so_rcv, "soreceive sbwait 2");
if (dosolock) {
sb_mtx_unlock(&so->so_rcv); sb_mtx_unlock(&so->so_rcv);
error = sbwait(so, &so->so_rcv); error = sbwait(so, &so->so_rcv);
if (error) { if (error) {
@ -1166,6 +1189,13 @@ dontblock:
return (0); return (0);
} }
sb_mtx_lock(&so->so_rcv); sb_mtx_lock(&so->so_rcv);
} else {
if (sbwait_locked(so, &so->so_rcv)) {
sb_mtx_unlock(&so->so_rcv);
sbunlock(so, &so->so_rcv);
return (0);
}
}
if ((m = so->so_rcv.sb_mb) != NULL) if ((m = so->so_rcv.sb_mb) != NULL)
nextrecord = m->m_nextpkt; nextrecord = m->m_nextpkt;
} }
@ -1214,6 +1244,8 @@ dontblock:
release: release:
sb_mtx_unlock(&so->so_rcv); sb_mtx_unlock(&so->so_rcv);
sbunlock(so, &so->so_rcv); sbunlock(so, &so->so_rcv);
out:
if (dosolock)
sounlock_shared(so); sounlock_shared(so);
return (error); return (error);
} }
@ -1223,7 +1255,6 @@ soshutdown(struct socket *so, int how)
{ {
int error = 0; int error = 0;
solock(so);
switch (how) { switch (how) {
case SHUT_RD: case SHUT_RD:
sorflush(so); sorflush(so);
@ -1232,25 +1263,29 @@ soshutdown(struct socket *so, int how)
sorflush(so); sorflush(so);
/* FALLTHROUGH */ /* FALLTHROUGH */
case SHUT_WR: case SHUT_WR:
solock(so);
error = pru_shutdown(so); error = pru_shutdown(so);
sounlock(so);
break; break;
default: default:
error = EINVAL; error = EINVAL;
break; break;
} }
sounlock(so);
return (error); return (error);
} }
void void
sorflush(struct socket *so) sorflush_locked(struct socket *so)
{ {
struct sockbuf *sb = &so->so_rcv; struct sockbuf *sb = &so->so_rcv;
struct mbuf *m; struct mbuf *m;
const struct protosw *pr = so->so_proto; const struct protosw *pr = so->so_proto;
int error; int error;
if ((sb->sb_flags & SB_OWNLOCK) == 0)
soassertlocked(so);
error = sblock(so, sb, SBL_WAIT | SBL_NOINTR); error = sblock(so, sb, SBL_WAIT | SBL_NOINTR);
/* with SBL_WAIT and SLB_NOINTR sblock() must not fail */ /* with SBL_WAIT and SLB_NOINTR sblock() must not fail */
KASSERT(error == 0); KASSERT(error == 0);
@ -1267,6 +1302,16 @@ sorflush(struct socket *so)
m_purge(m); m_purge(m);
} }
void
sorflush(struct socket *so)
{
if ((so->so_rcv.sb_flags & SB_OWNLOCK) == 0)
solock_shared(so);
sorflush_locked(so);
if ((so->so_rcv.sb_flags & SB_OWNLOCK) == 0)
sounlock_shared(so);
}
#ifdef SOCKET_SPLICE #ifdef SOCKET_SPLICE
#define so_splicelen so_sp->ssp_len #define so_splicelen so_sp->ssp_len
@ -1905,6 +1950,7 @@ sosetopt(struct socket *so, int level, int optname, struct mbuf *m)
if ((long)cnt <= 0) if ((long)cnt <= 0)
cnt = 1; cnt = 1;
if (((sb->sb_flags & SB_OWNLOCK) == 0))
solock(so); solock(so);
mtx_enter(&sb->sb_mtx); mtx_enter(&sb->sb_mtx);
@ -1931,6 +1977,7 @@ sosetopt(struct socket *so, int level, int optname, struct mbuf *m)
} }
mtx_leave(&sb->sb_mtx); mtx_leave(&sb->sb_mtx);
if (((sb->sb_flags & SB_OWNLOCK) == 0))
sounlock(so); sounlock(so);
break; break;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: uipc_socket2.c,v 1.148 2024/04/10 12:04:41 mvs Exp $ */ /* $OpenBSD: uipc_socket2.c,v 1.149 2024/04/11 13:32:51 mvs Exp $ */
/* $NetBSD: uipc_socket2.c,v 1.11 1996/02/04 02:17:55 christos Exp $ */ /* $NetBSD: uipc_socket2.c,v 1.11 1996/02/04 02:17:55 christos Exp $ */
/* /*
@ -322,7 +322,9 @@ socantsendmore(struct socket *so)
void void
socantrcvmore(struct socket *so) socantrcvmore(struct socket *so)
{ {
if ((so->so_rcv.sb_flags & SB_OWNLOCK) == 0)
soassertlocked(so); soassertlocked(so);
mtx_enter(&so->so_rcv.sb_mtx); mtx_enter(&so->so_rcv.sb_mtx);
so->so_rcv.sb_state |= SS_CANTRCVMORE; so->so_rcv.sb_state |= SS_CANTRCVMORE;
mtx_leave(&so->so_rcv.sb_mtx); mtx_leave(&so->so_rcv.sb_mtx);
@ -529,6 +531,17 @@ sblock(struct socket *so, struct sockbuf *sb, int flags)
{ {
int error = 0, prio = PSOCK; int error = 0, prio = PSOCK;
if (sb->sb_flags & SB_OWNLOCK) {
int rwflags = RW_WRITE;
if (!(flags & SBL_NOINTR || sb->sb_flags & SB_NOINTR))
rwflags |= RW_INTR;
if (!(flags & SBL_WAIT))
rwflags |= RW_NOSLEEP;
return rw_enter(&sb->sb_lock, rwflags);
}
soassertlocked(so); soassertlocked(so);
mtx_enter(&sb->sb_mtx); mtx_enter(&sb->sb_mtx);
@ -561,6 +574,11 @@ out:
void void
sbunlock_locked(struct socket *so, struct sockbuf *sb) sbunlock_locked(struct socket *so, struct sockbuf *sb)
{ {
if (sb->sb_flags & SB_OWNLOCK) {
rw_exit(&sb->sb_lock);
return;
}
MUTEX_ASSERT_LOCKED(&sb->sb_mtx); MUTEX_ASSERT_LOCKED(&sb->sb_mtx);
sb->sb_flags &= ~SB_LOCK; sb->sb_flags &= ~SB_LOCK;
@ -573,6 +591,11 @@ sbunlock_locked(struct socket *so, struct sockbuf *sb)
void void
sbunlock(struct socket *so, struct sockbuf *sb) sbunlock(struct socket *so, struct sockbuf *sb)
{ {
if (sb->sb_flags & SB_OWNLOCK) {
rw_exit(&sb->sb_lock);
return;
}
mtx_enter(&sb->sb_mtx); mtx_enter(&sb->sb_mtx);
sbunlock_locked(so, sb); sbunlock_locked(so, sb);
mtx_leave(&sb->sb_mtx); mtx_leave(&sb->sb_mtx);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: if.h,v 1.215 2023/11/11 14:24:03 bluhm Exp $ */ /* $OpenBSD: if.h,v 1.216 2024/04/11 15:08:18 bluhm Exp $ */
/* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */ /* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */
/* /*
@ -219,7 +219,7 @@ struct if_status_description {
/* flags set internally only: */ /* flags set internally only: */
#define IFF_CANTCHANGE \ #define IFF_CANTCHANGE \
(IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|\ (IFF_BROADCAST|IFF_LOOPBACK|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|\
IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI) IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI)
#define IFXF_MPSAFE 0x1 /* [I] if_start is mpsafe */ #define IFXF_MPSAFE 0x1 /* [I] if_start is mpsafe */

View File

@ -1,4 +1,4 @@
/* $OpenBSD: socketvar.h,v 1.128 2024/04/10 12:04:41 mvs Exp $ */ /* $OpenBSD: socketvar.h,v 1.129 2024/04/11 13:32:51 mvs Exp $ */
/* $NetBSD: socketvar.h,v 1.18 1996/02/09 18:25:38 christos Exp $ */ /* $NetBSD: socketvar.h,v 1.18 1996/02/09 18:25:38 christos Exp $ */
/*- /*-
@ -105,6 +105,7 @@ struct socket {
* Variables for socket buffering. * Variables for socket buffering.
*/ */
struct sockbuf { struct sockbuf {
struct rwlock sb_lock;
struct mutex sb_mtx; struct mutex sb_mtx;
/* The following fields are all zeroed on flush. */ /* The following fields are all zeroed on flush. */
#define sb_startzero sb_cc #define sb_startzero sb_cc
@ -134,7 +135,7 @@ struct socket {
#define SB_SPLICE 0x0020 /* buffer is splice source or drain */ #define SB_SPLICE 0x0020 /* buffer is splice source or drain */
#define SB_NOINTR 0x0040 /* operations not interruptible */ #define SB_NOINTR 0x0040 /* operations not interruptible */
#define SB_MTXLOCK 0x0080 /* use sb_mtx for sockbuf protection */ #define SB_MTXLOCK 0x0080 /* use sb_mtx for sockbuf protection */
#define SB_OWNLOCK 0x0100 /* sb_mtx used standalone */ #define SB_OWNLOCK 0x0100 /* sblock() doesn't need solock() */
void (*so_upcall)(struct socket *so, caddr_t arg, int waitf); void (*so_upcall)(struct socket *so, caddr_t arg, int waitf);
caddr_t so_upcallarg; /* Arg for above */ caddr_t so_upcallarg; /* Arg for above */

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ffs_extern.h,v 1.46 2024/02/03 18:51:58 beck Exp $ */ /* $OpenBSD: ffs_extern.h,v 1.47 2024/04/11 16:31:30 otto Exp $ */
/* $NetBSD: ffs_extern.h,v 1.4 1996/02/09 22:22:22 christos Exp $ */ /* $NetBSD: ffs_extern.h,v 1.4 1996/02/09 22:22:22 christos Exp $ */
/* /*
@ -58,6 +58,7 @@
{ 0, 0 }, \ { 0, 0 }, \
{ 0, 0 }, \ { 0, 0 }, \
{ 0, 0 }, \ { 0, 0 }, \
{ 0, 0 }, \
{ "sd_tickdelay", CTLTYPE_INT }, \ { "sd_tickdelay", CTLTYPE_INT }, \
{ "sd_worklist_push", CTLTYPE_INT }, \ { "sd_worklist_push", CTLTYPE_INT }, \
{ "sd_blk_limit_push", CTLTYPE_INT }, \ { "sd_blk_limit_push", CTLTYPE_INT }, \

View File

@ -1,4 +1,4 @@
/* $OpenBSD: parse.y,v 1.460 2024/04/09 12:40:01 claudio Exp $ */ /* $OpenBSD: parse.y,v 1.461 2024/04/11 18:07:55 tb Exp $ */
/* /*
* Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org> * Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -272,7 +272,7 @@ typedef struct {
%token <v.number> NUMBER %token <v.number> NUMBER
%type <v.number> asnumber as4number as4number_any optnumber %type <v.number> asnumber as4number as4number_any optnumber
%type <v.number> espah af safi restart origincode nettype %type <v.number> espah af safi restart origincode nettype
%type <v.number> yesno inout restricted expires enforce %type <v.number> yesno inout restricted expires
%type <v.number> yesnoenforce enforce %type <v.number> yesnoenforce enforce
%type <v.number> validity aspa_validity %type <v.number> validity aspa_validity
%type <v.number> addpathextra addpathmax %type <v.number> addpathextra addpathmax

View File

@ -1,4 +1,4 @@
/* $OpenBSD: session.c,v 1.469 2024/04/10 09:05:32 claudio Exp $ */ /* $OpenBSD: session.c,v 1.470 2024/04/11 08:33:15 claudio Exp $ */
/* /*
* Copyright (c) 2003, 2004, 2005 Henning Brauer <henning@openbsd.org> * Copyright (c) 2003, 2004, 2005 Henning Brauer <henning@openbsd.org>
@ -1257,10 +1257,10 @@ get_alternate_addr(struct bgpd_addr *local, struct bgpd_addr *remote,
continue; continue;
if (sa_equal(local, match->ifa_addr)) { if (sa_equal(local, match->ifa_addr)) {
if (match->ifa_flags & IFF_POINTOPOINT && if (match->ifa_flags & IFF_POINTOPOINT &&
match->ifa_dstaddr) { match->ifa_dstaddr != NULL) {
if (sa_equal(remote, match->ifa_dstaddr)) if (sa_equal(remote, match->ifa_dstaddr))
connected = 1; connected = 1;
} else if (match->ifa_netmask) { } else if (match->ifa_netmask != NULL) {
plen = mask2prefixlen( plen = mask2prefixlen(
match->ifa_addr->sa_family, match->ifa_addr->sa_family,
match->ifa_netmask); match->ifa_netmask);