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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1757E81DEE for ; Fri, 6 Oct 2023 12:34:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232159AbjJFMek (ORCPT ); Fri, 6 Oct 2023 08:34:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232224AbjJFMej (ORCPT ); Fri, 6 Oct 2023 08:34:39 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33D99C2 for ; Fri, 6 Oct 2023 05:34:37 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D05E4C433C7; Fri, 6 Oct 2023 12:34:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696595676; bh=oDjUTju2r3BG2ETE24d4qauYsFDz+99C3MZq1+eZau4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=NYnQmo58tcG0rxJYuwC4KAckCZo/2eLfB7a4qgxa1AB+Dzbhy0acfXXYbBK5lgSwK T3QBHoQ6UwbhLoBAukSECiT5VyKf42pU7bPQES6lABL8tnYTIQ6xO5MzH5qg72VO8c cwShMTku9thW/hyy+11qO8s9974u66yK+l2sXcI1+9rmIr8/N56RryAlx51rwazLfk YrObmCmjM+/m8mxcK6EVhqzI3z3/H0J9hpQeoOPpVBKtWUguxVgBN3tPB46IKniO5F IIJWuGoKFKonYqBbOJqoksuSX4vQHoy6A2YE8zpt9jEiS49AKHSK+1x0SWs2T4pCvp qZRpp7mzjFTLQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1qok2M-001ifF-9n; Fri, 06 Oct 2023 13:34:34 +0100 Date: Fri, 06 Oct 2023 13:34:34 +0100 Message-ID: <861qe8nd45.wl-maz@kernel.org> From: Marc Zyngier To: Oliver Upton Cc: kvmarm@lists.linux.dev, kvm@vger.kernel.org, James Morse , Suzuki K Poulose , Zenghui Yu Subject: Re: [PATCH 0/3] KVM: arm64: Load the stage-2 MMU from vcpu_load() for VHE In-Reply-To: <8634yongw3.wl-maz@kernel.org> References: <20231006093600.1250986-1-oliver.upton@linux.dev> <8634yongw3.wl-maz@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/29.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: oliver.upton@linux.dev, kvmarm@lists.linux.dev, kvm@vger.kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Fri, 06 Oct 2023 12:13:00 +0100, Marc Zyngier wrote: > > On Fri, 06 Oct 2023 10:35:57 +0100, > Oliver Upton wrote: > > > > Unlike nVHE, there is no need to switch the stage-2 MMU around on guest > > entry/exit in VHE mode as the host is running at EL2. Despite this KVM > > reloads the stage-2 on every guest entry, which is needless. > > > > This series moves the setup of the stage-2 MMU context to vcpu_load() > > when running in VHE mode. This is likely to be a win across the board, > > but also allows us to remove an ISB on the guest entry path for systems > > with one of the speculative AT errata. > > > > None of my machines affected by the AT errata are VHE-capable, so it'd > > be appreciated if someone could give this series a go and make sure I > > haven't wrecked anything. > > It totally breaks on my A55 board. Running a single guest seems OK, > but running a number of the concurrently makes them explode early on > (faults in EFI...) > > I guess we end-up running with the wrong VTTBR at times, which would > be interesting... Fun fact: diff --git a/arch/arm64/kvm/hyp/vhe/switch.c b/arch/arm64/kvm/hyp/vhe/switch.c index b0cafd7c5f8f..40c84db5884a 100644 --- a/arch/arm64/kvm/hyp/vhe/switch.c +++ b/arch/arm64/kvm/hyp/vhe/switch.c @@ -195,6 +195,11 @@ static int __kvm_vcpu_run_vhe(struct kvm_vcpu *vcpu) sysreg_restore_guest_state_vhe(guest_ctxt); __debug_switch_to_guest(vcpu); + WARN_ONCE(kvm_get_vttbr(vcpu->arch.hw_mmu) != read_sysreg(vttbr_el2), + "Oh crap %llx vs %llx\n", + kvm_get_vttbr(vcpu->arch.hw_mmu), + read_sysreg(vttbr_el2)); + if (is_hyp_ctxt(vcpu)) vcpu_set_flag(vcpu, VCPU_HYP_CONTEXT); else [ 36.190355] Oh crap 10000057a6001 vs 57a6001 My bet is that the VMID isn't allocated on first load, and everything goes downhill from there. M. -- Without deviation from the norm, progress is not possible.