From patchwork Fri Apr 9 15:21:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Elisei X-Patchwork-Id: 12194347 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51C85C433ED for ; Fri, 9 Apr 2021 15:23:20 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F01E2610D1 for ; Fri, 9 Apr 2021 15:23:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F01E2610D1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=wMSP98kLx8NeoqEEsjZACuw/9jvxJBGa6jknSrQNpuA=; b=TJnSBE3Yyi0/nW+IcXTYrl4ox Btv3Qizwg4UAvDtqq+HYinyMo8+DeVmsKux0csUlzxMWL002oMduMIgPF9DwWpZ7UIICyEkXUTDBT k+oHuHK9lcXBIWD/aa//wjaqtPcB+u4PA4djczO0BpJ7Hsowgqn/+J5aODNgmrSkS6un+nLlpoXRP 2pkejLZj2HRpcN7kMRsRvcKv0oMTesV3NRoU9N573ZjUmUBrqkrdsNCxo2axfPSCs71u7D8AT31rs q/6koITFXpQHnKko52ZKRfjxy45YtpEvPnqS5YF3l4jo6HwBcicxvc2GwrEtsZM2kB6NI/MrhDDbg gJBxay0hw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lUsxC-000zt1-Tx; Fri, 09 Apr 2021 15:21:51 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lUsx3-000zrn-Du for linux-arm-kernel@desiato.infradead.org; Fri, 09 Apr 2021 15:21:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=Yusik3V5u9UNcesN54fNzm9aN66/wAf0wbpp7HWZZL0=; b=1vWm4jJR4EOWc+m4AJHhQZj4oH SnYzGPzygmVctT8NQZbiMYtW/B3CgeMT50IDE1zZtmB1A/BW744TrusK173yAoV1plgIh77WFw7u/ +q8l9CS563OJUASA8AEv8Y7VTjVDVOg99bWNzTY2AxRbqhGTH0ginJajszRMjqQxbtzH/Ain9cIxX kqZ5d9RfdBI3VjE6B8EJsCIa1bd1xJyr/RSduoXf3L06LpzVMCil/kyo4+VIZHqQrub89GIy81UoV GPo1plTCpNWKbrP5T5S9ZC5pynmBceXQnxt/dNEDPlAtCHZcsWm54SR+lSkBdUuqhHRR6+bJ6p1LE mSKXvVcQ==; Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lUsx0-004cIY-QK for linux-arm-kernel@lists.infradead.org; Fri, 09 Apr 2021 15:21:40 +0000 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 987BE11B3; Fri, 9 Apr 2021 08:21:33 -0700 (PDT) Received: from monolith.localdoman (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 80FB83F694; Fri, 9 Apr 2021 08:21:32 -0700 (PDT) From: Alexandru Elisei To: maz@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu Cc: james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com Subject: [PATCH 2/2] KVM: arm64: Don't advertise FEAT_SPE to guests Date: Fri, 9 Apr 2021 16:21:54 +0100 Message-Id: <20210409152154.198566-3-alexandru.elisei@arm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210409152154.198566-1-alexandru.elisei@arm.com> References: <20210409152154.198566-1-alexandru.elisei@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210409_082138_914842_63BF6390 X-CRM114-Status: GOOD ( 10.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Even though KVM sets up MDCR_EL2 to trap accesses to the SPE buffer and sampling control registers and to inject an undefined exception, the presence of FEAT_SPE is still advertised in the ID_AA64DFR0_EL1 register, if the hardware supports it. Getting an undefined exception when accessing a register usually happens for a hardware feature which is not implemented, and indeed this is how PMU emulation is handled when the virtual machine has been created without the KVM_ARM_VCPU_PMU_V3 feature. Let's be consistent and never advertise FEAT_SPE, because KVM doesn't have support for emulating it yet. Signed-off-by: Alexandru Elisei --- arch/arm64/kvm/sys_regs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index 402cd11aa4fc..61ee9bfb8826 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -1063,6 +1063,8 @@ static u64 read_id_reg(const struct kvm_vcpu *vcpu, val = cpuid_feature_cap_perfmon_field(val, ID_AA64DFR0_PMUVER_SHIFT, kvm_vcpu_has_pmu(vcpu) ? ID_AA64DFR0_PMUVER_8_4 : 0); + /* Hide SPE from guests */ + val &= ~FEATURE(ID_AA64DFR0_PMSVER); break; case SYS_ID_DFR0_EL1: /* Limit guests to PMUv3 for ARMv8.4 */