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=-8.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED, USER_AGENT_MUTT 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 A7036C43381 for ; Thu, 21 Feb 2019 15:51:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8256E20823 for ; Thu, 21 Feb 2019 15:51:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728652AbfBUPvH (ORCPT ); Thu, 21 Feb 2019 10:51:07 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:46738 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726390AbfBUPvG (ORCPT ); Thu, 21 Feb 2019 10:51:06 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id F2B99A78; Thu, 21 Feb 2019 07:51:05 -0800 (PST) Received: from e103592.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 106E43F5C1; Thu, 21 Feb 2019 07:51:03 -0800 (PST) Date: Thu, 21 Feb 2019 15:51:01 +0000 From: Dave Martin To: Amit Daniel Kachhap Cc: linux-arm-kernel@lists.infradead.org, Marc Zyngier , Catalin Marinas , Will Deacon , Kristina Martsenko , kvmarm@lists.cs.columbia.edu, Ramana Radhakrishnan , linux-kernel@vger.kernel.org Subject: Re: [PATCH v6 2/6] arm64/kvm: preserve host MDCR_EL2 value Message-ID: <20190221155101.GV3567@e103592.cambridge.arm.com> References: <1550568271-5319-1-git-send-email-amit.kachhap@arm.com> <1550568271-5319-3-git-send-email-amit.kachhap@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1550568271-5319-3-git-send-email-amit.kachhap@arm.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 19, 2019 at 02:54:27PM +0530, Amit Daniel Kachhap wrote: > Save host MDCR_EL2 value during kvm HYP initialisation and restore > after every switch from host to guest. There should not be any > change in functionality due to this. > > The value of mdcr_el2 is now stored in struct kvm_cpu_context as > both host and guest can now use this field in a common way. Is MDCR_EL2 somehow relevant to pointer auth? It's not entirely clear why this patch is here. If this is a cleanup to align the handling of this register with how HCR_EL2 is handled, it would be good to explain that in the commit message. > Signed-off-by: Amit Daniel Kachhap > Cc: Marc Zyngier > Cc: Mark Rutland > Cc: Christoffer Dall > Cc: kvmarm@lists.cs.columbia.edu > --- > arch/arm/include/asm/kvm_host.h | 1 - > arch/arm64/include/asm/kvm_host.h | 6 ++---- > arch/arm64/kvm/debug.c | 28 ++++++---------------------- > arch/arm64/kvm/hyp/switch.c | 17 ++++------------- > arch/arm64/kvm/hyp/sysreg-sr.c | 6 ++++++ > virt/kvm/arm/arm.c | 1 - > 6 files changed, 18 insertions(+), 41 deletions(-) > > diff --git a/arch/arm/include/asm/kvm_host.h b/arch/arm/include/asm/kvm_host.h > index 05706b4..704667e 100644 > --- a/arch/arm/include/asm/kvm_host.h > +++ b/arch/arm/include/asm/kvm_host.h > @@ -294,7 +294,6 @@ static inline void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu) {} > static inline void kvm_arch_sched_in(struct kvm_vcpu *vcpu, int cpu) {} > static inline void kvm_arch_vcpu_block_finish(struct kvm_vcpu *vcpu) {} > > -static inline void kvm_arm_init_debug(void) {} > static inline void kvm_arm_setup_debug(struct kvm_vcpu *vcpu) {} > static inline void kvm_arm_clear_debug(struct kvm_vcpu *vcpu) {} > static inline void kvm_arm_reset_debug_ptr(struct kvm_vcpu *vcpu) {} > diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h > index 1b2e05b..2f1bb86 100644 > --- a/arch/arm64/include/asm/kvm_host.h > +++ b/arch/arm64/include/asm/kvm_host.h > @@ -205,6 +205,8 @@ struct kvm_cpu_context { > > /* HYP host/guest configuration */ > u64 hcr_el2; > + u32 mdcr_el2; > + ARMv8-A says MDCR_EL2 is a 64-bit register. Bits [63:20] are currently RES0, so this is probably not a big deal. But it would be better to make this 64-bit to prevent future accidents. It may be better to make that change in a separate patch. This is probably non-urgent, since this is clearly not causing problems for anyone today. [...] Cheers ---Dave