Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp564227rdf; Fri, 3 Nov 2023 08:31:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFFj5eh1i7/Y4nS/KGb8AdG8ULZCG4HdLSwtG5ez8fyx7X+7OLK0wamhKh5onQWAMYEJoIk X-Received: by 2002:a17:902:d4c8:b0:1cc:5392:3ef4 with SMTP id o8-20020a170902d4c800b001cc53923ef4mr14803672plg.21.1699025476741; Fri, 03 Nov 2023 08:31:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699025476; cv=none; d=google.com; s=arc-20160816; b=SI2L89D2qD4aAky6zPjIqH+aYEcD5vdYB3YNoNlae7ux3L0Us7I3HxNFXVBUHdUB9Q NVWmDmP1fHPm0uak3oDsexeoYhFkpPxp7Fxr6oDkLGhQdx77IGOGjVqfR8Enpo1Y5Naw P5fi6wkHwqksuqljRiKjI4HSZqgmaJsq3s0hVgUJc4o6nPZ9DOFmj9+XRcJ2kLujMD8z ZR1YN/NeIW+xhJFOPKDoVNfLFGB6yau/OMR8ZX8DRlOQi2H53wXQoTzmRRI4LoBkVkJE BfSkPtLz+nPXXBB4qykyt0Z005Pam5sQ8+BFPhOVnUwqMDy5JyiSCFLisX+gwBb59E58 KElw== 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=3ndJlZNeRg8eKoYiLSU2ZDnHkOEBvKilrv71pM5TEHQ=; fh=phoyWNdhP16OmN+W3S8Vc9hlKgpzJPpTW61lZ0r/kCU=; b=Q2vWAmw5i4fhzS9zTwrM4P8oJvjAuBjqY31rwdzWtipQ1+7Vlr9YD3hq+FXHgumK5P PffbWq5f6ZUAqo1/T/AvzC14quAfoCUJ94msn1j8kQ8ZtIwbg9hPIEAmCGXpFFO5FaW7 H8sgG/JrWtLroGMv4EvtfKYLxf7F4U3+UOAuqO7iH+237zrxQxWfhAw/lqik/LLwHCVR Fjb7yzZ/HdE1Q79D0NY6wEbkG8fbPs4M85MQxIq9gtJihIOju6qePUrmBG88+lkpjZOa /9Naz3blod7yh7+r99GRWL04AMjEXzjri/t6rempIxtZc/5VPawAs4W4Zx33MFFZhY4E QinQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=btC9ro5T; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=kQYiL6DM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id li8-20020a170903294800b001cc453f5178si1654022plb.439.2023.11.03.08.31.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 08:31:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=btC9ro5T; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=kQYiL6DM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id AE43A8038DA6; Fri, 3 Nov 2023 08:30:31 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234042AbjKCPaL (ORCPT + 99 others); Fri, 3 Nov 2023 11:30:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230151AbjKCPaK (ORCPT ); Fri, 3 Nov 2023 11:30:10 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59D50123; Fri, 3 Nov 2023 08:30:04 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 90B151F45F; Fri, 3 Nov 2023 15:30:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1699025402; 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=3ndJlZNeRg8eKoYiLSU2ZDnHkOEBvKilrv71pM5TEHQ=; b=btC9ro5TApirS1T623+HZinf3RTH+Pr6sUlcv2WbzFkewFb2iP6H97tHserzzu7QeK3Qqk kjuyzEBNJ6Kd+/ZdjatxwSSgy6wzdOkj+YIZDGPFx/QoQq/TSgi3GZ9CJilOOOtIFMEHqR 33UBZbma1qFK8dvb3xN3kDXMtdWhg/E= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1699025402; 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=3ndJlZNeRg8eKoYiLSU2ZDnHkOEBvKilrv71pM5TEHQ=; b=kQYiL6DMJFovIRAOGp9iw+gax6ypZhYnLXxhAnWdaYZtYb+JBN32JmpfGaeO8H0T7+OiR6 IJsM0V9nmalFQSCQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 53EED1348C; Fri, 3 Nov 2023 15:30:02 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id Dv9JE/oRRWU8LwAAMHmgww (envelope-from ); Fri, 03 Nov 2023 15:30:02 +0000 Message-ID: <30ff0335-3d9c-7d54-85d0-5898320f4e1f@suse.cz> Date: Fri, 3 Nov 2023 16:30:01 +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: Michael Roth , linux-efi@vger.kernel.org Cc: x86@kernel.org, linux-coco@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Ard Biesheuvel , "Kirill A . Shutemov" , Nikolay Borisov , stable@kernel.org, Tom Lendacky , Paolo Bonzini References: <20231103151354.110636-1-michael.roth@amd.com> From: Vlastimil Babka In-Reply-To: <20231103151354.110636-1-michael.roth@amd.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email 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 (groat.vger.email [0.0.0.0]); Fri, 03 Nov 2023 08:30:32 -0700 (PDT) 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 > --- > 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;