2 * Copyright (c) 2014-2015 Dmitry V. Levin <ldv@altlinux.org>
3 * Copyright (c) 2014-2017 The strace developers.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #include "xlat/kexec_load_flags.h"
32 #include "xlat/kexec_arch_values.h"
34 #ifndef KEXEC_ARCH_MASK
35 # define KEXEC_ARCH_MASK 0xffff0000
37 #ifndef KEXEC_SEGMENT_MAX
38 # define KEXEC_SEGMENT_MAX 16
42 print_seg(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data)
44 const kernel_ulong_t *seg;
45 kernel_ulong_t seg_buf[4];
47 if (elem_size < sizeof(seg_buf)) {
50 for (i = 0; i < ARRAY_SIZE(seg_buf); ++i)
51 seg_buf[i] = ((unsigned int *) elem_buf)[i];
59 tprintf(", bufsz=%" PRI_klu ", mem=", seg[1]);
61 tprintf(", memsz=%" PRI_klu "}", seg[3]);
67 print_kexec_segments(struct tcb *const tcp, const kernel_ulong_t addr,
68 const kernel_ulong_t len)
70 if (len > KEXEC_SEGMENT_MAX) {
75 kernel_ulong_t seg[4];
76 const size_t sizeof_seg = ARRAY_SIZE(seg) * current_wordsize;
78 print_array(tcp, addr, len, seg, sizeof_seg,
79 umoven_or_printaddr, print_seg, 0);
84 /* entry, nr_segments */
85 printaddr(tcp->u_arg[0]);
86 tprintf(", %" PRI_klu ", ", tcp->u_arg[1]);
89 print_kexec_segments(tcp, tcp->u_arg[2], tcp->u_arg[1]);
93 kernel_ulong_t n = tcp->u_arg[3];
94 printxval64(kexec_arch_values, n & KEXEC_ARCH_MASK, "KEXEC_ARCH_???");
95 n &= ~(kernel_ulong_t) KEXEC_ARCH_MASK;
98 printflags64(kexec_load_flags, n, "KEXEC_???");
104 #include "xlat/kexec_file_load_flags.h"
106 SYS_FUNC(kexec_file_load)
109 printfd(tcp, tcp->u_arg[0]);
112 printfd(tcp, tcp->u_arg[1]);
115 tprintf("%" PRI_klu ", ", tcp->u_arg[2]);
117 printstrn(tcp, tcp->u_arg[3], tcp->u_arg[2]);
120 printflags64(kexec_file_load_flags, tcp->u_arg[4], "KEXEC_FILE_???");