Skip to content

Commit 2896b80

Browse files
committed
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
2 parents 48bddb1 + 6d20e6b commit 2896b80

File tree

14 files changed

+41
-27
lines changed

14 files changed

+41
-27
lines changed

arch/um/Kconfig.um

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ config LD_SCRIPT_DYN
2020
bool
2121
default y
2222
depends on !LD_SCRIPT_STATIC
23+
select MODULE_REL_CRCS if MODVERSIONS
2324

2425
source "fs/Kconfig.binfmt"
2526

arch/um/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ archheaders:
121121
archprepare: include/generated/user_constants.h
122122

123123
LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static
124-
LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib
124+
LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib $(call cc-option, -no-pie)
125125

126126
CFLAGS_NO_HARDENING := $(call cc-option, -fno-PIC,) $(call cc-option, -fno-pic,) \
127127
$(call cc-option, -fno-stack-protector,) \

arch/um/configs/i386_defconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ CONFIG_NET=y
5353
CONFIG_PACKET=y
5454
CONFIG_UNIX=y
5555
CONFIG_INET=y
56-
# CONFIG_INET_LRO is not set
5756
# CONFIG_IPV6 is not set
5857
CONFIG_UML_NET=y
5958
CONFIG_UML_NET_ETHERTAP=y

arch/um/configs/x86_64_defconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ CONFIG_NET=y
5151
CONFIG_PACKET=y
5252
CONFIG_UNIX=y
5353
CONFIG_INET=y
54-
# CONFIG_INET_LRO is not set
5554
# CONFIG_IPV6 is not set
5655
CONFIG_UML_NET=y
5756
CONFIG_UML_NET_ETHERTAP=y

arch/um/include/asm/thread_info.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <asm/types.h>
1212
#include <asm/page.h>
1313
#include <asm/segment.h>
14+
#include <sysdep/ptrace_user.h>
1415

1516
struct thread_info {
1617
struct task_struct *task; /* main task structure */
@@ -22,6 +23,8 @@ struct thread_info {
2223
0-0xBFFFFFFF for user
2324
0-0xFFFFFFFF for kernel */
2425
struct thread_info *real_thread; /* Points to non-IRQ stack */
26+
unsigned long aux_fp_regs[FP_SIZE]; /* auxiliary fp_regs to save/restore
27+
them out-of-band */
2528
};
2629

2730
#define INIT_THREAD_INFO(tsk) \

arch/um/include/shared/os.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ extern int protect(struct mm_id * mm_idp, unsigned long addr,
278278
extern int is_skas_winch(int pid, int fd, void *data);
279279
extern int start_userspace(unsigned long stub_stack);
280280
extern int copy_context_skas0(unsigned long stack, int pid);
281-
extern void userspace(struct uml_pt_regs *regs);
281+
extern void userspace(struct uml_pt_regs *regs, unsigned long *aux_fp_regs);
282282
extern int map_stub_pages(int fd, unsigned long code, unsigned long data,
283283
unsigned long stack);
284284
extern void new_thread(void *stack, jmp_buf *buf, void (*handler)(void));

arch/um/kernel/gmon_syms.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,10 @@
77

88
extern void __bb_init_func(void *) __attribute__((weak));
99
EXPORT_SYMBOL(__bb_init_func);
10+
11+
extern void __gcov_init(void *) __attribute__((weak));
12+
EXPORT_SYMBOL(__gcov_init);
13+
extern void __gcov_merge_add(void *, unsigned int) __attribute__((weak));
14+
EXPORT_SYMBOL(__gcov_merge_add);
15+
extern void __gcov_exit(void) __attribute__((weak));
16+
EXPORT_SYMBOL(__gcov_exit);

arch/um/kernel/process.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ void new_thread_handler(void)
131131
* callback returns only if the kernel thread execs a process
132132
*/
133133
n = fn(arg);
134-
userspace(&current->thread.regs.regs);
134+
userspace(&current->thread.regs.regs, current_thread_info()->aux_fp_regs);
135135
}
136136

137137
/* Called magically, see new_thread_handler above */
@@ -150,7 +150,7 @@ void fork_handler(void)
150150

151151
current->thread.prev_sched = NULL;
152152

153-
userspace(&current->thread.regs.regs);
153+
userspace(&current->thread.regs.regs, current_thread_info()->aux_fp_regs);
154154
}
155155

