Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 8 Jun 2020 21:49:42 +0000 (UTC)
From:      Jessica Clarke <jrtc27@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r361943 - head/sys/dev/virtio/mmio
Message-ID:  <202006082149.058LngRR001219@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jrtc27
Date: Mon Jun  8 21:49:42 2020
New Revision: 361943
URL: https://svnweb.freebsd.org/changeset/base/361943

Log:
  virtio_mmio: Negotiate the upper half of the feature bits too
  
  The feature bits are exposed as a 32-bit register with 2 banks, so we
  should negotiate both halves. Notably, VIRTIO_F_VERSION_1 is in the
  upper half, and will be used in an upcoming commit.
  
  The PCI bus driver also has this bug, but the legacy BAR layout did not
  include selector registers and is rather different from the modern
  layout, so it remains solely as legacy.
  
  Reviewed by:	br, brooks (mentor), jhb (mentor)
  Approved by:	br, brooks (mentor), jhb (mentor)
  Differential Revision:	https://reviews.freebsd.org/D25131

Modified:
  head/sys/dev/virtio/mmio/virtio_mmio.c

Modified: head/sys/dev/virtio/mmio/virtio_mmio.c
==============================================================================
--- head/sys/dev/virtio/mmio/virtio_mmio.c	Mon Jun  8 21:38:52 2020	(r361942)
+++ head/sys/dev/virtio/mmio/virtio_mmio.c	Mon Jun  8 21:49:42 2020	(r361943)
@@ -390,7 +390,13 @@ vtmmio_negotiate_features(device_t dev, uint64_t child
 
 	sc = device_get_softc(dev);
 
+	vtmmio_write_config_4(sc, VIRTIO_MMIO_HOST_FEATURES_SEL, 1);
 	host_features = vtmmio_read_config_4(sc, VIRTIO_MMIO_HOST_FEATURES);
+	host_features <<= 32;
+
+	vtmmio_write_config_4(sc, VIRTIO_MMIO_HOST_FEATURES_SEL, 0);
+	host_features |= vtmmio_read_config_4(sc, VIRTIO_MMIO_HOST_FEATURES);
+
 	vtmmio_describe_features(sc, "host", host_features);
 
 	/*
@@ -402,6 +408,11 @@ vtmmio_negotiate_features(device_t dev, uint64_t child
 	sc->vtmmio_features = features;
 
 	vtmmio_describe_features(sc, "negotiated", features);
+
+	vtmmio_write_config_4(sc, VIRTIO_MMIO_HOST_FEATURES_SEL, 1);
+	vtmmio_write_config_4(sc, VIRTIO_MMIO_GUEST_FEATURES, features >> 32);
+
+	vtmmio_write_config_4(sc, VIRTIO_MMIO_HOST_FEATURES_SEL, 0);
 	vtmmio_write_config_4(sc, VIRTIO_MMIO_GUEST_FEATURES, features);
 
 	return (features);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202006082149.058LngRR001219>