Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp521707rdf; Fri, 3 Nov 2023 07:29:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGlC6y1h5f2eVv4x1ImGP07zruawtIhpq+gGe9/VQQ/UGEUsoKNjQvPnXd0l0QxqZWXCJNb X-Received: by 2002:a17:902:ce8e:b0:1cc:636f:f38a with SMTP id f14-20020a170902ce8e00b001cc636ff38amr11946373plg.57.1699021752159; Fri, 03 Nov 2023 07:29:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1699021752; cv=pass; d=google.com; s=arc-20160816; b=Q2NlnTtf6/pPJ9Ez2jcJlUiKtbYIdUeAqgKhAU2isJV6PaarcfRTVZM+HUGt+OlM7o 9K0wH3oAeRkyd1QtyK96l9QF3oBXpbj66nhSpFFGMzOSbkWqeQEomdFm3EPFtKlkH9i8 ygjLZWlXeHMulw4Y0Jm0nHWeXCM+gHpOhhLzerBot1eP/NQT9mzVBeuNrSPxV9cF71R3 OrEXUdVdyXt9Sd+H+mcBXgZZ6E3fg7vCZM3pI+o0EfheiJ2KsVZaeSIEtXwJCfauZcoh diUffVqPYxZd57H2ymbyUe8QHYUUu3ghGEgyq+akTiO6hWY1qSmFpi08YdBKXc/Imt3b qpkA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=XZaZ+wpf7eO/sfOl3udrQpzg2LYAtrdB8e2N4pjMP70=; fh=nGImq+mDeX7AtHO/YYfRXLGAgAk7mD49iTPpXOUEdkI=; b=t4u43WgsUm6crllFGGtVpzPAme4R1ZUn4nVplfwYC4DP8BiLhDci/gBcIZMuuQCpLK gnhRHbx3Cdg0K4Dc+nezwuapFmCaHGnLNpToxUqm87iJau67SHixgA1F6aE5zetDLFNB Dx45mnHqA4FuFqQy9OicOMKDkVQuygThLqsPyKt38UnbeJ7QrkbgXLeJnykMuYwYkbW3 cz/TvnSbqdKIin4ecA0TVrENPHb5g5e5Wi8JY4YRzn+d0428cns0KUOBhXf77Q1mbrWc vQpY64mMK6io31C9Zvcfvgui+7fwkdzMRtfJY3hcMV5AseO6epa2t9tGHeAmGyIWgGsV hI8w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=s2UDS4om; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id i4-20020a17090332c400b001cc5388a904si1676837plr.213.2023.11.03.07.29.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 07:29:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=s2UDS4om; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 2D94582F7FB7; Fri, 3 Nov 2023 07:29:11 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377788AbjKCO3K (ORCPT + 99 others); Fri, 3 Nov 2023 10:29:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377761AbjKCO3J (ORCPT ); Fri, 3 Nov 2023 10:29:09 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2059.outbound.protection.outlook.com [40.107.243.59]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6266DD43; Fri, 3 Nov 2023 07:29:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FXJLM02PFZqLp8gb4zlK3Ok5aihroKz1euPB+PEymAjMQktRELojtqYXYhbl5Jt4pv5xMq/9zKFjm2lAQ0n26ImAy66G/lq5pzTlqH3wyDuVR9MlY6rR24uUb1cXg3t8YzAWP+7HtciJAJWa2PnDZEU6UCyC8Z4Gm7Rzy9yQwtbp6N0JCUKnG51shWM5ayEJIF8geH1wv25MNb8+P0BqspoHrbiSGObmBtHgorQjiZOX4F5Pn854uYx+YPhE2QNzkRv5ePBknq8GAhRj4d3hALV5R0sw3eb1oPT4hy51GNND/SaEwckeqVjrlM05Y6wDtebbLhg5q1J64y+03DgCqw== 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=XZaZ+wpf7eO/sfOl3udrQpzg2LYAtrdB8e2N4pjMP70=; b=RN7mVxOimFFOTNJ4Nq4GCD5VU/+zojBkG28VlpEgrM5ZQKm6RVKXwSjS+7JV/taP0RvIi6WxFN1NfXKn68erMWvYRZKflVZLH8ZVkKq7/o2b9lPafeCOgFG7v7XQGTpzHpAPrFNAkgAToMYGBtyZFl45oA85EU8P9+IIaiHX9gCEzZmBxpIpL1W9onTCNs4wUaZSHr/HbtWpvZbx7mhQ08DhsvXj8pUTqFJeCmczQlluYjcD9S/KG4JR+aVW0Bzde2nyzU0co09iLC+jzEFkBmXbbM7dPP/66RpL/AoNHQl3JS+80MRbvAq9WVI+tKzQEXU7xQDhzTrRCwuUKJyyJA== 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=XZaZ+wpf7eO/sfOl3udrQpzg2LYAtrdB8e2N4pjMP70=; b=s2UDS4omXBBE5AOMwKQ9kc8UWb289T+N8I1pgh0/U/tr8qUi3DNww4tNWzTkasuLRKeYXEGEVCCWYXBwVfXtLg0isFdFzfinx+wKsrkEI+Td2TPkk22i5mVBGEV+5QdROrtdgQ58MymJGZRRnpLYNbjQBEbFFYISFMwas4qDvr8= Received: from CY5P221CA0019.NAMP221.PROD.OUTLOOK.COM (2603:10b6:930:b::32) by PH8PR12MB6938.namprd12.prod.outlook.com (2603:10b6:510:1bd::8) 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 14:28:59 +0000 Received: from CY4PEPF0000FCC4.namprd03.prod.outlook.com (2603:10b6:930:b:cafe::a7) by CY5P221CA0019.outlook.office365.com (2603:10b6:930:b::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.22 via Frontend Transport; Fri, 3 Nov 2023 14:28:59 +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 CY4PEPF0000FCC4.mail.protection.outlook.com (10.167.242.106) 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 14:28:58 +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 09:28:58 -0500 From: Michael Roth To: CC: , , , , Ard Biesheuvel , "Kirill A . Shutemov" , Vlastimil Babka , Nikolay Borisov , , Tom Lendacky , Paolo Bonzini Subject: [PATCH] efi/unaccepted: Fix off-by-one when checking for overlapping ranges Date: Fri, 3 Nov 2023 09:26:50 -0500 Message-ID: <20231103142650.108394-1-michael.roth@amd.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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: CY4PEPF0000FCC4:EE_|PH8PR12MB6938:EE_ X-MS-Office365-Filtering-Correlation-Id: ee7eac60-6075-4b30-4a2b-08dbdc7937fd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Cg/+pnqPrz0UArUqlV/Nceny0HdiGC4eAyHCf6RAApgagy/Sm4e63J0+kBRA9n0Y7sADbS1y6L6RUvIbfg1kIvni2h6CFKf3BehlWZv+rjv68ZaiA3HuiaNcRwtEMxXnmrfcn3MmH8QFGh3Jk7kHghLeerUBQ/RovbbrTfxtDwtwRdjANs2nJKM74XTY0YBVFhDuAnkqNRlm1Sh+vxHZmgBH8m4IQXg4BFgta9gVaAgnJJsbYxEUeE1wnWN5X5spw2yiw0fk/dRLpbqbRx2+YtXE8g18MalFTjoQukdk468IWWZOeSPud5A4o4PxjAMoBZggoc6dciXA/Au2vdjhUnGeRKiwfu05vtHhEApWHK93RITf4EBFnc+6NZ4TJbFAlUexf+lby3w1Ll6DlXJ2u0DKPAh8eAuoJCADQAPPNQpkvwp9ClqwO6ucixLx4B8fjpp/UyIWjctjCJo5Pied5T1+L0EaCzglrCoDAPF0WN+MurPeX8crlm87A3M5Uj9cbWw47swfqh539t//Ybde/+7OA0KN4q9MsxaIhC8LqRl/qVSdTd4Rlf59t+30PAAG9A+kkVP4Qg722miYsWlOynUkjnMJM9xxwfDfmkf9rWhC733H32f2KU3luKecJp1VInUg+kv7ejsKDxV1iwO9seXXgTGtONn6ZcdqtEM0i3P95AoINV9VKK5lYGQGzQxTZZWRp23XPO19EYdNKhJURgPbAX8oGdBKo2EKkcvn7WuOuBN8Gxyu8iZfpPVMS0tH 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)(396003)(39860400002)(376002)(346002)(136003)(230922051799003)(82310400011)(64100799003)(451199024)(1800799009)(186009)(40470700004)(46966006)(36840700001)(336012)(16526019)(6916009)(316002)(70586007)(1076003)(70206006)(40460700003)(54906003)(2616005)(40480700001)(2906002)(426003)(26005)(36756003)(6666004)(478600001)(966005)(36860700001)(86362001)(4326008)(8936002)(8676002)(44832011)(41300700001)(356005)(81166007)(82740400003)(83380400001)(47076005)(5660300002)(7416002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2023 14:28:58.9057 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ee7eac60-6075-4b30-4a2b-08dbdc7937fd 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: CY4PEPF0000FCC4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB6938 X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 03 Nov 2023 07:29:11 -0700 (PDT) When a thread needs to accept memory it will scan the accepting_list to see if any ranges already being processed by other threads overlap with its range. Due to an off-by-one in the range comparisons, a thread 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 Signed-off-by: Michael Roth --- 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; -- 2.25.1