156156
int copy_thread(unsigned long clone_flags, unsigned long sp,

arch/um/os-Linux/drivers/tuntap_user.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static int tuntap_open_tramp(char *gate, int *fd_out, int me, int remote,
8080
pid = run_helper(tuntap_pre_exec, &data, argv);
8181

8282
if (pid < 0)
83-
return -pid;
83+
return pid;
8484

8585
close(remote);
8686

arch/um/os-Linux/skas/process.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,11 @@ void wait_stub_done(int pid)
8888

8989
extern unsigned long current_stub_stack(void);
9090

91-
static void get_skas_faultinfo(int pid, struct faultinfo *fi)
91+
static void get_skas_faultinfo(int pid, struct faultinfo *fi, unsigned long *aux_fp_regs)
9292
{
9393
int err;
94-
unsigned long fpregs[FP_SIZE];
9594

96-
err = get_fp_registers(pid, fpregs);
95+
err = get_fp_registers(pid, aux_fp_regs);
9796
if (err < 0) {
9897
printk(UM_KERN_ERR "save_fp_registers returned %d\n",
9998
err);
@@ -113,17 +112,17 @@ static void get_skas_faultinfo(int pid, struct faultinfo *fi)
113112
*/
114113
memcpy(fi, (void *)current_stub_stack(), sizeof(*fi));
115114

116-
err = put_fp_registers(pid, fpregs);
115+
err = put_fp_registers(pid, aux_fp_regs);
117116
if (err < 0) {
118117
printk(UM_KERN_ERR "put_fp_registers returned %d\n",
119118
err);
120119
fatal_sigsegv();
121120
}
122121
}
123122

124-
static void handle_segv(int pid, struct uml_pt_regs * regs)
123+
static void handle_segv(int pid, struct uml_pt_regs *regs, unsigned long *aux_fp_regs)
125124
{
126-
get_skas_faultinfo(pid, &regs->faultinfo);
125+
get_skas_faultinfo(pid, &regs->faultinfo, aux_fp_regs);
127126
segv(regs->faultinfo, 0, 1, NULL);
128127
}
129128

@@ -332,7 +331,7 @@ int start_userspace(unsigned long stub_stack)
332331
return err;
333332
}
334333

335-
void userspace(struct uml_pt_regs *regs)
334+
void userspace(struct uml_pt_regs *regs, unsigned long *aux_fp_regs)
336335
{
337336
int err, status, op, pid = userspace_pid[0];
338337
/* To prevent races if using_sysemu changes under us.*/
@@ -407,11 +406,11 @@ void userspace(struct uml_pt_regs *regs)
407406
case SIGSEGV:
408407
if (PTRACE_FULL_FAULTINFO) {
409408
get_skas_faultinfo(pid,
410-
&regs->faultinfo);
409+
&regs->faultinfo, aux_fp_regs);
411410
(*sig_info[SIGSEGV])(SIGSEGV, (struct siginfo *)&si,
412411
regs);
413412
}
414-
else handle_segv(pid, regs);
413+
else handle_segv(pid, regs, aux_fp_regs);
415414
break;
416415
case SIGTRAP + 0x80:
417416
handle_trap(pid, regs, local_using_sysemu);

arch/um/os-Linux/start_up.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,10 @@ static int __init nosysemu_cmd_param(char *str, int* add)
154154

155155
__uml_setup("nosysemu", nosysemu_cmd_param,
156156
"nosysemu\n"
157-
" Turns off syscall emulation patch for ptrace (SYSEMU) on.\n"
157+
" Turns off syscall emulation patch for ptrace (SYSEMU).\n"
158158
" SYSEMU is a performance-patch introduced by Laurent Vivier. It changes\n"
159-
" behaviour of ptrace() and helps reducing host context switch rate.\n"
160-
" To make it working, you need a kernel patch for your host, too.\n"
159+
" behaviour of ptrace() and helps reduce host context switch rates.\n"
160+
" To make it work, you need a kernel patch for your host, too.\n"
161161
" See http://perso.wanadoo.fr/laurent.vivier/UML/ for further \n"
162162
" information.\n\n");
163163

arch/x86/um/os-Linux/registers.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
#include <errno.h>
8+
#include <stdlib.h>
89
#include <sys/ptrace.h>
910
#ifdef __i386__
1011
#include <sys/user.h>
@@ -31,7 +32,7 @@ int save_fp_registers(int pid, unsigned long *fp_regs)
3132

3233
if (have_xstate_support) {
3334
iov.iov_base = fp_regs;
34-
iov.iov_len = sizeof(struct _xstate);
35+
iov.iov_len = FP_SIZE * sizeof(unsigned long);
3536
if (ptrace(PTRACE_GETREGSET, pid, NT_X86_XSTATE, &iov) < 0)
3637
return -errno;
3738
return 0;
@@ -51,10 +52,9 @@ int restore_fp_registers(int pid, unsigned long *fp_regs)
5152
{
5253
#ifdef PTRACE_SETREGSET
5354
struct iovec iov;
54-
5555
if (have_xstate_support) {
5656
iov.iov_base = fp_regs;
57-
iov.iov_len = sizeof(struct _xstate);
57+
iov.iov_len = FP_SIZE * sizeof(unsigned long);
5858
if (ptrace(PTRACE_SETREGSET, pid, NT_X86_XSTATE, &iov) < 0)
5959
return -errno;
6060
return 0;
@@ -125,13 +125,19 @@ int put_fp_registers(int pid, unsigned long *regs)
125125
void arch_init_registers(int pid)
126126
{
127127
#ifdef PTRACE_GETREGSET
128-
struct _xstate fp_regs;
128+
void * fp_regs;
129129
struct iovec iov;
130130

131-
iov.iov_base = &fp_regs;
132-
iov.iov_len = sizeof(struct _xstate);
131+
fp_regs = malloc(FP_SIZE * sizeof(unsigned long));
132+
if(fp_regs == NULL)
133+
return;
134+
135+
iov.iov_base = fp_regs;
136+
iov.iov_len = FP_SIZE * sizeof(unsigned long);
133137
if (ptrace(PTRACE_GETREGSET, pid, NT_X86_XSTATE, &iov) == 0)
134138
have_xstate_support = 1;
139+
140+
free(fp_regs);
135141
#endif
136142
}
137143
#endif

arch/x86/um/os-Linux/tls.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void check_host_supports_tls(int *supports_tls, int *tls_min)
3737
continue;
3838
else if (errno == ENOSYS)
3939
*supports_tls = 0;
40-
return;
40+
return;
4141
}
4242
}
4343

arch/x86/um/user-offsets.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void foo(void)
5151
DEFINE(HOST_ORIG_AX, ORIG_EAX);
5252
#else
5353
#ifdef FP_XSTATE_MAGIC1
54-
DEFINE(HOST_FP_SIZE, sizeof(struct _xstate) / sizeof(unsigned long));
54+
DEFINE_LONGS(HOST_FP_SIZE, 2696);
5555
#else
5656
DEFINE(HOST_FP_SIZE, sizeof(struct _fpstate) / sizeof(unsigned long));
5757
#endif

0 commit comments

Comments
 (0)