Commit 2896b80e authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for-linus-4.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/uml

Pull UML updates from Richard Weinberger:

 - minor improvements

 - fixes for Debian's new gcc defaults (pie enabled by default)

 - fixes for XSTATE/XSAVE to make UML work again on modern systems

* 'for-linus-4.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/uml:
  um: return negative in tuntap_open_tramp()
  um: remove a stray tab
  um: Use relative modversions with LD_SCRIPT_DYN
  um: link vmlinux with -no-pie
  um: Fix CONFIG_GCOV for modules.
  Fix minor typos and grammar in UML start_up help
  um: defconfig: Cleanup from old Kconfig options
  um: Fix FP register size for XSTATE/XSAVE
parents 48bddb14 6d20e6b2
...@@ -20,6 +20,7 @@ config LD_SCRIPT_DYN ...@@ -20,6 +20,7 @@ config LD_SCRIPT_DYN
bool bool
default y default y
depends on !LD_SCRIPT_STATIC depends on !LD_SCRIPT_STATIC
select MODULE_REL_CRCS if MODVERSIONS
source "fs/Kconfig.binfmt" source "fs/Kconfig.binfmt"
......
...@@ -121,7 +121,7 @@ archheaders: ...@@ -121,7 +121,7 @@ archheaders:
archprepare: include/generated/user_constants.h archprepare: include/generated/user_constants.h
LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static
LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib $(call cc-option, -no-pie)
CFLAGS_NO_HARDENING := $(call cc-option, -fno-PIC,) $(call cc-option, -fno-pic,) \ CFLAGS_NO_HARDENING := $(call cc-option, -fno-PIC,) $(call cc-option, -fno-pic,) \
$(call cc-option, -fno-stack-protector,) \ $(call cc-option, -fno-stack-protector,) \
......
...@@ -53,7 +53,6 @@ CONFIG_NET=y ...@@ -53,7 +53,6 @@ CONFIG_NET=y
CONFIG_PACKET=y CONFIG_PACKET=y
CONFIG_UNIX=y CONFIG_UNIX=y
CONFIG_INET=y CONFIG_INET=y
# CONFIG_INET_LRO is not set
# CONFIG_IPV6 is not set # CONFIG_IPV6 is not set
CONFIG_UML_NET=y CONFIG_UML_NET=y
CONFIG_UML_NET_ETHERTAP=y CONFIG_UML_NET_ETHERTAP=y
......
...@@ -51,7 +51,6 @@ CONFIG_NET=y ...@@ -51,7 +51,6 @@ CONFIG_NET=y
CONFIG_PACKET=y CONFIG_PACKET=y
CONFIG_UNIX=y CONFIG_UNIX=y
CONFIG_INET=y CONFIG_INET=y
# CONFIG_INET_LRO is not set
# CONFIG_IPV6 is not set # CONFIG_IPV6 is not set
CONFIG_UML_NET=y CONFIG_UML_NET=y
CONFIG_UML_NET_ETHERTAP=y CONFIG_UML_NET_ETHERTAP=y
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <asm/types.h> #include <asm/types.h>
#include <asm/page.h> #include <asm/page.h>
#include <asm/segment.h> #include <asm/segment.h>
#include <sysdep/ptrace_user.h>
struct thread_info { struct thread_info {
struct task_struct *task; /* main task structure */ struct task_struct *task; /* main task structure */
...@@ -22,6 +23,8 @@ struct thread_info { ...@@ -22,6 +23,8 @@ struct thread_info {
0-0xBFFFFFFF for user 0-0xBFFFFFFF for user
0-0xFFFFFFFF for kernel */ 0-0xFFFFFFFF for kernel */
struct thread_info *real_thread; /* Points to non-IRQ stack */ struct thread_info *real_thread; /* Points to non-IRQ stack */
unsigned long aux_fp_regs[FP_SIZE]; /* auxiliary fp_regs to save/restore
them out-of-band */
}; };
#define INIT_THREAD_INFO(tsk) \ #define INIT_THREAD_INFO(tsk) \
......
...@@ -278,7 +278,7 @@ extern int protect(struct mm_id * mm_idp, unsigned long addr, ...@@ -278,7 +278,7 @@ extern int protect(struct mm_id * mm_idp, unsigned long addr,
extern int is_skas_winch(int pid, int fd, void *data); extern int is_skas_winch(int pid, int fd, void *data);
extern int start_userspace(unsigned long stub_stack); extern int start_userspace(unsigned long stub_stack);
extern int copy_context_skas0(unsigned long stack, int pid); extern int copy_context_skas0(unsigned long stack, int pid);
extern void userspace(struct uml_pt_regs *regs); extern void userspace(struct uml_pt_regs *regs, unsigned long *aux_fp_regs);
extern int map_stub_pages(int fd, unsigned long code, unsigned long data, extern int map_stub_pages(int fd, unsigned long code, unsigned long data,
unsigned long stack); unsigned long stack);
extern void new_thread(void *stack, jmp_buf *buf, void (*handler)(void)); extern void new_thread(void *stack, jmp_buf *buf, void (*handler)(void));
......
...@@ -7,3 +7,10 @@ ...@@ -7,3 +7,10 @@
extern void __bb_init_func(void *) __attribute__((weak)); extern void __bb_init_func(void *) __attribute__((weak));
EXPORT_SYMBOL(__bb_init_func); EXPORT_SYMBOL(__bb_init_func);
extern void __gcov_init(void *) __attribute__((weak));
EXPORT_SYMBOL(__gcov_init);
extern void __gcov_merge_add(void *, unsigned int) __attribute__((weak));
EXPORT_SYMBOL(__gcov_merge_add);
extern void __gcov_exit(void) __attribute__((weak));
EXPORT_SYMBOL(__gcov_exit);
...@@ -131,7 +131,7 @@ void new_thread_handler(void) ...@@ -131,7 +131,7 @@ void new_thread_handler(void)
* callback returns only if the kernel thread execs a process * callback returns only if the kernel thread execs a process
*/ */
n = fn(arg); n = fn(arg);
userspace(&current->thread.regs.regs); userspace(&current->thread.regs.regs, current_thread_info()->aux_fp_regs);
} }
/* Called magically, see new_thread_handler above */ /* Called magically, see new_thread_handler above */
...@@ -150,7 +150,7 @@ void fork_handler(void) ...@@ -150,7 +150,7 @@ void fork_handler(void)
current->thread.prev_sched = NULL; current->thread.prev_sched = NULL;
userspace(&current->thread.regs.regs); userspace(&current->thread.regs.regs, current_thread_info()->aux_fp_regs);
} }
int copy_thread(unsigned long clone_flags, unsigned long sp, int copy_thread(unsigned long clone_flags, unsigned long sp,
......
...@@ -80,7 +80,7 @@ static int tuntap_open_tramp(char *gate, int *fd_out, int me, int remote, ...@@ -80,7 +80,7 @@ static int tuntap_open_tramp(char *gate, int *fd_out, int me, int remote,
pid = run_helper(tuntap_pre_exec, &data, argv); pid = run_helper(tuntap_pre_exec, &data, argv);
if (pid < 0) if (pid < 0)
return -pid; return pid;
close(remote); close(remote);
......
...@@ -88,12 +88,11 @@ void wait_stub_done(int pid) ...@@ -88,12 +88,11 @@ void wait_stub_done(int pid)
extern unsigned long current_stub_stack(void); extern unsigned long current_stub_stack(void);
static void get_skas_faultinfo(int pid, struct faultinfo *fi) static void get_skas_faultinfo(int pid, struct faultinfo *fi, unsigned long *aux_fp_regs)
{ {
int err; int err;
unsigned long fpregs[FP_SIZE];
err = get_fp_registers(pid, fpregs); err = get_fp_registers(pid, aux_fp_regs);
if (err < 0) { if (err < 0) {
printk(UM_KERN_ERR "save_fp_registers returned %d\n", printk(UM_KERN_ERR "save_fp_registers returned %d\n",
err); err);
...@@ -113,7 +112,7 @@ static void get_skas_faultinfo(int pid, struct faultinfo *fi) ...@@ -113,7 +112,7 @@ static void get_skas_faultinfo(int pid, struct faultinfo *fi)
*/ */
memcpy(fi, (void *)current_stub_stack(), sizeof(*fi)); memcpy(fi, (void *)current_stub_stack(), sizeof(*fi));
err = put_fp_registers(pid, fpregs); err = put_fp_registers(pid, aux_fp_regs);
if (err < 0) { if (err < 0) {
printk(UM_KERN_ERR "put_fp_registers returned %d\n", printk(UM_KERN_ERR "put_fp_registers returned %d\n",
err); err);
...@@ -121,9 +120,9 @@ static void get_skas_faultinfo(int pid, struct faultinfo *fi) ...@@ -121,9 +120,9 @@ static void get_skas_faultinfo(int pid, struct faultinfo *fi)
} }
} }
static void handle_segv(int pid, struct uml_pt_regs * regs) static void handle_segv(int pid, struct uml_pt_regs *regs, unsigned long *aux_fp_regs)
{ {
get_skas_faultinfo(pid, &regs->faultinfo); get_skas_faultinfo(pid, &regs->faultinfo, aux_fp_regs);
segv(regs->faultinfo, 0, 1, NULL); segv(regs->faultinfo, 0, 1, NULL);
} }
...@@ -332,7 +331,7 @@ int start_userspace(unsigned long stub_stack) ...@@ -332,7 +331,7 @@ int start_userspace(unsigned long stub_stack)
return err; return err;
} }
void userspace(struct uml_pt_regs *regs) void userspace(struct uml_pt_regs *regs, unsigned long *aux_fp_regs)
{ {
int err, status, op, pid = userspace_pid[0]; int err, status, op, pid = userspace_pid[0];
/* To prevent races if using_sysemu changes under us.*/ /* To prevent races if using_sysemu changes under us.*/
...@@ -407,11 +406,11 @@ void userspace(struct uml_pt_regs *regs) ...@@ -407,11 +406,11 @@ void userspace(struct uml_pt_regs *regs)
case SIGSEGV: case SIGSEGV:
if (PTRACE_FULL_FAULTINFO) { if (PTRACE_FULL_FAULTINFO) {
get_skas_faultinfo(pid, get_skas_faultinfo(pid,
&regs->faultinfo); &regs->faultinfo, aux_fp_regs);
(*sig_info[SIGSEGV])(SIGSEGV, (struct siginfo *)&si, (*sig_info[SIGSEGV])(SIGSEGV, (struct siginfo *)&si,
regs); regs);
} }
else handle_segv(pid, regs); else handle_segv(pid, regs, aux_fp_regs);
break; break;
case SIGTRAP + 0x80: case SIGTRAP + 0x80:
handle_trap(pid, regs, local_using_sysemu); handle_trap(pid, regs, local_using_sysemu);
......
...@@ -154,10 +154,10 @@ static int __init nosysemu_cmd_param(char *str, int* add) ...@@ -154,10 +154,10 @@ static int __init nosysemu_cmd_param(char *str, int* add)
__uml_setup("nosysemu", nosysemu_cmd_param, __uml_setup("nosysemu", nosysemu_cmd_param,
"nosysemu\n" "nosysemu\n"
" Turns off syscall emulation patch for ptrace (SYSEMU) on.\n" " Turns off syscall emulation patch for ptrace (SYSEMU).\n"
" SYSEMU is a performance-patch introduced by Laurent Vivier. It changes\n" " SYSEMU is a performance-patch introduced by Laurent Vivier. It changes\n"
" behaviour of ptrace() and helps reducing host context switch rate.\n" " behaviour of ptrace() and helps reduce host context switch rates.\n"
" To make it working, you need a kernel patch for your host, too.\n" " To make it work, you need a kernel patch for your host, too.\n"
" See http://perso.wanadoo.fr/laurent.vivier/UML/ for further \n" " See http://perso.wanadoo.fr/laurent.vivier/UML/ for further \n"
" information.\n\n"); " information.\n\n");
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
*/ */
#include <errno.h> #include <errno.h>
#include <stdlib.h>
#include <sys/ptrace.h> #include <sys/ptrace.h>
#ifdef __i386__ #ifdef __i386__
#include <sys/user.h> #include <sys/user.h>
...@@ -31,7 +32,7 @@ int save_fp_registers(int pid, unsigned long *fp_regs) ...@@ -31,7 +32,7 @@ int save_fp_registers(int pid, unsigned long *fp_regs)
if (have_xstate_support) { if (have_xstate_support) {
iov.iov_base = fp_regs; iov.iov_base = fp_regs;
iov.iov_len = sizeof(struct _xstate); iov.iov_len = FP_SIZE * sizeof(unsigned long);
if (ptrace(PTRACE_GETREGSET, pid, NT_X86_XSTATE, &iov) < 0) if (ptrace(PTRACE_GETREGSET, pid, NT_X86_XSTATE, &iov) < 0)
return -errno; return -errno;
return 0; return 0;
...@@ -51,10 +52,9 @@ int restore_fp_registers(int pid, unsigned long *fp_regs) ...@@ -51,10 +52,9 @@ int restore_fp_registers(int pid, unsigned long *fp_regs)
{ {
#ifdef PTRACE_SETREGSET #ifdef PTRACE_SETREGSET
struct iovec iov; struct iovec iov;
if (have_xstate_support) { if (have_xstate_support) {
iov.iov_base = fp_regs; iov.iov_base = fp_regs;
iov.iov_len = sizeof(struct _xstate); iov.iov_len = FP_SIZE * sizeof(unsigned long);
if (ptrace(PTRACE_SETREGSET, pid, NT_X86_XSTATE, &iov) < 0) if (ptrace(PTRACE_SETREGSET, pid, NT_X86_XSTATE, &iov) < 0)
return -errno; return -errno;
return 0; return 0;
...@@ -125,13 +125,19 @@ int put_fp_registers(int pid, unsigned long *regs) ...@@ -125,13 +125,19 @@ int put_fp_registers(int pid, unsigned long *regs)
void arch_init_registers(int pid) void arch_init_registers(int pid)
{ {
#ifdef PTRACE_GETREGSET #ifdef PTRACE_GETREGSET
struct _xstate fp_regs; void * fp_regs;
struct iovec iov; struct iovec iov;
iov.iov_base = &fp_regs; fp_regs = malloc(FP_SIZE * sizeof(unsigned long));
iov.iov_len = sizeof(struct _xstate); if(fp_regs == NULL)
return;
iov.iov_base = fp_regs;
iov.iov_len = FP_SIZE * sizeof(unsigned long);
if (ptrace(PTRACE_GETREGSET, pid, NT_X86_XSTATE, &iov) == 0) if (ptrace(PTRACE_GETREGSET, pid, NT_X86_XSTATE, &iov) == 0)
have_xstate_support = 1; have_xstate_support = 1;
free(fp_regs);
#endif #endif
} }
#endif #endif
......
...@@ -51,7 +51,7 @@ void foo(void) ...@@ -51,7 +51,7 @@ void foo(void)
DEFINE(HOST_ORIG_AX, ORIG_EAX); DEFINE(HOST_ORIG_AX, ORIG_EAX);
#else #else
#ifdef FP_XSTATE_MAGIC1 #ifdef FP_XSTATE_MAGIC1
DEFINE(HOST_FP_SIZE, sizeof(struct _xstate) / sizeof(unsigned long)); DEFINE_LONGS(HOST_FP_SIZE, 2696);
#else #else
DEFINE(HOST_FP_SIZE, sizeof(struct _fpstate) / sizeof(unsigned long)); DEFINE(HOST_FP_SIZE, sizeof(struct _fpstate) / sizeof(unsigned long));
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment