public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Hiroshi Itoh" <hiroit@mcn.ne.jp>
To: "Maciej W. Rozycki" <macro@linux-mips.org>
Cc: "Li, Shaohua" <shaohua.li@intel.com>, <csapuntz@stanford.edu>,
	<linux-kernel@vger.kernel.org>,
	"Nickolai Zeldovich" <kolya@MIT.EDU>
Subject: Re: [patch] Fix GDT re-load on ACPI resume
Date: Wed, 17 Nov 2004 02:46:20 +0900	[thread overview]
Message-ID: <004701c4cc04$2fcbaff0$2000a8c0@TPHIROIT> (raw)
In-Reply-To: Pine.LNX.4.58L.0411161237020.17411@blysk.ds.pg.gda.pl

[-- Attachment #1: Type: text/plain, Size: 819 bytes --]

Hi, Maciej-san

> What is the "gdt body must be addressable from real mode" requirement
>about?  GDT is addressed by the CPU using a linear address as obtained
>from GDTR (bypassing segmentation, for obvious reasons) and is accessible
>regardless of its placement within the 32-bit linear address space in all
>CPU modes.  As its a linear address it only undergoes translation at the
>page level, if enabled.  The same applies to IDT.

I believe this patch is required because the original gdt is not addressable
via the low mapping page table (set by acpi_save_state_mem and used for wakeup
code), not the GDTR's linear address size reason.

cc:Shaohua and Len

wakeup_gdt2.patch should be slightestly modified to wakeup_gdt_2.6.10.patch
because %edx is conflict with msr's patch in 2.6.10-rc2 or later.

thanks
-Hiro

[-- Attachment #2: wakeup_gdt_2.6.10.patch --]
[-- Type: application/octet-stream, Size: 2216 bytes --]

--- a/arch/i386/kernel/acpi/sleep.c	2004-11-04 04:54:41.000000000 +0900
+++ b/arch/i386/kernel/acpi/sleep.c	2004-11-04 05:20:34.864501960 +0900
@@ -17,7 +17,7 @@
 
 extern void zap_low_mappings(void);
 
-extern unsigned long FASTCALL(acpi_copy_wakeup_routine(unsigned long));
+extern unsigned long FASTCALL(acpi_copy_wakeup_routine(unsigned long,unsigned long));
 
 static void init_low_mapping(pgd_t *pgd, int pgd_limit)
 {
@@ -41,7 +41,8 @@
 		return 1;
 	init_low_mapping(swapper_pg_dir, USER_PTRS_PER_PGD);
 	memcpy((void *) acpi_wakeup_address, &wakeup_start, &wakeup_end - &wakeup_start);
-	acpi_copy_wakeup_routine(acpi_wakeup_address);
+	acpi_copy_wakeup_routine(acpi_wakeup_address,
+				 virt_to_phys((void *)acpi_wakeup_address));
 
 	return 0;
 }
--- a/arch/i386/kernel/acpi/wakeup.S	2004-11-04 04:54:41.000000000 +0900
+++ b/arch/i386/kernel/acpi/wakeup.S	2004-11-04 05:23:46.490370400 +0900
@@ -100,6 +100,7 @@
 real_efer_save_restore:	.long 0
 real_save_efer_edx: 	.long 0
 real_save_efer_eax: 	.long 0
+real_gdt_table: .fill GDT_ENTRIES, 8, 0
 
 bogus_real_magic:
 	movw	$0x0e00 + 'B', %fs:(0x12)
@@ -224,6 +225,7 @@
 #
 # Parameters:
 # %eax:	place to copy wakeup routine to
+# %edx: the second argument (physical address)
 #
 # Returned address is location of code in low memory (past data and stack)
 #
@@ -234,6 +236,9 @@
 	sldt	saved_ldt
 	str	saved_tss
 
+	# save wakeup_start physical address in edx
+	pushl   %edx
+
 	movl	nx_enabled, %edx
 	movl	%edx, real_efer_save_restore - wakeup_start (%eax)
 	testl	$1, real_efer_save_restore - wakeup_start (%eax)
@@ -256,6 +261,17 @@
 	movl	%edx, real_save_cr0 - wakeup_start (%eax)
 	sgdt    real_save_gdt - wakeup_start (%eax)
 
+	# gdt body must be addressable from real mode by
+	# copying it to the lower mem
+	popl	%edx
+	lea     real_gdt_table - wakeup_start (%edx), %edx
+	movl    %edx, real_save_gdt + 2 - wakeup_start (%eax)
+	xor     %ecx, %ecx
+	movw    saved_gdt, %cx
+	movl    saved_gdt + 2, %esi
+	lea     real_gdt_table - wakeup_start (%eax), %edi
+	rep movsb
+
 	movl	saved_videomode, %edx
 	movl	%edx, video_mode - wakeup_start (%eax)
 	movl	acpi_video_flags, %edx

  reply	other threads:[~2004-11-16 17:46 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-16  5:37 [patch] Fix GDT re-load on ACPI resume Li, Shaohua
2004-11-16 12:42 ` Maciej W. Rozycki
2004-11-16 17:46   ` Hiroshi Itoh [this message]
2004-11-17  1:02     ` Maciej W. Rozycki
2004-11-17 18:57 ` Pavel Machek
  -- strict thread matches above, loose matches on Subject: below --
2004-11-18  1:59 Li, Shaohua
2004-11-15 20:35 Nickolai Zeldovich
2004-11-15 23:02 ` David Weinehall
2004-11-15 23:13   ` Nickolai Zeldovich
2004-11-15 23:26 ` Maciej W. Rozycki
2004-11-15 23:52   ` Nickolai Zeldovich

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='004701c4cc04$2fcbaff0$2000a8c0@TPHIROIT' \
    --to=hiroit@mcn.ne.jp \
    --cc=csapuntz@stanford.edu \
    --cc=kolya@MIT.EDU \
    --cc=linux-kernel@vger.kernel.org \
    --cc=macro@linux-mips.org \
    --cc=shaohua.li@intel.com \
    /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