* [GIT PULL] x86 setup: work around bug in Xen HVM
@ 2007-09-04 16:55 H. Peter Anvin
2007-09-04 22:33 ` Christoph Hellwig
0 siblings, 1 reply; 3+ messages in thread
From: H. Peter Anvin @ 2007-09-04 16:55 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Linux Kernel Mailing List, Christian Ehrhardt
Hi Linus,
Please pull:
git://git.kernel.org/pub/scm/linux/kernel/git/hpa/linux-2.6-x86setup.git for-linus
Christian Ehrhardt (1):
[x86 setup] Work around bug in Xen HVM
arch/i386/boot/pm.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
[Log messages and full diffs follow]
commit 92ea189254b87727d6be407558d9c18fed0937bb
Author: Christian Ehrhardt <lk@c--e.de>
Date: Mon Sep 3 20:32:38 2007 +0200
[x86 setup] Work around bug in Xen HVM
Apparently XEN does not keep the contents of the 48-bit gdt_48 data
structure that is passed to lgdt in the XEN machine state. Instead it
appears to save the _address_ of the 48-bit descriptor
somewhere. Unfortunately this data happens to reside on the stack and
is probably no longer availiable at the time of the actual protected
mode jump.
This is Xen bug but given that there is a one-line patch to work
around this problem, the linux kernel should probably do this. My fix
is to make the gdt_48 description in setup_gdt static (in setup_idt
this is already the case). This allows the kernel to boot under
Xen HVM again.
Signed-off-by: Christian Ehrhardt <lk@c--e.de>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
diff --git a/arch/i386/boot/pm.c b/arch/i386/boot/pm.c
index 6be9ca8..f7958f1 100644
--- a/arch/i386/boot/pm.c
+++ b/arch/i386/boot/pm.c
@@ -122,7 +122,7 @@ static void setup_gdt(void)
/* DS: data, read/write, 4 GB, base 0 */
[GDT_ENTRY_BOOT_DS] = GDT_ENTRY(0xc093, 0, 0xfffff),
};
- struct gdt_ptr gdt;
+ static struct gdt_ptr gdt;
gdt.len = sizeof(boot_gdt)-1;
gdt.ptr = (u32)&boot_gdt + (ds() << 4);
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [GIT PULL] x86 setup: work around bug in Xen HVM
2007-09-04 16:55 [GIT PULL] x86 setup: work around bug in Xen HVM H. Peter Anvin
@ 2007-09-04 22:33 ` Christoph Hellwig
2007-09-05 1:39 ` H. Peter Anvin
0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2007-09-04 22:33 UTC (permalink / raw)
To: H. Peter Anvin
Cc: Linus Torvalds, Linux Kernel Mailing List, Christian Ehrhardt
On Tue, Sep 04, 2007 at 09:55:45AM -0700, H. Peter Anvin wrote:
>
> Apparently XEN does not keep the contents of the 48-bit gdt_48 data
> structure that is passed to lgdt in the XEN machine state. Instead it
> appears to save the _address_ of the 48-bit descriptor
> somewhere. Unfortunately this data happens to reside on the stack and
> is probably no longer availiable at the time of the actual protected
> mode jump.
>
> This is Xen bug but given that there is a one-line patch to work
> around this problem, the linux kernel should probably do this. My fix
> is to make the gdt_48 description in setup_gdt static (in setup_idt
> this is already the case). This allows the kernel to boot under
> Xen HVM again.
> - struct gdt_ptr gdt;
> + static struct gdt_ptr gdt;
It might make sense to add your above commit message to the code as a comment.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [GIT PULL] x86 setup: work around bug in Xen HVM
2007-09-04 22:33 ` Christoph Hellwig
@ 2007-09-05 1:39 ` H. Peter Anvin
0 siblings, 0 replies; 3+ messages in thread
From: H. Peter Anvin @ 2007-09-05 1:39 UTC (permalink / raw)
To: Christoph Hellwig, H. Peter Anvin, Linus Torvalds,
Linux Kernel Mailing List, Christian Ehrhardt
Christoph Hellwig wrote:
> On Tue, Sep 04, 2007 at 09:55:45AM -0700, H. Peter Anvin wrote:
>>
>> Apparently XEN does not keep the contents of the 48-bit gdt_48 data
>> structure that is passed to lgdt in the XEN machine state. Instead it
>> appears to save the _address_ of the 48-bit descriptor
>> somewhere. Unfortunately this data happens to reside on the stack and
>> is probably no longer availiable at the time of the actual protected
>> mode jump.
>>
>> This is Xen bug but given that there is a one-line patch to work
>> around this problem, the linux kernel should probably do this. My fix
>> is to make the gdt_48 description in setup_gdt static (in setup_idt
>> this is already the case). This allows the kernel to boot under
>> Xen HVM again.
>
>> - struct gdt_ptr gdt;
>> + static struct gdt_ptr gdt;
>
> It might make sense to add your above commit message to the code as a comment.
Good point; I have amended the commit with a brief comment:
diff --git a/arch/i386/boot/pm.c b/arch/i386/boot/pm.c
index 6be9ca8..09fb342 100644
--- a/arch/i386/boot/pm.c
+++ b/arch/i386/boot/pm.c
@@ -122,7 +122,11 @@ static void setup_gdt(void)
/* DS: data, read/write, 4 GB, base 0 */
[GDT_ENTRY_BOOT_DS] = GDT_ENTRY(0xc093, 0, 0xfffff),
};
- struct gdt_ptr gdt;
+ /* Xen HVM incorrectly stores a pointer to the gdt_ptr, instead
+ of the gdt_ptr contents. Thus, make it static so it will
+ stay in memory, at least long enough that we switch to the
+ proper kernel GDT. */
+ static struct gdt_ptr gdt;
gdt.len = sizeof(boot_gdt)-1;
gdt.ptr = (u32)&boot_gdt + (ds() << 4);
-hpa
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-09-05 1:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-04 16:55 [GIT PULL] x86 setup: work around bug in Xen HVM H. Peter Anvin
2007-09-04 22:33 ` Christoph Hellwig
2007-09-05 1:39 ` H. Peter Anvin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox