From nobody Thu Oct 30 05:15:29 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1525363071363105.4206315155011; Thu, 3 May 2018 08:57:51 -0700 (PDT) Received: from localhost ([::1]:57404 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fEGcA-0006ib-K6 for importer@patchew.org; Thu, 03 May 2018 11:57:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50371) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fEGUb-0000p5-DA for qemu-devel@nongnu.org; Thu, 03 May 2018 11:50:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fEGUa-0003lr-6M for qemu-devel@nongnu.org; Thu, 03 May 2018 11:50:01 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:51556 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fEGUa-0003li-1G; Thu, 03 May 2018 11:50:00 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8FFF66166C; Thu, 3 May 2018 15:49:59 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-201.ams2.redhat.com [10.36.117.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6D687215CDAE; Thu, 3 May 2018 15:49:57 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Thu, 3 May 2018 17:49:34 +0200 Message-Id: <20180503154936.18946-7-david@redhat.com> In-Reply-To: <20180503154936.18946-1-david@redhat.com> References: <20180503154936.18946-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 03 May 2018 15:49:59 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 03 May 2018 15:49:59 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'david@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v1 6/8] machine: introduce enforce_memory_device_align() and add it for pc X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Pankaj Gupta , Eduardo Habkost , "Michael S . Tsirkin" , David Hildenbrand , Markus Armbruster , Alexander Graf , qemu-s390x@nongnu.org, qemu-ppc@nongnu.org, Paolo Bonzini , Marcel Apfelbaum , Igor Mammedov , David Gibson , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- 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, Erro= r **errp) } } =20 +static void pc_machine_enforce_memory_device_align(const MachineClass *mc, + const MemoryDeviceState= *md, + uint64_t *align) +{ + const PCMachineClass *pcmc =3D 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 =3D TARGET_PAGE_SIZE; + } + } +} + static void pc_machine_class_init(ObjectClass *oc, void *data) { MachineClass *mc =3D MACHINE_CLASS(oc); @@ -2371,6 +2385,7 @@ static void pc_machine_class_init(ObjectClass *oc, vo= id *data) hc->unplug =3D pc_machine_device_unplug_cb; nc->nmi_monitor_handler =3D x86_nmi; mc->default_cpu_type =3D TARGET_DEFAULT_CPU_TYPE; + mc->enforce_memory_device_align =3D pc_machine_enforce_memory_device_a= lign; =20 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" =20 /** * 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 f= or + * 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_inde= x); 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); }; =20 /** --=20 2.14.3