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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8258AC2D0CD for ; Wed, 21 May 2025 16:02:31 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.992130.1375906 (Exim 4.92) (envelope-from ) id 1uHltX-00041I-AI; Wed, 21 May 2025 16:02:15 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 992130.1375906; Wed, 21 May 2025 16:02:15 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uHltX-00041B-7p; Wed, 21 May 2025 16:02:15 +0000 Received: by outflank-mailman (input) for mailman id 992130; Wed, 21 May 2025 16:02:14 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uHltW-000415-2G for xen-devel@lists.xenproject.org; Wed, 21 May 2025 16:02:14 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.96) (envelope-from ) id 1uHltV-0062Uo-23; Wed, 21 May 2025 16:02:13 +0000 Received: from [15.248.2.235] (helo=[10.24.67.107]) by xenbits.xenproject.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uHltV-007167-0h; Wed, 21 May 2025 16:02:13 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:Cc:To:Subject:MIME-Version:Date:Message-ID; bh=ofZ0TmNT3UO0L4t2n85+JQXYCvXKSh2/A6Pr2hwNnjw=; b=PghmeuUv6QzJZe1VKeSBeRjxED rSqA1muEOe6BCiMXwOp5uQV6ywjrw8bs8sMEnDxNnlot/f/LKE58zx3/KzJIzm1LOgQHWrVkJGh3p 0hswl2UIwKZPPhKcLPixD3ZhLiGougKl6bUwsOOdZjDy7yo9ukCGsR/nSqMn6ujJJC88=; Message-ID: <55778d7c-e559-4ae3-a6f6-cb74e6e1d1a8@xen.org> Date: Wed, 21 May 2025 17:02:10 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] x86/vpci: fix handling of BAR overlaps with non-hole regions Content-Language: en-GB To: Roger Pau Monne , xen-devel@lists.xenproject.org Cc: Stefano Stabellini , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Jan Beulich , Andrew Cooper , Stefano Stabellini , Victor M Lira References: <20250516083159.61945-1-roger.pau@citrix.com> From: Julien Grall In-Reply-To: <20250516083159.61945-1-roger.pau@citrix.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi Roger, On 16/05/2025 09:31, Roger Pau Monne wrote: > For once the message printed when a BAR overlaps with a non-hole regions is > not accurate on x86. While the BAR won't be mapped by the vPCI logic, it > is quite likely overlapping with a reserved region in the memory map, and > already mapped as by default all reserved regions are identity mapped in > the p2m. Fix the message so it just warns about the overlap, without > mentioning that the BAR won't be mapped, as this has caused confusion in > the past. > > Secondly, when an overlap is detected the BAR 'enabled' field is not set, > hence other vPCI code that depends on it like vPCI MSI-X handling won't > function properly, as it sees the BAR as disabled, even when memory > decoding is enabled for the device and the BAR is likely mapped in the > p2m. Change the handling of BARs that overlap non-hole regions to instead > remove any overlapped regions from the rangeset, so the resulting ranges to > map just contain the hole regions. This requires introducing a new > pci_sanitize_bar_memory() that's implemented per-arch and sanitizes the > address range to add to the p2m. > > For x86 pci_sanitize_bar_memory() removes any regions present in the host > memory map, for ARM this is currently left as a dummy handler to not change > existing behavior. > > Ultimately the above changes should fix the vPCI MSI-X handlers not working > correctly when the BAR that contains the MSI-X table overlaps with a > non-hole region, as then the 'enabled' BAR bit won't be set and the MSI-X > traps won't handle accesses as expected. > > Reported-by: Stefano Stabellini > Fixes: 53d9133638c3 ('pci: do not disable memory decoding for devices') > Signed-off-by: Roger Pau Monné > Tested-by: Victor M Lira Acked-by: Julien Grall Cheers, -- Julien Grall