From nobody Fri Dec 27 03:05:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1503491022111729.8379605142958; Wed, 23 Aug 2017 05:23:42 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 975BB21E49BDF; Wed, 23 Aug 2017 05:20:34 -0700 (PDT) Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0074.outbound.protection.outlook.com [104.47.40.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B0E4121E49BA5 for ; Wed, 23 Aug 2017 05:20:29 -0700 (PDT) Received: from brijesh-build-machine.amd.com (165.204.77.1) by DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1362.18; Wed, 23 Aug 2017 12:23:02 +0000 X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=iwOu1K3btjVl5MAaXz4VaRHQpKTu0utFRkKAajcvezE=; b=Lp5HvhhZ5b0597iqVbV5ntawG9OsAc5DjoIe37NwJiROzjjm/6YvsfpH1/WB9uC8ADI6olCm4OkvPZFfPDsprszajSy/AcPXOVXHj7lnOG6eCHjVWHvLlijffzhEU+k0+txMfpb0pgqkLvN3PNawId9OJ5ivZCx4u5aBLEXrLuI= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: edk2-devel@lists.01.org Date: Wed, 23 Aug 2017 08:22:34 -0400 Message-Id: <1503490967-5559-11-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> References: <1503490967-5559-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR12CA0069.namprd12.prod.outlook.com (2603:10b6:3:103::31) To DM2PR12MB0155.namprd12.prod.outlook.com (2a01:111:e400:50ce::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 09a27489-ebb5-4003-8e98-08d4ea21b30e X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DM2PR12MB0155; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 3:mg6Qv5dU5a0id5anjknUfbQbLE10+gdNxL6c/kFw1Ikfbm8hrS+8eVAlMudmW8ZuzZ8XvQTSfEgSmiO4AmG0zG+h1sLuCU0Dq4vz6Qup6C3rTkEneEfgwkNb7hi/YLU/pwuJOI5GFHA3t13JaIrro2cWjwompYsRPq56BxnZYIw5boXMOOpKq8I2xRrFAP2YBbgnHHGi/VpYLA6sZjqUXq8NEQfmke9uOVy+owONXAPNExt/B8N3JPwBxcQmEZaX; 25:G+YJLcnj+1aW5ibJyAZW4YcgMxi8UNwtJnzcRjpsifMpOaZdNpRgEbZ4vUCpytFNlKaG6fyByStcj42mGG8B1SNz840stebj9LrkRpvjAQY13k+KXPPRa1AY9i9P07RKBJEMyQDfo+T/vx9aPKGgYlaaK87GhlADhRaw9g3JUW6pp8dgiclqeSczNuthETWKXkUWKAS+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7Bkk6oXgSkpS1EKt3lx2WhP181eUEe6tuhpExVlTQ5NATfBiGwbVeSGCIEosxVEz0i0U3bVusYbFa4vfJpp7IbfkvSfZ8wF/JIriG0TYRhgy7CnOUgyJFBD6NgoXbQC37kKrDIiGtVJ01BvBkTGnY7BnaLwedcswLdOr7hedR6xM10ds7i4/Z4Ih44CQ1vgTO7or3L/GnVHt/Q8lwFZo/q6ll3FTtLW7jHz65H7naj/3l9tYYvVpY5gA== X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(228905959029699); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(3002001)(6055026)(6041248)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123560025)(20161123564025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM2PR12MB0155; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM2PR12MB0155; X-Forefront-PRVS: 040866B734 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(7370300001)(4630300001)(6009001)(39860400002)(189002)(199003)(575784001)(305945005)(47776003)(97736004)(101416001)(110136004)(6666003)(189998001)(478600001)(7736002)(3846002)(66066001)(5003940100001)(6116002)(6486002)(48376002)(86362001)(105586002)(2950100002)(4326008)(106356001)(36756003)(6916009)(50466002)(2906002)(50226002)(42186005)(2351001)(33646002)(53416004)(25786009)(7350300001)(81156014)(76176999)(5660300001)(68736007)(54906002)(8676002)(53936002)(50986999)(81166006)(2361001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR12MB0155; H:brijesh-build-machine.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR12MB0155; 23:4DRwioHH9dOW+RPsYjbEejAyovITtpLJWYKEXL0UN?= =?us-ascii?Q?4kQeG6QYDQtK1f5280A2DsPx+4WfcYh3I08l7Og9QwanSaGORZoElnShBQz2?= =?us-ascii?Q?eBIRfvdMUmRTmuD8J54txV9D6qx8fSKPiQm7bh9AxTeh1iOXe48azH5uX5BX?= =?us-ascii?Q?7NNH9mhSxKteOZgyzRYOzIRgLpzpCv68SO1thIUuOHEFzBqAHxoKA2U9wu90?= =?us-ascii?Q?KQt50SoibPimnviJeSP7Wfk1gz0Cqpl+aCz5QvmqeEPUEI+1WIMU/sPM6TwG?= =?us-ascii?Q?H0eACoNRfuzck0eMuTRXdv+dQPKitIk6PtrhX2LZzPOPcPmz58QbesyB/0If?= =?us-ascii?Q?4KnrcAMkAcwD7I9SKT1w+SUoq5Vgq5x9EBg6NFnUmw5JL6NhYKiCbC96qmmP?= =?us-ascii?Q?X+9pggnkKlbTEGokM+TiU+rJjj0Zpf3uNdWZubqPWW7HaHEC7rgYruqQ5W3i?= =?us-ascii?Q?CboK2wVaeghNl2ROwT/LNL2NUv0Qm7x1iSgwIjRCFQtfJABSFW09X6juUB1g?= =?us-ascii?Q?fOATbQODs4oZdoMW1CNGeNzSs7EULGCHysJgsPsQAf6ATF+pzXQV4/GglnOR?= =?us-ascii?Q?a3OqwxeI/ygINOH3NvuBazBL//tvLdndRUtf35Tu8VAy0o6RE2NLE41Fktf+?= =?us-ascii?Q?eqFyLdi60bMOyEDMiSA8BcqE4awH3rDfNfrrhi3YqWfZEoNfpPleARAK69IX?= =?us-ascii?Q?X4xeZHWUFe/iXY+Xl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Gz6kgkGY5AM9v9goe6L7UH5kEGPZVZzAvg0uYg==; 24:+yX+KIv7DO+JNJUMTcKl18ekfBy2txctUYN5/VVlX70re5QgQh7gcIg6kG7FHxrTS+9OcRSF+xfaHbjcTyCU7OWfDmeS1GC99vCMQM6gHGg=; 7:AwUH5Jd5UnZM8JPtOJKMv/o2jYV2mX+8sge9sg1cFg6XVjrJ+UjjWn/FlIadAb1w520eO7fIbTXuJ0dTXaWNOsOvZhTPhznxY/+6ngyWGDL6QE56Fm8GdhA/FEiejvtMgm+TN+DTg/U9m/69TsZeGP8cIRFPZH2E/VhZThvsU/bUGE7g4QLYHpSmHu57Mwynv6dx81RkVCI9BZGPC2lgTsBzf5zhOn+OsIC6ecz7nSs= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0155; 20:OuHKJsqgrPukvhQXe3Q9RJwBLBKvhs4IrsKNLwIbr29WHfcbIth3x5cfgemwhVgERJN5INMAIPlX3gxi2U1vkInnMPyqdVCSeVtAcrnIqIBzrCb7qqYR7aoZ+6KzkTPBt68JzlMsMqosn38PRRRnxFaXrWAEJZx+VHC+zWCmsZIVzEITJ5vHWMmebIY28DdnANI/fQSMaq8qmap51V7oPNo8D8/Ff0KNLH2Vqk4V9u6DQf8Ds3/u4km2XHlyJ6bs X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2017 12:23:02.3259 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0155 Subject: [edk2] [PATCH v3 10/23] OvmfPkg/VirtioLib: alloc VRING buffer with AllocateSharedPages() X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jordan Justen , Tom Lendacky , Laszlo Ersek , Ard Biesheuvel Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The VRING buffer is a communication area between guest and hypervisor. Allocate it using VIRTIO_DEVICE_PROTOCOL.AllocateSharedPages() so that it can be mapped later with VirtioRingMap() for bi-directional access. Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Tom Lendacky Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Brijesh Singh Reviewed-by: Laszlo Ersek --- OvmfPkg/Library/VirtioLib/VirtioLib.inf | 1 - OvmfPkg/Include/Library/VirtioLib.h | 5 ++--- OvmfPkg/Library/VirtioLib/VirtioLib.c | 22 +++++++++++++------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/OvmfPkg/Library/VirtioLib/VirtioLib.inf b/OvmfPkg/Library/Virt= ioLib/VirtioLib.inf index fb5897a88ecf..e33856de38c4 100644 --- a/OvmfPkg/Library/VirtioLib/VirtioLib.inf +++ b/OvmfPkg/Library/VirtioLib/VirtioLib.inf @@ -32,5 +32,4 @@ [LibraryClasses] BaseLib BaseMemoryLib DebugLib - MemoryAllocationLib UefiBootServicesTableLib diff --git a/OvmfPkg/Include/Library/VirtioLib.h b/OvmfPkg/Include/Library/= VirtioLib.h index 3d9314b3acaf..c3e56ea23b89 100644 --- a/OvmfPkg/Include/Library/VirtioLib.h +++ b/OvmfPkg/Include/Library/VirtioLib.h @@ -42,9 +42,8 @@ =20 @param[out] Ring The virtio ring to set up. =20 - @retval EFI_OUT_OF_RESOURCES AllocatePages() failed to allocate contigu= ous - pages for the requested QueueSize. Fields = of - Ring have indeterminate value. + @retval Status codes propagated from + VirtIo->AllocateSharedPages(). =20 @retval EFI_SUCCESS Allocation and setup successful. Ring->Base (and nothing else) is responsible for diff --git a/OvmfPkg/Library/VirtioLib/VirtioLib.c b/OvmfPkg/Library/Virtio= Lib/VirtioLib.c index 535635ac0ba8..e5366e385f5d 100644 --- a/OvmfPkg/Library/VirtioLib/VirtioLib.c +++ b/OvmfPkg/Library/VirtioLib/VirtioLib.c @@ -19,7 +19,6 @@ #include #include #include -#include #include =20 #include @@ -44,9 +43,8 @@ =20 @param[out] Ring The virtio ring to set up. =20 - @retval EFI_OUT_OF_RESOURCES AllocatePages() failed to allocate contigu= ous - pages for the requested QueueSize. Fields = of - Ring have indeterminate value. + @retval Status codes propagated from + VirtIo->AllocateSharedPages(). =20 @retval EFI_SUCCESS Allocation and setup successful. Ring->Base (and nothing else) is responsible for @@ -61,6 +59,7 @@ VirtioRingInit ( OUT VRING *Ring ) { + EFI_STATUS Status; UINTN RingSize; volatile UINT8 *RingPagesPtr; =20 @@ -79,10 +78,17 @@ VirtioRingInit ( sizeof *Ring->Used.AvailEvent, EFI_PAGE_SIZE); =20 + // + // Allocate a shared ring buffer + // Ring->NumPages =3D EFI_SIZE_TO_PAGES (RingSize); - Ring->Base =3D AllocatePages (Ring->NumPages); - if (Ring->Base =3D=3D NULL) { - return EFI_OUT_OF_RESOURCES; + Status =3D VirtIo->AllocateSharedPages ( + VirtIo, + Ring->NumPages, + &Ring->Base + ); + if (EFI_ERROR (Status)) { + return Status; } SetMem (Ring->Base, RingSize, 0x00); RingPagesPtr =3D Ring->Base; @@ -143,7 +149,7 @@ VirtioRingUninit ( IN OUT VRING *Ring ) { - FreePages (Ring->Base, Ring->NumPages); + VirtIo->FreeSharedPages (VirtIo, Ring->NumPages, Ring->Base); SetMem (Ring, sizeof *Ring, 0x00); } =20 --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel