Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3767506rdh; Tue, 28 Nov 2023 03:25:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IGRuCuxqJhIXc5Hh/yAx0MMO2IEkL1hkp1phBnVlwgCXqFotDroT8tZHNZ0qZa3XKrLKp/J X-Received: by 2002:a05:6a00:2daa:b0:693:3851:bd3e with SMTP id fb42-20020a056a002daa00b006933851bd3emr15720090pfb.3.1701170742018; Tue, 28 Nov 2023 03:25:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701170742; cv=none; d=google.com; s=arc-20160816; b=F43Ds6E34sGmUFtK+jfiaNLPtR3uAEdnERRdP7ZSYLWC7u/rCf8k5cVxEqHx2vwtIG v+nWlLQtzy+eEUxCpY4XmNd0+vwVTBMohVxihDT32U9eXdm1g9wkgrm4Ah6yeX36etba +It75e/H2aOqX1LSN7lU4rgb59Ri/lWRiKtUrYNOkW5W2pZ91/X18x2wbhpaX7FJ58tQ IjrTJ2NvU5Zc8c7/ix5eesVuBX15IYmv8+Sz705S+dimyfFh83qAl+qyCXsG2rFMu6sa A5zyudBrHJXn9rwsXA5D9JAQBU24/VOKMoBs9zABquA0z143kgo2ThX40kjX1doY7a6a boeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-signature; bh=OgMlDqCEMti1tWEV4w0pWYe9MRlT/WzXID9W1NpeXw0=; fh=oUjaDhvPUzvaQXg7bvL2L16Ark5tO5HMn/d7ctOXy58=; b=wuinIP79YRKV57scDPDsUxx2GXj0sbX1rfphCW46a+CI6ILZu74QxNfHTkm5Vlsor1 ae0GP1CxwjLOu0RPk/FnNZsMO1OOekY2rEim2VqdQJrckbHArBFmfsG5xXE8Oc9wiFOh NYXrHO4cKTc94X8TRQR207H47V8Oq6hi2nOmKuW6/MO0zq1zQiz99arQIPsW9ItePA3i M7MMfbZInBKhh4tKqJ/Hy+TOcDGH3H8tb3BGy8EmYc3U2aff6j081orxjpa0L/qpFZVR CNlux8rovTYeRYlbId29UPerz33PJLiTVBSFSeNCpvrLBVMb5/tD5jrtIvf99/nd0maO Jj9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=BbbKWMmm; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id x16-20020a62fb10000000b006cc01aa0480si7686268pfm.370.2023.11.28.03.25.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 03:25:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=BbbKWMmm; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id C38AB804B01B; Tue, 28 Nov 2023 03:25:40 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344458AbjK1LZ2 (ORCPT + 99 others); Tue, 28 Nov 2023 06:25:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344558AbjK1LZZ (ORCPT ); Tue, 28 Nov 2023 06:25:25 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB8AAD60; Tue, 28 Nov 2023 03:25:30 -0800 (PST) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 1B0A82195A; Tue, 28 Nov 2023 11:25:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1701170729; h=from:from:reply-to: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:in-reply-to:references:references; bh=OgMlDqCEMti1tWEV4w0pWYe9MRlT/WzXID9W1NpeXw0=; b=BbbKWMmmKaQrhIyb2KL6NpH9DDIGUGVP+hPGD5QCUcS6X4Hr0oBnRDuf1b3xRaZpxJitkm nx8r/gv7jLOAO9h8sIRcCLGDv1rhNgqWuWHGJ7ah3cxLK7G1MZtthXRtKbUzAphJfJYWCL 27Ab0kO7Q7aTIYNxJI5IumkJ30JCpcc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1701170729; h=from:from:reply-to: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:in-reply-to:references:references; bh=OgMlDqCEMti1tWEV4w0pWYe9MRlT/WzXID9W1NpeXw0=; b=OqOvDLmLGZwIjekxgW6yZGcd83xjaN7OTKoc4Bz+CG9jrO4cHbkIF7FMgGnxkr0wQoGRZZ CnZbmSG5J27X0OBA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id F21441343E; Tue, 28 Nov 2023 11:25:28 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id isDDOijOZWUIAwAAD6G6ig (envelope-from ); Tue, 28 Nov 2023 11:25:28 +0000 Message-ID: <9be0159e-1762-6c07-e6eb-a86f1c780118@suse.cz> Date: Tue, 28 Nov 2023 12:25:28 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH v2] efi/unaccepted: Fix off-by-one when checking for overlapping ranges Content-Language: en-US To: Ard Biesheuvel Cc: Michael Roth , linux-efi@vger.kernel.org, x86@kernel.org, linux-coco@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Kirill A . Shutemov" , Nikolay Borisov , stable@kernel.org, Tom Lendacky , Paolo Bonzini References: <20231103151354.110636-1-michael.roth@amd.com> <30ff0335-3d9c-7d54-85d0-5898320f4e1f@suse.cz> From: Vlastimil Babka In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Authentication-Results: smtp-out1.suse.de; none X-Spam-Score: 3.21 X-Spamd-Result: default: False [3.21 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.19)[-0.959]; NEURAL_SPAM_LONG(3.50)[0.999]; RCPT_COUNT_TWELVE(0.00)[12]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; MID_RHS_MATCH_FROM(0.00)[] X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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]); Tue, 28 Nov 2023 03:25:40 -0800 (PST) On 11/8/23 12:21, Ard Biesheuvel wrote: > On Fri, 3 Nov 2023 at 16:30, Vlastimil Babka wrote: >> >> On 11/3/23 16:13, Michael Roth wrote: >> > 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 >> >> More justification for introducing a common ranges_overlap() helper somewhere :) >> >> Acked-by: Vlastimil Babka >> > > Thanks, I'll take this as a fix. Ping, can't see it in mainline nor -next? > >> > --- >> > 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; >> >