All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] target/s390x: Fix VSTL with a large length
@ 2023-08-04 23:55 Ilya Leoshkevich
  2023-08-04 23:55 ` [PATCH 2/2] tests/tcg/s390x: Test VSTL Ilya Leoshkevich
  2023-08-05  7:58 ` [PATCH 1/2] target/s390x: Fix VSTL with a large length David Hildenbrand
  0 siblings, 2 replies; 3+ messages in thread
From: Ilya Leoshkevich @ 2023-08-04 23:55 UTC (permalink / raw)
  To: Richard Henderson, David Hildenbrand, Thomas Huth
  Cc: qemu-devel, qemu-s390x, Ilya Leoshkevich, qemu-stable

The length is always truncated to 16 bytes. Do not probe more than
that.

Cc: qemu-stable@nongnu.org
Fixes: 0e0a5b49ad58 ("s390x/tcg: Implement VECTOR STORE WITH LENGTH")
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
 target/s390x/tcg/vec_helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/s390x/tcg/vec_helper.c b/target/s390x/tcg/vec_helper.c
index 48d86722b2d..dafc4c3582c 100644
--- a/target/s390x/tcg/vec_helper.c
+++ b/target/s390x/tcg/vec_helper.c
@@ -193,7 +193,7 @@ void HELPER(vstl)(CPUS390XState *env, const void *v1, uint64_t addr,
                   uint64_t bytes)
 {
     /* Probe write access before actually modifying memory */
-    probe_write_access(env, addr, bytes, GETPC());
+    probe_write_access(env, addr, MIN(bytes, 16), GETPC());
 
     if (likely(bytes >= 16)) {
         cpu_stq_data_ra(env, addr, s390_vec_read_element64(v1, 0), GETPC());
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] tests/tcg/s390x: Test VSTL
  2023-08-04 23:55 [PATCH 1/2] target/s390x: Fix VSTL with a large length Ilya Leoshkevich
@ 2023-08-04 23:55 ` Ilya Leoshkevich
  2023-08-05  7:58 ` [PATCH 1/2] target/s390x: Fix VSTL with a large length David Hildenbrand
  1 sibling, 0 replies; 3+ messages in thread
From: Ilya Leoshkevich @ 2023-08-04 23:55 UTC (permalink / raw)
  To: Richard Henderson, David Hildenbrand, Thomas Huth
  Cc: qemu-devel, qemu-s390x, Ilya Leoshkevich

Add a small test to prevent regressions.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
 tests/tcg/s390x/Makefile.target |  1 +
 tests/tcg/s390x/vstl.c          | 37 +++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+)
 create mode 100644 tests/tcg/s390x/vstl.c

diff --git a/tests/tcg/s390x/Makefile.target b/tests/tcg/s390x/Makefile.target
index 649c1e520e6..e3e22c6f7e3 100644
--- a/tests/tcg/s390x/Makefile.target
+++ b/tests/tcg/s390x/Makefile.target
@@ -60,6 +60,7 @@ Z13_TESTS=vistr
 Z13_TESTS+=lcbb
 Z13_TESTS+=locfhr
 Z13_TESTS+=vcksm
+Z13_TESTS+=vstl
 $(Z13_TESTS): CFLAGS+=-march=z13 -O2
 TESTS+=$(Z13_TESTS)
 
diff --git a/tests/tcg/s390x/vstl.c b/tests/tcg/s390x/vstl.c
new file mode 100644
index 00000000000..bece952c7ee
--- /dev/null
+++ b/tests/tcg/s390x/vstl.c
@@ -0,0 +1,37 @@
+/*
+ * Test the VSTL instruction.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#include <assert.h>
+#include <stdlib.h>
+#include "vx.h"
+
+static inline void vstl(S390Vector *v1, void *db2, size_t r3)
+{
+    asm("vstl %[v1],%[r3],%[db2]"
+        : [db2] "=Q" (*(char *)db2)
+        : [v1] "v" (v1->v), [r3] "r" (r3)
+        : "memory");
+}
+
+int main(void)
+{
+    uint64_t buf[3] = {0x1122334455667788ULL, 0x99aabbccddeeffULL,
+                       0x5a5a5a5a5a5a5a5aULL};
+    S390Vector v = {.d[0] = 0x1234567887654321ULL,
+                    .d[1] = 0x9abcdef00fedcba9ULL};
+
+    vstl(&v, buf, 0);
+    assert(buf[0] == 0x1222334455667788ULL);
+
+    vstl(&v, buf, 1);
+    assert(buf[0] == 0x1234334455667788ULL);
+
+    vstl(&v, buf, -1);
+    assert(buf[0] == 0x1234567887654321ULL);
+    assert(buf[1] == 0x9abcdef00fedcba9ULL);
+    assert(buf[2] == 0x5a5a5a5a5a5a5a5aULL);
+
+    return EXIT_SUCCESS;
+}
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] target/s390x: Fix VSTL with a large length
  2023-08-04 23:55 [PATCH 1/2] target/s390x: Fix VSTL with a large length Ilya Leoshkevich
  2023-08-04 23:55 ` [PATCH 2/2] tests/tcg/s390x: Test VSTL Ilya Leoshkevich
@ 2023-08-05  7:58 ` David Hildenbrand
  1 sibling, 0 replies; 3+ messages in thread
From: David Hildenbrand @ 2023-08-05  7:58 UTC (permalink / raw)
  To: Ilya Leoshkevich, Richard Henderson, Thomas Huth
  Cc: qemu-devel, qemu-s390x, qemu-stable

On 05.08.23 01:55, Ilya Leoshkevich wrote:
> The length is always truncated to 16 bytes. Do not probe more than
> that.
> 
> Cc: qemu-stable@nongnu.org
> Fixes: 0e0a5b49ad58 ("s390x/tcg: Implement VECTOR STORE WITH LENGTH")
> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
> ---
>   target/s390x/tcg/vec_helper.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/target/s390x/tcg/vec_helper.c b/target/s390x/tcg/vec_helper.c
> index 48d86722b2d..dafc4c3582c 100644
> --- a/target/s390x/tcg/vec_helper.c
> +++ b/target/s390x/tcg/vec_helper.c
> @@ -193,7 +193,7 @@ void HELPER(vstl)(CPUS390XState *env, const void *v1, uint64_t addr,
>                     uint64_t bytes)
>   {
>       /* Probe write access before actually modifying memory */
> -    probe_write_access(env, addr, bytes, GETPC());
> +    probe_write_access(env, addr, MIN(bytes, 16), GETPC());
>   
>       if (likely(bytes >= 16)) {
>           cpu_stq_data_ra(env, addr, s390_vec_read_element64(v1, 0), GETPC());

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 
Cheers,

David / dhildenb



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-08-05  7:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-04 23:55 [PATCH 1/2] target/s390x: Fix VSTL with a large length Ilya Leoshkevich
2023-08-04 23:55 ` [PATCH 2/2] tests/tcg/s390x: Test VSTL Ilya Leoshkevich
2023-08-05  7:58 ` [PATCH 1/2] target/s390x: Fix VSTL with a large length David Hildenbrand

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.