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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 53717C4332F for ; Sat, 16 Oct 2021 11:04:26 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id B722E611C3 for ; Sat, 16 Oct 2021 11:04:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B722E611C3 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 393424B176; Sat, 16 Oct 2021 07:04:25 -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 HixDftVF4EAX; Sat, 16 Oct 2021 07:04:24 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 2AFC94B15C; Sat, 16 Oct 2021 07:04:24 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 202144B133 for ; Sat, 16 Oct 2021 07:04:22 -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 nP0Ygn++yGCG for ; Sat, 16 Oct 2021 07:04:20 -0400 (EDT) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id C6EC84B0DD for ; Sat, 16 Oct 2021 07:04:20 -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 253F06108E; Sat, 16 Oct 2021 11:04:18 +0000 (UTC) Received: from sofa.misterjones.org ([185.219.108.64] helo=wait-a-minute.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 1mbhU7-00HBTK-S6; Sat, 16 Oct 2021 12:04:15 +0100 Date: Sat, 16 Oct 2021 12:04:15 +0100 Message-ID: <87ilxxut74.wl-maz@kernel.org> From: Marc Zyngier To: Quentin Perret Subject: Re: [PATCH 03/16] KVM: arm64: Avoid remapping the SVE state in the hyp stage-1 In-Reply-To: <20211013155831.943476-4-qperret@google.com> References: <20211013155831.943476-1-qperret@google.com> <20211013155831.943476-4-qperret@google.com> 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, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, will@kernel.org, tabba@google.com, dbrazdil@google.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, kernel-team@android.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Cc: kernel-team@android.com, Will Deacon , Catalin Marinas , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu 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 Wed, 13 Oct 2021 16:58:18 +0100, Quentin Perret wrote: > > We currently map the SVE state into the hypervisor stage-1 on VCPU_RUN, > when the vCPU thread's PID has changed. However, this only needs to be > done during the first VCPU_RUN as the SVE state doesn't depend on > thread-specific data, so move the create_hyp_mapping() call to > kvm_vcpu_first_run_init(). > > Suggested-by: Marc Zyngier > Signed-off-by: Quentin Perret > --- > arch/arm64/kvm/arm.c | 12 ++++++++++++ > arch/arm64/kvm/fpsimd.c | 11 ----------- > 2 files changed, 12 insertions(+), 11 deletions(-) > > diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c > index fe102cd2e518..c33d8c073820 100644 > --- a/arch/arm64/kvm/arm.c > +++ b/arch/arm64/kvm/arm.c > @@ -618,6 +618,18 @@ static int kvm_vcpu_first_run_init(struct kvm_vcpu *vcpu) > if (ret) > return ret; > > + if (vcpu->arch.sve_state) { > + void *sve_end; > + > + sve_end = vcpu->arch.sve_state + vcpu_sve_state_size(vcpu); > + > + ret = create_hyp_mappings(vcpu->arch.sve_state, sve_end, > + PAGE_HYP); > + if (ret) > + return ret; > + } > + > + > ret = kvm_arm_pmu_v3_enable(vcpu); > > return ret; > diff --git a/arch/arm64/kvm/fpsimd.c b/arch/arm64/kvm/fpsimd.c > index 5621020b28de..62c0d78da7be 100644 > --- a/arch/arm64/kvm/fpsimd.c > +++ b/arch/arm64/kvm/fpsimd.c > @@ -43,17 +43,6 @@ int kvm_arch_vcpu_run_map_fp(struct kvm_vcpu *vcpu) > if (ret) > goto error; > > - if (vcpu->arch.sve_state) { > - void *sve_end; > - > - sve_end = vcpu->arch.sve_state + vcpu_sve_state_size(vcpu); > - > - ret = create_hyp_mappings(vcpu->arch.sve_state, sve_end, > - PAGE_HYP); > - if (ret) > - goto error; > - } > - > vcpu->arch.host_thread_info = kern_hyp_va(ti); > vcpu->arch.host_fpsimd_state = kern_hyp_va(fpsimd); > error: I actually ended-up implementing a similar patch as part of my 'first run' series[1], though I moved the mapping to the point where we finalise the vcpu as that's where the allocation takes place. Do you see any potential issue with that approach? Thanks, M. [1] https://lore.kernel.org/r/20211015090822.2994920-2-maz@kernel.org -- 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