qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] accel/kvm: check for KVM_CAP_MEMORY_ATTRIBUTES on vm
@ 2024-10-11  8:59 Paolo Bonzini
  2024-10-11 11:29 ` Gupta, Pankaj
  0 siblings, 1 reply; 2+ messages in thread
From: Paolo Bonzini @ 2024-10-11  8:59 UTC (permalink / raw)
  To: qemu-devel; +Cc: erbse.13

The exact set of available memory attributes can vary by VM.  In the
future it might vary depending on enabled capabilities, too.  Query the
extension on the VM level instead of on the KVM level, and only after
architecture-specific initialization.

Inspired by an analogous patch by Tom Dohrmann.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 accel/kvm/kvm-all.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 4287e254df8..482c5b24cf6 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -2604,12 +2604,6 @@ static int kvm_init(MachineState *ms)
         goto err;
     }
 
-    kvm_supported_memory_attributes = kvm_check_extension(s, KVM_CAP_MEMORY_ATTRIBUTES);
-    kvm_guest_memfd_supported =
-        kvm_check_extension(s, KVM_CAP_GUEST_MEMFD) &&
-        kvm_check_extension(s, KVM_CAP_USER_MEMORY2) &&
-        (kvm_supported_memory_attributes & KVM_MEMORY_ATTRIBUTE_PRIVATE);
-
     kvm_immediate_exit = kvm_check_extension(s, KVM_CAP_IMMEDIATE_EXIT);
     s->nr_slots_max = kvm_check_extension(s, KVM_CAP_NR_MEMSLOTS);
 
@@ -2723,6 +2717,12 @@ static int kvm_init(MachineState *ms)
         goto err;
     }
 
+    kvm_supported_memory_attributes = kvm_vm_check_extension(s, KVM_CAP_MEMORY_ATTRIBUTES);
+    kvm_guest_memfd_supported =
+        kvm_check_extension(s, KVM_CAP_GUEST_MEMFD) &&
+        kvm_check_extension(s, KVM_CAP_USER_MEMORY2) &&
+        (kvm_supported_memory_attributes & KVM_MEMORY_ATTRIBUTE_PRIVATE);
+
     if (s->kernel_irqchip_split == ON_OFF_AUTO_AUTO) {
         s->kernel_irqchip_split = mc->default_kernel_irqchip_split ? ON_OFF_AUTO_ON : ON_OFF_AUTO_OFF;
     }
-- 
2.46.2



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

* Re: [PATCH] accel/kvm: check for KVM_CAP_MEMORY_ATTRIBUTES on vm
  2024-10-11  8:59 [PATCH] accel/kvm: check for KVM_CAP_MEMORY_ATTRIBUTES on vm Paolo Bonzini
@ 2024-10-11 11:29 ` Gupta, Pankaj
  0 siblings, 0 replies; 2+ messages in thread
From: Gupta, Pankaj @ 2024-10-11 11:29 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: erbse.13

On 10/11/2024 10:59 AM, Paolo Bonzini wrote:
> The exact set of available memory attributes can vary by VM.  In the
> future it might vary depending on enabled capabilities, too.  Query the
> extension on the VM level instead of on the KVM level, and only after
> architecture-specific initialization.
> 
> Inspired by an analogous patch by Tom Dohrmann.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Reviewed-by: Pankaj Gupta <pankaj.gupta@amd.com>

> ---
>   accel/kvm/kvm-all.c | 12 ++++++------
>   1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
> index 4287e254df8..482c5b24cf6 100644
> --- a/accel/kvm/kvm-all.c
> +++ b/accel/kvm/kvm-all.c
> @@ -2604,12 +2604,6 @@ static int kvm_init(MachineState *ms)
>           goto err;
>       }
>   
> -    kvm_supported_memory_attributes = kvm_check_extension(s, KVM_CAP_MEMORY_ATTRIBUTES);
> -    kvm_guest_memfd_supported =
> -        kvm_check_extension(s, KVM_CAP_GUEST_MEMFD) &&
> -        kvm_check_extension(s, KVM_CAP_USER_MEMORY2) &&
> -        (kvm_supported_memory_attributes & KVM_MEMORY_ATTRIBUTE_PRIVATE);
> -
>       kvm_immediate_exit = kvm_check_extension(s, KVM_CAP_IMMEDIATE_EXIT);
>       s->nr_slots_max = kvm_check_extension(s, KVM_CAP_NR_MEMSLOTS);
>   
> @@ -2723,6 +2717,12 @@ static int kvm_init(MachineState *ms)
>           goto err;
>       }
>   
> +    kvm_supported_memory_attributes = kvm_vm_check_extension(s, KVM_CAP_MEMORY_ATTRIBUTES);
> +    kvm_guest_memfd_supported =
> +        kvm_check_extension(s, KVM_CAP_GUEST_MEMFD) &&
> +        kvm_check_extension(s, KVM_CAP_USER_MEMORY2) &&
> +        (kvm_supported_memory_attributes & KVM_MEMORY_ATTRIBUTE_PRIVATE);
> +
>       if (s->kernel_irqchip_split == ON_OFF_AUTO_AUTO) {
>           s->kernel_irqchip_split = mc->default_kernel_irqchip_split ? ON_OFF_AUTO_ON : ON_OFF_AUTO_OFF;
>       }



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

end of thread, other threads:[~2024-10-11 17:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-11  8:59 [PATCH] accel/kvm: check for KVM_CAP_MEMORY_ATTRIBUTES on vm Paolo Bonzini
2024-10-11 11:29 ` Gupta, Pankaj

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