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=-10.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 84104C4361B for ; Mon, 7 Dec 2020 14:49:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4618E23380 for ; Mon, 7 Dec 2020 14:49:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726339AbgLGOtJ (ORCPT ); Mon, 7 Dec 2020 09:49:09 -0500 Received: from foss.arm.com ([217.140.110.172]:52772 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725774AbgLGOtJ (ORCPT ); Mon, 7 Dec 2020 09:49:09 -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 943EE1042; Mon, 7 Dec 2020 06:48:23 -0800 (PST) Received: from [192.168.1.179] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F328B3F68F; Mon, 7 Dec 2020 06:48:20 -0800 (PST) Subject: Re: [PATCH v6 1/2] arm64: kvm: Save/restore MTE registers To: Marc Zyngier Cc: Catalin Marinas , Will Deacon , 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 References: <20201127152113.13099-1-steven.price@arm.com> <20201127152113.13099-2-steven.price@arm.com> <946b1e7b06c4d286a78cf61408e0fc8d@kernel.org> From: Steven Price Message-ID: <03566358-21b0-11d9-c4f6-d07d137a1009@arm.com> Date: Mon, 7 Dec 2020 14:48:19 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <946b1e7b06c4d286a78cf61408e0fc8d@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/12/2020 17:07, Marc Zyngier wrote: > >> diff --git a/arch/arm64/include/asm/sysreg.h >> b/arch/arm64/include/asm/sysreg.h >> index e2ef4c2edf06..b6668ffa04d9 100644 >> --- a/arch/arm64/include/asm/sysreg.h >> +++ b/arch/arm64/include/asm/sysreg.h >> @@ -569,7 +569,8 @@ >>  #define SCTLR_ELx_M    (BIT(0)) >> >>  #define SCTLR_ELx_FLAGS    (SCTLR_ELx_M  | SCTLR_ELx_A | SCTLR_ELx_C | \ >> -             SCTLR_ELx_SA | SCTLR_ELx_I | SCTLR_ELx_IESB) >> +             SCTLR_ELx_SA | SCTLR_ELx_I | SCTLR_ELx_IESB | \ >> +             SCTLR_ELx_ITFSB) >> >>  /* SCTLR_EL2 specific flags. */ >>  #define SCTLR_EL2_RES1    ((BIT(4))  | (BIT(5))  | (BIT(11)) | >> (BIT(16)) | \ >> diff --git a/arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h >> b/arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h >> index cce43bfe158f..45255ba60152 100644 >> --- a/arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h >> +++ b/arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h >> @@ -18,6 +18,11 @@ >>  static inline void __sysreg_save_common_state(struct kvm_cpu_context >> *ctxt) >>  { >>      ctxt_sys_reg(ctxt, MDSCR_EL1)    = read_sysreg(mdscr_el1); >> +    if (system_supports_mte()) { > > Please move the per-VM predicate to this patch so that it can be used > not to save/restore the MTE registers if we don't need to. There isn't a valid struct kvm_vcpu or struct kvm here. I know there's ctx->__hyp_running_vcpu but AFAICT that is only valid with the host context. > >> +        ctxt_sys_reg(ctxt, RGSR_EL1)    = read_sysreg_s(SYS_RGSR_EL1); >> +        ctxt_sys_reg(ctxt, GCR_EL1)    = read_sysreg_s(SYS_GCR_EL1); >> +        ctxt_sys_reg(ctxt, TFSRE0_EL1)    = >> read_sysreg_s(SYS_TFSRE0_EL1); >> +    } > > Overall, I still don't understand how this is going to work once > we have MTE in the kernel. You mentioned having the ability to > create turn off the tag checks at times, but I don't see that > in this patch (and I'm not sure we want that either). Given that this is now highly unlikely to be merged for v5.11, I'll rebase onto of the KASAN MTE series and double check exactly what happens. My thought was that it should be as simple as setting TCO, but your previous comment about moving the save/restore into assembler might be wise in case the compiler starts playing with TCO itself. Steve