Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp555180pxb; Wed, 25 Aug 2021 09:20:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxRTIQEt00C65h4GEzrHCn9zmp8rdRV07KaoATTBFztCbL1UM5VRx5gQOKHkZSbPusOnELf X-Received: by 2002:aa7:ccc1:: with SMTP id y1mr49095093edt.321.1629908408266; Wed, 25 Aug 2021 09:20:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629908408; cv=none; d=google.com; s=arc-20160816; b=SRLji4i1J4yUgKSZK/DZ+IH/aPbnQi1xrPCyPXfzQmkFLuqJOHs+FQ1OBDx2w7wiF8 eV4NkIR93c6ogQBeEBUAcO8BRLgk3fKayrv6cEiHxwqoEaYv6LRfRiHFGsOpmJLmTZ49 6PIDb2Qeg2ewxYD4iApc5GawzmPBe80BegXy4HFhZ0dYKVcz0Xo83xLzr4iL3TVNrm01 4qAfN6pRqFfLI3eygPro5uPXVhdGVoK8J2ZeWt227N9WK+uKHmjYVskQo8j1H/AGRqFx dWRfp8KdtbWy+/RpJBLHgSpCeVbVrQJYEg+0Jcy8tyiOBamS8E8eiDTFr/Z6lEKq5oId q9tQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from; bh=f+AyYJpdxgOCbuIs/zZa+bDujiUjkgy5zoldJ183dgQ=; b=G3Vad7CkEDdx8xl5HYHUPNW5jznYHuq5c7RrjuiPtuLgI/GhAEYmv3SDM+6TOJDIyR E1p2mhJKKZ2Boxtl9KwBCSmauaHB7a7+gtih+3854X8aUqlrls57GhG+R12kelu+xPhI D6m3hoaq8xmlV6F7mU3RdX0TQ+N0aWf5vV8UtWiorZjMacwh1k5jWGeme8WgJBuTWoU6 7yArIY1s5kb7h51NgzICoQfhBT8VMbRtxTn41Ufqw2mG8ggUAeZZNDWAupNKsqmDu3k+ 3BKBBFJhaKtlH0gbJ5vGg1NRpfBsLvZxmeywmff3e9zE76sRUieWAJdhHT59nuHoSVvS krTw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s18si240674eji.59.2021.08.25.09.19.42; Wed, 25 Aug 2021 09:20:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237259AbhHYQSf (ORCPT + 99 others); Wed, 25 Aug 2021 12:18:35 -0400 Received: from foss.arm.com ([217.140.110.172]:54760 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240875AbhHYQSV (ORCPT ); Wed, 25 Aug 2021 12:18:21 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A0E5513A1; Wed, 25 Aug 2021 09:17:34 -0700 (PDT) Received: from monolith.cable.virginm.net (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 525B03F66F; Wed, 25 Aug 2021 09:17:33 -0700 (PDT) From: Alexandru Elisei To: maz@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, will@kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH v4 14/39] KVM: arm64: Add SPE capability and VCPU feature Date: Wed, 25 Aug 2021 17:17:50 +0100 Message-Id: <20210825161815.266051-15-alexandru.elisei@arm.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210825161815.266051-1-alexandru.elisei@arm.com> References: <20210825161815.266051-1-alexandru.elisei@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add the KVM_CAP_ARM_SPE capability which allows userspace to discover if SPE emulation is available. Add the KVM_ARM_VCPU_SPE feature which enables the emulation for a VCPU. Both are disabled for now. Signed-off-by: Alexandru Elisei --- Documentation/virt/kvm/api.rst | 9 +++++++++ arch/arm64/include/uapi/asm/kvm.h | 1 + arch/arm64/kvm/arm.c | 3 +++ include/uapi/linux/kvm.h | 1 + 4 files changed, 14 insertions(+) diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst index 994faa24690a..68fada258b80 100644 --- a/Documentation/virt/kvm/api.rst +++ b/Documentation/virt/kvm/api.rst @@ -7315,3 +7315,12 @@ The argument to KVM_ENABLE_CAP is also a bitmask, and must be a subset of the result of KVM_CHECK_EXTENSION. KVM will forward to userspace the hypercalls whose corresponding bit is in the argument, and return ENOSYS for the others. + +8.35 KVM_CAP_ARM_SPE +-------------------- + +:Architectures: arm64 + +This capability indicates that Statistical Profiling Extension (SPE) emulation +is available in KVM. SPE emulation is enabled for each VCPU which has the +feature bit KVM_ARM_VCPU_SPE set. diff --git a/arch/arm64/include/uapi/asm/kvm.h b/arch/arm64/include/uapi/asm/kvm.h index b3edde68bc3e..9f0a8ea50ea9 100644 --- a/arch/arm64/include/uapi/asm/kvm.h +++ b/arch/arm64/include/uapi/asm/kvm.h @@ -106,6 +106,7 @@ struct kvm_regs { #define KVM_ARM_VCPU_SVE 4 /* enable SVE for this CPU */ #define KVM_ARM_VCPU_PTRAUTH_ADDRESS 5 /* VCPU uses address authentication */ #define KVM_ARM_VCPU_PTRAUTH_GENERIC 6 /* VCPU uses generic authentication */ +#define KVM_ARM_VCPU_SPE 7 /* enable SPE for this CPU */ struct kvm_vcpu_init { __u32 target; diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index e8a7c0c3a086..22544eb367f3 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -304,6 +304,9 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext) case KVM_CAP_ARM_VCPU_SUPPORTED_CPUS: r = 1; break; + case KVM_CAP_ARM_SPE: + r = 0; + break; default: r = 0; } diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h index e5acc925c528..930ef91f7916 100644 --- a/include/uapi/linux/kvm.h +++ b/include/uapi/linux/kvm.h @@ -1114,6 +1114,7 @@ struct kvm_ppc_resize_hpt { #define KVM_CAP_ARM_MTE 205 #define KVM_CAP_ARM_LOCK_USER_MEMORY_REGION 206 #define KVM_CAP_ARM_VCPU_SUPPORTED_CPUS 207 +#define KVM_CAP_ARM_SPE 208 #ifdef KVM_CAP_IRQ_ROUTING -- 2.33.0