Skip to content

Commit

Permalink
Merge branch 'for-linus-4.13-rc1' of git://git.kernel.org/pub/scm/lin…
Browse files Browse the repository at this point in the history
…ux/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
  • Loading branch information
torvalds committed Jul 15, 2017
2 parents 966859b + 61e8d46 commit 4ecd4ff
Show file tree
Hide file tree
Showing 21 changed files with 201 additions and 82 deletions.
4 changes: 4 additions & 0 deletions arch/um/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,14 @@ KBUILD_CPPFLAGS += -I$(srctree)/$(HOST_DIR)/um
# Same things for in6addr_loopback and mktime - found in libc. For these two we
# only get link-time error, luckily.
#
# -Dlongjmp=kernel_longjmp prevents anything from referencing the libpthread.a
# embedded copy of longjmp, same thing for setjmp.
#
# These apply to USER_CFLAGS to.

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

Expand Down
3 changes: 3 additions & 0 deletions arch/um/drivers/stdio_console.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ __uml_exitcall(console_exit);

static int console_chan_setup(char *str)
{
if (!strncmp(str, "sole=", 5)) /* console= option specifies tty */
return 0;

line_setup(vt_conf, MAX_TTYS, &def_conf, str, "console");
return 1;
}
Expand Down
2 changes: 1 addition & 1 deletion arch/um/include/asm/common.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
PROVIDE (_unprotected_end = .);

. = ALIGN(4096);
.note : { *(.note.*) }
NOTES
EXCEPTION_TABLE(0)

BUG_TABLE
Expand Down
17 changes: 17 additions & 0 deletions arch/um/include/asm/io.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifndef _ASM_UM_IO_H
#define _ASM_UM_IO_H

#define ioremap ioremap
static inline void __iomem *ioremap(phys_addr_t offset, size_t size)
{
return (void __iomem *)(unsigned long)offset;
}

#define iounmap iounmap
static inline void iounmap(void __iomem *addr)
{
}

#include <asm-generic/io.h>

#endif
4 changes: 4 additions & 0 deletions arch/um/include/shared/os.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ extern void setup_hostinfo(char *buf, int len);
extern void os_dump_core(void) __attribute__ ((noreturn));
extern void um_early_printk(const char *s, unsigned int n);
extern void os_fix_helper_signals(void);
extern void os_info(const char *fmt, ...)
__attribute__ ((format (printf, 1, 2)));
extern void os_warn(const char *fmt, ...)
__attribute__ ((format (printf, 1, 2)));

/* time.c */
extern void os_idle_sleep(unsigned long long nsecs);
Expand Down
2 changes: 0 additions & 2 deletions arch/um/include/shared/skas/stub-data.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
#ifndef __STUB_DATA_H
#define __STUB_DATA_H

#include <time.h>

