From bbd92e39b84a6186c226cb41198756cf04dcc0c7dd186758505b1e7c1026b00d Mon Sep 17 00:00:00 2001 From: Dirk Mueller Date: Wed, 21 Nov 2018 12:11:24 +0000 Subject: [PATCH 01/13] - 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. OBS-URL: https://build.opensuse.org/package/show/devel:tools/valgrind?expand=0&rev=173 --- ...ad-only-PT_LOAD-segments-and-.rodata.patch | 102 - ...time-base-register-to-return-64-bits.patch | 115 - epoll-wait-fix.patch | 35 - valgrind-3.13.0.tar.bz2 | 3 - valgrind-3.14.0.tar.bz2 | 3 + valgrind.changes | 37 + valgrind.spec | 19 +- valgrind.xen.patch | 5387 +++++++++++++---- 8 files changed, 4199 insertions(+), 1502 deletions(-) delete mode 100644 0001-Accept-read-only-PT_LOAD-segments-and-.rodata.patch delete mode 100644 Fix-access-to-time-base-register-to-return-64-bits.patch delete mode 100644 epoll-wait-fix.patch delete mode 100644 valgrind-3.13.0.tar.bz2 create mode 100644 valgrind-3.14.0.tar.bz2 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/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/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..bd5e958 100644 --- a/valgrind.changes +++ b/valgrind.changes @@ -1,3 +1,40 @@ +------------------------------------------------------------------- +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..e748519 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -22,24 +22,19 @@ %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 BuildRequires: automake BuildRequires: docbook-xsl-stylesheets BuildRequires: docbook_4 @@ -110,10 +105,7 @@ 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 %build export FLAGS="%{optflags}" @@ -135,8 +127,9 @@ autoreconf -fi export GDB=%{_bindir}/gdb %configure \ + --enable-lto=yes \ %ifarch aarch64 - --enable-only64bit + --enable-only64bit %endif make %{?_smp_mflags} @@ -158,7 +151,7 @@ mkdir -p %{buildroot}%{_docdir}/%{name} cp -a README* NEWS AUTHORS %{buildroot}/%{_defaultdocdir}/%{name} %files -%license COPYING COPYING.DOCS +%license COPYING COPYING.DOCS %{_bindir}/* %doc %{_defaultdocdir}/%{name} %doc %{_mandir}/*/* diff --git a/valgrind.xen.patch b/valgrind.xen.patch index c058d88..471a716 100644 --- a/valgrind.xen.patch +++ b/valgrind.xen.patch @@ -1,80 +1,768 @@ +From 4424dfed6bb824d0ef506e8f3547bb2790a1233f Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:20:56 +0100 +Subject: [PATCH 01/75] fix xen_sysctl_numainfo handling -https://bugs.kde.org/show_bug.cgi?id=390553 -https://github.com/olafhering/valgrind/compare/master...xen +The OUT value node_to_node_distance is a 2D array, not a 1D array - 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(-) +bz#390553 +--- + coregrind/m_syswrap/syswrap-xen.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) -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 -@@ -234,6 +234,16 @@ PRE(memory_op) - case VKI_XENMEM_get_sharing_shared_pages: +diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c +index 54153ab1c..8865306f7 100644 +--- a/coregrind/m_syswrap/syswrap-xen.c ++++ b/coregrind/m_syswrap/syswrap-xen.c +@@ -1788,7 +1788,8 @@ POST(sysctl) + POST_MEM_WRITE((Addr)sysctl->u.numainfo.node_to_memfree.p, + sizeof(uint64_t) * sysctl->u.numainfo.max_node_index); + POST_MEM_WRITE((Addr)sysctl->u.numainfo.node_to_node_distance.p, +- sizeof(uint32_t) * sysctl->u.numainfo.max_node_index); ++ sizeof(uint32_t) * ++ (sysctl->u.numainfo.max_node_index * sysctl->u.numainfo.max_node_index)); 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; -+ } - case VKI_XENMEM_access_op: { - struct vki_xen_mem_event_op *arg = - (struct vki_xen_mem_event_op *)ARG2; -@@ -532,6 +542,7 @@ PRE(xen_version) - case VKI_XENVER_pagesize: - case VKI_XENVER_guest_handle: - case VKI_XENVER_commandline: -+ case VKI_XENVER_build_id: - /* No inputs */ + /* No outputs */ + +From f875f9c082532f30d68a5aee379ad04741fc05b3 Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:20:58 +0100 +Subject: [PATCH 02/75] xen-3.1: IOCTL_GNTDEV_MAP_GRANT_REF + +Signed-off-by: Olaf Hering +--- + coregrind/m_syswrap/syswrap-linux.c | 15 +++++++++++++++ + include/vki/vki-linux.h | 16 ++++++++++++++++ + 2 files changed, 31 insertions(+) + +diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c +index 90d4a8586..70be2e50b 100644 +--- a/coregrind/m_syswrap/syswrap-linux.c ++++ b/coregrind/m_syswrap/syswrap-linux.c +@@ -8260,6 +8260,15 @@ 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; + #endif -@@ -584,6 +595,11 @@ PRE(sysctl) { - case 0x00000009: - case 0x0000000a: - case 0x0000000b: -+ case 0x0000000c: -+ case 0x0000000d: -+ case 0x0000000e: -+ case 0x0000000f: -+ case 0x00000010: - break; - default: - bad_intf_version(tid, layout, arrghs, status, flags, -@@ -626,16 +642,11 @@ PRE(sysctl) { - 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: -- VG_(dmsg)("WARNING: XEN_SYSCTL_getdomaininfolist for sysctl version " -- "%"PRIx32" not implemented yet\n", -- sysctl->interface_version); -- SET_STATUS_Failure(VKI_EINVAL); -- return; + /* Lustre */ +@@ -10735,6 +10744,12 @@ 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; + #endif + + /* Lustre */ +diff --git a/include/vki/vki-linux.h b/include/vki/vki-linux.h +index b4c60854a..aad7f975a 100644 +--- a/include/vki/vki-linux.h ++++ b/include/vki/vki-linux.h +@@ -3428,6 +3428,22 @@ 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]; ++}; + + //---------------------------------------------------------------------- + // From linux-3.4.0/include/linux/fs.h + +From 4c8f2104755c4fbc0d290e9eae49e27b2d61eb86 Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:20:59 +0100 +Subject: [PATCH 03/75] xen-3.1: IOCTL_GNTDEV_UNMAP_GRANT_REF + +bz#390553 +--- + coregrind/m_syswrap/syswrap-linux.c | 14 ++++++++++++++ + include/vki/vki-linux.h | 8 ++++++++ + 2 files changed, 22 insertions(+) + +diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c +index 70be2e50b..9c24348ee 100644 +--- a/coregrind/m_syswrap/syswrap-linux.c ++++ b/coregrind/m_syswrap/syswrap-linux.c +@@ -8269,6 +8269,17 @@ PRE(sys_ioctl) + (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; + #endif -@@ -681,17 +692,69 @@ PRE(sysctl) { + /* Lustre */ +@@ -10750,6 +10761,9 @@ POST(sys_ioctl) + POST_FIELD_WRITE(args->index); + } + break; ++ case VKI_XEN_IOCTL_GNTDEV_UNMAP_GRANT_REF: ++ /* No output */ ++ break; + #endif + + /* Lustre */ +diff --git a/include/vki/vki-linux.h b/include/vki/vki-linux.h +index aad7f975a..9153997ea 100644 +--- a/include/vki/vki-linux.h ++++ b/include/vki/vki-linux.h +@@ -3445,6 +3445,14 @@ struct vki_xen_ioctl_gntdev_map_grant_ref { + 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; ++}; ++ + //---------------------------------------------------------------------- + // From linux-3.4.0/include/linux/fs.h + //---------------------------------------------------------------------- + +From 61dc99a7fba4efcda3cec3b00a2143039899153e Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:21:00 +0100 +Subject: [PATCH 04/75] xen-3.1: IOCTL_GNTDEV_GET_OFFSET_FOR_VADDR + +bz#390553 +--- + coregrind/m_syswrap/syswrap-linux.c | 14 ++++++++++++++ + include/vki/vki-linux.h | 9 +++++++++ + 2 files changed, 23 insertions(+) + +diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c +index 9c24348ee..01112a2fb 100644 +--- a/coregrind/m_syswrap/syswrap-linux.c ++++ b/coregrind/m_syswrap/syswrap-linux.c +@@ -8280,6 +8280,13 @@ PRE(sys_ioctl) + (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; + #endif + + /* Lustre */ +@@ -10764,6 +10771,13 @@ POST(sys_ioctl) + 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; + #endif + + /* Lustre */ +diff --git a/include/vki/vki-linux.h b/include/vki/vki-linux.h +index 9153997ea..3878eca0d 100644 +--- a/include/vki/vki-linux.h ++++ b/include/vki/vki-linux.h +@@ -3453,6 +3453,15 @@ struct vki_xen_ioctl_gntdev_unmap_grant_ref { + 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; ++}; ++ + //---------------------------------------------------------------------- + // From linux-3.4.0/include/linux/fs.h + //---------------------------------------------------------------------- + +From 4a059dc428cf47962ca9f8582107de3660b7fc0d Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:21:01 +0100 +Subject: [PATCH 05/75] xen-3.3: IOCTL_GNTDEV_SET_MAX_GRANTS + +bz#390553 +--- + coregrind/m_syswrap/syswrap-linux.c | 10 ++++++++++ + include/vki/vki-linux.h | 6 ++++++ + 2 files changed, 16 insertions(+) + +diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c +index 01112a2fb..16a1aae1f 100644 +--- a/coregrind/m_syswrap/syswrap-linux.c ++++ b/coregrind/m_syswrap/syswrap-linux.c +@@ -8287,6 +8287,13 @@ PRE(sys_ioctl) + (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; + #endif + + /* Lustre */ +@@ -10778,6 +10785,9 @@ POST(sys_ioctl) + POST_FIELD_WRITE(args->offset); + } + break; ++ case VKI_XEN_IOCTL_GNTDEV_SET_MAX_GRANTS: ++ /* No output */ ++ break; + #endif + + /* Lustre */ +diff --git a/include/vki/vki-linux.h b/include/vki/vki-linux.h +index 3878eca0d..a743b9678 100644 +--- a/include/vki/vki-linux.h ++++ b/include/vki/vki-linux.h +@@ -3462,6 +3462,12 @@ struct vki_xen_ioctl_gntdev_get_offset_for_vaddr { + 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; ++}; ++ + //---------------------------------------------------------------------- + // From linux-3.4.0/include/linux/fs.h + //---------------------------------------------------------------------- + +From 1e0cd634023ea9bf579f039194258e6c565a1ce2 Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:21:02 +0100 +Subject: [PATCH 06/75] xen-4.2: IOCTL_GNTALLOC_ALLOC_GREF + +bz#390553 +--- + coregrind/m_syswrap/syswrap-linux.c | 20 ++++++++++++++++++++ + include/vki/vki-linux.h | 10 ++++++++++ + 2 files changed, 30 insertions(+) + +diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c +index 16a1aae1f..433086116 100644 +--- a/coregrind/m_syswrap/syswrap-linux.c ++++ b/coregrind/m_syswrap/syswrap-linux.c +@@ -8294,6 +8294,17 @@ PRE(sys_ioctl) + (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; + #endif + + /* Lustre */ +@@ -10788,6 +10799,15 @@ POST(sys_ioctl) + 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; + #endif + + /* Lustre */ +diff --git a/include/vki/vki-linux.h b/include/vki/vki-linux.h +index a743b9678..472071a12 100644 +--- a/include/vki/vki-linux.h ++++ b/include/vki/vki-linux.h +@@ -3468,6 +3468,16 @@ 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]; ++}; ++ + //---------------------------------------------------------------------- + // From linux-3.4.0/include/linux/fs.h + //---------------------------------------------------------------------- + +From 353dc51d07ff08e24cccf32a1ae0e6b879dacdc9 Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Mon, 19 Nov 2018 10:49:49 +0100 +Subject: [PATCH 07/75] xen-4.2: IOCTL_GNTALLOC_DEALLOC_GREF + +bz#390553 +--- + coregrind/m_syswrap/syswrap-linux.c | 12 ++++++++++++ + include/vki/vki-linux.h | 7 +++++++ + 2 files changed, 19 insertions(+) + +diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c +index 433086116..774849907 100644 +--- a/coregrind/m_syswrap/syswrap-linux.c ++++ b/coregrind/m_syswrap/syswrap-linux.c +@@ -8305,6 +8305,15 @@ PRE(sys_ioctl) + (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; + #endif + + /* Lustre */ +@@ -10808,6 +10817,9 @@ POST(sys_ioctl) + sizeof(args->gref_ids) * sizeof(args->count)); + } + break; ++ case VKI_XEN_IOCTL_GNTALLOC_DEALLOC_GREF: ++ /* No output */ ++ break; + #endif + + /* Lustre */ +diff --git a/include/vki/vki-linux.h b/include/vki/vki-linux.h +index 472071a12..eb0b23615 100644 +--- a/include/vki/vki-linux.h ++++ b/include/vki/vki-linux.h +@@ -3478,6 +3478,13 @@ struct vki_xen_ioctl_gntalloc_alloc_gref { + 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; ++}; ++ + //---------------------------------------------------------------------- + // From linux-3.4.0/include/linux/fs.h + //---------------------------------------------------------------------- + +From 180935afc7b31975db44a5172f147ca214ca3ffd Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Mon, 19 Nov 2018 10:56:08 +0100 +Subject: [PATCH 08/75] xen-4.2: IOCTL_GNTALLOC_SET_UNMAP_NOTIFY + +bz#390553 +--- + coregrind/m_syswrap/syswrap-linux.c | 12 ++++++++++++ + include/vki/vki-linux.h | 8 ++++++++ + 2 files changed, 20 insertions(+) + +diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c +index 774849907..1b6064138 100644 +--- a/coregrind/m_syswrap/syswrap-linux.c ++++ b/coregrind/m_syswrap/syswrap-linux.c +@@ -8314,6 +8314,17 @@ PRE(sys_ioctl) + (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; + #endif + + /* Lustre */ +@@ -10818,6 +10829,7 @@ POST(sys_ioctl) + } + break; + case VKI_XEN_IOCTL_GNTALLOC_DEALLOC_GREF: ++ case VKI_XEN_IOCTL_GNTALLOC_SET_UNMAP_NOTIFY: + /* No output */ + break; + #endif +diff --git a/include/vki/vki-linux.h b/include/vki/vki-linux.h +index eb0b23615..6b079ebaf 100644 +--- a/include/vki/vki-linux.h ++++ b/include/vki/vki-linux.h +@@ -3485,6 +3485,14 @@ struct vki_xen_ioctl_gntalloc_dealloc_gref { + 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; ++}; ++ + //---------------------------------------------------------------------- + // From linux-3.4.0/include/linux/fs.h + //---------------------------------------------------------------------- + +From 8ced0994062e3cfc53a1e396d24add017c8eb0f1 Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:21:03 +0100 +Subject: [PATCH 09/75] xen: include vki-xen-physdev.h earlier in vki-xen.h + +Upcoming changes will require defines from this file. + +bz#390553 +--- + include/vki/vki-xen.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/include/vki/vki-xen.h b/include/vki/vki-xen.h +index c0dfee36b..2d65bcc0e 100644 +--- a/include/vki/vki-xen.h ++++ b/include/vki/vki-xen.h +@@ -104,6 +104,7 @@ struct vki_xenctl_bitmap { + vki_uint32_t nr_bits; + }; + ++#include + #include + #include + #include +@@ -115,7 +116,6 @@ struct vki_xenctl_bitmap { + #include + #include + #include +-#include + + #endif // __VKI_XEN_H + + +From dfa5ff84112f0eb47c80a32d1707cfe74f3b5032 Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:21:04 +0100 +Subject: [PATCH 10/75] xen-4.2: add sharing_op + +Add define for XENMEM_sharing_op + +bz#390553 +--- + include/vki/vki-xen-memory.h | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/include/vki/vki-xen-memory.h b/include/vki/vki-xen-memory.h +index 3b6f9e519..4fc575d39 100644 +--- a/include/vki/vki-xen-memory.h ++++ b/include/vki/vki-xen-memory.h +@@ -48,6 +48,7 @@ + #define VKI_XENMEM_get_sharing_freed_pages 18 + #define VKI_XENMEM_get_sharing_shared_pages 19 + #define VKI_XENMEM_access_op 21 ++#define VKI_XENMEM_sharing_op 22 + #define VKI_XENMEM_claim_pages 24 + #define VKI_XENMEM_machphys_compat_mfn_list 25 + + +From 3536fdc85b4ad7bcb27057b14bba973a42408951 Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:21:05 +0100 +Subject: [PATCH 11/75] xen-4.4: add_to_physmap_batch + +Add define for XENMEM_add_to_physmap_batch, which used to be +XENMEM_add_to_physmap_range up to xen-4.3. + +bz#390553 +--- + include/vki/vki-xen-memory.h | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/include/vki/vki-xen-memory.h b/include/vki/vki-xen-memory.h +index 4fc575d39..0de46ff9d 100644 +--- a/include/vki/vki-xen-memory.h ++++ b/include/vki/vki-xen-memory.h +@@ -49,6 +49,7 @@ + #define VKI_XENMEM_get_sharing_shared_pages 19 + #define VKI_XENMEM_access_op 21 + #define VKI_XENMEM_sharing_op 22 ++#define VKI_XENMEM_add_to_physmap_batch 23 + #define VKI_XENMEM_claim_pages 24 + #define VKI_XENMEM_machphys_compat_mfn_list 25 + + +From 1044c9e04d3987b234bcc35590c9a0374a78a827 Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:21:06 +0100 +Subject: [PATCH 12/75] xen-4.5: psr_cmt_op + +Add defines introduced in xen-4.5 + +bz#390553 +--- + include/vki/vki-xen-sysctl.h | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/include/vki/vki-xen-sysctl.h b/include/vki/vki-xen-sysctl.h +index 8f4eac124..6fab979e0 100644 +--- a/include/vki/vki-xen-sysctl.h ++++ b/include/vki/vki-xen-sysctl.h +@@ -38,6 +38,7 @@ + #define VKI_XEN_SYSCTL_cpupool_op 18 + #define VKI_XEN_SYSCTL_scheduler_op 19 + #define VKI_XEN_SYSCTL_coverage_op 20 ++#define VKI_XEN_SYSCTL_psr_cmt_op 21 + + struct vki_xen_sysctl_readconsole { + /* IN */ +@@ -192,6 +193,7 @@ 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; ++ //struct vki_xen_sysctl_psr_cmt_op psr_cmt_op; + + vki_uint8_t pad[128]; + } u; + +From 8eea6fda76928c86fe45854e6905a409145edb52 Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:21:07 +0100 +Subject: [PATCH 13/75] xen-4.5: GNTTABOP_cache_flush + +Add defines introduced in xen-4.5 + +bz#390553 +--- + include/vki/vki-xen-gnttab.h | 1 + + 1 file changed, 1 insertion(+) + +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 ++#define VKI_XEN_GNTTABOP_cache_flush 12 + + struct vki_xen_gnttab_setup_table { + /* IN parameters. */ + +From 7cb3b6e06c157ccbc3d712bbf7d116a8305a31c4 Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:21:09 +0100 +Subject: [PATCH 14/75] xen-4.5: domctl defines + +Add defines introduced in xen-4.5 + +bz#390553 +--- + include/vki/vki-xen-domctl.h | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/include/vki/vki-xen-domctl.h b/include/vki/vki-xen-domctl.h +index 9e8b5ef1f..3963fdd97 100644 +--- a/include/vki/vki-xen-domctl.h ++++ b/include/vki/vki-xen-domctl.h +@@ -119,6 +119,9 @@ + #define VKI_XEN_DOMCTL_cacheflush 71 + #define VKI_XEN_DOMCTL_get_vcpu_msrs 72 + #define VKI_XEN_DOMCTL_set_vcpu_msrs 73 ++#define VKI_XEN_DOMCTL_setvnumainfo 74 ++#define VKI_XEN_DOMCTL_psr_cmt_op 75 ++#define VKI_XEN_DOMCTL_arm_configure_domain 76 + #define VKI_XEN_DOMCTL_monitor_op 77 /* new in 4.6 */ + #define VKI_XEN_DOMCTL_gdbsx_guestmemio 1000 + #define VKI_XEN_DOMCTL_gdbsx_pausevcpu 1001 +@@ -582,6 +585,7 @@ struct vki_xen_domctl { + vki_xen_domid_t domain; + union { + struct vki_xen_domctl_createdomain createdomain; ++ //struct vki_xen_domctl_arm_configuredomain configuredomain; + struct vki_xen_domctl_getdomaininfo_00000007 getdomaininfo_00000007; + struct vki_xen_domctl_getdomaininfo_00000008 getdomaininfo_00000008; + struct vki_xen_domctl_getdomaininfo_00000009 getdomaininfo_00000009; +@@ -644,6 +648,8 @@ 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_vnuma vnuma; ++ //struct vki_xen_domctl_psr_cmt_op psr_cmt_op; + vki_uint8_t pad[128]; + } u; + }; + +From 7287d5c3f526fd2413cf9a20c54bc1290fec9085 Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:21:10 +0100 +Subject: [PATCH 15/75] xen-4.5: xen_domctl_createdomain + +Rename createdomain to represent layout up to xen-4.5. + +bz#390553 +--- + coregrind/m_syswrap/syswrap-xen.c | 13 ++++++++++--- + include/vki/vki-xen-domctl.h | 4 ++-- + 2 files changed, 12 insertions(+), 5 deletions(-) + +diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c +index 8865306f7..7eb1b2176 100644 +--- a/coregrind/m_syswrap/syswrap-xen.c ++++ b/coregrind/m_syswrap/syswrap-xen.c +@@ -757,9 +757,16 @@ PRE(domctl) + break; + + case VKI_XEN_DOMCTL_createdomain: +- PRE_XEN_DOMCTL_READ(createdomain, ssidref); +- PRE_XEN_DOMCTL_READ(createdomain, handle); +- PRE_XEN_DOMCTL_READ(createdomain, flags); ++ switch (domctl->interface_version) { ++ case 0x00000007: ++ 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); ++ break; ++ } + break; + + case VKI_XEN_DOMCTL_gethvmcontext: +diff --git a/include/vki/vki-xen-domctl.h b/include/vki/vki-xen-domctl.h +index 3963fdd97..36767d102 100644 +--- a/include/vki/vki-xen-domctl.h ++++ b/include/vki/vki-xen-domctl.h +@@ -128,7 +128,7 @@ + #define VKI_XEN_DOMCTL_gdbsx_unpausevcpu 1002 + #define VKI_XEN_DOMCTL_gdbsx_domstatus 1003 + +-struct vki_xen_domctl_createdomain { ++struct vki_xen_domctl_createdomain_0000000a { + /* IN parameters */ + vki_uint32_t ssidref; + vki_xen_domain_handle_t handle; +@@ -584,7 +584,7 @@ struct vki_xen_domctl { + vki_uint32_t interface_version; /* XEN_DOMCTL_INTERFACE_VERSION */ + vki_xen_domid_t domain; + union { +- struct vki_xen_domctl_createdomain createdomain; ++ struct vki_xen_domctl_createdomain_0000000a createdomain_0000000a; + //struct vki_xen_domctl_arm_configuredomain configuredomain; + struct vki_xen_domctl_getdomaininfo_00000007 getdomaininfo_00000007; + struct vki_xen_domctl_getdomaininfo_00000008 getdomaininfo_00000008; + +From ea4f0af7f70b4c82d838dc6cee1d66cd8e352647 Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:21:11 +0100 +Subject: [PATCH 16/75] xen-4.5: XENMEM_get_vnumainfo + +Add define for XENMEM_get_vnumainfo + +bz#390553 +--- + include/vki/vki-xen-memory.h | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/include/vki/vki-xen-memory.h b/include/vki/vki-xen-memory.h +index 0de46ff9d..4dc233f70 100644 +--- a/include/vki/vki-xen-memory.h ++++ b/include/vki/vki-xen-memory.h +@@ -52,6 +52,7 @@ + #define VKI_XENMEM_add_to_physmap_batch 23 + #define VKI_XENMEM_claim_pages 24 + #define VKI_XENMEM_machphys_compat_mfn_list 25 ++#define VKI_XENMEM_get_vnumainfo 26 + + struct vki_xen_memory_map { + unsigned int nr_entries; + +From 5aff54d961d804d03684039d8c18e10c94ba50f1 Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:21:12 +0100 +Subject: [PATCH 17/75] xen-4.5: XEN_SYSCTL_topologyinfo + +The XEN_SYSCTL_topologyinfo was available until xen-4.5. +In xen-4.6 it was replaced by XEN_SYSCTL_cputopoinfo. +Both share the same number. + +bz#390553 +--- + coregrind/m_syswrap/syswrap-xen.c | 54 +++++++++++++++++++++++-------- + 1 file changed, 40 insertions(+), 14 deletions(-) + +diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c +index 7eb1b2176..33e5fd626 100644 +--- a/coregrind/m_syswrap/syswrap-xen.c ++++ b/coregrind/m_syswrap/syswrap-xen.c +@@ -681,10 +681,25 @@ PRE(sysctl) { break; case VKI_XEN_SYSCTL_topologyinfo: @@ -82,7 +770,6 @@ Index: valgrind-3.13.0/coregrind/m_syswrap/syswrap-xen.c - 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: + switch (sysctl->interface_version) + { + case 0x00000007: @@ -95,15 +782,77 @@ Index: valgrind-3.13.0/coregrind/m_syswrap/syswrap-xen.c + PRE_XEN_SYSCTL_READ(topologyinfo, cpu_to_socket); + PRE_XEN_SYSCTL_READ(topologyinfo, cpu_to_node); + break; -+ case 0x0000000c: + default: -+ PRE_XEN_SYSCTL_READ(cputopoinfo_0000000c, num_cpus); -+ PRE_XEN_SYSCTL_READ(cputopoinfo_0000000c, cputopo); ++ VG_(dmsg)("WARNING: XEN_SYSCTL_cputopoinfo for sysctl version " ++ "%"PRIx32" not implemented yet\n", ++ sysctl->interface_version); ++ SET_STATUS_Failure(VKI_EINVAL); ++ return; ++ } + break; + + case VKI_XEN_SYSCTL_numainfo: +@@ -1776,16 +1791,27 @@ POST(sysctl) + break; + + 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, +- 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); +- 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); ++ switch (sysctl->interface_version) ++ { ++ case 0x00000007: ++ case 0x00000008: ++ case 0x00000009: ++ case 0x0000000a: ++ case 0x0000000b: ++ 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); ++ 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); ++ 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); ++ break; ++ default: + break; + } break; case VKI_XEN_SYSCTL_numainfo: + +From 234be8be627d4fdadef4fa9fe11c0dfd763db8f7 Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:21:13 +0100 +Subject: [PATCH 18/75] xen-4.5: XEN_SYSCTL_numainfo + +The XEN_SYSCTL_numainfo changed layout after xen-4.5. +Rename layout and handle runtime upto xen-4.5. + +bz#390553 +--- + coregrind/m_syswrap/syswrap-xen.c | 50 +++++++++++++++++++++++-------- + include/vki/vki-xen-sysctl.h | 4 +-- + 2 files changed, 40 insertions(+), 14 deletions(-) + +diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c +index 33e5fd626..a5942c33b 100644 +--- a/coregrind/m_syswrap/syswrap-xen.c ++++ b/coregrind/m_syswrap/syswrap-xen.c +@@ -703,10 +703,25 @@ PRE(sysctl) { + break; + + case VKI_XEN_SYSCTL_numainfo: - PRE_XEN_SYSCTL_READ(numainfo, max_node_index); - PRE_XEN_SYSCTL_READ(numainfo, node_to_memsize); - PRE_XEN_SYSCTL_READ(numainfo, node_to_memfree); @@ -120,63 +869,198 @@ Index: valgrind-3.13.0/coregrind/m_syswrap/syswrap-xen.c + PRE_XEN_SYSCTL_READ(numainfo_0000000b, node_to_memfree); + PRE_XEN_SYSCTL_READ(numainfo_0000000b, node_to_node_distance); + break; -+ case 0x0000000c: + default: -+ PRE_XEN_SYSCTL_READ(numainfo_0000000c, num_nodes); -+ PRE_XEN_SYSCTL_READ(numainfo_0000000c, meminfo); -+ PRE_XEN_SYSCTL_READ(numainfo_0000000c, distance); -+ break; -+ } -+ break; -+ -+ case VKI_XEN_SYSCTL_pcitopoinfo: -+ switch (sysctl->interface_version) -+ { -+ case 0x0000000c: -+ default: -+ PRE_XEN_SYSCTL_READ(pcitopoinfo_0000000c, num_devs); -+ PRE_XEN_SYSCTL_READ(pcitopoinfo_0000000c, devs); -+ break; -+ } -+ break; -+ -+ case VKI_XEN_SYSCTL_get_cpu_featureset: -+ switch (sysctl->interface_version) -+ { -+ case 0x0000000c: -+ default: -+ PRE_XEN_SYSCTL_READ(cpu_featureset_0000000d, index); -+ PRE_XEN_SYSCTL_READ(cpu_featureset_0000000d, nr_features); -+ break; ++ VG_(dmsg)("WARNING: XEN_SYSCTL_numainfo for sysctl version " ++ "%"PRIx32" not implemented yet\n", ++ sysctl->interface_version); ++ SET_STATUS_Failure(VKI_EINVAL); ++ return; + } break; default: -@@ -730,6 +793,8 @@ PRE(domctl) - case 0x0000000a: - case 0x0000000b: - case 0x0000000c: -+ case 0x0000000d: -+ case 0x0000000e: - break; - default: - bad_intf_version(tid, layout, arrghs, status, flags, -@@ -757,9 +822,42 @@ PRE(domctl) +@@ -1815,14 +1830,25 @@ POST(sysctl) break; - case VKI_XEN_DOMCTL_createdomain: -- PRE_XEN_DOMCTL_READ(createdomain, ssidref); -- PRE_XEN_DOMCTL_READ(createdomain, handle); -- PRE_XEN_DOMCTL_READ(createdomain, flags); + case VKI_XEN_SYSCTL_numainfo: +- POST_XEN_SYSCTL_WRITE(numainfo, max_node_index); +- POST_MEM_WRITE((Addr)sysctl->u.numainfo.node_to_memsize.p, +- sizeof(uint64_t) * sysctl->u.numainfo.max_node_index); +- POST_MEM_WRITE((Addr)sysctl->u.numainfo.node_to_memfree.p, +- sizeof(uint64_t) * sysctl->u.numainfo.max_node_index); +- POST_MEM_WRITE((Addr)sysctl->u.numainfo.node_to_node_distance.p, +- sizeof(uint32_t) * +- (sysctl->u.numainfo.max_node_index * 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, ++ sizeof(uint32_t) * ++ (sysctl->u.numainfo_0000000b.max_node_index * sysctl->u.numainfo_0000000b.max_node_index)); ++ break; ++ default: ++ break; ++ } + break; + + /* No outputs */ +diff --git a/include/vki/vki-xen-sysctl.h b/include/vki/vki-xen-sysctl.h +index 6fab979e0..22ac1706f 100644 +--- a/include/vki/vki-xen-sysctl.h ++++ b/include/vki/vki-xen-sysctl.h +@@ -121,7 +121,7 @@ struct vki_xen_sysctl_topologyinfo { + VKI_XEN_GUEST_HANDLE_64(vki_uint32) cpu_to_node; + }; + +-struct vki_xen_sysctl_numainfo { ++struct vki_xen_sysctl_numainfo_0000000b { + 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; +@@ -176,7 +176,7 @@ struct vki_xen_sysctl { + struct vki_xen_sysctl_physinfo_00000008 physinfo_00000008; + struct vki_xen_sysctl_physinfo_0000000a physinfo_0000000a; + struct vki_xen_sysctl_topologyinfo topologyinfo; +- struct vki_xen_sysctl_numainfo numainfo; ++ struct vki_xen_sysctl_numainfo_0000000b numainfo_0000000b; + struct vki_xen_sysctl_sched_id sched_id; + //struct vki_xen_sysctl_perfc_op perfc_op; + struct vki_xen_sysctl_getdomaininfolist_00000008 getdomaininfolist_00000008; + +From dac103346e6d6ec76a98366bed3ed79c61cad69c Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:21:14 +0100 +Subject: [PATCH 19/75] xen-4.5: xen_domctl_settimeoffset + +Rename settimeoffset to represent layout up to xen-4.5. + +bz#390553 +--- + coregrind/m_syswrap/syswrap-xen.c | 11 +++++++++-- + include/vki/vki-xen-domctl.h | 4 ++-- + 2 files changed, 11 insertions(+), 4 deletions(-) + +diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c +index a5942c33b..95e5e5994 100644 +--- a/coregrind/m_syswrap/syswrap-xen.c ++++ b/coregrind/m_syswrap/syswrap-xen.c +@@ -983,8 +983,15 @@ PRE(domctl) + break; + + case VKI_XEN_DOMCTL_settimeoffset: +- PRE_XEN_DOMCTL_READ(settimeoffset, time_offset_seconds); +- break; + switch (domctl->interface_version) { + case 0x00000007: + 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(settimeoffset_0000000a, time_offset_seconds); + break; ++ } ++ break; + + case VKI_XEN_DOMCTL_getvcpuinfo: + PRE_XEN_DOMCTL_READ(getvcpuinfo, vcpu); +diff --git a/include/vki/vki-xen-domctl.h b/include/vki/vki-xen-domctl.h +index 36767d102..8940e27ba 100644 +--- a/include/vki/vki-xen-domctl.h ++++ b/include/vki/vki-xen-domctl.h +@@ -336,7 +336,7 @@ 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 { + vki_int32_t time_offset_seconds; + }; + +@@ -609,7 +609,7 @@ 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_disable_migrate disable_migrate; + struct vki_xen_domctl_tsc_info_00000007 tsc_info_00000007; + struct vki_xen_domctl_tsc_info_0000000b tsc_info_0000000b; + +From 75476204f440888a407815ea513d00454a41edf8 Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:21:15 +0100 +Subject: [PATCH 20/75] xen-4.6: sysctl value + +Add 0xc as sysctl value of xen-4.6 + +bz#390553 +--- + coregrind/m_syswrap/syswrap-xen.c | 2 ++ + include/vki/vki-xen-sysctl.h | 1 + + 2 files changed, 3 insertions(+) + +diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c +index 95e5e5994..6b1c585b7 100644 +--- a/coregrind/m_syswrap/syswrap-xen.c ++++ b/coregrind/m_syswrap/syswrap-xen.c +@@ -584,6 +584,7 @@ PRE(sysctl) { + case 0x00000009: + case 0x0000000a: + case 0x0000000b: ++ case 0x0000000c: + break; + default: + bad_intf_version(tid, layout, arrghs, status, flags, +@@ -1716,6 +1717,7 @@ POST(sysctl) + case 0x00000009: + case 0x0000000a: + case 0x0000000b: ++ case 0x0000000c: + break; + default: + return; +diff --git a/include/vki/vki-xen-sysctl.h b/include/vki/vki-xen-sysctl.h +index 22ac1706f..248a5e12f 100644 +--- a/include/vki/vki-xen-sysctl.h ++++ b/include/vki/vki-xen-sysctl.h +@@ -9,6 +9,7 @@ + * - 0x00000009: Xen 4.2 + * - 0x0000000a: Xen 4.3 & 4.4 + * - 0x0000000b: Xen 4.5 ++ * - 0x0000000c: Xen 4.6 + * + * When adding a new subop be sure to include the variants used by all + * of the above, both here and in syswrap-xen.c + +From 620229b03e40308f7ca9916de1bc745d54843b2b Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:21:16 +0100 +Subject: [PATCH 21/75] xen-4.6: xen_domctl_createdomain + +xen_domctl_createdomain changed layout in xen-4.6 + +bz#390553 +--- + coregrind/m_syswrap/syswrap-xen.c | 13 +++++++++++++ + include/vki/vki-xen-domctl.h | 22 ++++++++++++++++++++++ + 2 files changed, 35 insertions(+) + +diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c +index 6b1c585b7..b4adf791a 100644 +--- a/coregrind/m_syswrap/syswrap-xen.c ++++ b/coregrind/m_syswrap/syswrap-xen.c +@@ -797,6 +797,19 @@ PRE(domctl) + PRE_XEN_DOMCTL_READ(createdomain_0000000a, handle); + PRE_XEN_DOMCTL_READ(createdomain_0000000a, flags); + break; + case 0x0000000b: + PRE_XEN_DOMCTL_READ(createdomain_0000000b, ssidref); + PRE_XEN_DOMCTL_READ(createdomain_0000000b, handle); @@ -190,6 +1074,555 @@ Index: valgrind-3.13.0/coregrind/m_syswrap/syswrap-xen.c + __PRE_XEN_DOMCTL_READ(createdomain_0000000b, createdomain_0000000b, config.clock_frequency); +#endif + break; + } + break; + +diff --git a/include/vki/vki-xen-domctl.h b/include/vki/vki-xen-domctl.h +index 8940e27ba..e5590cbea 100644 +--- a/include/vki/vki-xen-domctl.h ++++ b/include/vki/vki-xen-domctl.h +@@ -135,6 +135,27 @@ struct vki_xen_domctl_createdomain_0000000a { + vki_uint32_t flags; + }; + ++struct vki_xen_arch_domainconfig_0000000b { ++#if defined(__i386__) || defined(__x86_64__) ++ vki_uint8_t dummy; ++#endif ++#if defined(__arm__) || defined(__aarch64__) ++ /* IN/OUT */ ++ vki_uint8_t gic_version; ++ /* IN */ ++ vki_uint32_t nr_spis; ++ vki_uint32_t clock_frequency; ++#endif ++}; ++ ++struct vki_xen_domctl_createdomain_0000000b { ++ /* IN parameters */ ++ vki_uint32_t ssidref; ++ vki_xen_domain_handle_t handle; ++ vki_uint32_t flags; ++ struct vki_xen_arch_domainconfig_0000000b config; ++}; ++ + struct vki_xen_domctl_getdomaininfo_00000007 { + /* OUT variables. */ + vki_xen_domid_t domain; +@@ -585,6 +606,7 @@ struct vki_xen_domctl { + vki_xen_domid_t domain; + union { + struct vki_xen_domctl_createdomain_0000000a createdomain_0000000a; ++ struct vki_xen_domctl_createdomain_0000000b createdomain_0000000b; + //struct vki_xen_domctl_arm_configuredomain configuredomain; + struct vki_xen_domctl_getdomaininfo_00000007 getdomaininfo_00000007; + struct vki_xen_domctl_getdomaininfo_00000008 getdomaininfo_00000008; + +From 58c84ebc2895a0bc2725e5ecc647403c233c4ec6 Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:21:17 +0100 +Subject: [PATCH 22/75] xen-4.6: xen_domctl_settimeoffset + +Handle xen_domctl_settimeoffset layout introduced in xen-4.6 + +bz#390553 +--- + coregrind/m_syswrap/syswrap-xen.c | 3 +++ + include/vki/vki-xen-domctl.h | 5 +++++ + 2 files changed, 8 insertions(+) + +diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c +index b4adf791a..bf58c0726 100644 +--- a/coregrind/m_syswrap/syswrap-xen.c ++++ b/coregrind/m_syswrap/syswrap-xen.c +@@ -1004,6 +1004,9 @@ PRE(domctl) + case 0x0000000a: + PRE_XEN_DOMCTL_READ(settimeoffset_0000000a, time_offset_seconds); + break; ++ case 0x0000000b: ++ PRE_XEN_DOMCTL_READ(settimeoffset_0000000b, time_offset_seconds); ++ break; + } + break; + +diff --git a/include/vki/vki-xen-domctl.h b/include/vki/vki-xen-domctl.h +index e5590cbea..2c3c5fcf8 100644 +--- a/include/vki/vki-xen-domctl.h ++++ b/include/vki/vki-xen-domctl.h +@@ -361,6 +361,10 @@ struct vki_xen_domctl_settimeoffset_0000000a { + vki_int32_t time_offset_seconds; + }; + ++struct vki_xen_domctl_settimeoffset_0000000b { ++ vki_int64_t time_offset_seconds; ++}; ++ + struct vki_xen_domctl_cpuid { + vki_uint32_t input[2]; + vki_uint32_t eax; +@@ -632,6 +636,7 @@ struct vki_xen_domctl { + struct vki_xen_domctl_hypercall_init hypercall_init; + //struct vki_xen_domctl_arch_setup arch_setup; + struct vki_xen_domctl_settimeoffset_0000000a settimeoffset_0000000a; ++ 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; + struct vki_xen_domctl_tsc_info_0000000b tsc_info_0000000b; + +From 8e7fe10461322d9f2f7b67da0ed350c7f7c6eb4c Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:21:18 +0100 +Subject: [PATCH 23/75] xen-4.6: psr_cat_op + +Add defines for psr_cat_op introduced in xen-4.6 + +bz#390553 +--- + include/vki/vki-xen-domctl.h | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/include/vki/vki-xen-domctl.h b/include/vki/vki-xen-domctl.h +index 2c3c5fcf8..b88c56aba 100644 +--- a/include/vki/vki-xen-domctl.h ++++ b/include/vki/vki-xen-domctl.h +@@ -123,6 +123,7 @@ + #define VKI_XEN_DOMCTL_psr_cmt_op 75 + #define VKI_XEN_DOMCTL_arm_configure_domain 76 + #define VKI_XEN_DOMCTL_monitor_op 77 /* new in 4.6 */ ++#define VKI_XEN_DOMCTL_psr_cat_op 78 + #define VKI_XEN_DOMCTL_gdbsx_guestmemio 1000 + #define VKI_XEN_DOMCTL_gdbsx_pausevcpu 1001 + #define VKI_XEN_DOMCTL_gdbsx_unpausevcpu 1002 +@@ -677,6 +678,7 @@ struct vki_xen_domctl { + struct vki_xen_domctl_monitor_op_0000000b monitor_op_0000000b; + //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; + vki_uint8_t pad[128]; + } u; + }; + +From e72142e040a70b03427b016e842618a4e0aff8de Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:21:19 +0100 +Subject: [PATCH 24/75] xen-4.6: XENMEM_reserved_device_memory_map + +Add define for XENMEM_reserved_device_memory_map, introduced in 4.6 + +bz#390553 +--- + include/vki/vki-xen-memory.h | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/include/vki/vki-xen-memory.h b/include/vki/vki-xen-memory.h +index 4dc233f70..49565636b 100644 +--- a/include/vki/vki-xen-memory.h ++++ b/include/vki/vki-xen-memory.h +@@ -53,6 +53,7 @@ + #define VKI_XENMEM_claim_pages 24 + #define VKI_XENMEM_machphys_compat_mfn_list 25 + #define VKI_XENMEM_get_vnumainfo 26 ++#define VKI_XENMEM_reserved_device_memory_map 27 + + struct vki_xen_memory_map { + unsigned int nr_entries; + +From 7d104a9be6915e07be2d68fcb85b410edc0ece9e Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:21:20 +0100 +Subject: [PATCH 25/75] xen-4.6: XEN_SYSCTL_numainfo + +The XEN_SYSCTL_numainfo changed layout after xen-4.6. +Add new layout and handle runtime of xen-4.6. + +bz#390553 +--- + coregrind/m_syswrap/syswrap-xen.c | 17 ++++++++++++----- + include/vki/vki-xen-sysctl.h | 15 +++++++++++++++ + 2 files changed, 27 insertions(+), 5 deletions(-) + +diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c +index bf58c0726..30726c0be 100644 +--- a/coregrind/m_syswrap/syswrap-xen.c ++++ b/coregrind/m_syswrap/syswrap-xen.c +@@ -716,12 +716,12 @@ PRE(sysctl) { + PRE_XEN_SYSCTL_READ(numainfo_0000000b, node_to_memfree); + PRE_XEN_SYSCTL_READ(numainfo_0000000b, node_to_node_distance); + break; ++ case 0x0000000c: + default: +- VG_(dmsg)("WARNING: XEN_SYSCTL_numainfo for sysctl version " +- "%"PRIx32" not implemented yet\n", +- sysctl->interface_version); +- SET_STATUS_Failure(VKI_EINVAL); +- return; ++ PRE_XEN_SYSCTL_READ(numainfo_0000000c, num_nodes); ++ PRE_XEN_SYSCTL_READ(numainfo_0000000c, meminfo); ++ PRE_XEN_SYSCTL_READ(numainfo_0000000c, distance); ++ break; + } + break; + +@@ -1871,7 +1871,14 @@ POST(sysctl) + sizeof(uint32_t) * + (sysctl->u.numainfo_0000000b.max_node_index * sysctl->u.numainfo_0000000b.max_node_index)); + break; ++ case 0x0000000c: + default: ++ 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)); + break; + } + break; +diff --git a/include/vki/vki-xen-sysctl.h b/include/vki/vki-xen-sysctl.h +index 248a5e12f..65ad6d591 100644 +--- a/include/vki/vki-xen-sysctl.h ++++ b/include/vki/vki-xen-sysctl.h +@@ -128,6 +128,20 @@ struct vki_xen_sysctl_numainfo_0000000b { + VKI_XEN_GUEST_HANDLE_64(vki_uint64) node_to_memfree; + VKI_XEN_GUEST_HANDLE_64(vki_uint32) node_to_node_distance; + }; ++ ++struct vki_xen_xen_sysctl_meminfo_0000000c { ++ vki_uint64_t memsize; ++ vki_uint64_t memfree; ++}; ++typedef struct vki_xen_xen_sysctl_meminfo_0000000c vki_xen_xen_sysctl_meminfo_0000000c_t; ++DEFINE_VKI_XEN_GUEST_HANDLE(vki_xen_xen_sysctl_meminfo_0000000c_t); ++ ++struct vki_xen_sysctl_numainfo_0000000c { ++ vki_uint32_t num_nodes; ++ VKI_XEN_GUEST_HANDLE_64(vki_xen_xen_sysctl_meminfo_0000000c_t) meminfo; ++ VKI_XEN_GUEST_HANDLE_64(vki_uint32) distance; ++}; ++ + struct vki_xen_sysctl_physinfo_00000008 { + vki_uint32_t threads_per_core; + vki_uint32_t cores_per_socket; +@@ -178,6 +192,7 @@ struct vki_xen_sysctl { + struct vki_xen_sysctl_physinfo_0000000a physinfo_0000000a; + struct vki_xen_sysctl_topologyinfo topologyinfo; + struct vki_xen_sysctl_numainfo_0000000b numainfo_0000000b; ++ 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; + +From d7f5b54cffd3e1d860327cc9c7ace806bfd37ae2 Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:21:22 +0100 +Subject: [PATCH 26/75] xen-4.6: XEN_SYSCTL_cputopoinfo + +In xen-4.6 XEN_SYSCTL_topologyinfo was replaced by XEN_SYSCTL_cputopoinfo. +Both share the same number. Add code to catch both variants. + +bz#390553 +--- + coregrind/m_syswrap/syswrap-xen.c | 16 +++++++++++----- + include/vki/vki-xen-sysctl.h | 15 +++++++++++++++ + 2 files changed, 26 insertions(+), 5 deletions(-) + +diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c +index 30726c0be..69c3b230a 100644 +--- a/coregrind/m_syswrap/syswrap-xen.c ++++ b/coregrind/m_syswrap/syswrap-xen.c +@@ -682,6 +682,7 @@ PRE(sysctl) { + break; + + case VKI_XEN_SYSCTL_topologyinfo: ++// case VKI_XEN_SYSCTL_cputopoinfo: + switch (sysctl->interface_version) + { + case 0x00000007: +@@ -694,12 +695,11 @@ PRE(sysctl) { + PRE_XEN_SYSCTL_READ(topologyinfo, cpu_to_socket); + PRE_XEN_SYSCTL_READ(topologyinfo, cpu_to_node); + break; ++ case 0x0000000c: + default: +- VG_(dmsg)("WARNING: XEN_SYSCTL_cputopoinfo for sysctl version " +- "%"PRIx32" not implemented yet\n", +- sysctl->interface_version); +- SET_STATUS_Failure(VKI_EINVAL); +- return; ++ PRE_XEN_SYSCTL_READ(cputopoinfo_0000000c, num_cpus); ++ PRE_XEN_SYSCTL_READ(cputopoinfo_0000000c, cputopo); ++ break; + } + break; + +@@ -1831,6 +1831,7 @@ POST(sysctl) + break; + + case VKI_XEN_SYSCTL_topologyinfo: ++// case VKI_XEN_SYSCTL_cputopoinfo: + switch (sysctl->interface_version) + { + case 0x00000007: +@@ -1849,7 +1850,12 @@ POST(sysctl) + POST_MEM_WRITE((Addr)sysctl->u.topologyinfo.cpu_to_node.p, + sizeof(uint32_t) * sysctl->u.topologyinfo.max_cpu_index); + break; ++ case 0x0000000c: + default: ++ 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); + break; + } + break; +diff --git a/include/vki/vki-xen-sysctl.h b/include/vki/vki-xen-sysctl.h +index 65ad6d591..4f8a7d079 100644 +--- a/include/vki/vki-xen-sysctl.h ++++ b/include/vki/vki-xen-sysctl.h +@@ -35,6 +35,7 @@ + #define VKI_XEN_SYSCTL_page_offline_op 14 + #define VKI_XEN_SYSCTL_lockprof_op 15 + #define VKI_XEN_SYSCTL_topologyinfo 16 ++#define VKI_XEN_SYSCTL_cputopoinfo 16 /* Since xen-4.6 */ + #define VKI_XEN_SYSCTL_numainfo 17 + #define VKI_XEN_SYSCTL_cpupool_op 18 + #define VKI_XEN_SYSCTL_scheduler_op 19 +@@ -122,6 +123,19 @@ struct vki_xen_sysctl_topologyinfo { + VKI_XEN_GUEST_HANDLE_64(vki_uint32) cpu_to_node; + }; + ++struct vki_xen_sysctl_cputopo_0000000c { ++ vki_uint32_t core; ++ vki_uint32_t socket; ++ vki_uint32_t node; ++}; ++typedef struct vki_xen_sysctl_cputopo_0000000c vki_xen_sysctl_cputopo_0000000c_t; ++DEFINE_VKI_XEN_GUEST_HANDLE(vki_xen_sysctl_cputopo_0000000c_t); ++ ++struct vki_xen_sysctl_cputopoinfo_0000000c { ++ vki_uint32_t num_cpus; ++ VKI_XEN_GUEST_HANDLE_64(vki_xen_sysctl_cputopo_0000000c_t) cputopo; ++}; ++ + struct vki_xen_sysctl_numainfo_0000000b { + vki_uint32_t max_node_index; + VKI_XEN_GUEST_HANDLE_64(vki_uint64) node_to_memsize; +@@ -191,6 +205,7 @@ struct vki_xen_sysctl { + struct vki_xen_sysctl_physinfo_00000008 physinfo_00000008; + struct vki_xen_sysctl_physinfo_0000000a physinfo_0000000a; + struct vki_xen_sysctl_topologyinfo topologyinfo; ++ struct vki_xen_sysctl_cputopoinfo_0000000c cputopoinfo_0000000c; + struct vki_xen_sysctl_numainfo_0000000b numainfo_0000000b; + struct vki_xen_sysctl_numainfo_0000000c numainfo_0000000c; + struct vki_xen_sysctl_sched_id sched_id; + +From 9ba371d303a4fda7cb28a6a916124c21fdc1fa11 Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:21:23 +0100 +Subject: [PATCH 27/75] xen-4.6: support XEN_SYSCTL_pcitopoinfo + +bz#390553 +--- + coregrind/m_syswrap/syswrap-xen.c | 22 ++++++++++++++++++++++ + include/vki/vki-xen-physdev.h | 9 +++++++++ + include/vki/vki-xen-sysctl.h | 8 ++++++++ + 3 files changed, 39 insertions(+) + +diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c +index 69c3b230a..e79b0065a 100644 +--- a/coregrind/m_syswrap/syswrap-xen.c ++++ b/coregrind/m_syswrap/syswrap-xen.c +@@ -725,6 +725,17 @@ PRE(sysctl) { + } + break; + ++ case VKI_XEN_SYSCTL_pcitopoinfo: ++ switch (sysctl->interface_version) ++ { ++ case 0x0000000c: ++ default: ++ PRE_XEN_SYSCTL_READ(pcitopoinfo_0000000c, num_devs); ++ PRE_XEN_SYSCTL_READ(pcitopoinfo_0000000c, devs); ++ break; ++ } ++ break; ++ + default: + bad_subop(tid, layout, arrghs, status, flags, + "__HYPERVISOR_sysctl", sysctl->cmd); +@@ -1889,6 +1900,17 @@ POST(sysctl) + } + break; + ++ case VKI_XEN_SYSCTL_pcitopoinfo: ++ switch (sysctl->interface_version) ++ { ++ case 0x0000000c: ++ default: ++ 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); ++ break; ++ } ++ break; + /* No outputs */ + case VKI_XEN_SYSCTL_debug_keys: + break; +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; + }; + ++struct vki_physdev_pci_device { ++ /* IN */ ++ vki_uint16_t seg; ++ vki_uint8_t bus; ++ vki_uint8_t devfn; ++}; ++typedef struct vki_physdev_pci_device vki_physdev_pci_device_t; ++DEFINE_VKI_XEN_GUEST_HANDLE(vki_physdev_pci_device_t); ++ + #endif // __VKI_XEN_PHYSDEV_H + + /*--------------------------------------------------------------------*/ +diff --git a/include/vki/vki-xen-sysctl.h b/include/vki/vki-xen-sysctl.h +index 4f8a7d079..bceb14cfd 100644 +--- a/include/vki/vki-xen-sysctl.h ++++ b/include/vki/vki-xen-sysctl.h +@@ -41,6 +41,7 @@ + #define VKI_XEN_SYSCTL_scheduler_op 19 + #define VKI_XEN_SYSCTL_coverage_op 20 + #define VKI_XEN_SYSCTL_psr_cmt_op 21 ++#define VKI_XEN_SYSCTL_pcitopoinfo 22 + + struct vki_xen_sysctl_readconsole { + /* IN */ +@@ -136,6 +137,12 @@ struct vki_xen_sysctl_cputopoinfo_0000000c { + VKI_XEN_GUEST_HANDLE_64(vki_xen_sysctl_cputopo_0000000c_t) cputopo; + }; + ++struct vki_xen_sysctl_pcitopoinfo_0000000c { ++ vki_uint32_t num_devs; ++ VKI_XEN_GUEST_HANDLE_64(vki_physdev_pci_device_t) devs; ++ VKI_XEN_GUEST_HANDLE_64(vki_uint32) nodes; ++}; ++ + struct vki_xen_sysctl_numainfo_0000000b { + vki_uint32_t max_node_index; + VKI_XEN_GUEST_HANDLE_64(vki_uint64) node_to_memsize; +@@ -206,6 +213,7 @@ struct vki_xen_sysctl { + struct vki_xen_sysctl_physinfo_0000000a physinfo_0000000a; + struct vki_xen_sysctl_topologyinfo topologyinfo; + struct vki_xen_sysctl_cputopoinfo_0000000c cputopoinfo_0000000c; ++ struct vki_xen_sysctl_pcitopoinfo_0000000c pcitopoinfo_0000000c; + struct vki_xen_sysctl_numainfo_0000000b numainfo_0000000b; + struct vki_xen_sysctl_numainfo_0000000c numainfo_0000000c; + struct vki_xen_sysctl_sched_id sched_id; + +From 4f6a4c41c46ed66c8a1a68ab6b4aba65537d729e Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:21:24 +0100 +Subject: [PATCH 28/75] xen-4.6: psr_cat_op and tmem_op + +Add defines for XEN_SYSCTL_psr_cat_op and XEN_SYSCTL_tmem_op + +bz#390553 +--- + include/vki/vki-xen-sysctl.h | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/include/vki/vki-xen-sysctl.h b/include/vki/vki-xen-sysctl.h +index bceb14cfd..c22f285de 100644 +--- a/include/vki/vki-xen-sysctl.h ++++ b/include/vki/vki-xen-sysctl.h +@@ -42,6 +42,8 @@ + #define VKI_XEN_SYSCTL_coverage_op 20 + #define VKI_XEN_SYSCTL_psr_cmt_op 21 + #define VKI_XEN_SYSCTL_pcitopoinfo 22 ++#define VKI_XEN_SYSCTL_psr_cat_op 23 ++#define VKI_XEN_SYSCTL_tmem_op 24 + + struct vki_xen_sysctl_readconsole { + /* IN */ +@@ -214,6 +216,7 @@ struct vki_xen_sysctl { + struct vki_xen_sysctl_topologyinfo topologyinfo; + 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_0000000c numainfo_0000000c; + struct vki_xen_sysctl_sched_id sched_id; +@@ -233,6 +236,8 @@ struct vki_xen_sysctl { + //struct vki_xen_sysctl_scheduler_op scheduler_op; + //struct vki_xen_sysctl_coverage_op coverage_op; + //struct vki_xen_sysctl_psr_cmt_op psr_cmt_op; ++ //struct vki_xen_sysctl_psr_cat_op psr_cat_op; ++ //struct vki_xen_sysctl_tmem_op tmem_op; + + vki_uint8_t pad[128]; + } u; + +From 51d25fbc1ecfa6d615a33c0264c837281e5c1db8 Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:21:25 +0100 +Subject: [PATCH 29/75] xen-4.6: add xenpmu_op + +Add define for xenpmu_op, introduced in xen-4.6 + +bz#390553 +--- + coregrind/m_syswrap/syswrap-xen.c | 1 + + include/vki/vki-xen.h | 1 + + 2 files changed, 2 insertions(+) + +diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c +index e79b0065a..33ff117c1 100644 +--- a/coregrind/m_syswrap/syswrap-xen.c ++++ b/coregrind/m_syswrap/syswrap-xen.c +@@ -2384,6 +2384,7 @@ 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 + }; + + static void bad_before ( ThreadId tid, +diff --git a/include/vki/vki-xen.h b/include/vki/vki-xen.h +index 2d65bcc0e..f750a10ce 100644 +--- a/include/vki/vki-xen.h ++++ b/include/vki/vki-xen.h +@@ -69,6 +69,7 @@ + #define __VKI_XEN_kexec_op 37 + #define __VKI_XEN_tmem_op 38 + #define __VKI_XEN_xc_reserved_op 39 /* reserved for XenClient */ ++#define __VKI_XEN_xenpmu_op 40 + + #define __DEFINE_VKI_XEN_GUEST_HANDLE(name, type) \ + ___DEFINE_VKI_XEN_GUEST_HANDLE(name, type); \ + +From f1d31e3f36cea8bfb71568045a45a59e3be16d28 Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:21:26 +0100 +Subject: [PATCH 30/75] xen-4.7: update xen_arch_domainconfig layout + +New layout in xen-4.7, update createdomain. +--- + coregrind/m_syswrap/syswrap-xen.c | 13 +++++++++++++ + include/vki/vki-xen-domctl.h | 23 +++++++++++++++++++++++ + 2 files changed, 36 insertions(+) + +diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c +index 33ff117c1..c97c60d89 100644 +--- a/coregrind/m_syswrap/syswrap-xen.c ++++ b/coregrind/m_syswrap/syswrap-xen.c +@@ -821,6 +821,19 @@ PRE(domctl) + __PRE_XEN_DOMCTL_READ(createdomain_0000000b, createdomain_0000000b, config.clock_frequency); + #endif + break; + case 0x0000000c: + default: + PRE_XEN_DOMCTL_READ(createdomain_0000000c, ssidref); @@ -203,11 +1636,1236 @@ 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 VKI_XEN_DOMCTL_gethvmcontext: -@@ -780,30 +878,67 @@ PRE(domctl) +diff --git a/include/vki/vki-xen-domctl.h b/include/vki/vki-xen-domctl.h +index b88c56aba..6bb28b3cf 100644 +--- a/include/vki/vki-xen-domctl.h ++++ b/include/vki/vki-xen-domctl.h +@@ -157,6 +157,28 @@ struct vki_xen_domctl_createdomain_0000000b { + struct vki_xen_arch_domainconfig_0000000b config; + }; + ++/* The layout changed in 4.07, which shared domctl with 4.06 */ ++struct vki_xen_arch_domainconfig_0000000c { ++#if defined(__i386__) || defined(__x86_64__) ++ vki_uint32_t emulation_flags; ++#endif ++#if defined(__arm__) || defined(__aarch64__) ++ /* IN/OUT */ ++ vki_uint8_t gic_version; ++ /* IN */ ++ vki_uint32_t nr_spis; ++ vki_uint32_t clock_frequency; ++#endif ++}; ++ ++struct vki_xen_domctl_createdomain_0000000c { ++ /* IN parameters */ ++ vki_uint32_t ssidref; ++ vki_xen_domain_handle_t handle; ++ vki_uint32_t flags; ++ struct vki_xen_arch_domainconfig_0000000c config; ++}; ++ + struct vki_xen_domctl_getdomaininfo_00000007 { + /* OUT variables. */ + vki_xen_domid_t domain; +@@ -612,6 +634,7 @@ struct vki_xen_domctl { + union { + struct vki_xen_domctl_createdomain_0000000a createdomain_0000000a; + 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_getdomaininfo_00000007 getdomaininfo_00000007; + struct vki_xen_domctl_getdomaininfo_00000008 getdomaininfo_00000008; + +From ec5afe2ad610b41dc38a296ac460927d92868698 Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:21:27 +0100 +Subject: [PATCH 31/75] xen-4.7: XEN_VCPUAFFINITY_FORCE + +Add define for new flag XEN_VCPUAFFINITY_FORCE + +bz#390553 +--- + include/vki/vki-xen-domctl.h | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/include/vki/vki-xen-domctl.h b/include/vki/vki-xen-domctl.h +index 6bb28b3cf..f84b1afdc 100644 +--- a/include/vki/vki-xen-domctl.h ++++ b/include/vki/vki-xen-domctl.h +@@ -262,6 +262,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) ++#define VKI_XEN_VCPUAFFINITY_FORCE (1U<<2) + vki_uint32_t flags; /* IN */ + struct vki_xenctl_bitmap cpumap_hard; /* IN/OUT */ + struct vki_xenctl_bitmap cpumap_soft; /* IN/OUT */ + +From ac9fd78be2fb92546fb4aeb95dd9440bd0ad6c8a Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:21:28 +0100 +Subject: [PATCH 32/75] xen-4.7: SCHEDOP put/getvcpuinfo + +Add defines for XEN_DOMCTL_SCHEDOP_putvcpuinfo and XEN_DOMCTL_SCHEDOP_getvcpuinfo + +bz#390553 +--- + include/vki/vki-xen-domctl.h | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/include/vki/vki-xen-domctl.h b/include/vki/vki-xen-domctl.h +index f84b1afdc..ef6d8c780 100644 +--- a/include/vki/vki-xen-domctl.h ++++ b/include/vki/vki-xen-domctl.h +@@ -333,6 +333,8 @@ struct vki_xen_domctl_scheduler_op { + vki_uint32_t cmd; /* VKI_XEN_DOMCTL_SCHEDOP_* */ + #define VKI_XEN_DOMCTL_SCHEDOP_putinfo 0 + #define VKI_XEN_DOMCTL_SCHEDOP_getinfo 1 ++#define VKI_XEN_DOMCTL_SCHEDOP_putvcpuinfo 2 ++#define VKI_XEN_DOMCTL_SCHEDOP_getvcpuinfo 3 + union { + struct xen_domctl_sched_sedf { + vki_xen_uint64_aligned_t period; + +From a30771f1d9b5fb151f4651708d1d9a07c0d70b6a Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:21:29 +0100 +Subject: [PATCH 33/75] xen-4.7: soft_reset + +Add define for XEN_DOMCTL_soft_reset + +bz#390553 +--- + include/vki/vki-xen-domctl.h | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/include/vki/vki-xen-domctl.h b/include/vki/vki-xen-domctl.h +index ef6d8c780..5a974d020 100644 +--- a/include/vki/vki-xen-domctl.h ++++ b/include/vki/vki-xen-domctl.h +@@ -124,6 +124,7 @@ + #define VKI_XEN_DOMCTL_arm_configure_domain 76 + #define VKI_XEN_DOMCTL_monitor_op 77 /* new in 4.6 */ + #define VKI_XEN_DOMCTL_psr_cat_op 78 ++#define VKI_XEN_DOMCTL_soft_reset 79 + #define VKI_XEN_DOMCTL_gdbsx_guestmemio 1000 + #define VKI_XEN_DOMCTL_gdbsx_pausevcpu 1001 + #define VKI_XEN_DOMCTL_gdbsx_unpausevcpu 1002 + +From 8fd8ee9f79444b8925afcf94e08f51ffe4384abc Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:21:30 +0100 +Subject: [PATCH 34/75] xen-4.7: SCHEDOP_pin_override + +Add define for SCHEDOP_pin_override + +bz#390553 +--- + include/vki/vki-xen-schedop.h | 2 ++ + 1 file changed, 2 insertions(+) + +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 */ + +From 3d4735ff60689c45e99faba9ef5ebd7a50ce5dbe Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:21:31 +0100 +Subject: [PATCH 35/75] xen-4.7: support XEN_SYSCTL_get_cpu_featureset + +bz#390553 +--- + coregrind/m_syswrap/syswrap-xen.c | 24 ++++++++++++++++++++++++ + include/vki/vki-xen-sysctl.h | 8 ++++++++ + 2 files changed, 32 insertions(+) + +diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c +index c97c60d89..5a85b4e4b 100644 +--- a/coregrind/m_syswrap/syswrap-xen.c ++++ b/coregrind/m_syswrap/syswrap-xen.c +@@ -736,6 +736,17 @@ PRE(sysctl) { + } + break; + ++ case VKI_XEN_SYSCTL_get_cpu_featureset: ++ switch (sysctl->interface_version) ++ { ++ case 0x0000000c: ++ default: ++ PRE_XEN_SYSCTL_READ(cpu_featureset_0000000d, index); ++ PRE_XEN_SYSCTL_READ(cpu_featureset_0000000d, nr_features); ++ break; ++ } ++ break; ++ + default: + bad_subop(tid, layout, arrghs, status, flags, + "__HYPERVISOR_sysctl", sysctl->cmd); +@@ -1924,6 +1935,19 @@ POST(sysctl) + break; + } + break; ++ ++ case VKI_XEN_SYSCTL_get_cpu_featureset: ++ switch (sysctl->interface_version) ++ { ++ case 0x0000000c: ++ default: ++ 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); ++ break; ++ } ++ break; ++ + /* No outputs */ + case VKI_XEN_SYSCTL_debug_keys: + break; +diff --git a/include/vki/vki-xen-sysctl.h b/include/vki/vki-xen-sysctl.h +index c22f285de..42567fad9 100644 +--- a/include/vki/vki-xen-sysctl.h ++++ b/include/vki/vki-xen-sysctl.h +@@ -44,6 +44,7 @@ + #define VKI_XEN_SYSCTL_pcitopoinfo 22 + #define VKI_XEN_SYSCTL_psr_cat_op 23 + #define VKI_XEN_SYSCTL_tmem_op 24 ++#define VKI_XEN_SYSCTL_get_cpu_featureset 26 + + struct vki_xen_sysctl_readconsole { + /* IN */ +@@ -205,6 +206,12 @@ struct vki_xen_sysctl_sched_id { + vki_uint32_t sched_id; + }; + ++struct vki_xen_sysctl_cpu_featureset_0000000d { ++ vki_uint32_t index; ++ vki_uint32_t nr_features; ++ VKI_XEN_GUEST_HANDLE_64(vki_uint32) features; ++}; ++ + struct vki_xen_sysctl { + vki_uint32_t cmd; + vki_uint32_t interface_version; /* XEN_SYSCTL_INTERFACE_VERSION */ +@@ -238,6 +245,7 @@ struct vki_xen_sysctl { + //struct vki_xen_sysctl_psr_cmt_op psr_cmt_op; + //struct vki_xen_sysctl_psr_cat_op psr_cat_op; + //struct vki_xen_sysctl_tmem_op tmem_op; ++ struct vki_xen_sysctl_cpu_featureset_0000000d cpu_featureset_0000000d; + + vki_uint8_t pad[128]; + } u; + +From 753be5c53a52f3e0bb4a4f6e92c627680c68ec09 Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:21:32 +0100 +Subject: [PATCH 36/75] xen-4.7: sysctl for get_cpu_levelling_caps and + livepatch_op + +Add defines for XEN_SYSCTL_get_cpu_levelling_caps and +XEN_SYSCTL_livepatch_op + +bz#390553 +--- + include/vki/vki-xen-sysctl.h | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/include/vki/vki-xen-sysctl.h b/include/vki/vki-xen-sysctl.h +index 42567fad9..68ea0e5bd 100644 +--- a/include/vki/vki-xen-sysctl.h ++++ b/include/vki/vki-xen-sysctl.h +@@ -44,7 +44,9 @@ + #define VKI_XEN_SYSCTL_pcitopoinfo 22 + #define VKI_XEN_SYSCTL_psr_cat_op 23 + #define VKI_XEN_SYSCTL_tmem_op 24 ++#define VKI_XEN_SYSCTL_get_cpu_levelling_caps 25 + #define VKI_XEN_SYSCTL_get_cpu_featureset 26 ++#define VKI_XEN_SYSCTL_livepatch_op 27 + + struct vki_xen_sysctl_readconsole { + /* IN */ +@@ -245,7 +247,9 @@ struct vki_xen_sysctl { + //struct vki_xen_sysctl_psr_cmt_op psr_cmt_op; + //struct vki_xen_sysctl_psr_cat_op psr_cat_op; + //struct vki_xen_sysctl_tmem_op tmem_op; ++ //struct vki_xen_sysctl_cpu_levelling_caps cpu_levelling_caps; + struct vki_xen_sysctl_cpu_featureset_0000000d cpu_featureset_0000000d; ++ //struct vki_xen_sysctl_livepatch_op livepatch; + + vki_uint8_t pad[128]; + } u; + +From 64997751b854938d3de958be8b3b3251cca44c93 Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:21:33 +0100 +Subject: [PATCH 37/75] xen-4.7: XENVER_build_id + +Add code to handle XENVER_build_id, added in xen-4.7 + +bz#390553 +--- + coregrind/m_syswrap/syswrap-xen.c | 4 ++++ + include/vki/vki-xen-version.h | 11 +++++++++++ + 2 files changed, 15 insertions(+) + +diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c +index 5a85b4e4b..78d8d181b 100644 +--- a/coregrind/m_syswrap/syswrap-xen.c ++++ b/coregrind/m_syswrap/syswrap-xen.c +@@ -532,6 +532,7 @@ PRE(xen_version) + case VKI_XENVER_pagesize: + case VKI_XENVER_guest_handle: + case VKI_XENVER_commandline: ++ case VKI_XENVER_build_id: + /* No inputs */ + break; + +@@ -1739,6 +1740,9 @@ POST(xen_version) + case VKI_XENVER_commandline: + POST_MEM_WRITE((Addr)ARG2, sizeof(vki_xen_commandline_t)); + break; ++ case VKI_XENVER_build_id: ++ POST_MEM_WRITE((Addr)ARG2, sizeof(struct vki_xen_build_id)); ++ break; + } + } + +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 + #define VKI_XENVER_commandline 9 ++#define VKI_XENVER_build_id 10 + + typedef char vki_xen_extraversion_t[16]; + +@@ -63,6 +64,16 @@ struct vki_xen_feature_info { + + typedef char vki_xen_commandline_t[1024]; + ++struct vki_xen_build_id { ++ unsigned int len; /* IN: size of buf[]. */ ++#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L ++ unsigned char buf[]; ++#elif defined(__GNUC__) ++ unsigned char buf[1]; /* OUT: Variable length buffer with build_id. */ ++#endif ++ ++}; ++ + #endif // __VKI_XEN_VERSION_H + + /*--------------------------------------------------------------------*/ + +From c3f05104173bb5ec6e6c65703a7e50667ea26cc1 Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:21:34 +0100 +Subject: [PATCH 38/75] xen-4.7: sysctl value + +Add 0xd as sysctl value of xen-4.7 + +bz#390553 +--- + coregrind/m_syswrap/syswrap-xen.c | 2 ++ + include/vki/vki-xen-sysctl.h | 1 + + 2 files changed, 3 insertions(+) + +diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c +index 78d8d181b..b4ac3c6d1 100644 +--- a/coregrind/m_syswrap/syswrap-xen.c ++++ b/coregrind/m_syswrap/syswrap-xen.c +@@ -586,6 +586,7 @@ PRE(sysctl) { + case 0x0000000a: + case 0x0000000b: + case 0x0000000c: ++ case 0x0000000d: + break; + default: + bad_intf_version(tid, layout, arrghs, status, flags, +@@ -1773,6 +1774,7 @@ POST(sysctl) + case 0x0000000a: + case 0x0000000b: + case 0x0000000c: ++ case 0x0000000d: + break; + default: + return; +diff --git a/include/vki/vki-xen-sysctl.h b/include/vki/vki-xen-sysctl.h +index 68ea0e5bd..c4f8ddf27 100644 +--- a/include/vki/vki-xen-sysctl.h ++++ b/include/vki/vki-xen-sysctl.h +@@ -10,6 +10,7 @@ + * - 0x0000000a: Xen 4.3 & 4.4 + * - 0x0000000b: Xen 4.5 + * - 0x0000000c: Xen 4.6 ++ * - 0x0000000d: Xen 4.7 + * + * When adding a new subop be sure to include the variants used by all + * of the above, both here and in syswrap-xen.c + +From 473689eb5a2b7a4686a910c51bcb8ecec59c831b Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:29:27 +0100 +Subject: [PATCH 39/75] xen-4.8: IOCTL_GNTDEV_GRANT_COPY + +bz#390553 +--- + coregrind/m_syswrap/syswrap-linux.c | 15 +++++++++++++++ + include/vki/vki-linux.h | 21 +++++++++++++++++++++ + 2 files changed, 36 insertions(+) + +diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c +index 1b6064138..3c475b1af 100644 +--- a/coregrind/m_syswrap/syswrap-linux.c ++++ b/coregrind/m_syswrap/syswrap-linux.c +@@ -8325,6 +8325,15 @@ PRE(sys_ioctl) + (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 */ +@@ -10832,6 +10841,12 @@ POST(sys_ioctl) + 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/include/vki/vki-linux.h b/include/vki/vki-linux.h +index 6b079ebaf..76a37435a 100644 +--- a/include/vki/vki-linux.h ++++ b/include/vki/vki-linux.h +@@ -3493,6 +3493,27 @@ struct vki_xen_ioctl_gntalloc_set_unmap_notify { + 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 + //---------------------------------------------------------------------- + +From 261b1461519b107416fc9ddbde83855aec5d2028 Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:29:28 +0100 +Subject: [PATCH 40/75] xen-4.8: xen_domctl_monitor_op + +Layout of xen_domctl_monitor_op changed in xen-4.8. +Copy and adjust the existing monitor_op_0000000b handler. + +bz#390553 +--- + coregrind/m_syswrap/syswrap-xen.c | 19 +++++++++++++ + include/vki/vki-xen-domctl.h | 45 +++++++++++++++++++++++++++++++ + 2 files changed, 64 insertions(+) + +diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c +index b4ac3c6d1..a2881c999 100644 +--- a/coregrind/m_syswrap/syswrap-xen.c ++++ b/coregrind/m_syswrap/syswrap-xen.c +@@ -2305,6 +2305,25 @@ POST(domctl){ + } + } + ++ break; ++ case 0x000000c: ++ 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; + } + break; +diff --git a/include/vki/vki-xen-domctl.h b/include/vki/vki-xen-domctl.h +index 5a974d020..b01b0c6fe 100644 +--- a/include/vki/vki-xen-domctl.h ++++ b/include/vki/vki-xen-domctl.h +@@ -570,6 +570,9 @@ 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 ++#define VKI_XEN_DOMCTL_MONITOR_EVENT_DEBUG_EXCEPTION 5 ++#define VKI_XEN_DOMCTL_MONITOR_EVENT_CPUID 6 ++#define VKI_XEN_DOMCTL_MONITOR_EVENT_PRIVILEGED_CALL 7 + + struct vki_xen_domctl_monitor_op_0000000b { + vki_uint32_t op; /* vki_xen_DOMCTL_MONITOR_OP_* */ +@@ -608,6 +611,47 @@ 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; ++}; ++ + + struct vki_xen_domctl_monitor_op { + vki_uint32_t op; +@@ -703,6 +747,7 @@ 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_vnuma vnuma; + //struct vki_xen_domctl_psr_cmt_op psr_cmt_op; + //struct vki_xen_domctl_psr_cat_op psr_cat_op; + +From 8d9217f170d9c80f71ca2af366def3a563e3f6f5 Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:29:29 +0100 +Subject: [PATCH 41/75] xen-4.8: sysctl value + +Add 0xe as sysctl value of xen-4.8 + +bz#390553 +--- + coregrind/m_syswrap/syswrap-xen.c | 2 ++ + include/vki/vki-xen-sysctl.h | 1 + + 2 files changed, 3 insertions(+) + +diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c +index a2881c999..a204a8db8 100644 +--- a/coregrind/m_syswrap/syswrap-xen.c ++++ b/coregrind/m_syswrap/syswrap-xen.c +@@ -587,6 +587,7 @@ PRE(sysctl) { + case 0x0000000b: + case 0x0000000c: + case 0x0000000d: ++ case 0x0000000e: + break; + default: + bad_intf_version(tid, layout, arrghs, status, flags, +@@ -1775,6 +1776,7 @@ POST(sysctl) + case 0x0000000b: + case 0x0000000c: + case 0x0000000d: ++ case 0x0000000e: + break; + default: + return; +diff --git a/include/vki/vki-xen-sysctl.h b/include/vki/vki-xen-sysctl.h +index c4f8ddf27..b9beb2c19 100644 +--- a/include/vki/vki-xen-sysctl.h ++++ b/include/vki/vki-xen-sysctl.h +@@ -11,6 +11,7 @@ + * - 0x0000000b: Xen 4.5 + * - 0x0000000c: Xen 4.6 + * - 0x0000000d: Xen 4.7 ++ * - 0x0000000e: Xen 4.8 + * + * When adding a new subop be sure to include the variants used by all + * of the above, both here and in syswrap-xen.c + +From 30d8a6775914bb1852deb7c138184a7d5a5f39ce Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:29:30 +0100 +Subject: [PATCH 42/75] xen-4.8: fix domclt version in comment + +Version 0xc was introduced in xen-4.8, xen-4.7 has the same version as xen-4.6. + +bz#390553 +--- + include/vki/vki-xen-domctl.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/include/vki/vki-xen-domctl.h b/include/vki/vki-xen-domctl.h +index b01b0c6fe..1bdf3ad07 100644 +--- a/include/vki/vki-xen-domctl.h ++++ b/include/vki/vki-xen-domctl.h +@@ -37,7 +37,7 @@ + * - 0x00000009: Xen 4.3 & 4.4 + * - 0x0000000a: Xen 4.5 + * - 0x0000000b: Xen 4.6 +- * - 0x0000000c: Xen 4.7 ++ * - 0x0000000c: Xen 4.8 + * + * When adding a new subop be sure to include the variants used by all + * of the above, both here and in syswrap-xen.c + +From 616f2c03fd0d900e96ae7df13bbd63a2b4190a5b Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:29:31 +0100 +Subject: [PATCH 43/75] xen-4.8: domctl +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Add 0xc as domctl value of xen-4.8 + +Fixes commit: d73f2c748 ("Implement additional Xen hypercalls Fixes BZ#373086 Patch by: Mihai DONÈšU ") + +bz#390553 +--- + coregrind/m_syswrap/syswrap-xen.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c +index a204a8db8..8126203fb 100644 +--- a/coregrind/m_syswrap/syswrap-xen.c ++++ b/coregrind/m_syswrap/syswrap-xen.c +@@ -1973,6 +1973,7 @@ POST(domctl){ + case 0x00000009: + case 0x0000000a: + case 0x0000000b: ++ case 0x0000000c: + break; + default: + return; + +From c43f460fe06162bbfe34431ea3e03c083782e737 Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:29:33 +0100 +Subject: [PATCH 44/75] xen-4.9: domctl value + +Add 0xd as domctl value of xen-4.9 + +bz#390553 +--- + coregrind/m_syswrap/syswrap-xen.c | 2 ++ + include/vki/vki-xen-domctl.h | 1 + + 2 files changed, 3 insertions(+) + +diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c +index 8126203fb..847dcde1d 100644 +--- a/coregrind/m_syswrap/syswrap-xen.c ++++ b/coregrind/m_syswrap/syswrap-xen.c +@@ -786,6 +786,7 @@ PRE(domctl) + case 0x0000000a: + case 0x0000000b: + case 0x0000000c: ++ case 0x0000000d: + break; + default: + bad_intf_version(tid, layout, arrghs, status, flags, +@@ -1974,6 +1975,7 @@ POST(domctl){ + case 0x0000000a: + case 0x0000000b: + case 0x0000000c: ++ case 0x0000000d: + break; + default: + return; +diff --git a/include/vki/vki-xen-domctl.h b/include/vki/vki-xen-domctl.h +index 1bdf3ad07..fc6c31979 100644 +--- a/include/vki/vki-xen-domctl.h ++++ b/include/vki/vki-xen-domctl.h +@@ -38,6 +38,7 @@ + * - 0x0000000a: Xen 4.5 + * - 0x0000000b: Xen 4.6 + * - 0x0000000c: Xen 4.8 ++ * - 0x0000000d: Xen 4.9 + * + * When adding a new subop be sure to include the variants used by all + * of the above, both here and in syswrap-xen.c + +From 0be00fe82647dd44a4f8364982a928adbd221958 Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:29:34 +0100 +Subject: [PATCH 45/75] xen-4.9: add NULL scheduler + +Add define for XEN_SCHEDULER_NULL + +bz#390553 +--- + include/vki/vki-xen-domctl.h | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/include/vki/vki-xen-domctl.h b/include/vki/vki-xen-domctl.h +index fc6c31979..88a20ce1c 100644 +--- a/include/vki/vki-xen-domctl.h ++++ b/include/vki/vki-xen-domctl.h +@@ -332,6 +332,7 @@ struct vki_xen_domctl_scheduler_op { + #define VKI_XEN_SCHEDULER_CREDIT2 6 + #define VKI_XEN_SCHEDULER_ARINC653 7 + #define VKI_XEN_SCHEDULER_RTDS 8 ++#define VKI_XEN_SCHEDULER_NULL 9 + vki_uint32_t cmd; /* VKI_XEN_DOMCTL_SCHEDOP_* */ + #define VKI_XEN_DOMCTL_SCHEDOP_putinfo 0 + #define VKI_XEN_DOMCTL_SCHEDOP_getinfo 1 + +From 25445f787825219479e17473d21756ca7530f2fb Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:29:35 +0100 +Subject: [PATCH 46/75] xen-4.9: add monitor event INTERRUPT and DESC_ACCESS + +Add defines for XEN_DOMCTL_MONITOR_EVENT_INTERRUPT and +XEN_DOMCTL_MONITOR_EVENT_DESC_ACCESS + +bz#390553 +--- + include/vki/vki-xen-domctl.h | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/include/vki/vki-xen-domctl.h b/include/vki/vki-xen-domctl.h +index 88a20ce1c..cd4f77bc0 100644 +--- a/include/vki/vki-xen-domctl.h ++++ b/include/vki/vki-xen-domctl.h +@@ -575,6 +575,8 @@ struct vki_xen_domctl_vcpu_msrs { + #define VKI_XEN_DOMCTL_MONITOR_EVENT_DEBUG_EXCEPTION 5 + #define VKI_XEN_DOMCTL_MONITOR_EVENT_CPUID 6 + #define VKI_XEN_DOMCTL_MONITOR_EVENT_PRIVILEGED_CALL 7 ++#define VKI_XEN_DOMCTL_MONITOR_EVENT_INTERRUPT 8 ++#define VKI_XEN_DOMCTL_MONITOR_EVENT_DESC_ACCESS 9 + + struct vki_xen_domctl_monitor_op_0000000b { + vki_uint32_t op; /* vki_xen_DOMCTL_MONITOR_OP_* */ + +From cd69848be6f4eed00d680471f18f7bf1d6984f6c Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:29:36 +0100 +Subject: [PATCH 47/75] xen-4.9: sysctl value + +Add 0xf as sysctl value of xen-4.9 + +bz#390553 +--- + coregrind/m_syswrap/syswrap-xen.c | 2 ++ + include/vki/vki-xen-sysctl.h | 1 + + 2 files changed, 3 insertions(+) + +diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c +index 847dcde1d..7829308d8 100644 +--- a/coregrind/m_syswrap/syswrap-xen.c ++++ b/coregrind/m_syswrap/syswrap-xen.c +@@ -588,6 +588,7 @@ PRE(sysctl) { + case 0x0000000c: + case 0x0000000d: + case 0x0000000e: ++ case 0x0000000f: + break; + default: + bad_intf_version(tid, layout, arrghs, status, flags, +@@ -1778,6 +1779,7 @@ POST(sysctl) + case 0x0000000c: + case 0x0000000d: + case 0x0000000e: ++ case 0x0000000f: + break; + default: + return; +diff --git a/include/vki/vki-xen-sysctl.h b/include/vki/vki-xen-sysctl.h +index b9beb2c19..f00cb2295 100644 +--- a/include/vki/vki-xen-sysctl.h ++++ b/include/vki/vki-xen-sysctl.h +@@ -12,6 +12,7 @@ + * - 0x0000000c: Xen 4.6 + * - 0x0000000d: Xen 4.7 + * - 0x0000000e: Xen 4.8 ++ * - 0x0000000f: Xen 4.9 + * + * When adding a new subop be sure to include the variants used by all + * of the above, both here and in syswrap-xen.c + +From 82bdc86f686473b6e953679387ac5aa429541fcb Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:29:37 +0100 +Subject: [PATCH 48/75] xen-4.9: coverage_op replaced by gcov_op + +In xen-4.9 xen_sysctl_coverage_op was replaced by xen_sysctl_gcov_op. +The number remains the same. + +bz#390553 +--- + include/vki/vki-xen-sysctl.h | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/include/vki/vki-xen-sysctl.h b/include/vki/vki-xen-sysctl.h +index f00cb2295..214a652b8 100644 +--- a/include/vki/vki-xen-sysctl.h ++++ b/include/vki/vki-xen-sysctl.h +@@ -43,6 +43,7 @@ + #define VKI_XEN_SYSCTL_cpupool_op 18 + #define VKI_XEN_SYSCTL_scheduler_op 19 + #define VKI_XEN_SYSCTL_coverage_op 20 ++#define VKI_XEN_SYSCTL_gcov_op 20 /* Since xen-4.9 */ + #define VKI_XEN_SYSCTL_psr_cmt_op 21 + #define VKI_XEN_SYSCTL_pcitopoinfo 22 + #define VKI_XEN_SYSCTL_psr_cat_op 23 +@@ -247,6 +248,7 @@ 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; ++ //struct vki_xen_sysctl_gcov_op gcov_op; + //struct vki_xen_sysctl_psr_cmt_op psr_cmt_op; + //struct vki_xen_sysctl_psr_cat_op psr_cat_op; + //struct vki_xen_sysctl_tmem_op tmem_op; + +From 4e87c221e78dead32d672a06d8d21ab3d9ea4b00 Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:29:38 +0100 +Subject: [PATCH 49/75] xen-4.9: add dm_op + +Handle dm_op hypercall + +bz#390553 +--- + coregrind/m_syswrap/syswrap-xen.c | 19 +++++++++++++++++++ + include/vki/vki-xen.h | 1 + + 2 files changed, 20 insertions(+) + +diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c +index 7829308d8..be0bcdddf 100644 +--- a/coregrind/m_syswrap/syswrap-xen.c ++++ b/coregrind/m_syswrap/syswrap-xen.c +@@ -1566,6 +1566,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 ( %lu, %#lx, %lu )", ARG1, ARG2, ARG3); ++ ++ PRE_MEM_READ("__HYPERVISOR_dm_op ubuf", (Addr)args, sizeof(*args) * num); ++} ++ + POST(memory_op) + { + switch (ARG1) { +@@ -2392,6 +2402,14 @@ POST(tmem_op) + } + } + ++POST(dm_op) ++{ ++ unsigned int domid = ARG1, num = ARG2; ++ struct vki_xen_privcmd_dm_op_buf *args = (void *)(ARG3); ++ ++ POST_MEM_WRITE((Addr) args, sizeof(*args) * num); ++} ++ + typedef + struct { + SyscallTableEntry entry; +@@ -2454,6 +2472,7 @@ static XenHypercallTableEntry hypercall_table[] = { + // __VKI_XEN_kexec_op // 37 + HYPXY(__VKI_XEN_tmem_op, tmem_op, 1), // 38 + // __VKI_XEN_xenpmu_op // 40 ++ HYPXY(__VKI_XEN_dm_op, dm_op, 3), // 41 + }; + + static void bad_before ( ThreadId tid, +diff --git a/include/vki/vki-xen.h b/include/vki/vki-xen.h +index f750a10ce..ac8b21400 100644 +--- a/include/vki/vki-xen.h ++++ b/include/vki/vki-xen.h +@@ -70,6 +70,7 @@ + #define __VKI_XEN_tmem_op 38 + #define __VKI_XEN_xc_reserved_op 39 /* reserved for XenClient */ + #define __VKI_XEN_xenpmu_op 40 ++#define __VKI_XEN_dm_op 41 + + #define __DEFINE_VKI_XEN_GUEST_HANDLE(name, type) \ + ___DEFINE_VKI_XEN_GUEST_HANDLE(name, type); \ + +From 262998f32498effb079cb09edfb5a2c9d7a33417 Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:29:39 +0100 +Subject: [PATCH 50/75] xen-4.9: add IOCTL_PRIVCMD_DM_OP + +Handle IOCTL_PRIVCMD_DM_OP, add define for IOCTL_PRIVCMD_RESTRICT + +bz#390553 +--- + coregrind/m_syswrap/syswrap-linux.c | 17 +++++++++++++++++ + include/vki/vki-linux.h | 15 +++++++++++++++ + 2 files changed, 32 insertions(+) + +diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c +index 3c475b1af..c8f72de74 100644 +--- a/coregrind/m_syswrap/syswrap-linux.c ++++ b/coregrind/m_syswrap/syswrap-linux.c +@@ -8219,6 +8219,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 = +@@ -10800,6 +10811,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: +diff --git a/include/vki/vki-linux.h b/include/vki/vki-linux.h +index 76a37435a..0a0b5c2c1 100644 +--- a/include/vki/vki-linux.h ++++ b/include/vki/vki-linux.h +@@ -3384,12 +3384,27 @@ struct vki_xen_privcmd_mmapbatch_v2 { + int __user *err; /* array of error codes */ + }; + ++struct vki_xen_privcmd_dm_op_buf { ++ void __user *uptr; ++ __vki_kernel_size_t size; ++}; ++ ++struct vki_xen_privcmd_dm_op { ++ __vki_u16 dom; ++ __vki_u16 num; ++ const struct vki_xen_privcmd_dm_op_buf __user *ubufs; ++}; ++ ++ + #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)) + + #define VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH _VKI_IOC(_VKI_IOC_NONE, 'P', 3, sizeof(struct vki_xen_privcmd_mmapbatch)) + #define VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH_V2 _VKI_IOC(_VKI_IOC_NONE, 'P', 4, sizeof(struct vki_xen_privcmd_mmapbatch_v2)) + ++#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)) ++ + //---------------------------------------------------------------------- + // Xen evtchn IOCTL + //---------------------------------------------------------------------- + +From b51d38220ffa99e6bb95b6c77036be7c8d1f68ac Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:29:40 +0100 +Subject: [PATCH 51/75] xen-4.10: add domctl value + +Add 0xe as domctl value of xen-4.10 + +bz#390553 +--- + coregrind/m_syswrap/syswrap-xen.c | 2 ++ + include/vki/vki-xen-domctl.h | 1 + + 2 files changed, 3 insertions(+) + +diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c +index be0bcdddf..d3dfeb272 100644 +--- a/coregrind/m_syswrap/syswrap-xen.c ++++ b/coregrind/m_syswrap/syswrap-xen.c +@@ -788,6 +788,7 @@ PRE(domctl) + case 0x0000000b: + case 0x0000000c: + case 0x0000000d: ++ case 0x0000000e: + break; + default: + bad_intf_version(tid, layout, arrghs, status, flags, +@@ -1988,6 +1989,7 @@ POST(domctl){ + case 0x0000000b: + case 0x0000000c: + case 0x0000000d: ++ case 0x0000000e: + break; + default: + return; +diff --git a/include/vki/vki-xen-domctl.h b/include/vki/vki-xen-domctl.h +index cd4f77bc0..d5c59feb0 100644 +--- a/include/vki/vki-xen-domctl.h ++++ b/include/vki/vki-xen-domctl.h +@@ -39,6 +39,7 @@ + * - 0x0000000b: Xen 4.6 + * - 0x0000000c: Xen 4.8 + * - 0x0000000d: Xen 4.9 ++ * - 0x0000000e: Xen 4.10 + * + * When adding a new subop be sure to include the variants used by all + * of the above, both here and in syswrap-xen.c + +From 79a9c5ac046c6f3e63e13979c8e2c9348687562b Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:29:41 +0100 +Subject: [PATCH 52/75] xen-4.10: xen_domctl_assign_device + +The flags member moved in xen_domctl_assign_device. Copy the existing +code and handle xen-4.10. + +bz#390553 +--- + coregrind/m_syswrap/syswrap-xen.c | 66 +++++++++++++++++++++++++++++++ + include/vki/vki-xen-domctl.h | 15 +++++++ + 2 files changed, 81 insertions(+) + +diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c +index d3dfeb272..7ada2cba5 100644 +--- a/coregrind/m_syswrap/syswrap-xen.c ++++ b/coregrind/m_syswrap/syswrap-xen.c +@@ -914,6 +914,8 @@ PRE(domctl) + __PRE_XEN_DOMCTL_READ(test_assign_device, assign_device_00000007, machine_sbdf); + break; + case 0x0000000b: ++ case 0x0000000c: ++ case 0x0000000d: + __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) { +@@ -933,6 +935,26 @@ PRE(domctl) + break; + } + break; ++ case 0x0000000e: ++ __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) { ++ case VKI_XEN_DOMCTL_DEV_PCI: ++ __PRE_XEN_DOMCTL_READ(test_assign_device, assign_device_0000000e, u.pci); ++ break; ++ case VKI_XEN_DOMCTL_DEV_DT: ++ __PRE_XEN_DOMCTL_READ(test_assign_device, assign_device_0000000e, u.dt); ++ PRE_MEM_READ("XEN_DOMTCL_test_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_test_assign_device dev", ++ domctl->u.assign_device_0000000e.dev); ++ break; ++ } ++ break; + } + break; + case VKI_XEN_DOMCTL_assign_device: +@@ -944,6 +966,8 @@ PRE(domctl) + __PRE_XEN_DOMCTL_READ(assign_device, assign_device_00000007, machine_sbdf); + break; + case 0x0000000b: ++ case 0x0000000c: ++ case 0x0000000d: + __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) { +@@ -963,6 +987,26 @@ PRE(domctl) + break; + } + break; ++ case 0x0000000e: ++ __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) { ++ case VKI_XEN_DOMCTL_DEV_PCI: ++ __PRE_XEN_DOMCTL_READ(assign_device, assign_device_0000000e, u.pci); ++ break; ++ 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); ++ break; ++ } ++ break; + } + break; + case VKI_XEN_DOMCTL_deassign_device: +@@ -974,6 +1018,8 @@ PRE(domctl) + __PRE_XEN_DOMCTL_READ(deassign_device, assign_device_00000007, machine_sbdf); + break; + case 0x0000000b: ++ case 0x0000000c: ++ case 0x0000000d: + __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) { +@@ -993,6 +1039,26 @@ PRE(domctl) + break; + } + break; ++ case 0x0000000e: ++ __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) { ++ case VKI_XEN_DOMCTL_DEV_PCI: ++ __PRE_XEN_DOMCTL_READ(deassign_device, assign_device_0000000e, u.pci); ++ break; ++ 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); ++ break; ++ } ++ break; + } + break; + +diff --git a/include/vki/vki-xen-domctl.h b/include/vki/vki-xen-domctl.h +index d5c59feb0..c02357dd7 100644 +--- a/include/vki/vki-xen-domctl.h ++++ b/include/vki/vki-xen-domctl.h +@@ -522,6 +522,20 @@ struct vki_xen_domctl_assign_device_0000000b { + vki_uint32_t flag; /* flag of assigned device */ + }; + ++struct vki_xen_domctl_assign_device_0000000e { ++ vki_uint32_t dev; /* XEN_DOMCTL_DEV_* */ ++ vki_uint32_t flags; ++ union { ++ struct { ++ vki_uint32_t machine_sbdf; /* machine PCI ID of assigned device */ ++ } pci; ++ struct { ++ vki_uint32_t size; /* Length of the path */ ++ VKI_XEN_GUEST_HANDLE_64(vki_uint8) path; /* path to the device tree node */ ++ } dt; ++ } u; ++}; ++ + struct vki_xen_domctl_debug_op { + vki_uint32_t op; /* IN */ + vki_uint32_t vcpu; /* IN */ +@@ -725,6 +739,7 @@ struct vki_xen_domctl { + //struct vki_xen_domctl_get_device_group get_device_group; + struct vki_xen_domctl_assign_device_00000007 assign_device_00000007; + struct vki_xen_domctl_assign_device_0000000b assign_device_0000000b; ++ struct vki_xen_domctl_assign_device_0000000e assign_device_0000000e; + //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; + +From 54c7be433c080a7534340431bc84915b6968cd0c Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:29:42 +0100 +Subject: [PATCH 53/75] xen-4.10: rename hvmcontext_partial + +The layout of xen_domctl_hvmcontext_partial will change in xen-4.10. +Rename existing copy in preparation of following changes. + +bz#390553 +--- + coregrind/m_syswrap/syswrap-xen.c | 82 +++++++++++++++++++------------ + include/vki/vki-xen-domctl.h | 8 +-- + 2 files changed, 55 insertions(+), 35 deletions(-) + +diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c +index 7ada2cba5..6f6d040a9 100644 +--- a/coregrind/m_syswrap/syswrap-xen.c ++++ b/coregrind/m_syswrap/syswrap-xen.c +@@ -872,30 +872,40 @@ PRE(domctl) break; case VKI_XEN_DOMCTL_gethvmcontext_partial: @@ -266,476 +2924,12 @@ Index: valgrind-3.13.0/coregrind/m_syswrap/syswrap-xen.c + break; + } + break; -+ case 0x0000000e: -+ default: -+ __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); -+ __PRE_XEN_DOMCTL_READ(gethvmcontext_partial, hvmcontext_partial_0000000e, buffer); -+ -+ 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)); -+ 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)); -+ break; -+ default: -+ bad_subop(tid, layout, arrghs, status, flags, -+ "__HYPERVISOR_domctl_gethvmcontext_partial type", -+ domctl->u.hvmcontext_partial_0000000e.type); -+ break; -+ } -+ break; + } + break; case VKI_XEN_DOMCTL_max_mem: PRE_XEN_DOMCTL_READ(max_mem, max_memkb); -@@ -822,6 +957,8 @@ PRE(domctl) - __PRE_XEN_DOMCTL_READ(test_assign_device, assign_device_00000007, machine_sbdf); - break; - case 0x0000000b: -+ case 0x0000000c: -+ case 0x0000000d: - __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) - break; - } - break; -+ case 0x0000000e: -+ default: -+ __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) { -+ case VKI_XEN_DOMCTL_DEV_PCI: -+ __PRE_XEN_DOMCTL_READ(test_assign_device, assign_device_0000000e, u.pci); -+ break; -+ case VKI_XEN_DOMCTL_DEV_DT: -+ __PRE_XEN_DOMCTL_READ(test_assign_device, assign_device_0000000e, u.dt); -+ PRE_MEM_READ("XEN_DOMTCL_test_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_test_assign_device dev", -+ domctl->u.assign_device_0000000e.dev); -+ break; -+ } -+ break; - } - break; - case VKI_XEN_DOMCTL_assign_device: -@@ -852,6 +1010,8 @@ PRE(domctl) - __PRE_XEN_DOMCTL_READ(assign_device, assign_device_00000007, machine_sbdf); - break; - case 0x0000000b: -+ case 0x0000000c: -+ case 0x0000000d: - __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) - break; - } - break; -+ case 0x0000000e: -+ default: -+ __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) { -+ case VKI_XEN_DOMCTL_DEV_PCI: -+ __PRE_XEN_DOMCTL_READ(assign_device, assign_device_0000000e, u.pci); -+ break; -+ 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); -+ break; -+ } -+ break; - } - break; - case VKI_XEN_DOMCTL_deassign_device: -@@ -882,6 +1063,8 @@ PRE(domctl) - __PRE_XEN_DOMCTL_READ(deassign_device, assign_device_00000007, machine_sbdf); - break; - case 0x0000000b: -+ case 0x0000000c: -+ case 0x0000000d: - __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) - break; - } - break; -+ case 0x0000000e: -+ default: -+ __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) { -+ case VKI_XEN_DOMCTL_DEV_PCI: -+ __PRE_XEN_DOMCTL_READ(deassign_device, assign_device_0000000e, u.pci); -+ break; -+ 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); -+ break; -+ } -+ break; - } - break; - -@@ -916,6 +1120,7 @@ PRE(domctl) - __PRE_XEN_DOMCTL_READ(settscinfo, tsc_info_00000007, info.elapsed_nsec); - break; - case 0x0000000b: -+ default: - __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) - break; - - case VKI_XEN_DOMCTL_settimeoffset: -- PRE_XEN_DOMCTL_READ(settimeoffset, time_offset_seconds); -- break; -+ switch (domctl->interface_version) { -+ case 0x00000007: -+ case 0x00000008: -+ case 0x00000009: -+ case 0x0000000a: -+ PRE_XEN_DOMCTL_READ(settimeoffset_0000000a, time_offset_seconds); -+ break; -+ case 0x0000000b: -+ default: -+ PRE_XEN_DOMCTL_READ(settimeoffset_0000000b, time_offset_seconds); -+ break; -+ } -+ break; - - case VKI_XEN_DOMCTL_getvcpuinfo: - PRE_XEN_DOMCTL_READ(getvcpuinfo, vcpu); -@@ -991,6 +1207,7 @@ PRE(domctl) - __PRE_XEN_DOMCTL_READ(getvcpuaffinity, vcpuaffinity_00000009, cpumap.nr_bits); - break; - case 0x0000000a: -+ default: - __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) - domctl->u.vcpuaffinity_00000009.cpumap.nr_bits / 8); - break; - case 0x0000000a: -+ default: - __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) - 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); - break; - } - break; -@@ -1110,6 +1323,7 @@ PRE(domctl) - break; - - case 0x00000009: -+ default: - __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) - } - #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; - -@@ -1248,6 +1456,7 @@ PRE(domctl) - __PRE_XEN_DOMCTL_READ(mem_event_op, mem_event_op_00000007, mode); - break; - case 0x0000000b: -+ default: - __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) - case VKI_XEN_DOMCTL_monitor_op: - switch (domctl->interface_version) { - case 0x000000b: -+ default: - 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) { - 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) - } - 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; -+ } -+ break; -+ - default: - bad_subop(tid, layout, arrghs, status, flags, - "__HYPERVISOR_domctl", domctl->cmd); -@@ -1474,6 +1694,7 @@ POST(memory_op) - case VKI_XENMEM_claim_pages: - case VKI_XENMEM_maximum_gpfn: - case VKI_XENMEM_remove_from_physmap: -+ case VKI_XENMEM_set_pod_target: - case VKI_XENMEM_access_op: - /* No outputs */ - break; -@@ -1518,6 +1739,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; -+ - } - } - -@@ -1643,6 +1873,9 @@ POST(xen_version) - case VKI_XENVER_commandline: - POST_MEM_WRITE((Addr)ARG2, sizeof(vki_xen_commandline_t)); - break; -+ case VKI_XENVER_build_id: -+ POST_MEM_WRITE((Addr)ARG2, sizeof(struct vki_xen_build_id)); -+ break; - } - } - -@@ -1672,6 +1905,11 @@ POST(sysctl) - case 0x00000009: - case 0x0000000a: - case 0x0000000b: -+ case 0x0000000c: -+ case 0x0000000d: -+ case 0x0000000e: -+ case 0x0000000f: -+ case 0x00000010: - break; - default: - return; -@@ -1706,6 +1944,7 @@ POST(sysctl) - 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) - break; - case 0x0000000a: - case 0x0000000b: -+ case 0x0000000c: -+ case 0x0000000d: -+ case 0x0000000e: -+ case 0x0000000f: - 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) - POST_XEN_SYSCTL_WRITE(physinfo_0000000a, hw_cap[8]); - POST_XEN_SYSCTL_WRITE(physinfo_0000000a, capabilities); - break; -+ case 0x00000010: -+ default: -+ 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); -+ POST_XEN_SYSCTL_WRITE(physinfo_00000010, max_cpu_id); -+ POST_XEN_SYSCTL_WRITE(physinfo_00000010, nr_nodes); -+ POST_XEN_SYSCTL_WRITE(physinfo_00000010, max_node_id); -+ POST_XEN_SYSCTL_WRITE(physinfo_00000010, cpu_khz); -+ POST_XEN_SYSCTL_WRITE(physinfo_00000010, capabilities); -+ POST_XEN_SYSCTL_WRITE(physinfo_00000010, total_pages); -+ POST_XEN_SYSCTL_WRITE(physinfo_00000010, free_pages); -+ POST_XEN_SYSCTL_WRITE(physinfo_00000010, scrub_pages); -+ POST_XEN_SYSCTL_WRITE(physinfo_00000010, outstanding_pages); -+ POST_XEN_SYSCTL_WRITE(physinfo_00000010, max_mfn); -+ POST_XEN_SYSCTL_WRITE(physinfo_00000010, hw_cap[8]); -+ break; - } - break; - - 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, -- 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); -- 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: -+ switch (sysctl->interface_version) -+ { -+ case 0x00000007: -+ case 0x00000008: -+ case 0x00000009: -+ case 0x0000000a: -+ case 0x0000000b: -+ 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); -+ 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); -+ 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); -+ break; -+ case 0x0000000c: -+ default: -+ 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); -+ break; -+ } - break; - - case VKI_XEN_SYSCTL_numainfo: -- POST_XEN_SYSCTL_WRITE(numainfo, max_node_index); -- POST_MEM_WRITE((Addr)sysctl->u.numainfo.node_to_memsize.p, -- sizeof(uint64_t) * sysctl->u.numainfo.max_node_index); -- POST_MEM_WRITE((Addr)sysctl->u.numainfo.node_to_memfree.p, -- sizeof(uint64_t) * sysctl->u.numainfo.max_node_index); -- POST_MEM_WRITE((Addr)sysctl->u.numainfo.node_to_node_distance.p, -- 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, -+ sizeof(uint32_t) * -+ (sysctl->u.numainfo_0000000b.max_node_index * sysctl->u.numainfo_0000000b.max_node_index)); -+ break; -+ case 0x0000000c: -+ default: -+ 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)); -+ break; -+ } -+ break; -+ -+ case VKI_XEN_SYSCTL_pcitopoinfo: -+ switch (sysctl->interface_version) -+ { -+ case 0x0000000c: -+ default: -+ 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); -+ break; -+ } -+ break; -+ -+ case VKI_XEN_SYSCTL_get_cpu_featureset: -+ switch (sysctl->interface_version) -+ { -+ case 0x0000000c: -+ default: -+ 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); -+ break; -+ } - break; - - /* No outputs */ -@@ -1808,6 +2128,9 @@ POST(domctl){ - case 0x00000009: - case 0x0000000a: - case 0x0000000b: -+ case 0x0000000c: -+ case 0x0000000d: -+ case 0x0000000e: - break; - default: - return; -@@ -1869,6 +2192,7 @@ POST(domctl){ - sizeof(vki_xen_guest_tsc_info_t)); - break; - case 0x0000000b: -+ default: - __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){ +@@ -2145,14 +2155,24 @@ POST(domctl){ break; case VKI_XEN_DOMCTL_gethvmcontext_partial: @@ -762,8 +2956,98 @@ Index: valgrind-3.13.0/coregrind/m_syswrap/syswrap-xen.c + VKI_HVM_SAVE_LENGTH(CPU)); + break; + } ++ break; ++ } ++ break; + + case VKI_XEN_DOMCTL_scheduler_op: + if ( domctl->u.scheduler_op.cmd == VKI_XEN_DOMCTL_SCHEDOP_getinfo ) { +diff --git a/include/vki/vki-xen-domctl.h b/include/vki/vki-xen-domctl.h +index c02357dd7..c225287a7 100644 +--- a/include/vki/vki-xen-domctl.h ++++ b/include/vki/vki-xen-domctl.h +@@ -436,13 +436,13 @@ 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 { + 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); + + + struct vki_xen_domctl_pin_mem_cacheattr { +@@ -733,7 +733,7 @@ struct vki_xen_domctl { + struct vki_xen_domctl_tsc_info_0000000b tsc_info_0000000b; + //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_address_size address_size; + //struct vki_xen_domctl_sendtrigger sendtrigger; + //struct vki_xen_domctl_get_device_group get_device_group; + +From 2f75c6af0f30cd3911ca3452734c1020fe2e2572 Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:29:43 +0100 +Subject: [PATCH 54/75] xen-4.10: hvmcontext_partial + +Handle new layout of xen_domctl_hvmcontext_partial of xen-4.10 + +bz#390553 +--- + coregrind/m_syswrap/syswrap-xen.c | 34 +++++++++++++++++++++++++++++++ + include/vki/vki-xen-domctl.h | 9 ++++++++ + 2 files changed, 43 insertions(+) + +diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c +index 6f6d040a9..a73e702cc 100644 +--- a/coregrind/m_syswrap/syswrap-xen.c ++++ b/coregrind/m_syswrap/syswrap-xen.c +@@ -904,6 +904,32 @@ PRE(domctl) + break; + } + break; ++ case 0x0000000e: ++ __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); ++ __PRE_XEN_DOMCTL_READ(gethvmcontext_partial, hvmcontext_partial_0000000e, buffer); ++ ++ 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)); ++ 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)); ++ break; ++ default: ++ bad_subop(tid, layout, arrghs, status, flags, ++ "__HYPERVISOR_domctl_gethvmcontext_partial type", ++ domctl->u.hvmcontext_partial_0000000e.type); ++ break; ++ } ++ break; + } + break; + +@@ -2170,6 +2196,14 @@ POST(domctl){ + VKI_HVM_SAVE_LENGTH(CPU)); + break; + } + case 0x0000000e: -+ default: + switch (domctl->u.hvmcontext_partial_0000000e.type) { + case VKI_HVM_SAVE_CODE(CPU): + if ( domctl->u.hvmcontext_partial_0000000e.buffer.p ) @@ -771,70 +3055,68 @@ Index: valgrind-3.13.0/coregrind/m_syswrap/syswrap-xen.c + VKI_HVM_SAVE_LENGTH(CPU)); + break; + } -+ break; -+ } -+ break; - - case VKI_XEN_DOMCTL_scheduler_op: - if ( domctl->u.scheduler_op.cmd == VKI_XEN_DOMCTL_SCHEDOP_getinfo ) { -@@ -1943,6 +2286,7 @@ POST(domctl){ - domctl->u.vcpuaffinity_00000009.cpumap.nr_bits / 8); - break; - case 0x0000000a: -+ default: - 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){ - 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){ - break; - - case 0x00000009: -+ default: - __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){ - __POST_XEN_DOMCTL_WRITE(mem_event_op, mem_event_op_00000007, port); - break; - case 0x0000000b: -+ default: - __POST_XEN_DOMCTL_WRITE(vm_event_op, vm_event_op_0000000b, port); break; } -@@ -2143,6 +2490,46 @@ POST(domctl){ - } + break; +diff --git a/include/vki/vki-xen-domctl.h b/include/vki/vki-xen-domctl.h +index c225287a7..d0c9c28e1 100644 +--- a/include/vki/vki-xen-domctl.h ++++ b/include/vki/vki-xen-domctl.h +@@ -444,6 +444,14 @@ struct vki_xen_domctl_hvmcontext_partial_0000000d { + 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); + ++struct vki_xen_domctl_hvmcontext_partial_0000000e { ++ vki_uint32_t type; /* IN */ ++ vki_uint32_t instance; /* IN */ ++ vki_xen_uint64_aligned_t bufsz; /* IN */ ++ VKI_XEN_GUEST_HANDLE_64(vki_uint8) buffer; /* IN/OUT buffer */ ++}; ++typedef struct vki_xen_domctl_hvmcontext_partial_0000000e vki_xen_domctl_hvmcontext_partial_0000000e_t; ++DEFINE_VKI_XEN_GUEST_HANDLE(vki_xen_domctl_hvmcontext_partial_0000000e_t); + + struct vki_xen_domctl_pin_mem_cacheattr { + vki_xen_uint64_aligned_t start, end; /* IN */ +@@ -734,6 +742,7 @@ struct vki_xen_domctl { + //struct vki_xen_domctl_real_mode_area real_mode_area; + struct vki_xen_domctl_hvmcontext hvmcontext; + struct vki_xen_domctl_hvmcontext_partial_0000000d hvmcontext_partial_0000000d; ++ struct vki_xen_domctl_hvmcontext_partial_0000000e hvmcontext_partial_0000000e; + struct vki_xen_domctl_address_size address_size; + //struct vki_xen_domctl_sendtrigger sendtrigger; + //struct vki_xen_domctl_get_device_group get_device_group; + +From e58ecf1802b3e48ad001f868910399a77e8f2176 Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:29:44 +0100 +Subject: [PATCH 55/75] xen-4.10: xen_domctl_monitor_op + +Handle new layout of xen_domctl_monitor_op in xen-4.10 + +bz#390553 +--- + coregrind/m_syswrap/syswrap-xen.c | 20 ++++++++++++ + include/vki/vki-xen-domctl.h | 51 +++++++++++++++++++++++++++++++ + 2 files changed, 71 insertions(+) + +diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c +index a73e702cc..05d66bc1d 100644 +--- a/coregrind/m_syswrap/syswrap-xen.c ++++ b/coregrind/m_syswrap/syswrap-xen.c +@@ -2446,6 +2446,7 @@ POST(domctl){ break; -+ case 0x000000c: + 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; -+ } -+ } -+ + 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: +@@ -2463,6 +2464,25 @@ POST(domctl){ + } + } + + break; + case 0x000000e: -+ default: + 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: @@ -852,314 +3134,17 @@ Index: valgrind-3.13.0/coregrind/m_syswrap/syswrap-xen.c + } + } + -+ break; + break; } break; - } -@@ -2264,6 +2651,8 @@ static XenHypercallTableEntry hypercall_ - 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 - }; - - 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 { - int __user *err; /* array of error codes */ - }; - -+struct vki_xen_privcmd_dm_op_buf { -+ void __user *uptr; -+ __vki_kernel_size_t size; -+}; -+ -+struct vki_xen_privcmd_dm_op { -+ __vki_u16 dom; -+ __vki_u16 num; -+ const struct vki_xen_privcmd_dm_op_buf __user *ubufs; -+}; -+ -+ - #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)) - - #define VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH _VKI_IOC(_VKI_IOC_NONE, 'P', 3, sizeof(struct vki_xen_privcmd_mmapbatch)) - #define VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH_V2 _VKI_IOC(_VKI_IOC_NONE, 'P', 4, sizeof(struct vki_xen_privcmd_mmapbatch_v2)) - -+#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)) -+ - //---------------------------------------------------------------------- - // 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 @@ - * - 0x00000009: Xen 4.3 & 4.4 - * - 0x0000000a: Xen 4.5 - * - 0x0000000b: Xen 4.6 -- * - 0x0000000c: Xen 4.7 -+ * - 0x0000000c: Xen 4.8 -+ * - 0x0000000d: Xen 4.9 -+ * - 0x0000000e: Xen 4.10 - * - * 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 @@ - #define VKI_XEN_DOMCTL_cacheflush 71 - #define VKI_XEN_DOMCTL_get_vcpu_msrs 72 - #define VKI_XEN_DOMCTL_set_vcpu_msrs 73 -+#define VKI_XEN_DOMCTL_setvnumainfo 74 -+#define VKI_XEN_DOMCTL_psr_cmt_op 75 -+#define VKI_XEN_DOMCTL_arm_configure_domain 76 - #define VKI_XEN_DOMCTL_monitor_op 77 /* new in 4.6 */ -+#define VKI_XEN_DOMCTL_psr_cat_op 78 -+#define VKI_XEN_DOMCTL_soft_reset 79 -+#define VKI_XEN_DOMCTL_set_gnttab_limits 80 -+#define VKI_XEN_DOMCTL_vuart_op 81 - #define VKI_XEN_DOMCTL_gdbsx_guestmemio 1000 - #define VKI_XEN_DOMCTL_gdbsx_pausevcpu 1001 - #define VKI_XEN_DOMCTL_gdbsx_unpausevcpu 1002 - #define VKI_XEN_DOMCTL_gdbsx_domstatus 1003 - --struct vki_xen_domctl_createdomain { -+struct vki_xen_domctl_createdomain_0000000a { - /* IN parameters */ - vki_uint32_t ssidref; - vki_xen_domain_handle_t handle; - vki_uint32_t flags; - }; - -+struct vki_xen_arch_domainconfig_0000000b { -+#if defined(__i386__) || defined(__x86_64__) -+ vki_uint8_t dummy; -+#endif -+#if defined(__arm__) || defined(__aarch64__) -+ /* IN/OUT */ -+ vki_uint8_t gic_version; -+ /* IN */ -+ vki_uint32_t nr_spis; -+ vki_uint32_t clock_frequency; -+#endif -+}; -+ -+struct vki_xen_domctl_createdomain_0000000b { -+ /* IN parameters */ -+ vki_uint32_t ssidref; -+ vki_xen_domain_handle_t handle; -+ vki_uint32_t flags; -+ struct vki_xen_arch_domainconfig_0000000b config; -+}; -+ -+/* The layout changed in 4.07, which shared domctl with 4.06 */ -+struct vki_xen_arch_domainconfig_0000000c { -+#if defined(__i386__) || defined(__x86_64__) -+ vki_uint32_t emulation_flags; -+#endif -+#if defined(__arm__) || defined(__aarch64__) -+ /* IN/OUT */ -+ vki_uint8_t gic_version; -+ /* IN */ -+ vki_uint32_t nr_spis; -+ vki_uint32_t clock_frequency; -+#endif -+}; -+ -+struct vki_xen_domctl_createdomain_0000000c { -+ /* IN parameters */ -+ vki_uint32_t ssidref; -+ vki_xen_domain_handle_t handle; -+ vki_uint32_t flags; -+ 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 - vki_uint32_t vcpu; /* IN */ - #define VKI_XEN_VCPUAFFINITY_HARD (1U<<0) - #define VKI_XEN_VCPUAFFINITY_SOFT (1U<<1) -+#define VKI_XEN_VCPUAFFINITY_FORCE (1U<<2) - 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 { - #define VKI_XEN_SCHEDULER_CREDIT2 6 - #define VKI_XEN_SCHEDULER_ARINC653 7 - #define VKI_XEN_SCHEDULER_RTDS 8 -+#define VKI_XEN_SCHEDULER_NULL 9 - vki_uint32_t cmd; /* VKI_XEN_DOMCTL_SCHEDOP_* */ - #define VKI_XEN_DOMCTL_SCHEDOP_putinfo 0 - #define VKI_XEN_DOMCTL_SCHEDOP_getinfo 1 -+#define VKI_XEN_DOMCTL_SCHEDOP_putvcpuinfo 2 -+#define VKI_XEN_DOMCTL_SCHEDOP_getvcpuinfo 3 - union { - struct xen_domctl_sched_sedf { - vki_xen_uint64_aligned_t period; -@@ -333,10 +389,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 { - vki_int32_t time_offset_seconds; - }; - -+struct vki_xen_domctl_settimeoffset_0000000b { -+ vki_int64_t time_offset_seconds; -+}; -+ - struct vki_xen_domctl_cpuid { - vki_uint32_t input[2]; - vki_uint32_t eax; -@@ -378,14 +438,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 { - 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); - -+struct vki_xen_domctl_hvmcontext_partial_0000000e { -+ vki_uint32_t type; /* IN */ -+ vki_uint32_t instance; /* IN */ -+ vki_xen_uint64_aligned_t bufsz; /* IN */ -+ VKI_XEN_GUEST_HANDLE_64(vki_uint8) buffer; /* IN/OUT buffer */ -+}; -+typedef struct vki_xen_domctl_hvmcontext_partial_0000000e vki_xen_domctl_hvmcontext_partial_0000000e_t; -+DEFINE_VKI_XEN_GUEST_HANDLE(vki_xen_domctl_hvmcontext_partial_0000000e_t); - - 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 - vki_uint32_t flag; /* flag of assigned device */ - }; - -+struct vki_xen_domctl_assign_device_0000000e { -+ vki_uint32_t dev; /* XEN_DOMCTL_DEV_* */ -+ vki_uint32_t flags; -+ union { -+ struct { -+ vki_uint32_t machine_sbdf; /* machine PCI ID of assigned device */ -+ } pci; -+ struct { -+ vki_uint32_t size; /* Length of the path */ -+ VKI_XEN_GUEST_HANDLE_64(vki_uint8) path; /* path to the device tree node */ -+ } dt; -+ } u; -+}; -+ - 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 { - #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 -+#define VKI_XEN_DOMCTL_MONITOR_EVENT_DEBUG_EXCEPTION 5 -+#define VKI_XEN_DOMCTL_MONITOR_EVENT_CPUID 6 -+#define VKI_XEN_DOMCTL_MONITOR_EVENT_PRIVILEGED_CALL 7 -+#define VKI_XEN_DOMCTL_MONITOR_EVENT_INTERRUPT 8 -+#define VKI_XEN_DOMCTL_MONITOR_EVENT_DESC_ACCESS 9 -+#define VKI_XEN_DOMCTL_MONITOR_EVENT_EMUL_UNIMPLEMENTED 10 - - 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 +diff --git a/include/vki/vki-xen-domctl.h b/include/vki/vki-xen-domctl.h +index d0c9c28e1..e7c38a57b 100644 +--- a/include/vki/vki-xen-domctl.h ++++ b/include/vki/vki-xen-domctl.h +@@ -679,6 +679,56 @@ struct vki_xen_domctl_monitor_op_0000000c { } 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; -+}; -+ +struct vki_xen_domctl_monitor_op_0000000e { + vki_uint32_t op; /* vki_xen_DOMCTL_MONITOR_OP_* */ + @@ -1213,226 +3198,166 @@ 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 { - } u; - }; - -+struct vki_xen_domctl_set_gnttab_limits_0000000e { -+ vki_uint32_t grant_frames; -+ vki_uint32_t maptrack_frames; -+}; -+ - struct vki_xen_domctl { - vki_uint32_t cmd; - vki_uint32_t interface_version; /* XEN_DOMCTL_INTERFACE_VERSION */ - 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_0000000b createdomain_0000000b; -+ struct vki_xen_domctl_createdomain_0000000c createdomain_0000000c; -+ //struct vki_xen_domctl_arm_configuredomain configuredomain; - 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_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_0000000b settimeoffset_0000000b; - //struct vki_xen_domctl_disable_migrate disable_migrate; - struct vki_xen_domctl_tsc_info_00000007 tsc_info_00000007; - struct vki_xen_domctl_tsc_info_0000000b tsc_info_0000000b; - //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_0000000e hvmcontext_partial_0000000e; - struct vki_xen_domctl_address_size address_size; - //struct vki_xen_domctl_sendtrigger sendtrigger; - //struct vki_xen_domctl_get_device_group get_device_group; - struct vki_xen_domctl_assign_device_00000007 assign_device_00000007; - struct vki_xen_domctl_assign_device_0000000b assign_device_0000000b; -+ struct vki_xen_domctl_assign_device_0000000e assign_device_0000000e; - //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 { - //struct vki_xen_domctl_gdbsx_pauseunp_vcpu gdbsx_pauseunp_vcpu; +@@ -777,6 +827,7 @@ struct vki_xen_domctl { //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_0000000c monitor_op_0000000c; + struct vki_xen_domctl_monitor_op_0000000e monitor_op_0000000e; -+ //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_set_gnttab_limits_0000000e set_gnttab_limits_0000000e; + //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; + +From 100ac066c9b5025219bd2bcbbbef31c25a2584d8 Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:29:46 +0100 +Subject: [PATCH 56/75] xen-4.10: add monitor event EMUL_UNIMPLEMENTED + +Add define for XEN_DOMCTL_MONITOR_EVENT_EMUL_UNIMPLEMENTED + +bz#390553 +--- + include/vki/vki-xen-domctl.h | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/include/vki/vki-xen-domctl.h b/include/vki/vki-xen-domctl.h +index e7c38a57b..465f66bec 100644 +--- a/include/vki/vki-xen-domctl.h ++++ b/include/vki/vki-xen-domctl.h +@@ -600,6 +600,7 @@ struct vki_xen_domctl_vcpu_msrs { + #define VKI_XEN_DOMCTL_MONITOR_EVENT_PRIVILEGED_CALL 7 + #define VKI_XEN_DOMCTL_MONITOR_EVENT_INTERRUPT 8 + #define VKI_XEN_DOMCTL_MONITOR_EVENT_DESC_ACCESS 9 ++#define VKI_XEN_DOMCTL_MONITOR_EVENT_EMUL_UNIMPLEMENTED 10 + + struct vki_xen_domctl_monitor_op_0000000b { + vki_uint32_t op; /* vki_xen_DOMCTL_MONITOR_OP_* */ + +From 3dca8dec04b455d5768e228297d22d99b736c809 Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:29:47 +0100 +Subject: [PATCH 57/75] xen-4.10: add set_gnttab_limits and vuart_op + +Add defines for XEN_DOMCTL_set_gnttab_limits and XEN_DOMCTL_vuart_op + +bz#390553 +--- + include/vki/vki-xen-domctl.h | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/include/vki/vki-xen-domctl.h b/include/vki/vki-xen-domctl.h +index 465f66bec..b1068eb13 100644 +--- a/include/vki/vki-xen-domctl.h ++++ b/include/vki/vki-xen-domctl.h +@@ -127,6 +127,8 @@ + #define VKI_XEN_DOMCTL_monitor_op 77 /* new in 4.6 */ + #define VKI_XEN_DOMCTL_psr_cat_op 78 + #define VKI_XEN_DOMCTL_soft_reset 79 ++#define VKI_XEN_DOMCTL_set_gnttab_limits 80 ++#define VKI_XEN_DOMCTL_vuart_op 81 + #define VKI_XEN_DOMCTL_gdbsx_guestmemio 1000 + #define VKI_XEN_DOMCTL_gdbsx_pausevcpu 1001 + #define VKI_XEN_DOMCTL_gdbsx_unpausevcpu 1002 +@@ -832,6 +834,8 @@ struct vki_xen_domctl { + //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_set_gnttab_limits set_gnttab_limits; + //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 - #define VKI_XEN_GNTTABOP_get_status_frames 9 - #define VKI_XEN_GNTTABOP_get_version 10 - #define VKI_XEN_GNTTABOP_swap_grant_ref 11 -+#define VKI_XEN_GNTTABOP_cache_flush 12 - - 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 -@@ -48,8 +48,12 @@ - #define VKI_XENMEM_get_sharing_freed_pages 18 - #define VKI_XENMEM_get_sharing_shared_pages 19 - #define VKI_XENMEM_access_op 21 -+#define VKI_XENMEM_sharing_op 22 -+#define VKI_XENMEM_add_to_physmap_batch 23 - #define VKI_XENMEM_claim_pages 24 - #define VKI_XENMEM_machphys_compat_mfn_list 25 -+#define VKI_XENMEM_get_vnumainfo 26 -+#define VKI_XENMEM_reserved_device_memory_map 27 - - struct vki_xen_memory_map { - unsigned int nr_entries; -@@ -95,6 +99,14 @@ struct vki_xen_remove_from_physmap { - vki_xen_pfn_t gpfn; - }; - -+struct vki_xen_pod_target { -+ vki_uint64_t target_pages; -+ vki_uint64_t tot_pages; -+ vki_uint64_t pod_cache_pages; -+ vki_uint64_t pod_entries; -+ vki_xen_domid_t domid; -+}; -+ - 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 -@@ -60,6 +60,15 @@ struct vki_xen_physdev_unmap_pirq { - int pirq; - }; - -+struct vki_physdev_pci_device { -+ /* IN */ -+ vki_uint16_t seg; -+ vki_uint8_t bus; -+ vki_uint8_t devfn; -+}; -+typedef struct vki_physdev_pci_device vki_physdev_pci_device_t; -+DEFINE_VKI_XEN_GUEST_HANDLE(vki_physdev_pci_device_t); -+ - #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 - - #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 @@ - * - 0x00000009: Xen 4.2 - * - 0x0000000a: Xen 4.3 & 4.4 - * - 0x0000000b: Xen 4.5 -+ * - 0x0000000c: Xen 4.6 -+ * - 0x0000000d: Xen 4.7 -+ * - 0x0000000e: Xen 4.8 -+ * - 0x0000000f: Xen 4.9 + +From 0e657d18770914c7c02db8748b44d189390de319 Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:29:48 +0100 +Subject: [PATCH 58/75] xen-4.10: sysctl value + +Add 0x10 as sysctl value of xen-4.10 + +bz#390553 +--- + coregrind/m_syswrap/syswrap-xen.c | 2 ++ + include/vki/vki-xen-sysctl.h | 1 + + 2 files changed, 3 insertions(+) + +diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c +index 05d66bc1d..2b33b06bc 100644 +--- a/coregrind/m_syswrap/syswrap-xen.c ++++ b/coregrind/m_syswrap/syswrap-xen.c +@@ -589,6 +589,7 @@ PRE(sysctl) { + case 0x0000000d: + case 0x0000000e: + case 0x0000000f: ++ case 0x00000010: + break; + default: + bad_intf_version(tid, layout, arrghs, status, flags, +@@ -1893,6 +1894,7 @@ POST(sysctl) + case 0x0000000d: + case 0x0000000e: + case 0x0000000f: ++ case 0x00000010: + break; + default: + return; +diff --git a/include/vki/vki-xen-sysctl.h b/include/vki/vki-xen-sysctl.h +index 214a652b8..7b6e78d85 100644 +--- a/include/vki/vki-xen-sysctl.h ++++ b/include/vki/vki-xen-sysctl.h +@@ -13,6 +13,7 @@ + * - 0x0000000d: Xen 4.7 + * - 0x0000000e: Xen 4.8 + * - 0x0000000f: Xen 4.9 + * - 0x00000010: Xen 4.10 * * 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 @@ - #define VKI_XEN_SYSCTL_page_offline_op 14 - #define VKI_XEN_SYSCTL_lockprof_op 15 - #define VKI_XEN_SYSCTL_topologyinfo 16 -+#define VKI_XEN_SYSCTL_cputopoinfo 16 /* Since xen-4.6 */ - #define VKI_XEN_SYSCTL_numainfo 17 - #define VKI_XEN_SYSCTL_cpupool_op 18 - #define VKI_XEN_SYSCTL_scheduler_op 19 - #define VKI_XEN_SYSCTL_coverage_op 20 -+#define VKI_XEN_SYSCTL_gcov_op 20 /* Since xen-4.9 */ -+#define VKI_XEN_SYSCTL_psr_cmt_op 21 -+#define VKI_XEN_SYSCTL_pcitopoinfo 22 -+#define VKI_XEN_SYSCTL_psr_cat_op 23 -+#define VKI_XEN_SYSCTL_tmem_op 24 -+#define VKI_XEN_SYSCTL_get_cpu_levelling_caps 25 -+#define VKI_XEN_SYSCTL_get_cpu_featureset 26 -+#define VKI_XEN_SYSCTL_livepatch_op 27 -+#define VKI_XEN_SYSCTL_set_parameter 28 + +From e3070fed0faf48b9a23122b13b831caaed5f2c30 Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:29:49 +0100 +Subject: [PATCH 59/75] xen-4.10: xen_sysctl_physinfo + +Handle new layout of xen_sysctl_physinfo in xen-4.10 + +bz#390553 +--- + coregrind/m_syswrap/syswrap-xen.c | 16 ++++++++++++++++ + include/vki/vki-xen-sysctl.h | 18 ++++++++++++++++++ + 2 files changed, 34 insertions(+) + +diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c +index 2b33b06bc..88db3a214 100644 +--- a/coregrind/m_syswrap/syswrap-xen.c ++++ b/coregrind/m_syswrap/syswrap-xen.c +@@ -1988,6 +1988,22 @@ POST(sysctl) + POST_XEN_SYSCTL_WRITE(physinfo_0000000a, hw_cap[8]); + POST_XEN_SYSCTL_WRITE(physinfo_0000000a, capabilities); + break; ++ case 0x00000010: ++ 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); ++ POST_XEN_SYSCTL_WRITE(physinfo_00000010, max_cpu_id); ++ POST_XEN_SYSCTL_WRITE(physinfo_00000010, nr_nodes); ++ POST_XEN_SYSCTL_WRITE(physinfo_00000010, max_node_id); ++ POST_XEN_SYSCTL_WRITE(physinfo_00000010, cpu_khz); ++ POST_XEN_SYSCTL_WRITE(physinfo_00000010, capabilities); ++ POST_XEN_SYSCTL_WRITE(physinfo_00000010, total_pages); ++ POST_XEN_SYSCTL_WRITE(physinfo_00000010, free_pages); ++ POST_XEN_SYSCTL_WRITE(physinfo_00000010, scrub_pages); ++ POST_XEN_SYSCTL_WRITE(physinfo_00000010, outstanding_pages); ++ POST_XEN_SYSCTL_WRITE(physinfo_00000010, max_mfn); ++ POST_XEN_SYSCTL_WRITE(physinfo_00000010, hw_cap[8]); ++ break; + } + break; - struct vki_xen_sysctl_readconsole { - /* IN */ -@@ -120,12 +135,45 @@ struct vki_xen_sysctl_topologyinfo { - VKI_XEN_GUEST_HANDLE_64(vki_uint32) cpu_to_node; - }; - --struct vki_xen_sysctl_numainfo { -+struct vki_xen_sysctl_cputopo_0000000c { -+ vki_uint32_t core; -+ vki_uint32_t socket; -+ vki_uint32_t node; -+}; -+typedef struct vki_xen_sysctl_cputopo_0000000c vki_xen_sysctl_cputopo_0000000c_t; -+DEFINE_VKI_XEN_GUEST_HANDLE(vki_xen_sysctl_cputopo_0000000c_t); -+ -+struct vki_xen_sysctl_cputopoinfo_0000000c { -+ vki_uint32_t num_cpus; -+ VKI_XEN_GUEST_HANDLE_64(vki_xen_sysctl_cputopo_0000000c_t) cputopo; -+}; -+ -+struct vki_xen_sysctl_pcitopoinfo_0000000c { -+ vki_uint32_t num_devs; -+ VKI_XEN_GUEST_HANDLE_64(vki_physdev_pci_device_t) devs; -+ VKI_XEN_GUEST_HANDLE_64(vki_uint32) nodes; -+}; -+ -+struct vki_xen_sysctl_numainfo_0000000b { - 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; - VKI_XEN_GUEST_HANDLE_64(vki_uint32) node_to_node_distance; - }; -+ -+struct vki_xen_xen_sysctl_meminfo_0000000c { -+ vki_uint64_t memsize; -+ vki_uint64_t memfree; -+}; -+typedef struct vki_xen_xen_sysctl_meminfo_0000000c vki_xen_xen_sysctl_meminfo_0000000c_t; -+DEFINE_VKI_XEN_GUEST_HANDLE(vki_xen_xen_sysctl_meminfo_0000000c_t); -+ -+struct vki_xen_sysctl_numainfo_0000000c { -+ vki_uint32_t num_nodes; -+ VKI_XEN_GUEST_HANDLE_64(vki_xen_xen_sysctl_meminfo_0000000c_t) meminfo; -+ VKI_XEN_GUEST_HANDLE_64(vki_uint32) distance; -+}; -+ - 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 +diff --git a/include/vki/vki-xen-sysctl.h b/include/vki/vki-xen-sysctl.h +index 7b6e78d85..e371b81e4 100644 +--- a/include/vki/vki-xen-sysctl.h ++++ b/include/vki/vki-xen-sysctl.h +@@ -206,6 +206,23 @@ struct vki_xen_sysctl_physinfo_0000000a { vki_uint32_t capabilities; }; @@ -1456,104 +3381,1098 @@ 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 { - vki_uint32_t sched_id; - }; - -+struct vki_xen_sysctl_cpu_featureset_0000000d { -+ vki_uint32_t index; -+ vki_uint32_t nr_features; -+ VKI_XEN_GUEST_HANDLE_64(vki_uint32) features; -+}; -+ - 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 { +@@ -227,6 +244,7 @@ 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; + struct vki_xen_sysctl_physinfo_00000010 physinfo_00000010; struct vki_xen_sysctl_topologyinfo topologyinfo; -- 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_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 { - struct vki_xen_sysctl_cpupool_op cpupool_op; - //struct vki_xen_sysctl_scheduler_op scheduler_op; - //struct vki_xen_sysctl_coverage_op coverage_op; -+ //struct vki_xen_sysctl_gcov_op gcov_op; -+ //struct vki_xen_sysctl_psr_cmt_op psr_cmt_op; -+ //struct vki_xen_sysctl_psr_cat_op psr_cat_op; -+ //struct vki_xen_sysctl_tmem_op tmem_op; -+ //struct vki_xen_sysctl_cpu_levelling_caps cpu_levelling_caps; -+ struct vki_xen_sysctl_cpu_featureset_0000000d cpu_featureset_0000000d; -+ //struct vki_xen_sysctl_livepatch_op livepatch; + struct vki_xen_sysctl_cputopoinfo_0000000c cputopoinfo_0000000c; + struct vki_xen_sysctl_pcitopoinfo_0000000c pcitopoinfo_0000000c; + +From 4bffbd293849bdc43f479324bd19f3443af40654 Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:29:50 +0100 +Subject: [PATCH 60/75] xen: handle xen_sysctl_physinfo for more sysctl + versions + +bz#390553 +--- + coregrind/m_syswrap/syswrap-xen.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c +index 88db3a214..39abac4e4 100644 +--- a/coregrind/m_syswrap/syswrap-xen.c ++++ b/coregrind/m_syswrap/syswrap-xen.c +@@ -1974,6 +1974,10 @@ POST(sysctl) + break; + case 0x0000000a: + case 0x0000000b: ++ case 0x0000000c: ++ case 0x0000000d: ++ case 0x0000000e: ++ case 0x0000000f: + 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); + +From b6216ed6015ef7d9ff3256b054241a20adfc08ab Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:29:51 +0100 +Subject: [PATCH 61/75] xen-4.10: add set_parameter + +Add define for XEN_SYSCTL_set_parameter + +bz#390553 +--- + include/vki/vki-xen-sysctl.h | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/include/vki/vki-xen-sysctl.h b/include/vki/vki-xen-sysctl.h +index e371b81e4..d5980a41e 100644 +--- a/include/vki/vki-xen-sysctl.h ++++ b/include/vki/vki-xen-sysctl.h +@@ -52,6 +52,7 @@ + #define VKI_XEN_SYSCTL_get_cpu_levelling_caps 25 + #define VKI_XEN_SYSCTL_get_cpu_featureset 26 + #define VKI_XEN_SYSCTL_livepatch_op 27 ++#define VKI_XEN_SYSCTL_set_parameter 28 + + struct vki_xen_sysctl_readconsole { + /* IN */ +@@ -274,6 +275,7 @@ struct vki_xen_sysctl { + //struct vki_xen_sysctl_cpu_levelling_caps cpu_levelling_caps; + 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; 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 -@@ -38,6 +38,7 @@ - #define VKI_XENVER_pagesize 7 - #define VKI_XENVER_guest_handle 8 - #define VKI_XENVER_commandline 9 -+#define VKI_XENVER_build_id 10 + +From da8c77c57f85013c19eaa3c597cfb2169697453e Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:29:52 +0100 +Subject: [PATCH 62/75] xen: add a concept of "use the latest" + +In coregrind/m_syswrap/syswrap-xen.c the handlers of sysctl and domctl check +the current ->interface_version. If it is not yet known, an error is reported. +Otherwise the current ->cmd is processed. Several commands handle various +->interface_version. But none of these handlers have a concept of "use the +latest". If a new interface_version is added at the beginning of the list, each +and every handler must be updated with the newly added version number. I think +it would be simpler to check the supported versions as it is done now, then +each handler uses the latest layout in a "default:" case. + +bz#390553 +--- + coregrind/m_syswrap/syswrap-xen.c | 40 +++++++++++++++++-------------- + 1 file changed, 22 insertions(+), 18 deletions(-) + +diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c +index 39abac4e4..3d525fe2d 100644 +--- a/coregrind/m_syswrap/syswrap-xen.c ++++ b/coregrind/m_syswrap/syswrap-xen.c +@@ -632,16 +632,11 @@ PRE(sysctl) { + 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: +- VG_(dmsg)("WARNING: XEN_SYSCTL_getdomaininfolist for sysctl version " +- "%"PRIx32" not implemented yet\n", +- sysctl->interface_version); +- SET_STATUS_Failure(VKI_EINVAL); +- return; + } + break; - typedef char vki_xen_extraversion_t[16]; +@@ -906,6 +901,7 @@ PRE(domctl) + } + break; + case 0x0000000e: ++ default: + __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); +@@ -973,6 +969,7 @@ PRE(domctl) + } + break; + case 0x0000000e: ++ default: + __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) { +@@ -1025,6 +1022,7 @@ PRE(domctl) + } + break; + case 0x0000000e: ++ default: + __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) { +@@ -1077,6 +1075,7 @@ PRE(domctl) + } + break; + case 0x0000000e: ++ default: + __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) { +@@ -1111,6 +1110,7 @@ PRE(domctl) + __PRE_XEN_DOMCTL_READ(settscinfo, tsc_info_00000007, info.elapsed_nsec); + break; + case 0x0000000b: ++ default: + __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); +@@ -1149,6 +1149,7 @@ PRE(domctl) + PRE_XEN_DOMCTL_READ(settimeoffset_0000000a, time_offset_seconds); + break; + case 0x0000000b: ++ default: + PRE_XEN_DOMCTL_READ(settimeoffset_0000000b, time_offset_seconds); + break; + } +@@ -1196,6 +1197,7 @@ PRE(domctl) + __PRE_XEN_DOMCTL_READ(getvcpuaffinity, vcpuaffinity_00000009, cpumap.nr_bits); + break; + case 0x0000000a: ++ default: + __PRE_XEN_DOMCTL_READ(getvcpuaffinity, vcpuaffinity_0000000a, vcpu); + if (domctl->u.vcpuaffinity_0000000a.flags & VKI_XEN_VCPUAFFINITY_HARD) + __PRE_XEN_DOMCTL_READ( +@@ -1219,6 +1221,7 @@ PRE(domctl) + domctl->u.vcpuaffinity_00000009.cpumap.nr_bits / 8); + break; + case 0x0000000a: ++ default: + __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) { +@@ -1275,13 +1278,8 @@ PRE(domctl) + break; -@@ -63,6 +64,16 @@ struct vki_xen_feature_info { + 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); + break; + } + break; +@@ -1315,6 +1313,7 @@ PRE(domctl) + break; - typedef char vki_xen_commandline_t[1024]; + case 0x00000009: ++ default: + __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__) +@@ -1343,12 +1342,6 @@ PRE(domctl) + } + #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; -+struct vki_xen_build_id { -+ unsigned int len; /* IN: size of buf[]. */ -+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L -+ unsigned char buf[]; -+#elif defined(__GNUC__) -+ unsigned char buf[1]; /* OUT: Variable length buffer with build_id. */ -+#endif +@@ -1453,6 +1446,7 @@ PRE(domctl) + __PRE_XEN_DOMCTL_READ(mem_event_op, mem_event_op_00000007, mode); + break; + case 0x0000000b: ++ default: + __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; +@@ -1483,6 +1477,7 @@ PRE(domctl) + case VKI_XEN_DOMCTL_monitor_op: + switch (domctl->interface_version) { + case 0x000000b: ++ default: + if (domctl->u.monitor_op_0000000b.op == VKI_XEN_DOMCTL_MONITOR_OP_ENABLE || + domctl->u.monitor_op_0000000b.op == VKI_XEN_DOMCTL_MONITOR_OP_DISABLE) { + switch (domctl->u.monitor_op_0000000b.event) { +@@ -1929,6 +1924,7 @@ POST(sysctl) + 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) +@@ -1993,6 +1989,7 @@ POST(sysctl) + POST_XEN_SYSCTL_WRITE(physinfo_0000000a, capabilities); + break; + case 0x00000010: ++ default: + 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); +@@ -2175,6 +2172,7 @@ POST(domctl){ + sizeof(vki_xen_guest_tsc_info_t)); + break; + case 0x0000000b: ++ default: + __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); +@@ -2219,6 +2217,7 @@ POST(domctl){ + break; + } + case 0x0000000e: ++ default: + switch (domctl->u.hvmcontext_partial_0000000e.type) { + case VKI_HVM_SAVE_CODE(CPU): + if ( domctl->u.hvmcontext_partial_0000000e.buffer.p ) +@@ -2267,6 +2266,7 @@ POST(domctl){ + domctl->u.vcpuaffinity_00000009.cpumap.nr_bits / 8); + break; + case 0x0000000a: ++ default: + if (domctl->u.vcpuaffinity_0000000a.flags & VKI_XEN_VCPUAFFINITY_HARD) + POST_MEM_WRITE( + (Addr)domctl->u.vcpuaffinity_0000000a.cpumap_hard.bitmap.p, +@@ -2316,6 +2316,7 @@ POST(domctl){ + 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); +@@ -2368,6 +2369,7 @@ POST(domctl){ + break; + + case 0x00000009: ++ default: + __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, +@@ -2444,6 +2446,7 @@ POST(domctl){ + __POST_XEN_DOMCTL_WRITE(mem_event_op, mem_event_op_00000007, port); + break; + case 0x0000000b: ++ default: + __POST_XEN_DOMCTL_WRITE(vm_event_op, vm_event_op_0000000b, port); + break; + } +@@ -2488,6 +2491,7 @@ POST(domctl){ + + break; + case 0x000000e: ++ default: + 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: + +From e1f15f6161f44834ace37f2bcba091893baeee23 Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:29:53 +0100 +Subject: [PATCH 63/75] xen: support + XENMEM_set_pod_target/XENMEM_get_pod_target + +bz#390553 +--- + coregrind/m_syswrap/syswrap-xen.c | 20 ++++++++++++++++++++ + include/vki/vki-xen-memory.h | 8 ++++++++ + 2 files changed, 28 insertions(+) + +diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c +index 3d525fe2d..2acbd7a1a 100644 +--- a/coregrind/m_syswrap/syswrap-xen.c ++++ b/coregrind/m_syswrap/syswrap-xen.c +@@ -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; ++ } + case VKI_XENMEM_access_op: { + struct vki_xen_mem_event_op *arg = + (struct vki_xen_mem_event_op *)ARG2; +@@ -1684,6 +1694,7 @@ POST(memory_op) + case VKI_XENMEM_claim_pages: + case VKI_XENMEM_maximum_gpfn: + case VKI_XENMEM_remove_from_physmap: ++ case VKI_XENMEM_set_pod_target: + case VKI_XENMEM_access_op: + /* No outputs */ + break; +@@ -1728,6 +1739,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; + -+}; -+ - #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 -@@ -69,6 +69,8 @@ - #define __VKI_XEN_kexec_op 37 - #define __VKI_XEN_tmem_op 38 - #define __VKI_XEN_xc_reserved_op 39 /* reserved for XenClient */ -+#define __VKI_XEN_xenpmu_op 40 -+#define __VKI_XEN_dm_op 41 - - #define __DEFINE_VKI_XEN_GUEST_HANDLE(name, type) \ - ___DEFINE_VKI_XEN_GUEST_HANDLE(name, type); \ -@@ -104,6 +106,7 @@ struct vki_xenctl_bitmap { - vki_uint32_t nr_bits; +diff --git a/include/vki/vki-xen-memory.h b/include/vki/vki-xen-memory.h +index 49565636b..ae77d49c7 100644 +--- a/include/vki/vki-xen-memory.h ++++ b/include/vki/vki-xen-memory.h +@@ -99,6 +99,14 @@ struct vki_xen_remove_from_physmap { + vki_xen_pfn_t gpfn; }; -+#include - #include - #include - #include -@@ -115,7 +118,6 @@ struct vki_xenctl_bitmap { - #include - #include - #include --#include ++struct vki_xen_pod_target { ++ vki_uint64_t target_pages; ++ vki_uint64_t tot_pages; ++ vki_uint64_t pod_cache_pages; ++ vki_uint64_t pod_entries; ++ vki_xen_domid_t domid; ++}; ++ + struct vki_xen_mem_event_op { + vki_uint8_t op; + vki_xen_domid_t domain; + +From a1fc996be8b022a140fd35c3fbe613d49e625e6b Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:29:54 +0100 +Subject: [PATCH 64/75] xen-4.10: support xen_domctl_set_gnttab_limits + +bz#390553 +--- + coregrind/m_syswrap/syswrap-xen.c | 10 ++++++++++ + include/vki/vki-xen-domctl.h | 7 ++++++- + 2 files changed, 16 insertions(+), 1 deletion(-) + +diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c +index 2acbd7a1a..07b092bf4 100644 +--- a/coregrind/m_syswrap/syswrap-xen.c ++++ b/coregrind/m_syswrap/syswrap-xen.c +@@ -1509,6 +1509,16 @@ PRE(domctl) + } + break; - #endif // __VKI_XEN_H ++ 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; ++ } ++ break; ++ + default: + bad_subop(tid, layout, arrghs, status, flags, + "__HYPERVISOR_domctl", domctl->cmd); +diff --git a/include/vki/vki-xen-domctl.h b/include/vki/vki-xen-domctl.h +index b1068eb13..a6d7d7515 100644 +--- a/include/vki/vki-xen-domctl.h ++++ b/include/vki/vki-xen-domctl.h +@@ -755,6 +755,11 @@ struct vki_xen_domctl_monitor_op { + } u; + }; ++struct vki_xen_domctl_set_gnttab_limits_0000000e { ++ vki_uint32_t grant_frames; ++ vki_uint32_t maptrack_frames; ++}; ++ + struct vki_xen_domctl { + vki_uint32_t cmd; + vki_uint32_t interface_version; /* XEN_DOMCTL_INTERFACE_VERSION */ +@@ -834,7 +839,7 @@ struct vki_xen_domctl { + //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_set_gnttab_limits set_gnttab_limits; ++ 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; + +From 8755f7fc7d33cdd447dfeb6101a66bc737c98ee7 Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:29:55 +0100 +Subject: [PATCH 65/75] xen-4.10: add domctl value from shim + +bz#390553 +--- + coregrind/m_syswrap/syswrap-xen.c | 2 ++ + include/vki/vki-xen-domctl.h | 1 + + 2 files changed, 3 insertions(+) + +diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c +index 07b092bf4..ff933c1be 100644 +--- a/coregrind/m_syswrap/syswrap-xen.c ++++ b/coregrind/m_syswrap/syswrap-xen.c +@@ -795,6 +795,7 @@ PRE(domctl) + case 0x0000000c: + case 0x0000000d: + case 0x0000000e: ++ case 0x0000000f: + break; + default: + bad_intf_version(tid, layout, arrghs, status, flags, +@@ -2141,6 +2142,7 @@ POST(domctl){ + case 0x0000000c: + case 0x0000000d: + case 0x0000000e: ++ case 0x0000000f: + break; + default: + return; +diff --git a/include/vki/vki-xen-domctl.h b/include/vki/vki-xen-domctl.h +index a6d7d7515..62a72f897 100644 +--- a/include/vki/vki-xen-domctl.h ++++ b/include/vki/vki-xen-domctl.h +@@ -40,6 +40,7 @@ + * - 0x0000000c: Xen 4.8 + * - 0x0000000d: Xen 4.9 + * - 0x0000000e: Xen 4.10 ++ * - 0x0000000f: Xen 4.10 with shim + * + * When adding a new subop be sure to include the variants used by all + * of the above, both here and in syswrap-xen.c + +From 77ba331dda8cf1b5675ec55e5eed383822d06af0 Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Fri, 16 Nov 2018 17:29:56 +0100 +Subject: [PATCH 66/75] xen-4.10: xen_domctl_getdomaininfo + +Handle new layout of xen_getdomaininfo in xen-4.10 shim + +bz#390553 +--- + coregrind/m_syswrap/syswrap-xen.c | 26 +++++++++++++++++++++++++- + include/vki/vki-xen-domctl.h | 23 +++++++++++++++++++++++ + 2 files changed, 48 insertions(+), 1 deletion(-) + +diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c +index ff933c1be..a9b61030b 100644 +--- a/coregrind/m_syswrap/syswrap-xen.c ++++ b/coregrind/m_syswrap/syswrap-xen.c +@@ -2348,7 +2348,6 @@ POST(domctl){ + 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); +@@ -2363,6 +2362,31 @@ POST(domctl){ + POST_XEN_DOMCTL_WRITE(getdomaininfo_00000009, ssidref); + POST_XEN_DOMCTL_WRITE(getdomaininfo_00000009, handle); + POST_XEN_DOMCTL_WRITE(getdomaininfo_00000009, cpupool); ++ case 0x0000000f: ++ default: ++ 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; +diff --git a/include/vki/vki-xen-domctl.h b/include/vki/vki-xen-domctl.h +index 62a72f897..f1d78e4f2 100644 +--- a/include/vki/vki-xen-domctl.h ++++ b/include/vki/vki-xen-domctl.h +@@ -245,6 +245,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 */ +@@ -773,6 +795,7 @@ struct vki_xen_domctl { + struct vki_xen_domctl_getdomaininfo_00000007 getdomaininfo_00000007; + struct vki_xen_domctl_getdomaininfo_00000008 getdomaininfo_00000008; + struct vki_xen_domctl_getdomaininfo_00000009 getdomaininfo_00000009; ++ 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; + +From 05f94a0834c568cbb4b827ee0600db297e354fec Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Tue, 20 Nov 2018 10:14:52 +0100 +Subject: [PATCH 67/75] xen-4.11: sysctl value + +Add 0x11 as sysctl value of xen-4.11 + +bz#390553 +--- + coregrind/m_syswrap/syswrap-xen.c | 2 ++ + include/vki/vki-xen-sysctl.h | 1 + + 2 files changed, 3 insertions(+) + +diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c +index a9b61030b..779ae20e5 100644 +--- a/coregrind/m_syswrap/syswrap-xen.c ++++ b/coregrind/m_syswrap/syswrap-xen.c +@@ -600,6 +600,7 @@ PRE(sysctl) { + case 0x0000000e: + case 0x0000000f: + case 0x00000010: ++ case 0x00000011: + break; + default: + bad_intf_version(tid, layout, arrghs, status, flags, +@@ -1921,6 +1922,7 @@ POST(sysctl) + case 0x0000000e: + case 0x0000000f: + case 0x00000010: ++ case 0x00000011: + break; + default: + return; +diff --git a/include/vki/vki-xen-sysctl.h b/include/vki/vki-xen-sysctl.h +index d5980a41e..f68ba3610 100644 +--- a/include/vki/vki-xen-sysctl.h ++++ b/include/vki/vki-xen-sysctl.h +@@ -14,6 +14,7 @@ + * - 0x0000000e: Xen 4.8 + * - 0x0000000f: Xen 4.9 + * - 0x00000010: Xen 4.10 ++ * - 0x00000011: Xen 4.11 + * + * When adding a new subop be sure to include the variants used by all + * of the above, both here and in syswrap-xen.c + +From 57766db8cb59fbfb906ca929d3e23b8d88612b7b Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Tue, 20 Nov 2018 10:46:49 +0100 +Subject: [PATCH 68/75] xen-4.11: domctl value + +Add 0x10 as domctl value of xen-4.11 + +bz#390553 +--- + coregrind/m_syswrap/syswrap-xen.c | 2 ++ + include/vki/vki-xen-domctl.h | 1 + + 2 files changed, 3 insertions(+) + +diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c +index 779ae20e5..b59d1975a 100644 +--- a/coregrind/m_syswrap/syswrap-xen.c ++++ b/coregrind/m_syswrap/syswrap-xen.c +@@ -797,6 +797,7 @@ PRE(domctl) + case 0x0000000d: + case 0x0000000e: + case 0x0000000f: ++ case 0x00000010: + break; + default: + bad_intf_version(tid, layout, arrghs, status, flags, +@@ -2145,6 +2146,7 @@ POST(domctl){ + case 0x0000000d: + case 0x0000000e: + case 0x0000000f: ++ case 0x00000010: + break; + default: + return; +diff --git a/include/vki/vki-xen-domctl.h b/include/vki/vki-xen-domctl.h +index f1d78e4f2..f9c76cab2 100644 +--- a/include/vki/vki-xen-domctl.h ++++ b/include/vki/vki-xen-domctl.h +@@ -41,6 +41,7 @@ + * - 0x0000000d: Xen 4.9 + * - 0x0000000e: Xen 4.10 + * - 0x0000000f: Xen 4.10 with shim ++ * - 0x00000010: Xen 4.11 + * + * When adding a new subop be sure to include the variants used by all + * of the above, both here and in syswrap-xen.c + +From 751773406086216eb079fd68d7a1f4d9a453f3eb Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Tue, 20 Nov 2018 10:55:51 +0100 +Subject: [PATCH 69/75] xen-4.11: xen_domctl_monitor_op + +Handle new layout of xen_domctl_monitor_op in xen-4.11 + +bz#390553 +--- + coregrind/m_syswrap/syswrap-xen.c | 21 ++++++++++++- + include/vki/vki-xen-domctl.h | 52 +++++++++++++++++++++++++++++++ + 2 files changed, 72 insertions(+), 1 deletion(-) + +diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c +index b59d1975a..ae89afd08 100644 +--- a/coregrind/m_syswrap/syswrap-xen.c ++++ b/coregrind/m_syswrap/syswrap-xen.c +@@ -2551,7 +2551,6 @@ POST(domctl){ + + break; + case 0x000000e: +- default: + 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: +@@ -2569,6 +2568,26 @@ POST(domctl){ + } + } + ++ break; ++ case 0x0000010: ++ default: ++ 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; +diff --git a/include/vki/vki-xen-domctl.h b/include/vki/vki-xen-domctl.h +index f9c76cab2..c5936cc76 100644 +--- a/include/vki/vki-xen-domctl.h ++++ b/include/vki/vki-xen-domctl.h +@@ -756,6 +756,57 @@ struct vki_xen_domctl_monitor_op_0000000e { + } u; + }; + ++struct vki_xen_domctl_monitor_op_00000010 { ++ 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; ++ vki_uint8_t onchangeonly; ++ } 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 { + vki_uint32_t op; +@@ -861,6 +912,7 @@ struct vki_xen_domctl { + 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; + +From 3f19cef2fc9eda416acc5706d0de1e802b60ccda Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Tue, 20 Nov 2018 11:05:35 +0100 +Subject: [PATCH 70/75] xen-4.11: add IOCTL_PRIVCMD_MMAP_RESOURCE + +Add define for IOCTL_PRIVCMD_MMAP_RESOURCE + +bz#390553 +--- + coregrind/m_syswrap/syswrap-linux.c | 17 +++++++++++++++++ + include/vki/vki-linux.h | 9 +++++++++ + 2 files changed, 26 insertions(+) + +diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c +index c8f72de74..59e07b82b 100644 +--- a/coregrind/m_syswrap/syswrap-linux.c ++++ b/coregrind/m_syswrap/syswrap-linux.c +@@ -8230,6 +8230,23 @@ PRE(sys_ioctl) + (Addr)args->ubufs, sizeof(*(args->ubufs)) * args->num); + 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_EVTCHN_BIND_VIRQ: { + struct vki_xen_ioctl_evtchn_bind_virq *args = +diff --git a/include/vki/vki-linux.h b/include/vki/vki-linux.h +index 0a0b5c2c1..4aa2ec819 100644 +--- a/include/vki/vki-linux.h ++++ b/include/vki/vki-linux.h +@@ -3395,6 +3395,14 @@ struct vki_xen_privcmd_dm_op { + 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)) +@@ -3404,6 +3412,7 @@ struct vki_xen_privcmd_dm_op { + + #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)) + + //---------------------------------------------------------------------- + // Xen evtchn IOCTL + +From 3e77d31513b2e0445e86eeed4ab8a5cdbae255c1 Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Tue, 20 Nov 2018 11:29:14 +0100 +Subject: [PATCH 71/75] xen-4.12: sysctl value + +Add 0x12 as sysctl value of xen-4.12 + +bz#390553 +--- + coregrind/m_syswrap/syswrap-xen.c | 2 ++ + include/vki/vki-xen-sysctl.h | 1 + + 2 files changed, 3 insertions(+) + +diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c +index ae89afd08..766ca02c4 100644 +--- a/coregrind/m_syswrap/syswrap-xen.c ++++ b/coregrind/m_syswrap/syswrap-xen.c +@@ -601,6 +601,7 @@ PRE(sysctl) { + case 0x0000000f: + case 0x00000010: + case 0x00000011: ++ case 0x00000012: + break; + default: + bad_intf_version(tid, layout, arrghs, status, flags, +@@ -1924,6 +1925,7 @@ POST(sysctl) + case 0x0000000f: + case 0x00000010: + case 0x00000011: ++ case 0x00000012: + break; + default: + return; +diff --git a/include/vki/vki-xen-sysctl.h b/include/vki/vki-xen-sysctl.h +index f68ba3610..bf9cadda8 100644 +--- a/include/vki/vki-xen-sysctl.h ++++ b/include/vki/vki-xen-sysctl.h +@@ -15,6 +15,7 @@ + * - 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 + +From 0940be9b2ec78b9994672a85f1020b700f706b96 Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Tue, 20 Nov 2018 11:58:21 +0100 +Subject: [PATCH 72/75] xen-4.12 get_cpu_policy + +--- + include/vki/vki-xen-sysctl.h | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/include/vki/vki-xen-sysctl.h b/include/vki/vki-xen-sysctl.h +index bf9cadda8..5f5e78008 100644 +--- a/include/vki/vki-xen-sysctl.h ++++ b/include/vki/vki-xen-sysctl.h +@@ -55,6 +55,7 @@ + #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 */ +@@ -278,6 +279,7 @@ struct vki_xen_sysctl { + 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; + +From 68a2ad9886180d27702e967bf718e5f71ee8341a Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Tue, 20 Nov 2018 12:07:18 +0100 +Subject: [PATCH 73/75] xen-4.12: IOCTL_PRIVCMD_UNIMPLEMENTED + +--- + coregrind/m_syswrap/syswrap-linux.c | 2 ++ + include/vki/vki-linux.h | 1 + + 2 files changed, 3 insertions(+) + +diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c +index 59e07b82b..f079c5ea9 100644 +--- a/coregrind/m_syswrap/syswrap-linux.c ++++ b/coregrind/m_syswrap/syswrap-linux.c +@@ -8247,6 +8247,8 @@ PRE(sys_ioctl) + (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 = +diff --git a/include/vki/vki-linux.h b/include/vki/vki-linux.h +index 4aa2ec819..f5ae9b45d 100644 +--- a/include/vki/vki-linux.h ++++ b/include/vki/vki-linux.h +@@ -3413,6 +3413,7 @@ struct vki_xen_privcmd_mmap_resource { + #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 + +From bd001c940edf89b00441f2401e29e3acfc3fdd2e Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Wed, 21 Nov 2018 10:33:21 +0100 +Subject: [PATCH 74/75] xen-4.12: domctl + +--- + coregrind/m_syswrap/syswrap-xen.c | 2 ++ + include/vki/vki-xen-domctl.h | 1 + + 2 files changed, 3 insertions(+) + +diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c +index 766ca02c4..f17cae23b 100644 +--- a/coregrind/m_syswrap/syswrap-xen.c ++++ b/coregrind/m_syswrap/syswrap-xen.c +@@ -799,6 +799,7 @@ PRE(domctl) + case 0x0000000e: + case 0x0000000f: + case 0x00000010: ++ case 0x00000011: + break; + default: + bad_intf_version(tid, layout, arrghs, status, flags, +@@ -2149,6 +2150,7 @@ POST(domctl){ + case 0x0000000e: + case 0x0000000f: + case 0x00000010: ++ case 0x00000011: + break; + default: + return; +diff --git a/include/vki/vki-xen-domctl.h b/include/vki/vki-xen-domctl.h +index c5936cc76..fa62c2fc6 100644 +--- a/include/vki/vki-xen-domctl.h ++++ b/include/vki/vki-xen-domctl.h +@@ -42,6 +42,7 @@ + * - 0x0000000e: Xen 4.10 + * - 0x0000000f: Xen 4.10 with shim + * - 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 + +From 7172c2bcd6b02d6e58aef653d520573fe3f96250 Mon Sep 17 00:00:00 2001 +From: Olaf Hering +Date: Wed, 21 Nov 2018 10:36:06 +0100 +Subject: [PATCH 75/75] xen-4.12 : xen_domctl_createdomain + +Signed-off-by: Olaf Hering +--- + coregrind/m_syswrap/syswrap-xen.c | 19 ++++++++++++++++++- + include/vki/vki-xen-domctl.h | 13 +++++++++++++ + 2 files changed, 31 insertions(+), 1 deletion(-) + +diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c +index f17cae23b..77e9ff6c3 100644 +--- a/coregrind/m_syswrap/syswrap-xen.c ++++ b/coregrind/m_syswrap/syswrap-xen.c +@@ -850,7 +850,6 @@ PRE(domctl) + #endif + break; + case 0x0000000c: +- default: + PRE_XEN_DOMCTL_READ(createdomain_0000000c, ssidref); + PRE_XEN_DOMCTL_READ(createdomain_0000000c, handle); + PRE_XEN_DOMCTL_READ(createdomain_0000000c, flags); +@@ -862,6 +861,24 @@ PRE(domctl) + __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: ++ default: ++ 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; + +diff --git a/include/vki/vki-xen-domctl.h b/include/vki/vki-xen-domctl.h +index fa62c2fc6..699b7dd27 100644 +--- a/include/vki/vki-xen-domctl.h ++++ b/include/vki/vki-xen-domctl.h +@@ -187,6 +187,18 @@ struct vki_xen_domctl_createdomain_0000000c { + 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; +@@ -844,6 +856,7 @@ struct vki_xen_domctl { + struct vki_xen_domctl_createdomain_0000000a createdomain_0000000a; + struct vki_xen_domctl_createdomain_0000000b createdomain_0000000b; + struct vki_xen_domctl_createdomain_0000000c createdomain_0000000c; ++ struct vki_xen_domctl_createdomain_00000011 createdomain_00000011; + //struct vki_xen_domctl_arm_configuredomain configuredomain; + struct vki_xen_domctl_getdomaininfo_00000007 getdomaininfo_00000007; + struct vki_xen_domctl_getdomaininfo_00000008 getdomaininfo_00000008; From 865e063b74f6f89a5b44b8aba5db4bb3d1531d1dcb7ce96d05fd9bec2f116910 Mon Sep 17 00:00:00 2001 From: Dirk Mueller Date: Thu, 22 Nov 2018 09:38:33 +0000 Subject: [PATCH 02/13] - 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, Implement-emulated-system-registers.-Fixes-392146.patch (FATE#326355) OBS-URL: https://build.opensuse.org/package/show/devel:tools/valgrind?expand=0&rev=174 --- ...-Add-vector-register-support-for-vgd.patch | 422 ++++++++++++++++++ ...-Fix-register-allocation-for-VRs-vs-.patch | 87 ++++ ...-Sign-extend-immediate-operand-of-LO.patch | 45 ++ ...lated-system-registers.-Fixes-392146.patch | 33 +- armv6-support.diff | 2 +- valgrind.changes | 9 + valgrind.spec | 15 + 7 files changed, 594 insertions(+), 19 deletions(-) create mode 100644 0001-Bug-397187-s390x-Add-vector-register-support-for-vgd.patch create mode 100644 0001-Bug-400490-s390x-Fix-register-allocation-for-VRs-vs-.patch create mode 100644 0001-Bug-400491-s390x-Sign-extend-immediate-operand-of-LO.patch 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..31f4515 --- /dev/null +++ b/0001-Bug-397187-s390x-Add-vector-register-support-for-vgd.patch @@ -0,0 +1,422 @@ +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 + +diff --git a/NEWS b/NEWS +index e0917e25f..2fa2c86a3 100644 +--- a/NEWS ++++ b/NEWS +@@ -49,6 +49,7 @@ where XXXXXX is the bug number as listed below. + 399322 Improve callgrind_annotate output + 400490 s390x: VRs allocated as if separate from FPRs + 400491 s390x: Operand of LOCH treated as unsigned integer ++397187 z13 vector register support for vgdb gdbserver + + Release 3.14.0 (9 October 2018) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +diff --git a/coregrind/Makefile.am b/coregrind/Makefile.am +index 8de19968f..94030fdb0 100644 +--- a/coregrind/Makefile.am ++++ b/coregrind/Makefile.am +@@ -685,6 +685,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 \ +diff --git a/coregrind/m_gdbserver/s390-vx-valgrind-s1.xml b/coregrind/m_gdbserver/s390-vx-valgrind-s1.xml +new file mode 100644 +index 000000000..ca461b32a +--- /dev/null ++++ b/coregrind/m_gdbserver/s390-vx-valgrind-s1.xml +@@ -0,0 +1,43 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/coregrind/m_gdbserver/s390-vx-valgrind-s2.xml b/coregrind/m_gdbserver/s390-vx-valgrind-s2.xml +new file mode 100644 +index 000000000..eccbd8d5f +--- /dev/null ++++ b/coregrind/m_gdbserver/s390-vx-valgrind-s2.xml +@@ -0,0 +1,43 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/coregrind/m_gdbserver/s390-vx.xml b/coregrind/m_gdbserver/s390-vx.xml +new file mode 100644 +index 000000000..2a16873fe +--- /dev/null ++++ b/coregrind/m_gdbserver/s390-vx.xml +@@ -0,0 +1,59 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/coregrind/m_gdbserver/s390x-vx-linux-valgrind.xml b/coregrind/m_gdbserver/s390x-vx-linux-valgrind.xml +new file mode 100644 +index 000000000..02370022e +--- /dev/null ++++ b/coregrind/m_gdbserver/s390x-vx-linux-valgrind.xml +@@ -0,0 +1,28 @@ ++ ++ ++ ++ ++ ++ ++ ++ s390:64-bit ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/coregrind/m_gdbserver/s390x-vx-linux.xml b/coregrind/m_gdbserver/s390x-vx-linux.xml +new file mode 100644 +index 000000000..e431c5b2a +--- /dev/null ++++ b/coregrind/m_gdbserver/s390x-vx-linux.xml +@@ -0,0 +1,18 @@ ++ ++ ++ ++ ++ ++ ++ ++ s390:64-bit ++ ++ ++ ++ ++ ++ +diff --git a/coregrind/m_gdbserver/valgrind-low-s390x.c b/coregrind/m_gdbserver/valgrind-low-s390x.c +index 7bbb2e372..a667f4b40 100644 +--- a/coregrind/m_gdbserver/valgrind-low-s390x.c ++++ b/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, int abs_regno, void * buf, + 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, int abs_regno, void * buf, + 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 (ThreadState *tst) + } + + 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_target = { + 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; + } +-- +2.19.1 + 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/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/valgrind.changes b/valgrind.changes index bd5e958..043a9b8 100644 --- a/valgrind.changes +++ b/valgrind.changes @@ -1,3 +1,12 @@ +------------------------------------------------------------------- +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, + Implement-emulated-system-registers.-Fixes-392146.patch (FATE#326355) + ------------------------------------------------------------------- Wed Nov 21 11:51:45 UTC 2018 - Dirk Mueller diff --git a/valgrind.spec b/valgrind.spec index e748519..183fcb0 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -35,10 +35,17 @@ Patch0: valgrind.xen.patch Patch1: jit-register-unregister.diff Patch2: armv6-support.diff Patch4: Implement-emulated-system-registers.-Fixes-392146.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 BuildRequires: automake BuildRequires: docbook-xsl-stylesheets BuildRequires: docbook_4 +%if 0%{?suse_version} < 1220 +BuildRequires: gcc8-c++ +%else BuildRequires: gcc-c++ +%endif BuildRequires: glibc-devel-32bit BuildRequires: libxslt BuildRequires: pkgconfig @@ -106,8 +113,16 @@ but it has been successfully used to optimize several KDE applications. ##%patch1 %patch2 %patch4 -p1 +%patch5 -p1 +%patch6 -p1 +%patch7 -p1 %build +%if 0%{?suse_version} < 1220 +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 From 0299f4e453886ff06c35b91d81c3aa516f151e8bcf3606be5fef7276f2e8da76 Mon Sep 17 00:00:00 2001 From: Dirk Mueller Date: Thu, 22 Nov 2018 09:53:28 +0000 Subject: [PATCH 03/13] OBS-URL: https://build.opensuse.org/package/show/devel:tools/valgrind?expand=0&rev=175 --- ...-Add-vector-register-support-for-vgd.patch | 80 +++++++------------ 1 file changed, 30 insertions(+), 50 deletions(-) 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 index 31f4515..b0fbec6 100644 --- a/0001-Bug-397187-s390x-Add-vector-register-support-for-vgd.patch +++ b/0001-Bug-397187-s390x-Add-vector-register-support-for-vgd.patch @@ -21,23 +21,11 @@ represent the vector registers. This is fixed. create mode 100644 coregrind/m_gdbserver/s390x-vx-linux-valgrind.xml create mode 100644 coregrind/m_gdbserver/s390x-vx-linux.xml -diff --git a/NEWS b/NEWS -index e0917e25f..2fa2c86a3 100644 ---- a/NEWS -+++ b/NEWS -@@ -49,6 +49,7 @@ where XXXXXX is the bug number as listed below. - 399322 Improve callgrind_annotate output - 400490 s390x: VRs allocated as if separate from FPRs - 400491 s390x: Operand of LOCH treated as unsigned integer -+397187 z13 vector register support for vgdb gdbserver - - Release 3.14.0 (9 October 2018) - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -diff --git a/coregrind/Makefile.am b/coregrind/Makefile.am -index 8de19968f..94030fdb0 100644 ---- a/coregrind/Makefile.am -+++ b/coregrind/Makefile.am -@@ -685,6 +685,11 @@ GDBSERVER_XML_FILES = \ +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 \ @@ -49,11 +37,10 @@ index 8de19968f..94030fdb0 100644 m_gdbserver/mips-cp0-valgrind-s1.xml \ m_gdbserver/mips-cp0-valgrind-s2.xml \ m_gdbserver/mips-cp0.xml \ -diff --git a/coregrind/m_gdbserver/s390-vx-valgrind-s1.xml b/coregrind/m_gdbserver/s390-vx-valgrind-s1.xml -new file mode 100644 -index 000000000..ca461b32a +Index: valgrind-3.14.0/coregrind/m_gdbserver/s390-vx-valgrind-s1.xml +=================================================================== --- /dev/null -+++ b/coregrind/m_gdbserver/s390-vx-valgrind-s1.xml ++++ valgrind-3.14.0/coregrind/m_gdbserver/s390-vx-valgrind-s1.xml @@ -0,0 +1,43 @@ + +interface_version. But none of these handlers have a concept of "use the -latest". If a new interface_version is added at the beginning of the list, each -and every handler must be updated with the newly added version number. I think -it would be simpler to check the supported versions as it is done now, then -each handler uses the latest layout in a "default:" case. - -bz#390553 ---- - coregrind/m_syswrap/syswrap-xen.c | 40 +++++++++++++++++-------------- - 1 file changed, 22 insertions(+), 18 deletions(-) - -diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c -index 39abac4e4..3d525fe2d 100644 ---- a/coregrind/m_syswrap/syswrap-xen.c -+++ b/coregrind/m_syswrap/syswrap-xen.c -@@ -632,16 +632,11 @@ PRE(sysctl) { - 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: -- VG_(dmsg)("WARNING: XEN_SYSCTL_getdomaininfolist for sysctl version " -- "%"PRIx32" not implemented yet\n", -- sysctl->interface_version); -- SET_STATUS_Failure(VKI_EINVAL); -- return; - } - break; - -@@ -906,6 +901,7 @@ PRE(domctl) - } - break; - case 0x0000000e: -+ default: - __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); -@@ -973,6 +969,7 @@ PRE(domctl) - } - break; - case 0x0000000e: -+ default: - __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) { -@@ -1025,6 +1022,7 @@ PRE(domctl) - } - break; - case 0x0000000e: -+ default: - __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) { -@@ -1077,6 +1075,7 @@ PRE(domctl) - } - break; - case 0x0000000e: -+ default: - __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) { -@@ -1111,6 +1110,7 @@ PRE(domctl) - __PRE_XEN_DOMCTL_READ(settscinfo, tsc_info_00000007, info.elapsed_nsec); - break; - case 0x0000000b: -+ default: - __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); -@@ -1149,6 +1149,7 @@ PRE(domctl) - PRE_XEN_DOMCTL_READ(settimeoffset_0000000a, time_offset_seconds); - break; - case 0x0000000b: -+ default: - PRE_XEN_DOMCTL_READ(settimeoffset_0000000b, time_offset_seconds); - break; - } -@@ -1196,6 +1197,7 @@ PRE(domctl) - __PRE_XEN_DOMCTL_READ(getvcpuaffinity, vcpuaffinity_00000009, cpumap.nr_bits); - break; - case 0x0000000a: -+ default: - __PRE_XEN_DOMCTL_READ(getvcpuaffinity, vcpuaffinity_0000000a, vcpu); - if (domctl->u.vcpuaffinity_0000000a.flags & VKI_XEN_VCPUAFFINITY_HARD) - __PRE_XEN_DOMCTL_READ( -@@ -1219,6 +1221,7 @@ PRE(domctl) - domctl->u.vcpuaffinity_00000009.cpumap.nr_bits / 8); - break; - case 0x0000000a: -+ default: - __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) { -@@ -1275,13 +1278,8 @@ 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); - break; - } - break; -@@ -1315,6 +1313,7 @@ PRE(domctl) - break; - - case 0x00000009: -+ default: - __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__) -@@ -1343,12 +1342,6 @@ PRE(domctl) - } - #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; - -@@ -1453,6 +1446,7 @@ PRE(domctl) - __PRE_XEN_DOMCTL_READ(mem_event_op, mem_event_op_00000007, mode); - break; - case 0x0000000b: -+ default: - __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; -@@ -1483,6 +1477,7 @@ PRE(domctl) - case VKI_XEN_DOMCTL_monitor_op: - switch (domctl->interface_version) { - case 0x000000b: -+ default: - if (domctl->u.monitor_op_0000000b.op == VKI_XEN_DOMCTL_MONITOR_OP_ENABLE || - domctl->u.monitor_op_0000000b.op == VKI_XEN_DOMCTL_MONITOR_OP_DISABLE) { - switch (domctl->u.monitor_op_0000000b.event) { -@@ -1929,6 +1924,7 @@ POST(sysctl) - 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) -@@ -1993,6 +1989,7 @@ POST(sysctl) - POST_XEN_SYSCTL_WRITE(physinfo_0000000a, capabilities); - break; - case 0x00000010: -+ default: - 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); -@@ -2175,6 +2172,7 @@ POST(domctl){ - sizeof(vki_xen_guest_tsc_info_t)); - break; - case 0x0000000b: -+ default: - __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); -@@ -2219,6 +2217,7 @@ POST(domctl){ - break; - } - case 0x0000000e: -+ default: - switch (domctl->u.hvmcontext_partial_0000000e.type) { - case VKI_HVM_SAVE_CODE(CPU): - if ( domctl->u.hvmcontext_partial_0000000e.buffer.p ) -@@ -2267,6 +2266,7 @@ POST(domctl){ - domctl->u.vcpuaffinity_00000009.cpumap.nr_bits / 8); - break; - case 0x0000000a: -+ default: - if (domctl->u.vcpuaffinity_0000000a.flags & VKI_XEN_VCPUAFFINITY_HARD) - POST_MEM_WRITE( - (Addr)domctl->u.vcpuaffinity_0000000a.cpumap_hard.bitmap.p, -@@ -2316,6 +2316,7 @@ POST(domctl){ - 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); -@@ -2368,6 +2369,7 @@ POST(domctl){ - break; - - case 0x00000009: -+ default: - __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, -@@ -2444,6 +2446,7 @@ POST(domctl){ - __POST_XEN_DOMCTL_WRITE(mem_event_op, mem_event_op_00000007, port); - break; - case 0x0000000b: -+ default: - __POST_XEN_DOMCTL_WRITE(vm_event_op, vm_event_op_0000000b, port); - break; - } -@@ -2488,6 +2491,7 @@ POST(domctl){ - - break; - case 0x000000e: -+ default: - 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: - -From e1f15f6161f44834ace37f2bcba091893baeee23 Mon Sep 17 00:00:00 2001 -From: Olaf Hering -Date: Fri, 16 Nov 2018 17:29:53 +0100 -Subject: [PATCH 63/75] xen: support - XENMEM_set_pod_target/XENMEM_get_pod_target - -bz#390553 ---- - coregrind/m_syswrap/syswrap-xen.c | 20 ++++++++++++++++++++ - include/vki/vki-xen-memory.h | 8 ++++++++ - 2 files changed, 28 insertions(+) - -diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c -index 3d525fe2d..2acbd7a1a 100644 ---- a/coregrind/m_syswrap/syswrap-xen.c -+++ b/coregrind/m_syswrap/syswrap-xen.c -@@ -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; -+ } - case VKI_XENMEM_access_op: { - struct vki_xen_mem_event_op *arg = - (struct vki_xen_mem_event_op *)ARG2; -@@ -1684,6 +1694,7 @@ POST(memory_op) - case VKI_XENMEM_claim_pages: - case VKI_XENMEM_maximum_gpfn: - case VKI_XENMEM_remove_from_physmap: -+ case VKI_XENMEM_set_pod_target: - case VKI_XENMEM_access_op: - /* No outputs */ - break; -@@ -1728,6 +1739,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; -+ - } - } - -diff --git a/include/vki/vki-xen-memory.h b/include/vki/vki-xen-memory.h -index 49565636b..ae77d49c7 100644 ---- a/include/vki/vki-xen-memory.h -+++ b/include/vki/vki-xen-memory.h -@@ -99,6 +99,14 @@ struct vki_xen_remove_from_physmap { - vki_xen_pfn_t gpfn; - }; - -+struct vki_xen_pod_target { -+ vki_uint64_t target_pages; -+ vki_uint64_t tot_pages; -+ vki_uint64_t pod_cache_pages; -+ vki_uint64_t pod_entries; -+ vki_xen_domid_t domid; -+}; -+ - struct vki_xen_mem_event_op { - vki_uint8_t op; - vki_xen_domid_t domain; - -From a1fc996be8b022a140fd35c3fbe613d49e625e6b Mon Sep 17 00:00:00 2001 -From: Olaf Hering -Date: Fri, 16 Nov 2018 17:29:54 +0100 -Subject: [PATCH 64/75] xen-4.10: support xen_domctl_set_gnttab_limits - -bz#390553 ---- - coregrind/m_syswrap/syswrap-xen.c | 10 ++++++++++ - include/vki/vki-xen-domctl.h | 7 ++++++- - 2 files changed, 16 insertions(+), 1 deletion(-) - -diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c -index 2acbd7a1a..07b092bf4 100644 ---- a/coregrind/m_syswrap/syswrap-xen.c -+++ b/coregrind/m_syswrap/syswrap-xen.c -@@ -1509,6 +1509,16 @@ 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; -+ } -+ break; -+ - default: - bad_subop(tid, layout, arrghs, status, flags, - "__HYPERVISOR_domctl", domctl->cmd); -diff --git a/include/vki/vki-xen-domctl.h b/include/vki/vki-xen-domctl.h -index b1068eb13..a6d7d7515 100644 ---- a/include/vki/vki-xen-domctl.h -+++ b/include/vki/vki-xen-domctl.h -@@ -755,6 +755,11 @@ struct vki_xen_domctl_monitor_op { - } u; - }; - -+struct vki_xen_domctl_set_gnttab_limits_0000000e { -+ vki_uint32_t grant_frames; -+ vki_uint32_t maptrack_frames; -+}; -+ - struct vki_xen_domctl { - vki_uint32_t cmd; - vki_uint32_t interface_version; /* XEN_DOMCTL_INTERFACE_VERSION */ -@@ -834,7 +839,7 @@ struct vki_xen_domctl { - //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_set_gnttab_limits set_gnttab_limits; -+ 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; - -From 8755f7fc7d33cdd447dfeb6101a66bc737c98ee7 Mon Sep 17 00:00:00 2001 -From: Olaf Hering -Date: Fri, 16 Nov 2018 17:29:55 +0100 -Subject: [PATCH 65/75] xen-4.10: add domctl value from shim - -bz#390553 ---- - coregrind/m_syswrap/syswrap-xen.c | 2 ++ - include/vki/vki-xen-domctl.h | 1 + - 2 files changed, 3 insertions(+) - -diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c -index 07b092bf4..ff933c1be 100644 ---- a/coregrind/m_syswrap/syswrap-xen.c -+++ b/coregrind/m_syswrap/syswrap-xen.c -@@ -795,6 +795,7 @@ PRE(domctl) - case 0x0000000c: - case 0x0000000d: - case 0x0000000e: -+ case 0x0000000f: - break; - default: - bad_intf_version(tid, layout, arrghs, status, flags, -@@ -2141,6 +2142,7 @@ POST(domctl){ - case 0x0000000c: - case 0x0000000d: - case 0x0000000e: -+ case 0x0000000f: - break; - default: - return; -diff --git a/include/vki/vki-xen-domctl.h b/include/vki/vki-xen-domctl.h -index a6d7d7515..62a72f897 100644 ---- a/include/vki/vki-xen-domctl.h -+++ b/include/vki/vki-xen-domctl.h -@@ -40,6 +40,7 @@ - * - 0x0000000c: Xen 4.8 - * - 0x0000000d: Xen 4.9 - * - 0x0000000e: Xen 4.10 -+ * - 0x0000000f: Xen 4.10 with shim - * - * When adding a new subop be sure to include the variants used by all - * of the above, both here and in syswrap-xen.c - -From 77ba331dda8cf1b5675ec55e5eed383822d06af0 Mon Sep 17 00:00:00 2001 -From: Olaf Hering -Date: Fri, 16 Nov 2018 17:29:56 +0100 -Subject: [PATCH 66/75] xen-4.10: xen_domctl_getdomaininfo - -Handle new layout of xen_getdomaininfo in xen-4.10 shim - -bz#390553 ---- - coregrind/m_syswrap/syswrap-xen.c | 26 +++++++++++++++++++++++++- - include/vki/vki-xen-domctl.h | 23 +++++++++++++++++++++++ - 2 files changed, 48 insertions(+), 1 deletion(-) - -diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c -index ff933c1be..a9b61030b 100644 ---- a/coregrind/m_syswrap/syswrap-xen.c -+++ b/coregrind/m_syswrap/syswrap-xen.c -@@ -2348,7 +2348,6 @@ POST(domctl){ - 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); -@@ -2363,6 +2362,31 @@ POST(domctl){ - POST_XEN_DOMCTL_WRITE(getdomaininfo_00000009, ssidref); - POST_XEN_DOMCTL_WRITE(getdomaininfo_00000009, handle); - POST_XEN_DOMCTL_WRITE(getdomaininfo_00000009, cpupool); -+ case 0x0000000f: -+ default: -+ 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; -diff --git a/include/vki/vki-xen-domctl.h b/include/vki/vki-xen-domctl.h -index 62a72f897..f1d78e4f2 100644 ---- a/include/vki/vki-xen-domctl.h -+++ b/include/vki/vki-xen-domctl.h -@@ -245,6 +245,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 */ -@@ -773,6 +795,7 @@ struct vki_xen_domctl { - struct vki_xen_domctl_getdomaininfo_00000007 getdomaininfo_00000007; - struct vki_xen_domctl_getdomaininfo_00000008 getdomaininfo_00000008; - struct vki_xen_domctl_getdomaininfo_00000009 getdomaininfo_00000009; -+ 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; - -From 05f94a0834c568cbb4b827ee0600db297e354fec Mon Sep 17 00:00:00 2001 -From: Olaf Hering -Date: Tue, 20 Nov 2018 10:14:52 +0100 -Subject: [PATCH 67/75] xen-4.11: sysctl value - -Add 0x11 as sysctl value of xen-4.11 - -bz#390553 ---- - coregrind/m_syswrap/syswrap-xen.c | 2 ++ - include/vki/vki-xen-sysctl.h | 1 + - 2 files changed, 3 insertions(+) - -diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c -index a9b61030b..779ae20e5 100644 ---- a/coregrind/m_syswrap/syswrap-xen.c -+++ b/coregrind/m_syswrap/syswrap-xen.c -@@ -600,6 +600,7 @@ PRE(sysctl) { - case 0x0000000e: - case 0x0000000f: - case 0x00000010: -+ case 0x00000011: - break; - default: - bad_intf_version(tid, layout, arrghs, status, flags, -@@ -1921,6 +1922,7 @@ POST(sysctl) - case 0x0000000e: - case 0x0000000f: - case 0x00000010: -+ case 0x00000011: - break; - default: - return; -diff --git a/include/vki/vki-xen-sysctl.h b/include/vki/vki-xen-sysctl.h -index d5980a41e..f68ba3610 100644 ---- a/include/vki/vki-xen-sysctl.h -+++ b/include/vki/vki-xen-sysctl.h -@@ -14,6 +14,7 @@ - * - 0x0000000e: Xen 4.8 - * - 0x0000000f: Xen 4.9 - * - 0x00000010: Xen 4.10 -+ * - 0x00000011: Xen 4.11 - * - * When adding a new subop be sure to include the variants used by all - * of the above, both here and in syswrap-xen.c - -From 57766db8cb59fbfb906ca929d3e23b8d88612b7b Mon Sep 17 00:00:00 2001 -From: Olaf Hering -Date: Tue, 20 Nov 2018 10:46:49 +0100 -Subject: [PATCH 68/75] xen-4.11: domctl value - -Add 0x10 as domctl value of xen-4.11 - -bz#390553 ---- - coregrind/m_syswrap/syswrap-xen.c | 2 ++ - include/vki/vki-xen-domctl.h | 1 + - 2 files changed, 3 insertions(+) - -diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c -index 779ae20e5..b59d1975a 100644 ---- a/coregrind/m_syswrap/syswrap-xen.c -+++ b/coregrind/m_syswrap/syswrap-xen.c -@@ -797,6 +797,7 @@ PRE(domctl) - case 0x0000000d: - case 0x0000000e: - case 0x0000000f: -+ case 0x00000010: - break; - default: - bad_intf_version(tid, layout, arrghs, status, flags, -@@ -2145,6 +2146,7 @@ POST(domctl){ - case 0x0000000d: - case 0x0000000e: - case 0x0000000f: -+ case 0x00000010: - break; - default: - return; -diff --git a/include/vki/vki-xen-domctl.h b/include/vki/vki-xen-domctl.h -index f1d78e4f2..f9c76cab2 100644 ---- a/include/vki/vki-xen-domctl.h -+++ b/include/vki/vki-xen-domctl.h -@@ -41,6 +41,7 @@ - * - 0x0000000d: Xen 4.9 - * - 0x0000000e: Xen 4.10 - * - 0x0000000f: Xen 4.10 with shim -+ * - 0x00000010: Xen 4.11 - * - * When adding a new subop be sure to include the variants used by all - * of the above, both here and in syswrap-xen.c - -From 751773406086216eb079fd68d7a1f4d9a453f3eb Mon Sep 17 00:00:00 2001 -From: Olaf Hering -Date: Tue, 20 Nov 2018 10:55:51 +0100 -Subject: [PATCH 69/75] xen-4.11: xen_domctl_monitor_op - -Handle new layout of xen_domctl_monitor_op in xen-4.11 - -bz#390553 ---- - coregrind/m_syswrap/syswrap-xen.c | 21 ++++++++++++- - include/vki/vki-xen-domctl.h | 52 +++++++++++++++++++++++++++++++ - 2 files changed, 72 insertions(+), 1 deletion(-) - -diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c -index b59d1975a..ae89afd08 100644 ---- a/coregrind/m_syswrap/syswrap-xen.c -+++ b/coregrind/m_syswrap/syswrap-xen.c -@@ -2551,7 +2551,6 @@ POST(domctl){ - - break; - case 0x000000e: -- default: - 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: -@@ -2569,6 +2568,26 @@ POST(domctl){ - } - } - -+ break; -+ case 0x0000010: -+ default: -+ 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; -diff --git a/include/vki/vki-xen-domctl.h b/include/vki/vki-xen-domctl.h -index f9c76cab2..c5936cc76 100644 ---- a/include/vki/vki-xen-domctl.h -+++ b/include/vki/vki-xen-domctl.h -@@ -756,6 +756,57 @@ struct vki_xen_domctl_monitor_op_0000000e { - } u; - }; - -+struct vki_xen_domctl_monitor_op_00000010 { -+ 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; -+ vki_uint8_t onchangeonly; -+ } 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 { - vki_uint32_t op; -@@ -861,6 +912,7 @@ struct vki_xen_domctl { - 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; - -From 3f19cef2fc9eda416acc5706d0de1e802b60ccda Mon Sep 17 00:00:00 2001 -From: Olaf Hering -Date: Tue, 20 Nov 2018 11:05:35 +0100 -Subject: [PATCH 70/75] xen-4.11: add IOCTL_PRIVCMD_MMAP_RESOURCE - -Add define for IOCTL_PRIVCMD_MMAP_RESOURCE - -bz#390553 ---- - coregrind/m_syswrap/syswrap-linux.c | 17 +++++++++++++++++ - include/vki/vki-linux.h | 9 +++++++++ - 2 files changed, 26 insertions(+) - -diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c -index c8f72de74..59e07b82b 100644 ---- a/coregrind/m_syswrap/syswrap-linux.c -+++ b/coregrind/m_syswrap/syswrap-linux.c -@@ -8230,6 +8230,23 @@ PRE(sys_ioctl) - (Addr)args->ubufs, sizeof(*(args->ubufs)) * args->num); - 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_EVTCHN_BIND_VIRQ: { - struct vki_xen_ioctl_evtchn_bind_virq *args = -diff --git a/include/vki/vki-linux.h b/include/vki/vki-linux.h -index 0a0b5c2c1..4aa2ec819 100644 ---- a/include/vki/vki-linux.h -+++ b/include/vki/vki-linux.h -@@ -3395,6 +3395,14 @@ struct vki_xen_privcmd_dm_op { - 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)) -@@ -3404,6 +3412,7 @@ struct vki_xen_privcmd_dm_op { - - #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)) - - //---------------------------------------------------------------------- - // Xen evtchn IOCTL - -From 3e77d31513b2e0445e86eeed4ab8a5cdbae255c1 Mon Sep 17 00:00:00 2001 -From: Olaf Hering -Date: Tue, 20 Nov 2018 11:29:14 +0100 -Subject: [PATCH 71/75] xen-4.12: sysctl value - -Add 0x12 as sysctl value of xen-4.12 - -bz#390553 ---- - coregrind/m_syswrap/syswrap-xen.c | 2 ++ - include/vki/vki-xen-sysctl.h | 1 + - 2 files changed, 3 insertions(+) - -diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c -index ae89afd08..766ca02c4 100644 ---- a/coregrind/m_syswrap/syswrap-xen.c -+++ b/coregrind/m_syswrap/syswrap-xen.c -@@ -601,6 +601,7 @@ PRE(sysctl) { - case 0x0000000f: - case 0x00000010: - case 0x00000011: -+ case 0x00000012: - break; - default: - bad_intf_version(tid, layout, arrghs, status, flags, -@@ -1924,6 +1925,7 @@ POST(sysctl) - case 0x0000000f: - case 0x00000010: - case 0x00000011: -+ case 0x00000012: - break; - default: - return; -diff --git a/include/vki/vki-xen-sysctl.h b/include/vki/vki-xen-sysctl.h -index f68ba3610..bf9cadda8 100644 ---- a/include/vki/vki-xen-sysctl.h -+++ b/include/vki/vki-xen-sysctl.h -@@ -15,6 +15,7 @@ - * - 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 - -From 0940be9b2ec78b9994672a85f1020b700f706b96 Mon Sep 17 00:00:00 2001 -From: Olaf Hering -Date: Tue, 20 Nov 2018 11:58:21 +0100 -Subject: [PATCH 72/75] xen-4.12 get_cpu_policy - ---- - include/vki/vki-xen-sysctl.h | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/include/vki/vki-xen-sysctl.h b/include/vki/vki-xen-sysctl.h -index bf9cadda8..5f5e78008 100644 ---- a/include/vki/vki-xen-sysctl.h -+++ b/include/vki/vki-xen-sysctl.h -@@ -55,6 +55,7 @@ - #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 */ -@@ -278,6 +279,7 @@ struct vki_xen_sysctl { - 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; - -From 68a2ad9886180d27702e967bf718e5f71ee8341a Mon Sep 17 00:00:00 2001 -From: Olaf Hering -Date: Tue, 20 Nov 2018 12:07:18 +0100 -Subject: [PATCH 73/75] xen-4.12: IOCTL_PRIVCMD_UNIMPLEMENTED - ---- - coregrind/m_syswrap/syswrap-linux.c | 2 ++ - include/vki/vki-linux.h | 1 + - 2 files changed, 3 insertions(+) - -diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c -index 59e07b82b..f079c5ea9 100644 ---- a/coregrind/m_syswrap/syswrap-linux.c -+++ b/coregrind/m_syswrap/syswrap-linux.c -@@ -8247,6 +8247,8 @@ PRE(sys_ioctl) - (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 = -diff --git a/include/vki/vki-linux.h b/include/vki/vki-linux.h -index 4aa2ec819..f5ae9b45d 100644 ---- a/include/vki/vki-linux.h -+++ b/include/vki/vki-linux.h -@@ -3413,6 +3413,7 @@ struct vki_xen_privcmd_mmap_resource { - #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 - -From bd001c940edf89b00441f2401e29e3acfc3fdd2e Mon Sep 17 00:00:00 2001 -From: Olaf Hering -Date: Wed, 21 Nov 2018 10:33:21 +0100 -Subject: [PATCH 74/75] xen-4.12: domctl - ---- - coregrind/m_syswrap/syswrap-xen.c | 2 ++ - include/vki/vki-xen-domctl.h | 1 + - 2 files changed, 3 insertions(+) - -diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c -index 766ca02c4..f17cae23b 100644 ---- a/coregrind/m_syswrap/syswrap-xen.c -+++ b/coregrind/m_syswrap/syswrap-xen.c -@@ -799,6 +799,7 @@ PRE(domctl) - case 0x0000000e: - case 0x0000000f: - case 0x00000010: -+ case 0x00000011: - break; - default: - bad_intf_version(tid, layout, arrghs, status, flags, -@@ -2149,6 +2150,7 @@ POST(domctl){ - case 0x0000000e: - case 0x0000000f: - case 0x00000010: -+ case 0x00000011: - break; - default: - return; -diff --git a/include/vki/vki-xen-domctl.h b/include/vki/vki-xen-domctl.h -index c5936cc76..fa62c2fc6 100644 ---- a/include/vki/vki-xen-domctl.h -+++ b/include/vki/vki-xen-domctl.h -@@ -42,6 +42,7 @@ - * - 0x0000000e: Xen 4.10 - * - 0x0000000f: Xen 4.10 with shim - * - 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 - -From 7172c2bcd6b02d6e58aef653d520573fe3f96250 Mon Sep 17 00:00:00 2001 -From: Olaf Hering -Date: Wed, 21 Nov 2018 10:36:06 +0100 -Subject: [PATCH 75/75] xen-4.12 : xen_domctl_createdomain - -Signed-off-by: Olaf Hering ---- - coregrind/m_syswrap/syswrap-xen.c | 19 ++++++++++++++++++- - include/vki/vki-xen-domctl.h | 13 +++++++++++++ - 2 files changed, 31 insertions(+), 1 deletion(-) - -diff --git a/coregrind/m_syswrap/syswrap-xen.c b/coregrind/m_syswrap/syswrap-xen.c -index f17cae23b..77e9ff6c3 100644 ---- a/coregrind/m_syswrap/syswrap-xen.c -+++ b/coregrind/m_syswrap/syswrap-xen.c -@@ -850,7 +850,6 @@ PRE(domctl) - #endif - break; - case 0x0000000c: -- default: - PRE_XEN_DOMCTL_READ(createdomain_0000000c, ssidref); - PRE_XEN_DOMCTL_READ(createdomain_0000000c, handle); - PRE_XEN_DOMCTL_READ(createdomain_0000000c, flags); -@@ -862,6 +861,24 @@ PRE(domctl) - __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: -+ default: -+ 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; - -diff --git a/include/vki/vki-xen-domctl.h b/include/vki/vki-xen-domctl.h -index fa62c2fc6..699b7dd27 100644 ---- a/include/vki/vki-xen-domctl.h -+++ b/include/vki/vki-xen-domctl.h -@@ -187,6 +187,18 @@ struct vki_xen_domctl_createdomain_0000000c { - 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; -@@ -844,6 +856,7 @@ struct vki_xen_domctl { - struct vki_xen_domctl_createdomain_0000000a createdomain_0000000a; - struct vki_xen_domctl_createdomain_0000000b createdomain_0000000b; - struct vki_xen_domctl_createdomain_0000000c createdomain_0000000c; -+ struct vki_xen_domctl_createdomain_00000011 createdomain_00000011; - //struct vki_xen_domctl_arm_configuredomain configuredomain; - struct vki_xen_domctl_getdomaininfo_00000007 getdomaininfo_00000007; - struct vki_xen_domctl_getdomaininfo_00000008 getdomaininfo_00000008; From e62f4ba5e8b4443e9b4ead20988139bf23ce0218770b1356ad82027b7c6eafd1 Mon Sep 17 00:00:00 2001 From: Dirk Mueller Date: Mon, 26 Nov 2018 14:10:40 +0000 Subject: [PATCH 13/13] OBS-URL: https://build.opensuse.org/package/show/devel:tools/valgrind?expand=0&rev=185 --- valgrind.spec | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/valgrind.spec b/valgrind.spec index c2cab84..13fe772 100644 --- a/valgrind.spec +++ b/valgrind.spec @@ -169,10 +169,13 @@ 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 @@ -285,7 +288,6 @@ VALGRIND_LIB=$PWD/.in_place VALGRIND_LIB_INNER=$PWD/.in_place ./coregrind/valgri %{_libdir}/valgrind/s390x-vx-linux-valgrind.xml %{_libdir}/valgrind/s390x-vx-linux.xml - %files devel %{_libdir}/valgrind/lib*.a %{_includedir}/valgrind