Skip to content

Commit 4ecd4ff

Browse files
committed
Merge branch 'for-linus-4.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/uml
Pull UML updates from Richard Weinberger: "Mostly fixes for UML: - First round of fixes for PTRACE_GETRESET/SETREGSET - A printf vs printk cleanup - Minor improvements" * 'for-linus-4.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/uml: um: Correctly check for PTRACE_GETRESET/SETREGSET um: v2: Use generic NOTES macro um: Add kerneldoc for userspace_tramp() and start_userspace() um: Add kerneldoc for segv_handler um: stub-data.h: remove superfluous include um: userspace - be more verbose in ptrace set regs error um: add dummy ioremap and iounmap functions um: Allow building and running on older hosts um: Avoid longjmp/setjmp symbol clashes with libpthread.a um: console: Ignore console= option um: Use os_warn to print out pre-boot warning/error messages um: Add os_warn() for pre-boot warning/error messages um: Use os_info for the messages on normal path um: Add os_info() for pre-boot information messages um: Use printk instead of printf in make_uml_dir
2 parents 966859b + 61e8d46 commit 4ecd4ff

File tree

21 files changed

+201
-82
lines changed

21 files changed

+201
-82
lines changed

arch/um/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,14 @@ KBUILD_CPPFLAGS += -I$(srctree)/$(HOST_DIR)/um
5959
# Same things for in6addr_loopback and mktime - found in libc. For these two we
6060
# only get link-time error, luckily.
6161
#
62+
# -Dlongjmp=kernel_longjmp prevents anything from referencing the libpthread.a
63+
# embedded copy of longjmp, same thing for setjmp.
64+
#
6265
# These apply to USER_CFLAGS to.
6366

6467
KBUILD_CFLAGS += $(CFLAGS) $(CFLAGS-y) -D__arch_um__ \
6568
$(ARCH_INCLUDE) $(MODE_INCLUDE) -Dvmap=kernel_vmap \
69+
-Dlongjmp=kernel_longjmp -Dsetjmp=kernel_setjmp \
6670
-Din6addr_loopback=kernel_in6addr_loopback \
6771
-Din6addr_any=kernel_in6addr_any -Dstrrchr=kernel_strrchr
6872

arch/um/drivers/stdio_console.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,9 @@ __uml_exitcall(console_exit);
192192

193193
static int console_chan_setup(char *str)
194194
{
195+
if (!strncmp(str, "sole=", 5)) /* console= option specifies tty */
196+
return 0;
197+
195198
line_setup(vt_conf, MAX_TTYS, &def_conf, str, "console");
196199
return 1;
197200
}

arch/um/include/asm/common.lds.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
PROVIDE (_unprotected_end = .);
1616

1717
. = ALIGN(4096);
18-
.note : { *(.note.*) }
18+
NOTES
1919
EXCEPTION_TABLE(0)
2020

2121
BUG_TABLE

arch/um/include/asm/io.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#ifndef _ASM_UM_IO_H
2+
#define _ASM_UM_IO_H
3+
4+
#define ioremap ioremap
5+
static inline void __iomem *ioremap(phys_addr_t offset, size_t size)
6+
{
7+
return (void __iomem *)(unsigned long)offset;
8+
}
9+
10+
#define iounmap iounmap
11+
static inline void iounmap(void __iomem *addr)
12+
{
13+
}
14+
15+
#include <asm-generic/io.h>
16+
17+
#endif

arch/um/include/shared/os.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,10 @@ extern void setup_hostinfo(char *buf, int len);
242242
extern void os_dump_core(void) __attribute__ ((noreturn));
243243
extern void um_early_printk(const char *s, unsigned int n);
244244
extern void os_fix_helper_signals(void);
245+
extern void os_info(const char *fmt, ...)
246+
__attribute__ ((format (printf, 1, 2)));
247+
extern void os_warn(const char *fmt, ...)
248+
__attribute__ ((format (printf, 1, 2)));
245249

246250
/* time.c */
247251
extern void os_idle_sleep(unsigned long long nsecs);

arch/um/include/shared/skas/stub-data.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
#ifndef __STUB_DATA_H
99
#define __STUB_DATA_H
1010

