From nobody Tue Nov 4 15:25:24 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 1530552333393890.499771002006; Mon, 2 Jul 2018 10:25:33 -0700 (PDT) Received: from localhost ([::1]:34501 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa2Zr-0001Jd-G7 for importer@patchew.org; Mon, 02 Jul 2018 13:25:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45407) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa2Xa-0008IO-Cc for qemu-devel@nongnu.org; Mon, 02 Jul 2018 13:23:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa2XZ-0006J2-0I for qemu-devel@nongnu.org; Mon, 02 Jul 2018 13:23:06 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:47970 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 1fa2XU-0006ED-7Y; Mon, 02 Jul 2018 13:23:00 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CAD6687AC7; Mon, 2 Jul 2018 17:22:59 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-57.ams2.redhat.com [10.36.116.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id B9EAC111AF38; Mon, 2 Jul 2018 17:22:57 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, peter.maydell@linaro.org, shameerali.kolothum.thodi@huawei.com, kwangwoo.lee@sk.com, imammedo@redhat.com, david@redhat.com Date: Mon, 2 Jul 2018 19:22:28 +0200 Message-Id: <1530552162-15533-2-git-send-email-eric.auger@redhat.com> In-Reply-To: <1530552162-15533-1-git-send-email-eric.auger@redhat.com> References: <1530552162-15533-1-git-send-email-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 02 Jul 2018 17:22:59 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 02 Jul 2018 17:22:59 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'eric.auger@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] [RFC v2 01/15] linux-headers: header update for KVM/ARM KVM_ARM_GET_MAX_VM_PHYS_SHIFT 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: wei@redhat.com, drjones@redhat.com, david@gibson.dropbear.id.au, dgilbert@redhat.com, agraf@suse.de 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" This is a header update against git://linux-arm.org/linux-skp.git ipa52/v3 to get the KVM_ARM_GET_MAX_VM_PHYS_SHIFT ioctl. This allows to retrieve the IPA address range KVM supports. Signed-off-by: Eric Auger --- include/standard-headers/linux/virtio_config.h | 16 ++++++++++++---- linux-headers/asm-mips/unistd.h | 18 ++++++++++++------ linux-headers/asm-powerpc/kvm.h | 1 + linux-headers/linux/kvm.h | 16 ++++++++++++++++ 4 files changed, 41 insertions(+), 10 deletions(-) diff --git a/include/standard-headers/linux/virtio_config.h b/include/stand= ard-headers/linux/virtio_config.h index b777069..0b19436 100644 --- a/include/standard-headers/linux/virtio_config.h +++ b/include/standard-headers/linux/virtio_config.h @@ -45,11 +45,14 @@ /* We've given up on this device. */ #define VIRTIO_CONFIG_S_FAILED 0x80 =20 -/* Some virtio feature bits (currently bits 28 through 32) are reserved fo= r the - * transport being used (eg. virtio_ring), the rest are per-device feature - * bits. */ +/* + * Virtio feature bits VIRTIO_TRANSPORT_F_START through + * VIRTIO_TRANSPORT_F_END are reserved for the transport + * being used (e.g. virtio_ring, virtio_pci etc.), the + * rest are per-device feature bits. + */ #define VIRTIO_TRANSPORT_F_START 28 -#define VIRTIO_TRANSPORT_F_END 34 +#define VIRTIO_TRANSPORT_F_END 38 =20 #ifndef VIRTIO_CONFIG_NO_LEGACY /* Do we get callbacks when the ring is completely used, even if we've @@ -71,4 +74,9 @@ * this is for compatibility with legacy systems. */ #define VIRTIO_F_IOMMU_PLATFORM 33 + +/* + * Does the device support Single Root I/O Virtualization? + */ +#define VIRTIO_F_SR_IOV 37 #endif /* _LINUX_VIRTIO_CONFIG_H */ diff --git a/linux-headers/asm-mips/unistd.h b/linux-headers/asm-mips/unist= d.h index 9bfef7f..d4a85ef 100644 --- a/linux-headers/asm-mips/unistd.h +++ b/linux-headers/asm-mips/unistd.h @@ -388,17 +388,19 @@ #define __NR_pkey_alloc (__NR_Linux + 364) #define __NR_pkey_free (__NR_Linux + 365) #define __NR_statx (__NR_Linux + 366) +#define __NR_rseq (__NR_Linux + 367) +#define __NR_io_pgetevents (__NR_Linux + 368) =20 =20 /* * Offset of the last Linux o32 flavoured syscall */ -#define __NR_Linux_syscalls 366 +#define __NR_Linux_syscalls 368 =20 #endif /* _MIPS_SIM =3D=3D _MIPS_SIM_ABI32 */ =20 #define __NR_O32_Linux 4000 -#define __NR_O32_Linux_syscalls 366 +#define __NR_O32_Linux_syscalls 368 =20 #if _MIPS_SIM =3D=3D _MIPS_SIM_ABI64 =20 @@ -733,16 +735,18 @@ #define __NR_pkey_alloc (__NR_Linux + 324) #define __NR_pkey_free (__NR_Linux + 325) #define __NR_statx (__NR_Linux + 326) +#define __NR_rseq (__NR_Linux + 327) +#define __NR_io_pgetevents (__NR_Linux + 328) =20 /* * Offset of the last Linux 64-bit flavoured syscall */ -#define __NR_Linux_syscalls 326 +#define __NR_Linux_syscalls 328 =20 #endif /* _MIPS_SIM =3D=3D _MIPS_SIM_ABI64 */ =20 #define __NR_64_Linux 5000 -#define __NR_64_Linux_syscalls 326 +#define __NR_64_Linux_syscalls 328 =20 #if _MIPS_SIM =3D=3D _MIPS_SIM_NABI32 =20 @@ -1081,15 +1085,17 @@ #define __NR_pkey_alloc (__NR_Linux + 328) #define __NR_pkey_free (__NR_Linux + 329) #define __NR_statx (__NR_Linux + 330) +#define __NR_rseq (__NR_Linux + 331) +#define __NR_io_pgetevents (__NR_Linux + 332) =20 /* * Offset of the last N32 flavoured syscall */ -#define __NR_Linux_syscalls 330 +#define __NR_Linux_syscalls 332 =20 #endif /* _MIPS_SIM =3D=3D _MIPS_SIM_NABI32 */ =20 #define __NR_N32_Linux 6000 -#define __NR_N32_Linux_syscalls 330 +#define __NR_N32_Linux_syscalls 332 =20 #endif /* _ASM_UNISTD_H */ diff --git a/linux-headers/asm-powerpc/kvm.h b/linux-headers/asm-powerpc/kv= m.h index 833ed9a..1b32b56 100644 --- a/linux-headers/asm-powerpc/kvm.h +++ b/linux-headers/asm-powerpc/kvm.h @@ -633,6 +633,7 @@ struct kvm_ppc_cpu_char { #define KVM_REG_PPC_PSSCR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xbd) =20 #define KVM_REG_PPC_DEC_EXPIRY (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xbe) +#define KVM_REG_PPC_ONLINE (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0xbf) =20 /* Transactional Memory checkpointed state: * This is all GPRs, all VSX regs and a subset of SPRs diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h index 98f389a..0a90115 100644 --- a/linux-headers/linux/kvm.h +++ b/linux-headers/linux/kvm.h @@ -751,6 +751,16 @@ struct kvm_ppc_resize_hpt { #define KVM_S390_SIE_PAGE_OFFSET 1 =20 /* + * On arm/arm64, machine type can be used to request the physical + * address size for the VM. Bits [7-0] have been reserved for the + * PA size shift (i.e, log2(PA_Size)). For backward compatibility, + * value 0 implies the default IPA size, which is 40bits. + */ +#define KVM_VM_TYPE_ARM_PHYS_SHIFT_MASK 0xff +#define KVM_VM_TYPE_ARM_PHYS_SHIFT(x) \ + ((x) & KVM_VM_TYPE_ARM_PHYS_SHIFT_MASK) + +/* * ioctls for /dev/kvm fds: */ #define KVM_GET_API_VERSION _IO(KVMIO, 0x00) @@ -775,6 +785,12 @@ struct kvm_ppc_resize_hpt { #define KVM_GET_MSR_FEATURE_INDEX_LIST _IOWR(KVMIO, 0x0a, struct kvm_ms= r_list) =20 /* + * Get the maximum physical address size supported by the host. + * Returns log2(Max-Physical-Address-Size) + */ +#define KVM_ARM_GET_MAX_VM_PHYS_SHIFT _IO(KVMIO, 0x0b) + +/* * Extension capability list. */ #define KVM_CAP_IRQCHIP 0 --=20 2.5.5 From nobody Tue Nov 4 15:25:24 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 1530552333050895.6669952620401; Mon, 2 Jul 2018 10:25:33 -0700 (PDT) Received: from localhost ([::1]:34500 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa2Zr-0001JA-7g for importer@patchew.org; Mon, 02 Jul 2018 13:25:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45405) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa2Xa-0008IL-Ah for qemu-devel@nongnu.org; Mon, 02 Jul 2018 13:23:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa2XZ-0006JJ-89 for qemu-devel@nongnu.org; Mon, 02 Jul 2018 13:23:06 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:42262 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 1fa2XW-0006GE-NT; Mon, 02 Jul 2018 13:23:02 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2BFC581A4EA6; Mon, 2 Jul 2018 17:23:02 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-57.ams2.redhat.com [10.36.116.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0EA7A111AF38; Mon, 2 Jul 2018 17:22:59 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, peter.maydell@linaro.org, shameerali.kolothum.thodi@huawei.com, kwangwoo.lee@sk.com, imammedo@redhat.com, david@redhat.com Date: Mon, 2 Jul 2018 19:22:29 +0200 Message-Id: <1530552162-15533-3-git-send-email-eric.auger@redhat.com> In-Reply-To: <1530552162-15533-1-git-send-email-eric.auger@redhat.com> References: <1530552162-15533-1-git-send-email-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 02 Jul 2018 17:23:02 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 02 Jul 2018 17:23:02 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'eric.auger@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] [RFC v2 02/15] hw/boards: Add a MachineState parameter to kvm_type callback 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: wei@redhat.com, drjones@redhat.com, david@gibson.dropbear.id.au, dgilbert@redhat.com, agraf@suse.de 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" On ARM, the kvm_type will be resolved by querying the KVMState. Let's add the MachineState handle to the callback so that we can retrieve the KVMState handle. in kvm_init, when the callback is called, the kvm_state variable is not yet set. Signed-off-by: Eric Auger Acked-by: David Gibson [ppc parts] --- accel/kvm/kvm-all.c | 2 +- hw/ppc/mac_newworld.c | 2 +- hw/ppc/mac_oldworld.c | 2 +- hw/ppc/spapr.c | 2 +- include/hw/boards.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index eb7db92..37ac834 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -1549,7 +1549,7 @@ static int kvm_init(MachineState *ms) =20 kvm_type =3D qemu_opt_get(qemu_get_machine_opts(), "kvm-type"); if (mc->kvm_type) { - type =3D mc->kvm_type(kvm_type); + type =3D mc->kvm_type(ms, kvm_type); } else if (kvm_type) { ret =3D -EINVAL; fprintf(stderr, "Invalid argument kvm-type=3D%s\n", kvm_type); diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c index ff715ff..606b827 100644 --- a/hw/ppc/mac_newworld.c +++ b/hw/ppc/mac_newworld.c @@ -511,7 +511,7 @@ static void ppc_core99_init(MachineState *machine) qemu_register_boot_set(fw_cfg_boot_set, fw_cfg); } =20 -static int core99_kvm_type(const char *arg) +static int core99_kvm_type(MachineState *ms, const char *arg) { /* Always force PR KVM */ return 2; diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c index 4608bab..1211fcd 100644 --- a/hw/ppc/mac_oldworld.c +++ b/hw/ppc/mac_oldworld.c @@ -363,7 +363,7 @@ static void ppc_heathrow_init(MachineState *machine) qemu_register_boot_set(fw_cfg_boot_set, fw_cfg); } =20 -static int heathrow_kvm_type(const char *arg) +static int heathrow_kvm_type(MachineState *ms, const char *arg) { /* Always force PR KVM */ return 2; diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index b32b971..db6b018 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2841,7 +2841,7 @@ static void spapr_machine_init(MachineState *machine) } } =20 -static int spapr_kvm_type(const char *vm_type) +static int spapr_kvm_type(MachineState *ms, const char *vm_type) { if (!vm_type) { return 0; diff --git a/include/hw/boards.h b/include/hw/boards.h index 79069dd..3ac9594 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -173,7 +173,7 @@ struct MachineClass { void (*init)(MachineState *state); void (*reset)(void); void (*hot_add_cpu)(const int64_t id, Error **errp); - int (*kvm_type)(const char *arg); + int (*kvm_type)(MachineState *ms, const char *arg); =20 BlockInterfaceType block_default_type; int units_per_default_bus; --=20 2.5.5 From nobody Tue Nov 4 15:25:24 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 1530552508848900.3496123162358; Mon, 2 Jul 2018 10:28:28 -0700 (PDT) Received: from localhost ([::1]:34518 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa2ci-0003fC-2U for importer@patchew.org; Mon, 02 Jul 2018 13:28:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45533) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa2Xi-0008Sx-An for qemu-devel@nongnu.org; Mon, 02 Jul 2018 13:23:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa2Xd-0006NK-Cu for qemu-devel@nongnu.org; Mon, 02 Jul 2018 13:23:14 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:44628 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 1fa2Xb-0006Kx-1r; Mon, 02 Jul 2018 13:23:07 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9365740122DE; Mon, 2 Jul 2018 17:23:06 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-57.ams2.redhat.com [10.36.116.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5C4A7111AF38; Mon, 2 Jul 2018 17:23:02 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, peter.maydell@linaro.org, shameerali.kolothum.thodi@huawei.com, kwangwoo.lee@sk.com, imammedo@redhat.com, david@redhat.com Date: Mon, 2 Jul 2018 19:22:30 +0200 Message-Id: <1530552162-15533-4-git-send-email-eric.auger@redhat.com> In-Reply-To: <1530552162-15533-1-git-send-email-eric.auger@redhat.com> References: <1530552162-15533-1-git-send-email-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Mon, 02 Jul 2018 17:23:06 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Mon, 02 Jul 2018 17:23:06 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'eric.auger@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] [RFC v2 03/15] kvm: add kvm_arm_get_max_vm_phys_shift 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: wei@redhat.com, drjones@redhat.com, david@gibson.dropbear.id.au, dgilbert@redhat.com, agraf@suse.de 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" Add the kvm_arm_get_max_vm_phys_shift() helper that returns the log of the maximum IPA size supported by KVM. This capability needs to be known to create the VM with a correct IPA max size (kvm_type passed along KVM_CREATE_VM ioctl. Signed-off-by: Eric Auger --- v1 -> v2: - put this in ARM specific code --- target/arm/kvm.c | 9 +++++++++ target/arm/kvm_arm.h | 16 ++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/target/arm/kvm.c b/target/arm/kvm.c index 65f867d..7d501ca 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -18,6 +18,7 @@ #include "qemu/error-report.h" #include "sysemu/sysemu.h" #include "sysemu/kvm.h" +#include "sysemu/kvm_int.h" #include "kvm_arm.h" #include "cpu.h" #include "trace.h" @@ -154,6 +155,13 @@ void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu) env->features =3D arm_host_cpu_features.features; } =20 +int kvm_arm_get_max_vm_phys_shift(MachineState *ms) +{ + KVMState *s =3D KVM_STATE(ms->accelerator); + + return kvm_ioctl(s, KVM_ARM_GET_MAX_VM_PHYS_SHIFT, 0); +} + int kvm_arch_init(MachineState *ms, KVMState *s) { /* For ARM interrupt delivery is always asynchronous, @@ -713,3 +721,4 @@ int kvm_arch_msi_data_to_gsi(uint32_t data) { return (data - 32) & 0xffff; } + diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h index 863f205..ee973f6 100644 --- a/target/arm/kvm_arm.h +++ b/target/arm/kvm_arm.h @@ -183,6 +183,17 @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures = *ahcf); void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu); =20 /** + * kvm_arm_get_max_vm_phys_shift - Returns log2 of the max IPA size + * supported by KVM + * + * @s: Machine state handle + * + * Return the max number of IPA bits or a negative value if + * the host kernel does not expose this value. + */ +int kvm_arm_get_max_vm_phys_shift(MachineState *ms); + +/** * kvm_arm_sync_mpstate_to_kvm * @cpu: ARMCPU * @@ -214,6 +225,11 @@ static inline void kvm_arm_set_cpu_features_from_host(= ARMCPU *cpu) cpu->host_cpu_probe_failed =3D true; } =20 +static inline int kvm_arm_get_max_vm_phys_shift(MachineState *ms) +{ + return -ENOENT; +} + static inline int kvm_arm_vgic_probe(void) { return 0; --=20 2.5.5 From nobody Tue Nov 4 15:25:24 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530552688809498.03380442262915; Mon, 2 Jul 2018 10:31:28 -0700 (PDT) Received: from localhost ([::1]:34539 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa2fU-000620-W9 for importer@patchew.org; Mon, 02 Jul 2018 13:31:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45688) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa2Xs-00007H-Vq for qemu-devel@nongnu.org; Mon, 02 Jul 2018 13:23:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa2Xn-0006Xc-Ui for qemu-devel@nongnu.org; Mon, 02 Jul 2018 13:23:24 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:42272 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 1fa2Xk-0006Ta-18; Mon, 02 Jul 2018 13:23:16 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 957EB81A4EB7; Mon, 2 Jul 2018 17:23:15 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-57.ams2.redhat.com [10.36.116.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id CADFF111AF38; Mon, 2 Jul 2018 17:23:06 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, peter.maydell@linaro.org, shameerali.kolothum.thodi@huawei.com, kwangwoo.lee@sk.com, imammedo@redhat.com, david@redhat.com Date: Mon, 2 Jul 2018 19:22:31 +0200 Message-Id: <1530552162-15533-5-git-send-email-eric.auger@redhat.com> In-Reply-To: <1530552162-15533-1-git-send-email-eric.auger@redhat.com> References: <1530552162-15533-1-git-send-email-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 02 Jul 2018 17:23:15 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 02 Jul 2018 17:23:15 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'eric.auger@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] [RFC v2 04/15] hw/arm/virt: support kvm_type property 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: wei@redhat.com, drjones@redhat.com, david@gibson.dropbear.id.au, dgilbert@redhat.com, agraf@suse.de 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" The kvm-type property currently is used to pass a user parameter to KVM_CREATE_VM. This matches the way KVM/ARM expects to pass the max_vm_phys_shift parameter. This patch adds the support or the kvm-type property in machvirt and also implements the machine class kvm_type() callback so that it either returns the kvm-type value provided by the user or returns the max_vm_phys_shift exposed by KVM. for instance, the usespace can use the following option to instantiate a 42b IPA guest: -machine kvm-type=3D42 Signed-off-by: Eric Auger --- hw/arm/virt.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ include/hw/arm/virt.h | 1 + 2 files changed, 45 insertions(+) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 281ddcd..04a32de 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1649,6 +1649,21 @@ static void virt_set_iommu(Object *obj, const char *= value, Error **errp) } } =20 +static char *virt_get_kvm_type(Object *obj, Error **errp) +{ + VirtMachineState *vms =3D VIRT_MACHINE(obj); + + return g_strdup(vms->kvm_type); +} + +static void virt_set_kvm_type(Object *obj, const char *value, Error **errp) +{ + VirtMachineState *vms =3D VIRT_MACHINE(obj); + + g_free(vms->kvm_type); + vms->kvm_type =3D g_strdup(value); +} + static CpuInstanceProperties virt_cpu_index_to_props(MachineState *ms, unsigned cpu_index) { @@ -1710,6 +1725,31 @@ static HotplugHandler *virt_machine_get_hotplug_hand= ler(MachineState *machine, return NULL; } =20 +static int virt_kvm_type(MachineState *ms, const char *type_str) +{ + int max_vm_phys_shift, ret =3D 0; + uint64_t type; + + if (!type_str) { + max_vm_phys_shift =3D kvm_arm_get_max_vm_phys_shift(ms); + if (max_vm_phys_shift < 0) { + goto out; + } + } else { + type =3D g_ascii_strtoll(type_str, NULL, 0); + type &=3D 0xFF; + max_vm_phys_shift =3D (int)type; + if (max_vm_phys_shift < 40 || max_vm_phys_shift > 52) { + warn_report("valid kvm-type type values are within [40, 52]:" + " option is ignored and VM is created with 40b IPA= "); + goto out; + } + } + ret =3D max_vm_phys_shift; +out: + return ret; +} + static void virt_machine_class_init(ObjectClass *oc, void *data) { MachineClass *mc =3D MACHINE_CLASS(oc); @@ -1733,6 +1773,7 @@ static void virt_machine_class_init(ObjectClass *oc, = void *data) mc->cpu_index_to_instance_props =3D virt_cpu_index_to_props; mc->default_cpu_type =3D ARM_CPU_TYPE_NAME("cortex-a15"); mc->get_default_cpu_node_id =3D virt_get_default_cpu_node_id; + mc->kvm_type =3D virt_kvm_type; assert(!mc->get_hotplug_handler); mc->get_hotplug_handler =3D virt_machine_get_hotplug_handler; hc->plug =3D virt_machine_device_plug_cb; @@ -1826,6 +1867,9 @@ static void virt_3_0_instance_init(Object *obj) "Valid values are none and smmuv3", NULL); =20 + object_property_add_str(obj, "kvm-type", + virt_get_kvm_type, virt_set_kvm_type, NULL); + vms->memmap =3D a15memmap; vms->irqmap =3D a15irqmap; } diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index 9a870cc..1a90ffc 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -124,6 +124,7 @@ typedef struct { uint32_t msi_phandle; uint32_t iommu_phandle; int psci_conduit; + char *kvm_type; } VirtMachineState; =20 #define VIRT_ECAM_ID(high) (high ? VIRT_PCIE_ECAM_HIGH : VIRT_PCIE_ECAM) --=20 2.5.5 From nobody Tue Nov 4 15:25:24 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 1530552504681310.75032745933356; Mon, 2 Jul 2018 10:28:24 -0700 (PDT) Received: from localhost ([::1]:34517 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa2ch-0003d6-TX for importer@patchew.org; Mon, 02 Jul 2018 13:28:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45683) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa2Xs-00007E-UW for qemu-devel@nongnu.org; Mon, 02 Jul 2018 13:23:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa2Xp-0006YV-1O for qemu-devel@nongnu.org; Mon, 02 Jul 2018 13:23:24 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:44636 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 1fa2Xm-0006Vf-Bo; Mon, 02 Jul 2018 13:23:18 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E18B440122DE; Mon, 2 Jul 2018 17:23:17 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-57.ams2.redhat.com [10.36.116.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id CEE7A111AF38; Mon, 2 Jul 2018 17:23:15 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, peter.maydell@linaro.org, shameerali.kolothum.thodi@huawei.com, kwangwoo.lee@sk.com, imammedo@redhat.com, david@redhat.com Date: Mon, 2 Jul 2018 19:22:32 +0200 Message-Id: <1530552162-15533-6-git-send-email-eric.auger@redhat.com> In-Reply-To: <1530552162-15533-1-git-send-email-eric.auger@redhat.com> References: <1530552162-15533-1-git-send-email-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Mon, 02 Jul 2018 17:23:17 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Mon, 02 Jul 2018 17:23:17 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'eric.auger@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] [RFC v2 05/15] hw/arm/virt: handle max_vm_phys_shift conflicts on migration 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: wei@redhat.com, drjones@redhat.com, david@gibson.dropbear.id.au, dgilbert@redhat.com, agraf@suse.de 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" When migrating a VM, we must make sure the destination host supports as many IPA bits as the source. Otherwise the migration must fail. We add a VMState infrastructure to machvirt. On pre_save(), the current source max_vm_phys_shift is saved. On destination, we cannot use this information when creating the VM. The VM is created using the max value reported by the destination host - or the kvm_type inherited value -. However on post_load() we can check that this value is compatible with the source saved value. Signed-off-by: Eric Auger --- hw/arm/virt.c | 37 +++++++++++++++++++++++++++++++++++++ include/hw/arm/virt.h | 2 ++ 2 files changed, 39 insertions(+) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 04a32de..5a4d0bf 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1316,6 +1316,40 @@ static uint64_t virt_cpu_mp_affinity(VirtMachineStat= e *vms, int idx) return arm_cpu_mp_affinity(idx, clustersz); } =20 +static int virt_post_load(void *opaque, int version_id) +{ + VirtMachineState *vms =3D (VirtMachineState *)opaque; + + if (vms->max_vm_phys_shift < vms->source_max_vm_phys_shift) { + error_report("This host kernel only supports %d IPA bits whereas " + "the guest requires %d GPA bits", vms->max_vm_phys_sh= ift, + vms->source_max_vm_phys_shift); + return -1; + } + return 0; +} + +static int virt_pre_save(void *opaque) +{ + VirtMachineState *vms =3D (VirtMachineState *)opaque; + + vms->source_max_vm_phys_shift =3D vms->max_vm_phys_shift; + return 0; +} + +static const VMStateDescription vmstate_virt =3D { + .name =3D "virt", + .version_id =3D 1, + .minimum_version_id =3D 1, + .post_load =3D virt_post_load, + .pre_save =3D virt_pre_save, + .fields =3D (VMStateField[]) { + VMSTATE_INT32(source_max_vm_phys_shift, VirtMachineState), + VMSTATE_END_OF_LIST() + }, +}; + + static void machvirt_init(MachineState *machine) { VirtMachineState *vms =3D VIRT_MACHINE(machine); @@ -1537,6 +1571,7 @@ static void machvirt_init(MachineState *machine) =20 vms->machine_done.notify =3D virt_machine_done; qemu_add_machine_init_done_notifier(&vms->machine_done); + vmstate_register(NULL, 0, &vmstate_virt, vms); } =20 static bool virt_get_secure(Object *obj, Error **errp) @@ -1727,6 +1762,7 @@ static HotplugHandler *virt_machine_get_hotplug_handl= er(MachineState *machine, =20 static int virt_kvm_type(MachineState *ms, const char *type_str) { + VirtMachineState *vms =3D VIRT_MACHINE(ms); int max_vm_phys_shift, ret =3D 0; uint64_t type; =20 @@ -1747,6 +1783,7 @@ static int virt_kvm_type(MachineState *ms, const char= *type_str) } ret =3D max_vm_phys_shift; out: + vms->max_vm_phys_shift =3D (max_vm_phys_shift > 0) ? ret : 40; return ret; } =20 diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index 1a90ffc..91f6de2 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -125,6 +125,8 @@ typedef struct { uint32_t iommu_phandle; int psci_conduit; char *kvm_type; + int32_t max_vm_phys_shift; + int32_t source_max_vm_phys_shift; } VirtMachineState; =20 #define VIRT_ECAM_ID(high) (high ? VIRT_PCIE_ECAM_HIGH : VIRT_PCIE_ECAM) --=20 2.5.5 From nobody Tue Nov 4 15:25:24 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 1530552710882351.3027928329817; Mon, 2 Jul 2018 10:31:50 -0700 (PDT) Received: from localhost ([::1]:34542 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa2ft-0006Gs-JN for importer@patchew.org; Mon, 02 Jul 2018 13:31:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45769) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa2Xw-0000B9-Cw for qemu-devel@nongnu.org; Mon, 02 Jul 2018 13:23:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa2Xu-0006eK-UF for qemu-devel@nongnu.org; Mon, 02 Jul 2018 13:23:28 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:49740 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 1fa2Xo-0006Y4-P4; Mon, 02 Jul 2018 13:23:20 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3BC797C6A9; Mon, 2 Jul 2018 17:23:20 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-57.ams2.redhat.com [10.36.116.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 24D1A111AF38; Mon, 2 Jul 2018 17:23:18 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, peter.maydell@linaro.org, shameerali.kolothum.thodi@huawei.com, kwangwoo.lee@sk.com, imammedo@redhat.com, david@redhat.com Date: Mon, 2 Jul 2018 19:22:33 +0200 Message-Id: <1530552162-15533-7-git-send-email-eric.auger@redhat.com> In-Reply-To: <1530552162-15533-1-git-send-email-eric.auger@redhat.com> References: <1530552162-15533-1-git-send-email-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 02 Jul 2018 17:23:20 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 02 Jul 2018 17:23:20 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'eric.auger@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] [RFC v2 06/15] hw/arm/virt: Allocate device_memory 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: wei@redhat.com, drjones@redhat.com, david@gibson.dropbear.id.au, dgilbert@redhat.com, agraf@suse.de 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" We define a new hotpluggable RAM region (aka. device memory). Its base is 2TB GPA. This obviously requires 42b IPA support in KVM/ARM, FW and guest kernel. At the moment the device memory region is max 2TB. This is largely inspired of device memory initialization in pc machine code. Signed-off-by: Eric Auger Signed-off-by: Kwangwoo Lee --- hw/arm/virt.c | 104 ++++++++++++++++++++++++++++++++++++----------= ---- include/hw/arm/arm.h | 2 + include/hw/arm/virt.h | 1 + 3 files changed, 79 insertions(+), 28 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 5a4d0bf..6fefb78 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -59,6 +59,7 @@ #include "qapi/visitor.h" #include "standard-headers/linux/input.h" #include "hw/arm/smmuv3.h" +#include "hw/acpi/acpi.h" =20 #define DEFINE_VIRT_MACHINE_LATEST(major, minor, latest) \ static void virt_##major##_##minor##_class_init(ObjectClass *oc, \ @@ -94,34 +95,25 @@ =20 #define PLATFORM_BUS_NUM_IRQS 64 =20 -/* RAM limit in GB. Since VIRT_MEM starts at the 1GB mark, this means - * RAM can go up to the 256GB mark, leaving 256GB of the physical - * address space unallocated and free for future use between 256G and 512G. - * If we need to provide more RAM to VMs in the future then we need to: - * * allocate a second bank of RAM starting at 2TB and working up - * * fix the DT and ACPI table generation code in QEMU to correctly - * report two split lumps of RAM to the guest - * * fix KVM in the host kernel to allow guests with >40 bit address spac= es - * (We don't want to fill all the way up to 512GB with RAM because - * we might want it for non-RAM purposes later. Conversely it seems - * reasonable to assume that anybody configuring a VM with a quarter - * of a terabyte of RAM will be doing it on a host with more than a - * terabyte of physical address space.) - */ -#define RAMLIMIT_GB 255 -#define RAMLIMIT_BYTES (RAMLIMIT_GB * 1024ULL * 1024 * 1024) +#define SZ_64K 0x10000 +#define SZ_1G (1024ULL * 1024 * 1024) =20 /* Addresses and sizes of our components. - * 0..128MB is space for a flash device so we can run bootrom code such as= UEFI. - * 128MB..256MB is used for miscellaneous device I/O. - * 256MB..1GB is reserved for possible future PCI support (ie where the - * PCI memory window will go if we add a PCI host controller). - * 1GB and up is RAM (which may happily spill over into the - * high memory region beyond 4GB). - * This represents a compromise between how much RAM can be given to - * a 32 bit VM and leaving space for expansion and in particular for PCI. - * Note that devices should generally be placed at multiples of 0x10000, + * 0..128MB is space for a flash device so we can run bootrom code such as= UEFI, + * 128MB..256MB is used for miscellaneous device I/O, + * 256MB..1GB is used for PCI host controller, + * 1GB..256GB is RAM (not hotpluggable), + * 256GB..512GB: is left for device I/O (non RAM purpose), + * 512GB..1TB: high mem PCI MMIO region, + * 2TB..4TB is used for hot-pluggable DIMM (assumes 42b GPA is supported). + * + * Note that IO devices should generally be placed at multiples of 0x10000, * to accommodate guests using 64K pages. + * + * Conversely it seems reasonable to assume that anybody configuring a VM + * with a quarter of a terabyte of RAM will be doing it on a host with more + * than a terabyte of physical address space.) + * */ static const MemMapEntry a15memmap[] =3D { /* Space up to 0x8000000 is reserved for a boot ROM */ @@ -148,12 +140,13 @@ static const MemMapEntry a15memmap[] =3D { [VIRT_PCIE_MMIO] =3D { 0x10000000, 0x2eff0000 }, [VIRT_PCIE_PIO] =3D { 0x3eff0000, 0x00010000 }, [VIRT_PCIE_ECAM] =3D { 0x3f000000, 0x01000000 }, - [VIRT_MEM] =3D { 0x40000000, RAMLIMIT_BYTES }, + [VIRT_MEM] =3D { SZ_1G , 255 * SZ_1G }, /* Additional 64 MB redist region (can contain up to 512 redistributor= s) */ [VIRT_GIC_REDIST2] =3D { 0x4000000000ULL, 0x4000000 }, [VIRT_PCIE_ECAM_HIGH] =3D { 0x4010000000ULL, 0x10000000 }, /* Second PCIe window, 512GB wide at the 512GB boundary */ - [VIRT_PCIE_MMIO_HIGH] =3D { 0x8000000000ULL, 0x8000000000ULL }, + [VIRT_PCIE_MMIO_HIGH] =3D { 512 * SZ_1G, 512 * SZ_1G }, + [VIRT_HOTPLUG_MEM] =3D { 2048 * SZ_1G, 2048 * SZ_1G }, }; =20 static const int a15irqmap[] =3D { @@ -1223,6 +1216,58 @@ static void create_secure_ram(VirtMachineState *vms, g_free(nodename); } =20 +static void create_device_memory(VirtMachineState *vms, MemoryRegion *sysm= em) +{ + MachineState *ms =3D MACHINE(vms); + uint64_t device_memory_size; + uint64_t align =3D SZ_64K; + + /* always allocate the device memory information */ + ms->device_memory =3D g_malloc0(sizeof(*ms->device_memory)); + + if (vms->max_vm_phys_shift < 42) { + /* device memory starts at 2TB whereas this VM supports less than + * 2TB GPA */ + if (ms->maxram_size > ms->ram_size || ms->ram_slots) { + MachineClass *mc =3D MACHINE_GET_CLASS(ms); + + error_report("\"-memory 'slots|maxmem'\" is not supported by %= s " + "since KVM does not support more than 41b IPA", + mc->name); + exit(EXIT_FAILURE); + } + return; + } + + if (ms->ram_slots > ACPI_MAX_RAM_SLOTS) { + error_report("unsupported number of memory slots: %"PRIu64, + ms->ram_slots); + exit(EXIT_FAILURE); + } + + if (QEMU_ALIGN_UP(ms->maxram_size, align) !=3D ms->maxram_size) { + error_report("maximum memory size must be aligned to multiple of 0= x%" + PRIx64, align); + exit(EXIT_FAILURE); + } + + ms->device_memory->base =3D vms->memmap[VIRT_HOTPLUG_MEM].base; + device_memory_size =3D ms->maxram_size - ms->ram_size; + + if (device_memory_size > vms->memmap[VIRT_HOTPLUG_MEM].size) { + error_report("unsupported amount of maximum memory: " RAM_ADDR_FMT, + ms->maxram_size); + exit(EXIT_FAILURE); + } + + memory_region_init(&ms->device_memory->mr, OBJECT(vms), + "device-memory", device_memory_size); + memory_region_add_subregion(sysmem, ms->device_memory->base, + &ms->device_memory->mr); + vms->bootinfo.device_memory_start =3D ms->device_memory->base; + vms->bootinfo.device_memory_size =3D device_memory_size; +} + static void *machvirt_dtb(const struct arm_boot_info *binfo, int *fdt_size) { const VirtMachineState *board =3D container_of(binfo, VirtMachineState, @@ -1430,7 +1475,8 @@ static void machvirt_init(MachineState *machine) vms->smp_cpus =3D smp_cpus; =20 if (machine->ram_size > vms->memmap[VIRT_MEM].size) { - error_report("mach-virt: cannot model more than %dGB RAM", RAMLIMI= T_GB); + error_report("mach-virt: cannot model more than %dGB RAM", + (int)(vms->memmap[VIRT_MEM].size / SZ_1G)); exit(1); } =20 @@ -1525,6 +1571,8 @@ static void machvirt_init(MachineState *machine) machine->ram_size); memory_region_add_subregion(sysmem, vms->memmap[VIRT_MEM].base, ram); =20 + create_device_memory(vms, sysmem); + create_flash(vms, sysmem, secure_sysmem ? secure_sysmem : sysmem); =20 create_gic(vms, pic); diff --git a/include/hw/arm/arm.h b/include/hw/arm/arm.h index ffed392..76269e6 100644 --- a/include/hw/arm/arm.h +++ b/include/hw/arm/arm.h @@ -116,6 +116,8 @@ struct arm_boot_info { bool secure_board_setup; =20 arm_endianness endianness; + hwaddr device_memory_start; + hwaddr device_memory_size; }; =20 /** diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index 91f6de2..173938d 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -78,6 +78,7 @@ enum { VIRT_GPIO, VIRT_SECURE_UART, VIRT_SECURE_MEM, + VIRT_HOTPLUG_MEM, }; =20 typedef enum VirtIOMMUType { --=20 2.5.5 From nobody Tue Nov 4 15:25:24 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 153055252053798.51315724904202; Mon, 2 Jul 2018 10:28:40 -0700 (PDT) Received: from localhost ([::1]:34519 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa2cs-0003o7-N9 for importer@patchew.org; Mon, 02 Jul 2018 13:28:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45755) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa2Xv-0000AM-Me for qemu-devel@nongnu.org; Mon, 02 Jul 2018 13:23:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa2Xu-0006dg-EX for qemu-devel@nongnu.org; Mon, 02 Jul 2018 13:23:27 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:42296 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 1fa2Xq-0006Zq-Tl; Mon, 02 Jul 2018 13:23:23 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 82B1681A4EBA; Mon, 2 Jul 2018 17:23:22 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-57.ams2.redhat.com [10.36.116.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 72E74111AF38; Mon, 2 Jul 2018 17:23:20 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, peter.maydell@linaro.org, shameerali.kolothum.thodi@huawei.com, kwangwoo.lee@sk.com, imammedo@redhat.com, david@redhat.com Date: Mon, 2 Jul 2018 19:22:34 +0200 Message-Id: <1530552162-15533-8-git-send-email-eric.auger@redhat.com> In-Reply-To: <1530552162-15533-1-git-send-email-eric.auger@redhat.com> References: <1530552162-15533-1-git-send-email-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 02 Jul 2018 17:23:22 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 02 Jul 2018 17:23:22 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'eric.auger@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] [RFC v2 07/15] hw/arm/virt: Add memory hotplug framework 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: wei@redhat.com, drjones@redhat.com, david@gibson.dropbear.id.au, dgilbert@redhat.com, agraf@suse.de 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" From: Shameer Kolothum This patch adds the the memory hot-plug/hot-unplug infrastructure in machvirt. Signed-off-by: Eric Auger Signed-off-by: Shameer Kolothum Signed-off-by: Kwangwoo Lee --- v1 -> v2: - s/virt_dimm_plug|unplug/virt_memory_plug|unplug - s/pc_dimm_memory_plug/pc_dimm_plug - reworded title and commit message - added pre_plug cb - don't handle get_memory_region failure anymore --- default-configs/arm-softmmu.mak | 2 ++ hw/arm/virt.c | 68 +++++++++++++++++++++++++++++++++++++= +++- 2 files changed, 69 insertions(+), 1 deletion(-) diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.= mak index 834d45c..28fe8f3 100644 --- a/default-configs/arm-softmmu.mak +++ b/default-configs/arm-softmmu.mak @@ -152,3 +152,5 @@ CONFIG_PCI_DESIGNWARE=3Dy CONFIG_STRONGARM=3Dy CONFIG_HIGHBANK=3Dy CONFIG_MUSICPAL=3Dy +CONFIG_MEM_HOTPLUG=3Dy + diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 6fefb78..7190962 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -60,6 +60,8 @@ #include "standard-headers/linux/input.h" #include "hw/arm/smmuv3.h" #include "hw/acpi/acpi.h" +#include "hw/mem/pc-dimm.h" +#include "hw/mem/nvdimm.h" =20 #define DEFINE_VIRT_MACHINE_LATEST(major, minor, latest) \ static void virt_##major##_##minor##_class_init(ObjectClass *oc, \ @@ -1785,6 +1787,53 @@ static const CPUArchIdList *virt_possible_cpu_arch_i= ds(MachineState *ms) return ms->possible_cpus; } =20 +static void virt_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState = *dev, + Error **errp) +{ + const bool is_nvdimm =3D object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); + + if (is_nvdimm) { + error_setg(errp, "nvdimm is not yet supported"); + return; + } +} + +static void virt_memory_plug(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ + PCDIMMDevice *dimm =3D PC_DIMM(dev); + PCDIMMDeviceClass *ddc =3D PC_DIMM_GET_CLASS(dimm); + MemoryRegion *mr =3D ddc->get_memory_region(dimm, &error_abort); + Error *local_err =3D NULL; + uint64_t align; + + if (memory_region_get_alignment(mr)) { + align =3D memory_region_get_alignment(mr); + } else { + /* by default we align on 64KB page size */ + align =3D SZ_64K; + } + + pc_dimm_plug(dev, MACHINE(hotplug_dev), align, &local_err); + + error_propagate(errp, local_err); +} + +static void virt_memory_unplug(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ + pc_dimm_unplug(dev, MACHINE(hotplug_dev)); + object_unparent(OBJECT(dev)); +} + +static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ + if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { + virt_memory_pre_plug(hotplug_dev, dev, errp); + } +} + static void virt_machine_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { @@ -1796,12 +1845,27 @@ static void virt_machine_device_plug_cb(HotplugHand= ler *hotplug_dev, SYS_BUS_DEVICE(dev)); } } + if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { + virt_memory_plug(hotplug_dev, dev, errp); + } +} + +static void virt_machine_device_unplug_cb(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ + if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { + virt_memory_unplug(hotplug_dev, dev, errp); + } else { + error_setg(errp, "device unplug request for unsupported device" + " type: %s", object_get_typename(OBJECT(dev))); + } } =20 static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *mach= ine, DeviceState *dev) { - if (object_dynamic_cast(OBJECT(dev), TYPE_SYS_BUS_DEVICE)) { + if (object_dynamic_cast(OBJECT(dev), TYPE_SYS_BUS_DEVICE) || + (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM))) { return HOTPLUG_HANDLER(machine); } =20 @@ -1861,7 +1925,9 @@ static void virt_machine_class_init(ObjectClass *oc, = void *data) mc->kvm_type =3D virt_kvm_type; assert(!mc->get_hotplug_handler); mc->get_hotplug_handler =3D virt_machine_get_hotplug_handler; + hc->pre_plug =3D virt_machine_device_pre_plug_cb; hc->plug =3D virt_machine_device_plug_cb; + hc->unplug =3D virt_machine_device_unplug_cb; } =20 static const TypeInfo virt_machine_info =3D { --=20 2.5.5 From nobody Tue Nov 4 15:25:24 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 1530552880950981.7429862870752; Mon, 2 Jul 2018 10:34:40 -0700 (PDT) Received: from localhost ([::1]:34554 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa2im-0008JJ-6M for importer@patchew.org; Mon, 02 Jul 2018 13:34:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45784) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa2Xx-0000CN-4L for qemu-devel@nongnu.org; Mon, 02 Jul 2018 13:23:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa2Xv-0006fM-WA for qemu-devel@nongnu.org; Mon, 02 Jul 2018 13:23:29 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:55728 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 1fa2Xt-0006cD-Cl; Mon, 02 Jul 2018 13:23:25 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CF00B4022909; Mon, 2 Jul 2018 17:23:24 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-57.ams2.redhat.com [10.36.116.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id BBE77111AF38; Mon, 2 Jul 2018 17:23:22 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, peter.maydell@linaro.org, shameerali.kolothum.thodi@huawei.com, kwangwoo.lee@sk.com, imammedo@redhat.com, david@redhat.com Date: Mon, 2 Jul 2018 19:22:35 +0200 Message-Id: <1530552162-15533-9-git-send-email-eric.auger@redhat.com> In-Reply-To: <1530552162-15533-1-git-send-email-eric.auger@redhat.com> References: <1530552162-15533-1-git-send-email-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Mon, 02 Jul 2018 17:23:24 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Mon, 02 Jul 2018 17:23:24 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'eric.auger@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] [RFC v2 08/15] hw/arm/boot: introduce fdt_add_memory_node helper 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: wei@redhat.com, drjones@redhat.com, david@gibson.dropbear.id.au, dgilbert@redhat.com, agraf@suse.de 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" From: Shameer Kolothum We introduce an helper to create a memory node. Signed-off-by: Eric Auger Signed-off-by: Shameer Kolothum --- v1 -> v2: - nop of existing /memory nodes was already handled --- hw/arm/boot.c | 54 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/hw/arm/boot.c b/hw/arm/boot.c index e09201c..5243a25 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -413,6 +413,36 @@ static void set_kernel_args_old(const struct arm_boot_= info *info, } } =20 +static int fdt_add_memory_node(void *fdt, uint32_t acells, hwaddr mem_base, + uint32_t scells, hwaddr mem_len, + int numa_node_id) +{ + char *nodename =3D NULL; + int ret; + + nodename =3D g_strdup_printf("/memory@%" PRIx64, mem_base); + qemu_fdt_add_subnode(fdt, nodename); + qemu_fdt_setprop_string(fdt, nodename, "device_type", "memory"); + ret =3D qemu_fdt_setprop_sized_cells(fdt, nodename, "reg", acells, mem= _base, + scells, mem_len); + if (ret < 0) { + fprintf(stderr, "couldn't set %s/reg\n", nodename); + goto out; + } + if (numa_node_id < 0) { + goto out; + } + + ret =3D qemu_fdt_setprop_cell(fdt, nodename, "numa-node-id", numa_node= _id); + if (ret < 0) { + fprintf(stderr, "couldn't set %s/numa-node-id\n", nodename); + } + +out: + g_free(nodename); + return ret; +} + static void fdt_add_psci_node(void *fdt) { uint32_t cpu_suspend_fn; @@ -492,7 +522,6 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_inf= o *binfo, void *fdt =3D NULL; int size, rc, n =3D 0; uint32_t acells, scells; - char *nodename; unsigned int i; hwaddr mem_base, mem_len; char **node_path; @@ -566,35 +595,20 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_i= nfo *binfo, mem_base =3D binfo->loader_start; for (i =3D 0; i < nb_numa_nodes; i++) { mem_len =3D numa_info[i].node_mem; - nodename =3D g_strdup_printf("/memory@%" PRIx64, mem_base); - qemu_fdt_add_subnode(fdt, nodename); - qemu_fdt_setprop_string(fdt, nodename, "device_type", "memory"= ); - rc =3D qemu_fdt_setprop_sized_cells(fdt, nodename, "reg", - acells, mem_base, - scells, mem_len); + rc =3D fdt_add_memory_node(fdt, acells, mem_base, + scells, mem_len, i); if (rc < 0) { - fprintf(stderr, "couldn't set %s/reg for node %d\n", noden= ame, - i); goto fail; } =20 - qemu_fdt_setprop_cell(fdt, nodename, "numa-node-id", i); mem_base +=3D mem_len; - g_free(nodename); } } else { - nodename =3D g_strdup_printf("/memory@%" PRIx64, binfo->loader_sta= rt); - qemu_fdt_add_subnode(fdt, nodename); - qemu_fdt_setprop_string(fdt, nodename, "device_type", "memory"); - - rc =3D qemu_fdt_setprop_sized_cells(fdt, nodename, "reg", - acells, binfo->loader_start, - scells, binfo->ram_size); + rc =3D fdt_add_memory_node(fdt, acells, binfo->loader_start, + scells, binfo->ram_size, -1); if (rc < 0) { - fprintf(stderr, "couldn't set %s reg\n", nodename); goto fail; } - g_free(nodename); } =20 rc =3D fdt_path_offset(fdt, "/chosen"); --=20 2.5.5 From nobody Tue Nov 4 15:25:24 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 153055239306290.19322419984996; Mon, 2 Jul 2018 10:26:33 -0700 (PDT) Received: from localhost ([::1]:34507 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa2au-0002Dw-Bo for importer@patchew.org; Mon, 02 Jul 2018 13:26:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45942) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa2Y9-0000P7-F5 for qemu-devel@nongnu.org; Mon, 02 Jul 2018 13:23:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa2Y8-0006qa-Ga for qemu-devel@nongnu.org; Mon, 02 Jul 2018 13:23:41 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:49754 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 1fa2Y2-0006kr-6s; Mon, 02 Jul 2018 13:23:34 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C45BA7CBBA; Mon, 2 Jul 2018 17:23:33 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-57.ams2.redhat.com [10.36.116.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 14588111AF38; Mon, 2 Jul 2018 17:23:24 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, peter.maydell@linaro.org, shameerali.kolothum.thodi@huawei.com, kwangwoo.lee@sk.com, imammedo@redhat.com, david@redhat.com Date: Mon, 2 Jul 2018 19:22:36 +0200 Message-Id: <1530552162-15533-10-git-send-email-eric.auger@redhat.com> In-Reply-To: <1530552162-15533-1-git-send-email-eric.auger@redhat.com> References: <1530552162-15533-1-git-send-email-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 02 Jul 2018 17:23:33 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 02 Jul 2018 17:23:33 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'eric.auger@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] [RFC v2 09/15] hw/arm/boot: Expose the PC-DIMM nodes in the DT 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: wei@redhat.com, drjones@redhat.com, david@gibson.dropbear.id.au, dgilbert@redhat.com, agraf@suse.de 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" From: Shameer Kolothum This patch add memory nodes corresponding to PC-DIMM regions. NV_DIMM and ACPI_NVDIMM configs are not yet set for ARM so we don't need to care about NV-DIMM at this stage. Signed-off-by: Shameer Kolothum Signed-off-by: Eric Auger --- v1 -> v2: - added qapi_free_MemoryDeviceInfoList and simplify the loop --- hw/arm/boot.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/hw/arm/boot.c b/hw/arm/boot.c index 5243a25..2c7d558 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -19,6 +19,7 @@ #include "sysemu/numa.h" #include "hw/boards.h" #include "hw/loader.h" +#include "hw/mem/memory-device.h" #include "elf.h" #include "sysemu/device_tree.h" #include "qemu/config-file.h" @@ -516,6 +517,35 @@ static void fdt_add_psci_node(void *fdt) qemu_fdt_setprop_cell(fdt, "/psci", "migrate", migrate_fn); } =20 +static int fdt_add_hotpluggable_memory_nodes(void *fdt, + uint64_t base, uint64_t len, + uint32_t acells, uint32_t sce= lls) { + MemoryDeviceInfoList *info, *info_list =3D qmp_memory_device_list(); + MemoryDeviceInfo *mi; + PCDIMMDeviceInfo *di; + bool is_nvdimm; + int ret =3D 0; + + for (info =3D info_list; info !=3D NULL; info =3D info->next) { + mi =3D info->value; + is_nvdimm =3D (mi->type =3D=3D MEMORY_DEVICE_INFO_KIND_NVDIMM); + di =3D !is_nvdimm ? mi->u.dimm.data : mi->u.nvdimm.data; + + if (is_nvdimm) { + ret =3D -ENOENT; /* NV-DIMM not yet supported */ + } else { + ret =3D fdt_add_memory_node(fdt, acells, di->addr, + scells, di->size, di->node); + } + if (ret < 0) { + goto out; + } + } +out: + qapi_free_MemoryDeviceInfoList(info_list); + return ret; +} + int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo, hwaddr addr_limit, AddressSpace *as) { @@ -611,6 +641,14 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_in= fo *binfo, } } =20 + rc =3D fdt_add_hotpluggable_memory_nodes(fdt, binfo->device_memory_sta= rt, + binfo->device_memory_size, + acells, scells); + if (rc < 0) { + fprintf(stderr, "couldn't add hotpluggable memory nodes\n"); + goto fail; + } + rc =3D fdt_path_offset(fdt, "/chosen"); if (rc < 0) { qemu_fdt_add_subnode(fdt, "/chosen"); --=20 2.5.5 From nobody Tue Nov 4 15:25:24 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 1530552569420420.8622074802407; Mon, 2 Jul 2018 10:29:29 -0700 (PDT) Received: from localhost ([::1]:34520 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa2dk-0004Vd-JG for importer@patchew.org; Mon, 02 Jul 2018 13:29:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45965) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa2YA-0000Q4-6d for qemu-devel@nongnu.org; Mon, 02 Jul 2018 13:23:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa2Y8-0006rE-SU for qemu-devel@nongnu.org; Mon, 02 Jul 2018 13:23:42 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:48076 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 1fa2Y4-0006mt-H2; Mon, 02 Jul 2018 13:23:36 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1903777885; Mon, 2 Jul 2018 17:23:36 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-57.ams2.redhat.com [10.36.116.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 09332111AF38; Mon, 2 Jul 2018 17:23:33 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, peter.maydell@linaro.org, shameerali.kolothum.thodi@huawei.com, kwangwoo.lee@sk.com, imammedo@redhat.com, david@redhat.com Date: Mon, 2 Jul 2018 19:22:37 +0200 Message-Id: <1530552162-15533-11-git-send-email-eric.auger@redhat.com> In-Reply-To: <1530552162-15533-1-git-send-email-eric.auger@redhat.com> References: <1530552162-15533-1-git-send-email-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 02 Jul 2018 17:23:36 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 02 Jul 2018 17:23:36 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'eric.auger@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] [RFC v2 10/15] acpi: move build_srat_hotpluggable_memory to generic ACPI source 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: wei@redhat.com, drjones@redhat.com, david@gibson.dropbear.id.au, dgilbert@redhat.com, agraf@suse.de 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" We plan to reuse build_srat_hotpluggable_memory() for ARM so let's move the function to aml-build. Signed-off-by: Eric Auger --- hw/acpi/aml-build.c | 51 +++++++++++++++++++++++++++++++++++++++++= ++++ hw/i386/acpi-build.c | 49 -----------------------------------------= -- include/hw/acpi/aml-build.h | 3 +++ 3 files changed, 54 insertions(+), 49 deletions(-) diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index 1e43cd7..167fb6b 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -22,6 +22,7 @@ #include "qemu/osdep.h" #include #include "hw/acpi/aml-build.h" +#include "hw/mem/memory-device.h" #include "qemu/bswap.h" #include "qemu/bitops.h" #include "sysemu/numa.h" @@ -1802,3 +1803,53 @@ build_hdr: build_header(linker, tbl, (void *)(tbl->data + fadt_start), "FACP", tbl->len - fadt_start, f->rev, oem_id, oem_table_= id); } + +void build_srat_hotpluggable_memory(GArray *table_data, uint64_t base, + uint64_t len, int default_node) +{ + MemoryDeviceInfoList *info_list =3D qmp_memory_device_list(); + MemoryDeviceInfoList *info; + MemoryDeviceInfo *mi; + PCDIMMDeviceInfo *di; + uint64_t end =3D base + len, cur, size; + bool is_nvdimm; + AcpiSratMemoryAffinity *numamem; + MemoryAffinityFlags flags; + + for (cur =3D base, info =3D info_list; + cur < end; + cur +=3D size, info =3D info->next) { + numamem =3D acpi_data_push(table_data, sizeof *numamem); + + if (!info) { + build_srat_memory(numamem, cur, end - cur, default_node, + MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENA= BLED); + break; + } + + mi =3D info->value; + is_nvdimm =3D (mi->type =3D=3D MEMORY_DEVICE_INFO_KIND_NVDIMM); + di =3D !is_nvdimm ? mi->u.dimm.data : mi->u.nvdimm.data; + + if (cur < di->addr) { + build_srat_memory(numamem, cur, di->addr - cur, default_node, + MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENA= BLED); + numamem =3D acpi_data_push(table_data, sizeof *numamem); + } + + size =3D di->size; + + flags =3D MEM_AFFINITY_ENABLED; + if (di->hotpluggable) { + flags |=3D MEM_AFFINITY_HOTPLUGGABLE; + } + if (is_nvdimm) { + flags |=3D MEM_AFFINITY_NON_VOLATILE; + } + + build_srat_memory(numamem, di->addr, size, di->node, flags); + } + + qapi_free_MemoryDeviceInfoList(info_list); +} + diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 9bc6d97..fcebd02 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2251,55 +2251,6 @@ build_tpm2(GArray *table_data, BIOSLinker *linker, G= Array *tcpalog) #define HOLE_640K_START (640 * 1024) #define HOLE_640K_END (1024 * 1024) =20 -static void build_srat_hotpluggable_memory(GArray *table_data, uint64_t ba= se, - uint64_t len, int default_node) -{ - MemoryDeviceInfoList *info_list =3D qmp_memory_device_list(); - MemoryDeviceInfoList *info; - MemoryDeviceInfo *mi; - PCDIMMDeviceInfo *di; - uint64_t end =3D base + len, cur, size; - bool is_nvdimm; - AcpiSratMemoryAffinity *numamem; - MemoryAffinityFlags flags; - - for (cur =3D base, info =3D info_list; - cur < end; - cur +=3D size, info =3D info->next) { - numamem =3D acpi_data_push(table_data, sizeof *numamem); - - if (!info) { - build_srat_memory(numamem, cur, end - cur, default_node, - MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENA= BLED); - break; - } - - mi =3D info->value; - is_nvdimm =3D (mi->type =3D=3D MEMORY_DEVICE_INFO_KIND_NVDIMM); - di =3D !is_nvdimm ? mi->u.dimm.data : mi->u.nvdimm.data; - - if (cur < di->addr) { - build_srat_memory(numamem, cur, di->addr - cur, default_node, - MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENA= BLED); - numamem =3D acpi_data_push(table_data, sizeof *numamem); - } - - size =3D di->size; - - flags =3D MEM_AFFINITY_ENABLED; - if (di->hotpluggable) { - flags |=3D MEM_AFFINITY_HOTPLUGGABLE; - } - if (is_nvdimm) { - flags |=3D MEM_AFFINITY_NON_VOLATILE; - } - - build_srat_memory(numamem, di->addr, size, di->node, flags); - } - - qapi_free_MemoryDeviceInfoList(info_list); -} - static void build_srat(GArray *table_data, BIOSLinker *linker, MachineState *machine) { diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h index 6c36903..4c2ca13 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -416,4 +416,7 @@ void build_slit(GArray *table_data, BIOSLinker *linker); =20 void build_fadt(GArray *tbl, BIOSLinker *linker, const AcpiFadtData *f, const char *oem_id, const char *oem_table_id); + +void build_srat_hotpluggable_memory(GArray *table_data, uint64_t base, + uint64_t len, int default_node); #endif --=20 2.5.5 From nobody Tue Nov 4 15:25:24 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 1530552919383922.3570446525313; Mon, 2 Jul 2018 10:35:19 -0700 (PDT) Received: from localhost ([::1]:34559 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa2jO-0000NR-KG for importer@patchew.org; Mon, 02 Jul 2018 13:35:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45948) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa2Y9-0000PD-Jr for qemu-devel@nongnu.org; Mon, 02 Jul 2018 13:23:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa2Y8-0006qx-MO for qemu-devel@nongnu.org; Mon, 02 Jul 2018 13:23:41 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:48096 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 1fa2Y6-0006oc-PG; Mon, 02 Jul 2018 13:23:38 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6197777888; Mon, 2 Jul 2018 17:23:38 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-57.ams2.redhat.com [10.36.116.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 53219111AF38; Mon, 2 Jul 2018 17:23:36 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, peter.maydell@linaro.org, shameerali.kolothum.thodi@huawei.com, kwangwoo.lee@sk.com, imammedo@redhat.com, david@redhat.com Date: Mon, 2 Jul 2018 19:22:38 +0200 Message-Id: <1530552162-15533-12-git-send-email-eric.auger@redhat.com> In-Reply-To: <1530552162-15533-1-git-send-email-eric.auger@redhat.com> References: <1530552162-15533-1-git-send-email-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 02 Jul 2018 17:23:38 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 02 Jul 2018 17:23:38 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'eric.auger@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] [RFC v2 11/15] hw/arm/virt-acpi-build: Add PC-DIMM in SRAT 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: wei@redhat.com, drjones@redhat.com, david@gibson.dropbear.id.au, dgilbert@redhat.com, agraf@suse.de 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" From: Shameer Kolothum Generate Memory Affinity Structures for PC-DIMM ranges. Signed-off-by: Shameer Kolothum Signed-off-by: Eric Auger --- v1 -> v2: - build_srat_hotpluggable_memory movedc to aml-build --- hw/arm/virt-acpi-build.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 6ea47e2..0915391 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -568,6 +568,10 @@ build_srat(GArray *table_data, BIOSLinker *linker, Vir= tMachineState *vms) mem_base +=3D numa_info[i].node_mem; } =20 + build_srat_hotpluggable_memory(table_data, + vms->bootinfo.device_memory_start, + vms->bootinfo.device_memory_size , 0); + build_header(linker, table_data, (void *)(table_data->data + srat_star= t), "SRAT", table_data->len - srat_start, 3, NULL, NULL); } --=20 2.5.5 From nobody Tue Nov 4 15:25:24 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 153055269903584.18242539735797; Mon, 2 Jul 2018 10:31:39 -0700 (PDT) Received: from localhost ([::1]:34541 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa2fm-0006BE-SK for importer@patchew.org; Mon, 02 Jul 2018 13:31:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46034) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa2YE-0000UO-CP for qemu-devel@nongnu.org; Mon, 02 Jul 2018 13:23:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa2YC-0006v7-Sn for qemu-devel@nongnu.org; Mon, 02 Jul 2018 13:23:46 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:49778 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 1fa2Y9-0006rC-4M; Mon, 02 Jul 2018 13:23:41 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B09677DAC2; Mon, 2 Jul 2018 17:23:40 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-57.ams2.redhat.com [10.36.116.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9A72F111AF38; Mon, 2 Jul 2018 17:23:38 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, peter.maydell@linaro.org, shameerali.kolothum.thodi@huawei.com, kwangwoo.lee@sk.com, imammedo@redhat.com, david@redhat.com Date: Mon, 2 Jul 2018 19:22:39 +0200 Message-Id: <1530552162-15533-13-git-send-email-eric.auger@redhat.com> In-Reply-To: <1530552162-15533-1-git-send-email-eric.auger@redhat.com> References: <1530552162-15533-1-git-send-email-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 02 Jul 2018 17:23:40 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 02 Jul 2018 17:23:40 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'eric.auger@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] [RFC v2 12/15] nvdimm: use configurable ACPI IO base and size 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: wei@redhat.com, drjones@redhat.com, david@gibson.dropbear.id.au, dgilbert@redhat.com, agraf@suse.de 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" From: Kwangwoo Lee This patch uses configurable IO base and size to create NPIO AML for ACPI NFIT. Since a different architecture like AArch64 does not use port-mapped IO, a configurable IO base is required to create correct mapping of ACPI IO address and size. Signed-off-by: Kwangwoo Lee Signed-off-by: Eric Auger --- hw/acpi/nvdimm.c | 28 +++++++++++++++++++--------- hw/i386/pc_piix.c | 8 +++++++- hw/i386/pc_q35.c | 8 +++++++- include/hw/mem/nvdimm.h | 12 ++++++++++++ 4 files changed, 45 insertions(+), 11 deletions(-) diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c index 27eeb66..17d7146 100644 --- a/hw/acpi/nvdimm.c +++ b/hw/acpi/nvdimm.c @@ -929,8 +929,8 @@ void nvdimm_init_acpi_state(AcpiNVDIMMState *state, Mem= oryRegion *io, FWCfgState *fw_cfg, Object *owner) { memory_region_init_io(&state->io_mr, owner, &nvdimm_dsm_ops, state, - "nvdimm-acpi-io", NVDIMM_ACPI_IO_LEN); - memory_region_add_subregion(io, NVDIMM_ACPI_IO_BASE, &state->io_mr); + "nvdimm-acpi-io", state->dsm_io.len); + memory_region_add_subregion(io, state->dsm_io.base, &state->io_mr); =20 state->dsm_mem =3D g_array_new(false, true /* clear */, 1); acpi_data_push(state->dsm_mem, sizeof(NvdimmDsmIn)); @@ -959,12 +959,14 @@ void nvdimm_init_acpi_state(AcpiNVDIMMState *state, M= emoryRegion *io, =20 #define NVDIMM_QEMU_RSVD_UUID "648B9CF2-CDA1-4312-8AD9-49C4AF32BD62" =20 -static void nvdimm_build_common_dsm(Aml *dev) +static void nvdimm_build_common_dsm(Aml *dev, + AcpiNVDIMMState *acpi_nvdimm_state) { Aml *method, *ifctx, *function, *handle, *uuid, *dsm_mem, *elsectx2; Aml *elsectx, *unsupport, *unpatched, *expected_uuid, *uuid_invalid; Aml *pckg, *pckg_index, *pckg_buf, *field, *dsm_out_buf, *dsm_out_buf_= size; uint8_t byte_list[1]; + AmlRegionSpace rs; =20 method =3D aml_method(NVDIMM_COMMON_DSM, 5, AML_SERIALIZED); uuid =3D aml_arg(0); @@ -975,9 +977,16 @@ static void nvdimm_build_common_dsm(Aml *dev) =20 aml_append(method, aml_store(aml_name(NVDIMM_ACPI_MEM_ADDR), dsm_mem)); =20 + if (acpi_nvdimm_state->dsm_io.type =3D=3D NVDIMM_ACPI_IO_PORT) { + rs =3D AML_SYSTEM_IO; + } else { + rs =3D AML_SYSTEM_MEMORY; + } + /* map DSM memory and IO into ACPI namespace. */ - aml_append(method, aml_operation_region(NVDIMM_DSM_IOPORT, AML_SYSTEM_= IO, - aml_int(NVDIMM_ACPI_IO_BASE), NVDIMM_ACPI_IO_LEN)); + aml_append(method, aml_operation_region(NVDIMM_DSM_IOPORT, rs, + aml_int(acpi_nvdimm_state->dsm_io.base), + acpi_nvdimm_state->dsm_io.len)); aml_append(method, aml_operation_region(NVDIMM_DSM_MEMORY, AML_SYSTEM_MEMORY, dsm_mem, sizeof(NvdimmDsmIn))); =20 @@ -1260,7 +1269,8 @@ static void nvdimm_build_nvdimm_devices(Aml *root_dev= , uint32_t ram_slots) } =20 static void nvdimm_build_ssdt(GArray *table_offsets, GArray *table_data, - BIOSLinker *linker, GArray *dsm_dma_arrea, + BIOSLinker *linker, + AcpiNVDIMMState *acpi_nvdimm_state, uint32_t ram_slots) { Aml *ssdt, *sb_scope, *dev; @@ -1288,7 +1298,7 @@ static void nvdimm_build_ssdt(GArray *table_offsets, = GArray *table_data, */ aml_append(dev, aml_name_decl("_HID", aml_string("ACPI0012"))); =20 - nvdimm_build_common_dsm(dev); + nvdimm_build_common_dsm(dev, acpi_nvdimm_state); =20 /* 0 is reserved for root device. */ nvdimm_build_device_dsm(dev, 0); @@ -1307,7 +1317,7 @@ static void nvdimm_build_ssdt(GArray *table_offsets, = GArray *table_data, NVDIMM_ACPI_MEM_ADDR); =20 bios_linker_loader_alloc(linker, - NVDIMM_DSM_MEM_FILE, dsm_dma_arrea, + NVDIMM_DSM_MEM_FILE, acpi_nvdimm_state->dsm_m= em, sizeof(NvdimmDsmIn), false /* high memory */); bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE, mem_addr_offset, sizeof(uint32_t), @@ -1329,7 +1339,7 @@ void nvdimm_build_acpi(GArray *table_offsets, GArray = *table_data, return; } =20 - nvdimm_build_ssdt(table_offsets, table_data, linker, state->dsm_mem, + nvdimm_build_ssdt(table_offsets, table_data, linker, state, ram_slots); =20 device_list =3D nvdimm_get_device_list(); diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index d357907..607517e 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -296,7 +296,13 @@ static void pc_init1(MachineState *machine, } =20 if (pcms->acpi_nvdimm_state.is_enabled) { - nvdimm_init_acpi_state(&pcms->acpi_nvdimm_state, system_io, + AcpiNVDIMMState *acpi_nvdimm_state =3D &pcms->acpi_nvdimm_state; + + acpi_nvdimm_state->dsm_io.type =3D NVDIMM_ACPI_IO_PORT; + acpi_nvdimm_state->dsm_io.base =3D NVDIMM_ACPI_IO_BASE; + acpi_nvdimm_state->dsm_io.size =3D NVDIMM_ACPI_IO_LEN; + + nvdimm_init_acpi_state(acpi_nvdimm_state, system_io, pcms->fw_cfg, OBJECT(pcms)); } } diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 1a73e18..3c17e91 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -276,7 +276,13 @@ static void pc_q35_init(MachineState *machine) pc_nic_init(pcmc, isa_bus, host_bus); =20 if (pcms->acpi_nvdimm_state.is_enabled) { - nvdimm_init_acpi_state(&pcms->acpi_nvdimm_state, system_io, + AcpiNVDIMMState *acpi_nvdimm_state =3D &pcms->acpi_nvdimm_state; + + acpi_nvdimm_state->dsm_io.type =3D NVDIMM_ACPI_IO_PORT; + acpi_nvdimm_state->dsm_io.base =3D NVDIMM_ACPI_IO_BASE; + acpi_nvdimm_state->dsm_io.size =3D NVDIMM_ACPI_IO_LEN; + + nvdimm_init_acpi_state(acpi_nvdimm_state, system_io, pcms->fw_cfg, OBJECT(pcms)); } } diff --git a/include/hw/mem/nvdimm.h b/include/hw/mem/nvdimm.h index c5c9b3c..af8a5fd 100644 --- a/include/hw/mem/nvdimm.h +++ b/include/hw/mem/nvdimm.h @@ -123,6 +123,17 @@ struct NvdimmFitBuffer { }; typedef struct NvdimmFitBuffer NvdimmFitBuffer; =20 +typedef enum { + NVDIMM_ACPI_IO_PORT, + NVDIMM_ACPI_IO_MEMORY, +} AcpiNVDIMMIOType; + +typedef struct AcpiNVDIMMIOEntry { + AcpiNVDIMMIOType type; + hwaddr base; + hwaddr len; +} AcpiNVDIMMIOEntry; + struct AcpiNVDIMMState { /* detect if NVDIMM support is enabled. */ bool is_enabled; @@ -140,6 +151,7 @@ struct AcpiNVDIMMState { */ int32_t persistence; char *persistence_string; + AcpiNVDIMMIOEntry dsm_io; }; typedef struct AcpiNVDIMMState AcpiNVDIMMState; =20 --=20 2.5.5 From nobody Tue Nov 4 15:25:24 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 1530552791506572.5415610388089; Mon, 2 Jul 2018 10:33:11 -0700 (PDT) Received: from localhost ([::1]:34546 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa2hK-0007IH-Mb for importer@patchew.org; Mon, 02 Jul 2018 13:33:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46096) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa2YJ-0000YU-DV for qemu-devel@nongnu.org; Mon, 02 Jul 2018 13:23:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa2YI-0006zh-8r for qemu-devel@nongnu.org; Mon, 02 Jul 2018 13:23:51 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:55738 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 1fa2YB-0006td-Ed; Mon, 02 Jul 2018 13:23:43 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 065DA4022909; Mon, 2 Jul 2018 17:23:43 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-57.ams2.redhat.com [10.36.116.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id E6310111AF38; Mon, 2 Jul 2018 17:23:40 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, peter.maydell@linaro.org, shameerali.kolothum.thodi@huawei.com, kwangwoo.lee@sk.com, imammedo@redhat.com, david@redhat.com Date: Mon, 2 Jul 2018 19:22:40 +0200 Message-Id: <1530552162-15533-14-git-send-email-eric.auger@redhat.com> In-Reply-To: <1530552162-15533-1-git-send-email-eric.auger@redhat.com> References: <1530552162-15533-1-git-send-email-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Mon, 02 Jul 2018 17:23:43 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Mon, 02 Jul 2018 17:23:43 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'eric.auger@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] [RFC v2 13/15] hw/arm/virt: Add nvdimm hot-plug infrastructure 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: wei@redhat.com, drjones@redhat.com, david@gibson.dropbear.id.au, dgilbert@redhat.com, agraf@suse.de 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" From: Kwangwoo Lee Pre-plug and plug handlers are prepared for NVDIMM support. Signed-off-by: Eric Auger Signed-off-by: Kwangwoo Lee --- default-configs/arm-softmmu.mak | 2 ++ hw/arm/virt-acpi-build.c | 6 ++++++ hw/arm/virt.c | 23 +++++++++++++++++++++++ include/hw/arm/virt.h | 3 +++ 4 files changed, 34 insertions(+) diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.= mak index 28fe8f3..9f49a6a 100644 --- a/default-configs/arm-softmmu.mak +++ b/default-configs/arm-softmmu.mak @@ -153,4 +153,6 @@ CONFIG_STRONGARM=3Dy CONFIG_HIGHBANK=3Dy CONFIG_MUSICPAL=3Dy CONFIG_MEM_HOTPLUG=3Dy +CONFIG_NVDIMM=3Dy +CONFIG_ACPI_NVDIMM=3Dy =20 diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 0915391..f18bb5c 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -804,6 +804,7 @@ static void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables) { VirtMachineClass *vmc =3D VIRT_MACHINE_GET_CLASS(vms); + MachineState *ms =3D MACHINE(vms); GArray *table_offsets; unsigned dsdt, xsdt; GArray *tables_blob =3D tables->table_data; @@ -844,6 +845,11 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildT= ables *tables) } } =20 + if (vms->acpi_nvdimm_state.is_enabled) { + nvdimm_build_acpi(table_offsets, tables_blob, tables->linker, + &vms->acpi_nvdimm_state, ms->ram_slots); + } + if (its_class_name() && !vmc->no_its) { acpi_add_table(table_offsets, tables_blob); build_iort(tables_blob, tables->linker, vms); diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 7190962..51f42cd 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -135,6 +135,7 @@ static const MemMapEntry a15memmap[] =3D { [VIRT_GPIO] =3D { 0x09030000, 0x00001000 }, [VIRT_SECURE_UART] =3D { 0x09040000, 0x00001000 }, [VIRT_SMMU] =3D { 0x09050000, 0x00020000 }, + [VIRT_ACPI_IO] =3D { 0x09070000, 0x00010000 }, [VIRT_MMIO] =3D { 0x0a000000, 0x00000200 }, /* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that siz= e */ [VIRT_PLATFORM_BUS] =3D { 0x0c000000, 0x02000000 }, @@ -1607,6 +1608,18 @@ static void machvirt_init(MachineState *machine) =20 create_platform_bus(vms, pic); =20 + if (vms->acpi_nvdimm_state.is_enabled) { + AcpiNVDIMMState *acpi_nvdimm_state =3D &vms->acpi_nvdimm_state; + + acpi_nvdimm_state->dsm_io.type =3D NVDIMM_ACPI_IO_MEMORY; + acpi_nvdimm_state->dsm_io.base =3D + vms->memmap[VIRT_ACPI_IO].base + NVDIMM_ACPI_IO_BASE; + acpi_nvdimm_state->dsm_io.len =3D NVDIMM_ACPI_IO_LEN; + + nvdimm_init_acpi_state(acpi_nvdimm_state, sysmem, + vms->fw_cfg, OBJECT(vms)); + } + vms->bootinfo.ram_size =3D machine->ram_size; vms->bootinfo.kernel_filename =3D machine->kernel_filename; vms->bootinfo.kernel_cmdline =3D machine->kernel_cmdline; @@ -1801,9 +1814,11 @@ static void virt_memory_pre_plug(HotplugHandler *hot= plug_dev, DeviceState *dev, static void virt_memory_plug(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { + VirtMachineState *vms =3D VIRT_MACHINE(hotplug_dev); PCDIMMDevice *dimm =3D PC_DIMM(dev); PCDIMMDeviceClass *ddc =3D PC_DIMM_GET_CLASS(dimm); MemoryRegion *mr =3D ddc->get_memory_region(dimm, &error_abort); + bool is_nvdimm =3D object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); Error *local_err =3D NULL; uint64_t align; =20 @@ -1815,7 +1830,15 @@ static void virt_memory_plug(HotplugHandler *hotplug= _dev, } =20 pc_dimm_plug(dev, MACHINE(hotplug_dev), align, &local_err); + if (local_err) { + goto out; + } =20 + if (is_nvdimm) { + nvdimm_plug(&vms->acpi_nvdimm_state); + } + +out: error_propagate(errp, local_err); } =20 diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index 173938d..2cabdbe 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -37,6 +37,7 @@ #include "hw/arm/arm.h" #include "sysemu/kvm.h" #include "hw/intc/arm_gicv3_common.h" +#include "hw/mem/nvdimm.h" =20 #define NUM_GICV2M_SPIS 64 #define NUM_VIRTIO_TRANSPORTS 32 @@ -79,6 +80,7 @@ enum { VIRT_SECURE_UART, VIRT_SECURE_MEM, VIRT_HOTPLUG_MEM, + VIRT_ACPI_IO, }; =20 typedef enum VirtIOMMUType { @@ -128,6 +130,7 @@ typedef struct { char *kvm_type; int32_t max_vm_phys_shift; int32_t source_max_vm_phys_shift; + AcpiNVDIMMState acpi_nvdimm_state; } VirtMachineState; =20 #define VIRT_ECAM_ID(high) (high ? VIRT_PCIE_ECAM_HIGH : VIRT_PCIE_ECAM) --=20 2.5.5 From nobody Tue Nov 4 15:25:24 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 1530552899088108.18298768345551; Mon, 2 Jul 2018 10:34:59 -0700 (PDT) Received: from localhost ([::1]:34557 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa2j4-00007X-AM for importer@patchew.org; Mon, 02 Jul 2018 13:34:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46156) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa2YN-0000at-II for qemu-devel@nongnu.org; Mon, 02 Jul 2018 13:23:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa2YM-00073O-Hl for qemu-devel@nongnu.org; Mon, 02 Jul 2018 13:23:55 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:49798 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 1fa2YK-00071T-7a; Mon, 02 Jul 2018 13:23:52 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C43467C6A9; Mon, 2 Jul 2018 17:23:51 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-57.ams2.redhat.com [10.36.116.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3C7D2111AF38; Mon, 2 Jul 2018 17:23:43 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, peter.maydell@linaro.org, shameerali.kolothum.thodi@huawei.com, kwangwoo.lee@sk.com, imammedo@redhat.com, david@redhat.com Date: Mon, 2 Jul 2018 19:22:41 +0200 Message-Id: <1530552162-15533-15-git-send-email-eric.auger@redhat.com> In-Reply-To: <1530552162-15533-1-git-send-email-eric.auger@redhat.com> References: <1530552162-15533-1-git-send-email-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 02 Jul 2018 17:23:51 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 02 Jul 2018 17:23:51 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'eric.auger@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] [RFC v2 14/15] hw/arm/boot: Expose the pmem nodes in the DT 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: wei@redhat.com, drjones@redhat.com, david@gibson.dropbear.id.au, dgilbert@redhat.com, agraf@suse.de 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" In case of NV-DIMM slots, let's add /pmem DT nodes. Signed-off-by: Eric Auger --- hw/arm/boot.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/hw/arm/boot.c b/hw/arm/boot.c index 2c7d558..3381c66 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -444,6 +444,36 @@ out: return ret; } =20 +static int fdt_add_pmem_node(void *fdt, uint32_t acells, hwaddr mem_base, + uint32_t scells, hwaddr mem_len, + int numa_node_id) +{ + char *nodename =3D NULL; + int ret; + + nodename =3D g_strdup_printf("/pmem@%" PRIx64, mem_base); + qemu_fdt_add_subnode(fdt, nodename); + qemu_fdt_setprop_string(fdt, nodename, "compatible", "pmem-region"); + ret =3D qemu_fdt_setprop_sized_cells(fdt, nodename, "reg", acells, mem= _base, + scells, mem_len); + if (ret < 0) { + fprintf(stderr, "couldn't set %s/reg\n", nodename); + goto out; + } + if (numa_node_id < 0) { + goto out; + } + + ret =3D qemu_fdt_setprop_cell(fdt, nodename, "numa-node-id", numa_node= _id); + if (ret < 0) { + fprintf(stderr, "couldn't set %s/numa-node-id\n", nodename); + } + +out: + g_free(nodename); + return ret; +} + static void fdt_add_psci_node(void *fdt) { uint32_t cpu_suspend_fn; @@ -532,7 +562,8 @@ static int fdt_add_hotpluggable_memory_nodes(void *fdt, di =3D !is_nvdimm ? mi->u.dimm.data : mi->u.nvdimm.data; =20 if (is_nvdimm) { - ret =3D -ENOENT; /* NV-DIMM not yet supported */ + ret =3D fdt_add_pmem_node(fdt, acells, di->addr, + scells, di->size, di->node); } else { ret =3D fdt_add_memory_node(fdt, acells, di->addr, scells, di->size, di->node); --=20 2.5.5 From nobody Tue Nov 4 15:25:24 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 153055298768579.32492766873372; Mon, 2 Jul 2018 10:36:27 -0700 (PDT) Received: from localhost ([::1]:34572 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa2kU-0001Qs-TQ for importer@patchew.org; Mon, 02 Jul 2018 13:36:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46242) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa2YT-0000fd-Vw for qemu-devel@nongnu.org; Mon, 02 Jul 2018 13:24:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa2YP-000766-0s for qemu-devel@nongnu.org; Mon, 02 Jul 2018 13:24:01 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:49814 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 1fa2YM-000735-GR; Mon, 02 Jul 2018 13:23:54 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 170A97CBBA; Mon, 2 Jul 2018 17:23:54 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-57.ams2.redhat.com [10.36.116.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 07203111AF38; Mon, 2 Jul 2018 17:23:51 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, peter.maydell@linaro.org, shameerali.kolothum.thodi@huawei.com, kwangwoo.lee@sk.com, imammedo@redhat.com, david@redhat.com Date: Mon, 2 Jul 2018 19:22:42 +0200 Message-Id: <1530552162-15533-16-git-send-email-eric.auger@redhat.com> In-Reply-To: <1530552162-15533-1-git-send-email-eric.auger@redhat.com> References: <1530552162-15533-1-git-send-email-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 02 Jul 2018 17:23:54 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 02 Jul 2018 17:23:54 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'eric.auger@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] [RFC v2 15/15] hw/arm/virt: Add nvdimm and nvdimm-persistence options 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: wei@redhat.com, drjones@redhat.com, david@gibson.dropbear.id.au, dgilbert@redhat.com, agraf@suse.de 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" Machine option nvdimm allows to turn NVDIMM support on. Signed-off-by: Eric Auger --- hw/arm/virt.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++= +--- 1 file changed, 57 insertions(+), 3 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 51f42cd..13e6dec 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1762,6 +1762,47 @@ static void virt_set_kvm_type(Object *obj, const cha= r *value, Error **errp) vms->kvm_type =3D g_strdup(value); } =20 +static bool virt_get_nvdimm(Object *obj, Error **errp) +{ + VirtMachineState *vms =3D VIRT_MACHINE(obj); + + return vms->acpi_nvdimm_state.is_enabled; +} + +static void virt_set_nvdimm(Object *obj, bool value, Error **errp) +{ + VirtMachineState *vms =3D VIRT_MACHINE(obj); + + vms->acpi_nvdimm_state.is_enabled =3D value; +} + +static char *virt_get_nvdimm_persistence(Object *obj, Error **errp) +{ + VirtMachineState *vms =3D VIRT_MACHINE(obj); + + return g_strdup(vms->acpi_nvdimm_state.persistence_string); +} + +static void virt_set_nvdimm_persistence(Object *obj, const char *value, + Error **errp) +{ + VirtMachineState *vms =3D VIRT_MACHINE(obj); + AcpiNVDIMMState *nvdimm_state =3D &vms->acpi_nvdimm_state; + + if (strcmp(value, "cpu") =3D=3D 0) + nvdimm_state->persistence =3D 3; + else if (strcmp(value, "mem-ctrl") =3D=3D 0) + nvdimm_state->persistence =3D 2; + else { + error_report("-machine nvdimm-persistence=3D%s: unsupported option= ", + value); + exit(EXIT_FAILURE); + } + + g_free(nvdimm_state->persistence_string); + nvdimm_state->persistence_string =3D g_strdup(value); +} + static CpuInstanceProperties virt_cpu_index_to_props(MachineState *ms, unsigned cpu_index) { @@ -1804,10 +1845,10 @@ static void virt_memory_pre_plug(HotplugHandler *ho= tplug_dev, DeviceState *dev, Error **errp) { const bool is_nvdimm =3D object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); + VirtMachineState *vms =3D VIRT_MACHINE(hotplug_dev); =20 - if (is_nvdimm) { - error_setg(errp, "nvdimm is not yet supported"); - return; + if (is_nvdimm && !vms->acpi_nvdimm_state.is_enabled) { + error_setg(errp, "nvdimm is not enabled: missing 'nvdimm' in '-M'"= ); } } =20 @@ -2044,6 +2085,19 @@ static void virt_3_0_instance_init(Object *obj) object_property_add_str(obj, "kvm-type", virt_get_kvm_type, virt_set_kvm_type, NULL); =20 + object_property_add_bool(obj, "nvdimm", + virt_get_nvdimm, virt_set_nvdimm, NULL); + object_property_set_description(obj, "nvdimm", + "Set on/off to enable/disable NVD= IMM " + "instantiation", NULL); + + object_property_add_str(obj, "nvdimm-persistence", + virt_get_nvdimm_persistence, + virt_set_nvdimm_persistence, NULL); + object_property_set_description(obj, "nvdimm-persistence", + "Set NVDIMM persistence" + "Valid values are cpu and mem-ctrl", N= ULL); + vms->memmap =3D a15memmap; vms->irqmap =3D a15irqmap; } --=20 2.5.5