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?

diff --git a/sys/dev/pv/virtio.c b/sys/dev/pv/virtio.c
index d085376d054..fe0ac053c88 100644
--- a/sys/dev/pv/virtio.c
+++ b/sys/dev/pv/virtio.c
@@ -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 9e3e9c9a27b..f1c6d8cde1b 100644
--- a/sys/dev/pv/virtiovar.h
+++ b/sys/dev/pv/virtiovar.h
@@ -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;

Reply via email to