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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id D2DC8C54798 for ; Tue, 27 Feb 2024 07:08:29 +0000 (UTC) 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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Y5I78Pv3h5wIrRxYExMPT1GupFdtbHpDtG9r3ic7/QM=; b=XqZH4Mp2GLzKIP LZUdLw8M7y0pyHa2IJnjccuh2YzSNFcHOb7vCxWvKvL9Grg3au1W6YTA6iy9K9bgNd/yZ5e6AlK6n Q1oVpRjODAbKA35dNfAez56fHdo8MSaLU20RlHO0+QxJMq3E+d1MDZAi7BOrTBinpl1tyNv24Mzum mUaOlySCT/0NCZqNARlDuUZWlFINO/VdbV896a8lJlxPUiDpdwUGATM8zzpEvYbwhTKanWHVaTM0s aSLN4LbaHS1coa7wwFmX+J0xGxZL1SJl0PiG4T5El5Hk2e6guKYpKHu+2H6khJb2XinlVl92Bj9sS omtjSV9I7Evu8DieqXUA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rerZW-0000000449p-4ANE; Tue, 27 Feb 2024 07:08:14 +0000 Received: from out-180.mta1.migadu.com ([2001:41d0:203:375::b4]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rerZT-0000000447n-0u8z for linux-arm-kernel@lists.infradead.org; Tue, 27 Feb 2024 07:08:13 +0000 Date: Mon, 26 Feb 2024 23:07:55 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1709017680; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=LPLqxZBWlu+avdMKPH1o/8nV2jfbJWdh4RS5gf3tDfw=; b=t6qRFGpNTM6C2DPPOJQwPcC4rjR9I/gJr4xWRyhUVIpcp505iBo/6wLCnpWkefLbuY9jtO 8pkfqhLTG11PvWfgGVsgwNrYaLX4D3A+IaPI2PP/Bj2uFX2LdSPEJazDn/HZIxLTgOvIQ4 oRFiiQqEQ71JFmL+IO3dnFJYTnOKhqk= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Mark Brown Cc: Marc Zyngier , James Morse , Suzuki K Poulose , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] KVM: arm64: Reuse struct cpu_fp_state to track the guest FP state Message-ID: References: <20240226-kvm-arm64-group-fp-data-v1-0-07d13759517e@kernel.org> <20240226-kvm-arm64-group-fp-data-v1-2-07d13759517e@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240226-kvm-arm64-group-fp-data-v1-2-07d13759517e@kernel.org> X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240226_230811_562295_D2F7D6D2 X-CRM114-Status: GOOD ( 18.87 ) 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 Hey broonie, On Mon, Feb 26, 2024 at 08:44:11PM +0000, Mark Brown wrote: > At present we store the various bits of floating point state individually > in struct kvm_vpcu_arch and construct a struct cpu_fp_state to share with typo: kvm_vcpu_arch > diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c > index a2cba18effb2..84cc0dbd9b14 100644 > --- a/arch/arm64/kvm/arm.c > +++ b/arch/arm64/kvm/arm.c > @@ -379,6 +379,18 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu) > */ > vcpu->arch.fp_owner = FP_STATE_FREE; > > + /* > + * Initial setup for FP state for sharing with host, if SVE is > + * enabled additional configuration will be done. > + * > + * Currently we do not support SME guests so SVCR is always 0 > + * and we just need a variable to point to. > + */ > + vcpu->arch.fp_state.st = &vcpu->arch.ctxt.fp_regs; > + vcpu->arch.fp_state.fp_type = &vcpu->arch.fp_type; > + vcpu->arch.fp_state.svcr = &vcpu->arch.svcr; > + vcpu->arch.fp_state.to_save = FP_STATE_FPSIMD; > + I'm not too big of a fan of scattering the initialization in various places... Why can't we have a unified helper for priming cpu_fp_state once we know what we're dealing with? That can be called from either kvm_setup_vcpu() or kvm_vcpu_finalize_sve() depending on whether userspace signed up for SVE or not. > /* Set up the timer */ > kvm_timer_vcpu_init(vcpu); > > diff --git a/arch/arm64/kvm/fpsimd.c b/arch/arm64/kvm/fpsimd.c > index 8dbd62d1e677..45fe4a942992 100644 > --- a/arch/arm64/kvm/fpsimd.c > +++ b/arch/arm64/kvm/fpsimd.c > @@ -143,24 +143,7 @@ void kvm_arch_vcpu_ctxsync_fp(struct kvm_vcpu *vcpu) > WARN_ON_ONCE(!irqs_disabled()); > > if (vcpu->arch.fp_owner == FP_STATE_GUEST_OWNED) { > - > - /* > - * Currently we do not support SME guests so SVCR is > - * always 0 and we just need a variable to point to. > - */ > - fp_state.st = &vcpu->arch.ctxt.fp_regs; > - fp_state.sve_state = vcpu->arch.sve_state; > - fp_state.sve_vl = vcpu->arch.sve_max_vl; > - fp_state.sme_state = NULL; > - fp_state.svcr = &vcpu->arch.svcr; > - fp_state.fp_type = &vcpu->arch.fp_type; > - > - if (vcpu_has_sve(vcpu)) > - fp_state.to_save = FP_STATE_SVE; > - else > - fp_state.to_save = FP_STATE_FPSIMD; > - > - fpsimd_bind_state_to_cpu(&fp_state); > + fpsimd_bind_state_to_cpu(&vcpu->arch.fp_state); Shouldn't we get rid of the fp_state local at this point? I'm pretty sure a compiler would emit a warning here... -- Thanks, Oliver _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel