From: David Hildenbrand <david@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-s390x@nongnu.org, "Michael S . Tsirkin" <mst@redhat.com>,
Igor Mammedov <imammedo@redhat.com>,
Marcel Apfelbaum <marcel@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Richard Henderson <rth@twiddle.net>,
Eduardo Habkost <ehabkost@redhat.com>,
David Gibson <david@gibson.dropbear.id.au>,
Markus Armbruster <armbru@redhat.com>,
qemu-ppc@nongnu.org, Pankaj Gupta <pagupta@redhat.com>,
Alexander Graf <agraf@suse.de>,
David Hildenbrand <david@redhat.com>
Subject: [Qemu-devel] [PATCH v1 6/8] machine: introduce enforce_memory_device_align() and add it for pc
Date: Thu, 3 May 2018 17:49:34 +0200 [thread overview]
Message-ID: <20180503154936.18946-7-david@redhat.com> (raw)
In-Reply-To: <20180503154936.18946-1-david@redhat.com>
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 <david@redhat.com>
---
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
next prev parent reply other threads:[~2018-05-03 15:50 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-03 15:49 [Qemu-devel] [PATCH v1 0/8] MemoryDevice: introduce and use ResourceHandler David Hildenbrand
2018-05-03 15:49 ` [Qemu-devel] [PATCH v1 1/8] memory-device: always compile support for memory devices for SOFTMMU David Hildenbrand
2018-05-03 15:49 ` [Qemu-devel] [PATCH v1 2/8] qdev: introduce ResourceHandler as a first-stage hotplug handler David Hildenbrand
2018-05-04 14:22 ` David Hildenbrand
2018-05-03 15:49 ` [Qemu-devel] [PATCH v1 3/8] machine: provide default resource handler David Hildenbrand
2018-05-03 15:49 ` [Qemu-devel] [PATCH v1 4/8] memory-device: new functions to handle resource assignment David Hildenbrand
2018-05-03 15:49 ` [Qemu-devel] [PATCH v1 5/8] pc-dimm: implement new memory device functions David Hildenbrand
2018-05-03 15:49 ` David Hildenbrand [this message]
2018-05-03 15:49 ` [Qemu-devel] [PATCH v1 7/8] memory-device: factor out pre-assign into default resource handler David Hildenbrand
2018-05-03 15:49 ` [Qemu-devel] [PATCH v1 8/8] memory-device: factor out (un)assign " David Hildenbrand
2018-05-04 8:49 ` [Qemu-devel] [PATCH v1 0/8] MemoryDevice: introduce and use ResourceHandler Igor Mammedov
2018-05-04 9:19 ` David Hildenbrand
2018-05-04 10:00 ` Igor Mammedov
2018-05-04 11:49 ` David Hildenbrand
2018-05-09 14:13 ` David Hildenbrand
2018-05-10 13:02 ` Igor Mammedov
2018-05-10 13:20 ` David Hildenbrand
2018-05-10 13:32 ` Igor Mammedov
2018-05-11 7:41 ` David Hildenbrand
2018-05-10 13:04 ` [Qemu-devel] [PATCH] qdev: let machine hotplug handler to override bus hotplug handler Igor Mammedov
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=20180503154936.18946-7-david@redhat.com \
--to=david@redhat.com \
--cc=agraf@suse.de \
--cc=armbru@redhat.com \
--cc=david@gibson.dropbear.id.au \
--cc=ehabkost@redhat.com \
--cc=imammedo@redhat.com \
--cc=marcel@redhat.com \
--cc=mst@redhat.com \
--cc=pagupta@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=rth@twiddle.net \
/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).