linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: james.morse@arm.com (James Morse)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] arm64: suspend: avoid potential TLB conflict
Date: Wed, 10 Aug 2016 10:39:50 +0100	[thread overview]
Message-ID: <57AAF666.2030501@arm.com> (raw)
In-Reply-To: <20160809175157.GC13591@leverpostej>

Hi Mark,

On 09/08/16 18:51, Mark Rutland wrote:
> On Tue, Aug 09, 2016 at 05:25:37PM +0100, James Morse wrote:
>>> @@ -217,12 +218,16 @@ static int create_safe_exec_page(void *src_start, size_t length,
>>>  	set_pte(pte, __pte(virt_to_phys((void *)dst) |
>>>  			 pgprot_val(PAGE_KERNEL_EXEC)));
>>>  
>>> -	/* Load our new page tables */
>>> -	asm volatile("msr	ttbr0_el1, %0;"
>>> -		     "isb;"
>>> -		     "tlbi	vmalle1is;"
>>> -		     "dsb	ish;"
>>> -		     "isb" : : "r"(virt_to_phys(pgd)));
>>> +	/*
>>> +	 * Load our new page tables. TTBR0 currently points to the zero page,
>>
>> fe12c00d21bb ("PM / hibernate: Introduce test_resume mode for hibernation") came
>> in with the merge window, this does a suspend followed by a resume with the user
>> page tables still loaded in ttbr0_el1.
> 
> Hmmm... given that, it looks like if we bail out in swsusp_arch_resume()
> after the call to create_safe_exec_page(), we may return to userspace
> with a corrupted TTBR0.

Ah, didn't spot that.


> We probably need to defer the call to create_safe_exec_page() after the
> other potential failure sites so as to avoid that.
> 
> Looking around it's not clear to me how/where the get_safe_page()
> allocations are cleaned up when a failure occurs.

Its dealt with by the core code: they get added to to one of
kernel/power/snapshot.c's plethora of bitmaps, and freed via
free_basic_memory_bitmaps() -> memory_bm_free() -> free_list_of_pages() ->
free_image_page().

It looks like pages allocated by get_safe_page() are on the 'forbidden_pages_map'.


Thanks,

James

  reply	other threads:[~2016-08-10  9:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-08 10:10 [PATCH] arm64: suspend: avoid potential TLB conflict Mark Rutland
2016-08-09 16:25 ` James Morse
2016-08-09 16:49   ` Mark Rutland
2016-08-09 17:51   ` Mark Rutland
2016-08-10  9:39     ` James Morse [this message]
2016-08-11 11:01       ` Mark Rutland

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=57AAF666.2030501@arm.com \
    --to=james.morse@arm.com \
    --cc=linux-arm-kernel@lists.infradead.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).