public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Pavel Machek <pavel@ucw.cz>
Cc: discuss@x86-64.org, pm list <linux-pm@lists.linux-foundation.org>,
	Nigel Cunningham <nigel@nigel.suspend2.net>
Subject: Re: [discuss] [RFC][PATCH -mm 1/4] Hibernation: Arbitrary boot kernel support on x86_64
Date: Tue, 21 Aug 2007 22:47:59 +0200	[thread overview]
Message-ID: <200708212248.00058.rjw@sisk.pl> (raw)
In-Reply-To: <200708212130.24597.rjw@sisk.pl>

On Tuesday, 21 August 2007 21:30, Rafael J. Wysocki wrote:
> On Tuesday, 21 August 2007 16:37, Rafael J. Wysocki wrote:
> > On Tuesday, 21 August 2007 09:57, Pavel Machek wrote:
[--snip--]
> > > >  
> > > > -	movl	$24, %eax
> > > > -	movl	%eax, %ds
> > > > -
> > > > -	/* We don't restore %rax, it must be 0 anyway */
> > > > +	/* restore GPRs (we don't restore %rax, it must be 0 anyway) */
> > > >  	movq	$saved_context, %rax
> > > >  	movq	pt_regs_rsp(%rax), %rsp
> > > >  	movq	pt_regs_rbp(%rax), %rbp
> > > 
> > > Hmm, in the old code, we knew we don't have to restore %ds, because it
> > > is constant for one kernel. Now, we rely on %ds being constant accross
> > > kernels. Not nice, and should be at least documented.
> > 
> > Well, in fact we rely on it all the time (eg. the
> > "movq mmu_cr4_features(%rip), %rax" above wouldn't work if that's not true),
> > but I can keep the old code here just fine. ;-)
> 
> Well, I was wrong.  The new code doesn't work without this change and I'm not
> exactly sure why.

Actually, it works if the boot kernel is the same as the image kernel and it
doesn't work if the boot kernel is different.

I think what happens is that by loading %ds with a new selector we cause
the descriptor to be loaded from the descriptor table pointed to by the boot
kernel's GDT and this need not be in the same area as the image kernel's
global descriptor table.  If that is the case, an exception will trigger, so we
should not load %ds until the GDTR value is restored.

Moreover, according to the AMD tech docs, in 64-bit mode the value of %ds is
ignored, so we don't need to bother loading it anyway.

Greetings,
Rafael

  reply	other threads:[~2007-08-21 20:47 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-20 13:10 [RFC][PATCH -mm 0/4] Hibernation: Arbitrary boot kernel support on x86_64 Rafael J. Wysocki
2007-08-20 13:11 ` [RFC][PATCH -mm 1/4] " Rafael J. Wysocki
2007-08-21  7:57   ` Pavel Machek
2007-08-21 14:37     ` [discuss] " Rafael J. Wysocki
2007-08-21 19:30       ` Rafael J. Wysocki
2007-08-21 20:47         ` Rafael J. Wysocki [this message]
2007-08-20 13:16 ` [RFC][PATCH -mm 2/4] Hibernation: Turn on ACPI during restore if necessary Rafael J. Wysocki
2007-08-21  7:57   ` Pavel Machek
2007-08-21 14:39     ` Rafael J. Wysocki
2007-08-21 23:36       ` Pavel Machek
2007-08-22 20:47         ` [discuss] " Rafael J. Wysocki
2007-08-20 13:17 ` [RFC][PATCH -mm 3/4] Hibernation: Use temporary kernel text mapping during restore on x86_64 Rafael J. Wysocki
2007-08-21  7:59   ` Pavel Machek
2007-08-21 14:42     ` Rafael J. Wysocki
2007-08-20 13:18 ` [RFC][PATCH -mm 4/4] Hibernation: Pass CR3 value in hibernation header " Rafael J. Wysocki
2007-08-21  8:01   ` Pavel Machek
2007-08-21 14:46     ` Rafael J. Wysocki

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=200708212248.00058.rjw@sisk.pl \
    --to=rjw@sisk.pl \
    --cc=discuss@x86-64.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=nigel@nigel.suspend2.net \
    --cc=pavel@ucw.cz \
    /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