From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0044.outbound.protection.outlook.com [104.47.40.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 44A4821D1825F for ; Mon, 14 Aug 2017 04:34:58 -0700 (PDT) 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=zGDOtHMzhiriSkzHqQf2Ff3nIj+27o5IH1vesrxoGoM=; b=QGtzmA7r+SfhPPdUCoyfm1QuaBXRbOqVT0gNrTO+WFHPxiwq5OI6o94V/lGwewmMmzfaMrzwdidmxh7hflNyCUfo7yQosYv3u3KLc3hR1vd/BCCyanwCidLeszDHmIihHSahpoJbVzD0+QRGJoCXqlTMnOZooT8K2ToxKH4Mozw= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Received: from brijesh-build-machine.amd.com (165.204.77.1) by BY2PR12MB0145.namprd12.prod.outlook.com (10.162.82.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1341.21; Mon, 14 Aug 2017 11:37:20 +0000 From: Brijesh Singh To: edk2-devel@lists.01.org Cc: Brijesh Singh , Ard Biesheuvel , Jordan Justen , Tom Lendacky , Laszlo Ersek Date: Mon, 14 Aug 2017 07:36:37 -0400 Message-Id: <1502710605-8058-16-git-send-email-brijesh.singh@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502710605-8058-1-git-send-email-brijesh.singh@amd.com> References: <1502710605-8058-1-git-send-email-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: MWHPR15CA0043.namprd15.prod.outlook.com (10.173.226.157) To BY2PR12MB0145.namprd12.prod.outlook.com (10.162.82.18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bdb440fd-e20f-49ee-3114-08d4e308d32b 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:BY2PR12MB0145; X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0145; 3:7OP3zkzwjrtrBw0GZTu3E5URu4/vD0OhvtOj0ZUgvi1gaXZk2BpIlafGgHGU0H3qCPWJTq1nCQH8TgiT9b2JHGgeaSUtABak6KrfAomvzjjj/rcCvqzc6WqHCXCPrTrxP7JsjCwxegdQvTOQaBBhdkknW5b3CqZyLxlNbmBD00CCJ3EvupmpPI1yVHt4eD7e4hB4VbyEPJb7xfCms1BOu1jBuvqAz8cloiCmneLKuMUDwS9ZKQbp33Ybn5Y5JA3F; 25:5SEwTKZL2VLb6j0YE9MKMt2Ge0Z3C71aeaecliyZG5xKDqrwk1vu/vHztZ/k/whwZa6iyi/oAW95xpXj34f6LnacO7VQEGuqv46HTotxvQcZ++69wNQdaQWfY/aBX9I0U2p5ED+lFg7iw4yfFvE1CFTVuSIaTC7shhzyvnK9NSULl+ASiFISXrZaK4uPH2oK8SaKoAOrZeg1n4WQ5wlRtSgFIMbjKBraXoI/J5KznoodmSKhEyahbxZBj8Nv8UZLmEcqoEVIVYVg1pA7Mz1KpqZtrzkQubxniUPAL+6KMOs9Hvc/ecONWXW3xUxp1myr8JKbZDV7OGUtz2mBI5FxcA==; 31:p3oTx3RRePGqAnavmkaZLFVu3SYnkK51Gkz/fUBiH6SuBPFAUhYDVTwMtX8mYOHbjxXWGF5jrzGN/YW6p6Z6K8BjsTsEwCnaMlVUGbQXXPfgwLQiWOcxPC1VjrSCL+1L76sF4r+S5J/u7hA+juWEuaVddVHXg1OMDdX23gT6IECU9XA9JhC9KUIZcu5b5JBKtbd+3y+z4bl+wXCX+YMWMQA56C+pmRhGs6DT15a5Mpc= X-MS-TrafficTypeDiagnostic: BY2PR12MB0145: X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0145; 20:2iz+rTQkr5Mf42jpzcAfJc++rPya231xxT/4Kv9+XP+9R5yAGpFo+LkczfiO0qOMgaZwfFGqsxSgcDBrj8D0gKnyxx+1b2PKhWnIdEcMv5X51Gs/lqcw/xE4MsGmN2mR2jFkn+QIUj4wrE5ZaMDO6RqqwOSK4IH9N03ODRl6fC+qEHB+bzJvAvSh3EkZ4mu5PqNUoQieuE5OPH6N6McJdsh5QNP7GA1enn2Bsa6Ywk50i102si7E7ScnO/4wq5rqQFJM7LLYcibflEWzWk6t8hhOt6FyyT75E+mbU+TVNMJiVY+fVUOo9Rwyi5/NzCnh/BRIpU1uCyuE2yW4AsekuFq2su1OreZRAScLsQgFPR3a18JsvncxNyrHskc77SNHSeKmJ/ySfXA3qznCJszbFvrqCNoD0eSlGjcUj76hc5KW27xduu9mlfO+9VZOXv27g4FzIpyQOreou6tXhdbDu/X8UUadEPQK6po2O8xYlMCVMojiCiKVqcEmFsWuj5PL; 4:CmKxYNzzPv6aogFnlC1JXbIxV45rlq7/N/myzfh2aDm/t5Es3F+xdilKei/6aCiD7REuTAGAXTI6gIF9CwrKEWNx5jDhFfsrALqhu+GeiV9BtzqBN9kcY/1mNTG9xO7rZBLg1oq5Bo2fCi/Y9FzRl2mjpNeybOS0hzWU3toNLfO5Csz06bccZFXRn1nOxH+E9QWsCcR4oaARF81pjATUQBpUy9IfVbs3IpluFzMxqnHNiyvuV2EIgHkZwxIg79dgUVss9HdtVxHQdR2aUTJR6pe8PHsEBwSviyiWUGYCqI/hSrLOWAqzgS28eTiY/w+ZX0pT0jrfFjTM7uLNXrEalA== 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)(8121501046)(5005006)(93006095)(93001095)(10201501046)(100000703101)(100105400095)(3002001)(6055026)(6041248)(20161123558100)(20161123560025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123555025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:BY2PR12MB0145; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:BY2PR12MB0145; X-Forefront-PRVS: 039975700A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(7370300001)(4630300001)(6009001)(39860400002)(199003)(189002)(54906002)(5003940100001)(6116002)(3846002)(53936002)(97736004)(86362001)(36756003)(81156014)(81166006)(110136004)(8676002)(189998001)(50986999)(76176999)(5660300001)(2361001)(25786009)(2351001)(50226002)(4326008)(7350300001)(33646002)(478600001)(53416004)(42186005)(2906002)(105586002)(7736002)(305945005)(106356001)(48376002)(50466002)(47776003)(66066001)(6486002)(6916009)(2950100002)(6666003)(68736007)(101416001); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR12MB0145; H:brijesh-build-machine.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR12MB0145; 23:FtpSyl75XYzubUw8rDHIvClLjbXXpabFq4ccbTso3?= =?us-ascii?Q?THCzmEKGSFUxXmnqdH4H5BL4ZX9KuMspQ9Np50XYzSzkXlKayLR4Jufbw/UH?= =?us-ascii?Q?f/N14LCBtQVSJ0POit3ckDkTu99sdQY42VufazqjMtjbTfC6NEIkpCvZJPm6?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Metadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0145; 20:BxzvQ9x8RLu3bIOLi5re3ritOzrZiX1mHyfUWrNHfKx3wyO1+DTMBWbvAvbrDUKmADow8zXT7GVPuKfAVLhULSd0ansDRdOaJ7PYqf0MLgIoppAb50i7zEsBUZFZgmDdyTg2G7ONpw/HjPQp+tEpMsuXs0Uyx7EWbikyO3R6nqR8TI7PtGJkLHJnocxJr38c8vqeXdadeejNFZ785CgBIQiYIsp9YQLwhXJJeUw1GrpciJfgmym4GGvf2DO3z2QB X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Aug 2017 11:37:20.2211 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR12MB0145 Subject: [PATCH v2 15/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: , X-List-Received-Date: Mon, 14 Aug 2017 11:34:58 -0000 Content-Type: text/plain Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Tom Lendacky Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Brijesh Singh --- OvmfPkg/Library/VirtioLib/VirtioLib.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/OvmfPkg/Library/VirtioLib/VirtioLib.c b/OvmfPkg/Library/VirtioLib/VirtioLib.c index 7d07dcc09d3d..8010b5cf4735 100644 --- a/OvmfPkg/Library/VirtioLib/VirtioLib.c +++ b/OvmfPkg/Library/VirtioLib/VirtioLib.c @@ -61,6 +61,7 @@ VirtioRingInit ( OUT VRING *Ring ) { + EFI_STATUS Status; UINTN RingSize; volatile UINT8 *RingPagesPtr; @@ -79,9 +80,16 @@ VirtioRingInit ( sizeof *Ring->Used.AvailEvent, EFI_PAGE_SIZE); + // + // Allocate a shared ring buffer + // Ring->NumPages = EFI_SIZE_TO_PAGES (RingSize); - Ring->Base = AllocatePages (Ring->NumPages); - if (Ring->Base == NULL) { + Status = VirtIo->AllocateSharedPages ( + VirtIo, + Ring->NumPages, + &Ring->Base + ); + if (EFI_ERROR (Status)) { return EFI_OUT_OF_RESOURCES; } SetMem (Ring->Base, RingSize, 0x00); @@ -143,7 +151,7 @@ VirtioRingUninit ( IN OUT VRING *Ring ) { - FreePages (Ring->Base, Ring->NumPages); + VirtIo->FreeSharedPages (VirtIo, Ring->NumPages, Ring->Base); SetMem (Ring, sizeof *Ring, 0x00); } -- 2.7.4