qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] virtio: kconfig: memory devices are PCI only
@ 2024-09-06 10:16 Paolo Bonzini
  2024-09-06 10:25 ` David Hildenbrand
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Paolo Bonzini @ 2024-09-06 10:16 UTC (permalink / raw)
  To: qemu-devel; +Cc: David Hildenbrand, Michael Tokarev

Virtio memory devices rely on PCI BARs to expose the contents of memory.
Because of this they cannot be used (yet) with virtio-mmio or virtio-ccw.
In fact the code that is common to virtio-mem and virtio-pmem, which
is in hw/virtio/virtio-md-pci.c, is only included if CONFIG_VIRTIO_PCI
is set.  Reproduce the same condition in the Kconfig file, only allowing
VIRTIO_MEM and VIRTIO_PMEM to be defined if the transport supports it.

Without this patch it is possible to create a configuration with
CONFIG_VIRTIO_PCI=n and CONFIG_VIRTIO_MEM=y, but that causes a
linking failure.

Cc: David Hildenbrand <david@redhat.com>
Reported-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/virtio/Kconfig | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/hw/virtio/Kconfig b/hw/virtio/Kconfig
index aa63ff7fd41..0afec2ae929 100644
--- a/hw/virtio/Kconfig
+++ b/hw/virtio/Kconfig
@@ -16,6 +16,7 @@ config VIRTIO_PCI
     default y if PCI_DEVICES
     depends on PCI
     select VIRTIO
+    select VIRTIO_MD_SUPPORTED
 
 config VIRTIO_MMIO
     bool
@@ -35,10 +36,17 @@ config VIRTIO_CRYPTO
     default y
     depends on VIRTIO
 
+# not all virtio transports support memory devices; if none does,
+# no need to include the code
+config VIRTIO_MD_SUPPORTED
+    bool
+
 config VIRTIO_MD
     bool
+    depends on VIRTIO_MD_SUPPORTED
     select MEM_DEVICE
 
+# selected by the board if it has the required support code
 config VIRTIO_PMEM_SUPPORTED
     bool
 
@@ -46,9 +54,11 @@ config VIRTIO_PMEM
     bool
     default y
     depends on VIRTIO
+    depends on VIRTIO_MD_SUPPORTED
     depends on VIRTIO_PMEM_SUPPORTED
     select VIRTIO_MD
 
+# selected by the board if it has the required support code
 config VIRTIO_MEM_SUPPORTED
     bool
 
@@ -57,6 +67,7 @@ config VIRTIO_MEM
     default y
     depends on VIRTIO
     depends on LINUX
+    depends on VIRTIO_MD_SUPPORTED
     depends on VIRTIO_MEM_SUPPORTED
     select VIRTIO_MD
 
-- 
2.46.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] virtio: kconfig: memory devices are PCI only
  2024-09-06 10:16 [PATCH v2] virtio: kconfig: memory devices are PCI only Paolo Bonzini
@ 2024-09-06 10:25 ` David Hildenbrand
  2024-09-09 12:01 ` David Hildenbrand
  2024-09-25  7:39 ` Pankaj Gupta
  2 siblings, 0 replies; 5+ messages in thread
From: David Hildenbrand @ 2024-09-06 10:25 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: Michael Tokarev

On 06.09.24 12:16, Paolo Bonzini wrote:
> Virtio memory devices rely on PCI BARs to expose the contents of memory.
> Because of this they cannot be used (yet) with virtio-mmio or virtio-ccw.
> In fact the code that is common to virtio-mem and virtio-pmem, which
> is in hw/virtio/virtio-md-pci.c, is only included if CONFIG_VIRTIO_PCI
> is set.  Reproduce the same condition in the Kconfig file, only allowing
> VIRTIO_MEM and VIRTIO_PMEM to be defined if the transport supports it.
> 
> Without this patch it is possible to create a configuration with
> CONFIG_VIRTIO_PCI=n and CONFIG_VIRTIO_MEM=y, but that causes a
> linking failure.
> 
> Cc: David Hildenbrand <david@redhat.com>
> Reported-by: Michael Tokarev <mjt@tls.msk.ru>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---

Reviewed-by: David Hildenbrand <david@redhat.com>

Thanks!

-- 
Cheers,

