diff --git a/0001-Accept-read-only-PT_LOAD-segments-and-.rodata.patch b/0001-Accept-read-only-PT_LOAD-segments-and-.rodata.patch deleted file mode 100644 index 848dbfb..0000000 --- a/0001-Accept-read-only-PT_LOAD-segments-and-.rodata.patch +++ /dev/null @@ -1,102 +0,0 @@ -From cb72566ac3af13889f7ae88068c3b3ee6a6b757b Mon Sep 17 00:00:00 2001 -From: Mark Wielaard -Date: Thu, 12 Jul 2018 13:56:00 +0200 -Subject: [PATCH] Accept read-only PT_LOAD segments and .rodata. - -The new binutils ld -z separate-code option creates multiple read-only -PT_LOAD segments and might place .rodata in a non-executable segment. - -Allow and keep track of separate read-only segments and allow a readonly -page with .rodata section. - -Based on patches from Tom Hughes and -H.J. Lu . - -https://bugs.kde.org/show_bug.cgi?id=395682 - -[sbruens] Backported to 3.13.0 release ---- - coregrind/m_debuginfo/debuginfo.c | 2 -- - coregrind/m_debuginfo/readelf.c | 34 +++++++++++++++++++++++-------- - 2 files changed, 26 insertions(+), 10 deletions(-) - -diff --git a/coregrind/m_debuginfo/debuginfo.c b/coregrind/m_debuginfo/debuginfo.c -index 24814d8..2cf433a 100644 ---- a/coregrind/m_debuginfo/debuginfo.c -+++ b/coregrind/m_debuginfo/debuginfo.c -@@ -957,9 +957,7 @@ ULong VG_(di_notify_mmap)( Addr a, Bool allow_SkFileV, Int use_fd ) - # error "Unknown platform" - # endif - --# if defined(VGP_x86_darwin) && DARWIN_VERS >= DARWIN_10_7 - is_ro_map = seg->hasR && !seg->hasW && !seg->hasX; --# endif - - # if defined(VGO_solaris) - is_rx_map = seg->hasR && seg->hasX && !seg->hasW; -diff --git a/coregrind/m_debuginfo/readelf.c b/coregrind/m_debuginfo/readelf.c -index 3c8e62b..34a40c9 100644 ---- a/coregrind/m_debuginfo/readelf.c -+++ b/coregrind/m_debuginfo/readelf.c -@@ -1785,7 +1785,7 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) - Bool loaded = False; - for (j = 0; j < VG_(sizeXA)(di->fsm.maps); j++) { - const DebugInfoMapping* map = VG_(indexXA)(di->fsm.maps, j); -- if ( (map->rx || map->rw) -+ if ( (map->rx || map->rw || map->ro) - && map->size > 0 /* stay sane */ - && a_phdr.p_offset >= map->foff - && a_phdr.p_offset < map->foff + map->size -@@ -1816,6 +1816,16 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) - i, (UWord)item.bias); - loaded = True; - } -+ if (map->ro -+ && (a_phdr.p_flags & (PF_R | PF_W | PF_X)) -+ == PF_R) { -+ item.exec = False; -+ VG_(addToXA)(svma_ranges, &item); -+ TRACE_SYMTAB( -+ "PT_LOAD[%ld]: acquired as ro, bias 0x%lx\n", -+ i, (UWord)item.bias); -+ loaded = True; -+ } - } - } - if (!loaded) { -@@ -2083,17 +2093,25 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) - } - } - -- /* Accept .rodata where mapped as rx (data), even if zero-sized */ -+ /* Accept .rodata where mapped as rx or rw (data), even if zero-sized */ - if (0 == VG_(strcmp)(name, ".rodata")) { -- if (inrx && !di->rodata_present) { -- di->rodata_present = True; -+ if (!di->rodata_present) { - di->rodata_svma = svma; -- di->rodata_avma = svma + inrx->bias; -+ di->rodata_avma = svma; - di->rodata_size = size; -- di->rodata_bias = inrx->bias; - di->rodata_debug_svma = svma; -- di->rodata_debug_bias = inrx->bias; -- /* NB was 'inrw' prior to r11794 */ -+ if (inrx) { -+ di->rodata_avma += inrx->bias; -+ di->rodata_bias = inrx->bias; -+ di->rodata_debug_bias = inrx->bias; -+ } else if (inrw) { -+ di->rodata_avma += inrw->bias; -+ di->rodata_bias = inrw->bias; -+ di->rodata_debug_bias = inrw->bias; -+ } else { -+ BAD(".rodata"); -+ } -+ di->rodata_present = True; - TRACE_SYMTAB("acquiring .rodata svma = %#lx .. %#lx\n", - di->rodata_svma, - di->rodata_svma + di->rodata_size - 1); --- -2.18.0 - diff --git a/0001-Bug-397187-s390x-Add-vector-register-support-for-vgd.patch b/0001-Bug-397187-s390x-Add-vector-register-support-for-vgd.patch new file mode 100644 index 0000000..b0fbec6 --- /dev/null +++ b/0001-Bug-397187-s390x-Add-vector-register-support-for-vgd.patch @@ -0,0 +1,402 @@ +From 50bd2282bce101012a5668b670cb185375600d2d Mon Sep 17 00:00:00 2001 +From: Andreas Arnez +Date: Thu, 18 Oct 2018 17:51:57 +0200 +Subject: [PATCH] Bug 397187 s390x: Add vector register support for vgdb + +On s390x machines with a vector facility, Valgrind's gdbserver didn't +represent the vector registers. This is fixed. +--- + NEWS | 1 + + coregrind/Makefile.am | 5 + + coregrind/m_gdbserver/s390-vx-valgrind-s1.xml | 43 ++++++++ + coregrind/m_gdbserver/s390-vx-valgrind-s2.xml | 43 ++++++++ + coregrind/m_gdbserver/s390-vx.xml | 59 +++++++++++ + .../m_gdbserver/s390x-vx-linux-valgrind.xml | 28 ++++++ + coregrind/m_gdbserver/s390x-vx-linux.xml | 18 ++++ + coregrind/m_gdbserver/valgrind-low-s390x.c | 97 +++++++++++++++++-- + 8 files changed, 288 insertions(+), 6 deletions(-) + create mode 100644 coregrind/m_gdbserver/s390-vx-valgrind-s1.xml + create mode 100644 coregrind/m_gdbserver/s390-vx-valgrind-s2.xml + create mode 100644 coregrind/m_gdbserver/s390-vx.xml + create mode 100644 coregrind/m_gdbserver/s390x-vx-linux-valgrind.xml + create mode 100644 coregrind/m_gdbserver/s390x-vx-linux.xml + +Index: valgrind-3.14.0/coregrind/Makefile.am +=================================================================== +--- valgrind-3.14.0.orig/coregrind/Makefile.am ++++ valgrind-3.14.0/coregrind/Makefile.am +@@ -681,6 +681,11 @@ GDBSERVER_XML_FILES = \ + m_gdbserver/s390x-linux64-valgrind-s1.xml \ + m_gdbserver/s390x-linux64-valgrind-s2.xml \ + m_gdbserver/s390x-linux64.xml \ ++ m_gdbserver/s390-vx-valgrind-s1.xml \ ++ m_gdbserver/s390-vx-valgrind-s2.xml \ ++ m_gdbserver/s390-vx.xml \ ++ m_gdbserver/s390x-vx-linux-valgrind.xml \ ++ m_gdbserver/s390x-vx-linux.xml \ + m_gdbserver/mips-cp0-valgrind-s1.xml \ + m_gdbserver/mips-cp0-valgrind-s2.xml \ + m_gdbserver/mips-cp0.xml \ +Index: valgrind-3.14.0/coregrind/m_gdbserver/s390-vx-valgrind-s1.xml +=================================================================== +--- /dev/null ++++ valgrind-3.14.0/coregrind/m_gdbserver/s390-vx-valgrind-s1.xml +@@ -0,0 +1,43 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +Index: valgrind-3.14.0/coregrind/m_gdbserver/s390-vx-valgrind-s2.xml +=================================================================== +--- /dev/null ++++ valgrind-3.14.0/coregrind/m_gdbserver/s390-vx-valgrind-s2.xml +@@ -0,0 +1,43 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +Index: valgrind-3.14.0/coregrind/m_gdbserver/s390-vx.xml +=================================================================== +--- /dev/null ++++ valgrind-3.14.0/coregrind/m_gdbserver/s390-vx.xml +@@ -0,0 +1,59 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +Index: valgrind-3.14.0/coregrind/m_gdbserver/s390x-vx-linux-valgrind.xml +=================================================================== +--- /dev/null ++++ valgrind-3.14.0/coregrind/m_gdbserver/s390x-vx-linux-valgrind.xml +@@ -0,0 +1,28 @@ ++ ++ ++ ++ ++ ++ ++ ++ s390:64-bit ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +Index: valgrind-3.14.0/coregrind/m_gdbserver/s390x-vx-linux.xml +=================================================================== +--- /dev/null ++++ valgrind-3.14.0/coregrind/m_gdbserver/s390x-vx-linux.xml +@@ -0,0 +1,18 @@ ++ ++ ++ ++ ++ ++ ++ ++ s390:64-bit ++ ++ ++ ++ ++ ++ +Index: valgrind-3.14.0/coregrind/m_gdbserver/valgrind-low-s390x.c +=================================================================== +--- valgrind-3.14.0.orig/coregrind/m_gdbserver/valgrind-low-s390x.c ++++ valgrind-3.14.0/coregrind/m_gdbserver/valgrind-low-s390x.c +@@ -88,9 +88,42 @@ static struct reg regs[] = { + { "f14", 2592, 64 }, + { "f15", 2656, 64 }, + { "orig_r2", 2720, 64 }, ++ { "v0l", 2784, 64 }, ++ { "v1l", 2848, 64 }, ++ { "v2l", 2912, 64 }, ++ { "v3l", 2976, 64 }, ++ { "v4l", 3040, 64 }, ++ { "v5l", 3104, 64 }, ++ { "v6l", 3168, 64 }, ++ { "v7l", 3232, 64 }, ++ { "v8l", 3296, 64 }, ++ { "v9l", 3360, 64 }, ++ { "v10l", 3424, 64 }, ++ { "v11l", 3488, 64 }, ++ { "v12l", 3552, 64 }, ++ { "v13l", 3616, 64 }, ++ { "v14l", 3680, 64 }, ++ { "v15l", 3744, 64 }, ++ { "v16", 3808, 128 }, ++ { "v17", 3936, 128 }, ++ { "v18", 4064, 128 }, ++ { "v19", 4192, 128 }, ++ { "v20", 4320, 128 }, ++ { "v21", 4448, 128 }, ++ { "v22", 4576, 128 }, ++ { "v23", 4704, 128 }, ++ { "v24", 4832, 128 }, ++ { "v25", 4960, 128 }, ++ { "v26", 5088, 128 }, ++ { "v27", 5216, 128 }, ++ { "v28", 5344, 128 }, ++ { "v29", 5472, 128 }, ++ { "v30", 5600, 128 }, ++ { "v31", 5728, 128 }, + }; + static const char *expedite_regs[] = { "r14", "r15", "pswa", 0 }; +-#define num_regs (sizeof (regs) / sizeof (regs[0])) ++#define num_regs_all (sizeof (regs) / sizeof (regs[0])) ++static int num_regs; + + static + CORE_ADDR get_pc (void) +@@ -165,7 +198,7 @@ void transfer_register (ThreadId tid, in + case 32: VG_(transfer) (&s390x->guest_a14, buf, dir, size, mod); break; + case 33: VG_(transfer) (&s390x->guest_a15, buf, dir, size, mod); break; + case 34: VG_(transfer) (&s390x->guest_fpc, buf, dir, size, mod); break; +- case 35: VG_(transfer) (&s390x->guest_v0, buf, dir, size, mod); break; ++ case 35: VG_(transfer) (&s390x->guest_v0.w64[0], buf, dir, size, mod); break; + case 36: VG_(transfer) (&s390x->guest_v1.w64[0], buf, dir, size, mod); break; + case 37: VG_(transfer) (&s390x->guest_v2.w64[0], buf, dir, size, mod); break; + case 38: VG_(transfer) (&s390x->guest_v3.w64[0], buf, dir, size, mod); break; +@@ -182,18 +215,65 @@ void transfer_register (ThreadId tid, in + case 49: VG_(transfer) (&s390x->guest_v14.w64[0], buf, dir, size, mod); break; + case 50: VG_(transfer) (&s390x->guest_v15.w64[0], buf, dir, size, mod); break; + case 51: *mod = False; break; //GDBTD??? { "orig_r2", 0, 64 }, ++ case 52: VG_(transfer) (&s390x->guest_v0.w64[1], buf, dir, size, mod); break; ++ case 53: VG_(transfer) (&s390x->guest_v1.w64[1], buf, dir, size, mod); break; ++ case 54: VG_(transfer) (&s390x->guest_v2.w64[1], buf, dir, size, mod); break; ++ case 55: VG_(transfer) (&s390x->guest_v3.w64[1], buf, dir, size, mod); break; ++ case 56: VG_(transfer) (&s390x->guest_v4.w64[1], buf, dir, size, mod); break; ++ case 57: VG_(transfer) (&s390x->guest_v5.w64[1], buf, dir, size, mod); break; ++ case 58: VG_(transfer) (&s390x->guest_v6.w64[1], buf, dir, size, mod); break; ++ case 59: VG_(transfer) (&s390x->guest_v7.w64[1], buf, dir, size, mod); break; ++ case 60: VG_(transfer) (&s390x->guest_v8.w64[1], buf, dir, size, mod); break; ++ case 61: VG_(transfer) (&s390x->guest_v9.w64[1], buf, dir, size, mod); break; ++ case 62: VG_(transfer) (&s390x->guest_v10.w64[1], buf, dir, size, mod); break; ++ case 63: VG_(transfer) (&s390x->guest_v11.w64[1], buf, dir, size, mod); break; ++ case 64: VG_(transfer) (&s390x->guest_v12.w64[1], buf, dir, size, mod); break; ++ case 65: VG_(transfer) (&s390x->guest_v13.w64[1], buf, dir, size, mod); break; ++ case 66: VG_(transfer) (&s390x->guest_v14.w64[1], buf, dir, size, mod); break; ++ case 67: VG_(transfer) (&s390x->guest_v15.w64[1], buf, dir, size, mod); break; ++ case 68: VG_(transfer) (&s390x->guest_v16, buf, dir, size, mod); break; ++ case 69: VG_(transfer) (&s390x->guest_v17, buf, dir, size, mod); break; ++ case 70: VG_(transfer) (&s390x->guest_v18, buf, dir, size, mod); break; ++ case 71: VG_(transfer) (&s390x->guest_v19, buf, dir, size, mod); break; ++ case 72: VG_(transfer) (&s390x->guest_v20, buf, dir, size, mod); break; ++ case 73: VG_(transfer) (&s390x->guest_v21, buf, dir, size, mod); break; ++ case 74: VG_(transfer) (&s390x->guest_v22, buf, dir, size, mod); break; ++ case 75: VG_(transfer) (&s390x->guest_v23, buf, dir, size, mod); break; ++ case 76: VG_(transfer) (&s390x->guest_v24, buf, dir, size, mod); break; ++ case 77: VG_(transfer) (&s390x->guest_v25, buf, dir, size, mod); break; ++ case 78: VG_(transfer) (&s390x->guest_v26, buf, dir, size, mod); break; ++ case 79: VG_(transfer) (&s390x->guest_v27, buf, dir, size, mod); break; ++ case 80: VG_(transfer) (&s390x->guest_v28, buf, dir, size, mod); break; ++ case 81: VG_(transfer) (&s390x->guest_v29, buf, dir, size, mod); break; ++ case 82: VG_(transfer) (&s390x->guest_v30, buf, dir, size, mod); break; ++ case 83: VG_(transfer) (&s390x->guest_v31, buf, dir, size, mod); break; + default: vg_assert(0); + } + } + + static ++Bool have_vx (void) ++{ ++ VexArch va; ++ VexArchInfo vai; ++ VG_(machine_get_VexArchInfo) (&va, &vai); ++ return (vai.hwcaps & VEX_HWCAPS_S390X_VX) != 0; ++} ++ ++static + const char* target_xml (Bool shadow_mode) + { + if (shadow_mode) { +- return "s390x-generic-valgrind.xml"; ++ if (have_vx()) ++ return "s390x-vx-linux-valgrind.xml"; ++ else ++ return "s390x-generic-valgrind.xml"; + } else { +- return "s390x-generic.xml"; +- } ++ if (have_vx()) ++ return "s390x-vx-linux.xml"; ++ else ++ return "s390x-generic.xml"; ++ } + } + + static CORE_ADDR** target_get_dtv (ThreadState *tst) +@@ -206,7 +286,7 @@ static CORE_ADDR** target_get_dtv (Threa + } + + static struct valgrind_target_ops low_target = { +- num_regs, ++ -1, // Override at init time. + regs, + 17, //sp = r15, which is register offset 17 in regs + transfer_register, +@@ -220,6 +300,11 @@ static struct valgrind_target_ops low_ta + void s390x_init_architecture (struct valgrind_target_ops *target) + { + *target = low_target; ++ if (have_vx()) ++ num_regs = num_regs_all; ++ else ++ num_regs = num_regs_all - 32; // Remove all VX registers. ++ target->num_regs = num_regs; + set_register_cache (regs, num_regs); + gdbserver_expedite_regs = expedite_regs; + } diff --git a/0001-Bug-400490-s390x-Fix-register-allocation-for-VRs-vs-.patch b/0001-Bug-400490-s390x-Fix-register-allocation-for-VRs-vs-.patch new file mode 100644 index 0000000..69fe371 --- /dev/null +++ b/0001-Bug-400490-s390x-Fix-register-allocation-for-VRs-vs-.patch @@ -0,0 +1,87 @@ +From 71002d8a5111d02ce8049c55017a8d948c820e35 Mon Sep 17 00:00:00 2001 +From: Andreas Arnez +Date: Thu, 25 Oct 2018 13:47:12 +0200 +Subject: [PATCH] Bug 400490 s390x: Fix register allocation for VRs vs FPRs + +On s390x, if vector registers are available, they are fed to the register +allocator as if they were separate from the floating-point registers. But +in fact the FPRs are embedded in the VRs. So for instance, if both f3 and +v3 are allocated and used at the same time, corruption will result. + +This is fixed by offering only the non-overlapping VRs, v16 to v31, to the +register allocator instead. +--- + NEWS | 1 + + VEX/priv/host_s390_defs.c | 17 +++++++---------- + 2 files changed, 8 insertions(+), 10 deletions(-) + +Index: valgrind-3.14.0/VEX/priv/host_s390_defs.c +=================================================================== +--- valgrind-3.14.0.orig/VEX/priv/host_s390_defs.c ++++ valgrind-3.14.0/VEX/priv/host_s390_defs.c +@@ -59,7 +59,6 @@ static UInt s390_tchain_load64_len(void) + + /* A mapping from register number to register index */ + static Int gpr_index[16]; // GPR regno -> register index +-static Int fpr_index[16]; // FPR regno -> register index + static Int vr_index[32]; // VR regno -> register index + + HReg +@@ -73,7 +72,7 @@ s390_hreg_gpr(UInt regno) + HReg + s390_hreg_fpr(UInt regno) + { +- Int ix = fpr_index[regno]; ++ Int ix = vr_index[regno]; + vassert(ix >= 0); + return mkHReg(/*virtual*/False, HRcFlt64, regno, ix); + } +@@ -463,11 +462,9 @@ getRRegUniverse_S390(void) + + RRegUniverse__init(ru); + +- /* Assign invalid values to the gpr/fpr/vr_index */ ++ /* Assign invalid values to the gpr/vr_index */ + for (UInt i = 0; i < sizeof gpr_index / sizeof gpr_index[0]; ++i) + gpr_index[i] = -1; +- for (UInt i = 0; i < sizeof fpr_index / sizeof fpr_index[0]; ++i) +- fpr_index[i] = -1; + for (UInt i = 0; i < sizeof vr_index / sizeof vr_index[0]; ++i) + vr_index[i] = -1; + +@@ -494,17 +491,17 @@ getRRegUniverse_S390(void) + + ru->allocable_start[HRcFlt64] = ru->size; + for (UInt regno = 8; regno <= 15; ++regno) { +- fpr_index[regno] = ru->size; ++ vr_index[regno] = ru->size; + ru->regs[ru->size++] = s390_hreg_fpr(regno); + } + for (UInt regno = 0; regno <= 7; ++regno) { +- fpr_index[regno] = ru->size; ++ vr_index[regno] = ru->size; + ru->regs[ru->size++] = s390_hreg_fpr(regno); + } + ru->allocable_end[HRcFlt64] = ru->size - 1; + + ru->allocable_start[HRcVec128] = ru->size; +- for (UInt regno = 0; regno <= 31; ++regno) { ++ for (UInt regno = 16; regno <= 31; ++regno) { + vr_index[regno] = ru->size; + ru->regs[ru->size++] = s390_hreg_vr(regno); + } +@@ -527,12 +524,12 @@ getRRegUniverse_S390(void) + /* Sanity checking */ + for (UInt i = 0; i < sizeof gpr_index / sizeof gpr_index[0]; ++i) + vassert(gpr_index[i] >= 0); +- for (UInt i = 0; i < sizeof fpr_index / sizeof fpr_index[0]; ++i) +- vassert(fpr_index[i] >= 0); + for (UInt i = 0; i < sizeof vr_index / sizeof vr_index[0]; ++i) + vassert(vr_index[i] >= 0); + + initialised = True; ++ ++ RRegUniverse__check_is_sane(ru); + return ru; + } + diff --git a/0001-Bug-400491-s390x-Sign-extend-immediate-operand-of-LO.patch b/0001-Bug-400491-s390x-Sign-extend-immediate-operand-of-LO.patch new file mode 100644 index 0000000..f21c938 --- /dev/null +++ b/0001-Bug-400491-s390x-Sign-extend-immediate-operand-of-LO.patch @@ -0,0 +1,45 @@ +From 9545e9f96beda6e9f2205bdb3c3e96edaf8d9e2b Mon Sep 17 00:00:00 2001 +From: Andreas Arnez +Date: Tue, 30 Oct 2018 17:06:38 +0100 +Subject: [PATCH] Bug 400491 s390x: Sign-extend immediate operand of LOCHI and + friends + +The VEX implementation of each of the z/Architecture instructions LOCHI, +LOCHHI, and LOCGHI treats the immediate 16-bit operand as an unsigned +integer instead of a signed integer. This is fixed. +--- + NEWS | 1 + + VEX/priv/guest_s390_toIR.c | 6 +++--- + 2 files changed, 4 insertions(+), 3 deletions(-) + +Index: valgrind-3.14.0/VEX/priv/guest_s390_toIR.c +=================================================================== +--- valgrind-3.14.0.orig/VEX/priv/guest_s390_toIR.c ++++ valgrind-3.14.0/VEX/priv/guest_s390_toIR.c +@@ -16307,7 +16307,7 @@ static const HChar * + s390_irgen_LOCHHI(UChar r1, UChar m3, UShort i2, UChar unused) + { + next_insn_if(binop(Iop_CmpEQ32, s390_call_calculate_cond(m3), mkU32(0))); +- put_gpr_w0(r1, mkU32(i2)); ++ put_gpr_w0(r1, mkU32((UInt)(Int)(Short)i2)); + + return "lochhi"; + } +@@ -16316,7 +16316,7 @@ static const HChar * + s390_irgen_LOCHI(UChar r1, UChar m3, UShort i2, UChar unused) + { + next_insn_if(binop(Iop_CmpEQ32, s390_call_calculate_cond(m3), mkU32(0))); +- put_gpr_w1(r1, mkU32(i2)); ++ put_gpr_w1(r1, mkU32((UInt)(Int)(Short)i2)); + + return "lochi"; + } +@@ -16325,7 +16325,7 @@ static const HChar * + s390_irgen_LOCGHI(UChar r1, UChar m3, UShort i2, UChar unused) + { + next_insn_if(binop(Iop_CmpEQ32, s390_call_calculate_cond(m3), mkU32(0))); +- put_gpr_dw0(r1, mkU64(i2)); ++ put_gpr_dw0(r1, mkU64((UInt)(Int)(Short)i2)); + + return "locghi"; + } diff --git a/0001-s390x-more-fixes.patch b/0001-s390x-more-fixes.patch new file mode 100644 index 0000000..559328a --- /dev/null +++ b/0001-s390x-more-fixes.patch @@ -0,0 +1,51 @@ +From d10cd86ee32bf76495f79c02df62fc242adbcbe3 Mon Sep 17 00:00:00 2001 +From: Andreas Arnez +Date: Thu, 26 Jul 2018 16:35:24 +0200 +Subject: [PATCH] s390x: More fixes for z13 support + +This patch addresses the following: + +* Fix the implementation of LOCGHI. Previously Valgrind performed 32-bit + sign extension instead of 64-bit sign extension on the immediate value. + +* Advertise VXRS in HWCAP. If no VXRS are advertised, but the program + uses vector registers, this could cause problems with a glibc built with + "-march=z13". +--- + VEX/priv/guest_s390_toIR.c | 2 +- + coregrind/m_initimg/initimg-linux.c | 6 +++--- + 2 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/VEX/priv/guest_s390_toIR.c b/VEX/priv/guest_s390_toIR.c +index 9c4d79b87..50a5a4177 100644 +--- a/VEX/priv/guest_s390_toIR.c ++++ b/VEX/priv/guest_s390_toIR.c +@@ -16325,7 +16325,7 @@ static const HChar * + s390_irgen_LOCGHI(UChar r1, UChar m3, UShort i2, UChar unused) + { + next_insn_if(binop(Iop_CmpEQ32, s390_call_calculate_cond(m3), mkU32(0))); +- put_gpr_dw0(r1, mkU64((UInt)(Int)(Short)i2)); ++ put_gpr_dw0(r1, mkU64((ULong)(Long)(Short)i2)); + + return "locghi"; + } +diff --git a/coregrind/m_initimg/initimg-linux.c b/coregrind/m_initimg/initimg-linux.c +index 61cc458bc..8a7f0d024 100644 +--- a/coregrind/m_initimg/initimg-linux.c ++++ b/coregrind/m_initimg/initimg-linux.c +@@ -699,9 +699,9 @@ Addr setup_client_stack( void* init_sp, + } + # elif defined(VGP_s390x_linux) + { +- /* Advertise hardware features "below" TE only. TE and VXRS +- (and anything above) are not supported by Valgrind. */ +- auxv->u.a_val &= VKI_HWCAP_S390_TE - 1; ++ /* Advertise hardware features "below" TE and VXRS. TE itself ++ and anything above VXRS is not supported by Valgrind. */ ++ auxv->u.a_val &= (VKI_HWCAP_S390_TE - 1) | VKI_HWCAP_S390_VXRS; + } + # elif defined(VGP_arm64_linux) + { +-- +2.17.0 + diff --git a/Fix-access-to-time-base-register-to-return-64-bits.patch b/Fix-access-to-time-base-register-to-return-64-bits.patch deleted file mode 100644 index 517b126..0000000 --- a/Fix-access-to-time-base-register-to-return-64-bits.patch +++ /dev/null @@ -1,115 +0,0 @@ -From 6a55b1e82ccda3f0d663d2cc89eb543ae2d096bf Mon Sep 17 00:00:00 2001 -From: Carl Love -Date: Tue, 31 Oct 2017 13:45:28 -0500 -Subject: [PATCH] Fix access to time base register to return 64-bits. - ---- - NEWS | 1 + - VEX/priv/guest_ppc_toIR.c | 70 +++++++++++++++++++++++++++++++++++++---------- - 2 files changed, 56 insertions(+), 15 deletions(-) - ---- valgrind-3.13.0/NEWS 2017-06-15 15:37:40.000000000 +0200 -+++ valgrind-3.13.0/NEWS 2018-09-25 12:08:56.395509577 +0200 -@@ -250,6 +250,7 @@ - 380200 xtree generated callgrind files refer to files without directory name - 380202 Assertion failure for cache line size (cls == 64) on aarch64. - 380397 s390x: __GI_strcspn() replacement needed -+386397 PPC64, valgrind truncates powerpc timebase to 32-bits. - n-i-bz Fix pub_tool_basics.h build issue with g++ 4.4.7. - - (3.13.0.RC1: 2 June 2017, vex r3386, valgrind r16434) -diff --git a/VEX/priv/guest_ppc_toIR.c b/VEX/priv/guest_ppc_toIR.c -index f63146e7e256..4ec37f5f994f 100644 ---- a/VEX/priv/guest_ppc_toIR.c -+++ b/VEX/priv/guest_ppc_toIR.c -@@ -9419,26 +9419,60 @@ static Bool dis_proc_ctl ( const VexAbiInfo* vbi, UInt theInstr ) - putIReg( rD_addr, getGST( PPC_GST_SPRG3_RO ) ); - break; - -- /* Even a lowly PPC7400 can run the associated helper, so no -- obvious need for feature testing at this point. */ -- case 268 /* 0x10C */: -- case 269 /* 0x10D */: { -- UInt arg = SPR==268 ? 0 : 1; -- IRTemp val = newTemp(Ity_I32); -- IRExpr** args = mkIRExprVec_1( mkU32(arg) ); -+ case 268 /* 0x10C TB - 64 bit time base register */: -+ { -+ IRTemp val = newTemp(Ity_I64); -+ IRExpr** args = mkIRExprVec_0(); - IRDirty* d = unsafeIRDirty_1_N( -- val, -- 0/*regparms*/, -- "ppc32g_dirtyhelper_MFSPR_268_269", -- fnptr_to_fnentry -- (vbi, &ppc32g_dirtyhelper_MFSPR_268_269), -- args -- ); -+ val, -+ 0/*regparms*/, -+ "ppcg_dirtyhelper_MFTB", -+ fnptr_to_fnentry(vbi, -+ &ppcg_dirtyhelper_MFTB), -+ args ); -+ /* execute the dirty call, dumping the result in val. */ -+ stmt( IRStmt_Dirty(d) ); -+ putIReg( rD_addr, (mode64) ? mkexpr(val) : -+ unop(Iop_64to32, mkexpr(val)) ); -+ -+ break; -+ } -+ case 269 /* 0x10D TBU - upper 32-bits of time base register */: -+ { -+ DIP("mfspr r%u,%u", rD_addr, SPR); -+ IRTemp val = newTemp(Ity_I64); -+ IRExpr** args = mkIRExprVec_0(); -+ IRDirty* d = unsafeIRDirty_1_N( -+ val, -+ 0/*regparms*/, -+ "ppcg_dirtyhelper_MFTB", -+ fnptr_to_fnentry(vbi, -+ &ppcg_dirtyhelper_MFTB), -+ args ); - /* execute the dirty call, dumping the result in val. */ - stmt( IRStmt_Dirty(d) ); - putIReg( rD_addr, -- mkWidenFrom32(ty, mkexpr(val), False/*unsigned*/) ); -+ mkWidenFrom32(ty, unop(Iop_64HIto32, mkexpr(val)), -+ /* Signed */False) ); -+ break; -+ } -+ case 284 /* 0x1 TBL - lower 32-bits of time base register */: -+ { - DIP("mfspr r%u,%u", rD_addr, SPR); -+ IRTemp val = newTemp(Ity_I64); -+ IRExpr** args = mkIRExprVec_0(); -+ IRDirty* d = unsafeIRDirty_1_N( -+ val, -+ 0/*regparms*/, -+ "ppcg_dirtyhelper_MFTB", -+ fnptr_to_fnentry(vbi, -+ &ppcg_dirtyhelper_MFTB), -+ args ); -+ /* execute the dirty call, dumping the result in val. */ -+ stmt( IRStmt_Dirty(d) ); -+ putIReg( rD_addr, -+ mkWidenFrom32(ty, unop(Iop_64to32, mkexpr(val)), -+ /* Signed */False) ); - break; - } - -@@ -9493,6 +9527,12 @@ static Bool dis_proc_ctl ( const VexAbiInfo* vbi, UInt theInstr ) - putIReg( rD_addr, (mode64) ? mkexpr(val) : - unop(Iop_64to32, mkexpr(val)) ); - break; -+ case 284: -+ DIP("mftbl r%u", rD_addr); -+ putIReg( rD_addr, -+ mkWidenFrom32(ty, unop(Iop_64to32, mkexpr(val)), -+ /* Signed */False) ); -+ break; - default: - return False; /* illegal instruction */ - } --- -2.13.7 diff --git a/Implement-emulated-system-registers.-Fixes-392146.patch b/Implement-emulated-system-registers.-Fixes-392146.patch index 9d9f076..bea257a 100644 --- a/Implement-emulated-system-registers.-Fixes-392146.patch +++ b/Implement-emulated-system-registers.-Fixes-392146.patch @@ -10,11 +10,11 @@ Signed-off-by: Matthias Brugger VEX/priv/guest_arm64_toIR.c | 222 +++++++++++++++++++++++++++++++++ 3 files changed, 331 insertions(+) -diff --git a/VEX/priv/guest_arm64_defs.h b/VEX/priv/guest_arm64_defs.h -index b28f326c2..ae01e6f3b 100644 ---- a/VEX/priv/guest_arm64_defs.h -+++ b/VEX/priv/guest_arm64_defs.h -@@ -126,6 +126,15 @@ extern ULong arm64g_dirtyhelper_MRS_CNTVCT_EL0 ( void ); +Index: valgrind-3.14.0/VEX/priv/guest_arm64_defs.h +=================================================================== +--- valgrind-3.14.0.orig/VEX/priv/guest_arm64_defs.h ++++ valgrind-3.14.0/VEX/priv/guest_arm64_defs.h +@@ -126,6 +126,15 @@ extern ULong arm64g_dirtyhelper_MRS_CNTV extern ULong arm64g_dirtyhelper_MRS_CNTFRQ_EL0 ( void ); @@ -30,11 +30,11 @@ index b28f326c2..ae01e6f3b 100644 extern void arm64g_dirtyhelper_PMULLQ ( /*OUT*/V128* res, ULong arg1, ULong arg2 ); -diff --git a/VEX/priv/guest_arm64_helpers.c b/VEX/priv/guest_arm64_helpers.c -index 10065d547..c579c9e1b 100644 ---- a/VEX/priv/guest_arm64_helpers.c -+++ b/VEX/priv/guest_arm64_helpers.c -@@ -788,6 +788,106 @@ ULong arm64g_dirtyhelper_MRS_CNTFRQ_EL0 ( void ) +Index: valgrind-3.14.0/VEX/priv/guest_arm64_helpers.c +=================================================================== +--- valgrind-3.14.0.orig/VEX/priv/guest_arm64_helpers.c ++++ valgrind-3.14.0/VEX/priv/guest_arm64_helpers.c +@@ -788,6 +788,106 @@ ULong arm64g_dirtyhelper_MRS_CNTFRQ_EL0 # endif } @@ -141,11 +141,11 @@ index 10065d547..c579c9e1b 100644 void arm64g_dirtyhelper_PMULLQ ( /*OUT*/V128* res, ULong arg1, ULong arg2 ) { -diff --git a/VEX/priv/guest_arm64_toIR.c b/VEX/priv/guest_arm64_toIR.c -index e5af388e1..ed6c1ffa5 100644 ---- a/VEX/priv/guest_arm64_toIR.c -+++ b/VEX/priv/guest_arm64_toIR.c -@@ -6872,6 +6872,228 @@ Bool dis_ARM64_branch_etc(/*MB_OUT*/DisResult* dres, UInt insn, +Index: valgrind-3.14.0/VEX/priv/guest_arm64_toIR.c +=================================================================== +--- valgrind-3.14.0.orig/VEX/priv/guest_arm64_toIR.c ++++ valgrind-3.14.0/VEX/priv/guest_arm64_toIR.c +@@ -6891,6 +6891,228 @@ Bool dis_ARM64_branch_etc(/*MB_OUT*/DisR } /* ------------------ M{SR,RS} ------------------ */ @@ -374,6 +374,3 @@ index e5af388e1..ed6c1ffa5 100644 /* ---- Cases for TPIDR_EL0 ---- 0xD51BD0 010 Rt MSR tpidr_el0, rT 0xD53BD0 010 Rt MRS rT, tpidr_el0 --- -2.17.0 - diff --git a/armv6-support.diff b/armv6-support.diff index 72ff70f..14afaa4 100644 --- a/armv6-support.diff +++ b/armv6-support.diff @@ -2,7 +2,7 @@ Index: configure.ac =================================================================== --- configure.ac.orig +++ configure.ac -@@ -234,7 +234,7 @@ case "${host_cpu}" in +@@ -252,7 +252,7 @@ case "${host_cpu}" in ARCH_MAX="s390x" ;; diff --git a/epoll-wait-fix.patch b/epoll-wait-fix.patch deleted file mode 100644 index b61217d..0000000 --- a/epoll-wait-fix.patch +++ /dev/null @@ -1,35 +0,0 @@ -backport of https://bugs.kde.org/show_bug.cgi?id=381289 -see https://bugzilla.suse.com/show_bug.cgi?id=1064958 - ---- coregrind/m_syswrap/syswrap-linux.c (revision 16470) -+++ coregrind/m_syswrap/syswrap-linux.c (working copy) -@@ -1901,7 +1901,7 @@ PRE(sys_epoll_pwait) - int, maxevents, int, timeout, vki_sigset_t *, sigmask, - vki_size_t, sigsetsize); - PRE_MEM_WRITE( "epoll_pwait(events)", ARG2, sizeof(struct vki_epoll_event)*ARG3); -- if (ARG4) -+ if (ARG5) - PRE_MEM_READ( "epoll_pwait(sigmask)", ARG5, sizeof(vki_sigset_t) ); - } - POST(sys_epoll_pwait) -Index: memcheck/tests/linux/syscalls-2007.c -=================================================================== ---- memcheck/tests/linux/syscalls-2007.c (revision 16470) -+++ memcheck/tests/linux/syscalls-2007.c (working copy) -@@ -79,5 +79,16 @@ int main (void) - } - #endif - -+#if defined(HAVE_EPOLL_CREATE) && defined(HAVE_EPOLL_PWAIT) -+ { -+ int fd3; -+ struct epoll_event evs[10]; -+ -+ fd3 = epoll_create (10); -+ /* epoll_pwait can take a NULL sigmask. */ -+ epoll_pwait (fd3, evs, 10, 1, NULL); -+ } -+#endif -+ - return 0; - } diff --git a/valgrind-3.13.0.tar.bz2 b/valgrind-3.13.0.tar.bz2 deleted file mode 100644 index d13e0f2..0000000 --- a/valgrind-3.13.0.tar.bz2 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:d76680ef03f00cd5e970bbdcd4e57fb1f6df7d2e2c071635ef2be74790190c3b -size 14723076 diff --git a/valgrind-3.14.0.tar.bz2 b/valgrind-3.14.0.tar.bz2 new file mode 100644 index 0000000..f17b956 --- /dev/null +++ b/valgrind-3.14.0.tar.bz2 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:037c11bfefd477cc6e9ebe8f193bb237fe397f7ce791b4a4ce3fa1c6a520baa5 +size 16602858 diff --git a/valgrind.changes b/valgrind.changes index 22910d6..8f610ff 100644 --- a/valgrind.changes +++ b/valgrind.changes @@ -1,3 +1,56 @@ +------------------------------------------------------------------- +Sun Nov 25 21:06:20 UTC 2018 - olaf@aepfle.de + +- update valgrind.xen.patch to branch bug390553-20181125-ddfc274b2 + +------------------------------------------------------------------- +Thu Nov 22 09:21:45 UTC 2018 - Dirk Mueller + +- build against Toolchain module for SLE12 +- add 0001-Bug-397187-s390x-Add-vector-register-support-for-vgd.patch + 0001-Bug-400490-s390x-Fix-register-allocation-for-VRs-vs-.patch, + 0001-Bug-400491-s390x-Sign-extend-immediate-operand-of-LO.patch, + 0001-s390x-more-fixes.patch, + Implement-emulated-system-registers.-Fixes-392146.patch (FATE#326355) +- enable check (poo#36751) + +------------------------------------------------------------------- +Wed Nov 21 11:51:45 UTC 2018 - Dirk Mueller + +- update to 3.14.0 (bsc#1114575, FATE#326355): + see http://www.valgrind.org/docs/manual/dist.news.html + * The new option --keep-debuginfo=no|yes (default no) can be used to retain + debug info for unloaded code. This allows saved stack traces (e.g. for + memory leaks) to include file/line info for code that has been dlclose'd (or + similar). See the user manual for more information and known limitations. + * Ability to specify suppressions based on source file name and line number. + * Majorly overhauled register allocator. No end-user changes, but the JIT + generates code a bit more quickly now. + * Preliminary support for macOS 10.13 has been added. + * mips: support for MIPS32/MIPS64 Revision 6 has been added. + * mips: support for MIPS SIMD architecture (MSA) has been added. + * mips: support for MIPS N32 ABI has been added. + * s390: partial support for vector instructions (integer and string) has been + added. + * Helgrind: Addition of a flag + --delta-stacktrace=no|yes [yes on linux amd64/x86] + which specifies how full history stack traces should be computed. + Setting this to =yes can speed up Helgrind by 25% when using + --history-level=full. + * Memcheck: reduced false positive rate for optimised code created by Clang 6 + / LLVM 6 on x86, amd64 and arm64. In particular, Memcheck analyses code + blocks more carefully to determine where it can avoid expensive definedness + checks without loss of precision. This is controlled by the flag + --expensive-definedness-checks=no|auto|yes [auto]. + * Valgrind is now buildable with link-time optimisation (LTO). A new + configure option --enable-lto=yes allows building Valgrind with LTO. If the + toolchain supports it, this produces a smaller/faster Valgrind (up to 10%). + Note that if you are doing Valgrind development, --enable-lto=yes massively + slows down the build process. +- remove epoll-wait-fix.patch, + Fix-access-to-time-base-register-to-return-64-bits.patch, + 0001-Accept-read-only-PT_LOAD-segments-and-.rodata.patch (upstream), + ------------------------------------------------------------------- Tue Sep 25 16:32:22 UTC 2018 - Michal Suchanek diff --git a/valgrind.spec b/valgrind.spec index 8618507..13fe772 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -22,31 +22,35 @@ %define building_docs 1 Name: valgrind -Version: 3.13.0 +Version: 3.14.0 Release: 0 Summary: Memory Management Debugger License: GPL-2.0-or-later Group: Development/Tools/Debuggers Url: http://valgrind.org/ Source0: ftp://sourceware.org/pub/valgrind/valgrind-%{version}.tar.bz2 -# svn di svn://svn.valgrind.org/valgrind/tags/VALGRIND_3_5_0 svn://svn.valgrind.org/valgrind/branches/VALGRIND_3_5_BRANCH > 3_5_BRANCH.diff -# svn di svn://svn.valgrind.org/vex/tags/VEX_3_5_0 svn://svn.valgrind.org/vex/branches/VEX_3_5_BRANCH > VEX_3_5_BRANCH.diff +# https://bugs.kde.org/show_bug.cgi?id=390553 +# https://github.com/olafhering/valgrind/compare/olh-base-master...olh-fixes-master Patch0: valgrind.xen.patch Patch1: jit-register-unregister.diff Patch2: armv6-support.diff -Patch3: epoll-wait-fix.patch Patch4: Implement-emulated-system-registers.-Fixes-392146.patch -# PATCH-FIX-UPSTREAM [backport] - https://sourceware.org/git/?p=valgrind.git;a=commit;h=64aa729bfae71561505a40c12755bd6b55bb3061 -Patch5: 0001-Accept-read-only-PT_LOAD-segments-and-.rodata.patch -# PATCH-FIX-UPSTREAM - https://sourceware.org/git/?p=valgrind.git;a=commit;h=6a55b1e82ccda3f0d663d2cc89eb543ae2d096bf -Patch6: Fix-access-to-time-base-register-to-return-64-bits.patch +Patch5: 0001-Bug-400490-s390x-Fix-register-allocation-for-VRs-vs-.patch +Patch6: 0001-Bug-400491-s390x-Sign-extend-immediate-operand-of-LO.patch +Patch7: 0001-Bug-397187-s390x-Add-vector-register-support-for-vgd.patch +Patch8: 0001-s390x-more-fixes.patch BuildRequires: automake BuildRequires: docbook-xsl-stylesheets BuildRequires: docbook_4 +%if 0%{?suse_version} < 1320 +BuildRequires: gcc8-c++ +%else BuildRequires: gcc-c++ +%endif BuildRequires: glibc-devel-32bit BuildRequires: libxslt BuildRequires: pkgconfig +BuildRequires: procps Requires: glibc >= %{glibc_main_version}.%{glibc_major_version} Requires: glibc < %{glibc_main_version}.%{lua:print(rpm.expand("%{glibc_major_version}")+1)} Provides: callgrind = %{version} @@ -110,12 +114,18 @@ but it has been successfully used to optimize several KDE applications. # needs porting to 3.11 ##%patch1 %patch2 -%patch3 %patch4 -p1 %patch5 -p1 %patch6 -p1 +%patch7 -p1 +%patch8 -p1 %build +%if 0%{?suse_version} < 1320 +export CC="%{_bindir}/gcc-8" +export CXX="%{_bindir}/g++-8" +%endif + export FLAGS="%{optflags}" %ifarch %arm # Valgrind doesn't support compiling for Thumb yet. Remove when it gets @@ -135,8 +145,9 @@ autoreconf -fi export GDB=%{_bindir}/gdb %configure \ + --enable-lto=yes \ %ifarch aarch64 - --enable-only64bit + --enable-only64bit %endif make %{?_smp_mflags} @@ -157,8 +168,17 @@ fi mkdir -p %{buildroot}%{_docdir}/%{name} cp -a README* NEWS AUTHORS %{buildroot}/%{_defaultdocdir}/%{name} +%check +# OBS doesn't have a z13 +%ifnarch s390x +# has too many spurious failures +# make %{?_smp_mflags} regtest +#patent pending self test +VALGRIND_LIB=$PWD/.in_place VALGRIND_LIB_INNER=$PWD/.in_place ./coregrind/valgrind /usr/bin/perl -wc tests/vg_regtest +%endif + %files -%license COPYING COPYING.DOCS +%license COPYING COPYING.DOCS %{_bindir}/* %doc %{_defaultdocdir}/%{name} %doc %{_mandir}/*/* @@ -257,12 +277,16 @@ cp -a README* NEWS AUTHORS %{buildroot}/%{_defaultdocdir}/%{name} %{_libdir}/valgrind/s390-acr.xml %{_libdir}/valgrind/s390-fpr-valgrind-s*.xml %{_libdir}/valgrind/s390-fpr.xml +%{_libdir}/valgrind/s390-vx-valgrind-s*.xml +%{_libdir}/valgrind/s390-vx.xml %{_libdir}/valgrind/s390x-core64-valgrind-s*.xml %{_libdir}/valgrind/s390x-core64.xml %{_libdir}/valgrind/s390x-generic-valgrind.xml %{_libdir}/valgrind/s390x-generic.xml %{_libdir}/valgrind/s390x-linux64-valgrind-s*.xml %{_libdir}/valgrind/s390x-linux64.xml +%{_libdir}/valgrind/s390x-vx-linux-valgrind.xml +%{_libdir}/valgrind/s390x-vx-linux.xml %files devel %{_libdir}/valgrind/lib*.a diff --git a/valgrind.xen.patch b/valgrind.xen.patch index c058d88..80e00ee 100644 --- a/valgrind.xen.patch +++ b/valgrind.xen.patch @@ -1,41 +1,379 @@ +The following changes since commit ddfc274b24a1ae3b57166ada1fe97acb433b9b79: -https://bugs.kde.org/show_bug.cgi?id=390553 -https://github.com/olafhering/valgrind/compare/master...xen + s390x: More fixes for z13 support (2018-11-22 13:45:56 +0100) - coregrind/m_syswrap/syswrap-linux.c | 17 + - coregrind/m_syswrap/syswrap-xen.c | 549 ++++++++++++++++++++++++++++++------ - include/vki/vki-linux.h | 15 - include/vki/vki-xen-domctl.h | 215 +++++++++++++- - include/vki/vki-xen-gnttab.h | 1 - include/vki/vki-xen-memory.h | 12 - include/vki/vki-xen-physdev.h | 9 - include/vki/vki-xen-schedop.h | 2 - include/vki/vki-xen-sysctl.h | 88 +++++ - include/vki/vki-xen-version.h | 11 - include/vki/vki-xen.h | 4 - 11 files changed, 831 insertions(+), 92 deletions(-) +are available in the Git repository at: -Index: valgrind-3.13.0/coregrind/m_syswrap/syswrap-xen.c -=================================================================== ---- valgrind-3.13.0.orig/coregrind/m_syswrap/syswrap-xen.c -+++ valgrind-3.13.0/coregrind/m_syswrap/syswrap-xen.c + https://github.com/olafhering/valgrind bug390553-20181125-ddfc274b2 + +for you to fetch changes up to 1c102a54e05843c6525f536c4844b68fafaa0955: + + fix whitespace in syswrap-xen.c (2018-11-25 21:11:03 +0100) + +---------------------------------------------------------------- +Olaf Hering (101): + Remove dead code from XEN_DOMCTL_monitor_op + fix xen_sysctl_numainfo handling + Expect earliest version for versioned xen domctl/sysctl + fix typo in xen domctl and sysctl header + remove unhelpful comments from xen domctl + merge two xen domctl values for clearity + mention sysctl and domctl numbers from ancient Xen versions + xen: include vki-xen-physdev.h earlier in vki-xen.h + xen-3.0: versioned xen_domctl_settimeoffset + xen-3.0.4: versioned xen_domctl_createdomain + xen-3.1: handle IOCTL_GNTDEV_MAP_GRANT_REF + xen-3.1: handle IOCTL_GNTDEV_UNMAP_GRANT_REF + xen-3.1: handle IOCTL_GNTDEV_GET_OFFSET_FOR_VADDR + xen-3.3: handle IOCTL_GNTDEV_SET_MAX_GRANTS + xen-3.4: handle XENMEM_set_pod_target/XENMEM_get_pod_target + xen-3.4: versioned hvmcontext_partial + xen-4.1: versioned XEN_SYSCTL_numainfo + xen-4.2: handle IOCTL_GNTALLOC_ALLOC_GREF + xen-4.2: handle IOCTL_GNTALLOC_DEALLOC_GREF + xen-4.2: handle IOCTL_GNTALLOC_SET_UNMAP_NOTIFY + xen-4.2: define sharing_op + xen-4.4: define add_to_physmap_batch + xen-4.5: define sysctl psr_cmt_op + xen-4.5: define GNTTABOP_cache_flush + xen-4.5: define domctl setvnumainfo + xen-4.5: define domctl psr_cmt_op + xen-4.5: define domctl arm_configure_domain + xen-4.5: define XENMEM_get_vnumainfo + xen-4.5: versioned XEN_SYSCTL_topologyinfo + xen-4.5: handle all versioned domctl ops + xen-4.6: adjust case value for VKI_XEN_DOMCTL_monitor_op + xen-4.6: new sysctl value + xen-4.6: versioned xen_domctl_createdomain + xen-4.6: versioned xen_domctl_settimeoffset + xen-4.6: define domctl psr_cat_op + xen-4.6: define XENMEM_reserved_device_memory_map + xen-4.6: versioned XEN_SYSCTL_numainfo + xen-4.6: handle XEN_SYSCTL_cputopoinfo + xen-4.6: handle XEN_SYSCTL_pcitopoinfo + xen-4.6: define sysctl psr_cat_op + xen-4.6: define sysctl tmem_op + xen-4.6: define hypercall xenpmu_op + xen-4.6: handle all versioned domctl ops + xen-4.6: handle all versioned sysctl ops + xen-4.7: new sysctl value + xen-4.7: fix domctl value in comment + xen-4.7: versioned xen_arch_domainconfig + xen-4.7: define XEN_VCPUAFFINITY_FORCE + xen-4.7: define SCHEDOP put/getvcpuinfo + xen-4.7: handle domctl soft_reset + xen-4.7: define SCHEDOP_pin_override + xen-4.7: versioned XEN_SYSCTL_get_cpu_featureset + xen-4.7: define sysctl get_cpu_levelling_caps + xen-4.7: define sysctl livepatch_op + xen-4.7: handle XENVER_build_id + xen-4.7: handle all versioned sysctl ops + xen-4.8: new domctl value + xen-4.8: new sysctl value + xen-4.8: handle IOCTL_GNTDEV_GRANT_COPY + xen-4.8: versioned xen_domctl_monitor_op + xen-4.8: handle all versioned domctl ops + xen-4.8: handle all versioned sysctl ops + xen-4.9: new domctl value + xen-4.9: new sysctl value + xen-4.9: define NULL scheduler + xen-4.9: define monitor event INTERRUPT and DESC_ACCESS + xen-4.9: define sysctl gcov_op, which replaces coverage_op + xen-4.9: handle dm_op hypercall + xen-4.9: handle IOCTL_PRIVCMD_DM_OP + xen-4.9: handle IOCTL_PRIVCMD_RESTRICT + xen-4.9: handle all versioned domctl ops + xen-4.9: handle all versioned sysctl ops + xen-4.10: add domctl value + xen-4.10: new sysctl value + xen-4.10: handle xen_domctl_assign_device + xen-4.10: versioned hvmcontext_partial + xen-4.10: versioned xen_domctl_monitor_op + xen-4.10: define monitor event EMUL_UNIMPLEMENTED + xen-4.10: support xen_domctl_set_gnttab_limits + xen-4.10: define domctl vuart_op + xen-4.10: versioned xen_sysctl_physinfo + xen-4.10: define sysctl set_parameter + xen-4.10: handle all versioned domctl ops + xen-4.10: handle all versioned sysctl ops + xen-4.10.1: new domctl value from shim + xen-4.10.1: versioned xen_domctl_getdomaininfo + xen-4.10.1: handle all versioned domctl ops + xen-4.11: new domctl value + xen-4.11: new sysctl value + xen-4.11: versioned xen_domctl_monitor_op + xen-4.11: handle IOCTL_PRIVCMD_MMAP_RESOURCE + xen-4.11: handle all versioned domctl ops + xen-4.11: handle all versioned sysctl ops + xen-4.12: new domctl value + xen-4.12: new sysctl value + xen-4.12: define sysctl get_cpu_policy + xen-4.12: handle IOCTL_PRIVCMD_UNIMPLEMENTED + xen-4.12: versioned xen_domctl_createdomain + xen-4.12: handle all versioned domctl ops + xen-4.12: handle all versioned sysctl ops + fix whitespace in syswrap-xen.c + + coregrind/m_syswrap/syswrap-linux.c | 154 ++++++ + coregrind/m_syswrap/syswrap-xen.c | 1014 +++++++++++++++++++++++++++++------ + include/vki/vki-linux.h | 110 ++++ + include/vki/vki-xen-domctl.h | 246 ++++++++- + include/vki/vki-xen-gnttab.h | 1 + + include/vki/vki-xen-memory.h | 12 + + include/vki/vki-xen-physdev.h | 9 + + include/vki/vki-xen-schedop.h | 2 + + include/vki/vki-xen-sysctl.h | 99 +++- + include/vki/vki-xen-version.h | 11 + + include/vki/vki-xen.h | 4 +- + 11 files changed, 1469 insertions(+), 193 deletions(-) + +diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c +index 90d4a8586..b98007082 100644 +--- a/coregrind/m_syswrap/syswrap-linux.c ++++ b/coregrind/m_syswrap/syswrap-linux.c +@@ -8219,6 +8219,38 @@ PRE(sys_ioctl) + (Addr)args->arr, sizeof(*(args->arr)) * args->num); + break; + } ++ case VKI_XEN_IOCTL_PRIVCMD_DM_OP: { ++ struct vki_xen_privcmd_dm_op *args = ++ (struct vki_xen_privcmd_dm_op *)(ARG3); ++ PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_DM_OP(dom)", ++ (Addr)&args->dom, sizeof(args->dom)); ++ PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_DM_OP(num)", ++ (Addr)&args->num, sizeof(args->num)); ++ PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_DM_OP(ubufs)", ++ (Addr)args->ubufs, sizeof(*(args->ubufs)) * args->num); ++ break; ++ } ++ case VKI_XEN_IOCTL_PRIVCMD_RESTRICT: ++ break; ++ case VKI_XEN_IOCTL_PRIVCMD_MMAP_RESOURCE: { ++ struct vki_xen_privcmd_mmap_resource *args = ++ (struct vki_xen_privcmd_mmap_resource *)(ARG3); ++ PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_MMAP_RESOURCE(dom)", ++ (Addr)&args->dom, sizeof(args->dom)); ++ PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_MMAP_RESOURCE(type)", ++ (Addr)&args->type, sizeof(args->type)); ++ PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_MMAP_RESOURCE(id)", ++ (Addr)&args->id, sizeof(args->id)); ++ PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_MMAP_RESOURCE(idx)", ++ (Addr)&args->idx, sizeof(args->idx)); ++ PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_MMAP_RESOURCE(num)", ++ (Addr)&args->num, sizeof(args->num)); ++ PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_MMAP_RESOURCE(addr)", ++ (Addr)&args->addr, sizeof(args->addr)); ++ break; ++ } ++ case VKI_XEN_IOCTL_PRIVCMD_UNIMPLEMENTED: ++ break; + + case VKI_XEN_IOCTL_EVTCHN_BIND_VIRQ: { + struct vki_xen_ioctl_evtchn_bind_virq *args = +@@ -8260,6 +8292,80 @@ PRE(sys_ioctl) + case VKI_XEN_IOCTL_EVTCHN_RESET: + /* No input*/ + break; ++ case VKI_XEN_IOCTL_GNTDEV_MAP_GRANT_REF: { ++ struct vki_xen_ioctl_gntdev_map_grant_ref *args = ++ (struct vki_xen_ioctl_gntdev_map_grant_ref*)(Addr)(ARG3); ++ PRE_MEM_READ("VKI_XEN_IOCTL_GNTDEV_map_grant_ref(count)", ++ (Addr)&args->count, sizeof(args->count)); ++ PRE_MEM_READ("VKI_XEN_IOCTL_GNTDEV_map_grant_ref(refs)", ++ (Addr)args->refs, sizeof(*(args->refs)) * args->count); ++ } ++ break; ++ case VKI_XEN_IOCTL_GNTDEV_UNMAP_GRANT_REF: { ++ struct vki_xen_ioctl_gntdev_map_grant_ref *args = ++ (struct vki_xen_ioctl_gntdev_map_grant_ref*)(Addr)(ARG3); ++ PRE_MEM_READ("VKI_XEN_IOCTL_GNTDEV_map_grant_ref(index)", ++ (Addr)&args->index, sizeof(args->index)); ++ PRE_MEM_READ("VKI_XEN_IOCTL_GNTDEV_map_grant_ref(count)", ++ (Addr)&args->count, sizeof(args->count)); ++ PRE_MEM_READ("VKI_XEN_IOCTL_GNTDEV_map_grant_ref(pad)", ++ (Addr)&args->pad, sizeof(args->pad)); ++ } ++ break; ++ case VKI_XEN_IOCTL_GNTDEV_GET_OFFSET_FOR_VADDR: { ++ struct vki_xen_ioctl_gntdev_get_offset_for_vaddr *args = ++ (struct vki_xen_ioctl_gntdev_get_offset_for_vaddr*)(Addr)(ARG3); ++ PRE_MEM_READ("VKI_XEN_IOCTL_GNTDEV_map_grant_ref(vaddr)", ++ (Addr)&args->vaddr, sizeof(args->vaddr)); ++ } ++ break; ++ case VKI_XEN_IOCTL_GNTDEV_SET_MAX_GRANTS: { ++ struct vki_xen_ioctl_gntdev_set_max_grants *args = ++ (struct vki_xen_ioctl_gntdev_set_max_grants*)(Addr)(ARG3); ++ PRE_MEM_READ("VKI_XEN_IOCTL_GNTDEV_set_max_grants(count)", ++ (Addr)&args->count, sizeof(args->count)); ++ } ++ break; ++ case VKI_XEN_IOCTL_GNTALLOC_ALLOC_GREF: { ++ struct vki_xen_ioctl_gntalloc_alloc_gref *args = ++ (struct vki_xen_ioctl_gntalloc_alloc_gref*)(Addr)(ARG3); ++ PRE_MEM_READ("VKI_XEN_IOCTL_GNTALLOC_alloc_gref(domid)", ++ (Addr)&args->domid, sizeof(args->domid)); ++ PRE_MEM_READ("VKI_XEN_IOCTL_GNTALLOC_alloc_gref(flags)", ++ (Addr)&args->flags, sizeof(args->flags)); ++ PRE_MEM_READ("VKI_XEN_IOCTL_GNTALLOC_alloc_gref(count)", ++ (Addr)&args->count, sizeof(args->count)); ++ } ++ break; ++ case VKI_XEN_IOCTL_GNTALLOC_DEALLOC_GREF: { ++ struct vki_xen_ioctl_gntalloc_dealloc_gref *args = ++ (struct vki_xen_ioctl_gntalloc_dealloc_gref*)(Addr)(ARG3); ++ PRE_MEM_READ("VKI_XEN_IOCTL_GNTALLOC_dealloc_gref(index)", ++ (Addr)&args->index, sizeof(args->index)); ++ PRE_MEM_READ("VKI_XEN_IOCTL_GNTALLOC_dealloc_gref(count)", ++ (Addr)&args->count, sizeof(args->count)); ++ } ++ break; ++ case VKI_XEN_IOCTL_GNTALLOC_SET_UNMAP_NOTIFY: { ++ struct vki_xen_ioctl_gntalloc_set_unmap_notify *args = ++ (struct vki_xen_ioctl_gntalloc_set_unmap_notify*)(Addr)(ARG3); ++ PRE_MEM_READ("VKI_XEN_IOCTL_GNTALLOC_set_unmap_notify(index)", ++ (Addr)&args->index, sizeof(args->index)); ++ PRE_MEM_READ("VKI_XEN_IOCTL_GNTALLOC_set_unmap_notify(action)", ++ (Addr)&args->action, sizeof(args->action)); ++ PRE_MEM_READ("VKI_XEN_IOCTL_GNTALLOC_set_unmap_notify(event_channel_port)", ++ (Addr)&args->event_channel_port, sizeof(args->event_channel_port)); ++ } ++ break; ++ case VKI_XEN_IOCTL_GNTDEV_GRANT_COPY: { ++ struct vki_xen_ioctl_gntdev_grant_copy *args = ++ (struct vki_xen_ioctl_gntdev_grant_copy*)(Addr)(ARG3); ++ PRE_MEM_READ("VKI_XEN_IOCTL_GNTDEV_grant_copy(count)", ++ (Addr)&args->count, sizeof(args->count)); ++ PRE_MEM_READ("VKI_XEN_IOCTL_GNTDEV_grant_copy(segments)", ++ (Addr)args->segments, sizeof(*(args->segments)) * args->count); ++ } ++ break; + #endif + + /* Lustre */ +@@ -10726,6 +10832,16 @@ POST(sys_ioctl) + POST_MEM_WRITE((Addr)args->err, sizeof(*(args->err)) * args->num); + } + break; ++ case VKI_XEN_IOCTL_PRIVCMD_DM_OP: { ++ struct vki_xen_privcmd_dm_op *args = ++ (struct vki_xen_privcmd_dm_op *)(ARG3); ++ POST_MEM_WRITE((Addr)args->ubufs, sizeof(*(args->ubufs)) * args->num); ++ } ++ break; ++ case VKI_XEN_IOCTL_PRIVCMD_RESTRICT: ++ case VKI_XEN_IOCTL_PRIVCMD_MMAP_RESOURCE: ++ case VKI_XEN_IOCTL_PRIVCMD_UNIMPLEMENTED: ++ break; + + case VKI_XEN_IOCTL_EVTCHN_BIND_VIRQ: + case VKI_XEN_IOCTL_EVTCHN_BIND_INTERDOMAIN: +@@ -10735,6 +10851,44 @@ POST(sys_ioctl) + case VKI_XEN_IOCTL_EVTCHN_RESET: + /* No output */ + break; ++ case VKI_XEN_IOCTL_GNTDEV_MAP_GRANT_REF: { ++ struct vki_xen_ioctl_gntdev_map_grant_ref *args = ++ (struct vki_xen_ioctl_gntdev_map_grant_ref*)(Addr)(ARG3); ++ POST_FIELD_WRITE(args->index); ++ } ++ break; ++ case VKI_XEN_IOCTL_GNTDEV_UNMAP_GRANT_REF: ++ /* No output */ ++ break; ++ case VKI_XEN_IOCTL_GNTDEV_GET_OFFSET_FOR_VADDR: { ++ struct vki_xen_ioctl_gntdev_get_offset_for_vaddr *args = ++ (struct vki_xen_ioctl_gntdev_get_offset_for_vaddr*)(Addr)(ARG3); ++ POST_FIELD_WRITE(args->count); ++ POST_FIELD_WRITE(args->offset); ++ } ++ break; ++ case VKI_XEN_IOCTL_GNTDEV_SET_MAX_GRANTS: ++ /* No output */ ++ break; ++ case VKI_XEN_IOCTL_GNTALLOC_ALLOC_GREF: { ++ struct vki_xen_ioctl_gntalloc_alloc_gref *args = ++ (struct vki_xen_ioctl_gntalloc_alloc_gref*)(Addr)(ARG3); ++ POST_FIELD_WRITE(args->index); ++ POST_FIELD_WRITE(args->count); ++ POST_MEM_WRITE((Addr)&args->gref_ids, ++ sizeof(args->gref_ids) * sizeof(args->count)); ++ } ++ break; ++ case VKI_XEN_IOCTL_GNTALLOC_DEALLOC_GREF: ++ case VKI_XEN_IOCTL_GNTALLOC_SET_UNMAP_NOTIFY: ++ /* No output */ ++ break; ++ case VKI_XEN_IOCTL_GNTDEV_GRANT_COPY: { ++ struct vki_xen_ioctl_gntdev_grant_copy *args = ++ (struct vki_xen_ioctl_gntdev_grant_copy*)(Addr)(ARG3); ++ POST_MEM_WRITE((Addr)args->segments, sizeof(*(args->segments)) * args->count); ++ } ++ break; + #endif + + /* Lustre */ +diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c +index 54153ab1c..35e5ab453 100644 +--- a/coregrind/m_syswrap/syswrap-xen.c ++++ b/coregrind/m_syswrap/syswrap-xen.c +@@ -137,7 +137,7 @@ PRE(memory_op) + + case VKI_XENMEM_set_memory_map: { + struct vki_xen_foreign_memory_map *arg = +- (struct vki_xen_foreign_memory_map *)ARG2; ++ (struct vki_xen_foreign_memory_map *)ARG2; + PRE_MEM_READ("XENMEM_set_memory_map domid", + (Addr)&arg->domid, sizeof(arg->domid)); + PRE_MEM_READ("XENMEM_set_memory_map map", +@@ -148,7 +148,7 @@ PRE(memory_op) + case VKI_XENMEM_memory_map: + case VKI_XENMEM_machine_memory_map: { + struct vki_xen_memory_map *arg = +- (struct vki_xen_memory_map *)ARG2; ++ (struct vki_xen_memory_map *)ARG2; + PRE_MEM_READ("XENMEM_memory_map nr_entries", + (Addr)&arg->nr_entries, sizeof(arg->nr_entries)); + break; +@@ -171,7 +171,7 @@ PRE(memory_op) + PRE_MEM_READ(which, + (Addr)memory_reservation->extent_start.p, + sizeof(vki_xen_pfn_t) * memory_reservation->nr_extents); +- break; ++ break; + case VKI_XENMEM_populate_physmap: + which = "XENMEM_populate_physmap"; + PRE_MEM_READ(which, @@ -234,6 +234,16 @@ PRE(memory_op) case VKI_XENMEM_get_sharing_shared_pages: break; + case VKI_XENMEM_get_pod_target: + case VKI_XENMEM_set_pod_target: { -+ struct vki_xen_pod_target *arg = -+ (struct vki_xen_pod_target *)ARG2; -+ PRE_MEM_READ("XENMEM_set_pod_target target_pages", -+ (Addr)&arg->target_pages, sizeof(arg->target_pages)); -+ PRE_MEM_READ("XENMEM_set_pod_target domid", -+ (Addr)&arg->domid, sizeof(arg->domid)); -+ break; ++ struct vki_xen_pod_target *arg = ++ (struct vki_xen_pod_target *)ARG2; ++ PRE_MEM_READ("XENMEM_set_pod_target target_pages", ++ (Addr)&arg->target_pages, sizeof(arg->target_pages)); ++ PRE_MEM_READ("XENMEM_set_pod_target domid", ++ (Addr)&arg->domid, sizeof(arg->domid)); ++ break; + } case VKI_XENMEM_access_op: { struct vki_xen_mem_event_op *arg = (struct vki_xen_mem_event_op *)ARG2; +@@ -469,9 +479,9 @@ PRE(physdev_op) + + PRINT("__HYPERVISOR_physdev_op ( %ld, %#lx )", SARG1, ARG2); + +-#define PRE_XEN_PHYSDEVOP_READ(_op, _field) \ +- PRE_MEM_READ("XEN_PHYSDEVOP_" #_op " ." #_field, \ +- (Addr)&arg->_field, \ ++#define PRE_XEN_PHYSDEVOP_READ(_op, _field) \ ++ PRE_MEM_READ("XEN_PHYSDEVOP_" #_op " ." #_field, \ ++ (Addr)&arg->_field, \ + sizeof(arg->_field)) + + switch (cmd) { @@ -532,6 +542,7 @@ PRE(xen_version) case VKI_XENVER_pagesize: case VKI_XENVER_guest_handle: @@ -44,45 +382,110 @@ Index: valgrind-3.13.0/coregrind/m_syswrap/syswrap-xen.c /* No inputs */ break; -@@ -584,6 +595,11 @@ PRE(sysctl) { +@@ -548,11 +559,11 @@ PRE(grant_table_op) + switch (ARG1) { + case VKI_XEN_GNTTABOP_setup_table: { + struct vki_xen_gnttab_setup_table *gst = +- (struct vki_xen_gnttab_setup_table*)ARG2; ++ (struct vki_xen_gnttab_setup_table*)ARG2; + PRE_MEM_READ("VKI_XEN_GNTTABOP_setup_table dom", +- (Addr)&gst->dom, sizeof(gst->dom)); ++ (Addr)&gst->dom, sizeof(gst->dom)); + PRE_MEM_READ("VKI_XEN_GNTTABOP_setup_table nr_frames", +- (Addr)&gst->nr_frames, sizeof(gst->nr_frames)); ++ (Addr)&gst->nr_frames, sizeof(gst->nr_frames)); + break; + } + default: +@@ -584,16 +595,23 @@ PRE(sysctl) { case 0x00000009: case 0x0000000a: case 0x0000000b: +- break; + case 0x0000000c: + case 0x0000000d: + case 0x0000000e: + case 0x0000000f: + case 0x00000010: - break; ++ case 0x00000011: ++ case 0x00000012: ++ break; default: bad_intf_version(tid, layout, arrghs, status, flags, -@@ -626,16 +642,11 @@ PRE(sysctl) { - break; + "__HYPERVISOR_sysctl", sysctl->interface_version); + return; + } + +-#define __PRE_XEN_SYSCTL_READ(_sysctl, _union, _field) \ +- PRE_MEM_READ("XEN_SYSCTL_" #_sysctl " u." #_union "." #_field, \ +- (Addr)&sysctl->u._union._field, \ ++#define __PRE_XEN_SYSCTL_READ(_sysctl, _union, _field) \ ++ PRE_MEM_READ("XEN_SYSCTL_" #_sysctl " u." #_union "." #_field, \ ++ (Addr)&sysctl->u._union._field, \ + sizeof(sysctl->u._union._field)) + #define PRE_XEN_SYSCTL_READ(_sysctl, _field) \ + __PRE_XEN_SYSCTL_READ(_sysctl, _sysctl, _field) +@@ -615,27 +633,33 @@ PRE(sysctl) { + switch (sysctl->interface_version) + { + case 0x00000008: +- PRE_XEN_SYSCTL_READ(getdomaininfolist_00000008, first_domain); +- PRE_XEN_SYSCTL_READ(getdomaininfolist_00000008, max_domains); +- PRE_XEN_SYSCTL_READ(getdomaininfolist_00000008, buffer); +- break; ++ PRE_XEN_SYSCTL_READ(getdomaininfolist_00000008, first_domain); ++ PRE_XEN_SYSCTL_READ(getdomaininfolist_00000008, max_domains); ++ PRE_XEN_SYSCTL_READ(getdomaininfolist_00000008, buffer); ++ break; + case 0x00000009: +- PRE_XEN_SYSCTL_READ(getdomaininfolist_00000009, first_domain); +- PRE_XEN_SYSCTL_READ(getdomaininfolist_00000009, max_domains); +- PRE_XEN_SYSCTL_READ(getdomaininfolist_00000009, buffer); +- break; ++ PRE_XEN_SYSCTL_READ(getdomaininfolist_00000009, first_domain); ++ PRE_XEN_SYSCTL_READ(getdomaininfolist_00000009, max_domains); ++ PRE_XEN_SYSCTL_READ(getdomaininfolist_00000009, buffer); ++ break; case 0x0000000a: case 0x0000000b: -+ default: - PRE_XEN_SYSCTL_READ(getdomaininfolist_0000000a, first_domain); - PRE_XEN_SYSCTL_READ(getdomaininfolist_0000000a, max_domains); - PRE_XEN_SYSCTL_READ(getdomaininfolist_0000000a, buffer); - break; -- default: +- PRE_XEN_SYSCTL_READ(getdomaininfolist_0000000a, first_domain); +- PRE_XEN_SYSCTL_READ(getdomaininfolist_0000000a, max_domains); +- PRE_XEN_SYSCTL_READ(getdomaininfolist_0000000a, buffer); +- break; ++ case 0x0000000c: ++ case 0x0000000d: ++ case 0x0000000e: ++ case 0x0000000f: ++ case 0x00000010: ++ case 0x00000011: ++ case 0x00000012: ++ PRE_XEN_SYSCTL_READ(getdomaininfolist_0000000a, first_domain); ++ PRE_XEN_SYSCTL_READ(getdomaininfolist_0000000a, max_domains); ++ PRE_XEN_SYSCTL_READ(getdomaininfolist_0000000a, buffer); ++ break; + default: - VG_(dmsg)("WARNING: XEN_SYSCTL_getdomaininfolist for sysctl version " - "%"PRIx32" not implemented yet\n", - sysctl->interface_version); - SET_STATUS_Failure(VKI_EINVAL); - return; ++ VG_(dmsg)("WARNING: XEN_SYSCTL_getdomaininfolist for sysctl version " ++ "%"PRIx32" not implemented yet\n", sysctl->interface_version); ++ SET_STATUS_Failure(VKI_EINVAL); ++ return; } break; -@@ -681,17 +692,69 @@ PRE(sysctl) { +@@ -680,18 +704,87 @@ PRE(sysctl) { + /* No input params */ break; - case VKI_XEN_SYSCTL_topologyinfo: +- case VKI_XEN_SYSCTL_topologyinfo: - PRE_XEN_SYSCTL_READ(topologyinfo, max_cpu_index); - PRE_XEN_SYSCTL_READ(topologyinfo, cpu_to_core); - PRE_XEN_SYSCTL_READ(topologyinfo, cpu_to_socket); - PRE_XEN_SYSCTL_READ(topologyinfo, cpu_to_node); -+// case VKI_XEN_SYSCTL_cputopoinfo: ++ case VKI_XEN_SYSCTL_topologyinfo | VKI_XEN_SYSCTL_cputopoinfo: + switch (sysctl->interface_version) + { + case 0x00000007: @@ -96,7 +499,12 @@ Index: valgrind-3.13.0/coregrind/m_syswrap/syswrap-xen.c + PRE_XEN_SYSCTL_READ(topologyinfo, cpu_to_node); + break; + case 0x0000000c: -+ default: ++ case 0x0000000d: ++ case 0x0000000e: ++ case 0x0000000f: ++ case 0x00000010: ++ case 0x00000011: ++ case 0x00000012: + PRE_XEN_SYSCTL_READ(cputopoinfo_0000000c, num_cpus); + PRE_XEN_SYSCTL_READ(cputopoinfo_0000000c, cputopo); + break; @@ -110,18 +518,22 @@ Index: valgrind-3.13.0/coregrind/m_syswrap/syswrap-xen.c - PRE_XEN_SYSCTL_READ(numainfo, node_to_node_distance); + switch (sysctl->interface_version) + { -+ case 0x00000007: + case 0x00000008: + case 0x00000009: + case 0x0000000a: + case 0x0000000b: -+ PRE_XEN_SYSCTL_READ(numainfo_0000000b, max_node_index); -+ PRE_XEN_SYSCTL_READ(numainfo_0000000b, node_to_memsize); -+ PRE_XEN_SYSCTL_READ(numainfo_0000000b, node_to_memfree); -+ PRE_XEN_SYSCTL_READ(numainfo_0000000b, node_to_node_distance); ++ PRE_XEN_SYSCTL_READ(numainfo_00000008, max_node_index); ++ PRE_XEN_SYSCTL_READ(numainfo_00000008, node_to_memsize); ++ PRE_XEN_SYSCTL_READ(numainfo_00000008, node_to_memfree); ++ PRE_XEN_SYSCTL_READ(numainfo_00000008, node_to_node_distance); + break; + case 0x0000000c: -+ default: ++ case 0x0000000d: ++ case 0x0000000e: ++ case 0x0000000f: ++ case 0x00000010: ++ case 0x00000011: ++ case 0x00000012: + PRE_XEN_SYSCTL_READ(numainfo_0000000c, num_nodes); + PRE_XEN_SYSCTL_READ(numainfo_0000000c, meminfo); + PRE_XEN_SYSCTL_READ(numainfo_0000000c, distance); @@ -133,7 +545,12 @@ Index: valgrind-3.13.0/coregrind/m_syswrap/syswrap-xen.c + switch (sysctl->interface_version) + { + case 0x0000000c: -+ default: ++ case 0x0000000d: ++ case 0x0000000e: ++ case 0x0000000f: ++ case 0x00000010: ++ case 0x00000011: ++ case 0x00000012: + PRE_XEN_SYSCTL_READ(pcitopoinfo_0000000c, num_devs); + PRE_XEN_SYSCTL_READ(pcitopoinfo_0000000c, devs); + break; @@ -143,8 +560,12 @@ Index: valgrind-3.13.0/coregrind/m_syswrap/syswrap-xen.c + case VKI_XEN_SYSCTL_get_cpu_featureset: + switch (sysctl->interface_version) + { -+ case 0x0000000c: -+ default: ++ case 0x0000000d: ++ case 0x0000000e: ++ case 0x0000000f: ++ case 0x00000010: ++ case 0x00000011: ++ case 0x00000012: + PRE_XEN_SYSCTL_READ(cpu_featureset_0000000d, index); + PRE_XEN_SYSCTL_READ(cpu_featureset_0000000d, nr_features); + break; @@ -152,16 +573,49 @@ Index: valgrind-3.13.0/coregrind/m_syswrap/syswrap-xen.c break; default: -@@ -730,6 +793,8 @@ PRE(domctl) +@@ -716,8 +809,8 @@ PRE(domctl) + * vki_xen_domid_t domain; + */ + PRE_MEM_READ("__HYPERVISOR_domctl", ARG1, +- sizeof(vki_uint32_t) + sizeof(vki_uint32_t) +- + sizeof(vki_xen_domid_t)); ++ sizeof(vki_uint32_t) + sizeof(vki_uint32_t) ++ + sizeof(vki_xen_domid_t)); + + if (!domctl) + return; +@@ -730,16 +823,21 @@ PRE(domctl) case 0x0000000a: case 0x0000000b: case 0x0000000c: +- break; + case 0x0000000d: + case 0x0000000e: - break; ++ case 0x0000000f: ++ case 0x00000010: ++ case 0x00000011: ++ break; default: bad_intf_version(tid, layout, arrghs, status, flags, -@@ -757,9 +822,42 @@ PRE(domctl) + "__HYPERVISOR_domctl", domctl->interface_version); + return; + } + +-#define __PRE_XEN_DOMCTL_READ(_domctl, _union, _field) \ +- PRE_MEM_READ("XEN_DOMCTL_" #_domctl " u." #_union "." #_field, \ +- (Addr)&domctl->u._union._field, \ ++#define __PRE_XEN_DOMCTL_READ(_domctl, _union, _field) \ ++ PRE_MEM_READ("XEN_DOMCTL_" #_domctl " u." #_union "." #_field, \ ++ (Addr)&domctl->u._union._field, \ + sizeof(domctl->u._union._field)) + #define PRE_XEN_DOMCTL_READ(_domctl, _field) \ + __PRE_XEN_DOMCTL_READ(_domctl, _domctl, _field) +@@ -753,13 +851,67 @@ PRE(domctl) + case VKI_XEN_DOMCTL_getdomaininfo: + case VKI_XEN_DOMCTL_unpausedomain: + case VKI_XEN_DOMCTL_resumedomain: ++ case VKI_XEN_DOMCTL_soft_reset: + /* No input fields. */ break; case VKI_XEN_DOMCTL_createdomain: @@ -173,9 +627,9 @@ Index: valgrind-3.13.0/coregrind/m_syswrap/syswrap-xen.c + case 0x00000008: + case 0x00000009: + case 0x0000000a: -+ PRE_XEN_DOMCTL_READ(createdomain_0000000a, ssidref); -+ PRE_XEN_DOMCTL_READ(createdomain_0000000a, handle); -+ PRE_XEN_DOMCTL_READ(createdomain_0000000a, flags); ++ PRE_XEN_DOMCTL_READ(createdomain_00000004, ssidref); ++ PRE_XEN_DOMCTL_READ(createdomain_00000004, handle); ++ PRE_XEN_DOMCTL_READ(createdomain_00000004, flags); + break; + case 0x0000000b: + PRE_XEN_DOMCTL_READ(createdomain_0000000b, ssidref); @@ -191,7 +645,10 @@ Index: valgrind-3.13.0/coregrind/m_syswrap/syswrap-xen.c +#endif + break; + case 0x0000000c: -+ default: ++ case 0x0000000d: ++ case 0x0000000e: ++ case 0x0000000f: ++ case 0x00000010: + PRE_XEN_DOMCTL_READ(createdomain_0000000c, ssidref); + PRE_XEN_DOMCTL_READ(createdomain_0000000c, handle); + PRE_XEN_DOMCTL_READ(createdomain_0000000c, flags); @@ -203,11 +660,28 @@ Index: valgrind-3.13.0/coregrind/m_syswrap/syswrap-xen.c + __PRE_XEN_DOMCTL_READ(createdomain_0000000c, createdomain_0000000c, config.nr_spis); + __PRE_XEN_DOMCTL_READ(createdomain_0000000c, createdomain_0000000c, config.clock_frequency); +#endif ++ break; ++ case 0x00000011: ++ PRE_XEN_DOMCTL_READ(createdomain_00000011, ssidref); ++ PRE_XEN_DOMCTL_READ(createdomain_00000011, handle); ++ PRE_XEN_DOMCTL_READ(createdomain_00000011, flags); ++ PRE_XEN_DOMCTL_READ(createdomain_00000011, max_vcpus); ++ PRE_XEN_DOMCTL_READ(createdomain_00000011, max_evtchn_port); ++ PRE_XEN_DOMCTL_READ(createdomain_00000011, max_maptrack_frames); ++#if defined(__i386__) || defined(__x86_64__) ++ __PRE_XEN_DOMCTL_READ(createdomain_00000011, createdomain_00000011, config.emulation_flags); ++#endif ++#if defined(__arm__) || defined(__aarch64__) ++ __PRE_XEN_DOMCTL_READ(createdomain_00000011, createdomain_00000011, config.gic_version); ++ __PRE_XEN_DOMCTL_READ(createdomain_00000011, createdomain_00000011, config.nr_spis); ++ __PRE_XEN_DOMCTL_READ(createdomain_00000011, createdomain_00000011, config.clock_frequency); ++#endif ++ break; + } break; case VKI_XEN_DOMCTL_gethvmcontext: -@@ -780,30 +878,67 @@ PRE(domctl) +@@ -780,30 +932,69 @@ PRE(domctl) break; case VKI_XEN_DOMCTL_gethvmcontext_partial: @@ -230,6 +704,11 @@ Index: valgrind-3.13.0/coregrind/m_syswrap/syswrap-xen.c - break; - default: - bad_subop(tid, layout, arrghs, status, flags, +- "__HYPERVISOR_domctl_gethvmcontext_partial type", +- domctl->u.hvmcontext_partial.type); +- break; +- } +- break; + switch (domctl->interface_version) { + case 0x00000007: + case 0x00000008: @@ -238,36 +717,34 @@ Index: valgrind-3.13.0/coregrind/m_syswrap/syswrap-xen.c + case 0x0000000b: + case 0x0000000c: + case 0x0000000d: -+ __PRE_XEN_DOMCTL_READ(gethvmcontext_partial, hvmcontext_partial_0000000d, type); -+ __PRE_XEN_DOMCTL_READ(gethvmcontext_partial, hvmcontext_partial_0000000d, instance); -+ __PRE_XEN_DOMCTL_READ(gethvmcontext_partial, hvmcontext_partial_0000000d, buffer); ++ __PRE_XEN_DOMCTL_READ(gethvmcontext_partial, hvmcontext_partial_00000005, type); ++ __PRE_XEN_DOMCTL_READ(gethvmcontext_partial, hvmcontext_partial_00000005, instance); ++ __PRE_XEN_DOMCTL_READ(gethvmcontext_partial, hvmcontext_partial_00000005, buffer); + -+ switch (domctl->u.hvmcontext_partial_0000000d.type) { ++ switch (domctl->u.hvmcontext_partial_00000005.type) { + case VKI_HVM_SAVE_CODE(CPU): -+ if ( domctl->u.hvmcontext_partial_0000000d.buffer.p ) -+ PRE_MEM_WRITE("XEN_DOMCTL_gethvmcontext_partial *buffer", -+ (Addr)domctl->u.hvmcontext_partial_0000000d.buffer.p, -+ VKI_HVM_SAVE_LENGTH(CPU)); ++ if ( domctl->u.hvmcontext_partial_00000005.buffer.p ) ++ PRE_MEM_WRITE("XEN_DOMCTL_gethvmcontext_partial *buffer", ++ (Addr)domctl->u.hvmcontext_partial_00000005.buffer.p, ++ VKI_HVM_SAVE_LENGTH(CPU)); + break; + case VKI_HVM_SAVE_CODE(MTRR): -+ if ( domctl->u.hvmcontext_partial_0000000d.buffer.p ) -+ PRE_MEM_WRITE("XEN_DOMCTL_gethvmcontext_partial *buffer", -+ (Addr)domctl->u.hvmcontext_partial_0000000d.buffer.p, -+ VKI_HVM_SAVE_LENGTH(MTRR)); ++ if ( domctl->u.hvmcontext_partial_00000005.buffer.p ) ++ PRE_MEM_WRITE("XEN_DOMCTL_gethvmcontext_partial *buffer", ++ (Addr)domctl->u.hvmcontext_partial_00000005.buffer.p, ++ VKI_HVM_SAVE_LENGTH(MTRR)); + break; + default: + bad_subop(tid, layout, arrghs, status, flags, - "__HYPERVISOR_domctl_gethvmcontext_partial type", -- domctl->u.hvmcontext_partial.type); -- break; -- } -- break; -+ domctl->u.hvmcontext_partial_0000000d.type); ++ "__HYPERVISOR_domctl_gethvmcontext_partial type", ++ domctl->u.hvmcontext_partial_00000005.type); + break; + } + break; + case 0x0000000e: -+ default: ++ case 0x0000000f: ++ case 0x00000010: ++ case 0x00000011: + __PRE_XEN_DOMCTL_READ(gethvmcontext_partial, hvmcontext_partial_0000000e, type); + __PRE_XEN_DOMCTL_READ(gethvmcontext_partial, hvmcontext_partial_0000000e, instance); + __PRE_XEN_DOMCTL_READ(gethvmcontext_partial, hvmcontext_partial_0000000e, bufsz); @@ -276,20 +753,20 @@ Index: valgrind-3.13.0/coregrind/m_syswrap/syswrap-xen.c + switch (domctl->u.hvmcontext_partial_0000000e.type) { + case VKI_HVM_SAVE_CODE(CPU): + if ( domctl->u.hvmcontext_partial_0000000e.buffer.p ) -+ PRE_MEM_WRITE("XEN_DOMCTL_gethvmcontext_partial *buffer", -+ (Addr)domctl->u.hvmcontext_partial_0000000e.buffer.p, -+ VKI_HVM_SAVE_LENGTH(CPU)); ++ PRE_MEM_WRITE("XEN_DOMCTL_gethvmcontext_partial *buffer", ++ (Addr)domctl->u.hvmcontext_partial_0000000e.buffer.p, ++ VKI_HVM_SAVE_LENGTH(CPU)); + break; + case VKI_HVM_SAVE_CODE(MTRR): + if ( domctl->u.hvmcontext_partial_0000000e.buffer.p ) -+ PRE_MEM_WRITE("XEN_DOMCTL_gethvmcontext_partial *buffer", -+ (Addr)domctl->u.hvmcontext_partial_0000000e.buffer.p, -+ VKI_HVM_SAVE_LENGTH(MTRR)); ++ PRE_MEM_WRITE("XEN_DOMCTL_gethvmcontext_partial *buffer", ++ (Addr)domctl->u.hvmcontext_partial_0000000e.buffer.p, ++ VKI_HVM_SAVE_LENGTH(MTRR)); + break; + default: + bad_subop(tid, layout, arrghs, status, flags, -+ "__HYPERVISOR_domctl_gethvmcontext_partial type", -+ domctl->u.hvmcontext_partial_0000000e.type); ++ "__HYPERVISOR_domctl_gethvmcontext_partial type", ++ domctl->u.hvmcontext_partial_0000000e.type); + break; + } + break; @@ -298,7 +775,15 @@ Index: valgrind-3.13.0/coregrind/m_syswrap/syswrap-xen.c case VKI_XEN_DOMCTL_max_mem: PRE_XEN_DOMCTL_READ(max_mem, max_memkb); -@@ -822,6 +957,8 @@ PRE(domctl) +@@ -815,13 +1006,15 @@ PRE(domctl) + + case VKI_XEN_DOMCTL_test_assign_device: + switch (domctl->interface_version) { +- case 0x00000007: /* pre-4.6 */ ++ case 0x00000007: + case 0x00000008: + case 0x00000009: + case 0x0000000a: __PRE_XEN_DOMCTL_READ(test_assign_device, assign_device_00000007, machine_sbdf); break; case 0x0000000b: @@ -307,12 +792,14 @@ Index: valgrind-3.13.0/coregrind/m_syswrap/syswrap-xen.c __PRE_XEN_DOMCTL_READ(test_assign_device, assign_device_0000000b, dev); __PRE_XEN_DOMCTL_READ(test_assign_device, assign_device_0000000b, flag); switch (domctl->u.assign_device_0000000b.dev) { -@@ -841,6 +978,27 @@ PRE(domctl) +@@ -841,17 +1034,42 @@ PRE(domctl) break; } break; + case 0x0000000e: -+ default: ++ case 0x0000000f: ++ case 0x00000010: ++ case 0x00000011: + __PRE_XEN_DOMCTL_READ(test_assign_device, assign_device_0000000e, dev); + __PRE_XEN_DOMCTL_READ(test_assign_device, assign_device_0000000e, flags); + switch (domctl->u.assign_device_0000000e.dev) { @@ -335,7 +822,12 @@ Index: valgrind-3.13.0/coregrind/m_syswrap/syswrap-xen.c } break; case VKI_XEN_DOMCTL_assign_device: -@@ -852,6 +1010,8 @@ PRE(domctl) + switch (domctl->interface_version) { +- case 0x00000007: /* pre-4.6 */ ++ case 0x00000007: + case 0x00000008: + case 0x00000009: + case 0x0000000a: __PRE_XEN_DOMCTL_READ(assign_device, assign_device_00000007, machine_sbdf); break; case 0x0000000b: @@ -344,12 +836,14 @@ Index: valgrind-3.13.0/coregrind/m_syswrap/syswrap-xen.c __PRE_XEN_DOMCTL_READ(assign_device, assign_device_0000000b, dev); __PRE_XEN_DOMCTL_READ(assign_device, assign_device_0000000b, flag); switch (domctl->u.assign_device_0000000b.dev) { -@@ -871,6 +1031,27 @@ PRE(domctl) +@@ -871,17 +1089,37 @@ PRE(domctl) break; } break; + case 0x0000000e: -+ default: ++ case 0x0000000f: ++ case 0x00000010: ++ case 0x00000011: + __PRE_XEN_DOMCTL_READ(assign_device, assign_device_0000000e, dev); + __PRE_XEN_DOMCTL_READ(assign_device, assign_device_0000000e, flags); + switch (domctl->u.assign_device_0000000e.dev) { @@ -359,20 +853,20 @@ Index: valgrind-3.13.0/coregrind/m_syswrap/syswrap-xen.c + case VKI_XEN_DOMCTL_DEV_DT: + __PRE_XEN_DOMCTL_READ(assign_device, assign_device_0000000e, u.dt); + PRE_MEM_READ("XEN_DOMTCL_assign_device.dt", -+ (Addr)domctl->u.assign_device_0000000e.u.dt.path.p, -+ domctl->u.assign_device_0000000e.u.dt.size); -+ break; -+ default: -+ bad_subop(tid, layout, arrghs, status, flags, -+ "__HYPERVISOR_domctl_assign_device dev", -+ domctl->u.assign_device_0000000e.dev); ++ (Addr)domctl->u.assign_device_0000000e.u.dt.path.p, ++ domctl->u.assign_device_0000000e.u.dt.size); + break; + } + break; } break; case VKI_XEN_DOMCTL_deassign_device: -@@ -882,6 +1063,8 @@ PRE(domctl) + switch (domctl->interface_version) { +- case 0x00000007: /* pre-4.6 */ ++ case 0x00000007: + case 0x00000008: + case 0x00000009: + case 0x0000000a: __PRE_XEN_DOMCTL_READ(deassign_device, assign_device_00000007, machine_sbdf); break; case 0x0000000b: @@ -381,12 +875,14 @@ Index: valgrind-3.13.0/coregrind/m_syswrap/syswrap-xen.c __PRE_XEN_DOMCTL_READ(deassign_device, assign_device_0000000b, dev); __PRE_XEN_DOMCTL_READ(deassign_device, assign_device_0000000b, flag); switch (domctl->u.assign_device_0000000b.dev) { -@@ -901,6 +1084,27 @@ PRE(domctl) +@@ -901,12 +1139,30 @@ PRE(domctl) break; } break; + case 0x0000000e: -+ default: ++ case 0x0000000f: ++ case 0x00000010: ++ case 0x00000011: + __PRE_XEN_DOMCTL_READ(deassign_device, assign_device_0000000e, dev); + __PRE_XEN_DOMCTL_READ(deassign_device, assign_device_0000000e, flags); + switch (domctl->u.assign_device_0000000e.dev) { @@ -396,28 +892,35 @@ Index: valgrind-3.13.0/coregrind/m_syswrap/syswrap-xen.c + case VKI_XEN_DOMCTL_DEV_DT: + __PRE_XEN_DOMCTL_READ(deassign_device, assign_device_0000000e, u.dt); + PRE_MEM_READ("XEN_DOMTCL_assign_device.dt", -+ (Addr)domctl->u.assign_device_0000000e.u.dt.path.p, -+ domctl->u.assign_device_0000000e.u.dt.size); -+ break; -+ default: -+ bad_subop(tid, layout, arrghs, status, flags, -+ "__HYPERVISOR_domctl_deassign_device dev", -+ domctl->u.assign_device_0000000e.dev); ++ (Addr)domctl->u.assign_device_0000000e.u.dt.path.p, ++ domctl->u.assign_device_0000000e.u.dt.size); + break; + } + break; } break; -@@ -916,6 +1120,7 @@ PRE(domctl) + case VKI_XEN_DOMCTL_settscinfo: + switch (domctl->interface_version) { +- case 0x00000007: /* pre-4.6 */ ++ case 0x00000007: + case 0x00000008: + case 0x00000009: + case 0x0000000a: +@@ -916,6 +1172,12 @@ PRE(domctl) __PRE_XEN_DOMCTL_READ(settscinfo, tsc_info_00000007, info.elapsed_nsec); break; case 0x0000000b: -+ default: ++ case 0x0000000c: ++ case 0x0000000d: ++ case 0x0000000e: ++ case 0x0000000f: ++ case 0x00000010: ++ case 0x00000011: __PRE_XEN_DOMCTL_READ(settscinfo, tsc_info_0000000b, tsc_mode); __PRE_XEN_DOMCTL_READ(settscinfo, tsc_info_0000000b, gtsc_khz); __PRE_XEN_DOMCTL_READ(settscinfo, tsc_info_0000000b, incarnation); -@@ -946,8 +1151,19 @@ PRE(domctl) +@@ -946,8 +1208,24 @@ PRE(domctl) break; case VKI_XEN_DOMCTL_settimeoffset: @@ -428,10 +931,15 @@ Index: valgrind-3.13.0/coregrind/m_syswrap/syswrap-xen.c + case 0x00000008: + case 0x00000009: + case 0x0000000a: -+ PRE_XEN_DOMCTL_READ(settimeoffset_0000000a, time_offset_seconds); ++ PRE_XEN_DOMCTL_READ(settimeoffset_00000001, time_offset_seconds); + break; + case 0x0000000b: -+ default: ++ case 0x0000000c: ++ case 0x0000000d: ++ case 0x0000000e: ++ case 0x0000000f: ++ case 0x00000010: ++ case 0x00000011: + PRE_XEN_DOMCTL_READ(settimeoffset_0000000b, time_offset_seconds); + break; + } @@ -439,95 +947,207 @@ Index: valgrind-3.13.0/coregrind/m_syswrap/syswrap-xen.c case VKI_XEN_DOMCTL_getvcpuinfo: PRE_XEN_DOMCTL_READ(getvcpuinfo, vcpu); -@@ -991,6 +1207,7 @@ PRE(domctl) +@@ -991,6 +1269,13 @@ PRE(domctl) __PRE_XEN_DOMCTL_READ(getvcpuaffinity, vcpuaffinity_00000009, cpumap.nr_bits); break; case 0x0000000a: -+ default: ++ case 0x0000000b: ++ case 0x0000000c: ++ case 0x0000000d: ++ case 0x0000000e: ++ case 0x0000000f: ++ case 0x00000010: ++ case 0x00000011: __PRE_XEN_DOMCTL_READ(getvcpuaffinity, vcpuaffinity_0000000a, vcpu); if (domctl->u.vcpuaffinity_0000000a.flags & VKI_XEN_VCPUAFFINITY_HARD) __PRE_XEN_DOMCTL_READ( -@@ -1014,6 +1231,7 @@ PRE(domctl) +@@ -1014,6 +1299,13 @@ PRE(domctl) domctl->u.vcpuaffinity_00000009.cpumap.nr_bits / 8); break; case 0x0000000a: -+ default: ++ case 0x0000000b: ++ case 0x0000000c: ++ case 0x0000000d: ++ case 0x0000000e: ++ case 0x0000000f: ++ case 0x00000010: ++ case 0x00000011: __PRE_XEN_DOMCTL_READ(setvcpuaffinity, vcpuaffinity_0000000a, vcpu); __PRE_XEN_DOMCTL_READ(setvcpuaffinity, vcpuaffinity_0000000a, flags); if (domctl->u.vcpuaffinity_0000000a.flags & VKI_XEN_VCPUAFFINITY_HARD) { -@@ -1070,13 +1288,8 @@ PRE(domctl) +@@ -1070,6 +1362,14 @@ PRE(domctl) break; case 0x00000009: -- __PRE_XEN_DOMCTL_READ(get_ext_vcpucontext, ext_vcpucontext_00000009, vcpu); -- break; -- - default: -- VG_(dmsg)("WARNING: VKI_XEN_DOMCTL_get_ext_vcpucontext domctl version %#" -- PRIx32" not implemented\n", domctl->interface_version); -- SET_STATUS_Failure(VKI_EINVAL); -+ __PRE_XEN_DOMCTL_READ(get_ext_vcpucontext, ext_vcpucontext_00000009, vcpu); ++ case 0x0000000a: ++ case 0x0000000b: ++ case 0x0000000c: ++ case 0x0000000d: ++ case 0x0000000e: ++ case 0x0000000f: ++ case 0x00000010: ++ case 0x00000011: + __PRE_XEN_DOMCTL_READ(get_ext_vcpucontext, ext_vcpucontext_00000009, vcpu); break; - } - break; -@@ -1110,6 +1323,7 @@ PRE(domctl) + +@@ -1110,6 +1410,14 @@ PRE(domctl) break; case 0x00000009: -+ default: ++ case 0x0000000a: ++ case 0x0000000b: ++ case 0x0000000c: ++ case 0x0000000d: ++ case 0x0000000e: ++ case 0x0000000f: ++ case 0x00000010: ++ case 0x00000011: __PRE_XEN_DOMCTL_READ(set_ext_vcpucontext, ext_vcpucontext_00000009, vcpu); __PRE_XEN_DOMCTL_READ(set_ext_vcpucontext, ext_vcpucontext_00000009, size); #if defined(__i386__) || defined(__x86_64__) -@@ -1138,12 +1352,6 @@ PRE(domctl) +@@ -1137,7 +1445,7 @@ PRE(domctl) + mci_ctl2_bank1); } #endif - break; -- -- default: -- VG_(dmsg)("WARNING: VKI_XEN_DOMCTL_set_ext_vcpucontext domctl version %#" -- PRIx32" not implemented\n", domctl->interface_version); -- SET_STATUS_Failure(VKI_EINVAL); -- break; - } - break; +- break; ++ break; -@@ -1248,6 +1456,7 @@ PRE(domctl) + default: + VG_(dmsg)("WARNING: VKI_XEN_DOMCTL_set_ext_vcpucontext domctl version %#" +@@ -1237,10 +1545,9 @@ PRE(domctl) + PRE_XEN_DOMCTL_READ(access_required, access_required); + break; + +- case VKI_XEN_DOMCTL_mem_event_op: +- //case VKI_XEN_DOMCTL_vm_event_op: /* name change in 4.6 */ ++ case VKI_XEN_DOMCTL_mem_event_op | VKI_XEN_DOMCTL_vm_event_op: + switch (domctl->interface_version) { +- case 0x00000007: /* pre-4.6 */ ++ case 0x00000007: + case 0x00000008: + case 0x00000009: + case 0x0000000a: +@@ -1248,6 +1555,12 @@ PRE(domctl) __PRE_XEN_DOMCTL_READ(mem_event_op, mem_event_op_00000007, mode); break; case 0x0000000b: -+ default: ++ case 0x0000000c: ++ case 0x0000000d: ++ case 0x0000000e: ++ case 0x0000000f: ++ case 0x00000010: ++ case 0x00000011: __PRE_XEN_DOMCTL_READ(vm_event_op, vm_event_op_0000000b, op); __PRE_XEN_DOMCTL_READ(vm_event_op, vm_event_op_0000000b, mode); break; -@@ -1278,8 +1487,9 @@ PRE(domctl) +@@ -1277,7 +1590,7 @@ PRE(domctl) + case VKI_XEN_DOMCTL_monitor_op: switch (domctl->interface_version) { - case 0x000000b: -+ default: +- case 0x000000b: ++ case 0x0000000b: if (domctl->u.monitor_op_0000000b.op == VKI_XEN_DOMCTL_MONITOR_OP_ENABLE || -- domctl->u.monitor_op_0000000b.op == VKI_XEN_DOMCTL_MONITOR_OP_ENABLE) { -+ domctl->u.monitor_op_0000000b.op == VKI_XEN_DOMCTL_MONITOR_OP_DISABLE) { + domctl->u.monitor_op_0000000b.op == VKI_XEN_DOMCTL_MONITOR_OP_DISABLE) { switch (domctl->u.monitor_op_0000000b.event) { - case VKI_XEN_DOMCTL_MONITOR_EVENT_WRITE_CTRLREG: - __PRE_XEN_DOMCTL_READ(monitor_op, monitor_op_0000000b, u.mov_to_cr); -@@ -1299,6 +1509,16 @@ PRE(domctl) +@@ -1290,7 +1603,67 @@ PRE(domctl) + case VKI_XEN_DOMCTL_MONITOR_EVENT_GUEST_REQUEST: + __PRE_XEN_DOMCTL_READ(monitor_op, monitor_op_0000000b, u.guest_request); + break; +- case VKI_XEN_DOMCTL_MONITOR_OP_GET_CAPABILITIES: ++ } ++ } ++ ++ break; ++ case 0x0000000c: ++ case 0x0000000d: ++ if (domctl->u.monitor_op_0000000c.op == VKI_XEN_DOMCTL_MONITOR_OP_ENABLE || ++ domctl->u.monitor_op_0000000c.op == VKI_XEN_DOMCTL_MONITOR_OP_DISABLE) { ++ switch (domctl->u.monitor_op_0000000c.event) { ++ case VKI_XEN_DOMCTL_MONITOR_EVENT_WRITE_CTRLREG: ++ __PRE_XEN_DOMCTL_READ(monitor_op, monitor_op_0000000c, u.mov_to_cr); ++ break; ++ case VKI_XEN_DOMCTL_MONITOR_EVENT_MOV_TO_MSR: ++ __PRE_XEN_DOMCTL_READ(monitor_op, monitor_op_0000000c, u.mov_to_msr); ++ break; ++ case VKI_XEN_DOMCTL_MONITOR_EVENT_GUEST_REQUEST: ++ __PRE_XEN_DOMCTL_READ(monitor_op, monitor_op_0000000c, u.guest_request); ++ break; ++ case VKI_XEN_DOMCTL_MONITOR_EVENT_DEBUG_EXCEPTION: ++ __PRE_XEN_DOMCTL_READ(monitor_op, monitor_op_0000000c, u.debug_exception); ++ break; ++ } ++ } ++ break; ++ case 0x0000000e: ++ case 0x0000000f: ++ if (domctl->u.monitor_op_0000000e.op == VKI_XEN_DOMCTL_MONITOR_OP_ENABLE || ++ domctl->u.monitor_op_0000000e.op == VKI_XEN_DOMCTL_MONITOR_OP_DISABLE) { ++ switch (domctl->u.monitor_op_0000000e.event) { ++ case VKI_XEN_DOMCTL_MONITOR_EVENT_WRITE_CTRLREG: ++ __PRE_XEN_DOMCTL_READ(monitor_op, monitor_op_0000000e, u.mov_to_cr); ++ break; ++ case VKI_XEN_DOMCTL_MONITOR_EVENT_MOV_TO_MSR: ++ __PRE_XEN_DOMCTL_READ(monitor_op, monitor_op_0000000e, u.mov_to_msr); ++ break; ++ case VKI_XEN_DOMCTL_MONITOR_EVENT_GUEST_REQUEST: ++ __PRE_XEN_DOMCTL_READ(monitor_op, monitor_op_0000000e, u.guest_request); ++ break; ++ case VKI_XEN_DOMCTL_MONITOR_EVENT_DEBUG_EXCEPTION: ++ __PRE_XEN_DOMCTL_READ(monitor_op, monitor_op_0000000e, u.debug_exception); ++ break; ++ } ++ } ++ ++ break; ++ case 0x00000010: ++ case 0x00000011: ++ if (domctl->u.monitor_op_00000010.op == VKI_XEN_DOMCTL_MONITOR_OP_ENABLE || ++ domctl->u.monitor_op_00000010.op == VKI_XEN_DOMCTL_MONITOR_OP_DISABLE) { ++ switch (domctl->u.monitor_op_00000010.event) { ++ case VKI_XEN_DOMCTL_MONITOR_EVENT_WRITE_CTRLREG: ++ __PRE_XEN_DOMCTL_READ(monitor_op, monitor_op_00000010, u.mov_to_cr); ++ break; ++ case VKI_XEN_DOMCTL_MONITOR_EVENT_MOV_TO_MSR: ++ __PRE_XEN_DOMCTL_READ(monitor_op, monitor_op_00000010, u.mov_to_msr); ++ break; ++ case VKI_XEN_DOMCTL_MONITOR_EVENT_GUEST_REQUEST: ++ __PRE_XEN_DOMCTL_READ(monitor_op, monitor_op_00000010, u.guest_request); ++ break; ++ case VKI_XEN_DOMCTL_MONITOR_EVENT_DEBUG_EXCEPTION: ++ __PRE_XEN_DOMCTL_READ(monitor_op, monitor_op_00000010, u.debug_exception); + break; + } + } +@@ -1299,6 +1672,11 @@ PRE(domctl) } break; + case VKI_XEN_DOMCTL_set_gnttab_limits: -+ switch (domctl->interface_version) { -+ case 0x000000e: -+ default: -+ PRE_XEN_DOMCTL_READ(set_gnttab_limits_0000000e, grant_frames); -+ PRE_XEN_DOMCTL_READ(set_gnttab_limits_0000000e, maptrack_frames); -+ break; -+ } ++ PRE_XEN_DOMCTL_READ(set_gnttab_limits_0000000e, grant_frames); ++ PRE_XEN_DOMCTL_READ(set_gnttab_limits_0000000e, maptrack_frames); + break; + default: bad_subop(tid, layout, arrghs, status, flags, "__HYPERVISOR_domctl", domctl->cmd); -@@ -1474,6 +1694,7 @@ POST(memory_op) +@@ -1465,6 +1843,16 @@ PRE(tmem_op) + #undef __PRE_XEN_TMEMOP_READ + } + ++PRE(dm_op) ++{ ++ unsigned int domid = ARG1, num = ARG2; ++ struct vki_xen_privcmd_dm_op_buf *args = (void *)(ARG3); ++ ++ PRINT("__HYPERVISOR_dm_op ( %u, %u, %p )", domid, num, args); ++ ++ PRE_MEM_READ("__HYPERVISOR_dm_op ubuf", (Addr)args, sizeof(*args) * num); ++} ++ + POST(memory_op) + { + switch (ARG1) { +@@ -1474,6 +1862,7 @@ POST(memory_op) case VKI_XENMEM_claim_pages: case VKI_XENMEM_maximum_gpfn: case VKI_XENMEM_remove_from_physmap: @@ -535,23 +1155,23 @@ Index: valgrind-3.13.0/coregrind/m_syswrap/syswrap-xen.c case VKI_XENMEM_access_op: /* No outputs */ break; -@@ -1518,6 +1739,15 @@ POST(memory_op) +@@ -1518,6 +1907,15 @@ POST(memory_op) case VKI_XENMEM_get_sharing_shared_pages: /* No outputs */ break; + case VKI_XENMEM_get_pod_target: { -+ struct vki_xen_pod_target *arg = -+ (struct vki_xen_pod_target *)ARG2; -+ POST_MEM_WRITE((Addr)&arg->tot_pages, sizeof(arg->tot_pages)); -+ POST_MEM_WRITE((Addr)&arg->pod_cache_pages, sizeof(arg->pod_cache_pages)); -+ POST_MEM_WRITE((Addr)&arg->pod_entries, sizeof(arg->pod_entries)); -+ } -+ break; ++ struct vki_xen_pod_target *arg = ++ (struct vki_xen_pod_target *)ARG2; ++ POST_MEM_WRITE((Addr)&arg->tot_pages, sizeof(arg->tot_pages)); ++ POST_MEM_WRITE((Addr)&arg->pod_cache_pages, sizeof(arg->pod_cache_pages)); ++ POST_MEM_WRITE((Addr)&arg->pod_entries, sizeof(arg->pod_entries)); ++ } ++ break; + } } -@@ -1643,6 +1873,9 @@ POST(xen_version) +@@ -1643,6 +2041,9 @@ POST(xen_version) case VKI_XENVER_commandline: POST_MEM_WRITE((Addr)ARG2, sizeof(vki_xen_commandline_t)); break; @@ -561,27 +1181,79 @@ Index: valgrind-3.13.0/coregrind/m_syswrap/syswrap-xen.c } } -@@ -1672,6 +1905,11 @@ POST(sysctl) +@@ -1651,7 +2052,7 @@ POST(grant_table_op) + switch (ARG1) { + case VKI_XEN_GNTTABOP_setup_table: { + struct vki_xen_gnttab_setup_table *gst = +- (struct vki_xen_gnttab_setup_table*)ARG2; ++ (struct vki_xen_gnttab_setup_table*)ARG2; + PRE_MEM_WRITE("VKI_XEN_GNTTABOP_setup_table", + (Addr)&gst->status, sizeof(gst->status)); + PRE_MEM_WRITE("VKI_XEN_GNTTABOP_setup_table", +@@ -1672,7 +2073,14 @@ POST(sysctl) case 0x00000009: case 0x0000000a: case 0x0000000b: +- break; + case 0x0000000c: + case 0x0000000d: + case 0x0000000e: + case 0x0000000f: + case 0x00000010: - break; ++ case 0x00000011: ++ case 0x00000012: ++ break; default: return; -@@ -1706,6 +1944,7 @@ POST(sysctl) - break; + } +@@ -1693,24 +2101,31 @@ POST(sysctl) + switch (sysctl->interface_version) + { + case 0x00000008: +- POST_XEN_SYSCTL_WRITE(getdomaininfolist_00000008, num_domains); +- POST_MEM_WRITE((Addr)sysctl->u.getdomaininfolist_00000008.buffer.p, +- sizeof(*sysctl->u.getdomaininfolist_00000008.buffer.p) +- * sysctl->u.getdomaininfolist_00000008.num_domains); +- break; ++ POST_XEN_SYSCTL_WRITE(getdomaininfolist_00000008, num_domains); ++ POST_MEM_WRITE((Addr)sysctl->u.getdomaininfolist_00000008.buffer.p, ++ sizeof(*sysctl->u.getdomaininfolist_00000008.buffer.p) ++ * sysctl->u.getdomaininfolist_00000008.num_domains); ++ break; + case 0x00000009: +- POST_XEN_SYSCTL_WRITE(getdomaininfolist_00000009, num_domains); +- POST_MEM_WRITE((Addr)sysctl->u.getdomaininfolist_00000009.buffer.p, +- sizeof(*sysctl->u.getdomaininfolist_00000009.buffer.p) +- * sysctl->u.getdomaininfolist_00000009.num_domains); +- break; ++ POST_XEN_SYSCTL_WRITE(getdomaininfolist_00000009, num_domains); ++ POST_MEM_WRITE((Addr)sysctl->u.getdomaininfolist_00000009.buffer.p, ++ sizeof(*sysctl->u.getdomaininfolist_00000009.buffer.p) ++ * sysctl->u.getdomaininfolist_00000009.num_domains); ++ break; case 0x0000000a: case 0x0000000b: -+ default: - POST_XEN_SYSCTL_WRITE(getdomaininfolist_0000000a, num_domains); - POST_MEM_WRITE((Addr)sysctl->u.getdomaininfolist_0000000a.buffer.p, - sizeof(*sysctl->u.getdomaininfolist_0000000a.buffer.p) -@@ -1751,6 +1990,10 @@ POST(sysctl) +- POST_XEN_SYSCTL_WRITE(getdomaininfolist_0000000a, num_domains); +- POST_MEM_WRITE((Addr)sysctl->u.getdomaininfolist_0000000a.buffer.p, +- sizeof(*sysctl->u.getdomaininfolist_0000000a.buffer.p) +- * sysctl->u.getdomaininfolist_0000000a.num_domains); +- break; ++ case 0x0000000c: ++ case 0x0000000d: ++ case 0x0000000e: ++ case 0x0000000f: ++ case 0x00000010: ++ case 0x00000011: ++ case 0x00000012: ++ POST_XEN_SYSCTL_WRITE(getdomaininfolist_0000000a, num_domains); ++ POST_MEM_WRITE((Addr)sysctl->u.getdomaininfolist_0000000a.buffer.p, ++ sizeof(*sysctl->u.getdomaininfolist_0000000a.buffer.p) ++ * sysctl->u.getdomaininfolist_0000000a.num_domains); ++ break; + } + break; + +@@ -1751,6 +2166,10 @@ POST(sysctl) break; case 0x0000000a: case 0x0000000b: @@ -592,12 +1264,13 @@ Index: valgrind-3.13.0/coregrind/m_syswrap/syswrap-xen.c POST_XEN_SYSCTL_WRITE(physinfo_0000000a, threads_per_core); POST_XEN_SYSCTL_WRITE(physinfo_0000000a, cores_per_socket); POST_XEN_SYSCTL_WRITE(physinfo_0000000a, nr_cpus); -@@ -1765,30 +2008,107 @@ POST(sysctl) +@@ -1765,30 +2184,125 @@ POST(sysctl) POST_XEN_SYSCTL_WRITE(physinfo_0000000a, hw_cap[8]); POST_XEN_SYSCTL_WRITE(physinfo_0000000a, capabilities); break; + case 0x00000010: -+ default: ++ case 0x00000011: ++ case 0x00000012: + POST_XEN_SYSCTL_WRITE(physinfo_00000010, threads_per_core); + POST_XEN_SYSCTL_WRITE(physinfo_00000010, cores_per_socket); + POST_XEN_SYSCTL_WRITE(physinfo_00000010, nr_cpus); @@ -616,7 +1289,7 @@ Index: valgrind-3.13.0/coregrind/m_syswrap/syswrap-xen.c } break; - case VKI_XEN_SYSCTL_topologyinfo: +- case VKI_XEN_SYSCTL_topologyinfo: - POST_XEN_SYSCTL_WRITE(topologyinfo, max_cpu_index); - if (sysctl->u.topologyinfo.cpu_to_core.p) - POST_MEM_WRITE((Addr)sysctl->u.topologyinfo.cpu_to_core.p, @@ -627,7 +1300,7 @@ Index: valgrind-3.13.0/coregrind/m_syswrap/syswrap-xen.c - if (sysctl->u.topologyinfo.cpu_to_node.p) - POST_MEM_WRITE((Addr)sysctl->u.topologyinfo.cpu_to_node.p, - sizeof(uint32_t) * sysctl->u.topologyinfo.max_cpu_index); -+// case VKI_XEN_SYSCTL_cputopoinfo: ++ case VKI_XEN_SYSCTL_topologyinfo | VKI_XEN_SYSCTL_cputopoinfo: + switch (sysctl->interface_version) + { + case 0x00000007: @@ -638,20 +1311,25 @@ Index: valgrind-3.13.0/coregrind/m_syswrap/syswrap-xen.c + POST_XEN_SYSCTL_WRITE(topologyinfo, max_cpu_index); + if (sysctl->u.topologyinfo.cpu_to_core.p) + POST_MEM_WRITE((Addr)sysctl->u.topologyinfo.cpu_to_core.p, -+ sizeof(uint32_t) * sysctl->u.topologyinfo.max_cpu_index); ++ sizeof(uint32_t) * sysctl->u.topologyinfo.max_cpu_index); + if (sysctl->u.topologyinfo.cpu_to_socket.p) + POST_MEM_WRITE((Addr)sysctl->u.topologyinfo.cpu_to_socket.p, -+ sizeof(uint32_t) * sysctl->u.topologyinfo.max_cpu_index); ++ sizeof(uint32_t) * sysctl->u.topologyinfo.max_cpu_index); + if (sysctl->u.topologyinfo.cpu_to_node.p) + POST_MEM_WRITE((Addr)sysctl->u.topologyinfo.cpu_to_node.p, -+ sizeof(uint32_t) * sysctl->u.topologyinfo.max_cpu_index); ++ sizeof(uint32_t) * sysctl->u.topologyinfo.max_cpu_index); + break; + case 0x0000000c: -+ default: ++ case 0x0000000d: ++ case 0x0000000e: ++ case 0x0000000f: ++ case 0x00000010: ++ case 0x00000011: ++ case 0x00000012: + POST_XEN_SYSCTL_WRITE(cputopoinfo_0000000c, num_cpus); + if (sysctl->u.cputopoinfo_0000000c.cputopo.p) + POST_MEM_WRITE((Addr)sysctl->u.cputopoinfo_0000000c.cputopo.p, -+ sizeof(vki_xen_sysctl_cputopo_0000000c_t) * sysctl->u.cputopoinfo_0000000c.num_cpus); ++ sizeof(vki_xen_sysctl_cputopo_0000000c_t) * sysctl->u.cputopoinfo_0000000c.num_cpus); + break; + } break; @@ -666,28 +1344,32 @@ Index: valgrind-3.13.0/coregrind/m_syswrap/syswrap-xen.c - sizeof(uint32_t) * sysctl->u.numainfo.max_node_index); + switch (sysctl->interface_version) + { -+ case 0x00000007: + case 0x00000008: + case 0x00000009: + case 0x0000000a: + case 0x0000000b: -+ POST_XEN_SYSCTL_WRITE(numainfo_0000000b, max_node_index); -+ POST_MEM_WRITE((Addr)sysctl->u.numainfo_0000000b.node_to_memsize.p, -+ sizeof(uint64_t) * sysctl->u.numainfo_0000000b.max_node_index); -+ POST_MEM_WRITE((Addr)sysctl->u.numainfo_0000000b.node_to_memfree.p, -+ sizeof(uint64_t) * sysctl->u.numainfo_0000000b.max_node_index); -+ POST_MEM_WRITE((Addr)sysctl->u.numainfo_0000000b.node_to_node_distance.p, ++ POST_XEN_SYSCTL_WRITE(numainfo_00000008, max_node_index); ++ POST_MEM_WRITE((Addr)sysctl->u.numainfo_00000008.node_to_memsize.p, ++ sizeof(uint64_t) * sysctl->u.numainfo_00000008.max_node_index); ++ POST_MEM_WRITE((Addr)sysctl->u.numainfo_00000008.node_to_memfree.p, ++ sizeof(uint64_t) * sysctl->u.numainfo_00000008.max_node_index); ++ POST_MEM_WRITE((Addr)sysctl->u.numainfo_00000008.node_to_node_distance.p, + sizeof(uint32_t) * -+ (sysctl->u.numainfo_0000000b.max_node_index * sysctl->u.numainfo_0000000b.max_node_index)); ++ (sysctl->u.numainfo_00000008.max_node_index * sysctl->u.numainfo_00000008.max_node_index)); + break; + case 0x0000000c: -+ default: ++ case 0x0000000d: ++ case 0x0000000e: ++ case 0x0000000f: ++ case 0x00000010: ++ case 0x00000011: ++ case 0x00000012: + POST_XEN_SYSCTL_WRITE(numainfo_0000000c, num_nodes); + POST_MEM_WRITE((Addr)sysctl->u.numainfo_0000000c.meminfo.p, + sizeof(uint64_t) * sysctl->u.numainfo_0000000c.num_nodes); + POST_MEM_WRITE((Addr)sysctl->u.numainfo_0000000c.distance.p, + sizeof(uint32_t) * -+ (sysctl->u.numainfo_0000000c.num_nodes * sysctl->u.numainfo_0000000c.num_nodes)); ++ (sysctl->u.numainfo_0000000c.num_nodes * sysctl->u.numainfo_0000000c.num_nodes)); + break; + } + break; @@ -696,7 +1378,12 @@ Index: valgrind-3.13.0/coregrind/m_syswrap/syswrap-xen.c + switch (sysctl->interface_version) + { + case 0x0000000c: -+ default: ++ case 0x0000000d: ++ case 0x0000000e: ++ case 0x0000000f: ++ case 0x00000010: ++ case 0x00000011: ++ case 0x00000012: + POST_XEN_SYSCTL_WRITE(pcitopoinfo_0000000c, num_devs); + POST_MEM_WRITE((Addr)sysctl->u.pcitopoinfo_0000000c.nodes.p, + sizeof(uint32_t) * sysctl->u.pcitopoinfo_0000000c.num_devs); @@ -707,8 +1394,12 @@ Index: valgrind-3.13.0/coregrind/m_syswrap/syswrap-xen.c + case VKI_XEN_SYSCTL_get_cpu_featureset: + switch (sysctl->interface_version) + { -+ case 0x0000000c: -+ default: ++ case 0x0000000d: ++ case 0x0000000e: ++ case 0x0000000f: ++ case 0x00000010: ++ case 0x00000011: ++ case 0x00000012: + POST_XEN_SYSCTL_WRITE(cpu_featureset_0000000d, nr_features); + POST_MEM_WRITE((Addr)sysctl->u.cpu_featureset_0000000d.features.p, + sizeof(uint32_t) * sysctl->u.cpu_featureset_0000000d.nr_features); @@ -717,25 +1408,54 @@ Index: valgrind-3.13.0/coregrind/m_syswrap/syswrap-xen.c break; /* No outputs */ -@@ -1808,6 +2128,9 @@ POST(domctl){ +@@ -1808,9 +2322,15 @@ POST(domctl){ case 0x00000009: case 0x0000000a: case 0x0000000b: +- break; + case 0x0000000c: + case 0x0000000d: + case 0x0000000e: - break; ++ case 0x0000000f: ++ case 0x00000010: ++ case 0x00000011: ++ break; default: - return; -@@ -1869,6 +2192,7 @@ POST(domctl){ +- return; ++ return; + } + + #define __POST_XEN_DOMCTL_WRITE(_domctl, _union, _field) \ +@@ -1847,6 +2367,7 @@ POST(domctl){ + case VKI_XEN_DOMCTL_resumedomain: + case VKI_XEN_DOMCTL_set_vcpu_msrs: + case VKI_XEN_DOMCTL_set_access_required: ++ case VKI_XEN_DOMCTL_soft_reset: + /* No output fields */ + break; + +@@ -1860,7 +2381,7 @@ POST(domctl){ + + case VKI_XEN_DOMCTL_gettscinfo: + switch (domctl->interface_version) { +- case 0x00000007: /* pre-4.6 */ ++ case 0x00000007: + case 0x00000008: + case 0x00000009: + case 0x0000000a: +@@ -1869,6 +2390,11 @@ POST(domctl){ sizeof(vki_xen_guest_tsc_info_t)); break; case 0x0000000b: -+ default: ++ case 0x0000000c: ++ case 0x0000000d: ++ case 0x0000000e: ++ case 0x0000000f: ++ case 0x00000011: __POST_XEN_DOMCTL_WRITE(gettscinfo, tsc_info_0000000b, tsc_mode); __POST_XEN_DOMCTL_WRITE(gettscinfo, tsc_info_0000000b, gtsc_khz); __POST_XEN_DOMCTL_WRITE(gettscinfo, tsc_info_0000000b, incarnation); -@@ -1897,14 +2221,33 @@ POST(domctl){ +@@ -1897,14 +2423,34 @@ POST(domctl){ break; case VKI_XEN_DOMCTL_gethvmcontext_partial: @@ -755,20 +1475,21 @@ Index: valgrind-3.13.0/coregrind/m_syswrap/syswrap-xen.c + case 0x0000000b: + case 0x0000000c: + case 0x0000000d: -+ switch (domctl->u.hvmcontext_partial_0000000d.type) { ++ switch (domctl->u.hvmcontext_partial_00000005.type) { + case VKI_HVM_SAVE_CODE(CPU): -+ if ( domctl->u.hvmcontext_partial_0000000d.buffer.p ) -+ POST_MEM_WRITE((Addr)domctl->u.hvmcontext_partial_0000000d.buffer.p, -+ VKI_HVM_SAVE_LENGTH(CPU)); ++ if ( domctl->u.hvmcontext_partial_00000005.buffer.p ) ++ POST_MEM_WRITE((Addr)domctl->u.hvmcontext_partial_00000005.buffer.p, ++ VKI_HVM_SAVE_LENGTH(CPU)); + break; + } + case 0x0000000e: -+ default: ++ case 0x0000000f: ++ case 0x00000011: + switch (domctl->u.hvmcontext_partial_0000000e.type) { + case VKI_HVM_SAVE_CODE(CPU): + if ( domctl->u.hvmcontext_partial_0000000e.buffer.p ) -+ POST_MEM_WRITE((Addr)domctl->u.hvmcontext_partial_0000000e.buffer.p, -+ VKI_HVM_SAVE_LENGTH(CPU)); ++ POST_MEM_WRITE((Addr)domctl->u.hvmcontext_partial_0000000e.buffer.p, ++ VKI_HVM_SAVE_LENGTH(CPU)); + break; + } + break; @@ -777,64 +1498,225 @@ Index: valgrind-3.13.0/coregrind/m_syswrap/syswrap-xen.c case VKI_XEN_DOMCTL_scheduler_op: if ( domctl->u.scheduler_op.cmd == VKI_XEN_DOMCTL_SCHEDOP_getinfo ) { -@@ -1943,6 +2286,7 @@ POST(domctl){ +@@ -1943,6 +2489,12 @@ POST(domctl){ domctl->u.vcpuaffinity_00000009.cpumap.nr_bits / 8); break; case 0x0000000a: -+ default: ++ case 0x0000000b: ++ case 0x0000000c: ++ case 0x0000000d: ++ case 0x0000000e: ++ case 0x0000000f: ++ case 0x00000011: if (domctl->u.vcpuaffinity_0000000a.flags & VKI_XEN_VCPUAFFINITY_HARD) POST_MEM_WRITE( (Addr)domctl->u.vcpuaffinity_0000000a.cpumap_hard.bitmap.p, -@@ -1992,6 +2336,7 @@ POST(domctl){ +@@ -1962,51 +2514,80 @@ POST(domctl){ + case VKI_XEN_DOMCTL_getdomaininfo: + switch (domctl->interface_version) { + case 0x00000007: +- POST_XEN_DOMCTL_WRITE(getdomaininfo_00000007, domain); +- POST_XEN_DOMCTL_WRITE(getdomaininfo_00000007, flags); +- POST_XEN_DOMCTL_WRITE(getdomaininfo_00000007, tot_pages); +- POST_XEN_DOMCTL_WRITE(getdomaininfo_00000007, max_pages); +- POST_XEN_DOMCTL_WRITE(getdomaininfo_00000007, shr_pages); +- POST_XEN_DOMCTL_WRITE(getdomaininfo_00000007, shared_info_frame); +- POST_XEN_DOMCTL_WRITE(getdomaininfo_00000007, cpu_time); +- POST_XEN_DOMCTL_WRITE(getdomaininfo_00000007, nr_online_vcpus); +- POST_XEN_DOMCTL_WRITE(getdomaininfo_00000007, max_vcpu_id); +- POST_XEN_DOMCTL_WRITE(getdomaininfo_00000007, ssidref); +- POST_XEN_DOMCTL_WRITE(getdomaininfo_00000007, handle); +- POST_XEN_DOMCTL_WRITE(getdomaininfo_00000007, cpupool); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_00000007, domain); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_00000007, flags); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_00000007, tot_pages); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_00000007, max_pages); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_00000007, shr_pages); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_00000007, shared_info_frame); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_00000007, cpu_time); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_00000007, nr_online_vcpus); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_00000007, max_vcpu_id); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_00000007, ssidref); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_00000007, handle); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_00000007, cpupool); + break; + case 0x00000008: +- POST_XEN_DOMCTL_WRITE(getdomaininfo_00000008, domain); +- POST_XEN_DOMCTL_WRITE(getdomaininfo_00000008, flags); +- POST_XEN_DOMCTL_WRITE(getdomaininfo_00000008, tot_pages); +- POST_XEN_DOMCTL_WRITE(getdomaininfo_00000008, max_pages); +- POST_XEN_DOMCTL_WRITE(getdomaininfo_00000008, shr_pages); +- POST_XEN_DOMCTL_WRITE(getdomaininfo_00000008, paged_pages); +- POST_XEN_DOMCTL_WRITE(getdomaininfo_00000008, shared_info_frame); +- POST_XEN_DOMCTL_WRITE(getdomaininfo_00000008, cpu_time); +- POST_XEN_DOMCTL_WRITE(getdomaininfo_00000008, nr_online_vcpus); +- POST_XEN_DOMCTL_WRITE(getdomaininfo_00000008, max_vcpu_id); +- POST_XEN_DOMCTL_WRITE(getdomaininfo_00000008, ssidref); +- POST_XEN_DOMCTL_WRITE(getdomaininfo_00000008, handle); +- POST_XEN_DOMCTL_WRITE(getdomaininfo_00000008, cpupool); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_00000008, domain); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_00000008, flags); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_00000008, tot_pages); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_00000008, max_pages); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_00000008, shr_pages); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_00000008, paged_pages); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_00000008, shared_info_frame); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_00000008, cpu_time); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_00000008, nr_online_vcpus); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_00000008, max_vcpu_id); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_00000008, ssidref); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_00000008, handle); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_00000008, cpupool); break; case 0x00000009: case 0x0000000a: -+ default: - POST_XEN_DOMCTL_WRITE(getdomaininfo_00000009, domain); - POST_XEN_DOMCTL_WRITE(getdomaininfo_00000009, flags); - POST_XEN_DOMCTL_WRITE(getdomaininfo_00000009, tot_pages); -@@ -2044,6 +2389,7 @@ POST(domctl){ +- POST_XEN_DOMCTL_WRITE(getdomaininfo_00000009, domain); +- POST_XEN_DOMCTL_WRITE(getdomaininfo_00000009, flags); +- POST_XEN_DOMCTL_WRITE(getdomaininfo_00000009, tot_pages); +- POST_XEN_DOMCTL_WRITE(getdomaininfo_00000009, max_pages); +- POST_XEN_DOMCTL_WRITE(getdomaininfo_00000009, outstanding_pages); +- POST_XEN_DOMCTL_WRITE(getdomaininfo_00000009, shr_pages); +- POST_XEN_DOMCTL_WRITE(getdomaininfo_00000009, paged_pages); +- POST_XEN_DOMCTL_WRITE(getdomaininfo_00000009, shared_info_frame); +- POST_XEN_DOMCTL_WRITE(getdomaininfo_00000009, cpu_time); +- POST_XEN_DOMCTL_WRITE(getdomaininfo_00000009, nr_online_vcpus); +- POST_XEN_DOMCTL_WRITE(getdomaininfo_00000009, max_vcpu_id); +- POST_XEN_DOMCTL_WRITE(getdomaininfo_00000009, ssidref); +- POST_XEN_DOMCTL_WRITE(getdomaininfo_00000009, handle); +- POST_XEN_DOMCTL_WRITE(getdomaininfo_00000009, cpupool); +- break; ++ case 0x0000000b: ++ case 0x0000000c: ++ case 0x0000000d: ++ case 0x0000000e: ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_00000009, domain); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_00000009, flags); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_00000009, tot_pages); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_00000009, max_pages); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_00000009, outstanding_pages); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_00000009, shr_pages); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_00000009, paged_pages); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_00000009, shared_info_frame); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_00000009, cpu_time); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_00000009, nr_online_vcpus); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_00000009, max_vcpu_id); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_00000009, ssidref); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_00000009, handle); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_00000009, cpupool); ++ case 0x0000000f: ++ case 0x00000011: ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_0000000f, domain); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_0000000f, flags); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_0000000f, tot_pages); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_0000000f, max_pages); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_0000000f, outstanding_pages); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_0000000f, shr_pages); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_0000000f, paged_pages); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_0000000f, shared_info_frame); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_0000000f, cpu_time); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_0000000f, nr_online_vcpus); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_0000000f, max_vcpu_id); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_0000000f, ssidref); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_0000000f, handle); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_0000000f, cpupool); ++ POST_XEN_DOMCTL_WRITE(getdomaininfo_0000000f, arch_config); ++#if defined(__i386__) || defined(__x86_64__) ++ __POST_XEN_DOMCTL_WRITE(getdomaininfo_0000000f, getdomaininfo_0000000f, arch_config.emulation_flags); ++#endif ++#if defined(__arm__) || defined(__aarch64__) ++ __POST_XEN_DOMCTL_WRITE(getdomaininfo_0000000f, getdomaininfo_0000000f, arch_config.gic_version); ++ __POST_XEN_DOMCTL_WRITE(getdomaininfo_0000000f, getdomaininfo_0000000f, arch_config.nr_spis); ++ __POST_XEN_DOMCTL_WRITE(getdomaininfo_0000000f, getdomaininfo_0000000f, arch_config.clock_frequency); ++#endif ++ break; + } + break; + case VKI_XEN_DOMCTL_getvcpucontext: +@@ -2043,7 +2624,14 @@ POST(domctl){ + #endif break; - case 0x00000009: -+ default: +- case 0x00000009: ++ case 0x00000009: ++ case 0x0000000a: ++ case 0x0000000b: ++ case 0x0000000c: ++ case 0x0000000d: ++ case 0x0000000e: ++ case 0x0000000f: ++ case 0x00000011: __POST_XEN_DOMCTL_WRITE(get_ext_vcpucontext, ext_vcpucontext_00000009, size); #if defined(__i386__) || defined(__x86_64__) __POST_XEN_DOMCTL_WRITE(get_ext_vcpucontext, ext_vcpucontext_00000009, -@@ -2120,6 +2466,7 @@ POST(domctl){ +@@ -2066,7 +2654,7 @@ POST(domctl){ + __POST_XEN_DOMCTL_WRITE(get_ext_vcpucontext, ext_vcpucontext_00000009, + mci_ctl2_bank1); + #endif +- break; ++ break; + } + break; + +@@ -2110,16 +2698,20 @@ POST(domctl){ + domctl->u.vcpu_msrs.msr_count); + break; + +- case VKI_XEN_DOMCTL_mem_event_op: +- //case VKI_XEN_DOMCTL_vm_event_op: /* name change in 4.6 */ ++ case VKI_XEN_DOMCTL_mem_event_op | VKI_XEN_DOMCTL_vm_event_op: + switch (domctl->interface_version) { +- case 0x00000007: /* pre-4.6 */ ++ case 0x00000007: + case 0x00000008: + case 0x00000009: + case 0x0000000a: __POST_XEN_DOMCTL_WRITE(mem_event_op, mem_event_op_00000007, port); break; case 0x0000000b: -+ default: ++ case 0x0000000c: ++ case 0x0000000d: ++ case 0x0000000e: ++ case 0x0000000f: ++ case 0x00000011: __POST_XEN_DOMCTL_WRITE(vm_event_op, vm_event_op_0000000b, port); break; } -@@ -2143,6 +2490,46 @@ POST(domctl){ +@@ -2127,7 +2719,7 @@ POST(domctl){ + + case VKI_XEN_DOMCTL_monitor_op: + switch (domctl->interface_version) { +- case 0x000000b: ++ case 0x0000000b: + if (domctl->u.monitor_op_0000000b.op == VKI_XEN_DOMCTL_MONITOR_OP_GET_CAPABILITIES) { + switch(domctl->u.monitor_op_0000000b.event) { + case VKI_XEN_DOMCTL_MONITOR_EVENT_WRITE_CTRLREG: +@@ -2142,6 +2734,66 @@ POST(domctl){ + } } - break; -+ case 0x000000c: -+ case 0x000000d: -+ if (domctl->u.monitor_op_0000000c.op == VKI_XEN_DOMCTL_MONITOR_OP_GET_CAPABILITIES) { -+ switch(domctl->u.monitor_op_0000000c.event) { -+ case VKI_XEN_DOMCTL_MONITOR_EVENT_WRITE_CTRLREG: -+ __POST_XEN_DOMCTL_WRITE(monitor_op, monitor_op_0000000c, u.mov_to_cr); -+ break; -+ case VKI_XEN_DOMCTL_MONITOR_EVENT_MOV_TO_MSR: -+ __POST_XEN_DOMCTL_WRITE(monitor_op, monitor_op_0000000c, u.mov_to_msr); -+ break; -+ case VKI_XEN_DOMCTL_MONITOR_EVENT_GUEST_REQUEST: -+ __POST_XEN_DOMCTL_WRITE(monitor_op, monitor_op_0000000c, u.guest_request); -+ break; -+ case VKI_XEN_DOMCTL_MONITOR_EVENT_DEBUG_EXCEPTION: -+ __POST_XEN_DOMCTL_WRITE(monitor_op, monitor_op_0000000c, u.debug_exception); -+ break; -+ } -+ } ++ break; ++ case 0x0000000c: ++ case 0x0000000d: ++ if (domctl->u.monitor_op_0000000c.op == VKI_XEN_DOMCTL_MONITOR_OP_GET_CAPABILITIES) { ++ switch(domctl->u.monitor_op_0000000c.event) { ++ case VKI_XEN_DOMCTL_MONITOR_EVENT_WRITE_CTRLREG: ++ __POST_XEN_DOMCTL_WRITE(monitor_op, monitor_op_0000000c, u.mov_to_cr); ++ break; ++ case VKI_XEN_DOMCTL_MONITOR_EVENT_MOV_TO_MSR: ++ __POST_XEN_DOMCTL_WRITE(monitor_op, monitor_op_0000000c, u.mov_to_msr); ++ break; ++ case VKI_XEN_DOMCTL_MONITOR_EVENT_GUEST_REQUEST: ++ __POST_XEN_DOMCTL_WRITE(monitor_op, monitor_op_0000000c, u.guest_request); ++ break; ++ case VKI_XEN_DOMCTL_MONITOR_EVENT_DEBUG_EXCEPTION: ++ __POST_XEN_DOMCTL_WRITE(monitor_op, monitor_op_0000000c, u.debug_exception); ++ break; ++ } ++ } + + break; -+ case 0x000000e: -+ default: ++ case 0x0000000e: ++ case 0x0000000f: + if (domctl->u.monitor_op_0000000e.op == VKI_XEN_DOMCTL_MONITOR_OP_GET_CAPABILITIES) { + switch(domctl->u.monitor_op_0000000e.event) { + case VKI_XEN_DOMCTL_MONITOR_EVENT_WRITE_CTRLREG: @@ -853,58 +1735,57 @@ Index: valgrind-3.13.0/coregrind/m_syswrap/syswrap-xen.c + } + + break; ++ case 0x00000010: ++ case 0x00000011: ++ if (domctl->u.monitor_op_00000010.op == VKI_XEN_DOMCTL_MONITOR_OP_GET_CAPABILITIES) { ++ switch(domctl->u.monitor_op_00000010.event) { ++ case VKI_XEN_DOMCTL_MONITOR_EVENT_WRITE_CTRLREG: ++ __POST_XEN_DOMCTL_WRITE(monitor_op, monitor_op_00000010, u.mov_to_cr); ++ break; ++ case VKI_XEN_DOMCTL_MONITOR_EVENT_MOV_TO_MSR: ++ __POST_XEN_DOMCTL_WRITE(monitor_op, monitor_op_00000010, u.mov_to_msr); ++ break; ++ case VKI_XEN_DOMCTL_MONITOR_EVENT_GUEST_REQUEST: ++ __POST_XEN_DOMCTL_WRITE(monitor_op, monitor_op_00000010, u.guest_request); ++ break; ++ case VKI_XEN_DOMCTL_MONITOR_EVENT_DEBUG_EXCEPTION: ++ __POST_XEN_DOMCTL_WRITE(monitor_op, monitor_op_00000010, u.debug_exception); ++ break; ++ } ++ } ++ + break; } break; - } -@@ -2264,6 +2651,8 @@ static XenHypercallTableEntry hypercall_ +@@ -2203,6 +2855,14 @@ POST(tmem_op) + } + } + ++POST(dm_op) ++{ ++ unsigned int num = ARG2; ++ struct vki_xen_privcmd_dm_op_buf *args = (void *)(ARG3); ++ ++ POST_MEM_WRITE((Addr) args, sizeof(*args) * num); ++} ++ + typedef + struct { + SyscallTableEntry entry; +@@ -2264,6 +2924,8 @@ static XenHypercallTableEntry hypercall_table[] = { HYPXY(__VKI_XEN_domctl, domctl, 1), // 36 // __VKI_XEN_kexec_op // 37 HYPXY(__VKI_XEN_tmem_op, tmem_op, 1), // 38 + // __VKI_XEN_xenpmu_op // 40 -+ // __VKI_XEN_dm_op // 41 ++ HYPXY(__VKI_XEN_dm_op, dm_op, 3), // 41 }; static void bad_before ( ThreadId tid, -Index: valgrind-3.13.0/coregrind/m_syswrap/syswrap-linux.c -=================================================================== ---- valgrind-3.13.0.orig/coregrind/m_syswrap/syswrap-linux.c -+++ valgrind-3.13.0/coregrind/m_syswrap/syswrap-linux.c -@@ -7977,6 +7977,17 @@ PRE(sys_ioctl) - (Addr)args->arr, sizeof(*(args->arr)) * args->num); - break; - } -+ case VKI_XEN_IOCTL_PRIVCMD_DM_OP: { -+ struct vki_xen_privcmd_dm_op *args = -+ (struct vki_xen_privcmd_dm_op *)(ARG3); -+ PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_DM_OP(dom)", -+ (Addr)&args->dom, sizeof(args->dom)); -+ PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_DM_OP(num)", -+ (Addr)&args->num, sizeof(args->num)); -+ PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_DM_OP(ubufs)", -+ (Addr)args->ubufs, sizeof(*(args->ubufs)) * args->num); -+ break; -+ } - - case VKI_XEN_IOCTL_EVTCHN_BIND_VIRQ: { - struct vki_xen_ioctl_evtchn_bind_virq *args = -@@ -10404,6 +10415,12 @@ POST(sys_ioctl) - POST_MEM_WRITE((Addr)args->err, sizeof(*(args->err)) * args->num); - } - break; -+ case VKI_XEN_IOCTL_PRIVCMD_DM_OP: { -+ struct vki_xen_privcmd_dm_op *args = -+ (struct vki_xen_privcmd_dm_op *)(ARG3); -+ POST_MEM_WRITE((Addr)args->ubufs, sizeof(*(args->ubufs)) * args->num); -+ } -+ break; - - case VKI_XEN_IOCTL_EVTCHN_BIND_VIRQ: - case VKI_XEN_IOCTL_EVTCHN_BIND_INTERDOMAIN: -Index: valgrind-3.13.0/include/vki/vki-linux.h -=================================================================== ---- valgrind-3.13.0.orig/include/vki/vki-linux.h -+++ valgrind-3.13.0/include/vki/vki-linux.h -@@ -3329,12 +3329,27 @@ struct vki_xen_privcmd_mmapbatch_v2 { +diff --git a/include/vki/vki-linux.h b/include/vki/vki-linux.h +index b4c60854a..c99503c62 100644 +--- a/include/vki/vki-linux.h ++++ b/include/vki/vki-linux.h +@@ -3384,12 +3384,37 @@ struct vki_xen_privcmd_mmapbatch_v2 { int __user *err; /* array of error codes */ }; @@ -919,6 +1800,14 @@ Index: valgrind-3.13.0/include/vki/vki-linux.h + const struct vki_xen_privcmd_dm_op_buf __user *ubufs; +}; + ++struct vki_xen_privcmd_mmap_resource { ++ __vki_u16 dom; ++ __vki_u32 type; ++ __vki_u32 id; ++ __vki_u32 idx; ++ __vki_u64 num; ++ __vki_u64 addr; ++}; + #define VKI_XEN_IOCTL_PRIVCMD_HYPERCALL _VKI_IOC(_VKI_IOC_NONE, 'P', 0, sizeof(struct vki_xen_privcmd_hypercall)) #define VKI_XEN_IOCTL_PRIVCMD_MMAP _VKI_IOC(_VKI_IOC_NONE, 'P', 2, sizeof(struct vki_xen_privcmd_mmap)) @@ -928,26 +1817,144 @@ Index: valgrind-3.13.0/include/vki/vki-linux.h +#define VKI_XEN_IOCTL_PRIVCMD_DM_OP _VKI_IOC(_VKI_IOC_NONE, 'P', 5, sizeof(struct vki_xen_privcmd_dm_op)) +#define VKI_XEN_IOCTL_PRIVCMD_RESTRICT _VKI_IOC(_VKI_IOC_NONE, 'P', 6, sizeof(__vki_u16)) ++#define VKI_XEN_IOCTL_PRIVCMD_MMAP_RESOURCE _VKI_IOC(_VKI_IOC_NONE, 'P', 7, sizeof(struct vki_xen_privcmd_mmap_resource)) ++#define VKI_XEN_IOCTL_PRIVCMD_UNIMPLEMENTED _VKI_IOC(_VKI_IOC_NONE, 'P', 0xff, 0) + //---------------------------------------------------------------------- // Xen evtchn IOCTL //---------------------------------------------------------------------- -Index: valgrind-3.13.0/include/vki/vki-xen-domctl.h -=================================================================== ---- valgrind-3.13.0.orig/include/vki/vki-xen-domctl.h -+++ valgrind-3.13.0/include/vki/vki-xen-domctl.h -@@ -37,7 +37,9 @@ +@@ -3428,6 +3453,91 @@ struct vki_xen_ioctl_evtchn_notify { + #define VKI_XEN_IOCTL_EVTCHN_RESET \ + _VKI_IOC(_VKI_IOC_NONE, 'E', 5, 0) + ++//---------------------------------------------------------------------- ++// Xen gnttdev IOCTL ++//---------------------------------------------------------------------- ++ ++#define VKI_XEN_IOCTL_GNTDEV_MAP_GRANT_REF \ ++ _VKI_IOC(_VKI_IOC_NONE, 'G', 0, sizeof(struct vki_xen_ioctl_gntdev_map_grant_ref)) ++struct vki_xen_ioctl_gntdev_grant_ref { ++ vki_u32 domid; ++ vki_u32 ref; ++}; ++struct vki_xen_ioctl_gntdev_map_grant_ref { ++ vki_u32 count; ++ vki_u32 pad; ++ __vki_u64 index; ++ struct vki_xen_ioctl_gntdev_grant_ref refs[1]; ++}; ++ ++#define VKI_XEN_IOCTL_GNTDEV_UNMAP_GRANT_REF \ ++ _VKI_IOC(_VKI_IOC_NONE, 'G', 1, sizeof(struct vki_xen_ioctl_gntdev_unmap_grant_ref)) ++struct vki_xen_ioctl_gntdev_unmap_grant_ref { ++ __vki_u64 index; ++ vki_u32 count; ++ vki_u32 pad; ++}; ++ ++#define VKI_XEN_IOCTL_GNTDEV_GET_OFFSET_FOR_VADDR \ ++ _VKI_IOC(_VKI_IOC_NONE, 'G', 2, sizeof(struct vki_xen_ioctl_gntdev_get_offset_for_vaddr)) ++struct vki_xen_ioctl_gntdev_get_offset_for_vaddr { ++ __vki_u64 vaddr; ++ __vki_u64 offset; ++ vki_u32 count; ++ vki_u32 pad; ++}; ++ ++#define VKI_XEN_IOCTL_GNTDEV_SET_MAX_GRANTS \ ++ _VKI_IOC(_VKI_IOC_NONE, 'G', 3, sizeof(struct vki_xen_ioctl_gntdev_set_max_grants)) ++struct vki_xen_ioctl_gntdev_set_max_grants { ++ vki_u32 count; ++}; ++ ++#define VKI_XEN_IOCTL_GNTALLOC_ALLOC_GREF \ ++ _VKI_IOC(_VKI_IOC_NONE, 'G', 5, sizeof(struct vki_xen_ioctl_gntalloc_alloc_gref)) ++struct vki_xen_ioctl_gntalloc_alloc_gref { ++ vki_u16 domid; ++ vki_u16 flags; ++ vki_u32 count; ++ __vki_u64 index; ++ vki_u32 gref_ids[1]; ++}; ++ ++#define VKI_XEN_IOCTL_GNTALLOC_DEALLOC_GREF \ ++ _VKI_IOC(_VKI_IOC_NONE, 'G', 6, sizeof(struct vki_xen_ioctl_gntalloc_dealloc_gref)) ++struct vki_xen_ioctl_gntalloc_dealloc_gref { ++ __vki_u64 index; ++ vki_u32 count; ++}; ++ ++#define VKI_XEN_IOCTL_GNTALLOC_SET_UNMAP_NOTIFY \ ++ _VKI_IOC(_VKI_IOC_NONE, 'G', 7, sizeof(struct vki_xen_ioctl_gntalloc_set_unmap_notify)) ++struct vki_xen_ioctl_gntalloc_set_unmap_notify { ++ __vki_u64 index; ++ vki_u32 action; ++ vki_u32 event_channel_port; ++}; ++ ++#define VKI_XEN_IOCTL_GNTDEV_GRANT_COPY \ ++ _VKI_IOC(_VKI_IOC_NONE, 'G', 8, sizeof(struct vki_xen_ioctl_gntdev_grant_copy)) ++struct vki_xen_gntdev_grant_copy_segment { ++ union { ++ void *virt; ++ struct { ++ vki_u32 ref; /* grant_ref_t */ ++ vki_u16 offset; ++ vki_u16 domid; /* domid_t */ ++ } foreign; ++ } source, dest; ++ vki_u16 len; ++ vki_u16 flags; /* GNTCOPY_* */ ++ __vki_s16 status; /* GNTST_* */ ++}; ++ ++struct vki_xen_ioctl_gntdev_grant_copy { ++ vki_uint32_t count; ++ struct vki_xen_gntdev_grant_copy_segment *segments; ++}; + + //---------------------------------------------------------------------- + // From linux-3.4.0/include/linux/fs.h +diff --git a/include/vki/vki-xen-domctl.h b/include/vki/vki-xen-domctl.h +index 9e8b5ef1f..644912092 100644 +--- a/include/vki/vki-xen-domctl.h ++++ b/include/vki/vki-xen-domctl.h +@@ -30,21 +30,30 @@ + + /* + * The domctl interface is versioned via the interface_version +- * field. This structures in this header supports domctl interfaces: ++ * field. The structures in this header supports domctl interfaces: + * ++ * - 0x00000003: Xen 3.0.3 (unhandled) ++ * - 0x00000004: Xen 3.0.4 (unhandled) ++ * - 0x00000005: Xen 3.1 (unhandled) ++ * - 0x00000006: Xen 4.0 (unhandled) + * - 0x00000007: Xen 4.1 + * - 0x00000008: Xen 4.2 * - 0x00000009: Xen 4.3 & 4.4 * - 0x0000000a: Xen 4.5 - * - 0x0000000b: Xen 4.6 +- * - 0x0000000b: Xen 4.6 - * - 0x0000000c: Xen 4.7 ++ * - 0x0000000b: Xen 4.6 & 4.7 + * - 0x0000000c: Xen 4.8 + * - 0x0000000d: Xen 4.9 + * - 0x0000000e: Xen 4.10 ++ * - 0x0000000f: Xen 4.10.1 ++ * - 0x00000010: Xen 4.11 ++ * - 0x00000011: Xen 4.12 * * When adding a new subop be sure to include the variants used by all * of the above, both here and in syswrap-xen.c -@@ -119,19 +121,69 @@ + * + * Structs which are identical in all supported versions have no + * version suffix. Structs which do differ are defined multiple times +- * and use the suffix of the latest version to contain that particular ++ * and use the suffix of the earliest version to contain that particular + * variant. + */ + +@@ -119,19 +128,81 @@ #define VKI_XEN_DOMCTL_cacheflush 71 #define VKI_XEN_DOMCTL_get_vcpu_msrs 72 #define VKI_XEN_DOMCTL_set_vcpu_msrs 73 @@ -965,7 +1972,7 @@ Index: valgrind-3.13.0/include/vki/vki-xen-domctl.h #define VKI_XEN_DOMCTL_gdbsx_domstatus 1003 -struct vki_xen_domctl_createdomain { -+struct vki_xen_domctl_createdomain_0000000a { ++struct vki_xen_domctl_createdomain_00000004 { /* IN parameters */ vki_uint32_t ssidref; vki_xen_domain_handle_t handle; @@ -993,7 +2000,7 @@ Index: valgrind-3.13.0/include/vki/vki-xen-domctl.h + struct vki_xen_arch_domainconfig_0000000b config; +}; + -+/* The layout changed in 4.07, which shared domctl with 4.06 */ ++/* The layout changed in 4.07, which shares domctl with 4.06 */ +struct vki_xen_arch_domainconfig_0000000c { +#if defined(__i386__) || defined(__x86_64__) + vki_uint32_t emulation_flags; @@ -1014,11 +2021,52 @@ Index: valgrind-3.13.0/include/vki/vki-xen-domctl.h + vki_uint32_t flags; + struct vki_xen_arch_domainconfig_0000000c config; +}; ++ ++struct vki_xen_domctl_createdomain_00000011 { ++ /* IN parameters */ ++ vki_uint32_t ssidref; ++ vki_xen_domain_handle_t handle; ++ vki_uint32_t flags; ++ vki_uint32_t max_vcpus; ++ vki_uint32_t max_evtchn_port; ++ vki_uint32_t max_grant_frames; ++ vki_uint32_t max_maptrack_frames; ++ struct vki_xen_arch_domainconfig_0000000c config; ++}; + struct vki_xen_domctl_getdomaininfo_00000007 { /* OUT variables. */ vki_xen_domid_t domain; -@@ -215,6 +267,7 @@ struct vki_xen_domctl_vcpuaffinity_00000 +@@ -192,6 +263,28 @@ DEFINE_VKI_XEN_GUEST_HANDLE(vki_xen_domctl_getdomaininfo_00000009_t); + + /* vki_xen_domctl_getdomaininfo_0000000a is the same as 00000009 */ + ++struct vki_xen_domctl_getdomaininfo_0000000f { ++ /* OUT variables. */ ++ vki_xen_domid_t domain; ++ vki_uint32_t flags; ++ vki_xen_uint64_aligned_t tot_pages; ++ vki_xen_uint64_aligned_t max_pages; ++ vki_xen_uint64_aligned_t outstanding_pages; ++ vki_xen_uint64_aligned_t shr_pages; ++ vki_xen_uint64_aligned_t paged_pages; ++ vki_xen_uint64_aligned_t shared_info_frame; ++ vki_xen_uint64_aligned_t cpu_time; ++ vki_uint32_t nr_online_vcpus; ++ vki_uint32_t max_vcpu_id; ++ vki_uint32_t ssidref; ++ vki_xen_domain_handle_t handle; ++ vki_uint32_t cpupool; ++ struct vki_xen_arch_domainconfig_0000000c arch_config; ++}; ++typedef struct vki_xen_domctl_getdomaininfo_0000000f vki_xen_domctl_getdomaininfo_0000000f_t; ++DEFINE_VKI_XEN_GUEST_HANDLE(vki_xen_domctl_getdomaininfo_0000000f_t); ++ ++ + /* Get/set the NUMA node(s) with which the guest has affinity with. */ + /* XEN_DOMCTL_setnodeaffinity */ + /* XEN_DOMCTL_getnodeaffinity */ +@@ -215,6 +308,7 @@ struct vki_xen_domctl_vcpuaffinity_0000000a { vki_uint32_t vcpu; /* IN */ #define VKI_XEN_VCPUAFFINITY_HARD (1U<<0) #define VKI_XEN_VCPUAFFINITY_SOFT (1U<<1) @@ -1026,7 +2074,7 @@ Index: valgrind-3.13.0/include/vki/vki-xen-domctl.h vki_uint32_t flags; /* IN */ struct vki_xenctl_bitmap cpumap_hard; /* IN/OUT */ struct vki_xenctl_bitmap cpumap_soft; /* IN/OUT */ -@@ -282,9 +335,12 @@ struct vki_xen_domctl_scheduler_op { +@@ -282,9 +376,12 @@ struct vki_xen_domctl_scheduler_op { #define VKI_XEN_SCHEDULER_CREDIT2 6 #define VKI_XEN_SCHEDULER_ARINC653 7 #define VKI_XEN_SCHEDULER_RTDS 8 @@ -1039,12 +2087,12 @@ Index: valgrind-3.13.0/include/vki/vki-xen-domctl.h union { struct xen_domctl_sched_sedf { vki_xen_uint64_aligned_t period; -@@ -333,10 +389,14 @@ struct vki_xen_domctl_hypercall_init { +@@ -333,10 +430,14 @@ struct vki_xen_domctl_hypercall_init { vki_xen_uint64_aligned_t gmfn; /* GMFN to be initialised */ }; -struct vki_xen_domctl_settimeoffset { -+struct vki_xen_domctl_settimeoffset_0000000a { ++struct vki_xen_domctl_settimeoffset_00000001 { vki_int32_t time_offset_seconds; }; @@ -1055,20 +2103,20 @@ Index: valgrind-3.13.0/include/vki/vki-xen-domctl.h struct vki_xen_domctl_cpuid { vki_uint32_t input[2]; vki_uint32_t eax; -@@ -378,14 +438,22 @@ struct vki_xen_domctl_hvmcontext { +@@ -378,14 +479,22 @@ struct vki_xen_domctl_hvmcontext { typedef struct vki_xen_domctl_hvmcontext vki_xen_domctl_hvmcontext_t; DEFINE_VKI_XEN_GUEST_HANDLE(vki_xen_domctl_hvmcontext_t); -struct vki_xen_domctl_hvmcontext_partial { -+struct vki_xen_domctl_hvmcontext_partial_0000000d { ++struct vki_xen_domctl_hvmcontext_partial_00000005 { vki_uint32_t type; /* IN */ vki_uint32_t instance; /* IN */ VKI_XEN_GUEST_HANDLE_64(vki_uint8) buffer; /* IN/OUT buffer */ }; -typedef struct vki_xen_domctl_hvmcontext_partial vki_xen_domctl_hvmcontext_partial_t; -DEFINE_VKI_XEN_GUEST_HANDLE(vki_xen_domctl_hvmcontext_partial_t); -+typedef struct vki_xen_domctl_hvmcontext_partial_0000000d vki_xen_domctl_hvmcontext_partial_0000000d_t; -+DEFINE_VKI_XEN_GUEST_HANDLE(vki_xen_domctl_hvmcontext_partial_0000000d_t); ++typedef struct vki_xen_domctl_hvmcontext_partial_00000005 vki_xen_domctl_hvmcontext_partial_00000005_t; ++DEFINE_VKI_XEN_GUEST_HANDLE(vki_xen_domctl_hvmcontext_partial_00000005_t); +struct vki_xen_domctl_hvmcontext_partial_0000000e { + vki_uint32_t type; /* IN */ @@ -1081,7 +2129,7 @@ Index: valgrind-3.13.0/include/vki/vki-xen-domctl.h struct vki_xen_domctl_pin_mem_cacheattr { vki_xen_uint64_aligned_t start, end; /* IN */ -@@ -464,6 +532,20 @@ struct vki_xen_domctl_assign_device_0000 +@@ -464,6 +573,20 @@ struct vki_xen_domctl_assign_device_0000000b { vki_uint32_t flag; /* flag of assigned device */ }; @@ -1102,7 +2150,7 @@ Index: valgrind-3.13.0/include/vki/vki-xen-domctl.h struct vki_xen_domctl_debug_op { vki_uint32_t op; /* IN */ vki_uint32_t vcpu; /* IN */ -@@ -515,6 +597,12 @@ struct vki_xen_domctl_vcpu_msrs { +@@ -515,6 +638,12 @@ struct vki_xen_domctl_vcpu_msrs { #define VKI_XEN_DOMCTL_MONITOR_EVENT_SINGLESTEP 2 #define VKI_XEN_DOMCTL_MONITOR_EVENT_SOFTWARE_BREAKPOINT 3 #define VKI_XEN_DOMCTL_MONITOR_EVENT_GUEST_REQUEST 4 @@ -1115,46 +2163,26 @@ Index: valgrind-3.13.0/include/vki/vki-xen-domctl.h struct vki_xen_domctl_monitor_op_0000000b { vki_uint32_t op; /* vki_xen_DOMCTL_MONITOR_OP_* */ -@@ -553,6 +641,97 @@ struct vki_xen_domctl_monitor_op_0000000 +@@ -553,6 +682,78 @@ struct vki_xen_domctl_monitor_op_0000000b { } u; }; +struct vki_xen_domctl_monitor_op_0000000c { + vki_uint32_t op; /* vki_xen_DOMCTL_MONITOR_OP_* */ -+ -+ /* -+ * When used with ENABLE/DISABLE this has to be set to -+ * the requested vki_xen_DOMCTL_MONITOR_EVENT_* value. -+ * With GET_CAPABILITIES this field returns a bitmap of -+ * events supported by the platform, in the format -+ * (1 << vki_xen_DOMCTL_MONITOR_EVENT_*). -+ */ + vki_uint32_t event; -+ -+ /* -+ * Further options when issuing vki_xen_DOMCTL_MONITOR_OP_ENABLE. -+ */ + union { + struct { -+ /* Which control register */ + vki_uint8_t index; -+ /* Pause vCPU until response */ + vki_uint8_t sync; -+ /* Send event only on a change of value */ + vki_uint8_t onchangeonly; + } mov_to_cr; -+ + struct { + vki_uint32_t msr; + } mov_to_msr; -+ + struct { -+ /* Pause vCPU until response */ + vki_uint8_t sync; + } guest_request; -+ + struct { -+ /* Pause vCPU until response */ + vki_uint8_t sync; + } debug_exception; + } u; @@ -1162,49 +2190,50 @@ Index: valgrind-3.13.0/include/vki/vki-xen-domctl.h + +struct vki_xen_domctl_monitor_op_0000000e { + vki_uint32_t op; /* vki_xen_DOMCTL_MONITOR_OP_* */ -+ -+ /* -+ * When used with ENABLE/DISABLE this has to be set to -+ * the requested vki_xen_DOMCTL_MONITOR_EVENT_* value. -+ * With GET_CAPABILITIES this field returns a bitmap of -+ * events supported by the platform, in the format -+ * (1 << vki_xen_DOMCTL_MONITOR_EVENT_*). -+ */ + vki_uint32_t event; -+ -+ /* -+ * Further options when issuing vki_xen_DOMCTL_MONITOR_OP_ENABLE. -+ */ + union { + struct { -+ /* Which control register */ + vki_uint8_t index; -+ /* Pause vCPU until response */ + vki_uint8_t sync; -+ /* Send event only on a change of value */ + vki_uint8_t onchangeonly; -+ /* Allignment padding */ + vki_uint8_t pad1; + vki_uint32_t pad2; -+ /* -+ * Send event only if the changed bit in the control register -+ * is not masked. -+ */ + vki_xen_uint64_aligned_t bitmask; + } mov_to_cr; -+ + struct { + vki_uint32_t msr; + } mov_to_msr; -+ + struct { -+ /* Pause vCPU until response */ + vki_uint8_t sync; + vki_uint8_t allow_userspace; + } guest_request; -+ + struct { -+ /* Pause vCPU until response */ ++ vki_uint8_t sync; ++ } debug_exception; ++ } u; ++}; ++ ++struct vki_xen_domctl_monitor_op_00000010 { ++ vki_uint32_t op; /* vki_xen_DOMCTL_MONITOR_OP_* */ ++ vki_uint32_t event; ++ union { ++ struct { ++ vki_uint8_t index; ++ vki_uint8_t sync; ++ vki_uint8_t onchangeonly; ++ vki_uint8_t pad1; ++ vki_uint32_t pad2; ++ vki_xen_uint64_aligned_t bitmask; ++ } mov_to_cr; ++ struct { ++ vki_uint32_t msr; ++ vki_uint8_t onchangeonly; ++ } mov_to_msr; ++ struct { ++ vki_uint8_t sync; ++ vki_uint8_t allow_userspace; ++ } guest_request; ++ struct { + vki_uint8_t sync; + } debug_exception; + } u; @@ -1213,7 +2242,7 @@ Index: valgrind-3.13.0/include/vki/vki-xen-domctl.h struct vki_xen_domctl_monitor_op { vki_uint32_t op; -@@ -576,12 +755,20 @@ struct vki_xen_domctl_monitor_op { +@@ -576,15 +777,24 @@ struct vki_xen_domctl_monitor_op { } u; }; @@ -1228,19 +2257,23 @@ Index: valgrind-3.13.0/include/vki/vki-xen-domctl.h vki_xen_domid_t domain; union { - struct vki_xen_domctl_createdomain createdomain; -+ struct vki_xen_domctl_createdomain_0000000a createdomain_0000000a; ++ struct vki_xen_domctl_createdomain_00000004 createdomain_00000004; + struct vki_xen_domctl_createdomain_0000000b createdomain_0000000b; + struct vki_xen_domctl_createdomain_0000000c createdomain_0000000c; -+ //struct vki_xen_domctl_arm_configuredomain configuredomain; ++ struct vki_xen_domctl_createdomain_00000011 createdomain_00000011; struct vki_xen_domctl_getdomaininfo_00000007 getdomaininfo_00000007; struct vki_xen_domctl_getdomaininfo_00000008 getdomaininfo_00000008; struct vki_xen_domctl_getdomaininfo_00000009 getdomaininfo_00000009; -@@ -605,18 +792,21 @@ struct vki_xen_domctl { ++ struct vki_xen_domctl_getdomaininfo_0000000f getdomaininfo_0000000f; + //struct vki_xen_domctl_getmemlist getmemlist; + //struct vki_xen_domctl_getpageframeinfo getpageframeinfo; + //struct vki_xen_domctl_getpageframeinfo2 getpageframeinfo2; +@@ -605,18 +815,21 @@ struct vki_xen_domctl { struct vki_xen_domctl_ioport_permission ioport_permission; struct vki_xen_domctl_hypercall_init hypercall_init; //struct vki_xen_domctl_arch_setup arch_setup; - struct vki_xen_domctl_settimeoffset settimeoffset; -+ struct vki_xen_domctl_settimeoffset_0000000a settimeoffset_0000000a; ++ struct vki_xen_domctl_settimeoffset_00000001 settimeoffset_00000001; + struct vki_xen_domctl_settimeoffset_0000000b settimeoffset_0000000b; //struct vki_xen_domctl_disable_migrate disable_migrate; struct vki_xen_domctl_tsc_info_00000007 tsc_info_00000007; @@ -1248,7 +2281,7 @@ Index: valgrind-3.13.0/include/vki/vki-xen-domctl.h //struct vki_xen_domctl_real_mode_area real_mode_area; struct vki_xen_domctl_hvmcontext hvmcontext; - struct vki_xen_domctl_hvmcontext_partial hvmcontext_partial; -+ struct vki_xen_domctl_hvmcontext_partial_0000000d hvmcontext_partial_0000000d; ++ struct vki_xen_domctl_hvmcontext_partial_00000005 hvmcontext_partial_00000005; + struct vki_xen_domctl_hvmcontext_partial_0000000e hvmcontext_partial_0000000e; struct vki_xen_domctl_address_size address_size; //struct vki_xen_domctl_sendtrigger sendtrigger; @@ -1259,25 +2292,27 @@ Index: valgrind-3.13.0/include/vki/vki-xen-domctl.h //struct vki_xen_domctl_bind_pt_irq bind_pt_irq; //struct vki_xen_domctl_memory_mapping memory_mapping; //struct vki_xen_domctl_ioport_mapping ioport_mapping; -@@ -644,6 +834,13 @@ struct vki_xen_domctl { +@@ -644,6 +857,15 @@ struct vki_xen_domctl { //struct vki_xen_domctl_gdbsx_pauseunp_vcpu gdbsx_pauseunp_vcpu; //struct vki_xen_domctl_gdbsx_domstatus gdbsx_domstatus; struct vki_xen_domctl_monitor_op_0000000b monitor_op_0000000b; + struct vki_xen_domctl_monitor_op_0000000c monitor_op_0000000c; + struct vki_xen_domctl_monitor_op_0000000e monitor_op_0000000e; ++ struct vki_xen_domctl_monitor_op_00000010 monitor_op_00000010; + //struct vki_xen_domctl_vnuma vnuma; + //struct vki_xen_domctl_psr_cmt_op psr_cmt_op; + //struct vki_xen_domctl_psr_cat_op psr_cat_op; ++ //struct vki_xen_domctl_arm_configuredomain configuredomain; + struct vki_xen_domctl_set_gnttab_limits_0000000e set_gnttab_limits_0000000e; + //struct vki_xen_domctl_vuart_op vuart_op; vki_uint8_t pad[128]; } u; }; -Index: valgrind-3.13.0/include/vki/vki-xen-gnttab.h -=================================================================== ---- valgrind-3.13.0.orig/include/vki/vki-xen-gnttab.h -+++ valgrind-3.13.0/include/vki/vki-xen-gnttab.h -@@ -42,6 +42,7 @@ typedef vki_uint32_t vki_xen_grant_ref_t +diff --git a/include/vki/vki-xen-gnttab.h b/include/vki/vki-xen-gnttab.h +index 3e6c36cdb..73af94409 100644 +--- a/include/vki/vki-xen-gnttab.h ++++ b/include/vki/vki-xen-gnttab.h +@@ -42,6 +42,7 @@ typedef vki_uint32_t vki_xen_grant_ref_t; #define VKI_XEN_GNTTABOP_get_status_frames 9 #define VKI_XEN_GNTTABOP_get_version 10 #define VKI_XEN_GNTTABOP_swap_grant_ref 11 @@ -1285,10 +2320,10 @@ Index: valgrind-3.13.0/include/vki/vki-xen-gnttab.h struct vki_xen_gnttab_setup_table { /* IN parameters. */ -Index: valgrind-3.13.0/include/vki/vki-xen-memory.h -=================================================================== ---- valgrind-3.13.0.orig/include/vki/vki-xen-memory.h -+++ valgrind-3.13.0/include/vki/vki-xen-memory.h +diff --git a/include/vki/vki-xen-memory.h b/include/vki/vki-xen-memory.h +index 3b6f9e519..ae77d49c7 100644 +--- a/include/vki/vki-xen-memory.h ++++ b/include/vki/vki-xen-memory.h @@ -48,8 +48,12 @@ #define VKI_XENMEM_get_sharing_freed_pages 18 #define VKI_XENMEM_get_sharing_shared_pages 19 @@ -1317,10 +2352,10 @@ Index: valgrind-3.13.0/include/vki/vki-xen-memory.h struct vki_xen_mem_event_op { vki_uint8_t op; vki_xen_domid_t domain; -Index: valgrind-3.13.0/include/vki/vki-xen-physdev.h -=================================================================== ---- valgrind-3.13.0.orig/include/vki/vki-xen-physdev.h -+++ valgrind-3.13.0/include/vki/vki-xen-physdev.h +diff --git a/include/vki/vki-xen-physdev.h b/include/vki/vki-xen-physdev.h +index 6f8c2c84c..225119821 100644 +--- a/include/vki/vki-xen-physdev.h ++++ b/include/vki/vki-xen-physdev.h @@ -60,6 +60,15 @@ struct vki_xen_physdev_unmap_pirq { int pirq; }; @@ -1337,22 +2372,33 @@ Index: valgrind-3.13.0/include/vki/vki-xen-physdev.h #endif // __VKI_XEN_PHYSDEV_H /*--------------------------------------------------------------------*/ -Index: valgrind-3.13.0/include/vki/vki-xen-schedop.h -=================================================================== ---- valgrind-3.13.0.orig/include/vki/vki-xen-schedop.h -+++ valgrind-3.13.0/include/vki/vki-xen-schedop.h -@@ -47,4 +47,6 @@ typedef struct vki_xen_remote_shutdown v +diff --git a/include/vki/vki-xen-schedop.h b/include/vki/vki-xen-schedop.h +index 3c5b2ceeb..b18cdf4bf 100644 +--- a/include/vki/vki-xen-schedop.h ++++ b/include/vki/vki-xen-schedop.h +@@ -47,4 +47,6 @@ typedef struct vki_xen_remote_shutdown vki_xen_remote_shutdown_t; #define VKI_XEN_SCHEDOP_watchdog 6 +#define VKI_XEN_SCHEDOP_pin_override 7 + #endif /* __VKI_XEN_SCHED_OP_H */ -Index: valgrind-3.13.0/include/vki/vki-xen-sysctl.h -=================================================================== ---- valgrind-3.13.0.orig/include/vki/vki-xen-sysctl.h -+++ valgrind-3.13.0/include/vki/vki-xen-sysctl.h -@@ -9,6 +9,11 @@ +diff --git a/include/vki/vki-xen-sysctl.h b/include/vki/vki-xen-sysctl.h +index 8f4eac124..88e966ccf 100644 +--- a/include/vki/vki-xen-sysctl.h ++++ b/include/vki/vki-xen-sysctl.h +@@ -3,19 +3,30 @@ + + /* + * The sysctl interface is versioned via the interface_version +- * field. This structures in this header supports sysctl interfaces: ++ * field. The structures in this header supports sysctl interfaces: + * ++ * - 0x00000002: Xen 3.0.3 (unhandled) ++ * - 0x00000003: Xen 3.1.0 (unhandled) ++ * - 0x00000006: Xen 3.2 (unhandled) ++ * - 0x00000007: Xen 4.0 (unhandled) + * - 0x00000008: Xen 4.1 * - 0x00000009: Xen 4.2 * - 0x0000000a: Xen 4.3 & 4.4 * - 0x0000000b: Xen 4.5 @@ -1361,10 +2407,20 @@ Index: valgrind-3.13.0/include/vki/vki-xen-sysctl.h + * - 0x0000000e: Xen 4.8 + * - 0x0000000f: Xen 4.9 + * - 0x00000010: Xen 4.10 ++ * - 0x00000011: Xen 4.11 ++ * - 0x00000012: Xen 4.12 * * When adding a new subop be sure to include the variants used by all * of the above, both here and in syswrap-xen.c -@@ -34,10 +39,20 @@ + * + * Structs which are identical in all supported versions have no + * version suffix. Structs which do differ are defined multiple times +- * and use the suffix of the latest version to contain that particular ++ * and use the suffix of the earliest version to contain that particular + * variant. + */ + +@@ -34,10 +45,21 @@ #define VKI_XEN_SYSCTL_page_offline_op 14 #define VKI_XEN_SYSCTL_lockprof_op 15 #define VKI_XEN_SYSCTL_topologyinfo 16 @@ -1382,10 +2438,11 @@ Index: valgrind-3.13.0/include/vki/vki-xen-sysctl.h +#define VKI_XEN_SYSCTL_get_cpu_featureset 26 +#define VKI_XEN_SYSCTL_livepatch_op 27 +#define VKI_XEN_SYSCTL_set_parameter 28 ++#define VKI_XEN_SYSCTL_get_cpu_policy 29 struct vki_xen_sysctl_readconsole { /* IN */ -@@ -120,12 +135,45 @@ struct vki_xen_sysctl_topologyinfo { +@@ -120,12 +142,45 @@ struct vki_xen_sysctl_topologyinfo { VKI_XEN_GUEST_HANDLE_64(vki_uint32) cpu_to_node; }; @@ -1409,7 +2466,7 @@ Index: valgrind-3.13.0/include/vki/vki-xen-sysctl.h + VKI_XEN_GUEST_HANDLE_64(vki_uint32) nodes; +}; + -+struct vki_xen_sysctl_numainfo_0000000b { ++struct vki_xen_sysctl_numainfo_00000008 { vki_uint32_t max_node_index; VKI_XEN_GUEST_HANDLE_64(vki_uint64) node_to_memsize; VKI_XEN_GUEST_HANDLE_64(vki_uint64) node_to_memfree; @@ -1432,7 +2489,7 @@ Index: valgrind-3.13.0/include/vki/vki-xen-sysctl.h struct vki_xen_sysctl_physinfo_00000008 { vki_uint32_t threads_per_core; vki_uint32_t cores_per_socket; -@@ -159,6 +207,23 @@ struct vki_xen_sysctl_physinfo_0000000a +@@ -159,6 +214,23 @@ struct vki_xen_sysctl_physinfo_0000000a { vki_uint32_t capabilities; }; @@ -1456,7 +2513,7 @@ Index: valgrind-3.13.0/include/vki/vki-xen-sysctl.h /* vki_xen_sysctl_physinfo_0000000b is the same as 0000000a */ struct vki_xen_sysctl_sched_id { -@@ -166,6 +231,12 @@ struct vki_xen_sysctl_sched_id { +@@ -166,6 +238,12 @@ struct vki_xen_sysctl_sched_id { vki_uint32_t sched_id; }; @@ -1469,7 +2526,7 @@ Index: valgrind-3.13.0/include/vki/vki-xen-sysctl.h struct vki_xen_sysctl { vki_uint32_t cmd; vki_uint32_t interface_version; /* XEN_SYSCTL_INTERFACE_VERSION */ -@@ -174,8 +245,13 @@ struct vki_xen_sysctl { +@@ -174,8 +252,12 @@ struct vki_xen_sysctl { //struct vki_xen_sysctl_tbuf_op tbuf_op; struct vki_xen_sysctl_physinfo_00000008 physinfo_00000008; struct vki_xen_sysctl_physinfo_0000000a physinfo_0000000a; @@ -1478,13 +2535,12 @@ Index: valgrind-3.13.0/include/vki/vki-xen-sysctl.h - struct vki_xen_sysctl_numainfo numainfo; + struct vki_xen_sysctl_cputopoinfo_0000000c cputopoinfo_0000000c; + struct vki_xen_sysctl_pcitopoinfo_0000000c pcitopoinfo_0000000c; -+ //struct vki_xen_sysctl_cputopoinfo cputopoinfo_0000000c; -+ struct vki_xen_sysctl_numainfo_0000000b numainfo_0000000b; ++ struct vki_xen_sysctl_numainfo_00000008 numainfo_00000008; + struct vki_xen_sysctl_numainfo_0000000c numainfo_0000000c; struct vki_xen_sysctl_sched_id sched_id; //struct vki_xen_sysctl_perfc_op perfc_op; struct vki_xen_sysctl_getdomaininfolist_00000008 getdomaininfolist_00000008; -@@ -192,6 +268,14 @@ struct vki_xen_sysctl { +@@ -192,6 +274,15 @@ struct vki_xen_sysctl { struct vki_xen_sysctl_cpupool_op cpupool_op; //struct vki_xen_sysctl_scheduler_op scheduler_op; //struct vki_xen_sysctl_coverage_op coverage_op; @@ -1496,13 +2552,14 @@ Index: valgrind-3.13.0/include/vki/vki-xen-sysctl.h + struct vki_xen_sysctl_cpu_featureset_0000000d cpu_featureset_0000000d; + //struct vki_xen_sysctl_livepatch_op livepatch; + //struct vki_xen_sysctl_set_parameter set_parameter; ++ //struct vki_xen_sysctl_get_cpu_policy get_cpu_policy; vki_uint8_t pad[128]; } u; -Index: valgrind-3.13.0/include/vki/vki-xen-version.h -=================================================================== ---- valgrind-3.13.0.orig/include/vki/vki-xen-version.h -+++ valgrind-3.13.0/include/vki/vki-xen-version.h +diff --git a/include/vki/vki-xen-version.h b/include/vki/vki-xen-version.h +index dfaf7c07e..72bc56625 100644 +--- a/include/vki/vki-xen-version.h ++++ b/include/vki/vki-xen-version.h @@ -38,6 +38,7 @@ #define VKI_XENVER_pagesize 7 #define VKI_XENVER_guest_handle 8 @@ -1528,10 +2585,10 @@ Index: valgrind-3.13.0/include/vki/vki-xen-version.h #endif // __VKI_XEN_VERSION_H /*--------------------------------------------------------------------*/ -Index: valgrind-3.13.0/include/vki/vki-xen.h -=================================================================== ---- valgrind-3.13.0.orig/include/vki/vki-xen.h -+++ valgrind-3.13.0/include/vki/vki-xen.h +diff --git a/include/vki/vki-xen.h b/include/vki/vki-xen.h +index c0dfee36b..ac8b21400 100644 +--- a/include/vki/vki-xen.h ++++ b/include/vki/vki-xen.h @@ -69,6 +69,8 @@ #define __VKI_XEN_kexec_op 37 #define __VKI_XEN_tmem_op 38