From nobody Fri Dec 19 07:31:07 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51C59C61D85 for ; Tue, 21 Nov 2023 18:37:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234622AbjKUShU (ORCPT ); Tue, 21 Nov 2023 13:37:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234561AbjKUShM (ORCPT ); Tue, 21 Nov 2023 13:37:12 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB6E710CF for ; Tue, 21 Nov 2023 10:37:03 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 15255C433C9; Tue, 21 Nov 2023 18:37:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700591823; bh=xBeqzteKzjRFD7AK4f9XGIWZHMzDuTSTe3bPhMPVydE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XW+n6C08SNh+kInRoEGKqDrPEzsmS4/A230SA1t1ygBldR47hQJaz0mYmCkCFf3p0 VrlzzKWr2unKQkxS6rU6CxyBKOq0P0Lp5flZeYXdFimOWl4kV+FpiFji8iVt8Rt+8A cHtXR8Vb+F6VjpGZI3o8NDdtV8Igl4BtI5oHyRVrP7milTrTWKXU8xJuavzoe3gjzL RuIxdCWCnwiUlQhcZQK62gh3kKt95dBx1SBBZSOyt+BIfFDbGN5z/+GheND+w3YSzi FlGBrovDFtly2OWiWeSgTl3voaQ5JsTVvHXdlOm8Z0MuYaezO9iYSPqUKozVF5kscx wvJh13DDHuRbA== From: Bjorn Helgaas To: linux-pci@vger.kernel.org Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H . Peter Anvin" , "Rafael J . Wysocki" , Dan Williams , Kan Liang , Tony Luck , Giovanni Cabiddu , Yunying Sun , Tomasz Pala , Sebastian Manciulea , linux-kernel@vger.kernel.org, Bjorn Helgaas Subject: [PATCH 7/9] x86/pci: Comment pci_mmconfig_insert() obscure MCFG dependency Date: Tue, 21 Nov 2023 12:36:41 -0600 Message-Id: <20231121183643.249006-8-helgaas@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231121183643.249006-1-helgaas@kernel.org> References: <20231121183643.249006-1-helgaas@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Bjorn Helgaas In pci_mmconfig_insert(), there's no reference to "addr" between locking pci_mmcfg_lock and testing "addr", so it *looks* like we should move the test before the lock. But 07f9b61c3915 ("x86/PCI: MMCONFIG: Check earlier for MMCONFIG region at address zero") did that, which broke things by returning -EINVAL when "addr" is zero instead of -EEXIST. So 07f9b61c3915 was reverted by 67d470e0e171 ("Revert "x86/PCI: MMCONFIG: Check earlier for MMCONFIG region at address zero""). Add a comment about this issue to prevent it from happening again. Signed-off-by: Bjorn Helgaas --- arch/x86/pci/mmconfig-shared.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/pci/mmconfig-shared.c b/arch/x86/pci/mmconfig-shared.c index b36c10e86505..459e95782bb1 100644 --- a/arch/x86/pci/mmconfig-shared.c +++ b/arch/x86/pci/mmconfig-shared.c @@ -786,6 +786,10 @@ int pci_mmconfig_insert(struct device *dev, u16 seg, u= 8 start, u8 end, return -EEXIST; } =20 + /* + * Don't move earlier; we must return -EEXIST, not -EINVAL, if + * pci_mmconfig_lookup() finds something + */ if (!addr) { mutex_unlock(&pci_mmcfg_lock); return -EINVAL; --=20 2.34.1