diff options
author | Stefan Fritsch <sf@cvs.openbsd.org> | 2023-12-02 10:01:36 +0000 |
---|---|---|
committer | Stefan Fritsch <sf@cvs.openbsd.org> | 2023-12-02 10:01:36 +0000 |
commit | 087a7cc6507f1f60f137bd40e57858cdc3d519d0 (patch) | |
tree | 8a8296bf9a4782736fd2317a0482e411c57b5d04 /sys | |
parent | ed37cc8866546cdb562a36b4b9472666a1cd9980 (diff) |
virtio: Fix handling of feature bits >= 32
Fix handling of feature bits >= 32. This does not yet affect any driver
as no high feature bit besides VERSION_1 is used, and that one has
special handling.
Also, with VIRTIO_DEBUG, simply walk through all transport and device
feature names, so that we don't need to adjust the if clause whenever
the standard introduces new transport features.
ok jan@ bluhm@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/pv/virtio.c | 14 | ||||
-rw-r--r-- | sys/dev/pv/virtiovar.h | 6 |
2 files changed, 12 insertions, 8 deletions
diff --git a/sys/dev/pv/virtio.c b/sys/dev/pv/virtio.c index e9be61c0bbe..53e27e27211 100644 --- a/sys/dev/pv/virtio.c +++ b/sys/dev/pv/virtio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: virtio.c,v 1.23 2023/07/07 10:23:39 patrick Exp $ */ +/* $OpenBSD: virtio.c,v 1.24 2023/12/02 10:01:35 sf Exp $ */ /* $NetBSD: virtio.c,v 1.3 2011/11/02 23:05:52 njoly Exp $ */ /* @@ -97,7 +97,7 @@ virtio_log_features(uint64_t host, uint64_t neg, const struct virtio_feature_name *namep; int i; char c; - uint32_t bit; + uint64_t bit; for (i = 0; i < 64; i++) { if (i == 30) { @@ -107,13 +107,17 @@ virtio_log_features(uint64_t host, uint64_t neg, */ continue; } - bit = 1 << i; + bit = 1ULL << i; if ((host&bit) == 0) continue; - namep = (i < 24 || i > 37) ? guest_feature_names : - transport_feature_names; + namep = guest_feature_names; while (namep->bit && namep->bit != bit) namep++; + if (namep->name == NULL) { + namep = transport_feature_names; + while (namep->bit && namep->bit != bit) + namep++; + } c = (neg&bit) ? '+' : '-'; if (namep->name) printf(" %c%s", c, namep->name); diff --git a/sys/dev/pv/virtiovar.h b/sys/dev/pv/virtiovar.h index 7f2aea701cd..d12cb2c59b8 100644 --- a/sys/dev/pv/virtiovar.h +++ b/sys/dev/pv/virtiovar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: virtiovar.h,v 1.15 2023/07/07 10:23:39 patrick Exp $ */ +/* $OpenBSD: virtiovar.h,v 1.16 2023/12/02 10:01:35 sf Exp $ */ /* $NetBSD: virtiovar.h,v 1.1 2011/10/30 12:12:21 hannken Exp $ */ /* @@ -138,7 +138,7 @@ struct virtqueue { }; struct virtio_feature_name { - uint32_t bit; + uint64_t bit; const char *name; }; @@ -203,7 +203,7 @@ struct virtio_softc { #define virtio_device_reset(sc) virtio_set_status((sc), 0) static inline int -virtio_has_feature(struct virtio_softc *sc, unsigned int fbit) +virtio_has_feature(struct virtio_softc *sc, uint64_t fbit) { if (sc->sc_active_features & fbit) return 1; |