From: Oliver Upton <oliver.upton@linux.dev>
To: Mark Brown <broonie@kernel.org>
Cc: Marc Zyngier <maz@kernel.org>, James Morse <james.morse@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
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
Date: Mon, 26 Feb 2024 23:07:55 -0800 [thread overview]
Message-ID: <Zd2KS3sVI-vPxurg@linux.dev> (raw)
In-Reply-To: <20240226-kvm-arm64-group-fp-data-v1-2-07d13759517e@kernel.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
next prev parent reply other threads:[~2024-02-27 7:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-26 20:44 [PATCH 0/2] KVM: arm64: Store a cpu_fp_state directly in the vCPU data Mark Brown
2024-02-26 20:44 ` [PATCH 1/2] KVM: arm64: Rename variable for tracking ownership of FP state Mark Brown
2024-02-26 20:44 ` [PATCH 2/2] KVM: arm64: Reuse struct cpu_fp_state to track the guest " Mark Brown
2024-02-27 7:07 ` Oliver Upton [this message]
2024-02-27 12:19 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Zd2KS3sVI-vPxurg@linux.dev \
--to=oliver.upton@linux.dev \
--cc=broonie@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=james.morse@arm.com \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maz@kernel.org \
--cc=suzuki.poulose@arm.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).