Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 61ecdb84 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge branch 'x86-fixes-for-linus' of...

Merge branch 'x86-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip

* 'x86-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
  x86: Fix kprobes build with non-gawk awk
  x86: Split swiotlb initialization into two stages
  x86: Regex support and known-movable symbols for relocs, fix _end
  x86, msr: Remove incorrect, duplicated code in the MSR driver
  x86: Merge kernel_thread()
  x86: Sync 32/64-bit kernel_thread
  x86, 32-bit: Use same regs as 64-bit for kernel_thread_helper
  x86, 64-bit: Use user_mode() to determine new stack pointer in copy_thread()
  x86, 64-bit: Move kernel_thread to C
  x86-64, paravirt: Call set_iopl_mask() on 64 bits
  x86-32: Avoid pipeline serialization in PTREGSCALL1 and 2
  x86: Merge sys_clone
  x86, 32-bit: Convert sys_vm86 & sys_vm86old
  x86: Merge sys_sigaltstack
  x86: Merge sys_execve
  x86: Merge sys_iopl
  x86-32: Add new pt_regs stubs
  cpumask: Use modern cpumask style in arch/x86/kernel/cpu/mcheck/mce-inject.c
parents da184a80 23637568
Loading
Loading
Loading
Loading
+59 −28
Original line number Diff line number Diff line
@@ -9,6 +9,9 @@
#include <byteswap.h>
#define USE_BSD
#include <endian.h>
#include <regex.h>

static void die(char *fmt, ...);

#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
static Elf32_Ehdr ehdr;
@@ -30,25 +33,47 @@ static struct section *secs;
 * the address for which it has been compiled. Don't warn user about
 * absolute relocations present w.r.t these symbols.
 */
static const char* safe_abs_relocs[] = {
		"xen_irq_disable_direct_reloc",
		"xen_save_fl_direct_reloc",
};
static const char abs_sym_regex[] =
	"^(xen_irq_disable_direct_reloc$|"
	"xen_save_fl_direct_reloc$|"
	"VDSO|"
	"__crc_)";
static regex_t abs_sym_regex_c;
static int is_abs_reloc(const char *sym_name)
{
	return !regexec(&abs_sym_regex_c, sym_name, 0, NULL, 0);
}

static int is_safe_abs_reloc(const char* sym_name)
/*
 * These symbols are known to be relative, even if the linker marks them
 * as absolute (typically defined outside any section in the linker script.)
 */
static const char rel_sym_regex[] =
	"^_end$";
static regex_t rel_sym_regex_c;
static int is_rel_reloc(const char *sym_name)
{
	int i;
	return !regexec(&rel_sym_regex_c, sym_name, 0, NULL, 0);
}

