From mboxrd@z Thu Jan 1 00:00:00 1970 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=-14.0 required=3.0 tests=BAYES_00,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 A68C1C2B9F4 for ; Tue, 22 Jun 2021 08:48:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7598161353 for ; Tue, 22 Jun 2021 08:48:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229833AbhFVIuw (ORCPT ); Tue, 22 Jun 2021 04:50:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:49300 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229746AbhFVIuv (ORCPT ); Tue, 22 Jun 2021 04:50:51 -0400 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BE9026108E; Tue, 22 Jun 2021 08:48:35 +0000 (UTC) Received: from sofa.misterjones.org ([185.219.108.64] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1lvc5B-0093Qj-TK; Tue, 22 Jun 2021 09:48:34 +0100 Date: Tue, 22 Jun 2021 09:48:33 +0100 Message-ID: <877dimcmji.wl-maz@kernel.org> From: Marc Zyngier To: Fuad Tabba Cc: Steven Price , Catalin Marinas , Will Deacon , "Dr. David Alan Gilbert" , qemu-devel@nongnu.org, Dave Martin , Juan Quintela , Richard Henderson , linux-kernel@vger.kernel.org, Thomas Gleixner , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v17 4/6] KVM: arm64: Expose KVM_ARM_CAP_MTE In-Reply-To: References: <20210621111716.37157-1-steven.price@arm.com> <20210621111716.37157-5-steven.price@arm.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: tabba@google.com, steven.price@arm.com, catalin.marinas@arm.com, will@kernel.org, dgilbert@redhat.com, qemu-devel@nongnu.org, Dave.Martin@arm.com, quintela@redhat.com, richard.henderson@linaro.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 22 Jun 2021 09:07:51 +0100, Fuad Tabba wrote: > > Hi, > > On Mon, Jun 21, 2021 at 12:18 PM Steven Price wrote: > > > > It's now safe for the VMM to enable MTE in a guest, so expose the > > capability to user space. > > > > Reviewed-by: Catalin Marinas > > Signed-off-by: Steven Price > > --- > > arch/arm64/kvm/arm.c | 9 +++++++++ > > arch/arm64/kvm/reset.c | 4 ++++ > > arch/arm64/kvm/sys_regs.c | 3 +++ > > 3 files changed, 16 insertions(+) > > > > diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c > > index e720148232a0..28ce26a68f09 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; > > @@ -237,6 +243,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/reset.c b/arch/arm64/kvm/reset.c > > index d37ebee085cf..9e6922b9503a 100644 > > --- a/arch/arm64/kvm/reset.c > > +++ b/arch/arm64/kvm/reset.c > > @@ -244,6 +244,10 @@ int kvm_reset_vcpu(struct kvm_vcpu *vcpu) > > switch (vcpu->arch.target) { > > default: > > if (test_bit(KVM_ARM_VCPU_EL1_32BIT, vcpu->arch.features)) { > > + if (vcpu->kvm->arch.mte_enabled) { > > + ret = -EINVAL; > > + goto out; > > + } > > pstate = VCPU_RESET_PSTATE_SVC; > > } else { > > pstate = VCPU_RESET_PSTATE_EL1; > > nit: I was wondering whether this check would be better suited in > kvm_vcpu_set_target, rather than here (kvm_reset_vcpu). kvm_reset_vcpu > is called by kvm_vcpu_set_target, but kvm_vcpu_set_target is where > checking for supported features happens. It might be better to group > all such checks together. I don't think that there is any risk of this > feature being toggled by the other call path to kvm_reset_vcpu (via > check_vcpu_requests). We already group the 32bit related compatibility checks in vcpu_allowed_register_width(), and this is where I think this should move to. I've provisionally added the change below. M. diff --git a/arch/arm64/kvm/reset.c b/arch/arm64/kvm/reset.c index 9e6922b9503a..cba7872d69a8 100644 --- a/arch/arm64/kvm/reset.c +++ b/arch/arm64/kvm/reset.c @@ -176,6 +176,10 @@ static bool vcpu_allowed_register_width(struct kvm_vcpu *vcpu) if (!cpus_have_const_cap(ARM64_HAS_32BIT_EL1) && is32bit) return false; + /* MTE is incompatible with AArch32 */ + if (kvm_has_mte(vcpu->kvm) && is32bit) + return false; + /* Check that the vcpus are either all 32bit or all 64bit */ kvm_for_each_vcpu(i, tmp, vcpu->kvm) { if (vcpu_has_feature(tmp, KVM_ARM_VCPU_EL1_32BIT) != is32bit) @@ -244,10 +248,6 @@ int kvm_reset_vcpu(struct kvm_vcpu *vcpu) switch (vcpu->arch.target) { default: if (test_bit(KVM_ARM_VCPU_EL1_32BIT, vcpu->arch.features)) { - if (vcpu->kvm->arch.mte_enabled) { - ret = -EINVAL; - goto out; - } pstate = VCPU_RESET_PSTATE_SVC; } else { pstate = VCPU_RESET_PSTATE_EL1; -- Without deviation from the norm, progress is not possible. From mboxrd@z Thu Jan 1 00:00:00 1970 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=-14.0 required=3.0 tests=BAYES_00,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 86E07C2B9F4 for ; Tue, 22 Jun 2021 08:50:18 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 1BC4361042 for ; Tue, 22 Jun 2021 08:50:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1BC4361042 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:52244 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lvc6r-0001Ie-9t for qemu-devel@archiver.kernel.org; Tue, 22 Jun 2021 04:50:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52376) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lvc5H-0007dk-RY for qemu-devel@nongnu.org; Tue, 22 Jun 2021 04:48:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:38004) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lvc5F-0006GL-Hx for qemu-devel@nongnu.org; Tue, 22 Jun 2021 04:48:39 -0400 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BE9026108E; Tue, 22 Jun 2021 08:48:35 +0000 (UTC) Received: from sofa.misterjones.org ([185.219.108.64] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1lvc5B-0093Qj-TK; Tue, 22 Jun 2021 09:48:34 +0100 Date: Tue, 22 Jun 2021 09:48:33 +0100 Message-ID: <877dimcmji.wl-maz@kernel.org> From: Marc Zyngier To: Fuad Tabba Subject: Re: [PATCH v17 4/6] KVM: arm64: Expose KVM_ARM_CAP_MTE In-Reply-To: References: <20210621111716.37157-1-steven.price@arm.com> <20210621111716.37157-5-steven.price@arm.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: tabba@google.com, steven.price@arm.com, catalin.marinas@arm.com, will@kernel.org, dgilbert@redhat.com, qemu-devel@nongnu.org, Dave.Martin@arm.com, quintela@redhat.com, richard.henderson@linaro.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Received-SPF: pass client-ip=198.145.29.99; envelope-from=maz@kernel.org; helo=mail.kernel.org X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Juan Quintela , Catalin Marinas , Richard Henderson , qemu-devel@nongnu.org, "Dr. David Alan Gilbert" , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, Thomas Gleixner , Steven Price , Will Deacon , Dave Martin , linux-kernel@vger.kernel.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On Tue, 22 Jun 2021 09:07:51 +0100, Fuad Tabba wrote: > > Hi, > > On Mon, Jun 21, 2021 at 12:18 PM Steven Price wrote: > > > > It's now safe for the VMM to enable MTE in a guest, so expose the > > capability to user space. > > > > Reviewed-by: Catalin Marinas > > Signed-off-by: Steven Price > > --- > > arch/arm64/kvm/arm.c | 9 +++++++++ > > arch/arm64/kvm/reset.c | 4 ++++ > > arch/arm64/kvm/sys_regs.c | 3 +++ > > 3 files changed, 16 insertions(+) > > > > diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c > > index e720148232a0..28ce26a68f09 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; > > @@ -237,6 +243,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/reset.c b/arch/arm64/kvm/reset.c > > index d37ebee085cf..9e6922b9503a 100644 > > --- a/arch/arm64/kvm/reset.c > > +++ b/arch/arm64/kvm/reset.c > > @@ -244,6 +244,10 @@ int kvm_reset_vcpu(struct kvm_vcpu *vcpu) > > switch (vcpu->arch.target) { > > default: > > if (test_bit(KVM_ARM_VCPU_EL1_32BIT, vcpu->arch.features)) { > > + if (vcpu->kvm->arch.mte_enabled) { > > + ret = -EINVAL; > > + goto out; > > + } > > pstate = VCPU_RESET_PSTATE_SVC; > > } else { > > pstate = VCPU_RESET_PSTATE_EL1; > > nit: I was wondering whether this check would be better suited in > kvm_vcpu_set_target, rather than here (kvm_reset_vcpu). kvm_reset_vcpu > is called by kvm_vcpu_set_target, but kvm_vcpu_set_target is where > checking for supported features happens. It might be better to group > all such checks together. I don't think that there is any risk of this > feature being toggled by the other call path to kvm_reset_vcpu (via > check_vcpu_requests). We already group the 32bit related compatibility checks in vcpu_allowed_register_width(), and this is where I think this should move to. I've provisionally added the change below. M. diff --git a/arch/arm64/kvm/reset.c b/arch/arm64/kvm/reset.c index 9e6922b9503a..cba7872d69a8 100644 --- a/arch/arm64/kvm/reset.c +++ b/arch/arm64/kvm/reset.c @@ -176,6 +176,10 @@ static bool vcpu_allowed_register_width(struct kvm_vcpu *vcpu) if (!cpus_have_const_cap(ARM64_HAS_32BIT_EL1) && is32bit) return false; + /* MTE is incompatible with AArch32 */ + if (kvm_has_mte(vcpu->kvm) && is32bit) + return false; + /* Check that the vcpus are either all 32bit or all 64bit */ kvm_for_each_vcpu(i, tmp, vcpu->kvm) { if (vcpu_has_feature(tmp, KVM_ARM_VCPU_EL1_32BIT) != is32bit) @@ -244,10 +248,6 @@ int kvm_reset_vcpu(struct kvm_vcpu *vcpu) switch (vcpu->arch.target) { default: if (test_bit(KVM_ARM_VCPU_EL1_32BIT, vcpu->arch.features)) { - if (vcpu->kvm->arch.mte_enabled) { - ret = -EINVAL; - goto out; - } pstate = VCPU_RESET_PSTATE_SVC; } else { pstate = VCPU_RESET_PSTATE_EL1; -- Without deviation from the norm, progress is not possible. From mboxrd@z Thu Jan 1 00:00:00 1970 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=-14.0 required=3.0 tests=BAYES_00,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 4C7C3C2B9F4 for ; Tue, 22 Jun 2021 08:48:41 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id BD91A6108E for ; Tue, 22 Jun 2021 08:48:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BD91A6108E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvmarm-bounces@lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 4F25C4064F; Tue, 22 Jun 2021 04:48:40 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5F96iAItq2uT; Tue, 22 Jun 2021 04:48:39 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 1C36940762; Tue, 22 Jun 2021 04:48:39 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 1326B4064F for ; Tue, 22 Jun 2021 04:48:38 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id DIWtCnk0AnPf for ; Tue, 22 Jun 2021 04:48:37 -0400 (EDT) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id D5CAC40642 for ; Tue, 22 Jun 2021 04:48:36 -0400 (EDT) Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BE9026108E; Tue, 22 Jun 2021 08:48:35 +0000 (UTC) Received: from sofa.misterjones.org ([185.219.108.64] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1lvc5B-0093Qj-TK; Tue, 22 Jun 2021 09:48:34 +0100 Date: Tue, 22 Jun 2021 09:48:33 +0100 Message-ID: <877dimcmji.wl-maz@kernel.org> From: Marc Zyngier To: Fuad Tabba Subject: Re: [PATCH v17 4/6] KVM: arm64: Expose KVM_ARM_CAP_MTE In-Reply-To: References: <20210621111716.37157-1-steven.price@arm.com> <20210621111716.37157-5-steven.price@arm.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: tabba@google.com, steven.price@arm.com, catalin.marinas@arm.com, will@kernel.org, dgilbert@redhat.com, qemu-devel@nongnu.org, Dave.Martin@arm.com, quintela@redhat.com, richard.henderson@linaro.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Cc: Juan Quintela , Catalin Marinas , Richard Henderson , qemu-devel@nongnu.org, "Dr. David Alan Gilbert" , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, Thomas Gleixner , Steven Price , Will Deacon , Dave Martin , linux-kernel@vger.kernel.org X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu On Tue, 22 Jun 2021 09:07:51 +0100, Fuad Tabba wrote: > > Hi, > > On Mon, Jun 21, 2021 at 12:18 PM Steven Price wrote: > > > > It's now safe for the VMM to enable MTE in a guest, so expose the > > capability to user space. > > > > Reviewed-by: Catalin Marinas > > Signed-off-by: Steven Price > > --- > > arch/arm64/kvm/arm.c | 9 +++++++++ > > arch/arm64/kvm/reset.c | 4 ++++ > > arch/arm64/kvm/sys_regs.c | 3 +++ > > 3 files changed, 16 insertions(+) > > > > diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c > > index e720148232a0..28ce26a68f09 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; > > @@ -237,6 +243,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/reset.c b/arch/arm64/kvm/reset.c > > index d37ebee085cf..9e6922b9503a 100644 > > --- a/arch/arm64/kvm/reset.c > > +++ b/arch/arm64/kvm/reset.c > > @@ -244,6 +244,10 @@ int kvm_reset_vcpu(struct kvm_vcpu *vcpu) > > switch (vcpu->arch.target) { > > default: > > if (test_bit(KVM_ARM_VCPU_EL1_32BIT, vcpu->arch.features)) { > > + if (vcpu->kvm->arch.mte_enabled) { > > + ret = -EINVAL; > > + goto out; > > + } > > pstate = VCPU_RESET_PSTATE_SVC; > > } else { > > pstate = VCPU_RESET_PSTATE_EL1; > > nit: I was wondering whether this check would be better suited in > kvm_vcpu_set_target, rather than here (kvm_reset_vcpu). kvm_reset_vcpu > is called by kvm_vcpu_set_target, but kvm_vcpu_set_target is where > checking for supported features happens. It might be better to group > all such checks together. I don't think that there is any risk of this > feature being toggled by the other call path to kvm_reset_vcpu (via > check_vcpu_requests). We already group the 32bit related compatibility checks in vcpu_allowed_register_width(), and this is where I think this should move to. I've provisionally added the change below. M. diff --git a/arch/arm64/kvm/reset.c b/arch/arm64/kvm/reset.c index 9e6922b9503a..cba7872d69a8 100644 --- a/arch/arm64/kvm/reset.c +++ b/arch/arm64/kvm/reset.c @@ -176,6 +176,10 @@ static bool vcpu_allowed_register_width(struct kvm_vcpu *vcpu) if (!cpus_have_const_cap(ARM64_HAS_32BIT_EL1) && is32bit) return false; + /* MTE is incompatible with AArch32 */ + if (kvm_has_mte(vcpu->kvm) && is32bit) + return false; + /* Check that the vcpus are either all 32bit or all 64bit */ kvm_for_each_vcpu(i, tmp, vcpu->kvm) { if (vcpu_has_feature(tmp, KVM_ARM_VCPU_EL1_32BIT) != is32bit) @@ -244,10 +248,6 @@ int kvm_reset_vcpu(struct kvm_vcpu *vcpu) switch (vcpu->arch.target) { default: if (test_bit(KVM_ARM_VCPU_EL1_32BIT, vcpu->arch.features)) { - if (vcpu->kvm->arch.mte_enabled) { - ret = -EINVAL; - goto out; - } pstate = VCPU_RESET_PSTATE_SVC; } else { pstate = VCPU_RESET_PSTATE_EL1; -- Without deviation from the norm, progress is not possible. _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm From mboxrd@z Thu Jan 1 00:00:00 1970 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=-14.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 D3934C2B9F4 for ; Tue, 22 Jun 2021 08:50:12 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 9DF2F60C3E for ; Tue, 22 Jun 2021 08:50:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9DF2F60C3E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org 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=bombadil.20210309; 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: Subject:Cc:To:From:Message-ID:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Inf9Q0b6hOR4jtiFLrjsPkYP+K7ysiABfY/O4RC+RJU=; b=QOpYb6buV9Pwip E6/4qAvcjPloTDT48hudR89iVviFWYLP2eF39z1sY7vaISglliJT03H2jM1GGHYYXs1IE/SxE/q// OPrV2j+Tu9JAirui9JrXfatjoUkvgLtDkFWaMvvZiJg/G3p8UtOgZs5BhTs2YULh2jt+y3DDGMeLS DJ4JLZ27NpmZI6TRe6zUtmcjlmsqZehYNtH8/powYRqyk/DAhMahnsyOlxSubBMZGsiu4004U2cCC /u/GizXlry0lqtolUf/2HZzxLPEQafVOpxBbOabOh/9XQrt2/KWzqhopsJJGK3N/1EzWLvHduIp/D yUU7YjIXD9s84uCDpCYw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lvc5H-006IWB-Iv; Tue, 22 Jun 2021 08:48:39 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lvc5E-006IVR-3q for linux-arm-kernel@lists.infradead.org; Tue, 22 Jun 2021 08:48:37 +0000 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BE9026108E; Tue, 22 Jun 2021 08:48:35 +0000 (UTC) Received: from sofa.misterjones.org ([185.219.108.64] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1lvc5B-0093Qj-TK; Tue, 22 Jun 2021 09:48:34 +0100 Date: Tue, 22 Jun 2021 09:48:33 +0100 Message-ID: <877dimcmji.wl-maz@kernel.org> From: Marc Zyngier To: Fuad Tabba Cc: Steven Price , Catalin Marinas , Will Deacon , "Dr. David Alan Gilbert" , qemu-devel@nongnu.org, Dave Martin , Juan Quintela , Richard Henderson , linux-kernel@vger.kernel.org, Thomas Gleixner , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v17 4/6] KVM: arm64: Expose KVM_ARM_CAP_MTE In-Reply-To: References: <20210621111716.37157-1-steven.price@arm.com> <20210621111716.37157-5-steven.price@arm.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: tabba@google.com, steven.price@arm.com, catalin.marinas@arm.com, will@kernel.org, dgilbert@redhat.com, qemu-devel@nongnu.org, Dave.Martin@arm.com, quintela@redhat.com, richard.henderson@linaro.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210622_014836_233809_F6DE39F1 X-CRM114-Status: GOOD ( 31.64 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, 22 Jun 2021 09:07:51 +0100, Fuad Tabba wrote: > > Hi, > > On Mon, Jun 21, 2021 at 12:18 PM Steven Price wrote: > > > > It's now safe for the VMM to enable MTE in a guest, so expose the > > capability to user space. > > > > Reviewed-by: Catalin Marinas > > Signed-off-by: Steven Price > > --- > > arch/arm64/kvm/arm.c | 9 +++++++++ > > arch/arm64/kvm/reset.c | 4 ++++ > > arch/arm64/kvm/sys_regs.c | 3 +++ > > 3 files changed, 16 insertions(+) > > > > diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c > > index e720148232a0..28ce26a68f09 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; > > @@ -237,6 +243,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/reset.c b/arch/arm64/kvm/reset.c > > index d37ebee085cf..9e6922b9503a 100644 > > --- a/arch/arm64/kvm/reset.c > > +++ b/arch/arm64/kvm/reset.c > > @@ -244,6 +244,10 @@ int kvm_reset_vcpu(struct kvm_vcpu *vcpu) > > switch (vcpu->arch.target) { > > default: > > if (test_bit(KVM_ARM_VCPU_EL1_32BIT, vcpu->arch.features)) { > > + if (vcpu->kvm->arch.mte_enabled) { > > + ret = -EINVAL; > > + goto out; > > + } > > pstate = VCPU_RESET_PSTATE_SVC; > > } else { > > pstate = VCPU_RESET_PSTATE_EL1; > > nit: I was wondering whether this check would be better suited in > kvm_vcpu_set_target, rather than here (kvm_reset_vcpu). kvm_reset_vcpu > is called by kvm_vcpu_set_target, but kvm_vcpu_set_target is where > checking for supported features happens. It might be better to group > all such checks together. I don't think that there is any risk of this > feature being toggled by the other call path to kvm_reset_vcpu (via > check_vcpu_requests). We already group the 32bit related compatibility checks in vcpu_allowed_register_width(), and this is where I think this should move to. I've provisionally added the change below. M. diff --git a/arch/arm64/kvm/reset.c b/arch/arm64/kvm/reset.c index 9e6922b9503a..cba7872d69a8 100644 --- a/arch/arm64/kvm/reset.c +++ b/arch/arm64/kvm/reset.c @@ -176,6 +176,10 @@ static bool vcpu_allowed_register_width(struct kvm_vcpu *vcpu) if (!cpus_have_const_cap(ARM64_HAS_32BIT_EL1) && is32bit) return false; + /* MTE is incompatible with AArch32 */ + if (kvm_has_mte(vcpu->kvm) && is32bit) + return false; + /* Check that the vcpus are either all 32bit or all 64bit */ kvm_for_each_vcpu(i, tmp, vcpu->kvm) { if (vcpu_has_feature(tmp, KVM_ARM_VCPU_EL1_32BIT) != is32bit) @@ -244,10 +248,6 @@ int kvm_reset_vcpu(struct kvm_vcpu *vcpu) switch (vcpu->arch.target) { default: if (test_bit(KVM_ARM_VCPU_EL1_32BIT, vcpu->arch.features)) { - if (vcpu->kvm->arch.mte_enabled) { - ret = -EINVAL; - goto out; - } pstate = VCPU_RESET_PSTATE_SVC; } else { pstate = VCPU_RESET_PSTATE_EL1; -- Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel