From: sashiko-bot@kernel.org
To: "Mark Brown" <broonie@kernel.org>
Cc: kvmarm@lists.linux.dev, "Oliver Upton" <oupton@kernel.org>,
"Marc Zyngier" <maz@kernel.org>
Subject: Re: [PATCH v22 04/16] KVM: arm64: Ensure GCS memory effects are visible
Date: Mon, 30 Nov 2026 17:03:03 +0000 [thread overview]
Message-ID: <sashiko-outbox-241653@kernel.org> (raw)
In-Reply-To: <20261130-arm64-gcs-v22-4-80454edf47ea@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] KVM: arm64: missing gcsb_dsync() on vCPU load paths across
migration
--
commit fd91d0eaded40090a370f05ec0ab5e596e118250
Author: Mark Brown <broonie@kernel.org>
KVM: arm64: Ensure GCS memory effects are visible
This commit adds gcsb_dsync() barriers when putting a vCPU in VHE, nVHE,
and pKVM modes so that GCS memory effects from an outgoing vCPU are
visible elsewhere.
> diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c
> index a148e80d0aef7..2064cff8e92af 100644
> --- a/arch/arm64/kvm/arm.c
> +++ b/arch/arm64/kvm/arm.c
> @@ -826,6 +826,16 @@ static void vhe_vcpu_put(struct kvm_vcpu *vcpu)
> if (vcpu_has_nv(vcpu))
> kvm_vcpu_put_hw_mmu(vcpu);
>
> + /*
> + * Ensure any GCS memory effects from the outgoing vCPU are
> + * visible elsewhere, nested guests transitioning ELs do not
> + * need this.
> + */
> + if (kvm_has_gcs(vcpu->kvm) &&
> + !vcpu_get_flag(vcpu, IN_NESTED_ERET) &&
> + !vcpu_get_flag(vcpu, IN_NESTED_EXCEPTION))
> + gcsb_dsync();
> +
> vcpu_put_mmu(vcpu);
> }
>
> @@ -836,6 +846,14 @@ static void nvhe_vcpu_put(struct kvm_vcpu *vcpu)
> kvm_timer_vcpu_put(vcpu);
> kvm_vgic_put(vcpu);
> kvm_vcpu_pmu_restore_host(vcpu);
> +
> + /*
> + * Ensure any GCS memory effects from the outgoing vCPU are
> + * visible elsewhere.
> + */
> + if (kvm_has_gcs(vcpu->kvm))
> + gcsb_dsync();
> +
> vcpu_put_mmu(vcpu);
> }
>
> diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-main.c b/arch/arm64/kvm/hyp/nvhe/hyp-main.c
> index 0c023ee0cf42a..18030dd0dc0af 100644
> --- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c
> +++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c
> @@ -871,6 +871,13 @@ DEFINE_KVM_HOST_HCALL0(void, __pkvm_vcpu_put)
> sync_hyp_vcpu_state(hyp_vcpu);
> }
>
> + /*
> + * Ensure any GCS memory effects from the outgoing vCPU are
> + * visible elsewhere even if the host skips syncing.
> + */
> + if (kvm_has_gcs(hyp_vcpu->vcpu.kvm))
> + gcsb_dsync();
> +
> pkvm_put_hyp_vcpu(hyp_vcpu);
> }
> }
[Severity: Medium]
Should vhe_vcpu_load(), nvhe_vcpu_load(), and __pkvm_vcpu_load() also
issue gcsb_dsync() for incoming GCS-enabled vCPUs?
As noted in gcs_thread_switch(), making GCS memory effects visible across
PEs on migration requires gcsb_dsync() on both sides of the switch: on
the outgoing PE to order prior GCS memory effects before release memory
accesses, and on the incoming PE to order acquire memory accesses before
subsequent GCS memory effects:
arch/arm64/kernel/process.c:gcs_thread_switch() {
/*
* Ensure that GCS memory effects of the 'prev' thread are
* ordered before other memory accesses with release semantics
* (or preceded by a DMB) on the current PE. In addition, any
* memory accesses with acquire semantics (or succeeded by a
* DMB) are ordered before GCS memory effects of the 'next'
* thread. This will ensure that the GCS memory effects are
* visible to other PEs in case of migration.
*/
if (task_gcs_el0_enabled(current) || task_gcs_el0_enabled(next))
gcsb_dsync();
}
Because the host VMM thread running the vCPU may not have host EL0 GCS
enabled, migrating the vCPU thread to another PE will not trigger
gcsb_dsync() in gcs_thread_switch() on the destination PE, leaving the
migrated guest vCPU able to observe stale GCS memory.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261130-arm64-gcs-v22-0-80454edf47ea@kernel.org?part=4
next prev parent reply other threads:[~2026-11-30 17:03 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 16:35 [PATCH v22 00/16] KVM: arm64: Provide guest support for GCS Mark Brown
2026-11-30 16:35 ` [PATCH v22 01/16] arm64/gcs: Ensure FGTs for EL1 GCS instructions are disabled Mark Brown
2026-11-30 16:35 ` [PATCH v22 02/16] KVM: arm64: Drop the SPSR_EL1 and ELR_EL1 trap accessors Mark Brown
2026-11-30 16:35 ` [PATCH v22 03/16] KVM: arm64: Manage GCS access and registers for guests Mark Brown
2026-11-30 16:49 ` Leonardo Bras
2026-11-30 16:59 ` Mark Brown
2026-11-30 16:35 ` [PATCH v22 04/16] KVM: arm64: Ensure GCS memory effects are visible Mark Brown
2026-11-30 17:03 ` sashiko-bot [this message]
2026-11-30 16:35 ` [PATCH v22 05/16] KVM: arm64: Set PSTATE.EXLOCK when entering an exception Mark Brown
2026-11-30 16:35 ` [PATCH v22 06/16] KVM: arm64: Validate GCS exception lock when emulating ERET Mark Brown
2026-11-30 16:35 ` [PATCH v22 07/16] KVM: arm64: Forward GCS exceptions to nested guests Mark Brown
2026-11-30 17:05 ` sashiko-bot
2026-11-30 16:35 ` [PATCH v22 08/16] KVM: arm64: Preserve ISS2.GCS when injecting a Data Abort Mark Brown
2026-11-30 16:35 ` [PATCH v22 09/16] KVM: arm64: Fully implement GCS in the stage-1 walker Mark Brown
2026-11-30 16:35 ` [PATCH v22 10/16] KVM: arm64: Allow GCS to be enabled for guests Mark Brown
2026-11-30 17:16 ` sashiko-bot
2026-11-30 16:35 ` [PATCH v22 11/16] KVM: selftests: arm64: Check invalid feature combination handling Mark Brown
2026-11-30 16:35 ` [PATCH v22 12/16] KVM: selftests: arm64: Add GCS registers to get-reg-list Mark Brown
2026-11-30 16:35 ` [PATCH v22 13/16] KVM: selftests: arm64: Add GCS to set_id_regs Mark Brown
2026-11-30 16:35 ` [PATCH v22 14/16] KVM: selftests: arm64: Only restore SPSR_EL1 and ELR_EL1 if they change Mark Brown
2026-11-30 16:35 ` [PATCH v22 15/16] tools: Synchronise the kernel esr.h Mark Brown
2026-11-30 16:35 ` [PATCH v22 16/16] KVM: selftests: arm64: Add GCS EXLOCK exception emulation test 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=sashiko-outbox-241653@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=broonie@kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=maz@kernel.org \
--cc=oupton@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.