From patchwork Thu Jan 27 22:53:59 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rafael Wysocki X-Patchwork-Id: 513361 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p0RMsZeR013401 for ; Thu, 27 Jan 2011 22:54:36 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753803Ab1A0Wye (ORCPT ); Thu, 27 Jan 2011 17:54:34 -0500 Received: from ogre.sisk.pl ([217.79.144.158]:45886 "EHLO ogre.sisk.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753773Ab1A0Wyd (ORCPT ); Thu, 27 Jan 2011 17:54:33 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by ogre.sisk.pl (Postfix) with ESMTP id 165881A2311; Thu, 27 Jan 2011 23:56:19 +0100 (CET) Received: from ogre.sisk.pl ([127.0.0.1]) by localhost (ogre.sisk.pl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 03075-04; Thu, 27 Jan 2011 23:56:00 +0100 (CET) Received: from ferrari.rjw.lan (220-bem-13.acn.waw.pl [82.210.184.220]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ogre.sisk.pl (Postfix) with ESMTP id B22EB1A1BD6; Thu, 27 Jan 2011 23:56:00 +0100 (CET) From: "Rafael J. Wysocki" To: matthieu castet Subject: Re: [RFC] merge 32/64 bits realmode wakeup code Date: Thu, 27 Jan 2011 23:53:59 +0100 User-Agent: KMail/1.13.5 (Linux/2.6.38-rc2+; KDE/4.4.4; x86_64; ; ) Cc: Linux Kernel list , linux-acpi@vger.kernel.org, "H. Peter Anvin" , Thomas Gleixner , x86@kernel.org References: <4D41EA12.1030402@free.fr> In-Reply-To: <4D41EA12.1030402@free.fr> MIME-Version: 1.0 Message-Id: <201101272354.00042.rjw@sisk.pl> X-Virus-Scanned: amavisd-new at ogre.sisk.pl using MkS_Vir for Linux Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 27 Jan 2011 22:54:36 +0000 (UTC) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 3ed5ad9..3baa11c 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -219,7 +219,7 @@ config X86_HT config X86_TRAMPOLINE def_bool y - depends on SMP || (64BIT && ACPI_SLEEP) + depends on SMP || ACPI_SLEEP config X86_32_LAZY_GS def_bool y diff --git a/arch/x86/kernel/acpi/realmode/wakeup.S b/arch/x86/kernel/acpi/realmode/wakeup.S index 28595d6..2c2d5b8 100644 --- a/arch/x86/kernel/acpi/realmode/wakeup.S +++ b/arch/x86/kernel/acpi/realmode/wakeup.S @@ -90,36 +90,10 @@ _start: /* Do any other stuff... */ -#ifndef CONFIG_64BIT - /* This could also be done in C code... */ - movl pmode_cr3, %eax - movl %eax, %cr3 - - movl pmode_cr4, %ecx - jecxz 1f - movl %ecx, %cr4 -1: - movl pmode_efer, %eax - movl pmode_efer + 4, %edx - movl %eax, %ecx - orl %edx, %ecx - jz 1f - movl $MSR_EFER, %ecx - wrmsr -1: - - lgdtl pmode_gdt - - /* This really couldn't... */ - movl pmode_cr0, %eax - movl %eax, %cr0 - jmp pmode_return -#else pushw $0 pushw trampoline_segment pushw $0 lret -#endif bogus_real_magic: 1: diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c index 69fd72a..d32bef9 100644 --- a/arch/x86/kernel/acpi/sleep.c +++ b/arch/x86/kernel/acpi/sleep.c @@ -26,7 +26,7 @@ unsigned long acpi_realmode_flags; /* address in low memory of the wakeup routine. */ static unsigned long acpi_realmode; -#if defined(CONFIG_SMP) && defined(CONFIG_64BIT) +#if defined(CONFIG_SMP) static char temp_stack[4096]; #endif @@ -80,31 +80,24 @@ int acpi_save_state_mem(void) header->wakeup_gdt[2] = GDT_ENTRY(0x8093, acpi_wakeup_address, 0xfffff); -#ifndef CONFIG_64BIT - store_gdt((struct desc_ptr *)&header->pmode_gdt); - - if (rdmsr_safe(MSR_EFER, &header->pmode_efer_low, - &header->pmode_efer_high)) - header->pmode_efer_low = header->pmode_efer_high = 0; -#endif /* !CONFIG_64BIT */ - header->pmode_cr0 = read_cr0(); header->pmode_cr4 = read_cr4_safe(); header->realmode_flags = acpi_realmode_flags; header->real_magic = 0x12345678; - -#ifndef CONFIG_64BIT - header->pmode_entry = (u32)&wakeup_pmode_return; - header->pmode_cr3 = (u32)__pa(&initial_page_table); - saved_magic = 0x12345678; -#else /* CONFIG_64BIT */ header->trampoline_segment = setup_trampoline() >> 4; #ifdef CONFIG_SMP stack_start.sp = temp_stack + sizeof(temp_stack); early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(smp_processor_id()); +#ifdef CONFIG_64BIT initial_gs = per_cpu_offset(smp_processor_id()); #endif +#endif + +#ifndef CONFIG_64BIT + initial_code = (unsigned long)&wakeup_pmode_return; + saved_magic = 0x12345678; +#else initial_code = (unsigned long)wakeup_long64; saved_magic = 0x123456789abcdef0L; #endif /* CONFIG_64BIT */ diff --git a/arch/x86/kernel/trampoline_32.S b/arch/x86/kernel/trampoline_32.S index 8508237..11f0387 100644 --- a/arch/x86/kernel/trampoline_32.S +++ b/arch/x86/kernel/trampoline_32.S @@ -32,8 +32,12 @@ #include #include -/* We can free up trampoline after bootup if cpu hotplug is not supported. */ +#ifdef CONFIG_ACPI_SLEEP +.section .rodata, "a", @progbits +#else +/* We can free up the trampoline after bootup if cpu hotplug is not supported. */ __CPUINITRODATA +#endif .code16 ENTRY(trampoline_data)