David / dhildenb



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] virtio: kconfig: memory devices are PCI only
  2024-09-06 10:16 [PATCH v2] virtio: kconfig: memory devices are PCI only Paolo Bonzini
  2024-09-06 10:25 ` David Hildenbrand
@ 2024-09-09 12:01 ` David Hildenbrand
  2024-09-25  7:39 ` Pankaj Gupta
  2 siblings, 0 replies; 5+ messages in thread
From: David Hildenbrand @ 2024-09-09 12:01 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: Michael Tokarev

On 06.09.24 12:16, Paolo Bonzini wrote:
> Virtio memory devices rely on PCI BARs to expose the contents of memory.
> Because of this they cannot be used (yet) with virtio-mmio or virtio-ccw.
> In fact the code that is common to virtio-mem and virtio-pmem, which
> is in hw/virtio/virtio-md-pci.c, is only included if CONFIG_VIRTIO_PCI
> is set.  Reproduce the same condition in the Kconfig file, only allowing
> VIRTIO_MEM and VIRTIO_PMEM to be defined if the transport supports it.
> 
> Without this patch it is possible to create a configuration with
> CONFIG_VIRTIO_PCI=n and CONFIG_VIRTIO_MEM=y, but that causes a
> linking failure.

I'll queue this to

https://github.com/davidhildenbrand/qemu.git mem-next

and drop it if someone beats me to up-streaming it :)

-- 
Cheers,

David / dhildenb



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] virtio: kconfig: memory devices are PCI only
  2024-09-06 10:16 [PATCH v2] virtio: kconfig: memory devices are PCI only Paolo Bonzini
  2024-09-06 10:25 ` David Hildenbrand
  2024-09-09 12:01 ` David Hildenbrand
@ 2024-09-25  7:39 ` Pankaj Gupta
  2024-09-26  8:51   ` David Hildenbrand
  2 siblings, 1 reply; 5+ messages in thread
From: Pankaj Gupta @ 2024-09-25  7:39 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-devel, David Hildenbrand, Michael Tokarev

> Virtio memory devices rely on PCI BARs to expose the contents of memory.
> Because of this they cannot be used (yet) with virtio-mmio or virtio-ccw.
> In fact the code that is common to virtio-mem and virtio-pmem, which
> is in hw/virtio/virtio-md-pci.c, is only included if CONFIG_VIRTIO_PCI
> is set.  Reproduce the same condition in the Kconfig file, only allowing
> VIRTIO_MEM and VIRTIO_PMEM to be defined if the transport supports it.
>
> Without this patch it is possible to create a configuration with
> CONFIG_VIRTIO_PCI=n and CONFIG_VIRTIO_MEM=y, but that causes a
> linking failure.

Just curious what is required to make virtio-mem & virtio-pmem compatible with
virtio-mmio?

Maybe late but still:
Reviewed-by: Pankaj Gupta <pankaj.gupta@amd.com>

Thanks,
Pankaj

>
> Cc: David Hildenbrand <david@redhat.com>
> Reported-by: Michael Tokarev <mjt@tls.msk.ru>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  hw/virtio/Kconfig | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> diff --git a/hw/virtio/Kconfig b/hw/virtio/Kconfig
> index aa63ff7fd41..0afec2ae929 100644
> --- a/hw/virtio/Kconfig
> +++ b/hw/virtio/Kconfig
> @@ -16,6 +16,7 @@ config VIRTIO_PCI
>      default y if PCI_DEVICES
>      depends on PCI
>      select VIRTIO
> +    select VIRTIO_MD_SUPPORTED
>
>  config VIRTIO_MMIO
>      bool
> @@ -35,10 +36,17 @@ config VIRTIO_CRYPTO
>      default y
>      depends on VIRTIO
>
> +# not all virtio transports support memory devices; if none does,
> +# no need to include the code
> +config VIRTIO_MD_SUPPORTED
> +    bool
> +
>  config VIRTIO_MD
>      bool
> +    depends on VIRTIO_MD_SUPPORTED
>      select MEM_DEVICE
>
> +# selected by the board if it has the required support code
>  config VIRTIO_PMEM_SUPPORTED
>      bool
>
> @@ -46,9 +54,11 @@ config VIRTIO_PMEM
>      bool
>      default y
>      depends on VIRTIO
> +    depends on VIRTIO_MD_SUPPORTED
>      depends on VIRTIO_PMEM_SUPPORTED
>      select VIRTIO_MD
>
> +# selected by the board if it has the required support code
>  config VIRTIO_MEM_SUPPORTED
>      bool
>
> @@ -57,6 +67,7 @@ config VIRTIO_MEM
>      default y
>      depends on VIRTIO
>      depends on LINUX
> +    depends on VIRTIO_MD_SUPPORTED
>      depends on VIRTIO_MEM_SUPPORTED
>      select VIRTIO_MD
>
> --
> 2.46.0
>
>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] virtio: kconfig: memory devices are PCI only
  2024-09-25  7:39 ` Pankaj Gupta
@ 2024-09-26  8:51   ` David Hildenbrand
  0 siblings, 0 replies; 5+ messages in thread
From: David Hildenbrand @ 2024-09-26  8:51 UTC (permalink / raw)
  To: Pankaj Gupta, Paolo Bonzini; +Cc: qemu-devel, Michael Tokarev

On 25.09.24 09:39, Pankaj Gupta wrote:
>> Virtio memory devices rely on PCI BARs to expose the contents of memory.
>> Because of this they cannot be used (yet) with virtio-mmio or virtio-ccw.
>> In fact the code that is common to virtio-mem and virtio-pmem, which
>> is in hw/virtio/virtio-md-pci.c, is only included if CONFIG_VIRTIO_PCI
>> is set.  Reproduce the same condition in the Kconfig file, only allowing
>> VIRTIO_MEM and VIRTIO_PMEM to be defined if the transport supports it.
>>
>> Without this patch it is possible to create a configuration with
>> CONFIG_VIRTIO_PCI=n and CONFIG_VIRTIO_MEM=y, but that causes a
>> linking failure.
> 
> Just curious what is required to make virtio-mem & virtio-pmem compatible with
> virtio-mmio?

I assume not that much: primarily implementing the virtio-md-mmio 
abstraction, and the virtio-mem-mmio/virtio-pmem-mmio proxy devices. 
Then, it needs to be wired up in the machine hotplug code.

I posted the virtio-ccw variant a couple of days ago [1].

> 
> Maybe late but still:
> Reviewed-by: Pankaj Gupta <pankaj.gupta@amd.com>

I already sent a merge request that includes this change. If I have to 
resend it, I'll include that. Thanks!


[1] https://lkml.kernel.org/r/20240910175809.2135596-1-david@redhat.com

-- 
Cheers,

David / dhildenb



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-09-26  8:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-06 10:16 [PATCH v2] virtio: kconfig: memory devices are PCI only Paolo Bonzini
2024-09-06 10:25 ` David Hildenbrand
2024-09-09 12:01 ` David Hildenbrand
2024-09-25  7:39 ` Pankaj Gupta
2024-09-26  8:51   ` David Hildenbrand

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).