diff mbox

[v2] x86: Load __USER_DS into DS/ES after resume

Message ID 20150614085735.GA22174@amd (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Pavel Machek June 14, 2015, 8:57 a.m. UTC
On Sun 2015-06-14 09:49:22, Ingo Molnar wrote:
> 
> * Linus Torvalds <torvalds@linux-foundation.org> wrote:
> 
> > On Jun 13, 2015 8:56 PM, "Ingo Molnar" <mingo@kernel.org> wrote:
> > >
> > > Ok, so something like the patch below, right?
> > >
> > >         movw    $__KERNEL_DS, %ax
> > >         movw    %ax, %ss
> > > -       movw    %ax, %ds
> > > -       movw    %ax, %es
> > >         movw    %ax, %fs
> > >         movw    %ax, %gs
> > >
> > > +       movw    $__KERNEL_DS, %ax
> > > +       movw    %ax, %ds
> > > +       movw    %ax, %es
> > 
> > .. except with less cut-and-paste bugs.
> > 
> > That second KERNEL should be USER.
> 
> Yeah, doh :-/ Updated patch below.

Do we want similar patch for 64-bit, too?

Signed-off-by: Pavel Machek <pavel@ucw.cz>

Comments

Brian Gerst June 14, 2015, 2:22 p.m. UTC | #1
On Sun, Jun 14, 2015 at 4:57 AM, Pavel Machek <pavel@ucw.cz> wrote:
> On Sun 2015-06-14 09:49:22, Ingo Molnar wrote:
>>
>> * Linus Torvalds <torvalds@linux-foundation.org> wrote:
>>
>> > On Jun 13, 2015 8:56 PM, "Ingo Molnar" <mingo@kernel.org> wrote:
>> > >
>> > > Ok, so something like the patch below, right?
>> > >
>> > >         movw    $__KERNEL_DS, %ax
>> > >         movw    %ax, %ss
>> > > -       movw    %ax, %ds
>> > > -       movw    %ax, %es
>> > >         movw    %ax, %fs
>> > >         movw    %ax, %gs
>> > >
>> > > +       movw    $__KERNEL_DS, %ax
>> > > +       movw    %ax, %ds
>> > > +       movw    %ax, %es
>> >
>> > .. except with less cut-and-paste bugs.
>> >
>> > That second KERNEL should be USER.
>>
>> Yeah, doh :-/ Updated patch below.
>
> Do we want similar patch for 64-bit, too?
>
> Signed-off-by: Pavel Machek <pavel@ucw.cz>
>
> diff --git a/arch/x86/kernel/acpi/wakeup_64.S b/arch/x86/kernel/acpi/wakeup_64.S
> index ae693b5..2ac2bc7 100644
> --- a/arch/x86/kernel/acpi/wakeup_64.S
> +++ b/arch/x86/kernel/acpi/wakeup_64.S
> @@ -18,10 +18,12 @@ ENTRY(wakeup_long64)
>         cmpq    %rdx, %rax
>         jne     bogus_64_magic
>
> -       movw    $__KERNEL_DS, %ax
> -       movw    %ax, %ss
> +       movw    $__USER_DS, %ax
>         movw    %ax, %ds
>         movw    %ax, %es
> +
> +       movw    $__KERNEL_DS, %ax
> +       movw    %ax, %ss
>         movw    %ax, %fs
>         movw    %ax, %gs
>         movq    saved_rsp, %rsp

64-bit is a different animal.  DS/ES are ignored in 64-bit mode, so
they are always userspace-owned, and only matter for 32-bit user
processes.  64-bit does currently save/restore these in
x86/power/cpu.c.

--
Brian Gerst
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/x86/kernel/acpi/wakeup_64.S b/arch/x86/kernel/acpi/wakeup_64.S
index ae693b5..2ac2bc7 100644
--- a/arch/x86/kernel/acpi/wakeup_64.S
+++ b/arch/x86/kernel/acpi/wakeup_64.S
@@ -18,10 +18,12 @@  ENTRY(wakeup_long64)
 	cmpq	%rdx, %rax
 	jne	bogus_64_magic
 
-	movw	$__KERNEL_DS, %ax
-	movw	%ax, %ss	
+	movw	$__USER_DS, %ax
 	movw	%ax, %ds
 	movw	%ax, %es
+
+	movw	$__KERNEL_DS, %ax
+	movw	%ax, %ss	
 	movw	%ax, %fs
 	movw	%ax, %gs
 	movq	saved_rsp, %rsp