yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-target-i386-sev-Do-not-unpin-ram-device-memory-regio.patch

b38b0f
From b150f14fa8adcfe255c0380427e31d033bd44789 Mon Sep 17 00:00:00 2001
b38b0f
From: Alex Williamson <alex.williamson@redhat.com>
b38b0f
Date: Mon, 22 Jul 2019 18:09:47 +0100
b38b0f
Subject: [PATCH 21/39] target/i386: sev: Do not unpin ram device memory region
b38b0f
b38b0f
RH-Author: Alex Williamson <alex.williamson@redhat.com>
b38b0f
Message-id: <156381893103.14196.5165276806848335745.stgit@gimli.home>
b38b0f
Patchwork-id: 89617
b38b0f
O-Subject: [RHEL-8.1 qemu-kvm PATCH] target/i386: sev: Do not unpin ram device memory region
b38b0f
Bugzilla: 1728958
b38b0f
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
b38b0f
RH-Acked-by: Auger Eric <eric.auger@redhat.com>
b38b0f
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
b38b0f
b38b0f
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1728958
b38b0f
Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=22722091
b38b0f
Branch: rhel-8.1.0
b38b0f
b38b0f
The commit referenced below skipped pinning ram device memory when
b38b0f
ram blocks are added, we need to do the same when they're removed.
b38b0f
b38b0f
Cc: Brijesh Singh <brijesh.singh@amd.com>
b38b0f
Cc: Paolo Bonzini <pbonzini@redhat.com>
b38b0f
Fixes: cedc0ad539af ("target/i386: sev: Do not pin the ram device memory region")
b38b0f
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
b38b0f
Message-Id: <156320087103.2556.10983987500488190423.stgit@gimli.home>
b38b0f
Reviewed-by: Singh, Brijesh <brijesh.singh@amd.com>
b38b0f
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
b38b0f
(cherry picked from commit 56e2ec9488b3b281130e064929f8ae5595d6ac39)
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 b8009b0..7051a30 100644
b38b0f
--- a/target/i386/sev.c
b38b0f
+++ b/target/i386/sev.c
b38b0f
@@ -159,6 +159,17 @@ sev_ram_block_removed(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 have been 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