qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Jones <drjones@redhat.com>
To: kvmarm@lists.cs.columbia.edu, qemu-devel@nongnu.org,
	ard.biesheuvel@linaro.org, christoffer.dall@linaro.org,
	marc.zyngier@arm.com, peter.maydell@linaro.org,
	pbonzini@redhat.com
Cc: catalin.marinas@arm.com, lersek@redhat.com, agraf@suse.de,
	m.smarduch@samsung.com
Subject: [Qemu-devel] [RFC PATCH 3/4] memory: add uncached flag
Date: Wed, 18 Mar 2015 15:11:47 -0400	[thread overview]
Message-ID: <1426705908-2765-4-git-send-email-drjones@redhat.com> (raw)
In-Reply-To: <1426705908-2765-1-git-send-email-drjones@redhat.com>

Add an 'uncached' flag, which will result in the KVM_MEM_UNCACHED
flag getting set on KVM's corresponding memory slot.

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 include/exec/memory.h | 25 +++++++++++++++++++++++++
 kvm-all.c             |  9 +++++++++
 memory.c              | 15 +++++++++++++++
 3 files changed, 49 insertions(+)

diff --git a/include/exec/memory.h b/include/exec/memory.h
index 06ffa1d185b93..2a0d016f5fe6d 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -158,6 +158,7 @@ struct MemoryRegion {
     bool rom_device;
     bool warning_printed; /* For reservations */
     bool flush_coalesced_mmio;
+    bool uncached;
     MemoryRegion *alias;
     hwaddr alias_offset;
     int32_t priority;
@@ -778,6 +779,30 @@ void memory_region_set_flush_coalesced(MemoryRegion *mr);
 void memory_region_clear_flush_coalesced(MemoryRegion *mr);
 
 /**
+ * memory_region_set_uncached: Flag this memory region (for e.g. kvm) as
+ *                             typically being mapped uncached.
+ *
+ * @mr: the memory region to be updated.
+ */
+void memory_region_set_uncached(MemoryRegion *mr);
+
+/**
+ * memory_region_clear_uncached: Remove the 'uncached' flag.
+ *
+ * @mr: the memory region to be updated.
+ */
+void memory_region_clear_uncached(MemoryRegion *mr);
+
+/**
+ * memory_region_may_map_uncached: Return the 'uncached' flag, which
+ *                                 indicates the region is typically
+ *                                 mapped uncached.
+ *
+ * @mr: the memory region to check.
+ */
+bool memory_region_may_map_uncached(MemoryRegion *mr);
+
+/**
  * memory_region_add_eventfd: Request an eventfd to be triggered when a word
  *                            is written to a location.
  *
diff --git a/kvm-all.c b/kvm-all.c
index a1bc05a8d5c5c..4c826d0eab37b 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -126,6 +126,7 @@ bool kvm_gsi_routing_allowed;
 bool kvm_gsi_direct_mapping;
 bool kvm_allowed;
 bool kvm_readonly_mem_allowed;
+bool kvm_uncached_mem_allowed;
 bool kvm_vm_attributes_allowed;
 
 static const KVMCapabilityInfo kvm_required_capabilites[] = {
@@ -306,6 +307,9 @@ static int kvm_mem_flags(MemoryRegion *mr)
     if (readonly && kvm_readonly_mem_allowed) {
         flags |= KVM_MEM_READONLY;
     }
+    if (memory_region_may_map_uncached(mr) && kvm_uncached_mem_allowed) {
+        flags |= KVM_MEM_UNCACHED;
+    }
     return flags;
 }
 
@@ -1595,6 +1599,11 @@ static int kvm_init(MachineState *ms)
         (kvm_check_extension(s, KVM_CAP_READONLY_MEM) > 0);
 #endif
 
+#ifdef KVM_CAP_UNCACHED_MEM
+    kvm_uncached_mem_allowed =
+        (kvm_check_extension(s, KVM_CAP_UNCACHED_MEM) > 0);
+#endif
+
     kvm_eventfds_allowed =
         (kvm_check_extension(s, KVM_CAP_IOEVENTFD) > 0);
 
diff --git a/memory.c b/memory.c
index ee3f2a8a954ef..495cec1b6650c 100644
--- a/memory.c
+++ b/memory.c
@@ -1549,6 +1549,21 @@ void memory_region_clear_flush_coalesced(MemoryRegion *mr)
     }
 }
 
+void memory_region_set_uncached(MemoryRegion *mr)
+{
+    mr->uncached = true;
+}
+
+void memory_region_clear_uncached(MemoryRegion *mr)
+{
+    mr->uncached = false;
+}
+
+bool memory_region_may_map_uncached(MemoryRegion *mr)
+{
+    return mr->uncached;
+}
+
 void memory_region_add_eventfd(MemoryRegion *mr,
                                hwaddr addr,
                                unsigned size,
-- 
1.8.3.1

  parent reply	other threads:[~2015-03-18 19:12 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-18 19:08 [Qemu-devel] the arm cache coherency cluster "v2" Andrew Jones
2015-03-18 19:10 ` [Qemu-devel] [RFC PATCH 0/3] KVM: Introduce KVM_MEM_UNCACHED Andrew Jones
2015-03-18 19:10   ` [Qemu-devel] [RFC PATCH 1/3] KVM: promote KVM_MEMSLOT_INCOHERENT to uapi Andrew Jones
2015-04-20 15:26     ` Christoffer Dall
2015-03-18 19:10   ` [Qemu-devel] [RFC PATCH 2/3] arm/arm64: KVM: decouple READONLY and UNCACHED Andrew Jones
2015-03-18 19:10   ` [Qemu-devel] [RFC PATCH 3/3] arm/arm64: KVM: implement KVM_MEM_UNCACHED Andrew Jones
2015-03-19 16:56   ` [Qemu-devel] [RFC PATCH 0/3] KVM: Introduce KVM_MEM_UNCACHED Paolo Bonzini
2015-03-19 17:24     ` Andrew Jones
2015-04-29  9:03   ` Alexander Graf
2015-04-29  9:19     ` Peter Maydell
2015-04-29 11:19       ` Andrew Jones
2015-03-18 19:11 ` [Qemu-devel] [RFC PATCH 0/4] support KVM_MEM_UNCACHED Andrew Jones
2015-03-18 19:11   ` [Qemu-devel] [RFC PATCH 1/4] kvm-all: put kvm_mem_flags to more work Andrew Jones
2015-03-18 19:11   ` [Qemu-devel] [RFC PATCH 2/4] HACK: linux header update Andrew Jones
2015-03-18 19:11   ` Andrew Jones [this message]
2015-03-18 19:11   ` [Qemu-devel] [RFC PATCH 4/4] vga: flag vram as uncached Andrew Jones
2015-03-18 19:18 ` [Qemu-devel] the arm cache coherency cluster "v2" Andrew Jones
2015-05-03 21:29   ` Alexander Graf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1426705908-2765-4-git-send-email-drjones@redhat.com \
    --to=drjones@redhat.com \
    --cc=agraf@suse.de \
    --cc=ard.biesheuvel@linaro.org \
    --cc=catalin.marinas@arm.com \
    --cc=christoffer.dall@linaro.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=lersek@redhat.com \
    --cc=m.smarduch@samsung.com \
    --cc=marc.zyngier@arm.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).