[Qemu-devel] [PATCH for-4.1] target/i386: sev: Do not unpin ram device memory region

Alex Williamson posted 1 patch 4 years, 9 months ago
Test docker-clang@ubuntu passed
Test s390x passed
Test asan passed
Test docker-mingw@fedora passed
Test FreeBSD passed
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/156320087103.2556.10983987500488190423.stgit@gimli.home
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, Eduardo Habkost <ehabkost@redhat.com>, Richard Henderson <rth@twiddle.net>
target/i386/sev.c |   11 +++++++++++
1 file changed, 11 insertions(+)
[Qemu-devel] [PATCH for-4.1] target/i386: sev: Do not unpin ram device memory region
Posted by Alex Williamson 4 years, 9 months ago
The commit referenced below skipped pinning ram device memory when
ram blocks are added, we need to do the same when they're removed.

Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Fixes: cedc0ad539af ("target/i386: sev: Do not pin the ram device memory region")
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
 target/i386/sev.c |   11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/target/i386/sev.c b/target/i386/sev.c
index 6dbdc3cdf10f..5ba1384ea1f6 100644
--- a/target/i386/sev.c
+++ b/target/i386/sev.c
@@ -161,6 +161,17 @@ sev_ram_block_removed(RAMBlockNotifier *n, void *host, size_t size)
 {
     int r;
     struct kvm_enc_region range;
+    ram_addr_t offset;
+    MemoryRegion *mr;
+
+    /*
+     * The RAM device presents a memory region that should be treated
+     * as IO region and should not have been pinned.
+     */
+    mr = memory_region_from_host(host, &offset);
+    if (mr && memory_region_is_ram_device(mr)) {
+        return;
+    }
 
     range.addr = (__u64)(unsigned long)host;
     range.size = size;


Re: [Qemu-devel] [PATCH for-4.1] target/i386: sev: Do not unpin ram device memory region
Posted by Paolo Bonzini 4 years, 9 months ago
On 15/07/19 16:28, Alex Williamson wrote:
> The commit referenced below skipped pinning ram device memory when
> ram blocks are added, we need to do the same when they're removed.
> 
> Cc: Brijesh Singh <brijesh.singh@amd.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Fixes: cedc0ad539af ("target/i386: sev: Do not pin the ram device memory region")
> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
> ---
>  target/i386/sev.c |   11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/target/i386/sev.c b/target/i386/sev.c
> index 6dbdc3cdf10f..5ba1384ea1f6 100644
> --- a/target/i386/sev.c
> +++ b/target/i386/sev.c
> @@ -161,6 +161,17 @@ sev_ram_block_removed(RAMBlockNotifier *n, void *host, size_t size)
>  {
>      int r;
>      struct kvm_enc_region range;
> +    ram_addr_t offset;
> +    MemoryRegion *mr;
> +
> +    /*
> +     * The RAM device presents a memory region that should be treated
> +     * as IO region and should not have been pinned.
> +     */
> +    mr = memory_region_from_host(host, &offset);
> +    if (mr && memory_region_is_ram_device(mr)) {
> +        return;
> +    }
>  
>      range.addr = (__u64)(unsigned long)host;
>      range.size = size;
> 

Queued, thanks.

Paolo

Re: [Qemu-devel] [PATCH for-4.1] target/i386: sev: Do not unpin ram device memory region
Posted by Singh, Brijesh 4 years, 9 months ago

On 7/15/19 9:28 AM, Alex Williamson wrote:
> The commit referenced below skipped pinning ram device memory when
> ram blocks are added, we need to do the same when they're removed.
> 
> Cc: Brijesh Singh <brijesh.singh@amd.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Fixes: cedc0ad539af ("target/i386: sev: Do not pin the ram device memory region")
> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
> ---
>   target/i386/sev.c |   11 +++++++++++
>   1 file changed, 11 insertions(+)
> 

thanks

Reviewed-by: Brijesh Singh <brijesh.singh@amd.com>