Patchwork [4/5] s390x: implement rrbe instruction properly

login
register
mail settings
Submitter Alexander Graf
Date July 13, 2011, 2:44 a.m.
Message ID <1310525052-22530-5-git-send-email-agraf@suse.de>
Download mbox | patch
Permalink /patch/104652/
State New
Headers show

Comments

Alexander Graf - July 13, 2011, 2:44 a.m.
The rrbe instruction resets the reference bit in the given storage key.
So far, we merely made it a nop and also returned an invalid CC value,
so that the kernel never knew if a page actually got accessed.

This patch implements it properly, flushing the R bit and returning the
correct CC value.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 target-s390x/op_helper.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

Patch

diff --git a/target-s390x/op_helper.c b/target-s390x/op_helper.c
index 7583172..356eac8 100644
--- a/target-s390x/op_helper.c
+++ b/target-s390x/op_helper.c
@@ -2778,14 +2778,15 @@  void HELPER(sske)(uint32_t r1, uint64_t r2)
 /* reset reference bit extended */
 uint32_t HELPER(rrbe)(uint32_t r1, uint64_t r2)
 {
+    uint8_t re;
+    uint8_t key;
     if (r2 > ram_size) {
         return 0;
     }
 
-    /* XXX implement */
-#if 0
-    env->storage_keys[r2 / TARGET_PAGE_SIZE] &= ~SK_REFERENCED;
-#endif
+    key = env->storage_keys[r2 / TARGET_PAGE_SIZE];
+    re = key & (SK_R | SK_C);
+    env->storage_keys[r2 / TARGET_PAGE_SIZE] = (key & ~SK_R);
 
     /*
      * cc
@@ -2795,7 +2796,8 @@  uint32_t HELPER(rrbe)(uint32_t r1, uint64_t r2)
      * 2  Reference bit one; change bit zero
      * 3  Reference bit one; change bit one
      */
-    return 0;
+
+    return re >> 1;
 }
 
 /* compare and swap and purge */