Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp8229009rwl; Tue, 10 Jan 2023 10:33:26 -0800 (PST) X-Google-Smtp-Source: AMrXdXu8iGfWFCjyKNvmDr5eNYAlCJ2VmwFkvR7HPF6yXf5H5l0iwzlVAeNIZJLian//GNhuoE3/ X-Received: by 2002:a17:907:d109:b0:818:3f54:8df7 with SMTP id uy9-20020a170907d10900b008183f548df7mr77374756ejc.2.1673375606677; Tue, 10 Jan 2023 10:33:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673375606; cv=none; d=google.com; s=arc-20160816; b=Vo8yLsUvNyPulSn2X4KPU8K2EiBPoyDy9Nrck3UBoonqc5YO2oF1Uv9qStw/B8lToc VdyB+CWvtEbqogACs1wIMJ9V2LU2hO5b8+rAhyZq712iNFqBVoYJzMD5Pj+SedYdiZBL 2nd7cBEroS/XtCVKQnx1D1td0dyx55QqgHQqK3hSmU6TGPjPT/70tg29/llpZ58CS5qV fsU2DwlB/CbBlpmmPT4Pk/rD3q4Wtqvv827QHZlR7RQTIwDsTuPP9VzbfXK33slsUL5a GgC9mvkIr22ajJSO4knwZfM9qYtmh+Pkqr4wElX5o33a2Xui/KCcbSeCi7Az16LqqSAX zw5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Ixf0vYtJ46V28I9oq8aPLpwv2uooaIITQPsZwWr3UIA=; b=Hw6AsnM07LPAu3W7ABI/PMazCx+a5qycgQYCooCaTgsecPZvswktcw2eJ5PMXkVk2I Z4HCFkX1tOkjoi/DoglMCkOY9sGe6Klj76nhuEXOT9aL0xkdHxToS9rJFa8cvo6kaPhO WljiRQQW8OrtDtdYA/cgZyWQGbmlyRpM2tCVT1WXQS/8YeOB/+EVEFaLIsMZkwKT3gMz W/3l+DXyacwNiB4wptZxc0fsiN+Fkc5dYWsQ9CusmZof751ElplYPKs8u36/AaPuhmJp s7dOp2iBxX4MH7pVkrRwXJTfse3kemuiB/FH/LIQCRfb/KE/I8tE4yF4rTFIi55GI0mH S04w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qw10-20020a1709066a0a00b0080f0493b9c2si11550112ejc.249.2023.01.10.10.33.13; Tue, 10 Jan 2023 10:33:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239189AbjAJSSO (ORCPT + 55 others); Tue, 10 Jan 2023 13:18:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239185AbjAJSR1 (ORCPT ); Tue, 10 Jan 2023 13:17:27 -0500 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D59D6DEF; Tue, 10 Jan 2023 10:15:54 -0800 (PST) Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.1.0) id f305e4161af3989d; Tue, 10 Jan 2023 19:15:52 +0100 Received: from kreacher.localnet (unknown [213.134.183.108]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by v370.home.net.pl (Postfix) with ESMTPSA id 113FD262495C; Tue, 10 Jan 2023 19:15:51 +0100 (CET) From: "Rafael J. Wysocki" To: linux-pci@vger.kernel.org, Bjorn Helgaas Cc: Dan J Williams , Kan Liang , Tony Luck , David E Box , Yunying Sun , Dave Jiang , Mika Westerberg , Giovanni Cabiddu , Herbert Xu , Hans de Goede , Florent DELAHAYE , Konrad J Hambrick , Matt Hansen <2lprbe78@duck.com>, Nicholas Johnson , Benoit =?ISO-8859-1?Q?Gr=E9goire?= , Werner Sembach , mumblingdrunkard@protonmail.com, linux-kernel@vger.kernel.org, Bjorn Helgaas Subject: Re: [PATCH 2/2] x86/pci: Treat EfiMemoryMappedIO as reservation of ECAM space Date: Tue, 10 Jan 2023 19:15:50 +0100 Message-ID: <1860250.tdWV9SEqCh@kreacher> In-Reply-To: <20230110180243.1590045-3-helgaas@kernel.org> References: <20230110180243.1590045-1-helgaas@kernel.org> <20230110180243.1590045-3-helgaas@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 213.134.183.108 X-CLIENT-HOSTNAME: 213.134.183.108 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvhedrledvgdeglecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpeefudduuedtuefgleffudeigeeitdeufeelvdejgefftdethffhhfethfeljefgteenucffohhmrghinhepkhgvrhhnvghlrdhorhhgnecukfhppedvudefrddufeegrddukeefrddutdeknecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvddufedrudefgedrudekfedruddtkedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohepvddupdhrtghpthhtoheplhhinhhugidqphgtihesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehhvghlghgrrghssehkvghrnhgvlhdrohhrghdprhgtphhtthhopegurghnrdhjrdifihhllhhirghmshesihhnthgvlhdrtghomhdprhgtphhtthhopehkrghnrdhlihgrnhhgsehlihhnuhigrdhi nhhtvghlrdgtohhmpdhrtghpthhtohepthhonhihrdhluhgtkhesihhnthgvlhdrtghomhdprhgtphhtthhopegurghvihgurdgvrdgsohigsehinhhtvghlrdgtohhmpdhrtghpthhtohephihunhihihhnghdrshhunhesihhnthgvlhdrtghomhdprhgtphhtthhopegurghvvgdrjhhirghnghesihhnthgvlhdrtghomhdprhgtphhtthhopehmihhkrgdrfigvshhtvghrsggvrhhgsehlihhnuhigrdhinhhtvghlrdgtohhmpdhrtghpthhtohepghhiohhvrghnnhhirdgtrggsihguughusehinhhtvghlrdgtohhmpdhrtghpthhtohephhgvrhgsvghrthesghhonhguohhrrdgrphgrnhgrrdhorhhgrdgruhdprhgtphhtthhopehhuggvghhovgguvgesrhgvughhrghtrdgtohhmpdhrtghpthhtoheplhhinhhugihkvghrnhgvlhhmlhesuhhnuggvrggurdhfrhdprhgtphhtthhopehkjhhhrghmsghrihgtkhesghhmrghilhdrtghomhdprhgtphhtthhopedvlhhprhgsvgejkeesughutghkrdgtohhmpdhrtghpthhtohepnhhitghhohhlrghsrdhjohhhnhhsohhnqdhophgvnhhsohhurhgtvgesohhuthhlohhokhdrtghomhdrrghupdhrtghpthhtohepsggvnhhoihhtghestghovghushdrtggrpdhrtghpthhtohepfihsvgesthhugigvughotghomhhpuhhtvghrshdrtghomhdprhgtphhtthhopehmuhhmsghlihhnghgurhhunhhkrghrugesphhrohhtohhnmhgrihhlrdgtohhmpdhrtghpthhtoheplhhinhhugidqk hgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepsghhvghlghgrrghssehgohhoghhlvgdrtghomh X-DCC--Metrics: v370.home.net.pl 1024; Body=21 Fuz1=21 Fuz2=21 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS 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 On Tuesday, January 10, 2023 7:02:43 PM CET Bjorn Helgaas wrote: > From: Bjorn Helgaas > > Normally we reject ECAM space unless it is reported as reserved in the E820 > table or via a PNP0C02 _CRS method (PCI Firmware, r3.3, sec 4.1.2). This > means PCI extended config space (offsets 0x100-0xfff) may not be accessible. > > Some firmware doesn't report ECAM space via PNP0C02 _CRS methods, but does > mention it as an EfiMemoryMappedIO region via EFI GetMemoryMap(), which is > normally converted to an E820 entry by a bootloader or EFI stub. > > 07eab0901ede ("efi/x86: Remove EfiMemoryMappedIO from E820 map"), removes > E820 entries that correspond to EfiMemoryMappedIO regions because some > other firmware uses EfiMemoryMappedIO for PCI host bridge windows, and the > E820 entries prevent Linux from allocating BAR space for hot-added devices. > > Allow use of ECAM for extended config space when the region is covered by > an EfiMemoryMappedIO region, even if it's not included in E820 or PNP0C02 > _CRS. > > Reported by Kan Liang, Tony Luck, and Giovanni Cabiddu. > > Fixes: 07eab0901ede ("efi/x86: Remove EfiMemoryMappedIO from E820 map") > Link: https://lore.kernel.org/r/ac2693d8-8ba3-72e0-5b66-b3ae008d539d@linux.intel.com > Reported-by: Kan Liang > Reported-by: Tony Luck > Reported-by: Giovanni Cabiddu > Signed-off-by: Bjorn Helgaas Reviewed-by: Rafael J. Wysocki > --- > arch/x86/pci/mmconfig-shared.c | 31 +++++++++++++++++++++++++++++++ > 1 file changed, 31 insertions(+) > > diff --git a/arch/x86/pci/mmconfig-shared.c b/arch/x86/pci/mmconfig-shared.c > index cd16bef5f2d9..da4b6e8e9df0 100644 > --- a/arch/x86/pci/mmconfig-shared.c > +++ b/arch/x86/pci/mmconfig-shared.c > @@ -12,6 +12,7 @@ > */ > > #include > +#include > #include > #include > #include > @@ -442,6 +443,32 @@ static bool is_acpi_reserved(u64 start, u64 end, enum e820_type not_used) > return mcfg_res.flags; > } > > +static bool is_efi_mmio(u64 start, u64 end, enum e820_type not_used) > +{ > +#ifdef CONFIG_EFI > + efi_memory_desc_t *md; > + u64 size, mmio_start, mmio_end; > + > + for_each_efi_memory_desc(md) { > + if (md->type == EFI_MEMORY_MAPPED_IO) { > + size = md->num_pages << EFI_PAGE_SHIFT; > + mmio_start = md->phys_addr; > + mmio_end = mmio_start + size; > + > + /* > + * N.B. Caller supplies (start, start + size), > + * so to match, mmio_end is the first address > + * *past* the EFI_MEMORY_MAPPED_IO area. > + */ > + if (mmio_start <= start && end <= mmio_end) > + return true; > + } > + } > +#endif > + > + return false; > +} > + > typedef bool (*check_reserved_t)(u64 start, u64 end, enum e820_type type); > > static bool __ref is_mmconf_reserved(check_reserved_t is_reserved, > @@ -513,6 +540,10 @@ pci_mmcfg_check_reserved(struct device *dev, struct pci_mmcfg_region *cfg, int e > "MMCONFIG at %pR not reserved in " > "ACPI motherboard resources\n", > &cfg->res); > + > + if (is_mmconf_reserved(is_efi_mmio, cfg, dev, > + "EfiMemoryMappedIO")) > + return true; > } > > /* >