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.7 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 CE683C4338F for ; Fri, 20 Aug 2021 08:03:36 +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 9B00460FF2 for ; Fri, 20 Aug 2021 08:03:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9B00460FF2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=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=hudh5ZT29xVsf8RSIEtkVHh0ZnqJYIkn0mnzgpaIU7E=; b=Yh6sXIjHAapLeS c1rJ5aGseH+0aFCHfHqdQnCtp+bS49dkvL1+EyyI7XvMur2I3L2zEBBPzDVNmdxOkvo9Pn9KSuAMK oU5TjcVamikF8DOcMJ5Eq+R0EfxRV1F2qKPOKBDDpM7LlsXe8UztyeqZYS+n8B0N8gJ/io+0AVTUj QUMQw+W/PaytU3UKDY6ZVUsVE1ZLIddQHUYKAI6bclVgQiwLKIXanXOoIN+LfHKVqpMJDKjUdg6q4 Jd7wwH4qZboMgEF8g/b7VEFwK35FaEqq5y1yCCovI8A8PPH1DqKRycBThlLFNwqkTRfEc5AY2XH1K HtAmezKeoYdjVy2awWdw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mGzTH-00AJhV-MN; Fri, 20 Aug 2021 08:01:47 +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 1mGzTE-00AJgi-1E for linux-arm-kernel@lists.infradead.org; Fri, 20 Aug 2021 08:01:45 +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 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 Cc: Will Deacon , linux-arm-kernel@lists.infradead.org, kernel-team@android.com, Catalin Marinas , Jade Alglave , Shameer Kolothum , kvmarm@lists.cs.columbia.edu, linux-arch@vger.kernel.org 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210820_010144_166107_3BAD3B81 X-CRM114-Status: GOOD ( 24.78 ) 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 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. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel