thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-target-i386-sev-Do-not-pin-the-ram-device-memory-reg.patch

b38b0f
From 660e7dc57899e79e85c19baa93be009b0382ae8e Mon Sep 17 00:00:00 2001
b38b0f
From: Gary R Hook <ghook@redhat.com>
b38b0f
Date: Wed, 10 Apr 2019 00:08:03 +0100
b38b0f
Subject: [PATCH 3/5] target/i386: sev: Do not pin the ram device memory region
b38b0f
b38b0f
RH-Author: Gary R Hook <ghook@redhat.com>
b38b0f
Message-id: <20190410000803.1744-3-ghook@redhat.com>
b38b0f
Patchwork-id: 85542
b38b0f
O-Subject: [RHEL-8.1 virt 2/2] target/i386: sev: Do not pin the ram device memory region
b38b0f
Bugzilla: 1667249
b38b0f
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
b38b0f
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
b38b0f
RH-Acked-by: Alex Williamson <alex.williamson@redhat.com>
b38b0f
b38b0f
BZ: 1667249
b38b0f
Branch: rhel-8.1.0
b38b0f
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1667249
b38b0f
Upstream Status: 4.0.0-rc1
b38b0f
Build Info: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=20980582
b38b0f
Conflicts: None
b38b0f
b38b0f
commit cedc0ad539afbbb669dba9e73dfad2915bc1c25b
b38b0f
Author: Singh, Brijesh <brijesh.singh@amd.com>
b38b0f
Date:   Mon Feb 4 22:23:40 2019 +0000
b38b0f
b38b0f
    target/i386: sev: Do not pin the ram device memory region
b38b0f
b38b0f
    The RAM device presents a memory region that should be handled
b38b0f
    as an IO region and should not be pinned.
b38b0f
b38b0f
    In the case of the vfio-pci, RAM device represents a MMIO BAR
b38b0f
    and the memory region is not backed by pages hence
b38b0f
    KVM_MEMORY_ENCRYPT_REG_REGION fails to lock the memory range.
b38b0f
b38b0f
    Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1667249
b38b0f
    Cc: Alex Williamson <alex.williamson@redhat.com>
b38b0f
    Cc: Paolo Bonzini <pbonzini@redhat.com>
b38b0f
    Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
b38b0f
    Message-Id: <20190204222322.26766-3-brijesh.singh@amd.com>
b38b0f
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
b38b0f
b38b0f
Cc: Paolo Bonzini <pbonzini@redhat.com>
b38b0f
Cc: Richard Henderson <rth@twiddle.net>
b38b0f
Cc: Eduardo Habkost <ehabkost@redhat.com>
b38b0f
Cc: qemu-devel@nongnu.org
b38b0f
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
b38b0f
---
b38b0f
 target/i386/sev.c | 11 +++++++++++
b38b0f
 1 file changed, 11 insertions(+)
b38b0f
b38b0f
diff --git a/target/i386/sev.c b/target/i386/sev.c
b38b0f
index 2395171..b8009b0 100644
b38b0f
--- a/target/i386/sev.c
b38b0f
+++ b/target/i386/sev.c
b38b0f
@@ -130,6 +130,17 @@ sev_ram_block_added(RAMBlockNotifier *n, void *host, size_t size)
b38b0f
 {
b38b0f
     int r;
b38b0f
     struct kvm_enc_region range;
b38b0f
+    ram_addr_t offset;
b38b0f
+    MemoryRegion *mr;
b38b0f
+
b38b0f
+    /*
b38b0f
+     * The RAM device presents a memory region that should be treated
b38b0f
+     * as IO region and should not be pinned.
b38b0f
+     */
b38b0f
+    mr = memory_region_from_host(host, &offset);
b38b0f
+    if (mr && memory_region_is_ram_device(mr)) {
b38b0f
+	return;
b38b0f
+    }
b38b0f
 
b38b0f
     range.addr = (__u64)(unsigned long)host;
b38b0f
     range.size = size;
b38b0f
-- 
b38b0f
1.8.3.1
b38b0f