Commit 19b0bc62 authored by Rocky Automation's avatar Rocky Automation 📺
Browse files

import valgrind-3.16.0-4.el8

parent 3f0e3c4a
commit e2dec0ff9b1e071779bee2c4e6fc82f8194b1c1d
Author: Mark Wielaard <mark@klomp.org>
Date: Sun Jul 26 21:17:23 2020 +0200
Handle REX prefixed JMP instruction.
The NET Core runtime might generate a JMP with a REX prefix.
For Jv (32bit offset) and Jb (8bit offset) this is valid.
Prefixes that change operand size are ignored for such JMPs.
So remove the check for sz == 4 and force sz = 4 for Jv.
https://bugs.kde.org/show_bug.cgi?id=422174
diff --git a/VEX/priv/guest_amd64_toIR.c b/VEX/priv/guest_amd64_toIR.c
index fadf47d41..7888132eb 100644
--- a/VEX/priv/guest_amd64_toIR.c
+++ b/VEX/priv/guest_amd64_toIR.c
@@ -21392,8 +21392,8 @@ Long dis_ESC_NONE (
case 0xE9: /* Jv (jump, 16/32 offset) */
if (haveF3(pfx)) goto decode_failure;
- if (sz != 4)
- goto decode_failure; /* JRS added 2004 July 11 */
+ sz = 4; /* Prefixes that change operand size are ignored for this
+ instruction. Operand size is forced to 32bit. */
if (haveF2(pfx)) DIP("bnd ; "); /* MPX bnd prefix. */
d64 = (guest_RIP_bbstart+delta+sz) + getSDisp(sz,delta);
delta += sz;
@@ -21404,8 +21404,7 @@ Long dis_ESC_NONE (
case 0xEB: /* Jb (jump, byte offset) */
if (haveF3(pfx)) goto decode_failure;
- if (sz != 4)
- goto decode_failure; /* JRS added 2004 July 11 */
+ /* Prefixes that change operand size are ignored for this instruction. */
if (haveF2(pfx)) DIP("bnd ; "); /* MPX bnd prefix. */
d64 = (guest_RIP_bbstart+delta+1) + getSDisp8(delta);
delta++;
commit f4abcc05fdba3f25890a9b30b71d511ccc906d46
Author: Mark Wielaard <mark@klomp.org>
Date: Mon Jul 27 22:43:28 2020 +0200
Incorrect call-graph tracking due to new _dl_runtime_resolve_xsave*
Newer glibc have alternate ld.so _ld_runtime_resolve functions.
Namely _dl_runtime_resolve_xsave and _dl_runtime_resolve_xsave'2
This patch recognizes the xsave, xsvec and fxsave variants and
changes callgrind so that any variant counts as _dl_runtime_resolve.
Original patch by paulo.cesar.pereira.de.andrade@gmail.com
https://bugs.kde.org/show_bug.cgi?id=415293
diff --git a/callgrind/fn.c b/callgrind/fn.c
index e9d8dd214..7cce1a0c7 100644
--- a/callgrind/fn.c
+++ b/callgrind/fn.c
@@ -30,8 +30,11 @@
static fn_array current_fn_active;
-static Addr runtime_resolve_addr = 0;
-static int runtime_resolve_length = 0;
+/* x86_64 defines 4 variants. */
+#define MAX_RESOLVE_ADDRS 4
+static int runtime_resolve_addrs = 0;
+static Addr runtime_resolve_addr[MAX_RESOLVE_ADDRS];
+static int runtime_resolve_length[MAX_RESOLVE_ADDRS];
// a code pattern is a list of tuples (start offset, length)
struct chunk_t { int start, len; };
@@ -56,6 +59,9 @@ static Bool check_code(obj_node* obj,
/* first chunk of pattern should always start at offset 0 and
* have at least 3 bytes */
CLG_ASSERT((pat->chunk[0].start == 0) && (pat->chunk[0].len >2));
+
+ /* and we cannot be called more than MAX_RESOLVE_ADDRS times */
+ CLG_ASSERT(runtime_resolve_addrs < MAX_RESOLVE_ADDRS);
CLG_DEBUG(1, "check_code: %s, pattern %s, check %d bytes of [%x %x %x...]\n",
obj->name, pat->name, pat->chunk[0].len, code[0], code[1], code[2]);
@@ -93,8 +99,9 @@ static Bool check_code(obj_node* obj,
pat->name, obj->name + obj->last_slash_pos,
addr - obj->start, addr, pat->len);
- runtime_resolve_addr = addr;
- runtime_resolve_length = pat->len;
+ runtime_resolve_addr[runtime_resolve_addrs] = addr;
+ runtime_resolve_length[runtime_resolve_addrs] = pat->len;
+ runtime_resolve_addrs++;
return True;
}
}
@@ -138,8 +145,9 @@ static Bool search_runtime_resolve(obj_node* obj)
"x86-glibc2.8", 30, {{ 0,12 }, { 16,14 }, { 30,0}} };
if (VG_(strncmp)(obj->name, "/lib/ld", 7) != 0) return False;
- if (check_code(obj, code, &pat)) return True;
- if (check_code(obj, code_28, &pat_28)) return True;
+ Bool pat_p = check_code(obj, code, &pat);
+ Bool pat_28_p = check_code(obj, code_28, &pat_28);
+ if (pat_p || pat_28_p) return True;
return False;
#endif
@@ -186,9 +194,98 @@ static Bool search_runtime_resolve(obj_node* obj)
static struct pattern pat = {
"amd64-def", 110, {{ 0,62 }, { 66,44 }, { 110,0 }} };
+ static UChar code_xsavec[] = {
+ /* 0*/ 0x53, 0x48, 0x89, 0xe3, 0x48, 0x83, 0xe4, 0xc0,
+ /* 8*/ 0x48, 0x2b, 0x25, 0x00, 0x00, 0x00, 0x00, /* sub <i32>(%rip),%rsp */
+ /*15*/ 0x48,
+ /*16*/ 0x89, 0x04, 0x24, 0x48, 0x89, 0x4c, 0x24, 0x08,
+ /*24*/ 0x48, 0x89, 0x54, 0x24, 0x10, 0x48, 0x89, 0x74,
+ /*32*/ 0x24, 0x18, 0x48, 0x89, 0x7c, 0x24, 0x20, 0x4c,
+ /*40*/ 0x89, 0x44, 0x24, 0x28, 0x4c, 0x89, 0x4c, 0x24,
+ /*48*/ 0x30, 0xb8, 0xee, 0x00, 0x00, 0x00, 0x31, 0xd2,
+ /*56*/ 0x48, 0x89, 0x94, 0x24, 0x50, 0x02, 0x00, 0x00,
+ /*64*/ 0x48, 0x89, 0x94, 0x24, 0x58, 0x02, 0x00, 0x00,
+ /*72*/ 0x48, 0x89, 0x94, 0x24, 0x60, 0x02, 0x00, 0x00,
+ /*80*/ 0x48, 0x89, 0x94, 0x24, 0x68, 0x02, 0x00, 0x00,
+ /*88*/ 0x48, 0x89, 0x94, 0x24, 0x70, 0x02, 0x00, 0x00,
+ /*96*/ 0x48, 0x89, 0x94, 0x24, 0x78, 0x02, 0x00, 0x00,
+ /*04*/ 0x0f, 0xc7, 0x64, 0x24, 0x40, 0x48, 0x8b, 0x73,
+ /*112*/0x10, 0x48, 0x8b, 0x7b, 0x08,
+ /*117*/0xe8, 0x00, 0x00, 0x00, 0x00, /* callq <_dl_fixup> */
+ /*122*/0x49, 0x89, 0xc3, 0xb8, 0xee, 0x00,
+ /*128*/0x00, 0x00, 0x31, 0xd2, 0x0f, 0xae, 0x6c, 0x24,
+ /*136*/0x40, 0x4c, 0x8b, 0x4c, 0x24, 0x30, 0x4c, 0x8b,
+ /*144*/0x44, 0x24, 0x28, 0x48, 0x8b, 0x7c, 0x24, 0x20,
+ /*152*/0x48, 0x8b, 0x74, 0x24, 0x18, 0x48, 0x8b, 0x54,
+ /*160*/0x24, 0x10, 0x48, 0x8b, 0x4c, 0x24, 0x08, 0x48,
+ /*168*/0x8b, 0x04, 0x24, 0x48, 0x89, 0xdc, 0x48, 0x8b,
+ /*176*/0x1c, 0x24, 0x48, 0x83, 0xc4, 0x18, 0xf2, 0x41,
+ /*184*/0xff, 0xe3 };
+ static struct pattern pat_xsavec = {
+ "amd64-xsavec", 186, {{ 0,11 }, { 15,103 }, {122,64}, { 186,0 }} };
+
+ static UChar code_xsave[] = {
+ /* 0*/ 0x53, 0x48, 0x89, 0xe3, 0x48, 0x83, 0xe4, 0xc0,
+ /* 8*/ 0x48, 0x2b, 0x25, 0x00, 0x00, 0x00, 0x00, /* sub <i32>(%rip),%rsp */
+ /*15*/ 0x48,
+ /*16*/ 0x89, 0x04, 0x24, 0x48, 0x89, 0x4c, 0x24, 0x08,
+ /*24*/ 0x48, 0x89, 0x54, 0x24, 0x10, 0x48, 0x89, 0x74,
+ /*32*/ 0x24, 0x18, 0x48, 0x89, 0x7c, 0x24, 0x20, 0x4c,
+ /*40*/ 0x89, 0x44, 0x24, 0x28, 0x4c, 0x89, 0x4c, 0x24,
+ /*48*/ 0x30, 0xb8, 0xee, 0x00, 0x00, 0x00, 0x31, 0xd2,
+ /*56*/ 0x48, 0x89, 0x94, 0x24, 0x40, 0x02, 0x00, 0x00,
+ /*64*/ 0x48, 0x89, 0x94, 0x24, 0x48, 0x02, 0x00, 0x00,
+ /*72*/ 0x48, 0x89, 0x94, 0x24, 0x50, 0x02, 0x00, 0x00,
+ /*80*/ 0x48, 0x89, 0x94, 0x24, 0x58, 0x02, 0x00, 0x00,
+ /*88*/ 0x48, 0x89, 0x94, 0x24, 0x60, 0x02, 0x00, 0x00,
+ /*96*/ 0x48, 0x89, 0x94, 0x24, 0x68, 0x02, 0x00, 0x00,
+ /*104*/0x48, 0x89, 0x94, 0x24, 0x70, 0x02, 0x00, 0x00,
+ /*112*/0x48, 0x89, 0x94, 0x24, 0x78, 0x02, 0x00, 0x00,
+ /*120*/0x0f, 0xae, 0x64, 0x24, 0x40, 0x48, 0x8b, 0x73,
+ /*128*/0x10, 0x48, 0x8b, 0x7b, 0x08,
+ /*133*/0xe8, 0x00, 0x00, 0x00, 0x00, /* callq <_dl_fixup> */
+ /*138*/0x49, 0x89, 0xc3, 0xb8, 0xee, 0x00,
+ /*144*/0x00, 0x00, 0x31, 0xd2, 0x0f, 0xae, 0x6c, 0x24,
+ /*152*/0x40, 0x4c, 0x8b, 0x4c, 0x24, 0x30, 0x4c, 0x8b,
+ /*160*/0x44, 0x24, 0x28, 0x48, 0x8b, 0x7c, 0x24, 0x20,
+ /*168*/0x48, 0x8b, 0x74, 0x24, 0x18, 0x48, 0x8b, 0x54,
+ /*176*/0x24, 0x10, 0x48, 0x8b, 0x4c, 0x24, 0x08, 0x48,
+ /*184*/0x8b, 0x04, 0x24, 0x48, 0x89, 0xdc, 0x48, 0x8b,
+ /*192*/0x1c, 0x24, 0x48, 0x83, 0xc4, 0x18, 0xf2, 0x41,
+ /*200*/0xff, 0xe3 };
+ static struct pattern pat_xsave = {
+ "amd64-xsave", 202, {{ 0,11 }, { 15,119 }, {138,64}, { 202,0 }} };
+
+ static UChar code_fxsave[] = {
+ /* 0*/ 0x53, 0x48, 0x89, 0xe3, 0x48, 0x83, 0xe4, 0xf0,
+ /* 8*/ 0x48, 0x81, 0xec, 0x40, 0x02, 0x00, 0x00, 0x48,
+ /*16*/ 0x89, 0x04, 0x24, 0x48, 0x89, 0x4c, 0x24, 0x08,
+ /*24*/ 0x48, 0x89, 0x54, 0x24, 0x10, 0x48, 0x89, 0x74,
+ /*32*/ 0x24, 0x18, 0x48, 0x89, 0x7c, 0x24, 0x20, 0x4c,
+ /*40*/ 0x89, 0x44, 0x24, 0x28, 0x4c, 0x89, 0x4c, 0x24,
+ /*48*/ 0x30, 0x0f, 0xae, 0x44, 0x24, 0x40, 0x48, 0x8b,
+ /*56*/ 0x73, 0x10, 0x48, 0x8b, 0x7b, 0x08,
+ /*62*/ 0xe8, 0x00, 0x00, 0x00, 0x00, /* callq <_dl_fixup> */
+ /*67*/ 0x49, 0x89, 0xc3, 0x0f, 0xae,
+ /*72*/ 0x4c, 0x24, 0x40, 0x4c, 0x8b, 0x4c, 0x24, 0x30,
+ /*80*/ 0x4c, 0x8b, 0x44, 0x24, 0x28, 0x48, 0x8b, 0x7c,
+ /*88*/ 0x24, 0x20, 0x48, 0x8b, 0x74, 0x24, 0x18, 0x48,
+ /*96*/ 0x8b, 0x54, 0x24, 0x10, 0x48, 0x8b, 0x4c, 0x24,
+ /*104*/0x08, 0x48, 0x8b, 0x04, 0x24, 0x48, 0x89, 0xdc,
+ /*112*/0x48, 0x8b, 0x1c, 0x24, 0x48, 0x83, 0xc4, 0x18,
+ /*120*/0xf2, 0x41, 0xff, 0xe3 };
+ static struct pattern pat_fxsave = {
+ "amd64-fxsave", 124, {{ 0,63 }, { 67,57 }, { 124,0 }} };
+
if ((VG_(strncmp)(obj->name, "/lib/ld", 7) != 0) &&
- (VG_(strncmp)(obj->name, "/lib64/ld", 9) != 0)) return False;
- return check_code(obj, code, &pat);
+ (VG_(strncmp)(obj->name, "/lib64/ld", 9) != 0) &&
+ (VG_(strncmp)(obj->name, "/usr/lib/ld", 11) != 0) &&
+ (VG_(strncmp)(obj->name, "/usr/lib64/ld", 13) != 0)) return False;
+ Bool pat_p = check_code(obj, code, &pat);
+ Bool pat_xsavec_p = check_code(obj, code_xsavec, &pat_xsavec);
+ Bool pat_xsave_p = check_code(obj, code_xsave, &pat_xsave);
+ Bool pat_fxsave_p = check_code(obj, code_fxsave, &pat_fxsave);
+ if (pat_p || pat_xsavec_p || pat_xsave_p || pat_fxsave_p) return True;
#endif
/* For other platforms, no patterns known */
@@ -254,7 +351,7 @@ obj_node* new_obj_node(DebugInfo* di, obj_node* next)
i++;
}
- if (runtime_resolve_addr == 0) search_runtime_resolve(obj);
+ if (runtime_resolve_addrs == 0) search_runtime_resolve(obj);
return obj;
}
@@ -490,6 +587,7 @@ fn_node* CLG_(get_fn_node)(BB* bb)
DebugInfo* di;
UInt line_num;
fn_node* fn;
+ Int i;
/* fn from debug info is idempotent for a BB */
if (bb->fn) return bb->fn;
@@ -538,12 +636,14 @@ fn_node* CLG_(get_fn_node)(BB* bb)
}
if (0 == VG_(strcmp)(fnname, "_exit") && !exit_bb)
exit_bb = bb;
-
- if (runtime_resolve_addr &&
- (bb_addr(bb) >= runtime_resolve_addr) &&
- (bb_addr(bb) < runtime_resolve_addr + runtime_resolve_length)) {
- /* BB in runtime_resolve found by code check; use this name */
- fnname = "_dl_runtime_resolve";
+
+ for (i = 0; i < runtime_resolve_addrs; i++) {
+ if ((bb_addr(bb) >= runtime_resolve_addr[i]) &&
+ (bb_addr(bb) < runtime_resolve_addr[i] + runtime_resolve_length[i])) {
+ /* BB in runtime_resolve found by code check; use this name */
+ fnname = "_dl_runtime_resolve";
+ break;
+ }
}
/* get fn_node struct for this function */
commit f326d68d762edf4b0e9604daa446b6f8ca25725a
Author: Mark Wielaard <mark@klomp.org>
Date: Sun Jul 26 22:40:22 2020 +0200
epoll_ctl warns for uninitialized padding on non-amd64 64bit arches
struct vki_epoll_event is packed on x86_64, but not on other 64bit
arches. This means that on 64bit arches there can be padding in the
epoll_event struct. Seperately the data field is only used by user
space (which might not set the data field if it doesn't need to).
Only check the events field on epoll_ctl. But assume both events
and data are both written to by epoll_[p]wait (exclude padding).
https://bugs.kde.org/show_bug.cgi?id=422623
diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c
index 5b5b7eee6..929a4d9af 100644
--- a/coregrind/m_syswrap/syswrap-linux.c
+++ b/coregrind/m_syswrap/syswrap-linux.c
@@ -2099,8 +2099,29 @@ PRE(sys_epoll_ctl)
SARG1, ( ARG2<3 ? epoll_ctl_s[ARG2] : "?" ), SARG3, ARG4);
PRE_REG_READ4(long, "epoll_ctl",
int, epfd, int, op, int, fd, struct vki_epoll_event *, event);
- if (ARG2 != VKI_EPOLL_CTL_DEL)
- PRE_MEM_READ( "epoll_ctl(event)", ARG4, sizeof(struct vki_epoll_event) );
+ if (ARG2 != VKI_EPOLL_CTL_DEL) {
+ /* Just check the events field, the data field is for user space and
+ unused by the kernel. */
+ struct vki_epoll_event *event = (struct vki_epoll_event *) ARG4;
+ PRE_MEM_READ( "epoll_ctl(event)", (Addr) &event->events,
+ sizeof(__vki_u32) );
+ }
+}
+
+/* RES event records have been written (exclude padding). */
+static void epoll_post_helper ( ThreadId tid, SyscallArgs* arrghs,
+ SyscallStatus* status )
+{
+ vg_assert(SUCCESS);
+ if (RES > 0) {
+ Int i;
+ struct vki_epoll_event **events = (struct vki_epoll_event**)(Addr)ARG2;
+ for (i = 0; i < RES; i++) {
+ /* Assume both events and data are set (data is user space only). */
+ POST_FIELD_WRITE(events[i]->events);
+ POST_FIELD_WRITE(events[i]->data);
+ }
+ }
}
PRE(sys_epoll_wait)
@@ -2111,13 +2132,12 @@ PRE(sys_epoll_wait)
PRE_REG_READ4(long, "epoll_wait",
int, epfd, struct vki_epoll_event *, events,
int, maxevents, int, timeout);
+ /* Assume all (maxevents) events records should be (fully) writable. */
PRE_MEM_WRITE( "epoll_wait(events)", ARG2, sizeof(struct vki_epoll_event)*ARG3);
}
POST(sys_epoll_wait)
{
- vg_assert(SUCCESS);
- if (RES > 0)
- POST_MEM_WRITE( ARG2, sizeof(struct vki_epoll_event)*RES ) ;
+ epoll_post_helper (tid, arrghs, status);
}
PRE(sys_epoll_pwait)
@@ -2130,15 +2150,14 @@ PRE(sys_epoll_pwait)
int, epfd, struct vki_epoll_event *, events,
int, maxevents, int, timeout, vki_sigset_t *, sigmask,
vki_size_t, sigsetsize);
+ /* Assume all (maxevents) events records should be (fully) writable. */
PRE_MEM_WRITE( "epoll_pwait(events)", ARG2, sizeof(struct vki_epoll_event)*ARG3);
if (ARG5)
PRE_MEM_READ( "epoll_pwait(sigmask)", ARG5, sizeof(vki_sigset_t) );
}
POST(sys_epoll_pwait)
{
- vg_assert(SUCCESS);
- if (RES > 0)
- POST_MEM_WRITE( ARG2, sizeof(struct vki_epoll_event)*RES ) ;
+ epoll_post_helper (tid, arrghs, status);
}
PRE(sys_eventfd)
commit b74f9f23c8758c77367f18368ea95baa858544cb
Author: Mark Wielaard <mark@klomp.org>
Date: Tue Aug 18 23:58:55 2020 +0200
Fix epoll_ctl setting of array event and data fields.
Fix for https://bugs.kde.org/show_bug.cgi?id=422623 in commit ecf5ba119
epoll_ctl warns for uninitialized padding on non-amd64 64bit arches
contained a bug. A pointer to an array is not a pointer to a pointer to
an array. Found by a Fedora user:
https://bugzilla.redhat.com/show_bug.cgi?id=1844778#c10
diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c
index 0850487e9..3f488795a 100644
--- a/coregrind/m_syswrap/syswrap-linux.c
+++ b/coregrind/m_syswrap/syswrap-linux.c
@@ -2115,11 +2115,11 @@ static void epoll_post_helper ( ThreadId tid, SyscallArgs* arrghs,
vg_assert(SUCCESS);
if (RES > 0) {
Int i;
- struct vki_epoll_event **events = (struct vki_epoll_event**)(Addr)ARG2;
+ struct vki_epoll_event *events = (struct vki_epoll_event*)(Addr)ARG2;
for (i = 0; i < RES; i++) {
/* Assume both events and data are set (data is user space only). */
- POST_FIELD_WRITE(events[i]->events);
- POST_FIELD_WRITE(events[i]->data);
+ POST_FIELD_WRITE(events[i].events);
+ POST_FIELD_WRITE(events[i].data);
}
}
}
commit ba73f8d2ebe4b5fe8163ee5ab806f0e50961ebdf
Author: Andreas Arnez <arnez@linux.ibm.com>
Date: Tue Nov 3 18:17:30 2020 +0100
Bug 428648 - s390x: Force 12-bit amode for vector loads in isel
Similar to Bug 417452, where the instruction selector sometimes attempted
to generate vector stores with a 20-bit displacement, the same problem has
now been reported with vector loads.
The problem is caused in s390_isel_vec_expr_wrk(), where the addressing
mode is generated with s390_isel_amode() instead of
s390_isel_amode_short(). This is fixed.
diff --git a/VEX/priv/host_s390_isel.c b/VEX/priv/host_s390_isel.c
index 2f80dd850..134f3eb6f 100644
--- a/VEX/priv/host_s390_isel.c
+++ b/VEX/priv/host_s390_isel.c
@@ -3741,7 +3741,7 @@ s390_isel_vec_expr_wrk(ISelEnv *env, IRExpr *expr)
/* --------- LOAD --------- */
case Iex_Load: {
HReg dst = newVRegV(env);
- s390_amode *am = s390_isel_amode(env, expr->Iex.Load.addr);
+ s390_amode *am = s390_isel_amode_short(env, expr->Iex.Load.addr);
if (expr->Iex.Load.end != Iend_BE)
goto irreducible;
diff --git a/VEX/priv/guest_s390_defs.h b/VEX/priv/guest_s390_defs.h
index 9f93cff19..905429015 100644
--- a/VEX/priv/guest_s390_defs.h
+++ b/VEX/priv/guest_s390_defs.h
@@ -8,7 +8,7 @@
This file is part of Valgrind, a dynamic binary instrumentation
framework.
- Copyright IBM Corp. 2010-2017
+ Copyright IBM Corp. 2010-2020
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -263,26 +263,27 @@ extern ULong last_execute_target;
before S390_VEC_OP_LAST. */
typedef enum {
S390_VEC_OP_INVALID = 0,
- S390_VEC_OP_VPKS = 1,
- S390_VEC_OP_VPKLS = 2,
- S390_VEC_OP_VFAE = 3,
- S390_VEC_OP_VFEE = 4,
- S390_VEC_OP_VFENE = 5,
- S390_VEC_OP_VISTR = 6,
- S390_VEC_OP_VSTRC = 7,
- S390_VEC_OP_VCEQ = 8,
- S390_VEC_OP_VTM = 9,
- S390_VEC_OP_VGFM = 10,
- S390_VEC_OP_VGFMA = 11,
- S390_VEC_OP_VMAH = 12,
- S390_VEC_OP_VMALH = 13,
- S390_VEC_OP_VCH = 14,
- S390_VEC_OP_VCHL = 15,
- S390_VEC_OP_VFCE = 16,
- S390_VEC_OP_VFCH = 17,
- S390_VEC_OP_VFCHE = 18,
- S390_VEC_OP_VFTCI = 19,
- S390_VEC_OP_LAST = 20 // supposed to be the last element in enum
+ S390_VEC_OP_VPKS,
+ S390_VEC_OP_VPKLS,
+ S390_VEC_OP_VFAE,
+ S390_VEC_OP_VFEE,
+ S390_VEC_OP_VFENE,
+ S390_VEC_OP_VISTR,
+ S390_VEC_OP_VSTRC,
+ S390_VEC_OP_VCEQ,
+ S390_VEC_OP_VTM,
+ S390_VEC_OP_VGFM,
+ S390_VEC_OP_VGFMA,
+ S390_VEC_OP_VMAH,
+ S390_VEC_OP_VMALH,
+ S390_VEC_OP_VCH,
+ S390_VEC_OP_VCHL,
+ S390_VEC_OP_VFTCI,
+ S390_VEC_OP_VFMIN,
+ S390_VEC_OP_VFMAX,
+ S390_VEC_OP_VBPERM,
+ S390_VEC_OP_VMSL,
+ S390_VEC_OP_LAST // supposed to be the last element in enum
} s390x_vec_op_t;
/* Arguments of s390x_dirtyhelper_vec_op(...) which are packed into one
diff --git a/VEX/priv/guest_s390_helpers.c b/VEX/priv/guest_s390_helpers.c
index a470d9f8d..b71b621ae 100644
--- a/VEX/priv/guest_s390_helpers.c
+++ b/VEX/priv/guest_s390_helpers.c
@@ -8,7 +8,7 @@
This file is part of Valgrind, a dynamic binary instrumentation
framework.
- Copyright IBM Corp. 2010-2017
+ Copyright IBM Corp. 2010-2020
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -314,20 +314,11 @@ ULong s390x_dirtyhelper_STCKE(ULong *addr) {return 3;}
/*--- Dirty helper for Store Facility instruction ---*/
/*------------------------------------------------------------*/
#if defined(VGA_s390x)
-static void
-s390_set_facility_bit(ULong *addr, UInt bitno, UInt value)
-{
- addr += bitno / 64;
- bitno = bitno % 64;
-
- ULong mask = 1;
- mask <<= (63 - bitno);
- if (value == 1) {
- *addr |= mask; // set
- } else {
- *addr &= ~mask; // clear
- }
+static ULong
+s390_stfle_range(UInt lo, UInt hi)
+{
+ return ((1UL << (hi + 1 - lo)) - 1) << (63 - (hi % 64));
}
ULong
@@ -336,6 +327,77 @@ s390x_dirtyhelper_STFLE(VexGuestS390XState *guest_state, ULong *addr)
ULong hoststfle[S390_NUM_FACILITY_DW], cc, num_dw, i;
register ULong reg0 asm("0") = guest_state->guest_r0 & 0xF; /* r0[56:63] */
+ /* Restrict to facilities that we know about and that we assume to be
+ compatible with Valgrind. Of course, in this way we may reject features
+ that Valgrind is not really involved in (and thus would be compatible
+ with), but quering for such features doesn't seem like a typical use
+ case. */
+ ULong accepted_facility[S390_NUM_FACILITY_DW] = {
+ /* === 0 .. 63 === */
+ (s390_stfle_range(0, 16)
+ /* 17: message-security-assist, not supported */
+ | s390_stfle_range(18, 19)
+ /* 20: HFP-multiply-and-add/subtract, not supported */
+ | s390_stfle_range(21, 22)
+ /* 23: HFP-unnormalized-extension, not supported */
+ | s390_stfle_range(24, 25)
+ /* 26: parsing-enhancement, not supported */
+ | s390_stfle_range(27, 28)
+ /* 29: unassigned */
+ | s390_stfle_range(30, 30)
+ /* 31: extract-CPU-time, not supported */
+ | s390_stfle_range(32, 41)
+ /* 42-43: DFP, not fully supported */
+ /* 44: PFPO, not fully supported */
+ | s390_stfle_range(45, 47)
+ /* 48: DFP zoned-conversion, not supported */
+ /* 49: includes PPA, not supported */
+ /* 50: constrained transactional-execution, not supported */
+ | s390_stfle_range(51, 55)
+ /* 56: unassigned */
+ /* 57: MSA5, not supported */
+ | s390_stfle_range(58, 60)
+ /* 61: miscellaneous-instruction 3, not supported */
+ | s390_stfle_range(62, 63)),
+
+ /* === 64 .. 127 === */
+ (s390_stfle_range(64, 72)
+ /* 73: transactional-execution, not supported */
+ | s390_stfle_range(74, 75)
+ /* 76: MSA3, not supported */
+ /* 77: MSA4, not supported */
+ | s390_stfle_range(78, 78)
+ /* 80: DFP packed-conversion, not supported */
+ /* 81: PPA-in-order, not supported */
+ | s390_stfle_range(82, 82)
+ /* 83-127: unassigned */ ),
+
+ /* === 128 .. 191 === */
+ (s390_stfle_range(128, 131)
+ /* 132: unassigned */
+ /* 133: guarded-storage, not supported */
+ /* 134: vector packed decimal, not supported */
+ | s390_stfle_range(135, 135)
+ /* 136: unassigned */
+ /* 137: unassigned */
+ | s390_stfle_range(138, 142)
+ /* 143: unassigned */
+ | s390_stfle_range(144, 145)
+ /* 146: MSA8, not supported */
+ | s390_stfle_range(147, 147)
+ /* 148: vector-enhancements 2, not supported */
+ | s390_stfle_range(149, 149)
+ /* 150: unassigned */
+ /* 151: DEFLATE-conversion, not supported */
+ /* 153: unassigned */
+ /* 154: unassigned */
+ /* 155: MSA9, not supported */
+ | s390_stfle_range(156, 156)
+ /* 157-167: unassigned */
+ | s390_stfle_range(168, 168)
+ /* 168-191: unassigned */ ),
+ };
+
/* We cannot store more than S390_NUM_FACILITY_DW
(and it makes not much sense to do so anyhow) */
if (reg0 > S390_NUM_FACILITY_DW - 1)
@@ -351,35 +413,9 @@ s390x_dirtyhelper_STFLE(VexGuestS390XState *guest_state, ULong *addr)
/* Update guest register 0 with what STFLE set r0 to */
guest_state->guest_r0 = reg0;
- /* Set default: VM facilities = host facilities */
+ /* VM facilities = host facilities, filtered by acceptance */
for (i = 0; i < num_dw; ++i)
- addr[i] = hoststfle[i];
-
- /* Now adjust the VM facilities according to what the VM supports */
- s390_set_facility_bit(addr, S390_FAC_LDISP, 1);
- s390_set_facility_bit(addr, S390_FAC_EIMM, 1);
- s390_set_facility_bit(addr, S390_FAC_ETF2, 1);
- s390_set_facility_bit(addr, S390_FAC_ETF3, 1);
- s390_set_facility_bit(addr, S390_FAC_GIE, 1);
- s390_set_facility_bit(addr, S390_FAC_EXEXT, 1);
- s390_set_facility_bit(addr, S390_FAC_HIGHW, 1);
- s390_set_facility_bit(addr, S390_FAC_LSC2, 1);
-
- s390_set_facility_bit(addr, S390_FAC_HFPMAS, 0);
- s390_set_facility_bit(addr, S390_FAC_HFPUNX, 0);
- s390_set_facility_bit(addr, S390_FAC_XCPUT, 0);
- s390_set_facility_bit(addr, S390_FAC_MSA, 0);
- s390_set_facility_bit(addr, S390_FAC_PENH, 0);
- s390_set_facility_bit(addr, S390_FAC_DFP, 0);
- s390_set_facility_bit(addr, S390_FAC_PFPO, 0);
- s390_set_facility_bit(addr, S390_FAC_DFPZC, 0);
- s390_set_facility_bit(addr, S390_FAC_MISC, 0);
- s390_set_facility_bit(addr, S390_FAC_CTREXE, 0);
- s390_set_facility_bit(addr, S390_FAC_TREXE, 0);
- s390_set_facility_bit(addr, S390_FAC_MSA4, 0);
- s390_set_facility_bit(addr, S390_FAC_VXE, 0);
- s390_set_facility_bit(addr, S390_FAC_VXE2, 0);
- s390_set_facility_bit(addr, S390_FAC_DFLT, 0);
+ addr[i] = hoststfle[i] & accepted_facility[i];
return cc;
}
@@ -2500,25 +2536,26 @@ s390x_dirtyhelper_vec_op(VexGuestS390XState *guest_state,
vassert(d->op > S390_VEC_OP_INVALID && d->op < S390_VEC_OP_LAST);
static const UChar opcodes[][2] = {
{0x00, 0x00}, /* invalid */
- {0xe7, 0x97}, /* VPKS */
- {0xe7, 0x95}, /* VPKLS */
- {0xe7, 0x82}, /* VFAE */
- {0xe7, 0x80}, /* VFEE */
- {0xe7, 0x81}, /* VFENE */
- {0xe7, 0x5c}, /* VISTR */
- {0xe7, 0x8a}, /* VSTRC */
- {0xe7, 0xf8}, /* VCEQ */
- {0xe7, 0xd8}, /* VTM */
- {0xe7, 0xb4}, /* VGFM */
- {0xe7, 0xbc}, /* VGFMA */
- {0xe7, 0xab}, /* VMAH */
- {0xe7, 0xa9}, /* VMALH */
- {0xe7, 0xfb}, /* VCH */
- {0xe7, 0xf9}, /* VCHL */