Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3288163pxb; Mon, 1 Mar 2021 06:29:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJx4yBVwrt3hVX31qtxkLFTkZGD7+kdjikxmAVlv3nxu8v0MgBpgo7QopzLbI/OqwfTMxO2Y X-Received: by 2002:a17:907:1b02:: with SMTP id mp2mr16544398ejc.419.1614608992341; Mon, 01 Mar 2021 06:29:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614608992; cv=none; d=google.com; s=arc-20160816; b=KkxaS6VdffysaOCnenI9jPdPlNEtTzCJuigKkpG+9SUreerg3ebzLiicAskvXg6FZO 4HpqxlNW4BbGiNa9aEWu76tCHxh93i+1NGfU90lcG+mu2OKUp3mJ1mPcvxtrFcg+3U8j unBAq8r2lyx/C6VDyePxnlLPJd1EoZfJNPuR1ygEQcnnSPItFj5UTFn9/oDW7WhlDA44 p/JkHqBJ9CfFubJNe1El+rkecKcHUVjT2YVGcHAWimehLtZ1aYZTQgTU87rbkhnZWZBL rgkgh2dN9QkhsJIG/qIFRHvMCpl7Ar0Ayq4zQS2mDTFj9XIgvgpJZkFl7vHIsd8+6DvN cc/Q== 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:cc:to:from; bh=5Jwbig8/9UO3PKeLmSvauGT/TJJ17Za5BvFo4pZlakc=; b=ewhiP0XyOw6Apul7q1qJ/Z0WwLSuP+6fK7UNtNFR93PmOGFkR2TkRFrI3lCUjQSEmd 1e566Ca/LBCyK41Zwy4Un+QuWCjADCfa4r9BV4YrsL531slPVaQ8AQPJsp1i9jR8nySw BW3L0cSw7lYbtraZcA55j5idmYvC5505eY0/aq1LzSmpUvbfkMooEVILnM4nG/9qsgzo W5zYXL60K623o9HbTRelOce2V8/yw8L8jUrGZjbrSs07jVZ8gn2vckt7hGAnU771X5PP Kz3d6/YrliuNUbyihQFWm03eGq2RQE+xwgqGRes+zWM2A/tFWQe4ndwi6kvZBRtrZwcp XBNw== 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 ke20si7678103ejc.305.2021.03.01.06.29.23; Mon, 01 Mar 2021 06:29:52 -0800 (PST) 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 S236087AbhCAOZc (ORCPT + 99 others); Mon, 1 Mar 2021 09:25:32 -0500 Received: from foss.arm.com ([217.140.110.172]:59026 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233284AbhCAOYb (ORCPT ); Mon, 1 Mar 2021 09:24:31 -0500 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 4728F11D4; Mon, 1 Mar 2021 06:23:45 -0800 (PST) Received: from e112269-lin.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 84B143F70D; Mon, 1 Mar 2021 06:23:42 -0800 (PST) From: Steven Price To: Catalin Marinas , Marc Zyngier , Will Deacon Cc: Steven Price , James Morse , Julien Thierry , Suzuki K Poulose , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Dave Martin , Mark Rutland , Thomas Gleixner , qemu-devel@nongnu.org, Juan Quintela , "Dr. David Alan Gilbert" , Richard Henderson , Peter Maydell , Haibo Xu , Andrew Jones Subject: [PATCH v9 4/6] arm64: kvm: Expose KVM_ARM_CAP_MTE Date: Mon, 1 Mar 2021 14:23:13 +0000 Message-Id: <20210301142315.30920-5-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210301142315.30920-1-steven.price@arm.com> References: <20210301142315.30920-1-steven.price@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It's now safe for the VMM to enable MTE in a guest, so expose the capability to user space. Signed-off-by: Steven Price --- arch/arm64/kvm/arm.c | 9 +++++++++ arch/arm64/kvm/sys_regs.c | 3 +++ 2 files changed, 12 insertions(+) diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index fc4c95dd2d26..46bf319f6cb7 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -93,6 +93,12 @@ int kvm_vm_ioctl_enable_cap(struct kvm *kvm, r = 0; kvm->arch.return_nisv_io_abort_to_user = true; break; + case KVM_CAP_ARM_MTE: + if (!system_supports_mte() || kvm->created_vcpus) + return -EINVAL; + r = 0; + kvm->arch.mte_enabled = true; + break; default: r = -EINVAL; break; @@ -234,6 +240,9 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext) */ r = 1; break; + case KVM_CAP_ARM_MTE: + r = system_supports_mte(); + break; case KVM_CAP_STEAL_TIME: r = kvm_arm_pvtime_supported(); break; diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index 17cb6256f205..5793499334e3 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -1304,6 +1304,9 @@ static bool access_ccsidr(struct kvm_vcpu *vcpu, struct sys_reg_params *p, static unsigned int mte_visibility(const struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd) { + if (kvm_has_mte(vcpu->kvm)) + return 0; + return REG_HIDDEN; } -- 2.20.1