static void regex_init(void)
{
        char errbuf[128];
        int err;
	
	for (i = 0; i < ARRAY_SIZE(safe_abs_relocs); i++) {
		if (!strcmp(sym_name, safe_abs_relocs[i]))
			/* Match found */
			return 1;
        err = regcomp(&abs_sym_regex_c, abs_sym_regex,
                      REG_EXTENDED|REG_NOSUB);
        if (err) {
                regerror(err, &abs_sym_regex_c, errbuf, sizeof errbuf);
                die("%s", errbuf);
        }

        err = regcomp(&rel_sym_regex_c, rel_sym_regex,
                      REG_EXTENDED|REG_NOSUB);
        if (err) {
                regerror(err, &rel_sym_regex_c, errbuf, sizeof errbuf);
                die("%s", errbuf);
        }
	if (strncmp(sym_name, "VDSO", 4) == 0)
		return 1;
	if (strncmp(sym_name, "__crc_", 6) == 0)
		return 1;
	return 0;
}

static void die(char *fmt, ...)
@@ -131,7 +156,7 @@ static const char *rel_type(unsigned type)
#undef REL_TYPE
	};
	const char *name = "unknown type rel type name";
	if (type < ARRAY_SIZE(type_name)) {
	if (type < ARRAY_SIZE(type_name) && type_name[type]) {
		name = type_name[type];
	}
	return name;
@@ -448,7 +473,7 @@ static void print_absolute_relocs(void)
			 * Before warning check if this absolute symbol
			 * relocation is harmless.
			 */
			if (is_safe_abs_reloc(name))
			if (is_abs_reloc(name) || is_rel_reloc(name))
				continue;

			if (!printed) {
@@ -501,21 +526,26 @@ static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym))
			sym = &sh_symtab[ELF32_R_SYM(rel->r_info)];
			r_type = ELF32_R_TYPE(rel->r_info);
			/* Don't visit relocations to absolute symbols */
			if (sym->st_shndx == SHN_ABS) {
			if (sym->st_shndx == SHN_ABS &&
			    !is_rel_reloc(sym_name(sym_strtab, sym))) {
				continue;
			}
			if (r_type == R_386_NONE || r_type == R_386_PC32) {
			switch (r_type) {
			case R_386_NONE:
			case R_386_PC32:
				/*
				 * NONE can be ignored and and PC relative
				 * relocations don't need to be adjusted.
				 */
			}
			else if (r_type == R_386_32) {
				break;
			case R_386_32:
				/* Visit relocations that need to be adjusted */
				visit(rel, sym);
			}
			else {
				die("Unsupported relocation type: %d\n", r_type);
				break;
			default:
				die("Unsupported relocation type: %s (%d)\n",
				    rel_type(r_type), r_type);
				break;
			}
		}
	}
@@ -571,16 +601,15 @@ static void emit_relocs(int as_text)
	}
	else {
		unsigned char buf[4];
		buf[0] = buf[1] = buf[2] = buf[3] = 0;
		/* Print a stop */
		printf("%c%c%c%c", buf[0], buf[1], buf[2], buf[3]);
		fwrite("\0\0\0\0", 4, 1, stdout);
		/* Now print each relocation */
		for (i = 0; i < reloc_count; i++) {
			buf[0] = (relocs[i] >>  0) & 0xff;
			buf[1] = (relocs[i] >>  8) & 0xff;
			buf[2] = (relocs[i] >> 16) & 0xff;
			buf[3] = (relocs[i] >> 24) & 0xff;
			printf("%c%c%c%c", buf[0], buf[1], buf[2], buf[3]);
			fwrite(buf, 4, 1, stdout);
		}
	}
}
@@ -598,6 +627,8 @@ int main(int argc, char **argv)
	FILE *fp;
	int i;

	regex_init();

	show_absolute_syms = 0;
	show_absolute_relocs = 0;
	as_text = 0;
+6 −2
Original line number Diff line number Diff line
@@ -5,13 +5,17 @@

#ifdef CONFIG_SWIOTLB
extern int swiotlb;
extern int pci_swiotlb_init(void);
extern int __init pci_swiotlb_detect(void);
extern void __init pci_swiotlb_init(void);
#else
#define swiotlb 0
static inline int pci_swiotlb_init(void)
static inline int pci_swiotlb_detect(void)
{
	return 0;
}
static inline void pci_swiotlb_init(void)
{
}
#endif

static inline void dma_mark_clean(void *addr, size_t size) {}
+10 −22
Original line number Diff line number Diff line
@@ -18,16 +18,24 @@
/* Common in X86_32 and X86_64 */
/* kernel/ioport.c */
asmlinkage long sys_ioperm(unsigned long, unsigned long, int);
long sys_iopl(unsigned int, struct pt_regs *);

/* kernel/process.c */
int sys_fork(struct pt_regs *);
int sys_vfork(struct pt_regs *);
long sys_execve(char __user *, char __user * __user *,
		char __user * __user *, struct pt_regs *);
long sys_clone(unsigned long, unsigned long, void __user *,
	       void __user *, struct pt_regs *);

/* kernel/ldt.c */
asmlinkage int sys_modify_ldt(int, void __user *, unsigned long);

/* kernel/signal.c */
long sys_rt_sigreturn(struct pt_regs *);
long sys_sigaltstack(const stack_t __user *, stack_t __user *,
		     struct pt_regs *);


