From patchwork Fri Mar 29 13:15:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paluri, PavanKumar" X-Patchwork-Id: 13610624 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2074.outbound.protection.outlook.com [40.107.94.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 66C1286128 for ; Fri, 29 Mar 2024 13:15:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.74 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711718145; cv=fail; b=dBvArMgs7MuyeU39gZCbIwAN9YKdV4F2wWbuL4uJff//sHS5GoTgf+AeZBpQnEs2nJwQZMi/NiGR51KzVnE2SmN5UYxWHqfeetOEguG5oZ1tcgBEvgjP/uQgaBdtG2zbQ3EpYVidYTzkX+TY85oNTQPhbhHAor0mc9AskMwY3vM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711718145; c=relaxed/simple; bh=eqS707r7Bse27gh7zugFdLJZjTKtTFKjwLTUC614W8M=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LNSILZYq4l6xUxR6wqVQjqaxJAR5F5m6MmU8oc9bTArPf4cNkCDrYxPe8Y/XiVl2g60oYBNSWQtqf/v6Sdbs40IZ09iaaznNwqTprpLNThLDy+DDO83+DuOP7hZpMG7QtG5NjErDFupe4AfRaIp8b126YiLHQSDH6w9vqP8RWPI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=qPmPcevt; arc=fail smtp.client-ip=40.107.94.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="qPmPcevt" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gI5yAu1EaFKCPQRCoHQ039bFXYYWuqV5T19/sdVsni+C20KOHzebIpA+GTtW+ZTXxSHA5Ubno4kkr5yAW4dtM0365v67RhiqQLWeeouT/cWzGCfIW9g47OSAMAuMaN8phzC5js/4JY5BXNOhNZrN+CXTt/IsDW/Re5aVBziZhzyFKNqojbc60hYCuAMTs3NilQNwbyqL9BQsZBtSLErbvRjXeagUHEeUj4GpuV+Fs22txSbnzoV6WmIL+fZSIJTgrZzXs7x635Mxt6L4viEyEC29r+3ETrPKIq9wHBNWjWHeC6n8UkN/h5TyWFZbAy0pmDoUmEmDDwo4gbf08iVkWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=KoqEjZtMxVxzeVqpZABOV4G4Gd6XVC3elcBVHQ61A0k=; b=eA7xOmgj1vbTLYwd1FvFBbo+7G5OaQ2wTJHnmjn3lU2aE22eTirgw/9CBk5R667rhbvKxdV76LixVyu1qWBsAZAMuFQGgMEXQ5A9vGZySXPlntLb7883FGfLXAKjJn/0dfBTH2/Xh46rAG2IhXWZqon5+CC41Q4l/Xxu7it19jalSVOKCNFdsxEWzYI3B//MbWwNQZIdIAoyNNbmAPtysRCBs9QqMKoT+oKTVkrGAQKk90KvZpVutiEhFF2OIz+gAfGAL8SaiHUyRw7HhjORuXAWRKtq5OvSMicEcW1PHd+t6De66DBWmvTsZye3va/FeAR7lJ1kvRMfvbdNu0Ju4Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KoqEjZtMxVxzeVqpZABOV4G4Gd6XVC3elcBVHQ61A0k=; b=qPmPcevtTOCgynkyohnylmJLvnpH8vH6uprWqIWo3dExQt/GY+4WLPttdI5BbDEbF1EOEuuglOWYo3wY4eT6zk6W4VevRIP77TfZqhvHgU3nXNbOPxlvVP68baARvW6qBvEqjXSMuSxc5LbeW64b8GYuUPTgJEXDS1ltTl+UH14= Received: from MW4PR04CA0193.namprd04.prod.outlook.com (2603:10b6:303:86::18) by MN2PR12MB4079.namprd12.prod.outlook.com (2603:10b6:208:1d5::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.40; Fri, 29 Mar 2024 13:15:41 +0000 Received: from CO1PEPF000044FD.namprd21.prod.outlook.com (2603:10b6:303:86:cafe::7d) by MW4PR04CA0193.outlook.office365.com (2603:10b6:303:86::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.41 via Frontend Transport; Fri, 29 Mar 2024 13:15:41 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1PEPF000044FD.mail.protection.outlook.com (10.167.241.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7452.0 via Frontend Transport; Fri, 29 Mar 2024 13:15:41 +0000 Received: from ethanolx16dchost.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Fri, 29 Mar 2024 08:15:40 -0500 From: Pavan Kumar Paluri To: CC: , , , Pavan Kumar Paluri Subject: [kvm-unit-tests PATCH v4 1/2] x86 EFI: Bypass call to fdt_check_header() Date: Fri, 29 Mar 2024 08:15:21 -0500 Message-ID: <20240329131522.806983-2-papaluri@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240329131522.806983-1-papaluri@amd.com> References: <20240329131522.806983-1-papaluri@amd.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044FD:EE_|MN2PR12MB4079:EE_ X-MS-Office365-Filtering-Correlation-Id: 97d99421-db14-4f72-e324-08dc4ff2555a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UFHUAHaaFdgIkt0IyYAY0lF23Qsyl5gkqSJH55Caporwp2FOLX/rjLvs6DYbtIlV+y2Trw7Z8VaJjUOyGjbNSMYh1ss4B6Y4mLHGqiB/yFG6csGMqJsPEPc8+2q0iFGB71Aqsd5/hQNWOL81stKF9+Vx8uBU1cv4/4jHtmDTPRzug1lFCnwJTQ8jWbEK+wOiPfESV3tqneULk7all8M0rJnF54h5hUBhyaUtQ+IrNTkdokq5M7UTjp/O4IZTVKLVzUIb6blnziZocMx78FGmY18v/LT7xIU2kyb8pRSmYz2yFWo6trfXoj3sWsvKNzCWK8Zht2kNGzxzjfFY4HGpmknapnMaWW6YipqF+Od2/F5/aeD5QEHJe3mMAAVgZuZPcC3Mf48uAKo9AV1JkpSR6y7cg2LV7R5YeeaPo4zEjSdlkQ5YbTV5kz+PrgUPpr4O3TvwDqfnP3AtJ2FyaOmPti+xok/EY3ZfXL97myMGcBH3J+iBzsEP5fTPrKlwZ74za7nteuLweIygdbcFzw7vJnmKyTCxWf7RLBMDDLFAfAegM1m0rgZ0BZf2sXDvkjVWfhiFWnfKBO8Kxo6n+V0WtrMBOW8QpUSHgsTHWv2CgEybobPY3+k/S90FFPCy9JdrbxNVrTXt4jzBHjyTXTPO8ZZrw/B+nf0ydxfz5L9z+ccHNTqw/KYyUpL6GLD0vqNywY2KxpLUevfrbQvsyDZvpJeHg3pYcw0SmUrLV8IOn0eT/WFSmJFJDr7a2sYyAvmD X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(82310400014)(376005)(1800799015)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Mar 2024 13:15:41.1061 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 97d99421-db14-4f72-e324-08dc4ff2555a X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044FD.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4079 Issuing a call to fdt_check_header() prevents running any of x86 UEFI enabled tests. Bypass this call for x86 and also calls to efi_load_image(), efi_grow_buffer(), efi_get_var() in order to enable UEFI supported tests for KUT x86 arch. Fixes: 9632ce446b8f ("arm64: efi: Improve device tree discovery") Signed-off-by: Pavan Kumar Paluri Reviewed-by: Andrew Jones --- lib/efi.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/efi.c b/lib/efi.c index 5314eaa81e66..8a74a22834a4 100644 --- a/lib/efi.c +++ b/lib/efi.c @@ -204,6 +204,7 @@ static char *efi_convert_cmdline(struct efi_loaded_image_64 *image, int *cmd_lin return (char *)cmdline_addr; } +#if defined(__aarch64__) || defined(__riscv) /* * Open the file and read it into a buffer. */ @@ -330,6 +331,12 @@ static void *efi_get_fdt(efi_handle_t handle, struct efi_loaded_image_64 *image) return fdt_check_header(fdt) == 0 ? fdt : NULL; } +#else +static void *efi_get_fdt(efi_handle_t handle, struct efi_loaded_image_64 *image) +{ + return NULL; +} +#endif static const struct { struct efi_vendor_dev_path vendor; From patchwork Fri Mar 29 13:15:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paluri, PavanKumar" X-Patchwork-Id: 13610625 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2076.outbound.protection.outlook.com [40.107.93.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 39AEE85C65 for ; Fri, 29 Mar 2024 13:15:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.76 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711718158; cv=fail; b=UagO34n9rltewXm4HPE9PY8eixZshUH3tkiScaqAvvNQTOL9irKeg0vj3dx2NyLE5znmzODcnGkQIvtdAkZpKtEFPtgdkyGHHZWJ93H1n9fUm9l6XunNvUj/uBrARHQh/qpGlOfOQdSd9cviT71h3/4HXzxYH6nzFQvuQByBXUA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711718158; c=relaxed/simple; bh=x+Y/+2mBpnxTVq8MAx2KMGQv+Ql8+PBJabdLak7n0Ew=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rTSWvLdmXAJY/OaHygAJRkVqDVsAuPQ0z/+Vdxp8DamJsz49amqtLk3h8zX4hxDzBDqhmNKzyj1pH9yePn0xGiUigQu6ZVsD3HMTIz3foXS4M3shxzbL2Mreq/bh9Vx9xeddtnjIMLxYpq5H+eMFFGZMPq+rDBgAFBDvEpjFBOc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=YXzXFO5k; arc=fail smtp.client-ip=40.107.93.76 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="YXzXFO5k" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TtUMsUaAaNQJLxf4sAk+rWMDZ52SPOfw/VmsMYtfTxSUQVJbMTA7WOCp6Lp1jFKWxYslcAooezRp6qwC/xWxhpmG+tcfT+gWtQ6+cRIcFGCMVCv6hgsPev/UlQoKS2o1p0q8pq1Wl/euX4+j7WAmiCvWIEvx/uH2REb4JO4uN7JN77GnMBQbZRFJIZRrTvNwoenAGW50tCnRBYNzxChnKghEo6X5Tzor4ANk1n6BXHxYYUpRwx8rwfizdPZoeBDLdzsTuQAjEQQ+hdEJLik/24KI/MsvkdAVKWvdtvg6JGRAXAtQe3NseWCqHFeUukBs9+Cy8IGO6wNMLlZFym4p0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=d8kJYXi7M3CzOSYESIwKnPebntDJfZZiuZ9g3gk7tKs=; b=H70ZWBeUlEKTvN7N92Nh55J1wSQUQLJfC+vW1muUeT/qth1txRIxcwgB49fEGvGhAitwnCD2gNDFFP4YduHFPEhLGMY7QR//KodBSKxKsIL/0Ete2vV+EdPIMWASV2i0e0UzqEbrItcXJVBnrrF+7S9FJNTt4yIThmI7JjgGr7mYkmwqwm05oXumsMMezdOnbpgu2yDzNuSxdCVITjzQMWz/3Oti50GunTtzTfYRCR3P8Ru8c87EB+lAtIRKp+vvUTWd9XRcXEU8b2QMZBuqVQRymaGEfLChD5K29zP0tCmOlDx8u71xNcZv00tdHapCq+DyyebgCCoQxz16AtvohQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=d8kJYXi7M3CzOSYESIwKnPebntDJfZZiuZ9g3gk7tKs=; b=YXzXFO5kd4yMLgX8PuK2cxnqiMx7m+CxvV5mO4AKhvz6LGUuXJoTMPM6WQWe8UoQzCjyD+kyJFQ8fxBAsm0d9GB17f3baXA3ka6ajRuTUEXPfh+6t+noKI8hJQrzRIEePNbNKoKF5IwALi5LTHOFNyBd+UejQiJHBT21r5tNH38= Received: from MW4PR04CA0210.namprd04.prod.outlook.com (2603:10b6:303:86::35) by LV2PR12MB5846.namprd12.prod.outlook.com (2603:10b6:408:175::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.33; Fri, 29 Mar 2024 13:15:55 +0000 Received: from CO1PEPF000044FD.namprd21.prod.outlook.com (2603:10b6:303:86:cafe::6b) by MW4PR04CA0210.outlook.office365.com (2603:10b6:303:86::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.41 via Frontend Transport; Fri, 29 Mar 2024 13:15:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1PEPF000044FD.mail.protection.outlook.com (10.167.241.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7452.0 via Frontend Transport; Fri, 29 Mar 2024 13:15:51 +0000 Received: from ethanolx16dchost.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Fri, 29 Mar 2024 08:15:50 -0500 From: Pavan Kumar Paluri To: CC: , , , Pavan Kumar Paluri Subject: [kvm-unit-tests PATCH v4 2/2] x86/efi: Retry call to efi exit boot services Date: Fri, 29 Mar 2024 08:15:22 -0500 Message-ID: <20240329131522.806983-3-papaluri@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240329131522.806983-1-papaluri@amd.com> References: <20240329131522.806983-1-papaluri@amd.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044FD:EE_|LV2PR12MB5846:EE_ X-MS-Office365-Filtering-Correlation-Id: 96194bf5-96a0-400a-1f58-08dc4ff25bcf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tX/pA/ZiiwyEgsLMC1EYQz7CMAZugnkXtp4hIdyMbv10DWoQCI2w4yyHoyBzeYIPPSNHFyHHOkrnwlTC2pltkwCNZcVxD4Z5krONS9j1p4Z8JdscikBUjJNCf7EokUec37duFpNsc6ljBEKxMb40+cS8JHbpPprAwttiyXAXHoB8bMdYNEsDtk/8Tp1jo8e4CcXYBIqdoVjvqy5BTtbbuFfX/EN321jjLvCUe5qGCQ/oHssfCpjrlrIxv+Bcyn7Q/rK3vzQomSW7mB/T07acIngS7MzWmb413uySqE7YkLd8nONyDGmHObAIBGGK5z75v7q3dY8mo3ms6sio/iyd7PBymvvQe8lMueTMXf0iBhVRhb7/1Mjdo2quvwpQp7LYKubb3YObYl4fuK4iF6k5neFUSUdsDLPtgb17c6J5xzGEDikazH/iM9Gd6JrwTzqlz1b9n9/NSL8UtSjdJRQAkv1yV6fek9Z8QW4X3tbfzuP+zg/W4BkS1rxgUlQq9KDciiyom8fEHZ1KVhfGBFq2Mo0Hc2cP6gr64OqBOWXjW2YR8OUZTR7IYtbpEt+Opm9WVf+sfmDXs2dfxPIbRu5XipeZJIROhlvay6MIj8JjPPFhJEWbyRyH/nvX7BdNpWIlnfIgDM0dH6Jx19d8FHxMp+BASupnYGIOCK7u0O2eosT6fr65c6FKdFgsjmegBZPWAyuOzyX/mQ+BqNSrjPVvbj7d3nyLPOb7cYaM4fDlrGlwWtci+2o2mtexOWPnHI1K X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(82310400014)(36860700004)(1800799015)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Mar 2024 13:15:51.9029 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 96194bf5-96a0-400a-1f58-08dc4ff25bcf X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044FD.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5846 In some cases, KUT guest might fail to exit boot services due to a possible memory map update that might have taken place between efi_get_memory_map() and efi_exit_boot_services() calls. As per UEFI spec 2.10 (Section 7.4.6 EFI_BOOT_SERVICES.ExitBootServices()), we need to keep trying to update the memory map and calls to exit boot services as long as case status is EFI_INVALID_PARAMETER. Keep freeing the old memory map before obtaining new memory map via efi_get_memory_map() in case of exit boot services failure. Signed-off-by: Pavan Kumar Paluri Reviewed-by: Andrew Jones --- lib/efi.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/lib/efi.c b/lib/efi.c index 8a74a22834a4..44337837705d 100644 --- a/lib/efi.c +++ b/lib/efi.c @@ -406,8 +406,8 @@ efi_status_t efi_main(efi_handle_t handle, efi_system_table_t *sys_tab) efi_system_table = sys_tab; /* Memory map struct values */ - efi_memory_desc_t *map = NULL; - unsigned long map_size = 0, desc_size = 0, key = 0, buff_size = 0; + efi_memory_desc_t *map; + unsigned long map_size, desc_size, key, buff_size; u32 desc_ver; /* Helper variables needed to get the cmdline */ @@ -446,13 +446,6 @@ efi_status_t efi_main(efi_handle_t handle, efi_system_table_t *sys_tab) efi_bootinfo.mem_map.key_ptr = &key; efi_bootinfo.mem_map.buff_size = &buff_size; - /* Get EFI memory map */ - status = efi_get_memory_map(&efi_bootinfo.mem_map); - if (status != EFI_SUCCESS) { - printf("Failed to get memory map\n"); - goto efi_main_error; - } - #ifdef __riscv status = efi_get_boot_hartid(); if (status != EFI_SUCCESS) { @@ -461,11 +454,22 @@ efi_status_t efi_main(efi_handle_t handle, efi_system_table_t *sys_tab) } #endif - /* - * Exit EFI boot services, let kvm-unit-tests take full control of the - * guest - */ - status = efi_exit_boot_services(handle, &efi_bootinfo.mem_map); + status = EFI_INVALID_PARAMETER; + while (status == EFI_INVALID_PARAMETER) { + status = efi_get_memory_map(&efi_bootinfo.mem_map); + if (status != EFI_SUCCESS) { + printf("Failed to get memory map\n"); + goto efi_main_error; + } + /* + * Exit EFI boot services, let kvm-unit-tests take full + * control of the guest. + */ + status = efi_exit_boot_services(handle, &efi_bootinfo.mem_map); + if (status == EFI_INVALID_PARAMETER) + efi_free_pool(*efi_bootinfo.mem_map.map); + } + if (status != EFI_SUCCESS) { printf("Failed to exit boot services\n"); goto efi_main_error;