[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[qemu-s390x] [PATCH v1 6/8] machine: introduce enforce_memory_device_ali
From: |
David Hildenbrand |
Subject: |
[qemu-s390x] [PATCH v1 6/8] machine: introduce enforce_memory_device_align() and add it for pc |
Date: |
Thu, 3 May 2018 17:49:34 +0200 |
For compat handling, we'll have to ask the machine class if a certain
memory device has alignment requirements when assigning resource to
a memory device. This will only be required for PC for now, PPC is fine
(and will be handled via the alignment of the memory region).
Signed-off-by: David Hildenbrand <address@hidden>
---
hw/i386/pc.c | 15 +++++++++++++++
include/hw/boards.h | 8 ++++++++
2 files changed, 23 insertions(+)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index ffcd7b85d9..9405e28cfa 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -2332,6 +2332,20 @@ static void x86_nmi(NMIState *n, int cpu_index, Error
**errp)
}
}
+static void pc_machine_enforce_memory_device_align(const MachineClass *mc,
+ const MemoryDeviceState *md,
+ uint64_t *align)
+{
+ const PCMachineClass *pcmc = PC_MACHINE_CLASS(mc);
+
+ if (object_dynamic_cast(OBJECT(md), TYPE_PC_DIMM)) {
+ /* compat handling: force to TARGET_PAGE_SIZE */
+ if (!pcmc->enforce_aligned_dimm) {
+ *align = TARGET_PAGE_SIZE;
+ }
+ }
+}
+
static void pc_machine_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
@@ -2371,6 +2385,7 @@ static void pc_machine_class_init(ObjectClass *oc, void
*data)
hc->unplug = pc_machine_device_unplug_cb;
nc->nmi_monitor_handler = x86_nmi;
mc->default_cpu_type = TARGET_DEFAULT_CPU_TYPE;
+ mc->enforce_memory_device_align = pc_machine_enforce_memory_device_align;
object_class_property_add(oc, PC_MACHINE_DEVMEM_REGION_SIZE, "int",
pc_machine_get_device_memory_region_size, NULL,
diff --git a/include/hw/boards.h b/include/hw/boards.h
index ff5142d7c2..db66f2e2d9 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -9,6 +9,7 @@
#include "qom/object.h"
#include "qom/cpu.h"
#include "hw/resource-handler.h"
+#include "hw/mem/memory-device.h"
/**
* memory_region_allocate_system_memory - Allocate a board's main memory
@@ -163,6 +164,10 @@ typedef struct {
* should instead use "unimplemented-device" for all memory ranges where
* the guest will attempt to probe for a device that QEMU doesn't
* implement and a stub device is required.
+ * @enforce_memory_device_align:
+ * For some memory devices (e.g. DIMMs), alignment has to be enforced for
+ * compat handling by the machine. This function will only modify the
+ * asignment if it needs to be enforced.
*/
struct MachineClass {
/*< private >*/
@@ -221,6 +226,9 @@ struct MachineClass {
unsigned cpu_index);
const CPUArchIdList *(*possible_cpu_arch_ids)(MachineState *machine);
int64_t (*get_default_cpu_node_id)(const MachineState *ms, int idx);
+ void (*enforce_memory_device_align)(const MachineClass *mc,
+ const MemoryDeviceState *md,
+ uint64_t *align);
};
/**
--
2.14.3
- [qemu-s390x] [PATCH v1 0/8] MemoryDevice: introduce and use ResourceHandler, David Hildenbrand, 2018/05/03
- [qemu-s390x] [PATCH v1 1/8] memory-device: always compile support for memory devices for SOFTMMU, David Hildenbrand, 2018/05/03
- [qemu-s390x] [PATCH v1 2/8] qdev: introduce ResourceHandler as a first-stage hotplug handler, David Hildenbrand, 2018/05/03
- [qemu-s390x] [PATCH v1 3/8] machine: provide default resource handler, David Hildenbrand, 2018/05/03
- [qemu-s390x] [PATCH v1 4/8] memory-device: new functions to handle resource assignment, David Hildenbrand, 2018/05/03
- [qemu-s390x] [PATCH v1 5/8] pc-dimm: implement new memory device functions, David Hildenbrand, 2018/05/03
- [qemu-s390x] [PATCH v1 6/8] machine: introduce enforce_memory_device_align() and add it for pc,
David Hildenbrand <=
- [qemu-s390x] [PATCH v1 7/8] memory-device: factor out pre-assign into default resource handler, David Hildenbrand, 2018/05/03
- [qemu-s390x] [PATCH v1 8/8] memory-device: factor out (un)assign into default resource handler, David Hildenbrand, 2018/05/03
- Re: [qemu-s390x] [Qemu-devel] [PATCH v1 0/8] MemoryDevice: introduce and use ResourceHandler, Igor Mammedov, 2018/05/04
- Re: [qemu-s390x] [PATCH v1 0/8] MemoryDevice: introduce and use ResourceHandler, David Hildenbrand, 2018/05/09