struct stub_data {
unsigned long offset;
int fd;
Expand Down
10 changes: 5 additions & 5 deletions arch/um/kernel/physmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ void __init setup_physmem(unsigned long start, unsigned long reserve_end,
offset = uml_reserved - uml_physmem;
map_size = len - offset;
if(map_size <= 0) {
printf("Too few physical memory! Needed=%d, given=%d\n",
offset, len);
os_warn("Too few physical memory! Needed=%lu, given=%lu\n",
offset, len);
exit(1);
}

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

Expand Down
10 changes: 10 additions & 0 deletions arch/um/kernel/trap.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,16 @@ void fatal_sigsegv(void)
os_dump_core();
}

/**
* segv_handler() - the SIGSEGV handler
* @sig: the signal number
* @unused_si: the signal info struct; unused in this handler
* @regs: the ptrace register information
*
* The handler first extracts the faultinfo from the UML ptrace regs struct.
* If the userfault did not happen in an UML userspace process, bad_segv is called.
* Otherwise the signal did happen in a cloned userspace process, handle it.
*/
void segv_handler(int sig, struct siginfo *unused_si, struct uml_pt_regs *regs)
{
struct faultinfo * fi = UPT_FAULTINFO(regs);
Expand Down
16 changes: 9 additions & 7 deletions arch/um/kernel/um_arch.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ static char __initdata command_line[COMMAND_LINE_SIZE] = { 0 };
static void __init add_arg(char *arg)
{
if (strlen(command_line) + strlen(arg) + 1 > COMMAND_LINE_SIZE) {
printf("add_arg: Too many command line arguments!\n");
os_warn("add_arg: Too many command line arguments!\n");
exit(1);
}
if (strlen(command_line) > 0)
Expand Down Expand Up @@ -120,6 +120,7 @@ static const char *usage_string =

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

Expand Down Expand Up @@ -148,8 +149,8 @@ __uml_setup("root=", uml_root_setup,

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

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

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

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

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

if (virtmem_size < physmem_size)
printf("Kernel virtual memory size shrunk to %lu bytes\n",
virtmem_size);
os_info("Kernel virtual memory size shrunk to %lu bytes\n",
virtmem_size);

os_flush_stdout();

Expand Down
4 changes: 2 additions & 2 deletions arch/um/kernel/umid.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ static int __init set_umid_arg(char *name, int *add)
int err;

if (umid_inited) {
printf("umid already set\n");
os_warn("umid already set\n");
return 0;
}

*add = 0;
err = set_umid(name);
if (err == -EEXIST)
printf("umid '%s' already in use\n", name);
os_warn("umid '%s' already in use\n", name);
else if (!err)
umid_inited = 1;

Expand Down
2 changes: 1 addition & 1 deletion arch/um/os-Linux/execvp.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ int main(int argc, char**argv)
int ret;
argc--;
if (!argc) {
fprintf(stderr, "Not enough arguments\n");
os_warn("Not enough arguments\n");
return 1;
}
argv++;
Expand Down
9 changes: 4 additions & 5 deletions arch/um/os-Linux/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ static void install_fatal_handler(int sig)
action.sa_restorer = NULL;
action.sa_handler = last_ditch_exit;
if (sigaction(sig, &action, NULL) < 0) {
printf("failed to install handler for signal %d - errno = %d\n",
sig, errno);
os_warn("failed to install handler for signal %d "
"- errno = %d\n", sig, errno);
exit(1);
}
}
Expand Down Expand Up @@ -175,7 +175,7 @@ int __init main(int argc, char **argv, char **envp)
/* disable SIGIO for the fds and set SIGIO to be ignored */
err = deactivate_all_fds();
if (err)
printf("deactivate_all_fds failed, errno = %d\n", -err);
os_warn("deactivate_all_fds failed, errno = %d\n", -err);

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

os_info("\n");
/* Reboot */
if (ret) {
printf("\n");
execvp(new_argv[0], new_argv);
perror("Failed to exec kernel");
ret = 1;
}
printf("\n");
return uml_exitcode;
}

Expand Down
28 changes: 14 additions & 14 deletions arch/um/os-Linux/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ static int __init check_tmpfs(const char *dir)
{
struct statfs st;

printf("Checking if %s is on tmpfs...", dir);
os_info("Checking if %s is on tmpfs...", dir);
if (statfs(dir, &st) < 0) {
printf("%s\n", strerror(errno));
os_info("%s\n", strerror(errno));
} else if (st.f_type != TMPFS_MAGIC) {
printf("no\n");
os_info("no\n");
} else {
printf("OK\n");
os_info("OK\n");
return 0;
}
return -1;
Expand Down Expand Up @@ -61,18 +61,18 @@ static char * __init choose_tempdir(void)
int i;
const char *dir;

printf("Checking environment variables for a tempdir...");
os_info("Checking environment variables for a tempdir...");
for (i = 0; vars[i]; i++) {
dir = getenv(vars[i]);
if ((dir != NULL) && (*dir != '\0')) {
printf("%s\n", dir);
os_info("%s\n", dir);
if (check_tmpfs(dir) >= 0)
goto done;
else
goto warn;
}
}
printf("none found\n");
os_info("none found\n");

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

dir = fallback_dir;
warn:
printf("Warning: tempdir %s is not on tmpfs\n", dir);
os_warn("Warning: tempdir %s is not on tmpfs\n", dir);
done:
/* Make a copy since getenv results may not remain valid forever. */
return strdup(dir);
Expand All @@ -100,7 +100,7 @@ static int __init make_tempfile(const char *template)
if (tempdir == NULL) {
tempdir = choose_tempdir();
if (tempdir == NULL) {
fprintf(stderr, "Failed to choose tempdir: %s\n",
os_warn("Failed to choose tempdir: %s\n",
strerror(errno));
return -1;
}
Expand All @@ -125,7 +125,7 @@ static int __init make_tempfile(const char *template)
strcat(tempname, template);
fd = mkstemp(tempname);
if (fd < 0) {
fprintf(stderr, "open - cannot create %s: %s\n", tempname,
os_warn("open - cannot create %s: %s\n", tempname,
strerror(errno));
goto out;
}
Expand Down Expand Up @@ -194,16 +194,16 @@ void __init check_tmpexec(void)

addr = mmap(NULL, UM_KERN_PAGE_SIZE,
PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE, fd, 0);
printf("Checking PROT_EXEC mmap in %s...", tempdir);
os_info("Checking PROT_EXEC mmap in %s...", tempdir);
if (addr == MAP_FAILED) {
err = errno;
printf("%s\n", strerror(err));
os_warn("%s\n", strerror(err));
close(fd);
if (err == EPERM)
printf("%s must be not mounted noexec\n", tempdir);
os_warn("%s must be not mounted noexec\n", tempdir);
exit(1);
}
printf("OK\n");
os_info("OK\n");
munmap(addr, UM_KERN_PAGE_SIZE);

close(fd);
Expand Down
Loading

0 comments on commit 4ecd4ff

Please sign in to comment.