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 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 87B0CC433EF for ; Sat, 16 Oct 2021 11:05:37 +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 5246E6108E for ; Sat, 16 Oct 2021 11:05:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5246E6108E 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=spD8kgy3KiaySvJGcZ/YSoiKCN+1svKSbWBx8n8rAK4=; b=xJ4SCkgrF9n/De SrWb7v8tHf7UQ0/bWJwde6AOhYxYzd1arJOCcMX6raAJNW5re2eMG9l27lO/SrdvJMFcGqh1M7P/2 hLtpA8PlL+gbm5yRxNc2jQXBvpRWiat4gmrBqxLUks1OUcugsDRp/QrM6T28P+yfP+2v7J+EiiKUN 6LdN26dU7N2MTwynU9cwFiCkiQuF1TkpoCCOIrQ+PVisme5l1koWh2XEm5nxmGQQNBcotVq8Sjz+3 JkO0QOJN6ysPukKtnKycad9cw+PWi55M5TEk+hVrvF2OKpH6z1VrnDe0xD3kWZeWNS3MqMvUTgEza RFOUcyN0tT8jA3F/CGAA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mbhUH-00ARUa-NJ; Sat, 16 Oct 2021 11:04:25 +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 1mbhUD-00ARTn-KV for linux-arm-kernel@lists.infradead.org; Sat, 16 Oct 2021 11:04:23 +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 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 Cc: James Morse , Alexandru Elisei , Suzuki K Poulose , Catalin Marinas , Will Deacon , Fuad Tabba , David Brazdil , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, kernel-team@android.com 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211016_040421_737648_DEC13D25 X-CRM114-Status: GOOD ( 24.43 ) 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 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. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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 BAEC1C433F5 for ; Sat, 16 Oct 2021 11:04:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8A7536108E for ; Sat, 16 Oct 2021 11:04:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244199AbhJPLG1 (ORCPT ); Sat, 16 Oct 2021 07:06:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:34656 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236005AbhJPLGZ (ORCPT ); Sat, 16 Oct 2021 07:06:25 -0400 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 Cc: James Morse , Alexandru Elisei , Suzuki K Poulose , Catalin Marinas , Will Deacon , Fuad Tabba , David Brazdil , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, kernel-team@android.com 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") Content-Type: text/plain; charset=US-ASCII 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.