thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

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

Pablo Greco e6a3ae
From b150f14fa8adcfe255c0380427e31d033bd44789 Mon Sep 17 00:00:00 2001
Pablo Greco e6a3ae
From: Alex Williamson <alex.williamson@redhat.com>
Pablo Greco e6a3ae
Date: Mon, 22 Jul 2019 18:09:47 +0100
Pablo Greco e6a3ae
Subject: [PATCH 21/39] target/i386: sev: Do not unpin ram device memory region
Pablo Greco e6a3ae
Pablo Greco e6a3ae
RH-Author: Alex Williamson <alex.williamson@redhat.com>
Pablo Greco e6a3ae
Message-id: <156381893103.14196.5165276806848335745.stgit@gimli.home>
Pablo Greco e6a3ae
Patchwork-id: 89617
Pablo Greco e6a3ae
O-Subject: [RHEL-8.1 qemu-kvm PATCH] target/i386: sev: Do not unpin ram device memory region
Pablo Greco e6a3ae
Bugzilla: 1728958
Pablo Greco e6a3ae
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
Pablo Greco e6a3ae
RH-Acked-by: Auger Eric <eric.auger@redhat.com>
Pablo Greco e6a3ae
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
Pablo Greco e6a3ae
Pablo Greco e6a3ae
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1728958
Pablo Greco e6a3ae
Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=22722091
Pablo Greco e6a3ae
Branch: rhel-8.1.0
Pablo Greco e6a3ae
Pablo Greco e6a3ae
The commit referenced below skipped pinning ram device memory when
Pablo Greco e6a3ae
ram blocks are added, we need to do the same when they're removed.
Pablo Greco e6a3ae
Pablo Greco e6a3ae
Cc: Brijesh Singh <brijesh.singh@amd.com>
Pablo Greco e6a3ae
Cc: Paolo Bonzini <pbonzini@redhat.com>
Pablo Greco e6a3ae
Fixes: cedc0ad539af ("target/i386: sev: Do not pin the ram device memory region")
Pablo Greco e6a3ae
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Pablo Greco e6a3ae
Message-Id: <156320087103.2556.10983987500488190423.stgit@gimli.home>
Pablo Greco e6a3ae
Reviewed-by: Singh, Brijesh <brijesh.singh@amd.com>
Pablo Greco e6a3ae
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Pablo Greco e6a3ae
(cherry picked from commit 56e2ec9488b3b281130e064929f8ae5595d6ac39)
Pablo Greco e6a3ae
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
Pablo Greco e6a3ae
---
Pablo Greco e6a3ae
 target/i386/sev.c | 11 +++++++++++
Pablo Greco e6a3ae
 1 file changed, 11 insertions(+)
Pablo Greco e6a3ae
Pablo Greco e6a3ae
diff --git a/target/i386/sev.c b/target/i386/sev.c
Pablo Greco e6a3ae
index b8009b0..7051a30 100644
Pablo Greco e6a3ae
--- a/target/i386/sev.c
Pablo Greco e6a3ae
+++ b/target/i386/sev.c
Pablo Greco e6a3ae
@@ -159,6 +159,17 @@ sev_ram_block_removed(RAMBlockNotifier *n, void *host, size_t size)
Pablo Greco e6a3ae
 {
Pablo Greco e6a3ae
     int r;
Pablo Greco e6a3ae
     struct kvm_enc_region range;
Pablo Greco e6a3ae
+    ram_addr_t offset;
Pablo Greco e6a3ae
+    MemoryRegion *mr;
Pablo Greco e6a3ae
+
Pablo Greco e6a3ae
+    /*
Pablo Greco e6a3ae
+     * The RAM device presents a memory region that should be treated
Pablo Greco e6a3ae
+     * as IO region and should not have been pinned.
Pablo Greco e6a3ae
+     */
Pablo Greco e6a3ae
+    mr = memory_region_from_host(host, &offset);
Pablo Greco e6a3ae
+    if (mr && memory_region_is_ram_device(mr)) {
Pablo Greco e6a3ae
+        return;
Pablo Greco e6a3ae
+    }
Pablo Greco e6a3ae
 
Pablo Greco e6a3ae
     range.addr = (__u64)(unsigned long)host;
Pablo Greco e6a3ae
     range.size = size;
Pablo Greco e6a3ae
-- 
Pablo Greco e6a3ae
1.8.3.1
Pablo Greco e6a3ae