11-
#include <time.h>
12-
1311
struct stub_data {
1412
unsigned long offset;
1513
int fd;

arch/um/kernel/physmem.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ void __init setup_physmem(unsigned long start, unsigned long reserve_end,
8989
offset = uml_reserved - uml_physmem;
9090
map_size = len - offset;
9191
if(map_size <= 0) {
92-
printf("Too few physical memory! Needed=%d, given=%d\n",
93-
offset, len);
92+
os_warn("Too few physical memory! Needed=%lu, given=%lu\n",
93+
offset, len);
9494
exit(1);
9595
}
9696

@@ -99,9 +99,9 @@ void __init setup_physmem(unsigned long start, unsigned long reserve_end,
9999
err = os_map_memory((void *) uml_reserved, physmem_fd, offset,
100100
map_size, 1, 1, 1);
101101
if (err < 0) {
102-
printf("setup_physmem - mapping %ld bytes of memory at 0x%p "
103-
"failed - errno = %d\n", map_size,
104-
(void *) uml_reserved, err);
102+
os_warn("setup_physmem - mapping %ld bytes of memory at 0x%p "
103+
"failed - errno = %d\n", map_size,
104+
(void *) uml_reserved, err);
105105
exit(1);
106106
}
107107

arch/um/kernel/trap.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,16 @@ void fatal_sigsegv(void)
183183
os_dump_core();
184184
}
185185

186+
/**
187+
* segv_handler() - the SIGSEGV handler
188+
* @sig: the signal number
189+
* @unused_si: the signal info struct; unused in this handler
190+
* @regs: the ptrace register information
191+
*
192+
* The handler first extracts the faultinfo from the UML ptrace regs struct.
193+
* If the userfault did not happen in an UML userspace process, bad_segv is called.
194+
* Otherwise the signal did happen in a cloned userspace process, handle it.
195+
*/
186196
void segv_handler(int sig, struct siginfo *unused_si, struct uml_pt_regs *regs)
187197
{
188198
struct faultinfo * fi = UPT_FAULTINFO(regs);

arch/um/kernel/um_arch.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ static char __initdata command_line[COMMAND_LINE_SIZE] = { 0 };
3434
static void __init add_arg(char *arg)
3535
{
3636
if (strlen(command_line) + strlen(arg) + 1 > COMMAND_LINE_SIZE) {
37-
printf("add_arg: Too many command line arguments!\n");
37+
os_warn("add_arg: Too many command line arguments!\n");
3838
exit(1);
3939
}
4040
if (strlen(command_line) > 0)
@@ -120,6 +120,7 @@ static const char *usage_string =
120120

121121
static int __init uml_version_setup(char *line, int *add)
122122
{
123+
/* Explicitly use printf() to show version in stdout */
123124
printf("%s\n", init_utsname()->release);
124125
exit(0);
125126

@@ -148,8 +149,8 @@ __uml_setup("root=", uml_root_setup,
148149

149150
static int __init no_skas_debug_setup(char *line, int *add)
150151
{
151-
printf("'debug' is not necessary to gdb UML in skas mode - run \n");
152-
printf("'gdb linux'\n");
152+
os_warn("'debug' is not necessary to gdb UML in skas mode - run\n");
153+
os_warn("'gdb linux'\n");
153154

154155
return 0;
155156
}
@@ -165,6 +166,7 @@ static int __init Usage(char *line, int *add)
165166

166167
printf(usage_string, init_utsname()->release);
167168
p = &__uml_help_start;
169+
/* Explicitly use printf() to show help in stdout */
168170
while (p < &__uml_help_end) {
169171
printf("%s", *p);
170172
p++;
@@ -283,8 +285,8 @@ int __init linux_main(int argc, char **argv)
283285

284286
diff = UML_ROUND_UP(brk_start) - UML_ROUND_UP(&_end);
285287
if (diff > 1024 * 1024) {
286-
printf("Adding %ld bytes to physical memory to account for "
287-
"exec-shield gap\n", diff);
288+
os_info("Adding %ld bytes to physical memory to account for "
289+
"exec-shield gap\n", diff);
288290
physmem_size += UML_ROUND_UP(brk_start) - UML_ROUND_UP(&_end);
289291
}
290292

@@ -324,8 +326,8 @@ int __init linux_main(int argc, char **argv)
324326
end_vm = start_vm + virtmem_size;
325327

326328
if (virtmem_size < physmem_size)
327-
printf("Kernel virtual memory size shrunk to %lu bytes\n",
328-
virtmem_size);
329+
os_info("Kernel virtual memory size shrunk to %lu bytes\n",
330+
virtmem_size);
329331

330332
os_flush_stdout();
331333

arch/um/kernel/umid.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ static int __init set_umid_arg(char *name, int *add)
1616
int err;
1717

1818
if (umid_inited) {
19-
printf("umid already set\n");
19+
os_warn("umid already set\n");
2020
return 0;
2121
}
2222

2323
*add = 0;
2424
err = set_umid(name);
2525
if (err == -EEXIST)
26-
printf("umid '%s' already in use\n", name);
26+
os_warn("umid '%s' already in use\n", name);
2727
else if (!err)
2828
umid_inited = 1;
2929

arch/um/os-Linux/execvp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ int main(int argc, char**argv)
136136
int ret;
137137
argc--;
138138
if (!argc) {
139-
fprintf(stderr, "Not enough arguments\n");
139+
os_warn("Not enough arguments\n");
140140
return 1;
141141
}
142142
argv++;

arch/um/os-Linux/main.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ static void install_fatal_handler(int sig)
7474
action.sa_restorer = NULL;
7575
action.sa_handler = last_ditch_exit;
7676
if (sigaction(sig, &action, NULL) < 0) {
77-
printf("failed to install handler for signal %d - errno = %d\n",
78-
sig, errno);
77+
os_warn("failed to install handler for signal %d "
78+
"- errno = %d\n", sig, errno);
7979
exit(1);
8080
}
8181
}
@@ -175,7 +175,7 @@ int __init main(int argc, char **argv, char **envp)
175175
/* disable SIGIO for the fds and set SIGIO to be ignored */
176176
err = deactivate_all_fds();
177177
if (err)
178-
printf("deactivate_all_fds failed, errno = %d\n", -err);
178+
os_warn("deactivate_all_fds failed, errno = %d\n", -err);
179179

180180
/*
181181
* Let any pending signals fire now. This ensures
@@ -184,14 +184,13 @@ int __init main(int argc, char **argv, char **envp)
184184
*/
185185
unblock_signals();
186186

187+
os_info("\n");
187188
/* Reboot */
188189
if (ret) {
189-
printf("\n");
190190
execvp(new_argv[0], new_argv);
191191
perror("Failed to exec kernel");
192192
ret = 1;
193193
}
194-
printf("\n");
195194
return uml_exitcode;
196195
}
197196

arch/um/os-Linux/mem.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ static int __init check_tmpfs(const char *dir)
2525
{
2626
struct statfs st;
2727

28-
printf("Checking if %s is on tmpfs...", dir);
28+
os_info("Checking if %s is on tmpfs...", dir);
2929
if (statfs(dir, &st) < 0) {
30-
printf("%s\n", strerror(errno));
30+
os_info("%s\n", strerror(errno));
3131
} else if (st.f_type != TMPFS_MAGIC) {
32-
printf("no\n");
32+
os_info("no\n");
3333
} else {
34-
printf("OK\n");
34+
os_info("OK\n");
3535
return 0;
3636
}
3737
return -1;
@@ -61,18 +61,18 @@ static char * __init choose_tempdir(void)
6161
int i;
6262
const char *dir;
6363

64-
printf("Checking environment variables for a tempdir...");
64+
os_info("Checking environment variables for a tempdir...");
6565
for (i = 0; vars[i]; i++) {
6666
dir = getenv(vars[i]);
6767
if ((dir != NULL) && (*dir != '\0')) {
68-
printf("%s\n", dir);
68+
os_info("%s\n", dir);
6969
if (check_tmpfs(dir) >= 0)
7070
goto done;
7171
else
7272
goto warn;
7373
}
7474
}
75-
printf("none found\n");
75+
os_info("none found\n");
7676

7777
for (i = 0; tmpfs_dirs[i]; i++) {
7878
dir = tmpfs_dirs[i];
@@ -82,7 +82,7 @@ static char * __init choose_tempdir(void)
8282

8383
dir = fallback_dir;
8484
warn:
85-
printf("Warning: tempdir %s is not on tmpfs\n", dir);
85+
os_warn("Warning: tempdir %s is not on tmpfs\n", dir);
8686
done:
8787
/* Make a copy since getenv results may not remain valid forever. */
8888
return strdup(dir);
@@ -100,7 +100,7 @@ static int __init make_tempfile(const char *template)
100100
if (tempdir == NULL) {
101101
tempdir = choose_tempdir();
102102
if (tempdir == NULL) {
103-
fprintf(stderr, "Failed to choose tempdir: %s\n",
103+
os_warn("Failed to choose tempdir: %s\n",
104104
strerror(errno));
105105
return -1;
106106
}
@@ -125,7 +125,7 @@ static int __init make_tempfile(const char *template)
125125
strcat(tempname, template);
126126
fd = mkstemp(tempname);
127127
if (fd < 0) {
128-
fprintf(stderr, "open - cannot create %s: %s\n", tempname,
128+
os_warn("open - cannot create %s: %s\n", tempname,
129129
strerror(errno));
130130
goto out;
131131
}
@@ -194,16 +194,16 @@ void __init check_tmpexec(void)
194194

195195
addr = mmap(NULL, UM_KERN_PAGE_SIZE,
196196
PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE, fd, 0);
197-
printf("Checking PROT_EXEC mmap in %s...", tempdir);
197+
os_info("Checking PROT_EXEC mmap in %s...", tempdir);
198198
if (addr == MAP_FAILED) {
199199
err = errno;
200-
printf("%s\n", strerror(err));
200+
os_warn("%s\n", strerror(err));
201201
close(fd);
202202
if (err == EPERM)
203-
printf("%s must be not mounted noexec\n", tempdir);
203+
os_warn("%s must be not mounted noexec\n", tempdir);
204204
exit(1);
205205
}
206-
printf("OK\n");
206+
os_info("OK\n");
207207
munmap(addr, UM_KERN_PAGE_SIZE);
208208

209209
close(fd);

0 commit comments

Comments
 (0)