From patchwork Wed Jul 17 07:33:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Shao, Marshall" X-Patchwork-Id: 813261 Received: from mx0a-00154904.pphosted.com (mx0a-00154904.pphosted.com [148.163.133.20]) (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 8EF5317577; Wed, 17 Jul 2024 07:33:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.133.20 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721201612; cv=fail; b=mBr2WU9JgmrYelkaboVgskyM/2Dc54YK6SGbpz2T1DrK6jutJmVdgOm12zmlbF43YXa+jNFXQCN3wxRJ/PBYdprPNtkcd4gLW02tXf/Uyqea9JsevkOFU9b1Ljq7TN7+HF5if7qLTPsK1qbZp4K4FedwHUUHJEMvpGGuSWAbTdw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721201612; c=relaxed/simple; bh=wrT2QHSTK7EfG4xMSLYPsWCcugrKDb2Dp0qJeakpNQM=; h=From:To:CC:Subject:Date:Message-ID:Content-Type:MIME-Version; b=A8CX4EUTT6RUkJU1iKk8TMOQtdZeSYdgFhIwa6xEhEPDQIxGfjbe+NPzzaYtiQoU3GzTlZvQizZ9tlwJOYMiY2C7t86oXyjHRH93bunjy/LOpwtpOV0/HralkChMpw56rF1GQHNpSNPQ5Tldj2PuapUjxBLDiBkymMB4/achkpg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=Dell.com; spf=pass smtp.mailfrom=dell.com; dkim=pass (2048-bit key) header.d=dell.com header.i=@dell.com header.b=I280gY8W; arc=fail smtp.client-ip=148.163.133.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=Dell.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=dell.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=dell.com header.i=@dell.com header.b="I280gY8W" Received: from pps.filterd (m0170390.ppops.net [127.0.0.1]) by mx0a-00154904.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 46H18t8l029220; Wed, 17 Jul 2024 03:33:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dell.com; h=from :to:cc:subject:date:message-id:content-type :content-transfer-encoding:mime-version; s=smtpout1; bh=wPxfyjZD he/SCI+SAJNeYunYTHRr1iL6It/QQoGJ9nA=; b=I280gY8W+D14fF8kJKYwtgCo 1H2U06uq01j5maW6SPPMO0qxIPUsz8eiQSnWN63fZdeEHaylnHks9OaV5BnHN9kX Ta3qxHBm+kgOgaaHX1zI1Wtt0ioxd/r160OmOkbk1sXNfK+V9ZgVjbX7NANqWqpH 0nL3uIaMIa9/KOF3bv08Ztp+C04Fho7gAxaITifMc9xO/3ktRm91G5R7SUgqdtGP Oo2bk/ZyTvPrn3pfzcPpNrTfIQ+lJFm4noUZ6ptqYhBaVaac5KqhXeZnS1JiKxKN r4vMftp6auKMS230pzcSkp9acKA6K8ZQFr9k8CVpcyVVLDlFP01ciLCKr37WAw== Received: from mx0a-00154901.pphosted.com (mx0a-00154901.pphosted.com [67.231.149.39]) by mx0a-00154904.pphosted.com (PPS) with ESMTPS id 40dwfp311y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 17 Jul 2024 03:33:13 -0400 (EDT) Received: from pps.filterd (m0142693.ppops.net [127.0.0.1]) by mx0a-00154901.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 46H7RwcU037904; Wed, 17 Jul 2024 03:33:13 -0400 Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam02lp2044.outbound.protection.outlook.com [104.47.51.44]) by mx0a-00154901.pphosted.com (PPS) with ESMTPS id 40e9kf02mr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2024 03:33:13 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AjkIvffwgG3CHmt1lhHNtdk5ifk7WwW2KzqWWCvNNtD/QNG0DijhBV0/7kRpjRDvDCK6YaWL+AhtQvkSf2B/jVpoeSFCXdpwWEg46C1gqu7Hjf3r8Zt3u2thdA/8ixKpqpMv965T420WF9RPANQ9Z5aVbSg1rPjvLmLhrqP14vqq+BJmK6T8hrF62IUdDrbRsU+Pu4KIC+H2uPNXmcmimTQdTiLVlom278e5PIACZZxJ39/qYD5TfOitekI4UBxiu+tR/iVoFymG6gGzTHTxC+GobKr5Bm6yh0dCRgNuLsSGvM1kt3DBNKvcKxXjOvwPzCUX7ri0d5NbxGmO1rgWbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=wPxfyjZDhe/SCI+SAJNeYunYTHRr1iL6It/QQoGJ9nA=; b=h8ONwCSrF1AEZzXyOGowO0SG/TSu+6Gi+/B4splY8u3y2hq+x0C+J0r30M1QDodP3pZrUWcSuaAGBSMrXIY8GEOEQPEcAaIQBatQZa5rAfXnfNMI3OZs2fDHPUQqUhBgoK0/KbqRCSA0xYhHWRqXQTAyjxlQJaYIKe499li3hfEpBxEQXpYfSy3AM1tkdcf4Iy6Y/Eh4RlB/zCIr5+eHIpFjnJpi+xObjS9gzu3Hdkzo7jOMFDXsxM3y+AP1jikFiuDE4GyYnrZFtb1jCsQI3NHCoaCJVDX8NtCAYjCSg0wBayRVmAyuF4ZCX4HC3vDX5k+g+0orUFNWC0euSfHu7g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=dell.com; dmarc=pass action=none header.from=dell.com; dkim=pass header.d=dell.com; arc=none Received: from DS7PR19MB5709.namprd19.prod.outlook.com (2603:10b6:8:70::15) by PH8PR19MB6881.namprd19.prod.outlook.com (2603:10b6:510:1bd::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.30; Wed, 17 Jul 2024 07:33:09 +0000 Received: from DS7PR19MB5709.namprd19.prod.outlook.com ([fe80::3d06:d879:7717:36e0]) by DS7PR19MB5709.namprd19.prod.outlook.com ([fe80::3d06:d879:7717:36e0%5]) with mapi id 15.20.7784.016; Wed, 17 Jul 2024 07:33:08 +0000 From: "Shao, Marshall" To: "ardb@kernel.org" , "linux-efi@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "hpa@zytor.com" , "dave.hansen@linux.intel.com" , "bp@alien8.de" , "mingo@redhat.com" , "tglx@linutronix.de" CC: "Mishra, Ashish" , "Dion, Christopher" , "Caisse, Joe" , "Chia, Jia Yuan" , "Mukundan, Govind" Subject: [Patch] Do not clear BSS region in x86 stub Thread-Topic: [Patch] Do not clear BSS region in x86 stub Thread-Index: AdrYGyaFCseU4QE3SCibBf0Ev6R9+w== Date: Wed, 17 Jul 2024 07:33:08 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_73dd1fcc-24d7-4f55-9dc2-c1518f171327_ActionId=37d26f2c-3fd7-48a6-ba05-08288b1c2997; MSIP_Label_73dd1fcc-24d7-4f55-9dc2-c1518f171327_ContentBits=0; MSIP_Label_73dd1fcc-24d7-4f55-9dc2-c1518f171327_Enabled=true; MSIP_Label_73dd1fcc-24d7-4f55-9dc2-c1518f171327_Method=Standard; MSIP_Label_73dd1fcc-24d7-4f55-9dc2-c1518f171327_Name=No Protection (Label Only) - Internal Use; MSIP_Label_73dd1fcc-24d7-4f55-9dc2-c1518f171327_SetDate=2024-07-17T07:28:18Z; MSIP_Label_73dd1fcc-24d7-4f55-9dc2-c1518f171327_SiteId=945c199a-83a2-4e80-9f8c-5a91be5752dd; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DS7PR19MB5709:EE_|PH8PR19MB6881:EE_ x-ms-office365-filtering-correlation-id: 78bdf296-d3a6-4fa8-5b06-08dca632b4a9 x-exotenant: 2khUwGVqB6N9v58KS13ncyUmMJd8q4 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|366016|1800799024|376014|38070700018; x-microsoft-antispam-message-info: vBBoP6Qa8Kjz1+CSFl2kiJ8Ibc1IBuuCHG0/I6e3UvWo/ZtWhOGOVot3bm1pfRR4mgR8Ndm/dEUW7RigXN8z585vgxGBZ2TNJ23SV7h4pcduKBMfvXZRQKuQ59ZG1f+rdGhf+Pj4xOBt+yQcBKdfwIuyD2A7kdDwZ3cbAhFg9v0gkug5/sekqkz//MC1aMLjAYuENFOVTiFvPQhUP5iXiocjY91N0mw0Gz1hFY+f/sQzEzdsE59sRcW13JDr1ytnEA/2MrFuBjfgA5RWRvw+KE9kegIES12cJP322MCB8/NNpJmAgsTL4olm6lMuS4x2c7JHPFgcasktIvCzWLcjIbqi4MUPlp1OfXCem9x5b3xqO7f1kefEh5Ov/Gx1iPYl7yKsj91BB8GmqSgPiVTGD2sWVzOzuDmzdCErgIQgAAA6aY9GsZPHpICnhQDeV2bo6gWYnrMEVPv+UdkM5CJuqjzFoVtbFryO/+ezlDsPGZdnhL9NPtUjOIta/KIHrA0ev62Zs0v88A2BHt/HqdZo4pjk2PO7ljtyzImLKqhAGH4CmOIpCCam/OuHedVpeJU+iu/UXLf6ql1EEf7iqk7CU5Bs1scc3bE8WT9MdeXDxPNl0vqD27J6nKSglrOoan4WmUnj3rst3xr+MDHrICBT3uSYVlS31hGhtG0QeZWyy3fRuo+SQA+Bx7gnxXrxEA4jO9I2vujn1I56b/A8R+s2dLmLCvKH0t5E9BxfOpdFWttH6J6uTCNz56M3IigJJxJJdhxJqH+a19ouyFEP1b4f7j8jiR7ooEEA+SSJsdSO879wzXKx8up/WdhA2Yf15XuzTfeTOHxlDkzGN2qX0APlAgTtDWxRhvvu66Syn88o87+7RdsVSJquVmVELlNX05aE1Bs2CqjFInXztJQguIoRP4ZZCkP8nx/EDPZdS+vo3OT31dFHK0ezkf4dQqK2MGCOZkXXCPQ19u9wUoqJ+z68ZZZGaIsNlcoxT6sGHgirk+3Ch8bqCcnkjKUCfyEl3tK3+lKrryWgk4VF4+QnVR2Wf6UXZvwxeKroAzJyg7tTfbqPOykYiryhIc4s2vUpaolI2O/0vai1D2JIjCx8DcO5xCSqRWZwHatgqMmNgxbTbSkn+3CoH1kE29Yj6/bjqLMepmJ2QVNA15oMeeOcS6YBPh+tgvyDkN/VkG48y767qJIiArLgel18VYc/i1SQCERreiZS8b3pxf1WSl6CxJCPqmxJE+BkdclRVFuqTRU6XNdmNayIa+D+3N7FJNGsC5AEFKGBVuHxs3/gy2CBc4DePZSFDQqsisLviyL7pKO2Y2IwBI+s0DzxzGWindHhFB/8GGEmZKa+XO0aEu1D0LpcxcgEy2T0p8fjAeRqOUES6l7q6a9Ftf8qePEE32pd1GIvJjWyfoWezThnSgGoLEAEog== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DS7PR19MB5709.namprd19.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(1800799024)(376014)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: A/wmB0Hi8B9sqSYyrIdh0Ce3mdayOQKr7migiBJaOsp+qrNZAscBYxlp+ihisObLzS8i36BF8AVY0XmCciU0NJ9UbDFs/kkrfdDxh1Tg1Dlq8W4psac/CVIY4xKLdjMPTLcfIcE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YWySFcagz52zADqAMg8FiprVbF5Nkl8zeXjFS6ki+9BJsn4TdUB2+/UpOaagMirsNiFfabcHwt5ZQ98ph61eYqBd+DhcGGhTZeiLNqcCK7OvAJ+f2eoVd43NyFVnQuZmll6sEXf8wy7BfQjqFhSsOMzlr64v6YXFrTluqKuKa6m+7lT9ddChUnX8iZ0nNlB673kZtIkTNGqrRnYQW5VNovlbKl2GGWSuUu8+5kMfWydKx/L7P+DgcQG9j9ZDzng/WHJZ1u9oXgxYb3Sgv7jaa9j35T51jOknJ59SrQOZa1T77DqUXP1cm0pk7J4P11HwFNbmed3He1EauBRyYuqEGUy74EI97Uf9ucWT6NB/qmIWr7dbq0BqSvJa9mDOV7m Precedence: bulk X-Mailing-List: linux-efi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-OriginatorOrg: Dell.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DS7PR19MB5709.namprd19.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 78bdf296-d3a6-4fa8-5b06-08dca632b4a9 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Jul 2024 07:33:08.9268 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 945c199a-83a2-4e80-9f8c-5a91be5752dd X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: y7fiimgLfj3i/1sl4eqMbU9ubFu5ZE/yjY+Lis19dk5/iTluU2uEcAmUBm9DTRl2kbR9/WM/sAFzTV8l7ggn0g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR19MB6881 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-17_04,2024-07-16_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 impostorscore=0 malwarescore=0 priorityscore=1501 clxscore=1015 mlxscore=0 bulkscore=0 lowpriorityscore=0 spamscore=0 phishscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2407170056 X-Proofpoint-ORIG-GUID: -1J0Cxvsdn4O-tE5MW42mqbilEKr0ZOx X-Proofpoint-GUID: -1J0Cxvsdn4O-tE5MW42mqbilEKr0ZOx X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 lowpriorityscore=0 clxscore=1015 mlxlogscore=999 spamscore=0 suspectscore=0 malwarescore=0 mlxscore=0 adultscore=0 bulkscore=0 impostorscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2407110000 definitions=main-2407170056 From: Marshall Shao Clearing the BSS region may cause the UEFI firmware to malfunction during boot. When booting the kernel from an older firmware version that has TPM enabled and the MemoryOverwriteRequestControl bit set to 1, the firmware's boot service might encounter an exception if it attempts to initialize the BSS region within the x86 stub. To circumvent the firmware exception, it is advisable to enlarge the BOOT_STACK_SIZE and to perform the initialization of static variables prior to the decompression of the bzImage. Signed-off-by: Marshall Shao --- arch/x86/boot/compressed/misc.c | 8 +++----- arch/x86/include/asm/boot.h | 2 +- drivers/firmware/efi/libstub/x86-stub.c | 5 ----- 3 files changed, 4 insertions(+), 11 deletions(-) -- 2.34.1 Internal Use - Confidential diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c index b70e4a21c15f..bac5a3c55c2c 100644 --- a/arch/x86/boot/compressed/misc.c +++ b/arch/x86/boot/compressed/misc.c @@ -356,11 +356,9 @@ unsigned long decompress_kernel(unsigned char *outbuf, unsigned long virt_addr, void (*error)(char *x)) { unsigned long entry; - - if (!free_mem_ptr) { - free_mem_ptr = (unsigned long)boot_heap; - free_mem_end_ptr = (unsigned long)boot_heap + sizeof(boot_heap); - } + free_mem_ptr = (unsigned long)boot_heap; + free_mem_end_ptr = (unsigned long)boot_heap + sizeof(boot_heap); + malloc_ptr = free_mem_ptr; if (__decompress(input_data, input_len, NULL, NULL, outbuf, output_len, NULL, error) < 0) diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h index 3e5b111e619d..312bc87ab027 100644 --- a/arch/x86/include/asm/boot.h +++ b/arch/x86/include/asm/boot.h @@ -33,7 +33,7 @@ #endif #ifdef CONFIG_X86_64 -# define BOOT_STACK_SIZE 0x4000 +# define BOOT_STACK_SIZE 0x10000 /* * Used by decompressor's startup_32() to allocate page tables for identity diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c index 1983fd3bf392..d92d2ccc709b 100644 --- a/drivers/firmware/efi/libstub/x86-stub.c +++ b/drivers/firmware/efi/libstub/x86-stub.c @@ -21,7 +21,6 @@ #include "efistub.h" #include "x86-stub.h" -extern char _bss[], _ebss[]; const efi_system_table_t *efi_system_table; const efi_dxe_services_table_t *efi_dxe_table; @@ -476,9 +475,6 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle, efi_status_t status; char *cmdline_ptr; - if (efi_is_native()) - memset(_bss, 0, _ebss - _bss); - efi_system_table = sys_table_arg; /* Check if we were booted by the EFI firmware */ @@ -1000,7 +996,6 @@ void __noreturn efi_stub_entry(efi_handle_t handle, void efi_handover_entry(efi_handle_t handle, efi_system_table_t *sys_table_arg, struct boot_params *boot_params) { - memset(_bss, 0, _ebss - _bss); efi_stub_entry(handle, sys_table_arg, boot_params); }