From patchwork Fri Nov 3 15:13:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 13444608 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D819C4167B for ; Fri, 3 Nov 2023 15:16:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8B35C8D00BF; Fri, 3 Nov 2023 11:16:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 83D528D000C; Fri, 3 Nov 2023 11:16:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6B8608D00BF; Fri, 3 Nov 2023 11:16:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 576858D000C for ; Fri, 3 Nov 2023 11:16:00 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 22D851A0F34 for ; Fri, 3 Nov 2023 15:16:00 +0000 (UTC) X-FDA: 81416993280.20.F8B454E Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2048.outbound.protection.outlook.com [40.107.220.48]) by imf16.hostedemail.com (Postfix) with ESMTP id EBAD318002B for ; Fri, 3 Nov 2023 15:15:56 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=Az2TYXnk; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=quarantine) header.from=amd.com; spf=pass (imf16.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.220.48 as permitted sender) smtp.mailfrom=Michael.Roth@amd.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1699024557; a=rsa-sha256; cv=pass; b=R8RTVGhn2q9hs6DswrhqMU90a/dLUHE/RBsg4BSE2kJE/pzqlHK2y8zU35hEmr2hIjrWoE ylnXm8cJeQ8ZkeOj+gnGUFkZ1zTmaTNjYEFqDDiJsmIzeHYh0L8sCKEIKR7Mwve4Jbi5ro poCrK6HQrxmvMLVMH1/LnnFDLDTyHxA= ARC-Authentication-Results: i=2; imf16.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=Az2TYXnk; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=quarantine) header.from=amd.com; spf=pass (imf16.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.220.48 as permitted sender) smtp.mailfrom=Michael.Roth@amd.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1699024557; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=NI6KHNAQhrYqC2gA5NOfCUoTg8lunEAMJBfDkENyfwo=; b=8Ne1Cwojjw7v63DpVF5j9GVB33X/KFZrHon/slox0k/HWkwlBkR6MnpM/HIBZZaD/nLOiH dZ885A18yaVPY7yZnR8del/UGFJaR9jn4Niz4zAOvTzEG5mOunfTpziN8ToPYfo4s6eHXf 8iQaKlhZaZZKEmX+RTp+PxvbJGS0ps8= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=me0NeXvJTgOpzu+Rp6oPk5GLsSh3to1Yoj/r4ajJlxrMsR9GwjuPoiVlqerx1uCHxGKBisJSsA5SlwdRVqGURdDWPIXECCOj5x3y5xDnDk1jf4IN10hTp/EjYCtBpNBPEyNADHjpHewl2AXGiiTRasODC8gTdkyVe+FpJB0mX6aUYam4nVICPT2uLArrbcQ8gJ115K70Hgp6YtB8cC0vYyWzxmB6nxoZ9NNuCUUN3UPQHS3d5sQ2UFJouctHcaxc1/jB+lZSzL4ua0VCxvTg7OzA6jaiJLEnvD5+YsQGmdSPx5NzYY0e8PDNiFyOIniDixsEhloazbSoYMZ+0x339w== 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=NI6KHNAQhrYqC2gA5NOfCUoTg8lunEAMJBfDkENyfwo=; b=GyXVyKWFGadvLcR7kmjRbe+sxHw9vS5MgURCiuRJj0hsgkzC0MQ3diAjFmOseneKW7C/KHbXr+VkCJLlkiEmcvCEnsvwuy5PT4Czb38p6WZTg+kAGZrjT3ZcyqM5w0JAv4sUqemN4mv9jlRM/BRuX2mFXzlbaoNrQVldl3O7BVjhXSyLS9DvoIfQqJ2jvi1tLbGD1ZJv2/9UtxTlEULCWNB4ImS3It3toFs02BuKSN53kDErOShcj9z4z3YoHd8SvJwIeD7LusSP4Mc7Q1PKWOQN/+RyKX5vJuNvt4qQDHy14WJjk7yE6luZJin/SfsdivCnS5/N8xpiyAjlYaCDug== 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=NI6KHNAQhrYqC2gA5NOfCUoTg8lunEAMJBfDkENyfwo=; b=Az2TYXnkmU8Gv2RMRD68YZ46E/hti3INo8Z2U3XoSPFKCzqu++rIFGGVL6MrrmIDTIEDUOB/MExom1rM4ASDmmX/BY4xvdOZf6sIN9XsJGIWnZqQvUUjOE37vNhrC1J3SFlDpzU7IClQSn8xQuyyC/7/W6/s8TEep6YrKv0FlTM= Received: from MW3PR05CA0021.namprd05.prod.outlook.com (2603:10b6:303:2b::26) by PH0PR12MB8030.namprd12.prod.outlook.com (2603:10b6:510:28d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.21; Fri, 3 Nov 2023 15:15:53 +0000 Received: from MWH0EPF000989E9.namprd02.prod.outlook.com (2603:10b6:303:2b:cafe::32) by MW3PR05CA0021.outlook.office365.com (2603:10b6:303:2b::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6977.10 via Frontend Transport; Fri, 3 Nov 2023 15:15:53 +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 MWH0EPF000989E9.mail.protection.outlook.com (10.167.241.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6954.19 via Frontend Transport; Fri, 3 Nov 2023 15:15:52 +0000 Received: from localhost (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.32; Fri, 3 Nov 2023 10:15:51 -0500 From: Michael Roth To: CC: , , , , Ard Biesheuvel , "Kirill A . Shutemov" , Vlastimil Babka , Nikolay Borisov , , Tom Lendacky , Paolo Bonzini Subject: [PATCH v2] efi/unaccepted: Fix off-by-one when checking for overlapping ranges Date: Fri, 3 Nov 2023 10:13:54 -0500 Message-ID: <20231103151354.110636-1-michael.roth@amd.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] 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: MWH0EPF000989E9:EE_|PH0PR12MB8030:EE_ X-MS-Office365-Filtering-Correlation-Id: bac74ebb-2f42-430f-7705-08dbdc7fc527 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MxYN3tr3BDCRYyTYxlTmV8HHcPeiw2BEZ+OWHINzsIVyTvClfELToyy/7Lwr5oDqLKBkpEPi93n4qzdrev7pDeICq4XoOrBVTF4y9I9x/c/fKYF4yORwpJ5FcP5aVqc10SvPE6aMRHy4TaQeONg6WebiNQgZt9uhtvBqY4j2/3PBmJqwEfpfs/Q6ZNcYXSIoqQgd4PcVJtv5f+kqbk8aPOh1+USECdOjbqgIty6UZpS1OidE4jQP9BClaREtqUseNXIdfT2DphrLmhG9EZRKYPAWUeft+CmdFGwRMNRFJhzQLs9ItFoif4IbcJBEtAkeGPOmJ5FNIe5I+Gt42fkF37xO5RxedYK7T+Q4g/M0wYwOVi28dNCM5PdadiII2NWEVgfFm5Wj1FOP+tDa1hTuZxuXmf9drOnCX3IKEfNcapI9ZCCj4gdcHe5SkmbBWO4QIsTCmeCMIOL1F9x4kjxLCFsE4wgCKDd67UyjRICWc3gsaQsWCJFapmRnya17gyikhZBmbZOrHOVuHN+PLIGITsGnBWfqyb8nfRgKhpG0jqpAwlnvsyxIqjwuLXymqg7dSgBIr+nGsm23jBF0pUk4LRZenqJP9OUcsNecRf/bxs/mL5DqnAV/vyRpjPHySYp7GilPh1UHDMbTn0qKLI5jysb9T/Fmnafe5+OiHI5R7W9zJD5Rk0vTTumJ6BvNFUWyy9dSHcCeHQDGdHNVww9+DkqXwx/tj4E692Kb1vD9qs22V79wru8ym+P5J/BXjT4VEMH9iIdyYefVWwStSkQCgA== 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)(4636009)(39860400002)(396003)(346002)(136003)(376002)(230922051799003)(1800799009)(82310400011)(64100799003)(186009)(451199024)(36840700001)(40470700004)(46966006)(40460700003)(40480700001)(70206006)(54906003)(70586007)(6916009)(316002)(36756003)(86362001)(82740400003)(356005)(81166007)(36860700001)(83380400001)(426003)(478600001)(336012)(16526019)(26005)(1076003)(2616005)(966005)(2906002)(41300700001)(44832011)(47076005)(5660300002)(4326008)(7416002)(8936002)(8676002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2023 15:15:52.6118 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bac74ebb-2f42-430f-7705-08dbdc7fc527 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: MWH0EPF000989E9.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8030 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: EBAD318002B X-Stat-Signature: yohhgwk41t9i7wbg3q9emq1m5zq339rm X-HE-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taXkP4eIH/e4XDXRoVYpi+Y3tKL5Okip/6niaAnTXDGN6kaoQhCk0SFn17xHlWwV+81G/kHPenQnF6dTVY2ssiDiFakZ2UKBvhsqpNx/0mSoJ4LnoGYPYzIWvWHubUREpHuqxv97wEfx5YOIHOlwnQQP8Y2UEmcDb/bW51ZZAI1AU5WVs6m5XWSBbA7soUybzX8sKnL0adnfXntdItmGuko8h3jq1tHtuytb0Rhu+mn4vTz5/BypKcLVF1LwZu5wUpQkp7U+xTmH2hjY2isQ3InRoaazdkrlsYYiU9LJMPNlcm7noRpaPH9q8a4QxmYu3D8h4ToUWdgTYdufwo+Zt2lTDKrj0mROl6zW6BREw/d/j/3Yaf76wSjO06KyeYH0p/PiF3JXQWwLojm12Jug== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: When a task needs to accept memory it will scan the accepting_list to see if any ranges already being processed by other tasks overlap with its range. Due to an off-by-one in the range comparisons, a task might falsely determine that an overlapping range is being accepted, leading to an unnecessary delay before it begins processing the range. Fix the off-by-one in the range comparison to prevent this and slightly improve performance. Fixes: 50e782a86c98 ("efi/unaccepted: Fix soft lockups caused by parallel memory acceptance") Link: https://lore.kernel.org/linux-mm/20231101004523.vseyi5bezgfaht5i@amd.com/T/#me2eceb9906fcae5fe958b3fe88e41f920f8335b6 Reviewed-by: Kirill A. Shutemov Signed-off-by: Michael Roth Acked-by: Vlastimil Babka --- v2: * Improve commit message terminology (Kirill) --- drivers/firmware/efi/unaccepted_memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/firmware/efi/unaccepted_memory.c b/drivers/firmware/efi/unaccepted_memory.c index 135278ddaf62..79fb687bb90f 100644 --- a/drivers/firmware/efi/unaccepted_memory.c +++ b/drivers/firmware/efi/unaccepted_memory.c @@ -100,7 +100,7 @@ void accept_memory(phys_addr_t start, phys_addr_t end) * overlap on physical address level. */ list_for_each_entry(entry, &accepting_list, list) { - if (entry->end < range.start) + if (entry->end <= range.start) continue; if (entry->start >= range.end) continue;