From nobody Wed Feb 5 11:54:11 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1737016595; cv=none; d=zohomail.com; s=zohoarc; b=GLCoqdJJ1VK/p2AAR5M/AkvL+jy2JFTfEsH2VMKcfzYr6iR8FpV+3HQLKCr84cldLPo/vzQwuIJ55ovpanwwafLKsAWEVhcH0c0/xN7NQ0tuo8U6RqNe5J2woiuSgOmjUGryWUlTu4nvVmi6PIbiVqqlw1nMxJTDmY9X1XoSDkg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1737016595; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=0PvPtVvY3c5O67Lq3WJ2VN61KYz0kKAN6ZEncEHPG/o=; b=nsRjdr6NT4az4cp7Ikz0wk0bWHImTsfucfcyzQMdIxhfkA3Rf8dlRxX58c7C9LyZnoumhy5XjsBke1xfgi+otQxvfjeeEWQ45RxThni3r36MGJp0p3fPVUhv1wbex4gv5Jdud1tPU/1qN2dpAFx7Wsgdo8ClHnE7/tBbtwWG8yU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1737016595325890.6497914979652; Thu, 16 Jan 2025 00:36:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tYLKF-0007RV-Sk; Thu, 16 Jan 2025 03:34:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tYLKD-0007Qk-WE for qemu-devel@nongnu.org; Thu, 16 Jan 2025 03:34:02 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tYLKC-0005UU-Cz for qemu-devel@nongnu.org; Thu, 16 Jan 2025 03:34:01 -0500 Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-441-DSUb5U3fP3y1q7PRARosXw-1; Thu, 16 Jan 2025 03:33:55 -0500 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 512F219560BB; Thu, 16 Jan 2025 08:33:54 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.39.193.32]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 48C9F30001BE; Thu, 16 Jan 2025 08:33:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1737016439; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0PvPtVvY3c5O67Lq3WJ2VN61KYz0kKAN6ZEncEHPG/o=; b=ToDpdmOV7NmoEa9/h5rxWVcAyiubtTKXUEvGY/TkxZJqiRrbcmbYjGHuJMTOZlTU6pLLoC aZ2LuLSCzTpUHFQjgA/iVZYaKTAQdoyszWlAckQxuOShuN4ScGTMzIBWOBNHox9jdw3psl J8eFgU1x79qhVRfG/FYU7enAcFJGiCs= X-MC-Unique: DSUb5U3fP3y1q7PRARosXw-1 X-Mimecast-MFC-AGG-ID: DSUb5U3fP3y1q7PRARosXw From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, miguel.luis@oracle.com, peter.maydell@linaro.org, richard.henderson@linaro.org, maz@kernel.org, gkulkarni@amperecomputing.com, gankulkarni@os.amperecomputing.com Subject: [RFC v4 1/5] linux-headers: update to nv-next (Jan 9) Date: Thu, 16 Jan 2025 09:32:14 +0100 Message-ID: <20250116083339.674344-2-eric.auger@redhat.com> In-Reply-To: <20250116083339.674344-1-eric.auger@redhat.com> References: <20250116083339.674344-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=eric.auger@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1737016597286019000 Content-Type: text/plain; charset="utf-8" This is a temporary linux header update against Marc's nv-next branch (from Jan 9). As this branch is continuously evolving I made a snapshot at https://github.com/eauger/linux/tree/nv_next_jan9_2025 Signed-off-by: Eric Auger --- linux-headers/asm-arm64/kvm.h | 1 + linux-headers/linux/kvm.h | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/linux-headers/asm-arm64/kvm.h b/linux-headers/asm-arm64/kvm.h index dccd5d965f..b81e7d81a1 100644 --- a/linux-headers/asm-arm64/kvm.h +++ b/linux-headers/asm-arm64/kvm.h @@ -397,6 +397,7 @@ enum { #define KVM_DEV_ARM_VGIC_GRP_CPU_SYSREGS 6 #define KVM_DEV_ARM_VGIC_GRP_LEVEL_INFO 7 #define KVM_DEV_ARM_VGIC_GRP_ITS_REGS 8 +#define KVM_DEV_ARM_VGIC_GRP_MAINT_IRQ 9 #define KVM_DEV_ARM_VGIC_LINE_LEVEL_INFO_SHIFT 10 #define KVM_DEV_ARM_VGIC_LINE_LEVEL_INFO_MASK \ (0x3fffffULL << KVM_DEV_ARM_VGIC_LINE_LEVEL_INFO_SHIFT) diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h index 3bcd4eabe3..1c8431ff43 100644 --- a/linux-headers/linux/kvm.h +++ b/linux-headers/linux/kvm.h @@ -178,6 +178,7 @@ struct kvm_xen_exit { #define KVM_EXIT_NOTIFY 37 #define KVM_EXIT_LOONGARCH_IOCSR 38 #define KVM_EXIT_MEMORY_FAULT 39 +#define KVM_EXIT_ARM_LDST64B 40 =20 /* For KVM_EXIT_INTERNAL_ERROR */ /* Emulate instruction failed. */ @@ -391,7 +392,7 @@ struct kvm_run { } eoi; /* KVM_EXIT_HYPERV */ struct kvm_hyperv_exit hyperv; - /* KVM_EXIT_ARM_NISV */ + /* KVM_EXIT_ARM_NISV / KVM_EXIT_ARM_LDST64B */ struct { __u64 esr_iss; __u64 fault_ipa; @@ -925,6 +926,7 @@ struct kvm_enable_cap { #define KVM_CAP_PRE_FAULT_MEMORY 236 #define KVM_CAP_X86_APIC_BUS_CYCLES_NS 237 #define KVM_CAP_X86_GUEST_MODE 238 +#define KVM_CAP_ARM_EL2 239 =20 struct kvm_irq_routing_irqchip { __u32 irqchip; --=20 2.47.1 From nobody Wed Feb 5 11:54:11 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1737016556; cv=none; d=zohomail.com; s=zohoarc; b=jNGrD5u/ObHvEnLMypzEnBt20ya+9ox/HWegHw8fIQiDhB9Y+omehnsKjGpaXm6R2Z62Qh8STqZp8ZxNZNJcH0pdr+F3gLgR2Sr6AMDI5BsezAfoxGEntQ4GqvcSf7kGjsDwJ5UR1IvgCN1DH8a2ph1Am96r9Pt/rB5BhIlzrb0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1737016556; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=qM//RAvAkFTsI/+a1Sl4PLdWlz637bvbmjvEBgHeszc=; b=VkQsbk7mGGif8uuEWcIVtQsLyylwPYX0Useh/rks0GedgJxt5bYKUZgFj/WNz6pzuBNBWfdp6HPjKqojw8+JGRB3dFjiReKkgqv/sAurYKi5UiWrBCkV0J4OyQHzU28E02zxcrBbbICI5/5o3PJaZsbQ6w4VYYMd/jgbfd0BqUE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1737016556375790.6883535052913; Thu, 16 Jan 2025 00:35:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tYLKN-0007SH-Rn; Thu, 16 Jan 2025 03:34:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tYLKM-0007S4-TA for qemu-devel@nongnu.org; Thu, 16 Jan 2025 03:34:10 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tYLKK-0005VI-3Q for qemu-devel@nongnu.org; Thu, 16 Jan 2025 03:34:10 -0500 Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-589-7c5rvkWzOxG43-VMp5TK2Q-1; Thu, 16 Jan 2025 03:34:02 -0500 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8D6041955DB8; Thu, 16 Jan 2025 08:34:00 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.39.193.32]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id CC34B30001BE; Thu, 16 Jan 2025 08:33:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1737016447; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qM//RAvAkFTsI/+a1Sl4PLdWlz637bvbmjvEBgHeszc=; b=bCZ+oIQQKQho/1gM+DVRdCGtsLUFnRtRP9cJZd/lrla7h6/DfwvLsE6/YEwF549g1sgP9m qE7qoOvIJ2SMolHHOtY0ixpFvp94Mf3ysSl4CPt7G3xf5HFWk19Q2V4OwZfIOKusvpr1EF E7cwnTkavx0bfsF2CJ3TS9d52wnGzWA= X-MC-Unique: 7c5rvkWzOxG43-VMp5TK2Q-1 X-Mimecast-MFC-AGG-ID: 7c5rvkWzOxG43-VMp5TK2Q From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, miguel.luis@oracle.com, peter.maydell@linaro.org, richard.henderson@linaro.org, maz@kernel.org, gkulkarni@amperecomputing.com, gankulkarni@os.amperecomputing.com Subject: [RFC v4 2/5] hw/arm: Allow setting KVM vGIC maintenance IRQ Date: Thu, 16 Jan 2025 09:32:15 +0100 Message-ID: <20250116083339.674344-3-eric.auger@redhat.com> In-Reply-To: <20250116083339.674344-1-eric.auger@redhat.com> References: <20250116083339.674344-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=eric.auger@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1737016557487019000 Content-Type: text/plain; charset="utf-8" From: Haibo Xu Allow virt arm machine to set the interrupt ID for the KVM GIC maintenance interrupt. This setting must be done before the KVM_DEV_ARM_VGIC_CTRL_INIT hence the choice to perform the setting in the GICv3 realize instead of proceeding the same way as kvm_arm_pmu_set_irq(). Signed-off-by: Haibo Xu Signed-off-by: Miguel Luis Signed-off-by: Eric Auger --- v3 -> v4: - only set maint_irq if vms->virt v2 -> v3: - tweak the commit message and explain why we do not proceed the same way as kvm_arm_pmu_set_irq (Peter) v1 -> v2: - [Miguel] replaced the has_virt_extensions by the maintenance irq intid property. [Eric] restored kvm_device_check_attr and kvm_device_access standard usage and conditionally call those if the prop is set. --- include/hw/intc/arm_gicv3_common.h | 1 + hw/arm/virt.c | 3 +++ hw/intc/arm_gicv3_common.c | 1 + hw/intc/arm_gicv3_kvm.c | 21 +++++++++++++++++++++ 4 files changed, 26 insertions(+) diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3= _common.h index a3d6a0e507..c18503869f 100644 --- a/include/hw/intc/arm_gicv3_common.h +++ b/include/hw/intc/arm_gicv3_common.h @@ -231,6 +231,7 @@ struct GICv3State { uint32_t num_cpu; uint32_t num_irq; uint32_t revision; + uint32_t maint_irq; bool lpi_enable; bool nmi_support; bool security_extn; diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 99e0a68b6c..55b0bb24ba 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -827,6 +827,9 @@ static void create_gic(VirtMachineState *vms, MemoryReg= ion *mem) OBJECT(mem), &error_fatal); qdev_prop_set_bit(vms->gic, "has-lpi", true); } + } else if (vms->virt) { + qdev_prop_set_uint32(vms->gic, "maintenance-interrupt-id", + ARCH_GIC_MAINT_IRQ); } } else { if (!kvm_irqchip_in_kernel()) { diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c index 76b2283c92..2ed50d7d07 100644 --- a/hw/intc/arm_gicv3_common.c +++ b/hw/intc/arm_gicv3_common.c @@ -612,6 +612,7 @@ static const Property arm_gicv3_common_properties[] =3D= { DEFINE_PROP_BOOL("has-lpi", GICv3State, lpi_enable, 0), DEFINE_PROP_BOOL("has-nmi", GICv3State, nmi_support, 0), DEFINE_PROP_BOOL("has-security-extensions", GICv3State, security_extn,= 0), + DEFINE_PROP_UINT32("maintenance-interrupt-id", GICv3State, maint_irq, = 0), /* * Compatibility property: force 8 bits of physical priority, even * if the CPU being emulated should have fewer. diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c index 8e17cab2a0..7248055a02 100644 --- a/hw/intc/arm_gicv3_kvm.c +++ b/hw/intc/arm_gicv3_kvm.c @@ -22,6 +22,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "hw/intc/arm_gicv3_common.h" +#include "hw/arm/virt.h" #include "qemu/error-report.h" #include "qemu/module.h" #include "system/kvm.h" @@ -825,6 +826,26 @@ static void kvm_arm_gicv3_realize(DeviceState *dev, Er= ror **errp) return; } =20 + if (s->maint_irq) { + int ret; + + ret =3D kvm_device_check_attr(s->dev_fd, + KVM_DEV_ARM_VGIC_GRP_MAINT_IRQ, 0); + if (!ret) { + error_setg_errno(errp, errno, + "VGICv3 setting maintenance IRQ is not " + "supported by this host kernel"); + return; + } + + ret =3D kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_MAINT_IR= Q, 0, + &s->maint_irq, true, errp); + if (ret) { + error_setg_errno(errp, errno, "Failed to set VGIC maintenance = IRQ"); + return; + } + } + multiple_redist_region_allowed =3D kvm_device_check_attr(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, KVM_VGIC_V3_ADDR_TYPE_REDIST_REGION); --=20 2.47.1 From nobody Wed Feb 5 11:54:11 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1737016598; cv=none; d=zohomail.com; s=zohoarc; b=gpWr6wN4sz0GwlZ6seX9aYTgNvzjqWEQkrOMdQxBIwSBfdKI2dFnOoSUd84PeDLITUsMwc8sdWW4Vu5z/RESMoxYSi/Ov87rylmmZHczSkVc7rVDkI8BYvyi/sZYfPewXa/Rns3rSrll++v+By/W1nBC7fo6mFBh05gjcOItpkU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1737016598; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=n27dYMHHYP8KJ5aV5O/00ZCPe/fSvvQCNytTtLkRnag=; b=XUGlU6hziUw8lgV/B8dPzlOvZimtq4DctVau/PscYITWpexISMw3+5jY9cRt3xq4yBW5oRSABLveqFa9CywiQaUFUzNRb3GE8aYFrQZHY49MgH4BbMNbMn92b4XMjDqqBxfouPczkHrKaGJ8+g80uGDsnx9E5ExMG9/AcDgfCpA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17370165985854.115491164110836; Thu, 16 Jan 2025 00:36:38 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tYLKR-0007Td-1T; Thu, 16 Jan 2025 03:34:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tYLKO-0007Sq-Q8 for qemu-devel@nongnu.org; Thu, 16 Jan 2025 03:34:12 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tYLKN-0005Vt-EL for qemu-devel@nongnu.org; Thu, 16 Jan 2025 03:34:12 -0500 Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-204-p_iHrRzGMB6lzzfE1UPaIA-1; Thu, 16 Jan 2025 03:34:06 -0500 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 79B0B1955DCD; Thu, 16 Jan 2025 08:34:04 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.39.193.32]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 14CC030001BE; Thu, 16 Jan 2025 08:34:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1737016450; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=n27dYMHHYP8KJ5aV5O/00ZCPe/fSvvQCNytTtLkRnag=; b=KQHUrW4sjNyLacbsbbd/V6cHGgRf2qi8Jk/7XDDUfxmwwtiRgD8GuyR/C3zYraL7uRBRJR 0OcFTLGVIRlRAVF6UEsdQCtji0BpOzT6hlQvRqqgWKwKidqvO5/Dfmcib/0CHDRTvTnAPz qkHxnL1JL8jneA+femBcCzt7uqqEvhM= X-MC-Unique: p_iHrRzGMB6lzzfE1UPaIA-1 X-Mimecast-MFC-AGG-ID: p_iHrRzGMB6lzzfE1UPaIA From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, miguel.luis@oracle.com, peter.maydell@linaro.org, richard.henderson@linaro.org, maz@kernel.org, gkulkarni@amperecomputing.com, gankulkarni@os.amperecomputing.com Subject: [RFC v4 3/5] target/arm/kvm: Add helper to detect EL2 when using KVM Date: Thu, 16 Jan 2025 09:32:16 +0100 Message-ID: <20250116083339.674344-4-eric.auger@redhat.com> In-Reply-To: <20250116083339.674344-1-eric.auger@redhat.com> References: <20250116083339.674344-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=eric.auger@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -39 X-Spam_score: -4.0 X-Spam_bar: ---- X-Spam_report: (-4.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1.793, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1737016599264019000 From: Haibo Xu Introduce query support for KVM_CAP_ARM_EL2. Signed-off-by: Haibo Xu Signed-off-by: Miguel Luis Signed-off-by: Eric Auger Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/arm/kvm_arm.h | 12 ++++++++++++ target/arm/kvm.c | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h index 05c3de8cd4..8c1314da20 100644 --- a/target/arm/kvm_arm.h +++ b/target/arm/kvm_arm.h @@ -193,6 +193,13 @@ bool kvm_arm_sve_supported(void); */ bool kvm_arm_mte_supported(void); =20 +/** + * kvm_arm_el2_supported: + * + * Returns true if KVM can enable EL2 and false otherwise. + */ +bool kvm_arm_el2_supported(void); + /** * kvm_arm_get_max_vm_ipa_size: * @ms: Machine state handle @@ -247,6 +254,11 @@ static inline bool kvm_arm_mte_supported(void) return false; } =20 +static inline bool kvm_arm_el2_supported(void) +{ + return false; +} + /* * These functions should never actually be called without KVM support. */ diff --git a/target/arm/kvm.c b/target/arm/kvm.c index a9444a2c7a..43362164eb 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -1797,6 +1797,11 @@ bool kvm_arm_aarch32_supported(void) return kvm_check_extension(kvm_state, KVM_CAP_ARM_EL1_32BIT); } =20 +bool kvm_arm_el2_supported(void) +{ + return kvm_check_extension(kvm_state, KVM_CAP_ARM_EL2); +} + bool kvm_arm_sve_supported(void) { return kvm_check_extension(kvm_state, KVM_CAP_ARM_SVE); --=20 2.47.1 From nobody Wed Feb 5 11:54:11 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1737016568; cv=none; d=zohomail.com; s=zohoarc; b=lyYVtuQ1Q14/nJ4KjLWNCgnn9VrYvz5hiMIWCIq7H5/iaHkIEkE/EQagt3ptjCIOb5iYcq8S0G7GUyAAXSB9f3TmtQ1mjyaeejPLxpp/9k0XzrglK3rcNGCu/v31SulKRW6GIwzfCglkXAPwT446YVhY9U4hRNrLTXkWd1cUyWc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1737016568; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=bQI9yKVxWku1ZRu/VTAI0cqtwe5o+lSPdTj7dhFj0W4=; b=oFARz7kD7yKbOMafcTusgGNS5K+9zOgZf4MYGDZBTzRsUdBJ6keKbSkfzHknuu4JIJgI3wAvvOvUZmzUDRvNnsJTa+9wNmsRLDvey3YMSZePrqWMl6NOJWsTVXnB6cQ7LgUqtHkIFrgHwlINdC1NWvRxAJD06vJQ1rMcCelGplQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1737016568230464.3405051620423; Thu, 16 Jan 2025 00:36:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tYLKV-0007UO-Lr; Thu, 16 Jan 2025 03:34:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tYLKS-0007Tu-Sb for qemu-devel@nongnu.org; Thu, 16 Jan 2025 03:34:16 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tYLKR-0005We-1S for qemu-devel@nongnu.org; Thu, 16 Jan 2025 03:34:16 -0500 Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-523-sGn6A7bfOgOgoyfrIkOKJQ-1; Thu, 16 Jan 2025 03:34:10 -0500 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5D7591955DDF; Thu, 16 Jan 2025 08:34:09 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.39.193.32]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id F3FCF30001BE; Thu, 16 Jan 2025 08:34:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1737016454; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bQI9yKVxWku1ZRu/VTAI0cqtwe5o+lSPdTj7dhFj0W4=; b=Z5LL0Ppyi0iL/2btFa0M/c5/GoH8c9uqPW6kGSYsEdIQoQSpOJnYRc4j2L/HKtTD0SDMxv NPXT/i1C6swwPkSestujv/AH/1bFfhb5s1qJANhF1XSC1ZzBYVesnAsr926b4//BT24ebr zV1Zr9vtar9PCl+cm59PQeYJ+VIkaiU= X-MC-Unique: sGn6A7bfOgOgoyfrIkOKJQ-1 X-Mimecast-MFC-AGG-ID: sGn6A7bfOgOgoyfrIkOKJQ From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, miguel.luis@oracle.com, peter.maydell@linaro.org, richard.henderson@linaro.org, maz@kernel.org, gkulkarni@amperecomputing.com, gankulkarni@os.amperecomputing.com Subject: [RFC v4 4/5] target/arm: Enable feature ARM_FEATURE_EL2 if EL2 is supported Date: Thu, 16 Jan 2025 09:32:17 +0100 Message-ID: <20250116083339.674344-5-eric.auger@redhat.com> In-Reply-To: <20250116083339.674344-1-eric.auger@redhat.com> References: <20250116083339.674344-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=eric.auger@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1737016569836019000 Content-Type: text/plain; charset="utf-8" From: Haibo Xu KVM_CAP_ARM_EL2 must be supported by the cpu to enable ARM_FEATURE_EL2. In case the host does support NV, expose the feature. Signed-off-by: Haibo Xu Signed-off-by: Miguel Luis Signed-off-by: Eric Auger Reviewed-by: Richard Henderson --- v2 -> v3: - check pmu->has_el2 on kvm_arch_init_vcpu() when setting KVM_ARM_VCPU_HAS_EL2 feature (Peter) v1 -> v2: - remove isar_feature_aa64_aa32_el2 modif in target/arm/cpu.h [Richard] and use el2_supported in kvm_arch_init_vcpu --- target/arm/kvm.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/target/arm/kvm.c b/target/arm/kvm.c index 43362164eb..bfaf48824c 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -255,6 +255,7 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCPUFea= tures *ahcf) */ int fdarray[3]; bool sve_supported; + bool el2_supported; bool pmu_supported =3D false; uint64_t features =3D 0; int err; @@ -285,6 +286,14 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCPUFe= atures *ahcf) init.features[0] |=3D 1 << KVM_ARM_VCPU_SVE; } =20 + /* + * Ask for EL2 if supported. + */ + el2_supported =3D kvm_arm_el2_supported(); + if (el2_supported) { + init.features[0] |=3D 1 << KVM_ARM_VCPU_HAS_EL2; + } + /* * Ask for Pointer Authentication if supported, so that we get * the unsanitized field values for AA64ISAR1_EL1. @@ -468,6 +477,10 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCPUFe= atures *ahcf) features |=3D 1ULL << ARM_FEATURE_AARCH64; features |=3D 1ULL << ARM_FEATURE_GENERIC_TIMER; =20 + if (el2_supported) { + features |=3D 1ULL << ARM_FEATURE_EL2; + } + ahcf->features =3D features; =20 return true; @@ -1918,6 +1931,9 @@ int kvm_arch_init_vcpu(CPUState *cs) cpu->kvm_init_features[0] |=3D (1 << KVM_ARM_VCPU_PTRAUTH_ADDRESS | 1 << KVM_ARM_VCPU_PTRAUTH_GENERIC); } + if (cpu->has_el2 && kvm_arm_el2_supported()) { + cpu->kvm_init_features[0] |=3D 1 << KVM_ARM_VCPU_HAS_EL2; + } =20 /* Do KVM_ARM_VCPU_INIT ioctl */ ret =3D kvm_arm_vcpu_init(cpu); --=20 2.47.1 From nobody Wed Feb 5 11:54:11 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1737016524; cv=none; d=zohomail.com; s=zohoarc; b=JH2SJ3aMCxHLpY0UbNGs17axUa8VSFylu9DiTtbnZ3HNRQ05kyRQuYKgfEPKDffMFbNaIxkH+SEc6b7EzxDBQaRdHBPzpx0H/bZmDpt767UyqhGRAyV3ErTKiOa/BB3Hbg9nPKuqEBewiY+afTwMBwb+p/HbX2sJ6HF0RwmQ5BM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1737016524; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=cBvbNB7PNqpM2+SpADvQvkgIWYVFUD5w84r3hgu8Xg4=; b=AG0R4UzLCo6fUXvI7T04Lpzo7Xl41wxoCVv58L8+REHl/MYsdAKvQ/9CAlWTX+9q+ydDt9Ous/OZzsUpzYFoMrPuASQboaX/mXnexoWGe4Ztv/DsVtmB+vNq6+wFtwRmfXSw67IyDlpyo2IdQcMIwEVYGPzqhVa+tkHtNhFrBVA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1737016524569104.74964883596124; Thu, 16 Jan 2025 00:35:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tYLKe-0007Ye-SJ; Thu, 16 Jan 2025 03:34:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tYLKZ-0007V5-JY for qemu-devel@nongnu.org; Thu, 16 Jan 2025 03:34:23 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tYLKW-0005Y6-Si for qemu-devel@nongnu.org; Thu, 16 Jan 2025 03:34:22 -0500 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-312-TFZMyp-lNPykXe1pjYwXOw-1; Thu, 16 Jan 2025 03:34:16 -0500 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D28DD19560B0; Thu, 16 Jan 2025 08:34:14 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.39.193.32]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BB60D3003FD3; Thu, 16 Jan 2025 08:34:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1737016460; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cBvbNB7PNqpM2+SpADvQvkgIWYVFUD5w84r3hgu8Xg4=; b=M5VHFLmtv6v23Q+ZzsXF/AO26B728XxIf+/hUmpkWeNoGHSwIFVDaZfXY6yszy32SJa/yo jyz4WjWto88jzbea8B0gKLLLEJ1+eYT7n8uTOgu0B41BtM1N+xNl7KD9eWB8ETR3sYaB7a gGwHdtfNnC3mfWrFhvkmyg3kkhw2xUs= X-MC-Unique: TFZMyp-lNPykXe1pjYwXOw-1 X-Mimecast-MFC-AGG-ID: TFZMyp-lNPykXe1pjYwXOw From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, miguel.luis@oracle.com, peter.maydell@linaro.org, richard.henderson@linaro.org, maz@kernel.org, gkulkarni@amperecomputing.com, gankulkarni@os.amperecomputing.com Subject: [RFC v4 5/5] hw/arm/virt: Allow virt extensions with KVM Date: Thu, 16 Jan 2025 09:32:18 +0100 Message-ID: <20250116083339.674344-6-eric.auger@redhat.com> In-Reply-To: <20250116083339.674344-1-eric.auger@redhat.com> References: <20250116083339.674344-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=eric.auger@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -39 X-Spam_score: -4.0 X-Spam_bar: ---- X-Spam_report: (-4.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.141, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1.793, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1737016525204019000 Content-Type: text/plain; charset="utf-8" From: Haibo Xu Up to now virt support on guest has been only supported with TCG. Now it becomes feasible to use it with KVM acceleration. Also check only in-kernel GICv3 is used along with KVM EL2. Signed-off-by: Haibo Xu Signed-off-by: Miguel Luis Signed-off-by: Eric Auger Reviewed-by: Richard Henderson --- v2 -> v3: - check gic version/in-kernel implementation when kvm el2 is set (Peter) v1 -> v2: - fixed test ordering: virt && ((kvm && !kvm_el2) || hvf) [Richard] - tweeked the commit title & message --- hw/arm/virt.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 55b0bb24ba..fff25dd615 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -791,6 +791,13 @@ static void create_gic(VirtMachineState *vms, MemoryRe= gion *mem) default: g_assert_not_reached(); } + + if (kvm_enabled() && vms->virt && + (revision !=3D 3 || !kvm_irqchip_in_kernel())) { + error_report("KVM EL2 only is supported with in-kernel GICv3"); + exit(1); + } + vms->gic =3D qdev_new(gictype); qdev_prop_set_uint32(vms->gic, "revision", revision); qdev_prop_set_uint32(vms->gic, "num-cpu", smp_cpus); @@ -2210,7 +2217,8 @@ static void machvirt_init(MachineState *machine) exit(1); } =20 - if (vms->virt && (kvm_enabled() || hvf_enabled())) { + if (vms->virt && + ((kvm_enabled() && !kvm_arm_el2_supported()) || hvf_enabled())) { error_report("mach-virt: %s does not support providing " "Virtualization extensions to the guest CPU", current_accel_name()); --=20 2.47.1