nouveau.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Juergen Gross <jgross@suse.com>
To: Christoph Hellwig <hch@lst.de>
Cc: x86@kernel.org, "Stefano Stabellini" <sstabellini@kernel.org>,
	nouveau@lists.freedesktop.org,
	"Dave Hansen" <dave.hansen@linux.intel.com>,
	"Marek Marczykowski-Górecki" <marmarek@invisiblethingslab.com>,
	linux-kernel@vger.kernel.org, iommu@lists.linux.dev,
	"Ingo Molnar" <mingo@redhat.com>,
	"Borislav Petkov" <bp@alien8.de>,
	"Ben Skeggs" <bskeggs@redhat.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	xen-devel@lists.xenproject.org,
	"Thomas Gleixner" <tglx@linutronix.de>
Subject: Re: [Nouveau] [PATCH 2/4] x86: always initialize xen-swiotlb when xen-pcifront is enabling
Date: Mon, 12 Jun 2023 10:08:07 +0200	[thread overview]
Message-ID: <afc27bd9-5426-d837-dbb2-ec9083bec240@suse.com> (raw)
In-Reply-To: <79b26dac-b507-1c05-b499-784ca6ee3db0@suse.com>


[-- Attachment #1.1.1: Type: text/plain, Size: 1455 bytes --]

On 09.06.23 17:38, Juergen Gross wrote:
> On 07.06.23 15:12, Christoph Hellwig wrote:
>> On Mon, May 22, 2023 at 10:37:09AM +0200, Juergen Gross wrote:
>>> In normal cases PCI passthrough in PV guests requires to start the guest
>>> with e820_host=1. So it should be rather easy to limit allocating the
>>> 64MB in PV guests to the cases where the memory map has non-RAM regions
>>> especially in the first 1MB of the memory.
>>>
>>> This will cover even hotplug cases. The only case not covered would be a
>>> guest started with e820_host=1 even if no PCI passthrough was planned.
>>> But this should be rather rare (at least I hope so).
>>
>> So is this an ACK for the patch and can we go ahead with it?
> 
> As long as above mentioned check of the E820 map is done, yes.
> 
> If you want I can send a diff to be folded into your patch on Monday.

Attached is a patch for adding a new flag xen_pv_pci_possible. You can
either add the patch to your series or merge it into your patch 2.

You need to modify your patch like this:

@@ -111,7 +90,10 @@ static inline void __init pci_xen_swiotlb_init(void)
  void __init pci_iommu_alloc(void)
  {
  	if (xen_pv_domain()) {
-		if (xen_initial_domain() || x86_swiotlb_enable)
+		if (xen_initial_domain() ||
+		    (IS_ENABLED(CONFIG_XEN_PCIDEV_FRONTEND) &&
+		     xen_pv_pci_possible) ||
+		    x86_swiotlb_enable)
  			pci_xen_swiotlb_init();
  		return;
  	}


Juergen

[-- Attachment #1.1.2: 0001-xen-pci-add-flag-for-PCI-passthrough-being-possible.patch --]
[-- Type: text/x-patch, Size: 1903 bytes --]

From 7e84a88243b57bc90d1ef6bd42661f499886e659 Mon Sep 17 00:00:00 2001
From: Juergen Gross <jgross@suse.com>
Date: Mon, 12 Jun 2023 09:57:18 +0200
Subject: [PATCH] xen/pci: add flag for PCI passthrough being possible

When running as a Xen PV guests passed through PCI devices only have a
chance to work if the Xen supplied memory map has some PCI space
reserved.

Add a flag xen_pv_pci_possible which will be set in early boot in case
the memory map has at least one area with the type E820_TYPE_RESERVED.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 arch/x86/xen/setup.c | 6 ++++++
 include/xen/xen.h    | 6 ++++++
 2 files changed, 12 insertions(+)

diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index c2be3efb2ba0..716f76c41416 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -43,6 +43,9 @@ struct xen_memory_region xen_extra_mem[XEN_EXTRA_MEM_MAX_REGIONS] __initdata;
 /* Number of pages released from the initial allocation. */
 unsigned long xen_released_pages;
 
+/* Memory map would allow PCI passthrough. */
+bool xen_pv_pci_possible;
+
 /* E820 map used during setting up memory. */
 static struct e820_table xen_e820_table __initdata;
 
@@ -804,6 +807,9 @@ char * __init xen_memory_setup(void)
 		chunk_size = size;
 		type = xen_e820_table.entries[i].type;
 
+		if (type == E820_TYPE_RESERVED)
+			xen_pv_pci_possible = true;
+
 		if (type == E820_TYPE_RAM) {
 			if (addr < mem_end) {
 				chunk_size = min(size, mem_end - addr);
diff --git a/include/xen/xen.h b/include/xen/xen.h
index 0efeb652f9b8..5eb0a974a11e 100644
--- a/include/xen/xen.h
+++ b/include/xen/xen.h
@@ -29,6 +29,12 @@ extern bool xen_pvh;
 
 extern uint32_t xen_start_flags;
 
+#ifdef CONFIG_XEN_PV
+extern bool xen_pv_pci_possible;
+#else
+#define xen_pv_pci_possible	0
+#endif
+
 #include <xen/interface/hvm/start_info.h>
 extern struct hvm_start_info pvh_start_info;
 
-- 
2.35.3


[-- Attachment #1.1.3: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3149 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]

  parent reply	other threads:[~2023-06-12  8:08 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-18 13:42 [Nouveau] unexport swiotlb_active Christoph Hellwig
2023-05-18 13:42 ` [Nouveau] [PATCH 1/4] x86: move a check out of pci_xen_swiotlb_init Christoph Hellwig
2023-05-18 13:42 ` [Nouveau] [PATCH 2/4] x86: always initialize xen-swiotlb when xen-pcifront is enabling Christoph Hellwig
2023-05-18 18:18   ` Marek Marczykowski-Górecki
2023-05-19  4:04     ` Christoph Hellwig
2023-05-19 10:10       ` Marek Marczykowski-Górecki
2023-05-19 12:41         ` Christoph Hellwig
2023-05-19 12:49           ` Andrew Cooper
2023-05-19 12:58             ` Christoph Hellwig
2023-05-20  6:21               ` Christoph Hellwig
2023-05-22  7:52                 ` Petr Tesařík
2023-05-22  7:54         ` Petr Tesařík
2023-05-22  8:37         ` Juergen Gross
2023-06-07 13:12           ` Christoph Hellwig
2023-06-09 15:38             ` Juergen Gross
2023-06-12  6:47               ` Christoph Hellwig
2023-06-12  8:08               ` Juergen Gross [this message]
2023-06-12  8:23                 ` Christoph Hellwig
2023-05-18 13:42 ` [Nouveau] [PATCH 3/4] drm/nouveau: stop using is_swiotlb_active Christoph Hellwig
2023-05-18 20:30   ` Lyude Paul
2023-06-07 13:11     ` Christoph Hellwig
2023-05-18 13:42 ` [Nouveau] [PATCH 4/4] swiotlb: unexport is_swiotlb_active Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=afc27bd9-5426-d837-dbb2-ec9083bec240@suse.com \
    --to=jgross@suse.com \
    --cc=bp@alien8.de \
    --cc=bskeggs@redhat.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=hch@lst.de \
    --cc=hpa@zytor.com \
    --cc=iommu@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marmarek@invisiblethingslab.com \
    --cc=mingo@redhat.com \
    --cc=nouveau@lists.freedesktop.org \
    --cc=sstabellini@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).