From patchwork Thu Oct 18 14:30:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 985924 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42bWjw2QGkz9sBq for ; Fri, 19 Oct 2018 01:33:08 +1100 (AEDT) Received: from localhost ([::1]:42681 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD9MH-0006Lr-Ub for incoming@patchwork.ozlabs.org; Thu, 18 Oct 2018 10:33:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35903) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD9KR-0005Uh-8J for qemu-devel@nongnu.org; Thu, 18 Oct 2018 10:31:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gD9KQ-0006ae-88 for qemu-devel@nongnu.org; Thu, 18 Oct 2018 10:31:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53470) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gD9KL-0006OY-Qb; Thu, 18 Oct 2018 10:31:06 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 31D233001A5E; Thu, 18 Oct 2018 14:31:00 +0000 (UTC) Received: from laptop.redhat.com (ovpn-116-215.ams2.redhat.com [10.36.116.215]) by smtp.corp.redhat.com (Postfix) with ESMTP id C93C47899E; Thu, 18 Oct 2018 14:30: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: Thu, 18 Oct 2018 16:30:27 +0200 Message-Id: <20181018143042.29588-2-eric.auger@redhat.com> In-Reply-To: <20181018143042.29588-1-eric.auger@redhat.com> References: <20181018143042.29588-1-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Thu, 18 Oct 2018 14:31:00 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC v4 01/16] 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: drjones@redhat.com, dgilbert@redhat.com, Suzuki.Poulose@arm.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Shameer Kolothum We introduce an helper to create a memory node. Signed-off-by: Eric Auger Signed-off-by: Shameer Kolothum --- 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 20c71d7d96..ba2004da5c 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, } } +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 = NULL; + int ret; + + nodename = g_strdup_printf("/memory@%" PRIx64, mem_base); + qemu_fdt_add_subnode(fdt, nodename); + qemu_fdt_setprop_string(fdt, nodename, "device_type", "memory"); + ret = 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 = 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_info *binfo, void *fdt = NULL; int size, rc, n = 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_info *binfo, mem_base = binfo->loader_start; for (i = 0; i < nb_numa_nodes; i++) { mem_len = numa_info[i].node_mem; - nodename = g_strdup_printf("/memory@%" PRIx64, mem_base); - qemu_fdt_add_subnode(fdt, nodename); - qemu_fdt_setprop_string(fdt, nodename, "device_type", "memory"); - rc = qemu_fdt_setprop_sized_cells(fdt, nodename, "reg", - acells, mem_base, - scells, mem_len); + rc = 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", nodename, - i); goto fail; } - qemu_fdt_setprop_cell(fdt, nodename, "numa-node-id", i); mem_base += mem_len; - g_free(nodename); } } else { - nodename = g_strdup_printf("/memory@%" PRIx64, binfo->loader_start); - qemu_fdt_add_subnode(fdt, nodename); - qemu_fdt_setprop_string(fdt, nodename, "device_type", "memory"); - - rc = qemu_fdt_setprop_sized_cells(fdt, nodename, "reg", - acells, binfo->loader_start, - scells, binfo->ram_size); + rc = 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); } rc = fdt_path_offset(fdt, "/chosen"); From patchwork Thu Oct 18 14:30:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 985925 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42bWmt2WmZz9s8J for ; Fri, 19 Oct 2018 01:35:41 +1100 (AEDT) Received: from localhost ([::1]:42691 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD9Ol-0000bf-5F for incoming@patchwork.ozlabs.org; Thu, 18 Oct 2018 10:35:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36006) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD9Km-0005im-So for qemu-devel@nongnu.org; Thu, 18 Oct 2018 10:31:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gD9Kd-0006hr-Dq for qemu-devel@nongnu.org; Thu, 18 Oct 2018 10:31:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56338) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gD9KM-0006Pk-1v; Thu, 18 Oct 2018 10:31:06 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D7B173086269; Thu, 18 Oct 2018 14:31:02 +0000 (UTC) Received: from laptop.redhat.com (ovpn-116-215.ams2.redhat.com [10.36.116.215]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7929E7899E; Thu, 18 Oct 2018 14:31:00 +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: Thu, 18 Oct 2018 16:30:28 +0200 Message-Id: <20181018143042.29588-3-eric.auger@redhat.com> In-Reply-To: <20181018143042.29588-1-eric.auger@redhat.com> References: <20181018143042.29588-1-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Thu, 18 Oct 2018 14:31:02 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC v4 02/16] 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: drjones@redhat.com, dgilbert@redhat.com, Suzuki.Poulose@arm.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This is a header update against kvmarm next branch git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm kvmarm/next 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 --- v3 -> v4: - update against kvmarm next --- linux-headers/linux/kvm.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h index 83ba4eb571..9647ce4fcb 100644 --- a/linux-headers/linux/kvm.h +++ b/linux-headers/linux/kvm.h @@ -750,6 +750,15 @@ struct kvm_ppc_resize_hpt { #define KVM_S390_SIE_PAGE_OFFSET 1 +/* + * On arm64, machine type can be used to request the physical + * address size for the VM. Bits[7-0] are reserved for the guest + * PA size shift (i.e, log2(PA_Size)). For backward compatibility, + * value 0 implies the default IPA size, 40bits. + */ +#define KVM_VM_TYPE_ARM_IPA_SIZE_MASK 0xffULL +#define KVM_VM_TYPE_ARM_IPA_SIZE(x) \ + ((x) & KVM_VM_TYPE_ARM_IPA_SIZE_MASK) /* * ioctls for /dev/kvm fds: */ @@ -953,6 +962,7 @@ struct kvm_ppc_resize_hpt { #define KVM_CAP_NESTED_STATE 157 #define KVM_CAP_ARM_INJECT_SERROR_ESR 158 #define KVM_CAP_MSR_PLATFORM_INFO 159 +#define KVM_CAP_ARM_VM_IPA_SIZE 160 /* returns maximum IPA bits for a VM */ #ifdef KVM_CAP_IRQ_ROUTING From patchwork Thu Oct 18 14:30:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 985935 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42bWt542hpz9sBq for ; Fri, 19 Oct 2018 01:40:13 +1100 (AEDT) Received: from localhost ([::1]:42726 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD9T9-0004Ui-5b for incoming@patchwork.ozlabs.org; Thu, 18 Oct 2018 10:40:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36087) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD9Kt-0005pn-OL for qemu-devel@nongnu.org; Thu, 18 Oct 2018 10:31:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gD9Ks-0007C8-NP for qemu-devel@nongnu.org; Thu, 18 Oct 2018 10:31:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56018) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gD9Km-0006eJ-Sd; Thu, 18 Oct 2018 10:31:34 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 54E8B9091A; Thu, 18 Oct 2018 14:31:13 +0000 (UTC) Received: from laptop.redhat.com (ovpn-116-215.ams2.redhat.com [10.36.116.215]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6912A789AA; Thu, 18 Oct 2018 14:31:03 +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: Thu, 18 Oct 2018 16:30:29 +0200 Message-Id: <20181018143042.29588-4-eric.auger@redhat.com> In-Reply-To: <20181018143042.29588-1-eric.auger@redhat.com> References: <20181018143042.29588-1-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 18 Oct 2018 14:31:13 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC v4 03/16] 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: drjones@redhat.com, dgilbert@redhat.com, Suzuki.Poulose@arm.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 | 3 +-- hw/ppc/mac_oldworld.c | 2 +- hw/ppc/spapr.c | 2 +- include/hw/boards.h | 2 +- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index de12f78eb8..1505342ec5 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -1550,7 +1550,7 @@ static int kvm_init(MachineState *ms) kvm_type = qemu_opt_get(qemu_get_machine_opts(), "kvm-type"); if (mc->kvm_type) { - type = mc->kvm_type(kvm_type); + type = mc->kvm_type(ms, kvm_type); } else if (kvm_type) { ret = -EINVAL; fprintf(stderr, "Invalid argument kvm-type=%s\n", kvm_type); diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c index a630cb81cd..5b897011db 100644 --- a/hw/ppc/mac_newworld.c +++ b/hw/ppc/mac_newworld.c @@ -569,8 +569,7 @@ static char *core99_fw_dev_path(FWPathProvider *p, BusState *bus, return NULL; } - -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 9891c325a9..67cbd06b0f 100644 --- a/hw/ppc/mac_oldworld.c +++ b/hw/ppc/mac_oldworld.c @@ -422,7 +422,7 @@ static char *heathrow_fw_dev_path(FWPathProvider *p, BusState *bus, return NULL; } -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 98868d893a..18a9d2cf03 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2821,7 +2821,7 @@ static void spapr_machine_init(MachineState *machine) } } -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 f82f28468b..8bc015fb7c 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -172,7 +172,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); BlockInterfaceType block_default_type; int units_per_default_bus; From patchwork Thu Oct 18 14:30:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 985929 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42bWpp5hkGz9sC2 for ; Fri, 19 Oct 2018 01:37:22 +1100 (AEDT) Received: from localhost ([::1]:42712 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD9QO-0001s3-9c for incoming@patchwork.ozlabs.org; Thu, 18 Oct 2018 10:37:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36236) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD9L0-0005w8-7o for qemu-devel@nongnu.org; Thu, 18 Oct 2018 10:31:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gD9Kz-0007NI-Ah for qemu-devel@nongnu.org; Thu, 18 Oct 2018 10:31:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54376) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gD9Ks-0006lF-KE; Thu, 18 Oct 2018 10:31:38 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C4A1230A0210; Thu, 18 Oct 2018 14:31:24 +0000 (UTC) Received: from laptop.redhat.com (ovpn-116-215.ams2.redhat.com [10.36.116.215]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9D423789A3; Thu, 18 Oct 2018 14:31:13 +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: Thu, 18 Oct 2018 16:30:30 +0200 Message-Id: <20181018143042.29588-5-eric.auger@redhat.com> In-Reply-To: <20181018143042.29588-1-eric.auger@redhat.com> References: <20181018143042.29588-1-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Thu, 18 Oct 2018 14:31:24 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC v4 04/16] 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: drjones@redhat.com, dgilbert@redhat.com, Suzuki.Poulose@arm.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 specific IPA max size (kvm_type passed along KVM_CREATE_VM ioctl. Signed-off-by: Eric Auger --- v3 -> v4: - s/s/ms in kvm_arm_get_max_vm_phys_shift function comment - check KVM_CAP_ARM_VM_IPA_SIZE extension v1 -> v2: - put this in ARM specific code --- target/arm/kvm.c | 8 ++++++++ target/arm/kvm_arm.h | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/target/arm/kvm.c b/target/arm/kvm.c index 54ef5f711b..485e3291ae 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 = arm_host_cpu_features.features; } +int kvm_arm_get_max_vm_phys_shift(MachineState *ms) +{ + KVMState *s = KVM_STATE(ms->accelerator); + + return kvm_check_extension(s, KVM_CAP_ARM_VM_IPA_SIZE); +} + int kvm_arch_init(MachineState *ms, KVMState *s) { /* For ARM interrupt delivery is always asynchronous, diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h index 5948e8b560..749c38cb35 100644 --- a/target/arm/kvm_arm.h +++ b/target/arm/kvm_arm.h @@ -182,6 +182,17 @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf); */ void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu); +/** + * kvm_arm_get_max_vm_phys_shift - Returns log2 of the max IPA size + * supported by KVM + * + * @ms: 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 = true; } +static inline int kvm_arm_get_max_vm_phys_shift(MachineState *ms) +{ + return -ENOENT; +} + static inline int kvm_arm_vgic_probe(void) { return 0; From patchwork Thu Oct 18 14:30:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 985936 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42bWt66qwKz9s9h for ; Fri, 19 Oct 2018 01:40:14 +1100 (AEDT) Received: from localhost ([::1]:42727 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD9TA-0004Wu-G4 for incoming@patchwork.ozlabs.org; Thu, 18 Oct 2018 10:40:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36258) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD9L1-0005y1-QR for qemu-devel@nongnu.org; Thu, 18 Oct 2018 10:31:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gD9L1-0007Oh-13 for qemu-devel@nongnu.org; Thu, 18 Oct 2018 10:31:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53854) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gD9Kt-0006vO-EI; Thu, 18 Oct 2018 10:31:39 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B06E188E55; Thu, 18 Oct 2018 14:31:30 +0000 (UTC) Received: from laptop.redhat.com (ovpn-116-215.ams2.redhat.com [10.36.116.215]) by smtp.corp.redhat.com (Postfix) with ESMTP id 13DA4789A3; Thu, 18 Oct 2018 14:31: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: Thu, 18 Oct 2018 16:30:31 +0200 Message-Id: <20181018143042.29588-6-eric.auger@redhat.com> In-Reply-To: <20181018143042.29588-1-eric.auger@redhat.com> References: <20181018143042.29588-1-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 18 Oct 2018 14:31:30 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC v4 05/16] vl: Set machine ram_size, maxram_size and ram_slots earlier 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: drjones@redhat.com, dgilbert@redhat.com, Suzuki.Poulose@arm.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The machine RAM attributes will need to be analyzed during the configure_accelerator() process. especially kvm_type() arm64 machine callback will use them to know how many IPA/GPA bits are needed to model the whole RAM range. So let's assign those machine state fields before calling configure_accelerator. Signed-off-by: Eric Auger --- v4: new --- vl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vl.c b/vl.c index 4e25c78bff..35b426debd 100644 --- a/vl.c +++ b/vl.c @@ -4266,6 +4266,9 @@ int main(int argc, char **argv, char **envp) object_unref(OBJECT(current_machine)); exit(1); } + current_machine->ram_size = ram_size; + current_machine->maxram_size = maxram_size; + current_machine->ram_slots = ram_slots; configure_accelerator(current_machine); @@ -4470,9 +4473,6 @@ int main(int argc, char **argv, char **envp) replay_checkpoint(CHECKPOINT_INIT); qdev_machine_init(); - current_machine->ram_size = ram_size; - current_machine->maxram_size = maxram_size; - current_machine->ram_slots = ram_slots; current_machine->boot_order = boot_order; /* parse features once if machine provides default cpu_type */ From patchwork Thu Oct 18 14:30:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 985928 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42bWpC35HHz9s8J for ; Fri, 19 Oct 2018 01:36:51 +1100 (AEDT) Received: from localhost ([::1]:42709 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD9Ps-0001Vo-S8 for incoming@patchwork.ozlabs.org; Thu, 18 Oct 2018 10:36:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36164) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD9Kw-0005sJ-HO for qemu-devel@nongnu.org; Thu, 18 Oct 2018 10:31:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gD9Kv-0007IH-NG for qemu-devel@nongnu.org; Thu, 18 Oct 2018 10:31:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39678) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gD9Kt-00072u-2q; Thu, 18 Oct 2018 10:31:39 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9AB0E31676A7; Thu, 18 Oct 2018 14:31:33 +0000 (UTC) Received: from laptop.redhat.com (ovpn-116-215.ams2.redhat.com [10.36.116.215]) by smtp.corp.redhat.com (Postfix) with ESMTP id 026BF60150; Thu, 18 Oct 2018 14:31:30 +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: Thu, 18 Oct 2018 16:30:32 +0200 Message-Id: <20181018143042.29588-7-eric.auger@redhat.com> In-Reply-To: <20181018143042.29588-1-eric.auger@redhat.com> References: <20181018143042.29588-1-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Thu, 18 Oct 2018 14:31:33 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC v4 06/16] hw/arm/virt: Add virt-3.2 machine type 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: drjones@redhat.com, dgilbert@redhat.com, Suzuki.Poulose@arm.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Add virt-3.2 machine type. Signed-off-by: Eric Auger --- hw/arm/virt.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 9f677825f9..f920ef247b 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1796,7 +1796,7 @@ static void machvirt_machine_init(void) } type_init(machvirt_machine_init); -static void virt_3_1_instance_init(Object *obj) +static void virt_3_2_instance_init(Object *obj) { VirtMachineState *vms = VIRT_MACHINE(obj); VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms); @@ -1866,10 +1866,21 @@ static void virt_3_1_instance_init(Object *obj) vms->irqmap = a15irqmap; } -static void virt_machine_3_1_options(MachineClass *mc) +static void virt_machine_3_2_options(MachineClass *mc) { } -DEFINE_VIRT_MACHINE_AS_LATEST(3, 1) +DEFINE_VIRT_MACHINE_AS_LATEST(3, 2) + +static void virt_3_1_instance_init(Object *obj) +{ + virt_3_2_instance_init(obj); +} + +static void virt_machine_3_1_options(MachineClass *mc) +{ + virt_machine_3_2_options(mc); +} +DEFINE_VIRT_MACHINE(3, 1) static void virt_3_0_instance_init(Object *obj) { From patchwork Thu Oct 18 14:30:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 985943 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42bWxl5fFNz9sBq for ; Fri, 19 Oct 2018 01:43:23 +1100 (AEDT) Received: from localhost ([::1]:42743 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD9WD-00073S-D8 for incoming@patchwork.ozlabs.org; Thu, 18 Oct 2018 10:43:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36238) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD9L0-0005wU-FD for qemu-devel@nongnu.org; Thu, 18 Oct 2018 10:31:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gD9Kz-0007NL-Ai for qemu-devel@nongnu.org; Thu, 18 Oct 2018 10:31:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34442) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gD9Ku-0007EF-JK; Thu, 18 Oct 2018 10:31:40 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8325888314; Thu, 18 Oct 2018 14:31:39 +0000 (UTC) Received: from laptop.redhat.com (ovpn-116-215.ams2.redhat.com [10.36.116.215]) by smtp.corp.redhat.com (Postfix) with ESMTP id E0E64789A6; Thu, 18 Oct 2018 14:31: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: Thu, 18 Oct 2018 16:30:33 +0200 Message-Id: <20181018143042.29588-8-eric.auger@redhat.com> In-Reply-To: <20181018143042.29588-1-eric.auger@redhat.com> References: <20181018143042.29588-1-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 18 Oct 2018 14:31:39 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC v4 07/16] hw/arm/virt: Implement kvm_type function for 3.2 machine 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: drjones@redhat.com, dgilbert@redhat.com, Suzuki.Poulose@arm.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This patch computes the requested IPA bits according to the requested maxram value. The machine class kvm_type() callback is implemented and fills the kvm_type[7-0] bits with the computed max IPA shift (0 default value corresponds to 40b IPA). The kvm_type is passed to the KVM_CREATE_VM ioctl. The max IPA address shift is computed assuming the top of the address space is occuped by device memory starting at 2TB and of size maxram_size - ramsize. Signed-off-by: Eric Auger --- The approach to have an IPA range depending on the machine memory attributes is preferred here against having an IPA range based on the max capability of the host (which would be simpler). This latter would sometimes lead to having additional useless translation levels at stage2 as this may downgrade the guest performance. --- hw/arm/virt.c | 48 ++++++++++++++++++++++++++++++++++++++++++- include/hw/arm/virt.h | 1 + 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index f920ef247b..21718c250e 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -108,8 +108,12 @@ * of a terabyte of RAM will be doing it on a host with more than a * terabyte of physical address space.) */ +#define SZ_1G (1024ULL * 1024 * 1024) #define RAMLIMIT_GB 255 -#define RAMLIMIT_BYTES (RAMLIMIT_GB * 1024ULL * 1024 * 1024) +#define RAMLIMIT_BYTES (RAMLIMIT_GB * SZ_1G) + +/* device memory starts at 2TB */ +#define DEVICE_MEM_BASE (2048 * SZ_1G) /* Addresses and sizes of our components. * 0..128MB is space for a flash device so we can run bootrom code such as UEFI. @@ -1748,6 +1752,38 @@ static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *machine, return NULL; } +/* + * for arm64 kvm_type [7-0] encodes the IPA size shift + */ +static inline int virt_kvm_type(MachineState *ms, const char *type_str) +{ + int max_vm_phys_shift = kvm_arm_get_max_vm_phys_shift(ms); + ram_addr_t device_mem_size = ms->maxram_size - ms->ram_size; + uint8_t requested_vm_phys_shift; + + if (!device_mem_size) { + return 0; /* default 40b IPA */ + } + + /* we need at least 42b IPA to fit device memory at 2TB*/ + if (max_vm_phys_shift < 42) { + error_report("This host does not support 42b IPA: " + "maxram/slots options not usable"); + exit(1); + } + + requested_vm_phys_shift = 64 - clz64(DEVICE_MEM_BASE + device_mem_size); + + if (requested_vm_phys_shift > max_vm_phys_shift) { + error_report("maxmem option value too large. Max supported value " + "for this host is 0x%"PRIx64, + (ram_addr_t)((1ULL << max_vm_phys_shift) - DEVICE_MEM_BASE)); + exit(1); + } + + return requested_vm_phys_shift; +} + static void virt_machine_class_init(ObjectClass *oc, void *data) { MachineClass *mc = MACHINE_CLASS(oc); @@ -1772,6 +1808,7 @@ static void virt_machine_class_init(ObjectClass *oc, void *data) mc->cpu_index_to_instance_props = virt_cpu_index_to_props; mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a15"); mc->get_default_cpu_node_id = virt_get_default_cpu_node_id; + mc->kvm_type = virt_kvm_type; assert(!mc->get_hotplug_handler); mc->get_hotplug_handler = virt_machine_get_hotplug_handler; hc->plug = virt_machine_device_plug_cb; @@ -1878,7 +1915,16 @@ static void virt_3_1_instance_init(Object *obj) static void virt_machine_3_1_options(MachineClass *mc) { + VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc)); + virt_machine_3_2_options(mc); + + /* + * Device memory and capability to set the max IPA address shift + * are enabled from 3.2 onwards + */ + vmc->no_device_memory = true; + mc->kvm_type = NULL; } DEFINE_VIRT_MACHINE(3, 1) diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index 4cc57a7ef6..f57e4c1890 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -101,6 +101,7 @@ typedef struct { bool claim_edge_triggered_timers; bool smbios_old_sys_ver; bool no_highmem_ecam; + bool no_device_memory; } VirtMachineClass; typedef struct { From patchwork Thu Oct 18 14:30:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 985938 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42bWtS1Jckz9s9h for ; Fri, 19 Oct 2018 01:40:32 +1100 (AEDT) Received: from localhost ([::1]:42729 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD9TR-0004io-N7 for incoming@patchwork.ozlabs.org; Thu, 18 Oct 2018 10:40:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36260) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD9L1-0005y9-Tc for qemu-devel@nongnu.org; Thu, 18 Oct 2018 10:31:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gD9L0-0007Oa-KT for qemu-devel@nongnu.org; Thu, 18 Oct 2018 10:31:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53944) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gD9Kx-0007Jo-CJ; Thu, 18 Oct 2018 10:31:43 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5D57288E4F; Thu, 18 Oct 2018 14:31:42 +0000 (UTC) Received: from laptop.redhat.com (ovpn-116-215.ams2.redhat.com [10.36.116.215]) by smtp.corp.redhat.com (Postfix) with ESMTP id CAF44789A7; Thu, 18 Oct 2018 14:31:39 +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: Thu, 18 Oct 2018 16:30:34 +0200 Message-Id: <20181018143042.29588-9-eric.auger@redhat.com> In-Reply-To: <20181018143042.29588-1-eric.auger@redhat.com> References: <20181018143042.29588-1-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 18 Oct 2018 14:31:42 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC v4 08/16] 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: drjones@redhat.com, dgilbert@redhat.com, Suzuki.Poulose@arm.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" We define a device memory region stating at 2TB and max 4TB. This requires support of more than 40b IPA on host (CPU, kernel config and FW). IPA needs are adjusted according to maxram_size - ram_size value. This is largely inspired of device memory initialization in pc machine code. Signed-off-by: Eric Auger Signed-off-by: Kwangwoo Lee --- v3 -> v4: - remove bootinfo.device_memory_start/device_memory_size - rename VIRT_HOTPLUG_MEM into VIRT_DEVICE_MEM --- hw/arm/virt.c | 98 ++++++++++++++++++++++++++++++------------- include/hw/arm/virt.h | 1 + 2 files changed, 71 insertions(+), 28 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 21718c250e..9b06797090 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" #define DEFINE_VIRT_MACHINE_LATEST(major, minor, latest) \ static void virt_##major##_##minor##_class_init(ObjectClass *oc, \ @@ -94,38 +95,29 @@ #define PLATFORM_BUS_NUM_IRQS 64 -/* 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 spaces - * (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 SZ_1G (1024ULL * 1024 * 1024) -#define RAMLIMIT_GB 255 -#define RAMLIMIT_BYTES (RAMLIMIT_GB * SZ_1G) +#define SZ_64K 0x10000 /* device memory starts at 2TB */ #define DEVICE_MEM_BASE (2048 * SZ_1G) +#define DEVICE_MEM_SIZE (4096 * SZ_1G) /* 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..6TB is used for device memory (assumes dynamic IPA setting on kernel). + * + * 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[] = { /* Space up to 0x8000000 is reserved for a boot ROM */ @@ -154,12 +146,14 @@ static const MemMapEntry a15memmap[] = { [VIRT_PCIE_MMIO] = { 0x10000000, 0x2eff0000 }, [VIRT_PCIE_PIO] = { 0x3eff0000, 0x00010000 }, [VIRT_PCIE_ECAM] = { 0x3f000000, 0x01000000 }, - [VIRT_MEM] = { 0x40000000, RAMLIMIT_BYTES }, + [VIRT_MEM] = { SZ_1G , 255 * SZ_1G }, /* Additional 64 MB redist region (can contain up to 512 redistributors) */ [VIRT_GIC_REDIST2] = { 0x4000000000ULL, 0x4000000 }, [VIRT_PCIE_ECAM_HIGH] = { 0x4010000000ULL, 0x10000000 }, /* Second PCIe window, 512GB wide at the 512GB boundary */ - [VIRT_PCIE_MMIO_HIGH] = { 0x8000000000ULL, 0x8000000000ULL }, + [VIRT_PCIE_MMIO_HIGH] = { 512 * SZ_1G, 512 * SZ_1G }, + /* device memory beyond 2TB */ + [VIRT_DEVICE_MEM] = { DEVICE_MEM_BASE, DEVICE_MEM_SIZE }, }; static const int a15irqmap[] = { @@ -1265,6 +1259,51 @@ static void create_secure_ram(VirtMachineState *vms, g_free(nodename); } +static void create_device_memory(VirtMachineState *vms, MemoryRegion *sysmem) +{ + VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms); + MachineClass *mc = MACHINE_GET_CLASS(vms); + MachineState *ms = MACHINE(vms); + uint64_t device_memory_size = ms->maxram_size - ms->ram_size; + uint64_t align = SZ_64K; + + if (!device_memory_size) { + return; + } + + if (vmc->no_device_memory) { + error_report("Machine %s does not support device memory: " + "maxmem option not supported", mc->name); + exit(EXIT_FAILURE); + } + + 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) != ms->maxram_size) { + error_report("maximum memory size must be aligned to multiple of 0x%" + PRIx64, align); + exit(EXIT_FAILURE); + } + + if (device_memory_size > vms->memmap[VIRT_DEVICE_MEM].size) { + error_report("unsupported amount of maximum memory: " RAM_ADDR_FMT, + ms->maxram_size); + exit(EXIT_FAILURE); + } + + ms->device_memory = g_malloc0(sizeof(*ms->device_memory)); + ms->device_memory->base = vms->memmap[VIRT_DEVICE_MEM].base; + + 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); +} + static void *machvirt_dtb(const struct arm_boot_info *binfo, int *fdt_size) { const VirtMachineState *board = container_of(binfo, VirtMachineState, @@ -1438,7 +1477,8 @@ static void machvirt_init(MachineState *machine) vms->smp_cpus = smp_cpus; if (machine->ram_size > vms->memmap[VIRT_MEM].size) { - error_report("mach-virt: cannot model more than %dGB RAM", RAMLIMIT_GB); + error_report("mach-virt: cannot model more than %dGB RAM", + (int)(vms->memmap[VIRT_MEM].size / SZ_1G)); exit(1); } @@ -1533,6 +1573,8 @@ static void machvirt_init(MachineState *machine) machine->ram_size); memory_region_add_subregion(sysmem, vms->memmap[VIRT_MEM].base, ram); + create_device_memory(vms, sysmem); + create_flash(vms, sysmem, secure_sysmem ? secure_sysmem : sysmem); create_gic(vms, pic); diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index f57e4c1890..032d88f4c4 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -80,6 +80,7 @@ enum { VIRT_GPIO, VIRT_SECURE_UART, VIRT_SECURE_MEM, + VIRT_DEVICE_MEM, }; typedef enum VirtIOMMUType { From patchwork Thu Oct 18 14:30:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 985959 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42bX5L65xBz9sCT for ; Fri, 19 Oct 2018 01:49:58 +1100 (AEDT) Received: from localhost ([::1]:42789 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD9ca-0003rC-B6 for incoming@patchwork.ozlabs.org; Thu, 18 Oct 2018 10:49:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36355) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD9LC-000665-Hg for qemu-devel@nongnu.org; Thu, 18 Oct 2018 10:31:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gD9LB-0007Uf-I3 for qemu-devel@nongnu.org; Thu, 18 Oct 2018 10:31:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34532) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gD9L6-0007Qm-6D; Thu, 18 Oct 2018 10:31:52 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2538E7F7B5; Thu, 18 Oct 2018 14:31:51 +0000 (UTC) Received: from laptop.redhat.com (ovpn-116-215.ams2.redhat.com [10.36.116.215]) by smtp.corp.redhat.com (Postfix) with ESMTP id A65E060150; Thu, 18 Oct 2018 14:31:42 +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: Thu, 18 Oct 2018 16:30:35 +0200 Message-Id: <20181018143042.29588-10-eric.auger@redhat.com> In-Reply-To: <20181018143042.29588-1-eric.auger@redhat.com> References: <20181018143042.29588-1-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 18 Oct 2018 14:31:51 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC v4 09/16] 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: drjones@redhat.com, dgilbert@redhat.com, Suzuki.Poulose@arm.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 --- v3 -> v4: - check the memory device is not hotplugged v2 -> v3: - change in pc_dimm_plug()'s signature - add pc_dimm_pre_plug call 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 | 64 ++++++++++++++++++++++++++++++++- 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak index 2420491aac..1c110cfe7f 100644 --- a/default-configs/arm-softmmu.mak +++ b/default-configs/arm-softmmu.mak @@ -159,3 +159,5 @@ CONFIG_PCI_DESIGNWARE=y CONFIG_STRONGARM=y CONFIG_HIGHBANK=y CONFIG_MUSICPAL=y +CONFIG_MEM_HOTPLUG=y + diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 9b06797090..1548e9480a 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" #define DEFINE_VIRT_MACHINE_LATEST(major, minor, latest) \ static void virt_##major##_##minor##_class_init(ObjectClass *oc, \ @@ -1771,6 +1773,49 @@ static const CPUArchIdList *virt_possible_cpu_arch_ids(MachineState *ms) return ms->possible_cpus; } +static void virt_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, + Error **errp) +{ + const bool is_nvdimm = object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); + + if (dev->hotplugged) { + error_setg(errp, "memory hotplug is not supported"); + } + + if (is_nvdimm) { + error_setg(errp, "nvdimm is not yet supported"); + return; + } + + pc_dimm_pre_plug(dev, MACHINE(hotplug_dev), NULL, errp); +} + +static void virt_memory_plug(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ + VirtMachineState *vms = VIRT_MACHINE(hotplug_dev); + Error *local_err = NULL; + + pc_dimm_plug(dev, MACHINE(vms), &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) { @@ -1782,12 +1827,27 @@ static void virt_machine_device_plug_cb(HotplugHandler *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))); + } } static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *machine, 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); } @@ -1853,7 +1913,9 @@ static void virt_machine_class_init(ObjectClass *oc, void *data) mc->kvm_type = virt_kvm_type; assert(!mc->get_hotplug_handler); mc->get_hotplug_handler = virt_machine_get_hotplug_handler; + hc->pre_plug = virt_machine_device_pre_plug_cb; hc->plug = virt_machine_device_plug_cb; + hc->unplug = virt_machine_device_unplug_cb; } static const TypeInfo virt_machine_info = { From patchwork Thu Oct 18 14:30:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 985945 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42bWy36sxvz9sBq for ; Fri, 19 Oct 2018 01:43:39 +1100 (AEDT) Received: from localhost ([::1]:42747 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD9WT-0007RS-JP for incoming@patchwork.ozlabs.org; Thu, 18 Oct 2018 10:43:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36353) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD9LC-00065k-BJ for qemu-devel@nongnu.org; Thu, 18 Oct 2018 10:32:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gD9LB-0007Uk-In for qemu-devel@nongnu.org; Thu, 18 Oct 2018 10:31:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56694) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gD9L9-0007ST-0A; Thu, 18 Oct 2018 10:31:55 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CAEB430F8BF3; Thu, 18 Oct 2018 14:31:53 +0000 (UTC) Received: from laptop.redhat.com (ovpn-116-215.ams2.redhat.com [10.36.116.215]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6DF7E60150; Thu, 18 Oct 2018 14:31: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: Thu, 18 Oct 2018 16:30:36 +0200 Message-Id: <20181018143042.29588-11-eric.auger@redhat.com> In-Reply-To: <20181018143042.29588-1-eric.auger@redhat.com> References: <20181018143042.29588-1-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Thu, 18 Oct 2018 14:31:53 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC v4 10/16] 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: drjones@redhat.com, dgilbert@redhat.com, Suzuki.Poulose@arm.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 --- v3 -> v4: - git rid of @base and @len in fdt_add_hotpluggable_memory_nodes v1 -> v2: - added qapi_free_MemoryDeviceInfoList and simplify the loop --- hw/arm/boot.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/hw/arm/boot.c b/hw/arm/boot.c index ba2004da5c..81d621ce14 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,34 @@ static void fdt_add_psci_node(void *fdt) qemu_fdt_setprop_cell(fdt, "/psci", "migrate", migrate_fn); } +static int fdt_add_hotpluggable_memory_nodes(void *fdt, + uint32_t acells, uint32_t scells) { + MemoryDeviceInfoList *info, *info_list = qmp_memory_device_list(); + MemoryDeviceInfo *mi; + PCDIMMDeviceInfo *di; + bool is_nvdimm; + int ret = 0; + + for (info = info_list; info != NULL; info = info->next) { + mi = info->value; + is_nvdimm = (mi->type == MEMORY_DEVICE_INFO_KIND_NVDIMM); + di = !is_nvdimm ? mi->u.dimm.data : mi->u.nvdimm.data; + + if (is_nvdimm) { + ret = -ENOENT; /* NV-DIMM not yet supported */ + } else { + ret = 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 +640,12 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo, } } + rc = fdt_add_hotpluggable_memory_nodes(fdt, acells, scells); + if (rc < 0) { + fprintf(stderr, "couldn't add hotpluggable memory nodes\n"); + goto fail; + } + rc = fdt_path_offset(fdt, "/chosen"); if (rc < 0) { qemu_fdt_add_subnode(fdt, "/chosen"); From patchwork Thu Oct 18 14:30:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 985933 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42bWsG2XTZz9s9h for ; Fri, 19 Oct 2018 01:39:29 +1100 (AEDT) Received: from localhost ([::1]:42722 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD9SQ-0003zB-3l for incoming@patchwork.ozlabs.org; Thu, 18 Oct 2018 10:39:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36465) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD9LO-0006Gw-DB for qemu-devel@nongnu.org; Thu, 18 Oct 2018 10:32:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gD9LI-0007es-QM for qemu-devel@nongnu.org; Thu, 18 Oct 2018 10:32:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52777) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gD9LE-0007Wj-A1; Thu, 18 Oct 2018 10:32:00 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 611805F7AA; Thu, 18 Oct 2018 14:31:59 +0000 (UTC) Received: from laptop.redhat.com (ovpn-116-215.ams2.redhat.com [10.36.116.215]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D291789A6; Thu, 18 Oct 2018 14:31:53 +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: Thu, 18 Oct 2018 16:30:37 +0200 Message-Id: <20181018143042.29588-12-eric.auger@redhat.com> In-Reply-To: <20181018143042.29588-1-eric.auger@redhat.com> References: <20181018143042.29588-1-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 18 Oct 2018 14:31:59 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC v4 11/16] 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: drjones@redhat.com, dgilbert@redhat.com, Suzuki.Poulose@arm.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 +++++++++++++++++++++++++++++++++++++ include/hw/acpi/aml-build.h | 3 +++ 2 files changed, 54 insertions(+) diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index 1e43cd736d..167fb6bf3e 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 = qmp_memory_device_list(); + MemoryDeviceInfoList *info; + MemoryDeviceInfo *mi; + PCDIMMDeviceInfo *di; + uint64_t end = base + len, cur, size; + bool is_nvdimm; + AcpiSratMemoryAffinity *numamem; + MemoryAffinityFlags flags; + + for (cur = base, info = info_list; + cur < end; + cur += size, info = info->next) { + numamem = acpi_data_push(table_data, sizeof *numamem); + + if (!info) { + build_srat_memory(numamem, cur, end - cur, default_node, + MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENABLED); + break; + } + + mi = info->value; + is_nvdimm = (mi->type == MEMORY_DEVICE_INFO_KIND_NVDIMM); + di = !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_ENABLED); + numamem = acpi_data_push(table_data, sizeof *numamem); + } + + size = di->size; + + flags = MEM_AFFINITY_ENABLED; + if (di->hotpluggable) { + flags |= MEM_AFFINITY_HOTPLUGGABLE; + } + if (is_nvdimm) { + flags |= MEM_AFFINITY_NON_VOLATILE; + } + + build_srat_memory(numamem, di->addr, size, di->node, flags); + } + + qapi_free_MemoryDeviceInfoList(info_list); +} + diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h index 6c36903c0a..4c2ca134ee 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); 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 From patchwork Thu Oct 18 14:30:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 985964 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42bX960PD8z9sCT for ; Fri, 19 Oct 2018 01:53:14 +1100 (AEDT) Received: from localhost ([::1]:42813 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD9fj-0006WD-Hw for incoming@patchwork.ozlabs.org; Thu, 18 Oct 2018 10:53:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36439) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD9LK-0006Cu-3F for qemu-devel@nongnu.org; Thu, 18 Oct 2018 10:32:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gD9LJ-0007gY-FU for qemu-devel@nongnu.org; Thu, 18 Oct 2018 10:32:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56788) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gD9LH-0007aP-7c; Thu, 18 Oct 2018 10:32:03 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0E40830F8BF0; Thu, 18 Oct 2018 14:32:02 +0000 (UTC) Received: from laptop.redhat.com (ovpn-116-215.ams2.redhat.com [10.36.116.215]) by smtp.corp.redhat.com (Postfix) with ESMTP id A55FD7899E; Thu, 18 Oct 2018 14:31: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: Thu, 18 Oct 2018 16:30:38 +0200 Message-Id: <20181018143042.29588-13-eric.auger@redhat.com> In-Reply-To: <20181018143042.29588-1-eric.auger@redhat.com> References: <20181018143042.29588-1-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Thu, 18 Oct 2018 14:32:02 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC v4 12/16] 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: drjones@redhat.com, dgilbert@redhat.com, Suzuki.Poulose@arm.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Shameer Kolothum Generate Memory Affinity Structures for PC-DIMM ranges. Signed-off-by: Shameer Kolothum Signed-off-by: Eric Auger --- v3 -> v4: - do not use vms->bootinfo.device_memory_start/device_memory_size anymore 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 5785fb697c..8818bbf5ec 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -545,6 +545,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) int i, srat_start; uint64_t mem_base; MachineClass *mc = MACHINE_GET_CLASS(vms); + MachineState *ms = MACHINE(vms); const CPUArchIdList *cpu_list = mc->possible_cpu_arch_ids(MACHINE(vms)); srat_start = table_data->len; @@ -570,6 +571,9 @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) } } + build_srat_hotpluggable_memory(table_data, ms->device_memory->base, + ms->device_memory->mr.size, 0); + build_header(linker, table_data, (void *)(table_data->data + srat_start), "SRAT", table_data->len - srat_start, 3, NULL, NULL); } From patchwork Thu Oct 18 14:30:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 985948 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42bWzc18kgz9sC2 for ; Fri, 19 Oct 2018 01:45:00 +1100 (AEDT) Received: from localhost ([::1]:42754 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD9Xl-0000Fh-AA for incoming@patchwork.ozlabs.org; Thu, 18 Oct 2018 10:44:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36541) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD9Lc-0006SG-U0 for qemu-devel@nongnu.org; Thu, 18 Oct 2018 10:32:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gD9LY-00088z-Sd for qemu-devel@nongnu.org; Thu, 18 Oct 2018 10:32:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56872) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gD9LP-0007oZ-Do; Thu, 18 Oct 2018 10:32:11 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B03C130F8BF0; Thu, 18 Oct 2018 14:32:10 +0000 (UTC) Received: from laptop.redhat.com (ovpn-116-215.ams2.redhat.com [10.36.116.215]) by smtp.corp.redhat.com (Postfix) with ESMTP id 545F97899E; Thu, 18 Oct 2018 14:32: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: Thu, 18 Oct 2018 16:30:39 +0200 Message-Id: <20181018143042.29588-14-eric.auger@redhat.com> In-Reply-To: <20181018143042.29588-1-eric.auger@redhat.com> References: <20181018143042.29588-1-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Thu, 18 Oct 2018 14:32:10 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC v4 13/16] 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: drjones@redhat.com, dgilbert@redhat.com, Suzuki.Poulose@arm.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 --- v2 -> v3: - s/size/len in pc_piix.c and pc_q35.c --- 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 27eeb6609f..17d71469be 100644 --- a/hw/acpi/nvdimm.c +++ b/hw/acpi/nvdimm.c @@ -929,8 +929,8 @@ void nvdimm_init_acpi_state(AcpiNVDIMMState *state, MemoryRegion *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); state->dsm_mem = 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, MemoryRegion *io, #define NVDIMM_QEMU_RSVD_UUID "648B9CF2-CDA1-4312-8AD9-49C4AF32BD62" -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; method = aml_method(NVDIMM_COMMON_DSM, 5, AML_SERIALIZED); uuid = aml_arg(0); @@ -975,9 +977,16 @@ static void nvdimm_build_common_dsm(Aml *dev) aml_append(method, aml_store(aml_name(NVDIMM_ACPI_MEM_ADDR), dsm_mem)); + if (acpi_nvdimm_state->dsm_io.type == NVDIMM_ACPI_IO_PORT) { + rs = AML_SYSTEM_IO; + } else { + rs = 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))); @@ -1260,7 +1269,8 @@ static void nvdimm_build_nvdimm_devices(Aml *root_dev, uint32_t ram_slots) } 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"))); - nvdimm_build_common_dsm(dev); + nvdimm_build_common_dsm(dev, acpi_nvdimm_state); /* 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); bios_linker_loader_alloc(linker, - NVDIMM_DSM_MEM_FILE, dsm_dma_arrea, + NVDIMM_DSM_MEM_FILE, acpi_nvdimm_state->dsm_mem, 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; } - nvdimm_build_ssdt(table_offsets, table_data, linker, state->dsm_mem, + nvdimm_build_ssdt(table_offsets, table_data, linker, state, ram_slots); device_list = nvdimm_get_device_list(); diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index dc09466b3e..c569a19663 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -297,7 +297,13 @@ static void pc_init1(MachineState *machine, } if (pcms->acpi_nvdimm_state.is_enabled) { - nvdimm_init_acpi_state(&pcms->acpi_nvdimm_state, system_io, + AcpiNVDIMMState *acpi_nvdimm_state = &pcms->acpi_nvdimm_state; + + acpi_nvdimm_state->dsm_io.type = NVDIMM_ACPI_IO_PORT; + acpi_nvdimm_state->dsm_io.base = NVDIMM_ACPI_IO_BASE; + acpi_nvdimm_state->dsm_io.len = 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 532241e3f8..a693feb589 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -277,7 +277,13 @@ static void pc_q35_init(MachineState *machine) pc_nic_init(pcmc, isa_bus, host_bus); if (pcms->acpi_nvdimm_state.is_enabled) { - nvdimm_init_acpi_state(&pcms->acpi_nvdimm_state, system_io, + AcpiNVDIMMState *acpi_nvdimm_state = &pcms->acpi_nvdimm_state; + + acpi_nvdimm_state->dsm_io.type = NVDIMM_ACPI_IO_PORT; + acpi_nvdimm_state->dsm_io.base = NVDIMM_ACPI_IO_BASE; + acpi_nvdimm_state->dsm_io.len = 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 c5c9b3c7f8..af8a5fd034 100644 --- a/include/hw/mem/nvdimm.h +++ b/include/hw/mem/nvdimm.h @@ -123,6 +123,17 @@ struct NvdimmFitBuffer { }; typedef struct NvdimmFitBuffer NvdimmFitBuffer; +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; From patchwork Thu Oct 18 14:30:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 985950 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42bX0R69r0z9sC2 for ; Fri, 19 Oct 2018 01:45:43 +1100 (AEDT) Received: from localhost ([::1]:42758 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD9YT-0000mP-3r for incoming@patchwork.ozlabs.org; Thu, 18 Oct 2018 10:45:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36577) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD9Lh-0006UO-BP for qemu-devel@nongnu.org; Thu, 18 Oct 2018 10:32:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gD9LZ-00089D-P0 for qemu-devel@nongnu.org; Thu, 18 Oct 2018 10:32:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52436) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gD9LS-0007tE-5S; Thu, 18 Oct 2018 10:32:14 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6F57FC0587CE; Thu, 18 Oct 2018 14:32:13 +0000 (UTC) Received: from laptop.redhat.com (ovpn-116-215.ams2.redhat.com [10.36.116.215]) by smtp.corp.redhat.com (Postfix) with ESMTP id 00CF060150; Thu, 18 Oct 2018 14:32:10 +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: Thu, 18 Oct 2018 16:30:40 +0200 Message-Id: <20181018143042.29588-15-eric.auger@redhat.com> In-Reply-To: <20181018143042.29588-1-eric.auger@redhat.com> References: <20181018143042.29588-1-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 18 Oct 2018 14:32:13 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC v4 14/16] 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: drjones@redhat.com, dgilbert@redhat.com, Suzuki.Poulose@arm.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 | 22 ++++++++++++++++++++++ include/hw/arm/virt.h | 3 +++ 4 files changed, 33 insertions(+) diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak index 1c110cfe7f..466b3d2c39 100644 --- a/default-configs/arm-softmmu.mak +++ b/default-configs/arm-softmmu.mak @@ -160,4 +160,6 @@ CONFIG_STRONGARM=y CONFIG_HIGHBANK=y CONFIG_MUSICPAL=y CONFIG_MEM_HOTPLUG=y +CONFIG_NVDIMM=y +CONFIG_ACPI_NVDIMM=y diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 8818bbf5ec..dc100dd4c0 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -808,6 +808,7 @@ static void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables) { VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms); + MachineState *ms = MACHINE(vms); GArray *table_offsets; unsigned dsdt, xsdt; GArray *tables_blob = tables->table_data; @@ -848,6 +849,11 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables) } } + 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 1548e9480a..d84d5a5841 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -141,6 +141,7 @@ static const MemMapEntry a15memmap[] = { [VIRT_GPIO] = { 0x09030000, 0x00001000 }, [VIRT_SECURE_UART] = { 0x09040000, 0x00001000 }, [VIRT_SMMU] = { 0x09050000, 0x00020000 }, + [VIRT_ACPI_IO] = { 0x09070000, 0x00010000 }, [VIRT_MMIO] = { 0x0a000000, 0x00000200 }, /* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */ [VIRT_PLATFORM_BUS] = { 0x0c000000, 0x02000000 }, @@ -1609,6 +1610,18 @@ static void machvirt_init(MachineState *machine) create_platform_bus(vms, pic); + if (vms->acpi_nvdimm_state.is_enabled) { + AcpiNVDIMMState *acpi_nvdimm_state = &vms->acpi_nvdimm_state; + + acpi_nvdimm_state->dsm_io.type = NVDIMM_ACPI_IO_MEMORY; + acpi_nvdimm_state->dsm_io.base = + vms->memmap[VIRT_ACPI_IO].base + NVDIMM_ACPI_IO_BASE; + acpi_nvdimm_state->dsm_io.len = NVDIMM_ACPI_IO_LEN; + + nvdimm_init_acpi_state(acpi_nvdimm_state, sysmem, + vms->fw_cfg, OBJECT(vms)); + } + vms->bootinfo.ram_size = machine->ram_size; vms->bootinfo.kernel_filename = machine->kernel_filename; vms->bootinfo.kernel_cmdline = machine->kernel_cmdline; @@ -1794,10 +1807,19 @@ static void virt_memory_plug(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { VirtMachineState *vms = VIRT_MACHINE(hotplug_dev); + bool is_nvdimm = object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); Error *local_err = NULL; pc_dimm_plug(dev, MACHINE(vms), &local_err); + if (local_err) { + goto out; + } + if (is_nvdimm) { + nvdimm_plug(&vms->acpi_nvdimm_state); + } + +out: error_propagate(errp, local_err); } diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index 032d88f4c4..974a110a38 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" #define NUM_GICV2M_SPIS 64 #define NUM_VIRTIO_TRANSPORTS 32 @@ -81,6 +82,7 @@ enum { VIRT_SECURE_UART, VIRT_SECURE_MEM, VIRT_DEVICE_MEM, + VIRT_ACPI_IO, }; typedef enum VirtIOMMUType { @@ -128,6 +130,7 @@ typedef struct { uint32_t msi_phandle; uint32_t iommu_phandle; int psci_conduit; + AcpiNVDIMMState acpi_nvdimm_state; } VirtMachineState; #define VIRT_ECAM_ID(high) (high ? VIRT_PCIE_ECAM_HIGH : VIRT_PCIE_ECAM) From patchwork Thu Oct 18 14:30:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 985942 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42bWwt4m2Vz9sBj for ; Fri, 19 Oct 2018 01:42:38 +1100 (AEDT) Received: from localhost ([::1]:42740 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD9VT-0006Lr-QP for incoming@patchwork.ozlabs.org; Thu, 18 Oct 2018 10:42:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36609) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD9Li-0006Wg-Ei for qemu-devel@nongnu.org; Thu, 18 Oct 2018 10:32:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gD9Lh-0008Fu-CS for qemu-devel@nongnu.org; Thu, 18 Oct 2018 10:32:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56586) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gD9La-00085z-4q; Thu, 18 Oct 2018 10:32:22 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 035B313A9D; Thu, 18 Oct 2018 14:32:19 +0000 (UTC) Received: from laptop.redhat.com (ovpn-116-215.ams2.redhat.com [10.36.116.215]) by smtp.corp.redhat.com (Postfix) with ESMTP id B242060150; Thu, 18 Oct 2018 14:32:13 +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: Thu, 18 Oct 2018 16:30:41 +0200 Message-Id: <20181018143042.29588-16-eric.auger@redhat.com> In-Reply-To: <20181018143042.29588-1-eric.auger@redhat.com> References: <20181018143042.29588-1-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 18 Oct 2018 14:32:19 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC v4 15/16] 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: drjones@redhat.com, dgilbert@redhat.com, Suzuki.Poulose@arm.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 81d621ce14..50acf0abd4 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -444,6 +444,36 @@ out: return ret; } +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 = NULL; + int ret; + + nodename = g_strdup_printf("/pmem@%" PRIx64, mem_base); + qemu_fdt_add_subnode(fdt, nodename); + qemu_fdt_setprop_string(fdt, nodename, "compatible", "pmem-region"); + ret = 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 = 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; @@ -531,7 +561,8 @@ static int fdt_add_hotpluggable_memory_nodes(void *fdt, di = !is_nvdimm ? mi->u.dimm.data : mi->u.nvdimm.data; if (is_nvdimm) { - ret = -ENOENT; /* NV-DIMM not yet supported */ + ret = fdt_add_pmem_node(fdt, acells, di->addr, + scells, di->size, di->node); } else { ret = fdt_add_memory_node(fdt, acells, di->addr, scells, di->size, di->node); From patchwork Thu Oct 18 14:30:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 985956 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42bX4K4xmKz9sC2 for ; Fri, 19 Oct 2018 01:49:05 +1100 (AEDT) Received: from localhost ([::1]:42784 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD9bj-0003DC-6x for incoming@patchwork.ozlabs.org; Thu, 18 Oct 2018 10:49:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36640) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD9Ln-0006cy-Cl for qemu-devel@nongnu.org; Thu, 18 Oct 2018 10:32:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gD9Lm-0008PL-ER for qemu-devel@nongnu.org; Thu, 18 Oct 2018 10:32:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39986) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gD9Lc-00089K-SP; Thu, 18 Oct 2018 10:32:26 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A6AC1308A95E; Thu, 18 Oct 2018 14:32:21 +0000 (UTC) Received: from laptop.redhat.com (ovpn-116-215.ams2.redhat.com [10.36.116.215]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4B81260150; Thu, 18 Oct 2018 14:32:19 +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: Thu, 18 Oct 2018 16:30:42 +0200 Message-Id: <20181018143042.29588-17-eric.auger@redhat.com> In-Reply-To: <20181018143042.29588-1-eric.auger@redhat.com> References: <20181018143042.29588-1-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Thu, 18 Oct 2018 14:32:21 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC v4 16/16] 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: drjones@redhat.com, dgilbert@redhat.com, Suzuki.Poulose@arm.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Machine option nvdimm allows to turn NVDIMM support on. Signed-off-by: Eric Auger --- hw/arm/virt.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index d84d5a5841..02fb62595e 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1748,6 +1748,47 @@ static void virt_set_iommu(Object *obj, const char *value, Error **errp) } } +static bool virt_get_nvdimm(Object *obj, Error **errp) +{ + VirtMachineState *vms = VIRT_MACHINE(obj); + + return vms->acpi_nvdimm_state.is_enabled; +} + +static void virt_set_nvdimm(Object *obj, bool value, Error **errp) +{ + VirtMachineState *vms = VIRT_MACHINE(obj); + + vms->acpi_nvdimm_state.is_enabled = value; +} + +static char *virt_get_nvdimm_persistence(Object *obj, Error **errp) +{ + VirtMachineState *vms = 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 = VIRT_MACHINE(obj); + AcpiNVDIMMState *nvdimm_state = &vms->acpi_nvdimm_state; + + if (strcmp(value, "cpu") == 0) + nvdimm_state->persistence = 3; + else if (strcmp(value, "mem-ctrl") == 0) + nvdimm_state->persistence = 2; + else { + error_report("-machine nvdimm-persistence=%s: unsupported option", + value); + exit(EXIT_FAILURE); + } + + g_free(nvdimm_state->persistence_string); + nvdimm_state->persistence_string = g_strdup(value); +} + static CpuInstanceProperties virt_cpu_index_to_props(MachineState *ms, unsigned cpu_index) { @@ -1790,13 +1831,14 @@ static void virt_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { const bool is_nvdimm = object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); + VirtMachineState *vms = VIRT_MACHINE(hotplug_dev); if (dev->hotplugged) { error_setg(errp, "memory hotplug is not supported"); } - if (is_nvdimm) { - error_setg(errp, "nvdimm is not yet supported"); + if (is_nvdimm && !vms->acpi_nvdimm_state.is_enabled) { + error_setg(errp, "nvdimm is not enabled: missing 'nvdimm' in '-M'"); return; } @@ -2025,6 +2067,19 @@ static void virt_3_2_instance_init(Object *obj) "Valid values are none and smmuv3", NULL); + 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 NVDIMM " + "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", NULL); + vms->memmap = a15memmap; vms->irqmap = a15irqmap; }