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 713A2FF885A for ; Mon, 4 May 2026 12:36:51 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.1299759.1574305 (Exim 4.92) (envelope-from ) id 1wJsXO-0008JL-LG; Mon, 04 May 2026 12:36:38 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 1299759.1574305; Mon, 04 May 2026 12:36:38 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wJsXO-0008JE-Hr; Mon, 04 May 2026 12:36:38 +0000 Received: by outflank-mailman (input) for mailman id 1299759; Mon, 04 May 2026 12:36:37 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wJsXN-0008J8-PL for xen-devel@lists.xenproject.org; Mon, 04 May 2026 12:36:37 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wJsXM-00AD9B-TQ for xen-devel@lists.xenproject.org; Mon, 04 May 2026 14:36:36 +0200 Received: from [10.42.69.7] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 69f892d4-e002-0a2a0a5209dd-0a2a45078104-0 for ; Mon, 04 May 2026 14:36:36 +0200 Received: from [209.85.128.48] (helo=mail-wm1-f48.google.com) by tlsNG-ef75cf.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 69f892d4-229c-0a2a45070019-d1558030e85a-3 for ; Mon, 04 May 2026 14:36:36 +0200 Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-488ff90d6c7so38349935e9.2 for ; Mon, 04 May 2026 05:36:36 -0700 (PDT) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48a8fe93166sm77518115e9.7.2026.05.04.05.36.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 04 May 2026 05:36:35 -0700 (PDT) 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" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=suse.com header.i="@suse.com" header.h="Content-Transfer-Encoding:In-Reply-To:Autocrypt:From:Content-Language:References:Cc:To:Subject:User-Agent:MIME-Version:Date:Message-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1777898196; x=1778502996; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=uFMYZYyyXm+4Js+sJJbb4IVsuzxzO7AOUyEVnxpYh8w=; b=GXNZUM0o3DMV/AafJk48dLvwh72FgTF6QJTfGg0ZXkmSDoWiZh5DSTISP2oedy6cxk VzerwcE2pP0fPLYcb2DepLmEU9Qg3CnJsQn1A2kNlHOwj+sFJJ0kLNAuY2BiGtXjZ4z5 KInHEbEWtlgCTp3Xd/KNuXZMpunJAlTbN3TAKmL30aAm1O6YDiQyJDBt4pBWa8vcDhoK Hez8j16py3mhMeMjLquwS40fUJz5T2gnwct/3WvewAk0UaLF4g2+sKQtx9Z8MuJVbEpp vngYTxdyUlwcrQmIj+x5SLcib2D7CwhIBjBlB0r1tztVP5TulNyGWEqnUHQAC0Xz3hP9 9lZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777898196; x=1778502996; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=uFMYZYyyXm+4Js+sJJbb4IVsuzxzO7AOUyEVnxpYh8w=; b=hMeASOSHqX5H/8OAsbVT8PlW6Qf2dceziBVSrOIgdfzglFtjwCwUYfxPFz39BLMoeb UJK2y+MI4RaSBGgXC1DuwumHl76113cBsGxyMPnjFjyxjNA4aMIwf+9yP0oy1RXGU56w ui/N2zF1ykqX0ZL0bCQNO7FXUO7FcbR8+3lDlGstjs+HoUIWszW672Ksu88+hrIHwymu IJQ+yjYN5Mb49NLKJ8vX1oJffUmDbmohQFlEs2wOq1B+KoaeIUawyXitecO8853tIkbp Jr3fJkBmbFNCV0wUiVD1Y1B9ixhouzRj1hcb1X7nX4lieD3XjENYa8/dSs8oN0Gl2NyY 1hmQ== X-Gm-Message-State: AOJu0Ywvrd3M/EJWaAONrwQbNy7fh6JuES9x579CDmEjHHu7MX5OMalU CGwRMgpZQGkAqT2MALkt//dWgZEh/o2FuXnabPIYtG5ke06DkU8zlNEvMP/QX9n9bw== X-Gm-Gg: AeBDiev24u/ywgnFow5lR4dqg6NelFo6U3bXtjgmbjF5NXM9XypAKprpb+Cv0VpYvzK HHEgWSaNtYM8BNdLKUrZsOJzchZJXyoZDQFocj8nJwLPxnIy58BJqoOmc/llXzNQn4CvCMZu57y JXcLqrQ0Kwk31X6HxbOgSAH4WLbhuQlQqzYUjjQ85FT2SiT9Qy7jAXYJETg5i+HEqshCix0PnpZ nUVKA8mq8F9d9tiIJjVSspv2h+qHuPs9+btwAq/0DCk0AbbgMNciPND/E1DquOrEJ0ru2QW+Qeb cMVVw+d5cgXH+ih3eRS9YIa88q+QQ0kBW2+EwGaaSrOxgon7S3U+1kPOXuMDeHpIVGY4Vy4VMs0 8V/1REPQw5kevj0RFGIU+l1DGuWZF6u5imgHsVAEwWTL1mJgq1K8oVrupye16WdvQlPUJD4Yx3g B8qw88/Uf8cn9JoQDdLltgEUuz0XlKdZ73CseN1y8LdriPXruheHQqvc7M7S7ci3DNnI/Uo9f2h FtPyS+ZQJCpcmLxu8HtL+aG+g== X-Received: by 2002:a05:600c:5296:b0:489:1b10:d896 with SMTP id 5b1f17b1804b1-48d12f9147emr2915995e9.0.1777898196237; Mon, 04 May 2026 05:36:36 -0700 (PDT) Message-ID: <2945a61e-dcf8-40eb-a3e4-3c8e977f9ebf@suse.com> Date: Mon, 4 May 2026 14:36:45 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 11/17] hvmloader: allocate MMCONFIG area in the MMIO hole To: =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= Cc: xen-devel@lists.xenproject.org, Andrew Cooper , Anthony PERARD , Alexey Gerasimenko , Thierry Escande References: <20260313163455.790692-1-thierry.escande@vates.tech> <20260313163455.790692-12-thierry.escande@vates.tech> Content-Language: en-US From: Jan Beulich Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf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: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-purgate-ID: tlsNG-ef75cf/1777898196-1565BC48-A22DFFBF/0/0 X-purgate-type: clean X-purgate-size: 3591 On 04.05.2026 14:23, Roger Pau Monné wrote: > On Mon, May 04, 2026 at 01:11:44PM +0200, Jan Beulich wrote: >> On 29.04.2026 11:29, Roger Pau Monné wrote: >>> On Fri, Mar 13, 2026 at 04:35:04PM +0000, Thierry Escande wrote: >>>> --- a/tools/firmware/hvmloader/pci.c >>>> +++ b/tools/firmware/hvmloader/pci.c >>>> @@ -413,6 +413,58 @@ void pci_setup(void) >>>> pci_devfn_decode_type[devfn] |= PCI_COMMAND_MASTER; >>>> } >>>> >>>> + /* >>>> + * Calculate MMCONFIG area size and squeeze it into the bars array >>>> + * for assigning a slot in the MMIO hole >>>> + */ >>>> + if ( is_running_on_q35 ) >>>> + { >>>> + /* disable PCIEXBAR decoding for now */ >>>> + pci_writel(PCI_MCH_DEVFN, PCI_MCH_PCIEXBAR, 0); >>>> + pci_writel(PCI_MCH_DEVFN, PCI_MCH_PCIEXBAR + 4, 0); >>>> + >>>> + switch ( PCI_MAX_MCFG_BUSES ) >>>> + { >>>> + case 64: >>>> + bar_data = PCIEXBAR_64_BUSES | PCIEXBAR_ENABLE; >>>> + bar_sz = MB(64); >>>> + break; >>>> + >>>> + case 128: >>>> + bar_data = PCIEXBAR_128_BUSES | PCIEXBAR_ENABLE; >>>> + bar_sz = MB(128); >>>> + break; >>>> + >>>> + case 256: >>>> + bar_data = PCIEXBAR_256_BUSES | PCIEXBAR_ENABLE; >>>> + bar_sz = MB(256); >>>> + break; >>>> + >>>> + default: >>>> + /* unsupported number of buses specified */ >>>> + BUG(); >>>> + } >>>> + >>>> + addr_mask = ~(bar_sz - 1); >>>> + >>>> + for ( i = 0; i < nr_bars; i++ ) >>>> + if ( bars[i].bar_sz < bar_sz ) >>>> + break; >>>> + >>>> + if ( i != nr_bars ) >>>> + memmove(&bars[i+1], &bars[i], (nr_bars-i) * sizeof(*bars)); >>>> + >>>> + bars[i].is_mem = 1; >>>> + bars[i].devfn = PCI_MCH_DEVFN; >>>> + bars[i].bar_reg = PCI_MCH_PCIEXBAR; >>>> + bars[i].bar_sz = bar_sz; >>>> + bars[i].addr_mask = addr_mask; >>>> + bars[i].bar_data = bar_data; >>>> + >>>> + mmio_total += bar_sz; >>>> + nr_bars++; >>>> + } >>> >>> I think it might be best if the ECAM fake BAR is the first element in >>> the bars array, so we ensure it's the first item to consume memory >>> from the low MMIO hole. Not sure how that will work with the current >>> sorting of the resources based on their size, but it's imperative for >>> hvmloader to attempt to position ECAM ahead of the other device >>> resources IMO. >> >> Why would this be? > > I would assume it's best to have ECAM access in the low 4G (for 32bit > OSes) at the expense of some 32bit BARs possibly not fitting in the > 32bit space. But the ECAM space could be placed above 4G, and 32bit > OSes might not care much about extended address space capabilities. This doesn't require it to be 1st, though? Ideally we would try to put it below 4G if possible (i.e. if all other BARs which aren't 64-bit capable still fit), but fall back to putting it above 4G otherwise. In all of this it would still be put in the slot that its size demands. If we put it first, a significant gap could result between it and the first "real" BAR. (Then again a significant gap could also result if the number of buses to cover wasn't a power of 2.) Properly making use of such a gap would further complicate the code, I expect. > Should is_64bar be set for the MCFG "fake" BAR? As per above, maybe when making a 2nd (retry) pass. Jan