Re: [PATCH v2 5/9] KVM: s390: Fix pgste_get_trylock_multiple()

From: Christoph Schlameuss

Date: Wed Aug 12 2026 - 07:16:41 EST


On Wed Aug 12, 2026 at 12:44 PM CEST, Claudio Imbrenda wrote:
> In case of failure, pgste_get_trylock_multiple() will attempt to unlock
> the locked PGSTEs based on whether the PCL is set. In some
> circumstances this can lead to unlocking PGSTEs that were locked by
> other threads.
>
> Fix by unlocking the amount of PGSTEs that were actually locked,
> ignoring the PCL bit in the array.
>
> Fixes: 94fd9b16cc67 ("KVM: s390: KVM page table management functions: lifecycle management")
> Signed-off-by: Claudio Imbrenda <imbrenda@xxxxxxxxxxxxx>
> Reviewed-by: Christian Borntraeger <borntraeger@xxxxxxxxxxxxx>

Reviewed-by: Christoph Schlameuss <schlameuss@xxxxxxxxxxxxx>

> ---
> arch/s390/kvm/dat.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/arch/s390/kvm/dat.c b/arch/s390/kvm/dat.c
> index 165c704fcf29..f4dd6f783417 100644
> --- a/arch/s390/kvm/dat.c
> +++ b/arch/s390/kvm/dat.c
> @@ -923,11 +923,8 @@ static void pgste_set_unlock_multiple(union pte *first, int n, union pgste *pgst
> {
> int i;
>
> - for (i = 0; i < n; i++) {
> - if (!pgstes[i].pcl)
> - break;
> + for (i = 0; i < n; i++)
> pgste_set_unlock(first + i, pgstes[i]);
> - }
> }
>
> static bool pgste_get_trylock_multiple(union pte *first, int n, union pgste *pgstes)
> @@ -940,7 +937,7 @@ static bool pgste_get_trylock_multiple(union pte *first, int n, union pgste *pgs
> }
> if (i == n)
> return true;
> - pgste_set_unlock_multiple(first, n, pgstes);
> + pgste_set_unlock_multiple(first, i, pgstes);
> return false;
> }
>