/* kernel/tls.c */
asmlinkage int sys_set_thread_area(struct user_desc __user *);
@@ -35,18 +43,11 @@ asmlinkage int sys_get_thread_area(struct user_desc __user *);

/* X86_32 only */
#ifdef CONFIG_X86_32
/* kernel/ioport.c */
long sys_iopl(struct pt_regs *);

/* kernel/process_32.c */
int sys_clone(struct pt_regs *);
int sys_execve(struct pt_regs *);

/* kernel/signal.c */
asmlinkage int sys_sigsuspend(int, int, old_sigset_t);
asmlinkage int sys_sigaction(int, const struct old_sigaction __user *,
			     struct old_sigaction __user *);
int sys_sigaltstack(struct pt_regs *);
unsigned long sys_sigreturn(struct pt_regs *);

/* kernel/sys_i386_32.c */
@@ -62,28 +63,15 @@ asmlinkage int sys_uname(struct old_utsname __user *);
asmlinkage int sys_olduname(struct oldold_utsname __user *);

/* kernel/vm86_32.c */
int sys_vm86old(struct pt_regs *);
int sys_vm86(struct pt_regs *);
int sys_vm86old(struct vm86_struct __user *, struct pt_regs *);
int sys_vm86(unsigned long, unsigned long, struct pt_regs *);

#else /* CONFIG_X86_32 */

/* X86_64 only */
/* kernel/ioport.c */
asmlinkage long sys_iopl(unsigned int, struct pt_regs *);

/* kernel/process_64.c */
asmlinkage long sys_clone(unsigned long, unsigned long,
			  void __user *, void __user *,
			  struct pt_regs *);
asmlinkage long sys_execve(char __user *, char __user * __user *,
			   char __user * __user *,
			   struct pt_regs *);
long sys_arch_prctl(int, unsigned long);

/* kernel/signal.c */
asmlinkage long sys_sigaltstack(const stack_t __user *, stack_t __user *,
				struct pt_regs *);

/* kernel/sys_x86_64.c */
struct new_utsname;

+12 −10
Original line number Diff line number Diff line
@@ -74,7 +74,7 @@ static void raise_exception(struct mce *m, struct pt_regs *pregs)
	m->finished = 0;
}

static cpumask_t mce_inject_cpumask;
static cpumask_var_t mce_inject_cpumask;

static int mce_raise_notify(struct notifier_block *self,
			    unsigned long val, void *data)
