Skip to content

Commit 380ac2b

Browse files
davidhildenbrandhuth
authored andcommitted
s390x/mmu_helper: avoid setting the storage key if nothing changed
Avoid setting the key if nothing changed. Signed-off-by: David Hildenbrand <[email protected]> Reviewed-by: Thomas Huth <[email protected]> Message-Id: <[email protected]> Signed-off-by: Thomas Huth <[email protected]>
1 parent 390191c commit 380ac2b

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

target/s390x/mmu_helper.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ static void mmu_handle_skey(target_ulong addr, int rw, int *flags)
301301
{
302302
static S390SKeysClass *skeyclass;
303303
static S390SKeysState *ss;
304-
uint8_t key;
304+
uint8_t key, old_key;
305305
int rc;
306306

307307
/*
@@ -337,6 +337,7 @@ static void mmu_handle_skey(target_ulong addr, int rw, int *flags)
337337
trace_get_skeys_nonzero(rc);
338338
return;
339339
}
340+
old_key = key;
340341

341342
switch (rw) {
342343
case MMU_DATA_LOAD:
@@ -360,9 +361,11 @@ static void mmu_handle_skey(target_ulong addr, int rw, int *flags)
360361
/* Any store/fetch sets the reference bit */
361362
key |= SK_R;
362363

363-
rc = skeyclass->set_skeys(ss, addr / TARGET_PAGE_SIZE, 1, &key);
364-
if (rc) {
365-
trace_set_skeys_nonzero(rc);
364+
if (key != old_key) {
365+
rc = skeyclass->set_skeys(ss, addr / TARGET_PAGE_SIZE, 1, &key);
366+
if (rc) {
367+
trace_set_skeys_nonzero(rc);
368+
}
366369
}
367370
}
368371

0 commit comments

Comments
 (0)