KVM: s390: Fix pgste_get_trylock_multiple()

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: 94fd9b16cc ("KVM: s390: KVM page table management functions: lifecycle management")
Reviewed-by: Christian Borntraeger <borntraeger@linux.ibm.com>
Reviewed-by: Christoph Schlameuss <schlameuss@linux.ibm.com>
Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Message-ID: <20260812104436.109741-6-imbrenda@linux.ibm.com>
This commit is contained in:
Claudio Imbrenda 2026-08-12 12:44:32 +02:00
parent ae50d47222
commit b5a941112f

View File

@ -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;
}