Commit 36c4fd23 authored by Eric W. Biederman's avatar Eric W. Biederman Committed by Linus Torvalds

[PATCH] x86_64 machine_kexec: Cleanup inline assembly.

In an uncensored copy of code from i386 to x86_64 I wound up
with inline assembly with the wrong constraints.  Use input
constraints instead of output constraints.

So I know the assembler will do the right thing specify the size
of the operand lidtq and lgdtq instead of just lidt and lgdt.

Make load_segments use an input constraint, and delete the macro fun.
Without having to reload %cs like I do on i386 this code is noticeably
simpler.
Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent e7b47cca
...@@ -122,45 +122,43 @@ static int init_pgtable(struct kimage *image, unsigned long start_pgtable) ...@@ -122,45 +122,43 @@ static int init_pgtable(struct kimage *image, unsigned long start_pgtable)
static void set_idt(void *newidt, u16 limit) static void set_idt(void *newidt, u16 limit)
{ {
unsigned char curidt[10]; struct desc_ptr curidt;
/* x86-64 supports unaliged loads & stores */ /* x86-64 supports unaliged loads & stores */
(*(u16 *)(curidt)) = limit; curidt.size = limit;
(*(u64 *)(curidt +2)) = (unsigned long)(newidt); curidt.address = (unsigned long)newidt;
__asm__ __volatile__ ( __asm__ __volatile__ (
"lidt %0\n" "lidtq %0\n"
: "=m" (curidt) : : "m" (curidt)
); );
}; };
static void set_gdt(void *newgdt, u16 limit) static void set_gdt(void *newgdt, u16 limit)
{ {
unsigned char curgdt[10]; struct desc_ptr curgdt;
/* x86-64 supports unaligned loads & stores */ /* x86-64 supports unaligned loads & stores */
(*(u16 *)(curgdt)) = limit; curgdt.size = limit;
(*(u64 *)(curgdt +2)) = (unsigned long)(newgdt); curgdt.address = (unsigned long)newgdt;
__asm__ __volatile__ ( __asm__ __volatile__ (
"lgdt %0\n" "lgdtq %0\n"
: "=m" (curgdt) : : "m" (curgdt)
); );
}; };
static void load_segments(void) static void load_segments(void)
{ {
__asm__ __volatile__ ( __asm__ __volatile__ (
"\tmovl $"STR(__KERNEL_DS)",%eax\n" "\tmovl %0,%%ds\n"
"\tmovl %eax,%ds\n" "\tmovl %0,%%es\n"
"\tmovl %eax,%es\n" "\tmovl %0,%%ss\n"
"\tmovl %eax,%ss\n" "\tmovl %0,%%fs\n"
"\tmovl %eax,%fs\n" "\tmovl %0,%%gs\n"
"\tmovl %eax,%gs\n" : : "a" (__KERNEL_DS)
); );
#undef STR
#undef __STR
} }
typedef NORET_TYPE void (*relocate_new_kernel_t)(unsigned long indirection_page, typedef NORET_TYPE void (*relocate_new_kernel_t)(unsigned long indirection_page,
......
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