Branch data Line data Source code
1 : : /*
2 : : * Copyright (c) 2014-2015 Dmitry V. Levin <ldv@altlinux.org>
3 : : * All rights reserved.
4 : : *
5 : : * Redistribution and use in source and binary forms, with or without
6 : : * modification, are permitted provided that the following conditions
7 : : * are met:
8 : : * 1. Redistributions of source code must retain the above copyright
9 : : * notice, this list of conditions and the following disclaimer.
10 : : * 2. Redistributions in binary form must reproduce the above copyright
11 : : * notice, this list of conditions and the following disclaimer in the
12 : : * documentation and/or other materials provided with the distribution.
13 : : * 3. The name of the author may not be used to endorse or promote products
14 : : * derived from this software without specific prior written permission.
15 : : *
16 : : * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 : : * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 : : * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 : : * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 : : * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 : : * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 : : * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 : : * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 : : * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 : : * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 : : */
27 : :
28 : : #include "defs.h"
29 : :
30 : : #include "xlat/kexec_load_flags.h"
31 : : #include "xlat/kexec_arch_values.h"
32 : :
33 : : #ifndef KEXEC_ARCH_MASK
34 : : # define KEXEC_ARCH_MASK 0xffff0000
35 : : #endif
36 : : #ifndef KEXEC_SEGMENT_MAX
37 : : # define KEXEC_SEGMENT_MAX 16
38 : : #endif
39 : :
40 : : static bool
41 : 192 : print_seg(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data)
42 : : {
43 : : const kernel_ulong_t *seg;
44 : : kernel_ulong_t seg_buf[4];
45 : :
46 [ + + ]: 192 : if (elem_size < sizeof(seg_buf)) {
47 : : unsigned int i;
48 : :
49 [ + + ]: 160 : for (i = 0; i < ARRAY_SIZE(seg_buf); ++i)
50 : 128 : seg_buf[i] = ((unsigned int *) elem_buf)[i];
51 : 32 : seg = seg_buf;
52 : : } else {
53 : 160 : seg = elem_buf;
54 : : }
55 : :
56 : 192 : tprints("{buf=");
57 : 192 : printaddr(seg[0]);
58 : 192 : tprintf(", bufsz=%" PRI_klu ", mem=", seg[1]);
59 : 192 : printaddr(seg[2]);
60 : 192 : tprintf(", memsz=%" PRI_klu "}", seg[3]);
61 : :
62 : 192 : return true;
63 : : }
64 : :
65 : : static void
66 : 42 : print_kexec_segments(struct tcb *const tcp, const kernel_ulong_t addr,
67 : : const kernel_ulong_t len)
68 : : {
69 [ + + ]: 42 : if (len > KEXEC_SEGMENT_MAX) {
70 : 12 : printaddr(addr);
71 : 12 : return;
72 : : }
73 : :
74 : : kernel_ulong_t seg[4];
75 : 30 : const size_t sizeof_seg = ARRAY_SIZE(seg) * current_wordsize;
76 : :
77 : 30 : print_array(tcp, addr, len, seg, sizeof_seg,
78 : : umoven_or_printaddr, print_seg, 0);
79 : : }
80 : :
81 : 42 : SYS_FUNC(kexec_load)
82 : : {
83 : : /* entry, nr_segments */
84 : 42 : printaddr(tcp->u_arg[0]);
85 : 42 : tprintf(", %" PRI_klu ", ", tcp->u_arg[1]);
86 : :
87 : : /* segments */
88 : 42 : print_kexec_segments(tcp, tcp->u_arg[2], tcp->u_arg[1]);
89 : 42 : tprints(", ");
90 : :
91 : : /* flags */
92 : 42 : kernel_ulong_t n = tcp->u_arg[3];
93 : 42 : printxval64(kexec_arch_values, n & KEXEC_ARCH_MASK, "KEXEC_ARCH_???");
94 : 42 : n &= ~(kernel_ulong_t) KEXEC_ARCH_MASK;
95 [ + + ]: 42 : if (n) {
96 : 24 : tprints("|");
97 : 24 : printflags64(kexec_load_flags, n, "KEXEC_???");
98 : : }
99 : :
100 : 42 : return RVAL_DECODED;
101 : : }
102 : :
103 : : #include "xlat/kexec_file_load_flags.h"
104 : :
105 : 105 : SYS_FUNC(kexec_file_load)
106 : : {
107 : : /* kernel_fd */
108 : 105 : printfd(tcp, tcp->u_arg[0]);
109 : 105 : tprints(", ");
110 : : /* initrd_fd */
111 : 105 : printfd(tcp, tcp->u_arg[1]);
112 : 105 : tprints(", ");
113 : : /* cmdline_len */
114 : 105 : tprintf("%" PRI_klu ", ", tcp->u_arg[2]);
115 : : /* cmdline */
116 : 105 : printstrn(tcp, tcp->u_arg[3], tcp->u_arg[2]);
117 : 105 : tprints(", ");
118 : : /* flags */
119 : 105 : printflags64(kexec_file_load_flags, tcp->u_arg[4], "KEXEC_FILE_???");
120 : :
121 : 105 : return RVAL_DECODED;
122 : : }
|