From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.groups.io with SMTP id smtpd.web12.8208.1630071919301113731 for ; Fri, 27 Aug 2021 06:45:19 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Fd4NQ6Tw; spf=pass (domain: redhat.com, ip: 216.205.24.124, mailfrom: kraxel@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630071917; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+0XuMjzH6GCvSlnXzRIFJQukNzjqVx5RN4OQQNybS+U=; b=Fd4NQ6TwYs48R3TzAaHvD+U+A+dHpCWP9OrMAQCSBEhjoLT52BGPYfwz7lbIu6elhBwjRf QNBD3eJChc3hdu+2+ujX2izSzN6DN+kew3a98OgVQBnHErM83lHYxPQ85bgbJVXn13bpPc l3Pe2Ovt63vMlIjOoJotDeTj+yFL0m4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-293-DssDQTp5NJyIILMt_wd3JQ-1; Fri, 27 Aug 2021 09:45:16 -0400 X-MC-Unique: DssDQTp5NJyIILMt_wd3JQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D1DB9C7405; Fri, 27 Aug 2021 13:45:14 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.91]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9E52C19C46; Fri, 27 Aug 2021 13:45:10 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id C7E47180079C; Fri, 27 Aug 2021 15:44:59 +0200 (CEST) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Jiewen Yao , Gerd Hoffmann , Ard Biesheuvel , Jordan Justen , Philippe Mathieu-Daude Subject: [PATCH v5 2/7] OvmfPkg/VirtioMmioDeviceLib: Add virtio 1.0 detection. Date: Fri, 27 Aug 2021 15:44:54 +0200 Message-Id: <20210827134459.635098-3-kraxel@redhat.com> In-Reply-To: <20210827134459.635098-1-kraxel@redhat.com> References: <20210827134459.635098-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Add #defines for the Version field. Read and store the version, log the version found as info message. Continue to return UNSUPPORTED for now, we need some more patches to complete virtio 1.0 support first. Signed-off-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daude --- .../VirtioMmioDeviceLib/VirtioMmioDevice.h | 4 ++++ .../VirtioMmioDeviceLib/VirtioMmioDevice.c | 17 +++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h index ab53b90d51c9..0c2f99633c46 100644 --- a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h +++ b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h @@ -23,9 +23,13 @@ #include #define VIRTIO_MMIO_DEVICE_SIGNATURE SIGNATURE_32 ('V', 'M', 'I', 'O') +#define VIRTIO_MMIO_DEVICE_VERSION_0_95 1 +#define VIRTIO_MMIO_DEVICE_VERSION_1_00 2 + typedef struct { UINT32 Signature; + UINT32 Version; VIRTIO_DEVICE_PROTOCOL VirtioDevice; PHYSICAL_ADDRESS BaseAddress; } VIRTIO_MMIO_DEVICE; diff --git a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.c b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.c index 6dbbba008c75..0c92f5373151 100644 --- a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.c +++ b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.c @@ -58,7 +58,6 @@ VirtioMmioInit ( ) { UINT32 MagicValue; - UINT32 Version; // // Initialize VirtIo Mmio Device @@ -66,7 +65,6 @@ VirtioMmioInit ( CopyMem (&Device->VirtioDevice, &mMmioDeviceProtocolTemplate, sizeof (VIRTIO_DEVICE_PROTOCOL)); Device->BaseAddress = BaseAddress; - Device->VirtioDevice.Revision = VIRTIO_SPEC_REVISION (0, 9, 5); Device->VirtioDevice.SubSystemDeviceId = MmioRead32 (BaseAddress + VIRTIO_MMIO_OFFSET_DEVICE_ID); @@ -78,8 +76,19 @@ VirtioMmioInit ( return EFI_UNSUPPORTED; } - Version = VIRTIO_CFG_READ (Device, VIRTIO_MMIO_OFFSET_VERSION); - if (Version != 1) { + Device->Version = VIRTIO_CFG_READ (Device, VIRTIO_MMIO_OFFSET_VERSION); + switch (Device->Version) { + case VIRTIO_MMIO_DEVICE_VERSION_0_95: + DEBUG ((DEBUG_INFO, "%a virtio 0.9.5, id %d\n", __FUNCTION__, + Device->VirtioDevice.SubSystemDeviceId)); + Device->VirtioDevice.Revision = VIRTIO_SPEC_REVISION (0, 9, 5); + break; + case VIRTIO_MMIO_DEVICE_VERSION_1_00: + DEBUG ((DEBUG_INFO, "%a virtio 1.0, id %d\n", __FUNCTION__, + Device->VirtioDevice.SubSystemDeviceId)); + Device->VirtioDevice.Revision = VIRTIO_SPEC_REVISION (1, 0, 0); + return EFI_UNSUPPORTED; + default: return EFI_UNSUPPORTED; } -- 2.31.1