From nobody Sat Apr 27 15:46:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529500689681717.55689291672; Wed, 20 Jun 2018 06:18:09 -0700 (PDT) Received: from localhost ([::1]:49601 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fVczq-0005Ur-R8 for importer@patchew.org; Wed, 20 Jun 2018 09:18:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50911) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fVcq1-0004RN-8i for qemu-devel@nongnu.org; Wed, 20 Jun 2018 09:07:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fVcq0-0005gX-1F for qemu-devel@nongnu.org; Wed, 20 Jun 2018 09:07:53 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:34530 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fVcpu-0005ej-V3; Wed, 20 Jun 2018 09:07:47 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 90BB67721B; Wed, 20 Jun 2018 13:07:46 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-106.ams2.redhat.com [10.36.117.106]) by smtp.corp.redhat.com (Postfix) with ESMTP id DE1ED2026D6B; Wed, 20 Jun 2018 13:07:44 +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 Date: Wed, 20 Jun 2018 15:07:28 +0200 Message-Id: <1529500053-21704-2-git-send-email-eric.auger@redhat.com> In-Reply-To: <1529500053-21704-1-git-send-email-eric.auger@redhat.com> References: <1529500053-21704-1-git-send-email-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Wed, 20 Jun 2018 13:07:46 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Wed, 20 Jun 2018 13:07:46 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'eric.auger@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [RFC 1/6] linux-headers: Partial update for KVM/ARM KVM_ARM_GET_MAX_VM_PHYS_SHIFT X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: wei@redhat.com, drjones@redhat.com, suzuki.poulose@arm.com, dgilbert@redhat.com, agraf@suse.de, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This is a partial header to get the KVM_ARM_GET_MAX_VM_PHYS_SHIFT ioctl. This allows to retrieve the IPA address range KVM supports. This is based on branch: https://github.com/eauger/linux/tree/4.16.0-rc3-Suzuki-52b-IPA-v2 itself derived from Suzuki's branch (just incremented the IOCTL index) git://linux-arm.org/linux-skp.git ipa52/v2 Signed-off-by: Eric Auger --- linux-headers/asm-arm/kvm.h | 15 --------------- linux-headers/asm-arm64/kvm.h | 6 ------ linux-headers/linux/kvm.h | 6 ++++++ 3 files changed, 6 insertions(+), 21 deletions(-) diff --git a/linux-headers/asm-arm/kvm.h b/linux-headers/asm-arm/kvm.h index 670b43c..4392955 100644 --- a/linux-headers/asm-arm/kvm.h +++ b/linux-headers/asm-arm/kvm.h @@ -135,15 +135,6 @@ struct kvm_arch_memory_slot { #define KVM_REG_ARM_CRM_SHIFT 7 #define KVM_REG_ARM_32_CRN_MASK 0x0000000000007800 #define KVM_REG_ARM_32_CRN_SHIFT 11 -/* - * For KVM currently all guest registers are nonsecure, but we reserve a b= it - * in the encoding to distinguish secure from nonsecure for AArch32 system - * registers that are banked by security. This is 1 for the secure banked - * register, and 0 for the nonsecure banked register or if the register is - * not banked by security. - */ -#define KVM_REG_ARM_SECURE_MASK 0x0000000010000000 -#define KVM_REG_ARM_SECURE_SHIFT 28 =20 #define ARM_CP15_REG_SHIFT_MASK(x,n) \ (((x) << KVM_REG_ARM_ ## n ## _SHIFT) & KVM_REG_ARM_ ## n ## _MASK) @@ -195,12 +186,6 @@ struct kvm_arch_memory_slot { #define KVM_REG_ARM_VFP_FPINST 0x1009 #define KVM_REG_ARM_VFP_FPINST2 0x100A =20 -/* KVM-as-firmware specific pseudo-registers */ -#define KVM_REG_ARM_FW (0x0014 << KVM_REG_ARM_COPROC_SHIFT) -#define KVM_REG_ARM_FW_REG(r) (KVM_REG_ARM | KVM_REG_SIZE_U64 | \ - KVM_REG_ARM_FW | ((r) & 0xffff)) -#define KVM_REG_ARM_PSCI_VERSION KVM_REG_ARM_FW_REG(0) - /* Device Control API: ARM VGIC */ #define KVM_DEV_ARM_VGIC_GRP_ADDR 0 #define KVM_DEV_ARM_VGIC_GRP_DIST_REGS 1 diff --git a/linux-headers/asm-arm64/kvm.h b/linux-headers/asm-arm64/kvm.h index 17315ab..4e80651 100644 --- a/linux-headers/asm-arm64/kvm.h +++ b/linux-headers/asm-arm64/kvm.h @@ -206,12 +206,6 @@ struct kvm_arch_memory_slot { #define KVM_REG_ARM_TIMER_CNT ARM64_SYS_REG(3, 3, 14, 3, 2) #define KVM_REG_ARM_TIMER_CVAL ARM64_SYS_REG(3, 3, 14, 0, 2) =20 -/* KVM-as-firmware specific pseudo-registers */ -#define KVM_REG_ARM_FW (0x0014 << KVM_REG_ARM_COPROC_SHIFT) -#define KVM_REG_ARM_FW_REG(r) (KVM_REG_ARM64 | KVM_REG_SIZE_U64 | \ - KVM_REG_ARM_FW | ((r) & 0xffff)) -#define KVM_REG_ARM_PSCI_VERSION KVM_REG_ARM_FW_REG(0) - /* Device Control API: ARM VGIC */ #define KVM_DEV_ARM_VGIC_GRP_ADDR 0 #define KVM_DEV_ARM_VGIC_GRP_DIST_REGS 1 diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h index cdb148e..a6c4e24 100644 --- a/linux-headers/linux/kvm.h +++ b/linux-headers/linux/kvm.h @@ -774,6 +774,12 @@ struct kvm_ppc_resize_hpt { #define KVM_GET_EMULATED_CPUID _IOWR(KVMIO, 0x09, struct kvm_cpuid2) #define KVM_GET_MSR_FEATURE_INDEX_LIST _IOWR(KVMIO, 0x0a, struct kvm_ms= r_list) =20 + /* + * Get the maximum physical address size supported by the host. + * Returns log2(Max-Physical-Address-Size) + */ +#define KVM_ARM_GET_MAX_VM_PHYS_SHIFT _IO(KVMIO, 0x0b) + /* * Extension capability list. */ --=20 2.5.5 From nobody Sat Apr 27 15:46:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529500328743219.64366883403864; Wed, 20 Jun 2018 06:12:08 -0700 (PDT) Received: from localhost ([::1]:49549 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fVcu7-0007X8-TV for importer@patchew.org; Wed, 20 Jun 2018 09:12:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50950) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fVcq2-0004SL-IN for qemu-devel@nongnu.org; Wed, 20 Jun 2018 09:07:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fVcq1-0005hV-D4 for qemu-devel@nongnu.org; Wed, 20 Jun 2018 09:07:54 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:53746 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fVcpx-0005fG-6F; Wed, 20 Jun 2018 09:07:49 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C6AD44023826; Wed, 20 Jun 2018 13:07:48 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-106.ams2.redhat.com [10.36.117.106]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D6D72026D6B; Wed, 20 Jun 2018 13:07:46 +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 Date: Wed, 20 Jun 2018 15:07:29 +0200 Message-Id: <1529500053-21704-3-git-send-email-eric.auger@redhat.com> In-Reply-To: <1529500053-21704-1-git-send-email-eric.auger@redhat.com> References: <1529500053-21704-1-git-send-email-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 20 Jun 2018 13:07:48 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 20 Jun 2018 13:07:48 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'eric.auger@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [RFC 2/6] hw/boards: Add a MachineState parameter to kvm_type callback X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: wei@redhat.com, drjones@redhat.com, suzuki.poulose@arm.com, dgilbert@redhat.com, agraf@suse.de, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" On ARM, the kvm_type will be resolved by querying the KVMState. Let's add the MachineState handle to the callback so that we can retrieve the KVMState handle. in kvm_init, when the callback is called, the kvm_state variable is not yet set. Signed-off-by: Eric Auger Acked-by: David Gibson --- accel/kvm/kvm-all.c | 2 +- hw/ppc/mac_newworld.c | 2 +- hw/ppc/mac_oldworld.c | 2 +- hw/ppc/spapr.c | 2 +- include/hw/boards.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index ffee68e..0590986 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -1550,7 +1550,7 @@ static int kvm_init(MachineState *ms) =20 kvm_type =3D qemu_opt_get(qemu_get_machine_opts(), "kvm-type"); if (mc->kvm_type) { - type =3D mc->kvm_type(kvm_type); + type =3D mc->kvm_type(ms, kvm_type); } else if (kvm_type) { ret =3D -EINVAL; fprintf(stderr, "Invalid argument kvm-type=3D%s\n", kvm_type); diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c index 744acdf..1409d9e 100644 --- a/hw/ppc/mac_newworld.c +++ b/hw/ppc/mac_newworld.c @@ -492,7 +492,7 @@ static void ppc_core99_init(MachineState *machine) qemu_register_boot_set(fw_cfg_boot_set, fw_cfg); } =20 -static int core99_kvm_type(const char *arg) +static int core99_kvm_type(MachineState *ms, const char *arg) { /* Always force PR KVM */ return 2; diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c index 4608bab..1211fcd 100644 --- a/hw/ppc/mac_oldworld.c +++ b/hw/ppc/mac_oldworld.c @@ -363,7 +363,7 @@ static void ppc_heathrow_init(MachineState *machine) qemu_register_boot_set(fw_cfg_boot_set, fw_cfg); } =20 -static int heathrow_kvm_type(const char *arg) +static int heathrow_kvm_type(MachineState *ms, const char *arg) { /* Always force PR KVM */ return 2; diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index f59999d..faf078e 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2834,7 +2834,7 @@ static void spapr_machine_init(MachineState *machine) } } =20 -static int spapr_kvm_type(const char *vm_type) +static int spapr_kvm_type(MachineState *ms, const char *vm_type) { if (!vm_type) { return 0; diff --git a/include/hw/boards.h b/include/hw/boards.h index ef7457f..78f90a1 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -170,7 +170,7 @@ struct MachineClass { void (*init)(MachineState *state); void (*reset)(void); void (*hot_add_cpu)(const int64_t id, Error **errp); - int (*kvm_type)(const char *arg); + int (*kvm_type)(MachineState *ms, const char *arg); =20 BlockInterfaceType block_default_type; int units_per_default_bus; --=20 2.5.5 From nobody Sat Apr 27 15:46:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529500760739595.7353726174199; Wed, 20 Jun 2018 06:19:20 -0700 (PDT) Received: from localhost ([::1]:49603 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fVd16-0006Od-0s for importer@patchew.org; Wed, 20 Jun 2018 09:19:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50945) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fVcq2-0004SK-C8 for qemu-devel@nongnu.org; Wed, 20 Jun 2018 09:07:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fVcq1-0005hL-BF for qemu-devel@nongnu.org; Wed, 20 Jun 2018 09:07:54 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:34694 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fVcpz-0005fs-49; Wed, 20 Jun 2018 09:07:51 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BDEED81A4E9F; Wed, 20 Jun 2018 13:07:50 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-106.ams2.redhat.com [10.36.117.106]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A81C2026D6B; Wed, 20 Jun 2018 13:07:48 +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 Date: Wed, 20 Jun 2018 15:07:30 +0200 Message-Id: <1529500053-21704-4-git-send-email-eric.auger@redhat.com> In-Reply-To: <1529500053-21704-1-git-send-email-eric.auger@redhat.com> References: <1529500053-21704-1-git-send-email-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 20 Jun 2018 13:07:50 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 20 Jun 2018 13:07:50 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'eric.auger@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [RFC 3/6] kvm: add kvm_get_max_vm_phys_shift X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: wei@redhat.com, drjones@redhat.com, suzuki.poulose@arm.com, dgilbert@redhat.com, agraf@suse.de, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add the kvm_get_max_vm_phys_shift() helper that returns the log of the maximum IPA size supported by KVM. This capability needs to be known to create the VM with a correct IPA max size (kvm_type passed along KVM_CREATE_VM ioctl. Signed-off-by: Eric Auger --- accel/kvm/kvm-all.c | 7 +++++++ accel/stubs/kvm-stub.c | 5 +++++ include/sysemu/kvm.h | 1 + 3 files changed, 13 insertions(+) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 0590986..137c38e 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -280,6 +280,13 @@ static int kvm_set_user_memory_region(KVMMemoryListene= r *kml, KVMSlot *slot) return ret; } =20 +int kvm_get_max_vm_phys_shift(MachineState *ms) +{ + KVMState *s =3D KVM_STATE(ms->accelerator); + + return kvm_ioctl(s, KVM_ARM_GET_MAX_VM_PHYS_SHIFT, 0); +} + int kvm_destroy_vcpu(CPUState *cpu) { KVMState *s =3D kvm_state; diff --git a/accel/stubs/kvm-stub.c b/accel/stubs/kvm-stub.c index 02d5170..7575ba7 100644 --- a/accel/stubs/kvm-stub.c +++ b/accel/stubs/kvm-stub.c @@ -161,6 +161,11 @@ bool kvm_has_free_slot(MachineState *ms) return false; } =20 +int kvm_get_max_vm_phys_shift(MachineState *ms) +{ + return 0; +} + void kvm_init_cpu_signals(CPUState *cpu) { abort(); diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index 0b64b8e..240e3d9 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -206,6 +206,7 @@ extern KVMState *kvm_state; /* external API */ =20 bool kvm_has_free_slot(MachineState *ms); +int kvm_get_max_vm_phys_shift(MachineState *ms); bool kvm_has_sync_mmu(void); int kvm_has_vcpu_events(void); int kvm_has_robust_singlestep(void); --=20 2.5.5 From nobody Sat Apr 27 15:46:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529500482187366.3824988207682; Wed, 20 Jun 2018 06:14:42 -0700 (PDT) Received: from localhost ([::1]:49568 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fVcwY-0001OC-LD for importer@patchew.org; Wed, 20 Jun 2018 09:14:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51025) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fVcq9-0004Xs-2C for qemu-devel@nongnu.org; Wed, 20 Jun 2018 09:08:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fVcq4-0005jO-SY for qemu-devel@nongnu.org; Wed, 20 Jun 2018 09:08:01 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:38946 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fVcq1-0005gx-2H; Wed, 20 Jun 2018 09:07:53 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A9B78401EF0D; Wed, 20 Jun 2018 13:07:52 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-106.ams2.redhat.com [10.36.117.106]) by smtp.corp.redhat.com (Postfix) with ESMTP id 02D7E2026D6B; Wed, 20 Jun 2018 13:07:50 +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 Date: Wed, 20 Jun 2018 15:07:31 +0200 Message-Id: <1529500053-21704-5-git-send-email-eric.auger@redhat.com> In-Reply-To: <1529500053-21704-1-git-send-email-eric.auger@redhat.com> References: <1529500053-21704-1-git-send-email-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 20 Jun 2018 13:07:52 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 20 Jun 2018 13:07:52 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'eric.auger@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [RFC 4/6] hw/arm/virt: Add virt-3.0 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: wei@redhat.com, drjones@redhat.com, suzuki.poulose@arm.com, dgilbert@redhat.com, agraf@suse.de, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add virt-3.0 machine type. Signed-off-by: Eric Auger --- Due to the kernel dependency, virt 3.1 will be targetted instead. --- hw/arm/virt.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index f0a4fa0..dd92ab9 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1692,10 +1692,7 @@ static void machvirt_machine_init(void) } type_init(machvirt_machine_init); =20 -#define VIRT_COMPAT_2_12 \ - HW_COMPAT_2_12 - -static void virt_2_12_instance_init(Object *obj) +static void virt_3_0_instance_init(Object *obj) { VirtMachineState *vms =3D VIRT_MACHINE(obj); VirtMachineClass *vmc =3D VIRT_MACHINE_GET_CLASS(vms); @@ -1763,11 +1760,25 @@ static void virt_2_12_instance_init(Object *obj) vms->irqmap =3D a15irqmap; } =20 +static void virt_machine_3_0_options(MachineClass *mc) +{ +} +DEFINE_VIRT_MACHINE_AS_LATEST(3, 0) + +#define VIRT_COMPAT_2_12 \ + HW_COMPAT_2_12 + +static void virt_2_12_instance_init(Object *obj) +{ + virt_3_0_instance_init(obj); +} + static void virt_machine_2_12_options(MachineClass *mc) { + virt_machine_3_0_options(mc); SET_MACHINE_COMPAT(mc, VIRT_COMPAT_2_12); } -DEFINE_VIRT_MACHINE_AS_LATEST(2, 12) +DEFINE_VIRT_MACHINE(2, 12) =20 #define VIRT_COMPAT_2_11 \ HW_COMPAT_2_11 --=20 2.5.5 From nobody Sat Apr 27 15:46:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529500493489565.9464389292597; Wed, 20 Jun 2018 06:14:53 -0700 (PDT) Received: from localhost ([::1]:49571 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fVcwj-0001YI-4m for importer@patchew.org; Wed, 20 Jun 2018 09:14:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51045) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fVcqA-0004Yt-4A for qemu-devel@nongnu.org; Wed, 20 Jun 2018 09:08:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fVcq9-0005ky-5W for qemu-devel@nongnu.org; Wed, 20 Jun 2018 09:08:02 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:53758 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fVcq2-0005i9-VY; Wed, 20 Jun 2018 09:07:55 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 96C0E4023826; Wed, 20 Jun 2018 13:07:54 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-106.ams2.redhat.com [10.36.117.106]) by smtp.corp.redhat.com (Postfix) with ESMTP id E40B02026D6B; Wed, 20 Jun 2018 13:07:52 +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 Date: Wed, 20 Jun 2018 15:07:32 +0200 Message-Id: <1529500053-21704-6-git-send-email-eric.auger@redhat.com> In-Reply-To: <1529500053-21704-1-git-send-email-eric.auger@redhat.com> References: <1529500053-21704-1-git-send-email-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 20 Jun 2018 13:07:54 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 20 Jun 2018 13:07:54 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'eric.auger@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [RFC 5/6] hw/arm/virt: support kvm_type property X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: wei@redhat.com, drjones@redhat.com, suzuki.poulose@arm.com, dgilbert@redhat.com, agraf@suse.de, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The kvm-type property currently is used to pass a user parameter to KVM_CREATE_VM. This matches the way KVM/ARM expects to pass the max_vm_phys_shift parameter. This patch adds the support or the kvm-type property in machvirt and also implements the machine class kvm_type() callback so that it either returns the kvm-type value provided by the user or returns the max_vm_phys_shift exposed by KVM. for instance, the usespace can use the following option to instantiate a 42b IPA guest: -machine kvm-type=3D42 Signed-off-by: Eric Auger --- hw/arm/virt.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ include/hw/arm/virt.h | 1 + 2 files changed, 45 insertions(+) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index dd92ab9..1700556 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1585,6 +1585,21 @@ static void virt_set_iommu(Object *obj, const char *= value, Error **errp) } } =20 +static char *virt_get_kvm_type(Object *obj, Error **errp) +{ + VirtMachineState *vms =3D VIRT_MACHINE(obj); + + return g_strdup(vms->kvm_type); +} + +static void virt_set_kvm_type(Object *obj, const char *value, Error **errp) +{ + VirtMachineState *vms =3D VIRT_MACHINE(obj); + + g_free(vms->kvm_type); + vms->kvm_type =3D g_strdup(value); +} + static CpuInstanceProperties virt_cpu_index_to_props(MachineState *ms, unsigned cpu_index) { @@ -1646,6 +1661,31 @@ static HotplugHandler *virt_machine_get_hotplug_hand= ler(MachineState *machine, return NULL; } =20 +static int virt_kvm_type(MachineState *ms, const char *type_str) +{ + int max_vm_phys_shift, ret =3D 0; + uint64_t type; + + if (!type_str) { + max_vm_phys_shift =3D kvm_get_max_vm_phys_shift(ms); + if (max_vm_phys_shift < 0) { + goto out; + } + } else { + type =3D g_ascii_strtoll(type_str, NULL, 0); + type &=3D 0xFF; + max_vm_phys_shift =3D (int)type; + if (max_vm_phys_shift < 40 || max_vm_phys_shift > 52) { + warn_report("valid kvm-type type values are within [40, 52]:" + " option is ignored and VM is created with 40b IPA= "); + goto out; + } + } + ret =3D max_vm_phys_shift; +out: + return ret; +} + static void virt_machine_class_init(ObjectClass *oc, void *data) { MachineClass *mc =3D MACHINE_CLASS(oc); @@ -1668,6 +1708,7 @@ static void virt_machine_class_init(ObjectClass *oc, = void *data) mc->cpu_index_to_instance_props =3D virt_cpu_index_to_props; mc->default_cpu_type =3D ARM_CPU_TYPE_NAME("cortex-a15"); mc->get_default_cpu_node_id =3D virt_get_default_cpu_node_id; + mc->kvm_type =3D virt_kvm_type; assert(!mc->get_hotplug_handler); mc->get_hotplug_handler =3D virt_machine_get_hotplug_handler; hc->plug =3D virt_machine_device_plug_cb; @@ -1756,6 +1797,9 @@ static void virt_3_0_instance_init(Object *obj) "Valid values are none and smmuv3", NULL); =20 + object_property_add_str(obj, "kvm-type", + virt_get_kvm_type, virt_set_kvm_type, NULL); + vms->memmap =3D a15memmap; vms->irqmap =3D a15irqmap; } diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index 4ac7ef6..2674ce7 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -118,6 +118,7 @@ typedef struct { uint32_t msi_phandle; uint32_t iommu_phandle; int psci_conduit; + char *kvm_type; } VirtMachineState; =20 #define TYPE_VIRT_MACHINE MACHINE_TYPE_NAME("virt") --=20 2.5.5 From nobody Sat Apr 27 15:46:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529501053519569.9624237986078; Wed, 20 Jun 2018 06:24:13 -0700 (PDT) Received: from localhost ([::1]:49637 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fVd5k-0001sP-Oz for importer@patchew.org; Wed, 20 Jun 2018 09:24:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51068) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fVcqB-0004aH-7Y for qemu-devel@nongnu.org; Wed, 20 Jun 2018 09:08:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fVcqA-0005lM-9a for qemu-devel@nongnu.org; Wed, 20 Jun 2018 09:08:03 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:53768 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fVcq4-0005jB-VK; Wed, 20 Jun 2018 09:07:57 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 90C074023827; Wed, 20 Jun 2018 13:07:56 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-106.ams2.redhat.com [10.36.117.106]) by smtp.corp.redhat.com (Postfix) with ESMTP id D0C812026D6B; Wed, 20 Jun 2018 13:07:54 +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 Date: Wed, 20 Jun 2018 15:07:33 +0200 Message-Id: <1529500053-21704-7-git-send-email-eric.auger@redhat.com> In-Reply-To: <1529500053-21704-1-git-send-email-eric.auger@redhat.com> References: <1529500053-21704-1-git-send-email-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 20 Jun 2018 13:07:56 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 20 Jun 2018 13:07:56 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'eric.auger@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [RFC 6/6] hw/arm/virt: handle max_vm_phys_shift conflicts on migration X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: wei@redhat.com, drjones@redhat.com, suzuki.poulose@arm.com, dgilbert@redhat.com, agraf@suse.de, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" When migrating a VM, we must make sure the destination host supports as many IPA bits as the source. Otherwise the migration must fail. We add a VMState infrastructure to machvirt. On pre_save(), the current source max_vm_phys_shift is saved. On destination, we cannot use this information when creating the VM. The VM is created using the max value reported by the destination host - or the kvm_type inherited value -. However on post_load() we can check that this value is compatible with the source saved value. Signed-off-by: Eric Auger --- hw/arm/virt.c | 37 +++++++++++++++++++++++++++++++++++++ include/hw/arm/virt.h | 2 ++ 2 files changed, 39 insertions(+) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 1700556..667f754 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1258,6 +1258,40 @@ static uint64_t virt_cpu_mp_affinity(VirtMachineStat= e *vms, int idx) return arm_cpu_mp_affinity(idx, clustersz); } =20 +static int virt_post_load(void *opaque, int version_id) +{ + VirtMachineState *vms =3D (VirtMachineState *)opaque; + + if (vms->max_vm_phys_shift < vms->source_max_vm_phys_shift) { + error_report("This host kernel only supports %d IPA bits whereas " + "the guest requires %d GPA bits", vms->max_vm_phys_sh= ift, + vms->source_max_vm_phys_shift); + return -1; + } + return 0; +} + +static int virt_pre_save(void *opaque) +{ + VirtMachineState *vms =3D (VirtMachineState *)opaque; + + vms->source_max_vm_phys_shift =3D vms->max_vm_phys_shift; + return 0; +} + +static const VMStateDescription vmstate_virt =3D { + .name =3D "virt", + .version_id =3D 1, + .minimum_version_id =3D 1, + .post_load =3D virt_post_load, + .pre_save =3D virt_pre_save, + .fields =3D (VMStateField[]) { + VMSTATE_INT32(source_max_vm_phys_shift, VirtMachineState), + VMSTATE_END_OF_LIST() + }, +}; + + static void machvirt_init(MachineState *machine) { VirtMachineState *vms =3D VIRT_MACHINE(machine); @@ -1473,6 +1507,7 @@ static void machvirt_init(MachineState *machine) =20 vms->machine_done.notify =3D virt_machine_done; qemu_add_machine_init_done_notifier(&vms->machine_done); + vmstate_register(NULL, 0, &vmstate_virt, vms); } =20 static bool virt_get_secure(Object *obj, Error **errp) @@ -1663,6 +1698,7 @@ static HotplugHandler *virt_machine_get_hotplug_handl= er(MachineState *machine, =20 static int virt_kvm_type(MachineState *ms, const char *type_str) { + VirtMachineState *vms =3D VIRT_MACHINE(ms); int max_vm_phys_shift, ret =3D 0; uint64_t type; =20 @@ -1683,6 +1719,7 @@ static int virt_kvm_type(MachineState *ms, const char= *type_str) } ret =3D max_vm_phys_shift; out: + vms->max_vm_phys_shift =3D (max_vm_phys_shift > 0) ? ret : 40; return ret; } =20 diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index 2674ce7..600d96d 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -119,6 +119,8 @@ typedef struct { uint32_t iommu_phandle; int psci_conduit; char *kvm_type; + int32_t max_vm_phys_shift; + int32_t source_max_vm_phys_shift; } VirtMachineState; =20 #define TYPE_VIRT_MACHINE MACHINE_TYPE_NAME("virt") --=20 2.5.5