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 7DD5CC4338F for ; Fri, 20 Aug 2021 08:01:58 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id C745D60F92 for ; Fri, 20 Aug 2021 08:01:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C745D60F92 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 670784B0EA; Fri, 20 Aug 2021 04:01:57 -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 foorWL8txkfX; Fri, 20 Aug 2021 04:01:51 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 93E704B0F3; Fri, 20 Aug 2021 04:01:51 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 0D13D4B0E2 for ; Fri, 20 Aug 2021 04:01:50 -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 RP99r5bGhxrx for ; Fri, 20 Aug 2021 04:01:45 -0400 (EDT) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 8F9F64B0C7 for ; Fri, 20 Aug 2021 04:01:45 -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 CA5DA60FF2; Fri, 20 Aug 2021 08:01:43 +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 1mGzTB-0068mH-RR; Fri, 20 Aug 2021 09:01:41 +0100 Date: Fri, 20 Aug 2021 09:01:41 +0100 Message-ID: <87tujkr1cq.wl-maz@kernel.org> From: Marc Zyngier To: Quentin Perret Subject: Re: [PATCH 3/4] KVM: arm64: Convert the host S2 over to __load_guest_stage2() In-Reply-To: References: <20210806113109.2475-1-will@kernel.org> <20210806113109.2475-5-will@kernel.org> 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: qperret@google.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, kernel-team@android.com, catalin.marinas@arm.com, jade.alglave@arm.com, shameerali.kolothum.thodi@huawei.com, kvmarm@lists.cs.columbia.edu, linux-arch@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Cc: linux-arch@vger.kernel.org, Will Deacon , Catalin Marinas , kernel-team@android.com, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, Jade Alglave 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 Fri, 06 Aug 2021 14:40:00 +0100, Quentin Perret wrote: > > On Friday 06 Aug 2021 at 12:31:07 (+0100), Will Deacon wrote: > > From: Marc Zyngier > > > > The protected mode relies on a separate helper to load the > > S2 context. Move over to the __load_guest_stage2() helper > > instead. > > > > Cc: Catalin Marinas > > Cc: Jade Alglave > > Cc: Shameer Kolothum > > Signed-off-by: Marc Zyngier > > Signed-off-by: Will Deacon > > --- > > arch/arm64/include/asm/kvm_mmu.h | 11 +++-------- > > arch/arm64/kvm/hyp/include/nvhe/mem_protect.h | 2 +- > > arch/arm64/kvm/hyp/nvhe/mem_protect.c | 2 +- > > 3 files changed, 5 insertions(+), 10 deletions(-) > > > > diff --git a/arch/arm64/include/asm/kvm_mmu.h b/arch/arm64/include/asm/kvm_mmu.h > > index 05e089653a1a..934ef0deff9f 100644 > > --- a/arch/arm64/include/asm/kvm_mmu.h > > +++ b/arch/arm64/include/asm/kvm_mmu.h > > @@ -267,9 +267,10 @@ static __always_inline u64 kvm_get_vttbr(struct kvm_s2_mmu *mmu) > > * Must be called from hyp code running at EL2 with an updated VTTBR > > * and interrupts disabled. > > */ > > -static __always_inline void __load_stage2(struct kvm_s2_mmu *mmu, unsigned long vtcr) > > +static __always_inline void __load_guest_stage2(struct kvm_s2_mmu *mmu, > > + struct kvm_arch *arch) > > { > > - write_sysreg(vtcr, vtcr_el2); > > + write_sysreg(arch->vtcr, vtcr_el2); > > write_sysreg(kvm_get_vttbr(mmu), vttbr_el2); > > > > /* > > @@ -280,12 +281,6 @@ static __always_inline void __load_stage2(struct kvm_s2_mmu *mmu, unsigned long > > asm(ALTERNATIVE("nop", "isb", ARM64_WORKAROUND_SPECULATIVE_AT)); > > } > > > > -static __always_inline void __load_guest_stage2(struct kvm_s2_mmu *mmu, > > - struct kvm_arch *arch) > > -{ > > - __load_stage2(mmu, arch->vtcr); > > -} > > - > > static inline struct kvm *kvm_s2_mmu_to_kvm(struct kvm_s2_mmu *mmu) > > { > > return container_of(mmu->arch, struct kvm, arch); > > diff --git a/arch/arm64/kvm/hyp/include/nvhe/mem_protect.h b/arch/arm64/kvm/hyp/include/nvhe/mem_protect.h > > index 9c227d87c36d..a910648bc71b 100644 > > --- a/arch/arm64/kvm/hyp/include/nvhe/mem_protect.h > > +++ b/arch/arm64/kvm/hyp/include/nvhe/mem_protect.h > > @@ -29,7 +29,7 @@ void handle_host_mem_abort(struct kvm_cpu_context *host_ctxt); > > static __always_inline void __load_host_stage2(void) > > { > > if (static_branch_likely(&kvm_protected_mode_initialized)) > > - __load_stage2(&host_kvm.arch.mmu, host_kvm.arch.vtcr); > > + __load_guest_stage2(&host_kvm.arch.mmu, &host_kvm.arch); > > else > > write_sysreg(0, vttbr_el2); > > } > > diff --git a/arch/arm64/kvm/hyp/nvhe/mem_protect.c b/arch/arm64/kvm/hyp/nvhe/mem_protect.c > > index d938ce95d3bd..d4e74ca7f876 100644 > > --- a/arch/arm64/kvm/hyp/nvhe/mem_protect.c > > +++ b/arch/arm64/kvm/hyp/nvhe/mem_protect.c > > @@ -126,7 +126,7 @@ int __pkvm_prot_finalize(void) > > kvm_flush_dcache_to_poc(params, sizeof(*params)); > > > > write_sysreg(params->hcr_el2, hcr_el2); > > - __load_stage2(&host_kvm.arch.mmu, host_kvm.arch.vtcr); > > + __load_guest_stage2(&host_kvm.arch.mmu, &host_kvm.arch); > > Nit: clearly we're not loading a guest stage-2 here, so maybe the > function should take a more generic name? How about we rename __load_guest_stage2() to __load_stage2() instead, with the same parameters? Thanks, M. -- 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