From: Thomas Garnier <thgarnie@google.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, "H . Peter Anvin" <hpa@zytor.com>,
Kees Cook <keescook@chromium.org>,
Yinghai Lu <yinghai@kernel.org>, Pavel Machek <pavel@ucw.cz>,
the arch/x86 maintainers <x86@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Linux PM list <linux-pm@vger.kernel.org>,
kernel-hardening@lists.openwall.com
Subject: Re: [PATCH v1 2/2] x86/power/64: Fix __PAGE_OFFSET usage on restore
Date: Tue, 2 Aug 2016 13:59:01 -0700 [thread overview]
Message-ID: <CAJcbSZFC-qeEySJYO9DFs=HfE087QHROW=opDRCmZo2WXB1gqw@mail.gmail.com> (raw)
In-Reply-To: <CAJZ5v0gKGhymb-53_hRCMRuRCkdAcqyGSOkVzg=pULc7Nyqd7w@mail.gmail.com>
On Tue, Aug 2, 2016 at 1:47 PM, Rafael J. Wysocki <rafael@kernel.org> wrote:
> On Tue, Aug 2, 2016 at 4:34 PM, Thomas Garnier <thgarnie@google.com> wrote:
>> On Mon, Aug 1, 2016 at 5:38 PM, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:
>>> On Monday, August 01, 2016 10:08:00 AM Thomas Garnier wrote:
>>>> When KASLR memory randomization is used, __PAGE_OFFSET is a global
>>>> variable changed during boot. The assembly code was using the variable
>>>> as an immediate value to calculate the cr3 physical address. The
>>>> physical address was incorrect resulting to a GP fault.
>>>>
>>>> Signed-off-by: Thomas Garnier <thgarnie@google.com>
>>>> ---
>>>> arch/x86/power/hibernate_asm_64.S | 12 +++++++++++-
>>>> 1 file changed, 11 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/arch/x86/power/hibernate_asm_64.S b/arch/x86/power/hibernate_asm_64.S
>>>> index 8eee0e9..8db4905 100644
>>>> --- a/arch/x86/power/hibernate_asm_64.S
>>>> +++ b/arch/x86/power/hibernate_asm_64.S
>>>> @@ -23,6 +23,16 @@
>>>> #include <asm/processor-flags.h>
>>>> #include <asm/frame.h>
>>>>
>>>> +/*
>>>> + * A global variable holds the page_offset when KASLR memory randomization
>>>> + * is enabled.
>>>> + */
>>>> +#ifdef CONFIG_RANDOMIZE_MEMORY
>>>> +#define __PAGE_OFFSET_REF __PAGE_OFFSET
>>>> +#else
>>>> +#define __PAGE_OFFSET_REF $__PAGE_OFFSET
>>>> +#endif
>>>> +
>>>> ENTRY(swsusp_arch_suspend)
>>>> movq $saved_context, %rax
>>>> movq %rsp, pt_regs_sp(%rax)
>>>> @@ -72,7 +82,7 @@ ENTRY(restore_image)
>>>> /* code below has been relocated to a safe page */
>>>> ENTRY(core_restore_code)
>>>> /* switch to temporary page tables */
>>>> - movq $__PAGE_OFFSET, %rcx
>>>> + movq __PAGE_OFFSET_REF, %rcx
>>>> subq %rcx, %rax
>>>> movq %rax, %cr3
>>>> /* flush TLB */
>>>>
>>>
>>> I'm not particularly liking the #ifdefs and they won't be really
>>> necessary if the subtraction is carried out by the C code IMO.
>>>
>>> What about the patch below instead?
>>>
>>
>> Yes, I think that's a good idea. I will test it and send PATCH v2.
>
> No need to send this patch again. Please just let me know if it works
> for you. :-)
>
It worked well when I tested it and I agree that's a better approach.
> Thanks,
> Rafael
next prev parent reply other threads:[~2016-08-02 20:59 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-01 17:07 [PATCH v1 0/2] x86/power/64: Make KASLR memory randomization compatible with hibernation Thomas Garnier
2016-08-01 17:07 ` [PATCH v1 1/2] x86/power/64: Support unaligned addresses for temporary mapping Thomas Garnier
2016-08-02 0:36 ` Rafael J. Wysocki
2016-08-02 18:01 ` Yinghai Lu
2016-08-02 17:36 ` Yinghai Lu
2016-08-02 17:48 ` Thomas Garnier
2016-08-02 19:55 ` Yinghai Lu
2016-08-03 15:29 ` Thomas Garnier
2016-08-03 18:23 ` [PATCH v2] " Yinghai Lu
2016-08-03 21:28 ` Rafael J. Wysocki
2016-08-07 1:03 ` Rafael J. Wysocki
2016-08-07 4:53 ` Yinghai Lu
2016-08-07 23:23 ` Rafael J. Wysocki
2016-08-08 7:06 ` Yinghai Lu
2016-08-08 7:23 ` Yinghai Lu
2016-08-08 13:16 ` Rafael J. Wysocki
2016-08-01 17:08 ` [PATCH v1 2/2] x86/power/64: Fix __PAGE_OFFSET usage on restore Thomas Garnier
2016-08-02 0:38 ` Rafael J. Wysocki
2016-08-02 14:34 ` Thomas Garnier
2016-08-02 20:47 ` Rafael J. Wysocki
2016-08-02 20:59 ` Thomas Garnier [this message]
2016-08-02 21:08 ` Rafael J. Wysocki
2016-08-02 23:19 ` [PATCH] x86/power/64: Do not refer to __PAGE_OFFSET from assembly code Rafael J. Wysocki
2016-08-05 10:37 ` Pavel Machek
2016-08-05 14:44 ` Rafael J. Wysocki
2016-08-05 15:21 ` Thomas Garnier
2016-08-05 23:12 ` Rafael J. Wysocki
2016-08-06 19:41 ` Pavel Machek
2016-08-01 23:48 ` [PATCH v1 0/2] x86/power/64: Make KASLR memory randomization compatible with hibernation Rafael J. Wysocki
2016-08-02 0:47 ` 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='CAJcbSZFC-qeEySJYO9DFs=HfE087QHROW=opDRCmZo2WXB1gqw@mail.gmail.com' \
--to=thgarnie@google.com \
--cc=hpa@zytor.com \
--cc=keescook@chromium.org \
--cc=kernel-hardening@lists.openwall.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pavel@ucw.cz \
--cc=rafael@kernel.org \
--cc=rjw@rjwysocki.net \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
--cc=yinghai@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).