From: "Gerd Hoffmann" <kraxel@redhat.com>
To: devel@edk2.groups.io
Cc: Jiewen Yao <jiewen.yao@intel.com>,
Gerd Hoffmann <kraxel@redhat.com>,
Ard Biesheuvel <ardb+tianocore@kernel.org>,
Jordan Justen <jordan.l.justen@intel.com>,
Philippe Mathieu-Daude <philmd@redhat.com>
Subject: [PATCH v5 6/7] OvmfPkg/VirtioMmioDeviceLib: virtio 1.0: Adapt feature bit handling
Date: Fri, 27 Aug 2021 15:44:58 +0200 [thread overview]
Message-ID: <20210827134459.635098-7-kraxel@redhat.com> (raw)
In-Reply-To: <20210827134459.635098-1-kraxel@redhat.com>
virtio 1.0 has 64 feature bits instead of 32.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
---
.../VirtioMmioDeviceFunctions.c | 28 +++++++++++++++----
1 file changed, 23 insertions(+), 5 deletions(-)
diff --git a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c
index 436da2a2b497..b43850e69da9 100644
--- a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c
+++ b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceFunctions.c
@@ -20,6 +20,7 @@ VirtioMmioGetDeviceFeatures (
)
{
VIRTIO_MMIO_DEVICE *Device;
+ UINT32 LowBits, HighBits;
if (DeviceFeatures == NULL) {
return EFI_INVALID_PARAMETER;
@@ -27,7 +28,15 @@ VirtioMmioGetDeviceFeatures (
Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This);
- *DeviceFeatures = VIRTIO_CFG_READ (Device, VIRTIO_MMIO_OFFSET_HOST_FEATURES);
+ if (Device->Version == VIRTIO_MMIO_DEVICE_VERSION_0_95) {
+ *DeviceFeatures = VIRTIO_CFG_READ (Device, VIRTIO_MMIO_OFFSET_HOST_FEATURES);
+ } else {
+ VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_HOST_FEATURES_SEL, 0);
+ LowBits = VIRTIO_CFG_READ (Device, VIRTIO_MMIO_OFFSET_HOST_FEATURES);
+ VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_HOST_FEATURES_SEL, 1);
+ HighBits = VIRTIO_CFG_READ (Device, VIRTIO_MMIO_OFFSET_HOST_FEATURES);
+ *DeviceFeatures = LShiftU64(HighBits, 32) | LowBits;
+ }
return EFI_SUCCESS;
}
@@ -238,11 +247,20 @@ VirtioMmioSetGuestFeatures (
Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This);
- if (Features > MAX_UINT32) {
- return EFI_UNSUPPORTED;
+ if (Device->Version == VIRTIO_MMIO_DEVICE_VERSION_0_95) {
+ if (Features > MAX_UINT32) {
+ return EFI_UNSUPPORTED;
+ }
+ VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_GUEST_FEATURES,
+ (UINT32)Features);
+ } else {
+ VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_GUEST_FEATURES_SEL, 0);
+ VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_GUEST_FEATURES,
+ (UINT32)Features);
+ VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_GUEST_FEATURES_SEL, 1);
+ VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_GUEST_FEATURES,
+ (UINT32)RShiftU64(Features, 32));
}
- VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_GUEST_FEATURES,
- (UINT32)Features);
return EFI_SUCCESS;
}
--
2.31.1
next prev parent reply other threads:[~2021-08-27 13:45 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-27 13:44 [PATCH v5 0/7] add support for virtio-mmio 1.0 Gerd Hoffmann
2021-08-27 13:44 ` [PATCH v5 1/7] OvmfPkg/Virtio10: Add virtio-mmio 1.0 defines Gerd Hoffmann
2021-08-27 13:44 ` [PATCH v5 2/7] OvmfPkg/VirtioMmioDeviceLib: Add virtio 1.0 detection Gerd Hoffmann
2021-08-27 13:44 ` [PATCH v5 3/7] OvmfPkg/VirtioMmioDeviceLib: virtio 1.0: Fix SetPageSize Gerd Hoffmann
2021-08-27 13:44 ` [PATCH v5 4/7] OvmfPkg/VirtioMmioDeviceLib: virtio 1.0: Fix SetQueueAddress Gerd Hoffmann
2021-08-27 13:44 ` [PATCH v5 5/7] OvmfPkg/VirtioMmioDeviceLib: virtio 1.0: Add default QueueNum Gerd Hoffmann
2021-08-27 13:44 ` Gerd Hoffmann [this message]
2021-08-27 13:44 ` [PATCH v5 7/7] OvmfPkg/VirtioMmioDeviceLib: enable virtio 1.0 Gerd Hoffmann
2021-08-28 1:49 ` [PATCH v5 0/7] add support for virtio-mmio 1.0 Yao, Jiewen
2021-08-30 1:20 ` Yao, Jiewen
2021-08-30 1:21 ` Yao, Jiewen
2021-08-30 3:17 ` 回复: [edk2-devel] " gaoliming
2021-08-30 7:54 ` Gerd Hoffmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210827134459.635098-7-kraxel@redhat.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox