|
|
0a122b |
From e2bf4a6155c08480e42afe12d5ea1ce083c35f00 Mon Sep 17 00:00:00 2001
|
|
|
0a122b |
From: Juan Quintela <quintela@redhat.com>
|
|
|
0a122b |
Date: Tue, 14 Jan 2014 15:07:44 +0100
|
|
|
0a122b |
Subject: [PATCH 33/40] memory: split cpu_physical_memory_* functions to its own include
|
|
|
0a122b |
|
|
|
0a122b |
RH-Author: Juan Quintela <quintela@redhat.com>
|
|
|
0a122b |
Message-id: <1389712071-23303-34-git-send-email-quintela@redhat.com>
|
|
|
0a122b |
Patchwork-id: 56688
|
|
|
0a122b |
O-Subject: [RHEL7 qemu-kvm PATCH 33/40] memory: split cpu_physical_memory_* functions to its own include
|
|
|
0a122b |
Bugzilla: 997559
|
|
|
0a122b |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
0a122b |
RH-Acked-by: Orit Wasserman <owasserm@redhat.com>
|
|
|
0a122b |
RH-Acked-by: Dr. David Alan Gilbert (git) <dgilbert@redhat.com>
|
|
|
0a122b |
|
|
|
0a122b |
All the functions that use ram_addr_t should be here.
|
|
|
0a122b |
|
|
|
0a122b |
Signed-off-by: Juan Quintela <quintela@redhat.com>
|
|
|
0a122b |
Reviewed-by: Orit Wasserman <owasserm@redhat.com>
|
|
|
0a122b |
(cherry picked from commit 220c3ebddbd1ac289ae7fc64733c9501b3921d94)
|
|
|
0a122b |
|
|
|
0a122b |
Conflicts:
|
|
|
0a122b |
exec.c
|
|
|
0a122b |
include/exec/memory-internal.h
|
|
|
0a122b |
|
|
|
0a122b |
Conflicts due to missing upstream commits:
|
|
|
0a122b |
|
|
|
0a122b |
commit d2702032b4746515cff0bf29891a6b6decfc3d86
|
|
|
0a122b |
Author: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
0a122b |
Date: Fri May 24 11:55:06 2013 +0200
|
|
|
0a122b |
|
|
|
0a122b |
memory: export memory_region_access_valid to exec.c
|
|
|
0a122b |
|
|
|
0a122b |
commit d197063fcf969e1269dc53c9c9e9a073f87aa3b4
|
|
|
0a122b |
Author: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
0a122b |
Date: Fri May 24 13:23:38 2013 +0200
|
|
|
0a122b |
|
|
|
0a122b |
memory: move unassigned_mem_ops to memory.c
|
|
|
0a122b |
|
|
|
0a122b |
commit b40acf99bef69fa8ab0f9092ff162fde945eec12
|
|
|
0a122b |
Author: Jan Kiszka <jan.kiszka@siemens.com>
|
|
|
0a122b |
Date: Mon Jun 24 10:45:09 2013 +0200
|
|
|
0a122b |
|
|
|
0a122b |
ioport: Switch dispatching to memory core layer
|
|
|
0a122b |
|
|
|
0a122b |
commit ee983cb3cc8f856b408a272269f434cc9a82ceff
|
|
|
0a122b |
Author: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
0a122b |
Date: Tue May 14 11:47:56 2013 +0200
|
|
|
0a122b |
|
|
|
0a122b |
exec: make qemu_get_ram_ptr private
|
|
|
0a122b |
|
|
|
0a122b |
Signed-off-by: Juan Quintela <quintela@trasno.org>
|
|
|
0a122b |
---
|
|
|
0a122b |
cputlb.c | 1 +
|
|
|
0a122b |
exec.c | 1 +
|
|
|
0a122b |
include/exec/memory-internal.h | 76 ---------------------------------
|
|
|
0a122b |
include/exec/ram_addr.h | 97 ++++++++++++++++++++++++++++++++++++++++++
|
|
|
0a122b |
memory.c | 1 +
|
|
|
0a122b |
5 files changed, 100 insertions(+), 76 deletions(-)
|
|
|
0a122b |
create mode 100644 include/exec/ram_addr.h
|
|
|
0a122b |
|
|
|
0a122b |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
0a122b |
---
|
|
|
0a122b |
cputlb.c | 1 +
|
|
|
0a122b |
exec.c | 1 +
|
|
|
0a122b |
include/exec/memory-internal.h | 76 -------------------------------
|
|
|
0a122b |
include/exec/ram_addr.h | 97 ++++++++++++++++++++++++++++++++++++++++
|
|
|
0a122b |
memory.c | 1 +
|
|
|
0a122b |
5 files changed, 100 insertions(+), 76 deletions(-)
|
|
|
0a122b |
create mode 100644 include/exec/ram_addr.h
|
|
|
0a122b |
|
|
|
0a122b |
diff --git a/cputlb.c b/cputlb.c
|
|
|
0a122b |
index 44ec9bc..7699fdd 100644
|
|
|
0a122b |
--- a/cputlb.c
|
|
|
0a122b |
+++ b/cputlb.c
|
|
|
0a122b |
@@ -26,6 +26,7 @@
|
|
|
0a122b |
#include "exec/cputlb.h"
|
|
|
0a122b |
|
|
|
0a122b |
#include "exec/memory-internal.h"
|
|
|
0a122b |
+#include "exec/ram_addr.h"
|
|
|
0a122b |
|
|
|
0a122b |
//#define DEBUG_TLB
|
|
|
0a122b |
//#define DEBUG_TLB_CHECK
|
|
|
0a122b |
diff --git a/exec.c b/exec.c
|
|
|
0a122b |
index 12adb12..b16ef4a 100644
|
|
|
0a122b |
--- a/exec.c
|
|
|
0a122b |
+++ b/exec.c
|
|
|
0a122b |
@@ -50,6 +50,7 @@
|
|
|
0a122b |
#include "translate-all.h"
|
|
|
0a122b |
|
|
|
0a122b |
#include "exec/memory-internal.h"
|
|
|
0a122b |
+#include "exec/ram_addr.h"
|
|
|
0a122b |
|
|
|
0a122b |
//#define DEBUG_UNASSIGNED
|
|
|
0a122b |
//#define DEBUG_SUBPAGE
|
|
|
0a122b |
diff --git a/include/exec/memory-internal.h b/include/exec/memory-internal.h
|
|
|
0a122b |
index 327d54e..8b558bf 100644
|
|
|
0a122b |
--- a/include/exec/memory-internal.h
|
|
|
0a122b |
+++ b/include/exec/memory-internal.h
|
|
|
0a122b |
@@ -20,87 +20,11 @@
|
|
|
0a122b |
#define MEMORY_INTERNAL_H
|
|
|
0a122b |
|
|
|
0a122b |
#ifndef CONFIG_USER_ONLY
|
|
|
0a122b |
-#include "hw/xen/xen.h"
|
|
|
0a122b |
-
|
|
|
0a122b |
-
|
|
|
0a122b |
typedef struct AddressSpaceDispatch AddressSpaceDispatch;
|
|
|
0a122b |
|
|
|
0a122b |
void address_space_init_dispatch(AddressSpace *as);
|
|
|
0a122b |
void address_space_destroy_dispatch(AddressSpace *as);
|
|
|
0a122b |
|
|
|
0a122b |
-ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
|
|
|
0a122b |
- MemoryRegion *mr);
|
|
|
0a122b |
-ram_addr_t qemu_ram_alloc(ram_addr_t size, MemoryRegion *mr);
|
|
|
0a122b |
-void qemu_ram_free(ram_addr_t addr);
|
|
|
0a122b |
-void qemu_ram_free_from_ptr(ram_addr_t addr);
|
|
|
0a122b |
-
|
|
|
0a122b |
-static inline bool cpu_physical_memory_get_dirty(ram_addr_t start,
|
|
|
0a122b |
- ram_addr_t length,
|
|
|
0a122b |
- unsigned client)
|
|
|
0a122b |
-{
|
|
|
0a122b |
- unsigned long end, page, next;
|
|
|
0a122b |
-
|
|
|
0a122b |
- assert(client < DIRTY_MEMORY_NUM);
|
|
|
0a122b |
-
|
|
|
0a122b |
- end = TARGET_PAGE_ALIGN(start + length) >> TARGET_PAGE_BITS;
|
|
|
0a122b |
- page = start >> TARGET_PAGE_BITS;
|
|
|
0a122b |
- next = find_next_bit(ram_list.dirty_memory[client], end, page);
|
|
|
0a122b |
-
|
|
|
0a122b |
- return next < end;
|
|
|
0a122b |
-}
|
|
|
0a122b |
-
|
|
|
0a122b |
-static inline bool cpu_physical_memory_get_dirty_flag(ram_addr_t addr,
|
|
|
0a122b |
- unsigned client)
|
|
|
0a122b |
-{
|
|
|
0a122b |
- return cpu_physical_memory_get_dirty(addr, 1, client);
|
|
|
0a122b |
-}
|
|
|
0a122b |
-
|
|
|
0a122b |
-static inline bool cpu_physical_memory_is_clean(ram_addr_t addr)
|
|
|
0a122b |
-{
|
|
|
0a122b |
- bool vga = cpu_physical_memory_get_dirty_flag(addr, DIRTY_MEMORY_VGA);
|
|
|
0a122b |
- bool code = cpu_physical_memory_get_dirty_flag(addr, DIRTY_MEMORY_CODE);
|
|
|
0a122b |
- bool migration =
|
|
|
0a122b |
- cpu_physical_memory_get_dirty_flag(addr, DIRTY_MEMORY_MIGRATION);
|
|
|
0a122b |
- return !(vga && code && migration);
|
|
|
0a122b |
-}
|
|
|
0a122b |
-
|
|
|
0a122b |
-static inline void cpu_physical_memory_set_dirty_flag(ram_addr_t addr,
|
|
|
0a122b |
- unsigned client)
|
|
|
0a122b |
-{
|
|
|
0a122b |
- assert(client < DIRTY_MEMORY_NUM);
|
|
|
0a122b |
- set_bit(addr >> TARGET_PAGE_BITS, ram_list.dirty_memory[client]);
|
|
|
0a122b |
-}
|
|
|
0a122b |
-
|
|
|
0a122b |
-static inline void cpu_physical_memory_set_dirty_range(ram_addr_t start,
|
|
|
0a122b |
- ram_addr_t length)
|
|
|
0a122b |
-{
|
|
|
0a122b |
- unsigned long end, page;
|
|
|
0a122b |
-
|
|
|
0a122b |
- end = TARGET_PAGE_ALIGN(start + length) >> TARGET_PAGE_BITS;
|
|
|
0a122b |
- page = start >> TARGET_PAGE_BITS;
|
|
|
0a122b |
- bitmap_set(ram_list.dirty_memory[DIRTY_MEMORY_MIGRATION], page, end - page);
|
|
|
0a122b |
- bitmap_set(ram_list.dirty_memory[DIRTY_MEMORY_VGA], page, end - page);
|
|
|
0a122b |
- bitmap_set(ram_list.dirty_memory[DIRTY_MEMORY_CODE], page, end - page);
|
|
|
0a122b |
- xen_modified_memory(start, length);
|
|
|
0a122b |
-}
|
|
|
0a122b |
-
|
|
|
0a122b |
-static inline void cpu_physical_memory_clear_dirty_range(ram_addr_t start,
|
|
|
0a122b |
- ram_addr_t length,
|
|
|
0a122b |
- unsigned client)
|
|
|
0a122b |
-{
|
|
|
0a122b |
- unsigned long end, page;
|
|
|
0a122b |
-
|
|
|
0a122b |
- assert(client < DIRTY_MEMORY_NUM);
|
|
|
0a122b |
- end = TARGET_PAGE_ALIGN(start + length) >> TARGET_PAGE_BITS;
|
|
|
0a122b |
- page = start >> TARGET_PAGE_BITS;
|
|
|
0a122b |
- bitmap_clear(ram_list.dirty_memory[client], page, end - page);
|
|
|
0a122b |
-}
|
|
|
0a122b |
-
|
|
|
0a122b |
-void cpu_physical_memory_reset_dirty(ram_addr_t start, ram_addr_t length,
|
|
|
0a122b |
- unsigned client);
|
|
|
0a122b |
-
|
|
|
0a122b |
extern const IORangeOps memory_region_iorange_ops;
|
|
|
0a122b |
-
|
|
|
0a122b |
#endif
|
|
|
0a122b |
-
|
|
|
0a122b |
#endif
|
|
|
0a122b |
diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h
|
|
|
0a122b |
new file mode 100644
|
|
|
0a122b |
index 0000000..0caa239
|
|
|
0a122b |
--- /dev/null
|
|
|
0a122b |
+++ b/include/exec/ram_addr.h
|
|
|
0a122b |
@@ -0,0 +1,97 @@
|
|
|
0a122b |
+/*
|
|
|
0a122b |
+ * Declarations for cpu physical memory functions
|
|
|
0a122b |
+ *
|
|
|
0a122b |
+ * Copyright 2011 Red Hat, Inc. and/or its affiliates
|
|
|
0a122b |
+ *
|
|
|
0a122b |
+ * Authors:
|
|
|
0a122b |
+ * Avi Kivity <avi@redhat.com>
|
|
|
0a122b |
+ *
|
|
|
0a122b |
+ * This work is licensed under the terms of the GNU GPL, version 2 or
|
|
|
0a122b |
+ * later. See the COPYING file in the top-level directory.
|
|
|
0a122b |
+ *
|
|
|
0a122b |
+ */
|
|
|
0a122b |
+
|
|
|
0a122b |
+/*
|
|
|
0a122b |
+ * This header is for use by exec.c and memory.c ONLY. Do not include it.
|
|
|
0a122b |
+ * The functions declared here will be removed soon.
|
|
|
0a122b |
+ */
|
|
|
0a122b |
+
|
|
|
0a122b |
+#ifndef RAM_ADDR_H
|
|
|
0a122b |
+#define RAM_ADDR_H
|
|
|
0a122b |
+
|
|
|
0a122b |
+#ifndef CONFIG_USER_ONLY
|
|
|
0a122b |
+#include "hw/xen/xen.h"
|
|
|
0a122b |
+
|
|
|
0a122b |
+ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
|
|
|
0a122b |
+ MemoryRegion *mr);
|
|
|
0a122b |
+ram_addr_t qemu_ram_alloc(ram_addr_t size, MemoryRegion *mr);
|
|
|
0a122b |
+void qemu_ram_free(ram_addr_t addr);
|
|
|
0a122b |
+void qemu_ram_free_from_ptr(ram_addr_t addr);
|
|
|
0a122b |
+
|
|
|
0a122b |
+static inline bool cpu_physical_memory_get_dirty(ram_addr_t start,
|
|
|
0a122b |
+ ram_addr_t length,
|
|
|
0a122b |
+ unsigned client)
|
|
|
0a122b |
+{
|
|
|
0a122b |
+ unsigned long end, page, next;
|
|
|
0a122b |
+
|
|
|
0a122b |
+ assert(client < DIRTY_MEMORY_NUM);
|
|
|
0a122b |
+
|
|
|
0a122b |
+ end = TARGET_PAGE_ALIGN(start + length) >> TARGET_PAGE_BITS;
|
|
|
0a122b |
+ page = start >> TARGET_PAGE_BITS;
|
|
|
0a122b |
+ next = find_next_bit(ram_list.dirty_memory[client], end, page);
|
|
|
0a122b |
+
|
|
|
0a122b |
+ return next < end;
|
|
|
0a122b |
+}
|
|
|
0a122b |
+
|
|
|
0a122b |
+static inline bool cpu_physical_memory_get_dirty_flag(ram_addr_t addr,
|
|
|
0a122b |
+ unsigned client)
|
|
|
0a122b |
+{
|
|
|
0a122b |
+ return cpu_physical_memory_get_dirty(addr, 1, client);
|
|
|
0a122b |
+}
|
|
|
0a122b |
+
|
|
|
0a122b |
+static inline bool cpu_physical_memory_is_clean(ram_addr_t addr)
|
|
|
0a122b |
+{
|
|
|
0a122b |
+ bool vga = cpu_physical_memory_get_dirty_flag(addr, DIRTY_MEMORY_VGA);
|
|
|
0a122b |
+ bool code = cpu_physical_memory_get_dirty_flag(addr, DIRTY_MEMORY_CODE);
|
|
|
0a122b |
+ bool migration =
|
|
|
0a122b |
+ cpu_physical_memory_get_dirty_flag(addr, DIRTY_MEMORY_MIGRATION);
|
|
|
0a122b |
+ return !(vga && code && migration);
|
|
|
0a122b |
+}
|
|
|
0a122b |
+
|
|
|
0a122b |
+static inline void cpu_physical_memory_set_dirty_flag(ram_addr_t addr,
|
|
|
0a122b |
+ unsigned client)
|
|
|
0a122b |
+{
|
|
|
0a122b |
+ assert(client < DIRTY_MEMORY_NUM);
|
|
|
0a122b |
+ set_bit(addr >> TARGET_PAGE_BITS, ram_list.dirty_memory[client]);
|
|
|
0a122b |
+}
|
|
|
0a122b |
+
|
|
|
0a122b |
+static inline void cpu_physical_memory_set_dirty_range(ram_addr_t start,
|
|
|
0a122b |
+ ram_addr_t length)
|
|
|
0a122b |
+{
|
|
|
0a122b |
+ unsigned long end, page;
|
|
|
0a122b |
+
|
|
|
0a122b |
+ end = TARGET_PAGE_ALIGN(start + length) >> TARGET_PAGE_BITS;
|
|
|
0a122b |
+ page = start >> TARGET_PAGE_BITS;
|
|
|
0a122b |
+ bitmap_set(ram_list.dirty_memory[DIRTY_MEMORY_MIGRATION], page, end - page);
|
|
|
0a122b |
+ bitmap_set(ram_list.dirty_memory[DIRTY_MEMORY_VGA], page, end - page);
|
|
|
0a122b |
+ bitmap_set(ram_list.dirty_memory[DIRTY_MEMORY_CODE], page, end - page);
|
|
|
0a122b |
+ xen_modified_memory(start, length);
|
|
|
0a122b |
+}
|
|
|
0a122b |
+
|
|
|
0a122b |
+static inline void cpu_physical_memory_clear_dirty_range(ram_addr_t start,
|
|
|
0a122b |
+ ram_addr_t length,
|
|
|
0a122b |
+ unsigned client)
|
|
|
0a122b |
+{
|
|
|
0a122b |
+ unsigned long end, page;
|
|
|
0a122b |
+
|
|
|
0a122b |
+ assert(client < DIRTY_MEMORY_NUM);
|
|
|
0a122b |
+ end = TARGET_PAGE_ALIGN(start + length) >> TARGET_PAGE_BITS;
|
|
|
0a122b |
+ page = start >> TARGET_PAGE_BITS;
|
|
|
0a122b |
+ bitmap_clear(ram_list.dirty_memory[client], page, end - page);
|
|
|
0a122b |
+}
|
|
|
0a122b |
+
|
|
|
0a122b |
+void cpu_physical_memory_reset_dirty(ram_addr_t start, ram_addr_t length,
|
|
|
0a122b |
+ unsigned client);
|
|
|
0a122b |
+
|
|
|
0a122b |
+#endif
|
|
|
0a122b |
+#endif
|
|
|
0a122b |
diff --git a/memory.c b/memory.c
|
|
|
0a122b |
index b49642b..685912d 100644
|
|
|
0a122b |
--- a/memory.c
|
|
|
0a122b |
+++ b/memory.c
|
|
|
0a122b |
@@ -21,6 +21,7 @@
|
|
|
0a122b |
#include <assert.h>
|
|
|
0a122b |
|
|
|
0a122b |
#include "exec/memory-internal.h"
|
|
|
0a122b |
+#include "exec/ram_addr.h"
|
|
|
0a122b |
|
|
|
0a122b |
static unsigned memory_region_transaction_depth;
|
|
|
0a122b |
static bool memory_region_update_pending;
|
|
|
0a122b |
--
|
|
|
0a122b |
1.7.1
|
|
|
0a122b |
|