]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
s390x: Fix PRNO for SHA-512-DRNG generate
authorAndreas Arnez <arnez@linux.ibm.com>
Wed, 10 Jul 2024 16:47:07 +0000 (18:47 +0200)
committerAndreas Arnez <arnez@linux.ibm.com>
Wed, 10 Jul 2024 16:47:07 +0000 (18:47 +0200)
In the implementation of PRNO, when handling the "SHA-512-DRNG generate"
operation, the updated length is written back to the wrong register.
Also, while the instruction fills the output buffer from right-to-left,
the memory tracking is done as if it were the other way around.  Fix both
of these issues.

coregrind/m_extension/extension-s390x.c

index 95116587c5216257cc3f226f765499c8f10ae9d2..e94e7933c85407206187dc32d2f5217c8dca2ea5 100644 (file)
@@ -183,8 +183,9 @@ static enum ExtensionError do_extension_PRNO(ThreadState* tst, ULong variant)
       cc = do_PRNO_insn(func, parms, &addr1, &len1, &addr2, &len2);
       POST_MEM_WRITE(tst, parms, parms_len);
       if (mflag == 0) {
-         WRITE_GPR(tst, r2 + 1, len1);
-         POST_MEM_WRITE(tst, orig_addr1, orig_len1 - len1);
+         WRITE_GPR(tst, r1 + 1, len1);
+         // The operand is filled from right to left
+         POST_MEM_WRITE(tst, orig_addr1 + len1, orig_len1 - len1);
       }
       break;
    case 114: // TRNG