From patchwork Sun Oct 6 15:36:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: KobaK X-Patchwork-Id: 13823789 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2050.outbound.protection.outlook.com [40.107.223.50]) (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 C5BFD184555; Sun, 6 Oct 2024 15:36:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728228982; cv=fail; b=Pf/UXaO0XsdW6d4hG3fF3fEhRnUad+t5nhVvaGnvJfDWHl4w6kyU3/7vXi2BfN/Gd4WW8rfryDrDpuurY/b742KEZrPO6vxRhSvptSsPt/3s23kNIssC4eW6Dy9yBfH3NGPa1dnGxHeazaKoRWPrZh16oZnEsjuz+wBWY5HOYZA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728228982; c=relaxed/simple; bh=6S5W1Z5vB7i3pR9RbWhm8AD4aUn3qUo61k1KnrV6Xpw=; h=From:To:Subject:Date:Message-ID:Content-Type:MIME-Version; b=uNHkWS6NSPiypHeXLYV+ZiwoL0M9SLuL3m4/mU480gl5D8CeqUbWj5R7xgQ8MmIFQz2TWNlYst1Ab1AB8ImHkeUOJGQJOz9cN8AIMwMnvI/dTwsZysU8kifYpdVI7VzEok0j538dM0v5NUs1xY+KU/Zm69BZC9We2GC8yMw2GPU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=FSOJNJiV; arc=fail smtp.client-ip=40.107.223.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="FSOJNJiV" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tz+mPt84Xwq9tyy0IQezbmrB2nZWeHYCusBqsFCxg7GWjvChHd3rwbpIt5E8M4Hpc5RKoE7eLexckX1qCRNf+nvKDxYj/UG1gNqqbxci7Q1fGYoResw/AIVfRgXaz5uAOHhT5lV1nH9YART/AjW3ZJ+t8X/+3RnlOb5QFBNXqIjY+nWXeSYGuHR2SqFOdSVJj7r0GKqR384RG050Pf0wvF+7xtnP8eZ007miV1Ge+vvEZvnWGvmFvXvzOTxT1CbL+4ZSlzAruZuBXvvSFC4aLfFkyEB1gDwHZXfQJ1tO25Gah8KFanzqqi/aELTfGOO4jzR6A0oged4VGJrDOanZDg== 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=oO13Nt8G9M90opNAxhl0r1iGZIFP5/B62sLG5mrkIa8=; b=AEURr07zrdLt/nceCe9I0BsU3XGeI7Ql4ZrDvenCfMDZatUn9lU9hRMnSyN2PrXU+fkDUSuC8D8wUPpQu8JEF3eGQLzKeujcaIz3asCYVhmolhKz7ezvq46SVLYkIS6v7QpL+9Qq8OtxE5bC/gONx3OHNssVawaXWf8cUrhqqJ7YMGZrEmTZTKu43gg69r6BV13CPfLpNBIDNNCQhTOuNNiqhUBqP+ajDDaCwczY2g375PX4Kp7SOlNeROf29g4/TIIIZbAfvPCCZAmcx1jiIdq7EIDIaL8UNMco5k3+njg9mDOPuotG35cIKYxLBKAA037lCVDStnQI50IzcXN+JA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oO13Nt8G9M90opNAxhl0r1iGZIFP5/B62sLG5mrkIa8=; b=FSOJNJiV4Wu/GotUzQKptRNUc4jiDnwOzn9HpDOLRC9DvGFBgYnqN6KfVyXL2XYgG89wCcGYhT+aLrh0yl2Duy6dP1OXJxxTQotbvDzlC7WHQyRoVGFBpnFd5OWPqCTg0rQbtqYHOt39GHpbXcPN57jcoUNJBqFabfsk1oO+AZA5l6EncnOivRvvdNasNHWAexJTE58XaHh+S4xG8a7kzlSEkodpQcBgLFb5w739R5+kNSb0llsxC1q/0EjHsLHJ6LQWzHjK+qWk33EXdcnU92nwFEQU4trV4Huw3GhuDfFypgjwG15Kp9Iaz+krijkgXYnNXG2j5anW7tfTdcgosw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from IA0PR12MB7579.namprd12.prod.outlook.com (2603:10b6:208:43c::14) by DS0PR12MB6487.namprd12.prod.outlook.com (2603:10b6:8:c4::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.20; Sun, 6 Oct 2024 15:36:15 +0000 Received: from IA0PR12MB7579.namprd12.prod.outlook.com ([fe80::da98:f83b:ca75:64d5]) by IA0PR12MB7579.namprd12.prod.outlook.com ([fe80::da98:f83b:ca75:64d5%7]) with mapi id 15.20.8026.017; Sun, 6 Oct 2024 15:36:15 +0000 From: KobaK To: Matt Ochs , James Morse , "Rafael J . Wysocki" , Len Brown , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Zhang Rui , linux-efi@vger.kernel.org, Ard Biesheuvel Subject: [PATCH 1/2 V6] acpi/prmt: find block with specific type Date: Sun, 6 Oct 2024 23:36:10 +0800 Message-ID: <20241006153611.1165482-1-kobak@nvidia.com> X-Mailer: git-send-email 2.43.0 X-ClientProxiedBy: SJ0PR03CA0235.namprd03.prod.outlook.com (2603:10b6:a03:39f::30) To IA0PR12MB7579.namprd12.prod.outlook.com (2603:10b6:208:43c::14) Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: IA0PR12MB7579:EE_|DS0PR12MB6487:EE_ X-MS-Office365-Filtering-Correlation-Id: 5ca56c56-1ba5-4fdd-6e40-08dce61c9d4e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: SZVN1q58jx/7LvjWhLpcS5neQGQkguHX+7Mhot2rgneEecGRwfPtwCRROlZPeLuvZguywme60cFfbWAkUkMSSjFPeeLky6tuOWD9sQ6OfME9Vr6xgVhNkqZ3TFopetgSxgf8nzIjlL0NlOU3sySlszOLIYVGxTwG01F/LrALBnYO7OXPebxg3YUEwFVaCHz1324uYb9inrEsiD9ka1IvdlSOxzD4tLaEaC1RQVf5LRRZVBYUZ41ZrAzZ8Qia4I6coCG73tQfdrtIEEuLv2L5Bq2piwTuoNu7qlUfyeRDQXnsCVByE7qUiXtqfvk20rb2FeGYn49jbFp6rWz99dkjlK6mP/sexQXfb/6e31wC/xcYQnSqTDCZV3jTWy0zoVf+EAjyDSOZ7g8tBwPFtd84h6oD9NHcPivZHh04PPXxxsyPg/p5ZeBuUs8vAP2h/llWZEUZaCEFTTmDeCXrSIswN99TdcPwc1JuxFNnI8+Vm7wsF4Qeiid2QIHhynHshnkfHdTso2eMSO0PCtHp75RWrW0gjBDf0EBH2sVVFG0Ioxl0ZYv4Of0nKoZwvaM2PW9N+X7I6KQsxg+AQD6svurubmmNs6Wfum0l21y2gU/dhey0emLVoHXLFmk5/dDptRfN11ht/IXt9EugJOGhf5hPk34Mn+nCvlywxDG3X+bEKLZa3Z4ZvuWvGH3LBjd7vRDSvGlZD3D5jzt2LV9jdQbGdYj8USBI53m8ZxiWqBhDht4/vjppBViDqRTU86YAS2zZ2UOIIq+XN0FRmQTa4f6ph7S3TnVDrj3oZOsybzaANukmNvgrcVfLMZb3xrQPeRaKys4megguxa506Mm79j3x2LqRuf4c8IefG/lVSLqm71yWWkNVDda3j1gG4eDtnAarBnG+sgO/+QPYjp/tQBVMFyxLmRPOgMKRilef/Phgje4X/iiFADGx1zB8RIif6HG8U90FioJLF7CFyRlY+G7JOODjfTLKCw3m6E6YgYuvmtj05WsyAj0lB5p0LwIKRE3EswM1qhF0IMy3mDsIqnV//LJbI1vFHzbDW84JlF1suEKZSZgVq7sMj1XQa8m18jszd2nKbRItbU32oG80KQcl0KVXY/rNoxGvIGqGYxPlQCUh4URl+vIkF5QgTQMKYn8/2vDTw7RQrtMl9yUKNhZFvs7o0XLX07l1SbtXYqVRk0eCJDt9TiV9FchAiP+2AppEE8fVVkQfJinI0DvJykEG19I5PB/Wj5gA4GZPj+yEqOtLAsJhpcnygGmx7LyNr7m8QusIBwkdEmHkgdvpvpmYyw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:IA0PR12MB7579.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4tjeTvjgLJZJEoPTfxpWkskXqd6o28P3PadBQSwGruUtw7lKJ9jsneGlm7jvAdS5xnzGv8NFhkaNg1yHx8mnJ3GjmYwDG/dCLR/b6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VhErxDbe8U92WvxwzvFrct7PiSkLtiMq02Y3kW98cGoDxIfkIRflU0Ei5Qx28yyytdCL28NeAlTRLpk8Bi5xsSszy7J81iqwiuVaSUXzlVPnHYzPyK4xclw6SYNNWQuTb7Ra0NxGw/M3RuySyLiCr2MM49bNzQp5BMIsS5CDcSD+V9mp8IdmiYtfjfiagN9fQyw8jSQ2YtXa716LQWqw+T3Kxn6BnGJ1A29j7wp48WGvnNNig4Ts4M2TbFq4oC5m8Hge6d0ZZUdCxFe2k2LEHCE+raW2G2/UzcvZ5drPOVmt3SFzXfbPH+gKGOZFsoUwyQU7rTL3A3TdbshZAIJYz8CPUxRQVZRwVqNlFH8LANApALoB5FrqY6A03OByfxF+9nzz80QgQ/Tg4OdQ5RCvlih1J/Tb X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5ca56c56-1ba5-4fdd-6e40-08dce61c9d4e X-MS-Exchange-CrossTenant-AuthSource: IA0PR12MB7579.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Oct 2024 15:36:15.3524 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 2IMVD3AK29pdiHQlsa2QRBTPfua9GDifKSvfNIzuNgW2jUJoHHOz3sB+2MeBR+z9Cdg71zZz/juj46tLa34R0A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6487 From: kobak PRMT needs to find the correct type of block to translate the PA-VA mapping for EFI runtime services. The issue arises because the PRMT is finding a block of type EFI_CONVENTIONAL_MEMORY, which is not appropriate for runtime services as described in Section 2.2.2 (Runtime Services) of the UEFI Specification [1]. Since the PRM handler is a type of runtime service, this causes an exception when the PRM handler is called. [Firmware Bug]: Unable to handle paging request in EFI runtime service WARNING: CPU: 22 PID: 4330 at drivers/firmware/efi/runtime-wrappers.c:341 __efi_queue_work+0x11c/0x170 Call trace: __efi_queue_work+0x11c/0x170 efi_call_acpi_prm_handler+0x68/0xd0 acpi_platformrt_space_handler+0x198/0x258 acpi_ev_address_space_dispatch+0x144/0x388 acpi_ex_access_region+0x9c/0x118 acpi_ex_write_serial_bus+0xc4/0x218 acpi_ex_write_data_to_field+0x168/0x218 acpi_ex_store_object_to_node+0x1a8/0x258 acpi_ex_store+0xec/0x330 acpi_ex_opcode_1A_1T_1R+0x15c/0x618 acpi_ds_exec_end_op+0x274/0x548 acpi_ps_parse_loop+0x10c/0x6b8 acpi_ps_parse_aml+0x140/0x3b0 acpi_ps_execute_method+0x12c/0x2a0 acpi_ns_evaluate+0x210/0x310 acpi_evaluate_object+0x178/0x358 acpi_proc_write+0x1a8/0x8a0 [acpi_call] proc_reg_write+0xcc/0x150 vfs_write+0xd8/0x380 ksys_write+0x70/0x120 __arm64_sys_write+0x24/0x48 invoke_syscall.constprop.0+0x80/0xf8 do_el0_svc+0x50/0x110 el0_svc+0x48/0x1d0 el0t_64_sync_handler+0x15c/0x178 el0t_64_sync+0x1a8/0x1b0 Find a block with specific type to fix this. prmt find a block with EFI_RUNTIME_SERVICES_DATA for prm handler and find a block with EFI_RUNTIME_SERVICES_CODE for prm context. If no suitable block is found, a warning message will be prompted but the procedue continues to manage the next prm handler. However, if the prm handler is actullay called without proper allocation, it would result in a failure during error handling. By using the correct memory types for runtime services, Ensure that the PRM handler and the context are properly mapped in the virtual address space during runtime, preventing the paging request error. [1] https://uefi.org/sites/default/files/resources/UEFI_Spec_2_10_Aug29.pdf Fixes: cefc7ca46235 ("ACPI: PRM: implement OperationRegion handler for the PlatformRtMechanism subtype") Signed-off-by: Koba Ko Reviewed-by: Matthew R. Ochs Reviewed-by: Zhang Rui --- V2: 1. format the changelog and add more about error handling. 2. replace goto V3: Warn if parts of handler are missed during va-pa translating. V4: Fix the 0day V5: Fix typo and pr_warn warning V6: use EFI_MOMOERY_RUNTIME to find block and split goto refactor as a single patch --- drivers/acpi/prmt.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/prmt.c b/drivers/acpi/prmt.c index 1cfaa5957ac4..970207bc8f4a 100644 --- a/drivers/acpi/prmt.c +++ b/drivers/acpi/prmt.c @@ -79,8 +79,10 @@ static u64 efi_pa_va_lookup(u64 pa) u64 page = pa & PAGE_MASK; for_each_efi_memory_desc(md) { - if (md->phys_addr < pa && pa < md->phys_addr + PAGE_SIZE * md->num_pages) + if ((md->attribute & EFI_MEMORY_RUNTIME) && + (md->phys_addr < pa && pa < md->phys_addr + PAGE_SIZE * md->num_pages)) { return pa_offset + md->virt_addr + page - md->phys_addr; + } } return 0; @@ -149,8 +151,20 @@ acpi_parse_prmt(union acpi_subtable_headers *header, const unsigned long end) guid_copy(&th->guid, (guid_t *)handler_info->handler_guid); th->handler_addr = (void *)efi_pa_va_lookup(handler_info->handler_address); + if (!th->handler_addr) + pr_warn("Idx: %llu, failed to find VA for handler_addr(GUID: %pUL, PA: %p)", + cur_handler, &th->guid, th->handler_addr); + th->static_data_buffer_addr = efi_pa_va_lookup(handler_info->static_data_buffer_address); + if (!th->static_data_buffer_addr) + pr_warn("Idx: %llu, failed to find VA for data_addr(GUID: %pUL, PA: %p)", + cur_handler, &th->guid, (void *)th->static_data_buffer_addr); + th->acpi_param_buffer_addr = efi_pa_va_lookup(handler_info->acpi_param_buffer_address); + if (!th->acpi_param_buffer_addr) + pr_warn("Idx: %llu, failed to find VA for param_addr(GUID: %pUL, PA: %p)", + cur_handler, &th->guid, (void *)th->acpi_param_buffer_addr); + } while (++cur_handler < tm->handler_count && (handler_info = get_next_handler(handler_info))); return 0; @@ -277,6 +291,12 @@ static acpi_status acpi_platformrt_space_handler(u32 function, if (!handler || !module) goto invalid_guid; + if (!handler->handler_addr || !handler->static_data_buffer_addr || + !handler->acpi_param_buffer_addr) { + buffer->prm_status = PRM_HANDLER_ERROR; + return AE_OK; + } + ACPI_COPY_NAMESEG(context.signature, "PRMC"); context.revision = 0x0; context.reserved = 0x0; From patchwork Sun Oct 6 15:36:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: KobaK X-Patchwork-Id: 13823790 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2050.outbound.protection.outlook.com [40.107.223.50]) (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 A856B185948; Sun, 6 Oct 2024 15:36:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728228984; cv=fail; b=ghqU09MYkeiviD8PR7UL/xxw4R08tCju3JIlWndPdYXXJaKuSrHQZas7sodNwnCpxDYQw13HobBc4YaieBTEKL1uus/5iFR1cXpC7CUi+w+J1y64D4x1pUiVLrCmDUIUdtHQqe4Iw9fRb6dZqYD3NONQEyL7dOupkiW1kzz/kzY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728228984; c=relaxed/simple; bh=XhAdjRAKmJpgtwf3jd6QNXMK8fN4OoP5NACE+NJZ5dM=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=VdtdeMtzAjdyR9bsDPQ85icS+cY5qKtlQ6ICJxoDAdlyza9bLWFDyS8qeGr8WMmkgsq9Ew6u+ELXE8u5MX7pcIAVMEYPbLQLTKw+psQwcR8ZovuNVkwGSh1elAK79fSn2dEe3lNhT5FHVPH0CtbxFuxxl1fZmbLQ37l5rUOVcFE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=cjTKKP2E; arc=fail smtp.client-ip=40.107.223.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="cjTKKP2E" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jk3uQFArVk0ipnd8d3Zl6W/0lttT462PQwfqOA1EHUNm6ortNrfOe4k/H60HW90DpEEVLdou/3la1eX5iBn7l0Sf7Gk0jpeqQUdL/tXG3CA4PwrtZ8FsxzMsIUCC0dTuAPOCVXUs4dAd5oUOk9iyBBkVcpWiOedO6b8TZRsTJZ2bdmgZ1D+9/DzSds2q9FhZmDa5SNkW6Q4JdjrZFOGxuxa3PzfAN2LeD19pvOT1QKHtEmHhr+L8gTiMMQq8om2Q6WhL6hYtyaiFj+uFudbwJiGbkZ3aXb9a8dyz+YpxlcQJkJLfnX/DhdtB1svQyp5i7fF7BOkRxGpFhwYJYRQYvA== 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=KEmlPTD0HOFtprOtFXo0+sQxqo0Sl8vmGDePiw+CXTo=; b=HBsaGRLPIZJdc+0KoRB397sCYh5N8Bv9vI114dKoWcKMOUBzEy2fCfLdCvJtg1QW6D3xWiA/xkNMstKIpxY9bjbpK3AyGemrfe7l4NxRI8w+FsMxmTEEKdMbjfx7e4q2bHXu0m4TT3VDsnyfEs9y502+Xl5JlyEGmRb9FP1+1y7Dj8lZCf0TyU2Y6ANLnIlrVRY0EehQmcr0XnZwQTTyZVmAVFBjxc4TyJfBHZXpwi9Tsd/RgVSsMU/c/sHDqTpNl6+RBYpeeqJ6UYss/rQ5KmtEPOnw7B8u9WYpq77sCCJWZlcRy663kdu0ssC+eicc1M032TN/NNUOfNcs2yHuHQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KEmlPTD0HOFtprOtFXo0+sQxqo0Sl8vmGDePiw+CXTo=; b=cjTKKP2ElVIsXkdQshnroZiJi6M/sfziKuNB06EjqppVckeRZsBEfBEAjK3Ce6szITKQdbUgpK3K2OQqVzIpkhYLRTMrDrb4z7ZkFjlbqbuM/l5SLwziZwav/NTZqt1ddacNluvs+jKlS8qmAP1XFDoYQmO3vepllnh/y8sUJZsWir8SgrWo1CeObQpVi0pnl9+pJI381DQLC/wT5AmCWwiEDVOpVht7Cq3bqIsicytEUpEYBmDI8wqn8EQpxagNHRH6d+HVMEUhdXBMfVFStPQstU7imG7OrQ9lBy5cSuCnH2KPnUfUSF/TrxiBdRnR3dNMqmG0+uE4b/u1FkmShA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from IA0PR12MB7579.namprd12.prod.outlook.com (2603:10b6:208:43c::14) by DS0PR12MB6487.namprd12.prod.outlook.com (2603:10b6:8:c4::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.20; Sun, 6 Oct 2024 15:36:19 +0000 Received: from IA0PR12MB7579.namprd12.prod.outlook.com ([fe80::da98:f83b:ca75:64d5]) by IA0PR12MB7579.namprd12.prod.outlook.com ([fe80::da98:f83b:ca75:64d5%7]) with mapi id 15.20.8026.017; Sun, 6 Oct 2024 15:36:19 +0000 From: KobaK To: Matt Ochs , James Morse , "Rafael J . Wysocki" , Len Brown , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Zhang Rui , linux-efi@vger.kernel.org, Ard Biesheuvel Subject: [PATCH 2/2 V6] acpi/prmt: refactor acpi_platformrt_space_handler to drop gotos Date: Sun, 6 Oct 2024 23:36:11 +0800 Message-ID: <20241006153611.1165482-2-kobak@nvidia.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241006153611.1165482-1-kobak@nvidia.com> References: <20241006153611.1165482-1-kobak@nvidia.com> X-ClientProxiedBy: BYAPR01CA0047.prod.exchangelabs.com (2603:10b6:a03:94::24) To IA0PR12MB7579.namprd12.prod.outlook.com (2603:10b6:208:43c::14) Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: IA0PR12MB7579:EE_|DS0PR12MB6487:EE_ X-MS-Office365-Filtering-Correlation-Id: 0346090f-158e-4a21-4427-08dce61c9f6c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: imkvKTgu1au7kqPqVUQ5hzRI2uNerGBoYvEVPFA2bj1/ah+Ip+PUfzDWle7OtrFUNSqD3BNNG7yuNZsVaEyQNpsUEr7V+4q12pbEaJG1M3bHKR7woFYrJc3QsPuS8mX/UJUN2MOr+PAXUQebXHSkZoqLygWpIDm2rt3rXSc//QjwyYFMpsLjtRMxYRZlswNWmq7awQHHg7FEjZx21Fw8glbV1YlEn/Z0Ld8cWBUQUTtW1bB5FKuDtmcuixbbSgDlXAUlRBfU1qTxaF5FGvlgkE5uZsFSW4j+2NPFUz8Qyw5eM2uAK1/ewG78X3kaz8weJ3BNOzYE354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;CAT:NONE;SFS:(13230040)(1800799024)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: swjgy7dwdde7WxxyeIzPxl3mbpONi/2uOdaagMybXUxsgKAyowOCSt8x0H2A6S4u9TF09tVl35nOBszk32xypJvrhz/fWj31Y8XYBNYkL0ln0pvCxs8skzXSPyLg2feBMMrdIQx6AoXCh63HPVhwW6xPy2H+6RUFG9uiBV3V++WgjiSWd0F4jEGbu7I2MdvUxuD354LxlhjmfdVQZV1DVNrIMCz/4SEkRM/E+G1r/ked/a2+QHas3gcNDR9GkeVJymd1j0QuyIDIpYGDgUvNk+2ZSDr0hhHJSmzTVoM41YCT00DRkxmkhlVdreutd0EiDH0hf2ywZquoSJqU5HcfOKiW+WPb/sAbtGTxbByvlUsJyAw5i//TOudBAKfZ1ETkdZArec7Qpnstw6zwkAW1CUwXUa4Bw0bRVDX99doYrlsx1vt/TGMubtXDwocRCUdPXi9qJk8e1kbRqPiBDRF3SJ95YHgCBTJmSlpCmaV4kfrv493t/ev2VANY922Bp96rKiUnrNpyfBXUjU4bsZv++prmnzhv4jbfEhXLjaGxvO8NrJjdm8Z/GaPs6yWfrKNgxp+OMQ/gxTWTEt9e/Di5KkSiB7m/HddorsBwJ1CHFruL3i9gW+V5n+/Sm6t2jI58yMfgAeiaprTU+Ay/OcAIvMn1Vwy84p2QW7mazf1nemOmstM7oExm7A2MWtqxQOp+h5wpt6XU191sWbqbCTeiVB4137clS00AGamvfG2F+QK05OFl3xUCrzq7OLx4qDv2njjntGlAV+4iC57nriqMGBZHcLydDh7hVC3IMWnkp+6KanSPWmnO/wHGp9zIPKvq7u7hsSPjNN6HamimqznTR6dStKwOnq/cAl6spvjE67mb9LmxVivixO1eDSnJ0MUxIng1Evj8B6Zxps/HZGaa1y/kjxQ5q6MlWg6FqlSEDgfiLh5SZ2359yLu4X0MsuWdmgfQQSTq3gS/V/WGphmSt5ma6j+Ii/k58WaxFNCPs2pCARpqEn6UMvtMWwALopWbsa2vTzr/rxkm1FziJKMMfZtusYvtigZqPXOx200h0dwrIcefu0+sFWlHqrndI2L5NJIseJ4Age2lp52lvzN0WrmaojUENS8JONy7ZNcL3ov4m41YQwt+ELFjR1tob+fIQt8cQcQUeE4tefFX0Nq2bi3nc66ecuC4KdskY0pgVOrLnq3gxOj7EOSZU4qs2sG7jw3XCxfNFnqWACG/3JrXnHYkxIikUG7ln4VDdcmSJaOXJceXvS2DeUV91gzGWmrH83LwLv2OJNt98WjW+GTpFOjpFMMWcIKpT6plIj3IEzhF/IdvVSeAw1I/MCug24hzlpCm4zdZBMUqEHCwvZwqlJhpfSz3FLVHx/p2u+HpN4rsUxgLe6Iu7JmEsMR6jeY630dca2xAiXcHhrN4xYjCio71PM1U9gKF7h6shHnlE3GVeuPZZgmy6subnpZXaqXgIFL8X0DVbEuH99hyrU1yq4Hg6hLLUoWhCRAuxylHA+n4nkWdjZuhUN6J3/5f5Cy3OvcyzWDK62sN14Bl033Xv4QnbKEbz/HYqiZ27ucjUZGh6BxoIkqcV7AgSDht/8zE X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0346090f-158e-4a21-4427-08dce61c9f6c X-MS-Exchange-CrossTenant-AuthSource: IA0PR12MB7579.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Oct 2024 15:36:19.0398 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: M/X194UDJPxXYuCqrhGPVff2Eu7lWBNsuNGwv1n4mafbWo7nhyGvpzMyCv4vsGkNHCbQefvJFZryp9ECUCCYqg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6487 From: koba ko Replace gotos with returns Signed-off-by: koba ko --- drivers/acpi/prmt.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/acpi/prmt.c b/drivers/acpi/prmt.c index 970207bc8f4a..b0cf4428f7e3 100644 --- a/drivers/acpi/prmt.c +++ b/drivers/acpi/prmt.c @@ -288,8 +288,10 @@ static acpi_status acpi_platformrt_space_handler(u32 function, handler = find_prm_handler(&buffer->handler_guid); module = find_prm_module(&buffer->handler_guid); - if (!handler || !module) - goto invalid_guid; + if (!handler || !module) { + buffer->prm_status = PRM_HANDLER_GUID_NOT_FOUND; + return AE_OK; + } if (!handler->handler_addr || !handler->static_data_buffer_addr || !handler->acpi_param_buffer_addr) { @@ -318,8 +320,10 @@ static acpi_status acpi_platformrt_space_handler(u32 function, case PRM_CMD_START_TRANSACTION: module = find_prm_module(&buffer->handler_guid); - if (!module) - goto invalid_guid; + if (!module) { + buffer->prm_status = PRM_HANDLER_GUID_NOT_FOUND; + return AE_OK; + } if (module->updatable) module->updatable = false; @@ -330,8 +334,10 @@ static acpi_status acpi_platformrt_space_handler(u32 function, case PRM_CMD_END_TRANSACTION: module = find_prm_module(&buffer->handler_guid); - if (!module) - goto invalid_guid; + if (!module) { + buffer->prm_status = PRM_HANDLER_GUID_NOT_FOUND; + return AE_OK; + } if (module->updatable) buffer->prm_status = UPDATE_UNLOCK_WITHOUT_LOCK; @@ -346,10 +352,6 @@ static acpi_status acpi_platformrt_space_handler(u32 function, } return AE_OK; - -invalid_guid: - buffer->prm_status = PRM_HANDLER_GUID_NOT_FOUND; - return AE_OK; } void __init init_prmt(void)