@@ -82,9 +82,9 @@ static int mce_raise_notify(struct notifier_block *self,
	struct die_args *args = (struct die_args *)data;
	int cpu = smp_processor_id();
	struct mce *m = &__get_cpu_var(injectm);
	if (val != DIE_NMI_IPI || !cpu_isset(cpu, mce_inject_cpumask))
	if (val != DIE_NMI_IPI || !cpumask_test_cpu(cpu, mce_inject_cpumask))
		return NOTIFY_DONE;
	cpu_clear(cpu, mce_inject_cpumask);
	cpumask_clear_cpu(cpu, mce_inject_cpumask);
	if (m->inject_flags & MCJ_EXCEPTION)
		raise_exception(m, args->regs);
	else if (m->status)
@@ -148,22 +148,22 @@ static void raise_mce(struct mce *m)
		unsigned long start;
		int cpu;
		get_online_cpus();
		mce_inject_cpumask = cpu_online_map;
		cpu_clear(get_cpu(), mce_inject_cpumask);
		cpumask_copy(mce_inject_cpumask, cpu_online_mask);
		cpumask_clear_cpu(get_cpu(), mce_inject_cpumask);
		for_each_online_cpu(cpu) {
			struct mce *mcpu = &per_cpu(injectm, cpu);
			if (!mcpu->finished ||
			    MCJ_CTX(mcpu->inject_flags) != MCJ_CTX_RANDOM)
				cpu_clear(cpu, mce_inject_cpumask);
				cpumask_clear_cpu(cpu, mce_inject_cpumask);
		}
		if (!cpus_empty(mce_inject_cpumask))
			apic->send_IPI_mask(&mce_inject_cpumask, NMI_VECTOR);
		if (!cpumask_empty(mce_inject_cpumask))
			apic->send_IPI_mask(mce_inject_cpumask, NMI_VECTOR);
		start = jiffies;
		while (!cpus_empty(mce_inject_cpumask)) {
		while (!cpumask_empty(mce_inject_cpumask)) {
			if (!time_before(jiffies, start + 2*HZ)) {
				printk(KERN_ERR
				"Timeout waiting for mce inject NMI %lx\n",
					*cpus_addr(mce_inject_cpumask));
					*cpumask_bits(mce_inject_cpumask));
				break;
			}
			cpu_relax();
@@ -210,6 +210,8 @@ static ssize_t mce_write(struct file *filp, const char __user *ubuf,

static int inject_init(void)
{
	if (!alloc_cpumask_var(&mce_inject_cpumask, GFP_KERNEL))
		return -ENOMEM;
	printk(KERN_INFO "Machine check injector initialized\n");
	mce_chrdev_ops.write = mce_write;
	register_die_notifier(&mce_raise_nb);
+52 −17
Original line number Diff line number Diff line
@@ -725,22 +725,61 @@ END(syscall_badsys)
/*
 * System calls that need a pt_regs pointer.
 */
#define PTREGSCALL(name) \
#define PTREGSCALL0(name) \
	ALIGN; \
ptregs_##name: \
	leal 4(%esp),%eax; \
	jmp sys_##name;

PTREGSCALL(iopl)
PTREGSCALL(fork)
PTREGSCALL(clone)
PTREGSCALL(vfork)
PTREGSCALL(execve)
PTREGSCALL(sigaltstack)
PTREGSCALL(sigreturn)
PTREGSCALL(rt_sigreturn)
PTREGSCALL(vm86)
PTREGSCALL(vm86old)
#define PTREGSCALL1(name) \
	ALIGN; \
ptregs_##name: \
	leal 4(%esp),%edx; \
	movl (PT_EBX+4)(%esp),%eax; \
	jmp sys_##name;

#define PTREGSCALL2(name) \
	ALIGN; \
ptregs_##name: \
	leal 4(%esp),%ecx; \
	movl (PT_ECX+4)(%esp),%edx; \
	movl (PT_EBX+4)(%esp),%eax; \
	jmp sys_##name;

#define PTREGSCALL3(name) \
	ALIGN; \
ptregs_##name: \
	leal 4(%esp),%eax; \
	pushl %eax; \
	movl PT_EDX(%eax),%ecx; \
	movl PT_ECX(%eax),%edx; \
	movl PT_EBX(%eax),%eax; \
	call sys_##name; \
	addl $4,%esp; \
	ret

PTREGSCALL1(iopl)
PTREGSCALL0(fork)
PTREGSCALL0(vfork)
PTREGSCALL3(execve)
PTREGSCALL2(sigaltstack)
PTREGSCALL0(sigreturn)
PTREGSCALL0(rt_sigreturn)
PTREGSCALL2(vm86)
PTREGSCALL1(vm86old)

/* Clone is an oddball.  The 4th arg is in %edi */
	ALIGN;
ptregs_clone:
	leal 4(%esp),%eax
	pushl %eax
	pushl PT_EDI(%eax)
	movl PT_EDX(%eax),%ecx
	movl PT_ECX(%eax),%edx
	movl PT_EBX(%eax),%eax
	call sys_clone
	addl $8,%esp
	ret

.macro FIXUP_ESPFIX_STACK
/*
@@ -1008,12 +1047,8 @@ END(spurious_interrupt_bug)
ENTRY(kernel_thread_helper)
	pushl $0		# fake return address for unwinder
	CFI_STARTPROC
	movl %edx,%eax
	push %edx
	CFI_ADJUST_CFA_OFFSET 4
	call *%ebx
	push %eax
	CFI_ADJUST_CFA_OFFSET 4
	movl %edi,%eax
	call *%esi
	call do_exit
	ud2			# padding for call trace
	CFI_ENDPROC
Loading