From: Vivek Goyal <vgoyal@in.ibm.com>
To: Pavel Machek <pavel@ucw.cz>
Cc: linux kernel mailing list <linux-kernel@vger.kernel.org>,
Reloc Kernel List <fastboot@lists.osdl.org>,
ebiederm@xmission.com, akpm@linux-foundation.org, ak@suse.de,
hpa@zytor.com, magnus.damm@gmail.com, lwang@redhat.com,
dzickus@redhat.com, rjw@sisk.pl
Subject: Re: [PATCH 12/20] x86_64: 64bit ACPI wakeup trampoline
Date: Thu, 8 Mar 2007 10:28:41 +0530 [thread overview]
Message-ID: <20070308045841.GF6000@in.ibm.com> (raw)
In-Reply-To: <20070307224508.GE5956@elf.ucw.cz>
On Wed, Mar 07, 2007 at 11:45:08PM +0100, Pavel Machek wrote:
[..]
>
> > + if ((&wakeup_end - &wakeup_start) > (PAGE_SIZE*2))
> > printk(KERN_CRIT
> > - "ACPI: Wakeup code way too big, will crash on attempt to suspend\n");
> > + "ACPI: Wakeup code way too big, will crash on attempt"
> > + " to suspend\n");
>
> Hmm, if you split it like
> printk(KERN_CRIT "ACPI: Wakeup code way too big, will crash"
> "on attempt to suspend\n");
>
> ...you'll still keep 80-column rule while keeping it readable.
>
Thanks. Done the changes in attached patch.
> > @@ -159,11 +159,11 @@ wakeup_32:
> > */
> >
> > /* Finally jump in 64bit mode */
> > - ljmp *(wakeup_long64_vector - __START_KERNEL_map)
> > + ljmp *(wakeup_long64_vector - wakeup_code)(%esi)
>
> spaces vs. tabs problem.
>
Thanks. Done the changes in attached patch.
Vivek
o Moved wakeup_level4_pgt into the wakeup routine so we can
run the kernel above 4G.
o Now we first go to 64bit mode and continue to run from trampoline and
then then start accessing kernel symbols and restore processor context.
This enables us to resume even in relocatable kernel context when
kernel might not be loaded at physical addr it has been compiled for.
o Removed the need for modifying any existing kernel page table.
o Increased the size of the wakeup routine to 8K. This is required as
wake page tables are on trampoline itself and they got to be at 4K
boundary, hence one page is not sufficient.
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Vivek Goyal <vgoyal@in.ibm.com>
---
arch/x86_64/kernel/acpi/sleep.c | 23 ++-------------
arch/x86_64/kernel/acpi/wakeup.S | 59 ++++++++++++++++++++++++---------------
arch/x86_64/kernel/head.S | 9 -----
3 files changed, 41 insertions(+), 50 deletions(-)
diff -puN arch/x86_64/kernel/acpi/sleep.c~x86_64-64bit-ACPI-wakeup-trampoline arch/x86_64/kernel/acpi/sleep.c
--- linux-2.6.21-rc2-reloc/arch/x86_64/kernel/acpi/sleep.c~x86_64-64bit-ACPI-wakeup-trampoline 2007-03-07 01:28:11.000000000 +0530
+++ linux-2.6.21-rc2-reloc-root/arch/x86_64/kernel/acpi/sleep.c 2007-03-08 18:26:13.000000000 +0530
@@ -60,17 +60,6 @@ extern char wakeup_start, wakeup_end;
extern unsigned long acpi_copy_wakeup_routine(unsigned long);
-static pgd_t low_ptr;
-
-static void init_low_mapping(void)
-{
- pgd_t *slot0 = pgd_offset(current->mm, 0UL);
- low_ptr = *slot0;
- set_pgd(slot0, *pgd_offset(current->mm, PAGE_OFFSET));
- WARN_ON(num_online_cpus() != 1);
- local_flush_tlb();
-}
-
/**
* acpi_save_state_mem - save kernel state
*
@@ -79,8 +68,6 @@ static void init_low_mapping(void)
*/
int acpi_save_state_mem(void)
{
- init_low_mapping();
-
memcpy((void *)acpi_wakeup_address, &wakeup_start,
&wakeup_end - &wakeup_start);
acpi_copy_wakeup_routine(acpi_wakeup_address);
@@ -93,8 +80,6 @@ int acpi_save_state_mem(void)
*/
void acpi_restore_state_mem(void)
{
- set_pgd(pgd_offset(current->mm, 0UL), low_ptr);
- local_flush_tlb();
}
/**
@@ -107,10 +92,10 @@ void acpi_restore_state_mem(void)
*/
void __init acpi_reserve_bootmem(void)
{
- acpi_wakeup_address = (unsigned long)alloc_bootmem_low(PAGE_SIZE);
- if ((&wakeup_end - &wakeup_start) > PAGE_SIZE)
- printk(KERN_CRIT
- "ACPI: Wakeup code way too big, will crash on attempt to suspend\n");
+ acpi_wakeup_address = (unsigned long)alloc_bootmem_low(PAGE_SIZE*2);
+ if ((&wakeup_end - &wakeup_start) > (PAGE_SIZE*2))
+ printk(KERN_CRIT "ACPI: Wakeup code way too big, will crash"
+ " on attempt to suspend\n");
}
static int __init acpi_sleep_setup(char *str)
diff -puN arch/x86_64/kernel/acpi/wakeup.S~x86_64-64bit-ACPI-wakeup-trampoline arch/x86_64/kernel/acpi/wakeup.S
--- linux-2.6.21-rc2-reloc/arch/x86_64/kernel/acpi/wakeup.S~x86_64-64bit-ACPI-wakeup-trampoline 2007-03-07 01:28:11.000000000 +0530
+++ linux-2.6.21-rc2-reloc-root/arch/x86_64/kernel/acpi/wakeup.S 2007-03-08 18:27:55.000000000 +0530
@@ -1,6 +1,7 @@
.text
#include <linux/linkage.h>
#include <asm/segment.h>
+#include <asm/pgtable.h>
#include <asm/page.h>
#include <asm/msr.h>
@@ -62,12 +63,15 @@ wakeup_code:
movb $0xa2, %al ; outb %al, $0x80
- lidt %ds:idt_48a - wakeup_code
- xorl %eax, %eax
- movw %ds, %ax # (Convert %ds:gdt to a linear ptr)
- shll $4, %eax
- addl $(gdta - wakeup_code), %eax
- movl %eax, gdt_48a +2 - wakeup_code
+ mov %ds, %ax # Find 32bit wakeup_code addr
+ movzx %ax, %esi # (Convert %ds:gdt to a liner ptr)
+ shll $4, %esi
+ # Fix up the vectors
+ addl %esi, wakeup_32_vector - wakeup_code
+ addl %esi, wakeup_long64_vector - wakeup_code
+ addl %esi, gdt_48a + 2 - wakeup_code # Fixup the gdt pointer
+
+ lidtl %ds:idt_48a - wakeup_code
lgdtl %ds:gdt_48a - wakeup_code # load gdt with whatever is
# appropriate
@@ -80,7 +84,7 @@ wakeup_code:
.balign 4
wakeup_32_vector:
- .long wakeup_32 - __START_KERNEL_map
+ .long wakeup_32 - wakeup_code
.word __KERNEL32_CS, 0
.code32
@@ -103,10 +107,6 @@ wakeup_32:
movl $__KERNEL_DS, %eax
movl %eax, %ds
- movl saved_magic - __START_KERNEL_map, %eax
- cmpl $0x9abcdef0, %eax
- jne bogus_32_magic
-
movw $0x0e00 + 'i', %ds:(0xb8012)
movb $0xa8, %al ; outb %al, $0x80;
@@ -120,7 +120,7 @@ wakeup_32:
movl %eax, %cr4
/* Setup early boot stage 4 level pagetables */
- movl $(wakeup_level4_pgt - __START_KERNEL_map), %eax
+ leal (wakeup_level4_pgt - wakeup_code)(%esi), %eax
movl %eax, %cr3
/* Enable Long Mode */
@@ -159,11 +159,11 @@ wakeup_32:
*/
/* Finally jump in 64bit mode */
- ljmp *(wakeup_long64_vector - __START_KERNEL_map)
+ ljmp *(wakeup_long64_vector - wakeup_code)(%esi)
.balign 4
wakeup_long64_vector:
- .long wakeup_long64 - __START_KERNEL_map
+ .long wakeup_long64 - wakeup_code
.word __KERNEL_CS, 0
.code64
@@ -178,11 +178,16 @@ wakeup_long64:
* addresses where we're currently running on. We have to do that here
* because in 32bit we couldn't load a 64bit linear address.
*/
- lgdt cpu_gdt_descr - __START_KERNEL_map
+ lgdt cpu_gdt_descr
movw $0x0e00 + 'n', %ds:(0xb8014)
movb $0xa9, %al ; outb %al, $0x80
+ movq saved_magic, %rax
+ movq $0x123456789abcdef0, %rdx
+ cmpq %rdx, %rax
+ jne bogus_64_magic
+
movw $0x0e00 + 'u', %ds:(0xb8016)
nop
@@ -223,20 +228,21 @@ idt_48a:
gdt_48a:
.word 0x800 # gdt limit=2048,
# 256 GDT entries
- .word 0, 0 # gdt base (filled in later)
-
+ .long gdta - wakeup_code # gdt base (relocated in later)
real_magic: .quad 0
video_mode: .quad 0
video_flags: .quad 0
+.code16
bogus_real_magic:
movb $0xba,%al ; outb %al,$0x80
jmp bogus_real_magic
-bogus_32_magic:
+.code64
+bogus_64_magic:
movb $0xb3,%al ; outb %al,$0x80
- jmp bogus_32_magic
+ jmp bogus_64_magic
bogus_cpu:
movb $0xbc,%al ; outb %al,$0x80
@@ -263,6 +269,7 @@ bogus_cpu:
#define VIDEO_FIRST_V7 0x0900
# Setting of user mode (AX=mode ID) => CF=success
+.code16
mode_seta:
movw %ax, %bx
#if 0
@@ -313,6 +320,13 @@ wakeup_stack_begin: # Stack grows down
.org 0xff0
wakeup_stack: # Just below end of page
+.org 0x1000
+ENTRY(wakeup_level4_pgt)
+ .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
+ .fill 510,8,0
+ /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
+ .quad level3_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
+
ENTRY(wakeup_end)
##
@@ -338,9 +352,10 @@ ENTRY(acpi_copy_wakeup_routine)
movq $0x123456789abcdef0, %rdx
movq %rdx, saved_magic
- movl saved_magic - __START_KERNEL_map, %eax
- cmpl $0x9abcdef0, %eax
- jne bogus_32_magic
+ movq saved_magic, %rax
+ movq $0x123456789abcdef0, %rdx
+ cmpq %rdx, %rax
+ jne bogus_64_magic
# restore the regs we used
popq %rdx
diff -puN arch/x86_64/kernel/head.S~x86_64-64bit-ACPI-wakeup-trampoline arch/x86_64/kernel/head.S
--- linux-2.6.21-rc2-reloc/arch/x86_64/kernel/head.S~x86_64-64bit-ACPI-wakeup-trampoline 2007-03-07 01:28:11.000000000 +0530
+++ linux-2.6.21-rc2-reloc-root/arch/x86_64/kernel/head.S 2007-03-08 18:17:22.000000000 +0530
@@ -308,15 +308,6 @@ NEXT_PAGE(level2_kernel_pgt)
.data
-#ifdef CONFIG_ACPI_SLEEP
- .align PAGE_SIZE
-ENTRY(wakeup_level4_pgt)
- .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
- .fill 510,8,0
- /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
- .quad level3_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
-#endif
-
#ifndef CONFIG_HOTPLUG_CPU
__INITDATA
#endif
_
next prev parent reply other threads:[~2007-03-08 4:59 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-07 6:57 [PATCH 0/20] x86_64 Relocatable bzImage support (V4) Vivek Goyal
2007-03-07 6:59 ` [PATCH 1/20] x86_64: Assembly safe page.h and pgtable.h Vivek Goyal
2007-03-07 19:24 ` Sam Ravnborg
2007-03-08 6:01 ` Vivek Goyal
2007-03-08 6:16 ` Eric W. Biederman
2007-03-07 7:00 ` [PATCH 2/20] x86_64: Kill temp boot pmds Vivek Goyal
2007-03-07 7:02 ` [PATCH 3/20] x86_64: Clean up the early boot page table Vivek Goyal
2007-03-07 7:03 ` [PATCH 4/20] x86_64: Fix early printk to use standard ISA mapping Vivek Goyal
2007-03-07 7:04 ` [PATCH 5/20] x86_64: modify copy_bootdata to use virtual addresses Vivek Goyal
2007-03-07 7:06 ` [PATCH 6/20] x86_64: cleanup segments Vivek Goyal
2007-03-07 7:08 ` [PATCH 7/20] x86_64: Add EFER to the register set saved by save_processor_state Vivek Goyal
2007-03-07 7:09 ` [PATCH 8/20] x86_64: 64bit PIC SMP trampoline Vivek Goyal
2007-03-07 7:10 ` [PATCH 9/20] x86_64: Get rid of dead code in suspend resume Vivek Goyal
2007-03-07 7:12 ` [PATCH 10/20] x86_64: wakeup.S rename registers to reflect right names Vivek Goyal
2007-03-07 22:30 ` Pavel Machek
2007-03-07 7:13 ` [PATCH 11/20] x86_64: wakeup.S misc cleanups Vivek Goyal
2007-03-07 22:40 ` Pavel Machek
2007-03-08 4:25 ` Vivek Goyal
2007-03-07 22:41 ` Pavel Machek
2007-03-08 4:29 ` Vivek Goyal
2007-03-08 11:43 ` Pavel Machek
2007-03-08 16:45 ` [Fastboot] " Lombard, David N
2007-03-07 7:14 ` [PATCH 12/20] x86_64: 64bit ACPI wakeup trampoline Vivek Goyal
2007-03-07 22:45 ` Pavel Machek
2007-03-07 22:57 ` [Fastboot] " Bernhard Walle
2007-03-08 4:58 ` Vivek Goyal [this message]
2007-03-08 11:44 ` Pavel Machek
2007-03-07 7:16 ` [PATCH 13/20] x86_64: Modify discover_ebda to use virtual addresses Vivek Goyal
2007-03-07 7:17 ` [PATCH 14/20] x86_64: Remove the identity mapping as early as possible Vivek Goyal
2007-03-07 7:18 ` [PATCH 15/20] Move swsusp __pa() dependent code to arch portion Vivek Goyal
2007-03-07 22:47 ` Pavel Machek
2007-03-08 5:34 ` Vivek Goyal
2007-03-08 11:47 ` Pavel Machek
2007-03-07 7:20 ` [PATCH 16/20] swsusp: do not use virt_to_page on kernel data address Vivek Goyal
2007-03-07 22:49 ` Pavel Machek
2007-03-08 5:17 ` Vivek Goyal
2007-03-08 11:47 ` Pavel Machek
2007-03-07 22:50 ` Pavel Machek
2007-03-07 23:15 ` Nigel Cunningham
2007-03-08 5:04 ` Vivek Goyal
2007-03-08 11:44 ` Pavel Machek
2007-03-07 7:21 ` [PATCH 17/20] x86_64: __pa and __pa_symbol address space separation Vivek Goyal
2007-03-07 7:22 ` [PATCH 18/20] x86_64: Relocatable Kernel Support Vivek Goyal
2007-03-07 7:24 ` [PATCH 19/20] x86_64: Extend bzImage protocol for relocatable bzImage Vivek Goyal
2007-03-07 7:25 ` [PATCH 20/20] x86_64: Move cpu verification code to common file Vivek Goyal
2007-03-07 15:07 ` [PATCH 0/20] x86_64 Relocatable bzImage support (V4) Arjan van de Ven
2007-03-07 19:08 ` Eric W. Biederman
2007-03-07 20:49 ` Nigel Cunningham
2007-03-07 23:15 ` Nigel Cunningham
2007-03-08 4:40 ` Vivek Goyal
2007-03-08 8:07 ` Nigel Cunningham
2007-03-08 8:27 ` Vivek Goyal
2007-03-08 7:48 ` Vivek Goyal
2007-03-08 3:36 ` Vivek Goyal
2007-03-14 23:10 ` Andi Kleen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070308045841.GF6000@in.ibm.com \
--to=vgoyal@in.ibm.com \
--cc=ak@suse.de \
--cc=akpm@linux-foundation.org \
--cc=dzickus@redhat.com \
--cc=ebiederm@xmission.com \
--cc=fastboot@lists.osdl.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lwang@redhat.com \
--cc=magnus.damm@gmail.com \
--cc=pavel@ucw.cz \
--cc=rjw@sisk.pl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox