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

Commit 4d37e7e3 authored by Zachary Amsden's avatar Zachary Amsden Committed by Linus Torvalds
Browse files

[PATCH] i386: inline assembler: cleanup and encapsulate descriptor and task register management



i386 inline assembler cleanup.

This change encapsulates descriptor and task register management.  Also,
it is possible to improve assembler generation in two cases; savesegment
may store the value in a register instead of a memory location, which
allows GCC to optimize stack variables into registers, and MOV MEM, SEG
is always a 16-bit write to memory, making the casting in math-emu
unnecessary.

Signed-off-by: default avatarZachary Amsden <zach@vmware.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 245067d1
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -613,8 +613,8 @@ void __devinit cpu_init(void)
	memcpy(thread->tls_array, &per_cpu(cpu_gdt_table, cpu),
		GDT_ENTRY_TLS_ENTRIES * 8);

	__asm__ __volatile__("lgdt %0" : : "m" (cpu_gdt_descr[cpu]));
	__asm__ __volatile__("lidt %0" : : "m" (idt_descr));
	load_gdt(&cpu_gdt_descr[cpu]);
	load_idt(&idt_descr);

	/*
	 * Delete NT
+1 −1
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ static void doublefault_fn(void)
	struct Xgt_desc_struct gdt_desc = {0, 0};
	unsigned long gdt, tss;

	__asm__ __volatile__("sgdt %0": "=m" (gdt_desc): :"memory");
	store_gdt(&gdt_desc);
	gdt = gdt_desc.address;

	printk("double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
+2 −3
Original line number Diff line number Diff line
@@ -104,8 +104,7 @@ static void efi_call_phys_prelog(void)
	local_flush_tlb();

	cpu_gdt_descr[0].address = __pa(cpu_gdt_descr[0].address);
	__asm__ __volatile__("lgdt %0":"=m"
			    (*(struct Xgt_desc_struct *) __pa(&cpu_gdt_descr[0])));
	load_gdt((struct Xgt_desc_struct *) __pa(&cpu_gdt_descr[0]));
}

static void efi_call_phys_epilog(void)
@@ -114,7 +113,7 @@ static void efi_call_phys_epilog(void)

	cpu_gdt_descr[0].address =
		(unsigned long) __va(cpu_gdt_descr[0].address);
	__asm__ __volatile__("lgdt %0":"=m"(cpu_gdt_descr));
	load_gdt(&cpu_gdt_descr[0]);
	cr4 = read_cr4();

	if (cr4 & X86_CR4_PSE) {
+5 −4
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@
#include <linux/dmi.h>
#include <asm/uaccess.h>
#include <asm/apic.h>
#include <asm/desc.h>
#include "mach_reboot.h"
#include <linux/reboot_fixups.h>

@@ -242,13 +243,13 @@ void machine_real_restart(unsigned char *code, int length)

	/* Set up the IDT for real mode. */

	__asm__ __volatile__ ("lidt %0" : : "m" (real_mode_idt));
	load_idt(&real_mode_idt);

	/* Set up a GDT from which we can load segment descriptors for real
	   mode.  The GDT is not used in real mode; it is just needed here to
	   prepare the descriptors. */

	__asm__ __volatile__ ("lgdt %0" : : "m" (real_mode_gdt));
	load_gdt(&real_mode_gdt);

	/* Load the data segment registers, and thus the descriptors ready for
	   real mode.  The base address of each segment is 0x100, 16 times the
@@ -316,7 +317,7 @@ void machine_emergency_restart(void)
	if (!reboot_thru_bios) {
		if (efi_enabled) {
			efi.reset_system(EFI_RESET_COLD, EFI_SUCCESS, 0, NULL);
			__asm__ __volatile__("lidt %0": :"m" (no_idt));
			load_idt(&no_idt);
			__asm__ __volatile__("int3");
		}
		/* rebooting needs to touch the page at absolute addr 0 */
@@ -325,7 +326,7 @@ void machine_emergency_restart(void)
			mach_reboot_fixups(); /* for board specific fixups */
			mach_reboot();
			/* That didn't work - force a triple fault.. */
			__asm__ __volatile__("lidt %0": :"m" (no_idt));
			load_idt(&no_idt);
			__asm__ __volatile__("int3");
		}
	}
+2 −2
Original line number Diff line number Diff line
@@ -278,9 +278,9 @@ setup_sigcontext(struct sigcontext __user *sc, struct _fpstate __user *fpstate,
	int tmp, err = 0;

	tmp = 0;
	__asm__("movl %%gs,%0" : "=r"(tmp): "0"(tmp));
	savesegment(gs, tmp);
	err |= __put_user(tmp, (unsigned int __user *)&sc->gs);
	__asm__("movl %%fs,%0" : "=r"(tmp): "0"(tmp));
	savesegment(fs, tmp);
	err |= __put_user(tmp, (unsigned int __user *)&sc->fs);

	err |= __put_user(regs->xes, (unsigned int __user *)&sc->es);
Loading