From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8A6176FC3 for ; Mon, 5 Jun 2023 16:39:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685983196; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=+WZAeY2M1M3VRyRqli4bEzyT4GZo8nI6OGMhk9CIMS4=; b=Lq+8ytBDT5ijmNoiVk96tBV1zav2afpbvEww0yyA93oh3yZFtrmYWE5B/VK+LthUqt0hJL kfe/1mbT7Kd91K/Z/nJs9u7cyi+Hg9WsENGqW8bAgYRZ2KJT+alLeF5y3w13NkcIcCy5yp 99QaPOOXVWUK10VPM0bgWSMN21Fo81g= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-58-7PjixWQCPJq1B7YkvSGeOg-1; Mon, 05 Jun 2023 12:39:53 -0400 X-MC-Unique: 7PjixWQCPJq1B7YkvSGeOg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1504285A5BA; Mon, 5 Jun 2023 16:39:52 +0000 (UTC) Received: from localhost (unknown [10.39.193.252]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AC91348205E; Mon, 5 Jun 2023 16:39:51 +0000 (UTC) From: Cornelia Huck To: Marc Zyngier , Suraj Jitindar Singh Cc: jingzhangos@google.com, alexandru.elisei@arm.com, james.morse@arm.com, kvm@vger.kernel.org, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, oupton@google.com, pbonzini@redhat.com, rananta@google.com, reijiw@google.com, suzuki.poulose@arm.com, tabba@google.com, will@kernel.org, sjitindarsingh@gmail.com Subject: Re: [PATCH 3/3] KVM: arm64: Use per guest ID register for ID_AA64PFR1_EL1.MTE In-Reply-To: <873539ospa.wl-maz@kernel.org> Organization: Red Hat GmbH References: <20230602005118.2899664-1-jingzhangos@google.com> <20230602221447.1809849-1-surajjs@amazon.com> <20230602221447.1809849-4-surajjs@amazon.com> <873539ospa.wl-maz@kernel.org> User-Agent: Notmuch/0.37 (https://notmuchmail.org) Date: Mon, 05 Jun 2023 18:39:50 +0200 Message-ID: <87h6rl50dl.fsf@redhat.com> Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 On Sat, Jun 03 2023, Marc Zyngier wrote: > On Fri, 02 Jun 2023 23:14:47 +0100, > Suraj Jitindar Singh wrote: >> >> With per guest ID registers, MTE settings from userspace can be stored in >> its corresponding ID register. >> >> No functional change intended. >> >> Signed-off-by: Suraj Jitindar Singh >> --- >> arch/arm64/include/asm/kvm_host.h | 21 ++++++++++----------- >> arch/arm64/kvm/arm.c | 11 ++++++++++- >> arch/arm64/kvm/sys_regs.c | 5 +++++ >> 3 files changed, 25 insertions(+), 12 deletions(-) >> diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c >> index ca18c09ccf82..6fc4190559d1 100644 >> --- a/arch/arm64/kvm/arm.c >> +++ b/arch/arm64/kvm/arm.c >> @@ -80,8 +80,17 @@ int kvm_vm_ioctl_enable_cap(struct kvm *kvm, >> if (!system_supports_mte() || kvm->created_vcpus) { >> r = -EINVAL; >> } else { >> + u64 val; >> + >> + /* Protects the idregs against modification */ >> + mutex_lock(&kvm->arch.config_lock); >> + >> + val = IDREG(kvm, SYS_ID_AA64PFR1_EL1); >> + val |= FIELD_PREP(ID_AA64PFR1_EL1_MTE_MASK, 1); > > The architecture specifies 3 versions of MTE in the published ARM ARM, > with a 4th coming up as part of the 2022 extensions. Is that the one that adds some more MTE bits in AA64PFR1 and AA64PFR2? > Why are you > actively crippling the MTE version presented to the guest, and > potentially introduce unexpected behaviours? While the code does not look correct here, I think we'll need some way to control which version of MTE is presented to the guest for compatibility handling; does it make sense to control this per-cpu, or does it need to be a vm-wide setting? 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 0A356C7EE23 for ; Mon, 5 Jun 2023 16:40:27 +0000 (UTC) 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:Message-ID:Date:References :In-Reply-To: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=hkC1baM1eqR7OXLn5yIQiVu8zWtHZ662J//ZYtVkq5g=; b=2jkejYnqCXaVNu HEHRxqTrAEzoy5Mrzgpbh2Ty/ZkBVPPZ3h9tbv7HOFabEdMR3UrKSpmmdzDW1R6tPiVO1Vz0bavuf 6B8VBiGhISPeRJhiiTYn4f8/sjC+42eLc0aU1yYmwaFkYEqwYNRnq7qKzY1oWOT9qjLX2Kq46P4FF tr2IMoF+bBV1WyU/Yw6sEkMKtA4hbQro+exOiY0pbMdFV8KZXb7+xcELK7Vi57Eb0VwCumUlnUT2z cr+6vhZ20YbLRDncP5GG9mC0B7S4YxaNKP2yubnuvt1ayHnS+EfBlqXGXtnJPL6MfTpJknT0Re5vi HcJ2tAwzcnHvWGfzl7cg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6DFS-00GAKk-0p; Mon, 05 Jun 2023 16:40:02 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6DFP-00GAIs-2A for linux-arm-kernel@lists.infradead.org; Mon, 05 Jun 2023 16:40:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685983197; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=+WZAeY2M1M3VRyRqli4bEzyT4GZo8nI6OGMhk9CIMS4=; b=cL+Wf1LAv8aj/iUySMTSc5NIvzIALxRtacvIBdtCkNoDEknF91m9SlIi5GYiJuHvqxUCmI Vj032ykKt0Fcv6jRjUDSTrHM1rSzw+RcyETvlKujY2+ApBLgtktpnwMD89X9sj/XL2s9RN IVbsN8Qd5n8Fv65qc2bkq4udujUcQkQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-58-7PjixWQCPJq1B7YkvSGeOg-1; Mon, 05 Jun 2023 12:39:53 -0400 X-MC-Unique: 7PjixWQCPJq1B7YkvSGeOg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1504285A5BA; Mon, 5 Jun 2023 16:39:52 +0000 (UTC) Received: from localhost (unknown [10.39.193.252]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AC91348205E; Mon, 5 Jun 2023 16:39:51 +0000 (UTC) From: Cornelia Huck To: Marc Zyngier , Suraj Jitindar Singh Cc: jingzhangos@google.com, alexandru.elisei@arm.com, james.morse@arm.com, kvm@vger.kernel.org, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, oupton@google.com, pbonzini@redhat.com, rananta@google.com, reijiw@google.com, suzuki.poulose@arm.com, tabba@google.com, will@kernel.org, sjitindarsingh@gmail.com Subject: Re: [PATCH 3/3] KVM: arm64: Use per guest ID register for ID_AA64PFR1_EL1.MTE In-Reply-To: <873539ospa.wl-maz@kernel.org> Organization: Red Hat GmbH References: <20230602005118.2899664-1-jingzhangos@google.com> <20230602221447.1809849-1-surajjs@amazon.com> <20230602221447.1809849-4-surajjs@amazon.com> <873539ospa.wl-maz@kernel.org> User-Agent: Notmuch/0.37 (https://notmuchmail.org) Date: Mon, 05 Jun 2023 18:39:50 +0200 Message-ID: <87h6rl50dl.fsf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230605_093959_783550_FA079BF4 X-CRM114-Status: GOOD ( 19.79 ) 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 Sat, Jun 03 2023, Marc Zyngier wrote: > On Fri, 02 Jun 2023 23:14:47 +0100, > Suraj Jitindar Singh wrote: >> >> With per guest ID registers, MTE settings from userspace can be stored in >> its corresponding ID register. >> >> No functional change intended. >> >> Signed-off-by: Suraj Jitindar Singh >> --- >> arch/arm64/include/asm/kvm_host.h | 21 ++++++++++----------- >> arch/arm64/kvm/arm.c | 11 ++++++++++- >> arch/arm64/kvm/sys_regs.c | 5 +++++ >> 3 files changed, 25 insertions(+), 12 deletions(-) >> diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c >> index ca18c09ccf82..6fc4190559d1 100644 >> --- a/arch/arm64/kvm/arm.c >> +++ b/arch/arm64/kvm/arm.c >> @@ -80,8 +80,17 @@ int kvm_vm_ioctl_enable_cap(struct kvm *kvm, >> if (!system_supports_mte() || kvm->created_vcpus) { >> r = -EINVAL; >> } else { >> + u64 val; >> + >> + /* Protects the idregs against modification */ >> + mutex_lock(&kvm->arch.config_lock); >> + >> + val = IDREG(kvm, SYS_ID_AA64PFR1_EL1); >> + val |= FIELD_PREP(ID_AA64PFR1_EL1_MTE_MASK, 1); > > The architecture specifies 3 versions of MTE in the published ARM ARM, > with a 4th coming up as part of the 2022 extensions. Is that the one that adds some more MTE bits in AA64PFR1 and AA64PFR2? > Why are you > actively crippling the MTE version presented to the guest, and > potentially introduce unexpected behaviours? While the code does not look correct here, I think we'll need some way to control which version of MTE is presented to the guest for compatibility handling; does it make sense to control this per-cpu, or does it need to be a vm-wide setting? _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel