Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1434670
| From | "Rafael J. Wysocki" <rafael@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v4] x86/power/64: Fix kernel text mapping corruption during image restoration |
| Date | 2016-06-30 17:50 +0200 |
| Message-ID | <rPMo2-2Vc-9@gated-at.bofh.it> (permalink) |
| References | (2 earlier) <rOFHY-1ok-11@gated-at.bofh.it> <rPK2R-1Bo-3@gated-at.bofh.it> <rPLLj-2HF-7@gated-at.bofh.it> <rPM4F-2Oj-9@gated-at.bofh.it> <rPM4F-2Oj-7@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Thu, Jun 30, 2016 at 5:24 PM, Andy Lutomirski <luto@amacapital.net> wrote:
> On Thu, Jun 30, 2016 at 8:17 AM, Rafael J. Wysocki <rafael@kernel.org> wrote:
>> On Thu, Jun 30, 2016 at 5:05 PM, Borislav Petkov <bp@alien8.de> wrote:
>>> On Thu, Jun 30, 2016 at 03:17:20PM +0200, Rafael J. Wysocki wrote:
>>>> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>>>>
>>>> Logan Gunthorpe reports that hibernation stopped working reliably for
>>>> him after commit ab76f7b4ab23 (x86/mm: Set NX on gap between __ex_table
>>>> and rodata).
>>>
>>> ...
>>>
>>>> +static int relocate_restore_code(void)
>>>> +{
>>>> + pgd_t *pgd;
>>>> + pud_t *pud;
>>>> +
>>>> + relocated_restore_code = get_safe_page(GFP_ATOMIC);
>>>> + if (!relocated_restore_code)
>>>> + return -ENOMEM;
>>>> +
>>>> + memcpy((void *)relocated_restore_code, &core_restore_code, PAGE_SIZE);
>>>> +
>>>> + /* Make the page containing the relocated code executable */
>>>> + pgd = (pgd_t *)__va(read_cr3()) + pgd_index(relocated_restore_code);
>>>> + pud = pud_offset(pgd, relocated_restore_code);
>>>> + if (pud_large(*pud)) {
>>>> + set_pud(pud, __pud(pud_val(*pud) & ~_PAGE_NX));
>>>> + } else {
>>>> + pmd_t *pmd = pmd_offset(pud, relocated_restore_code);
>>>> +
>>>> + if (pmd_large(*pmd)) {
>>>> + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_NX));
>>>> + } else {
>>>> + pte_t *pte = pte_offset_kernel(pmd, relocated_restore_code);
>>>> +
>>>> + set_pte(pte, __pte(pte_val(*pte) & ~_PAGE_NX));
>>>> + }
>>>> + }
>>>> + flush_tlb_all();
>>>
>>> I know you want to flush TLBs but this causes the splat below on the
>>> resume kernel.
>>>
>>> Most likely because:
>>>
>>> resume_target_kernel() does local_irq_disable() and then
>>>
>>> swsusp_arch_resume() -> relocate_restore_code() -> flush_tlb_all()
>>>
>>> and smp_call_function_many() doesn't like it when IRQs are disabled.
>>
>> Right.
>>
>> Can I invoke __flush_tlb_all() from here to flush the TLB on the local
>> CPU? That should be sufficient IMO.
>
> Yes, unless there's another CPU already up at the time, but that seems unlikely.
They are all offline at that time.
OK, let me do that then.
> FWIW, the CPU can and will cache the NX bit and the CPU will *not*
> refresh the TLB before sending a page fault. You definitely need to
> flush.
OK
> I wonder if this is also why you're seeing a certain amount of
> random corruption.
Well, the corruption we saw was not really random. I can give you all
of the details if you're interested, maybe you'll be able to figure
out what might be happening. :-)
Thanks,
Rafael
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v3] x86/power/64: Fix kernel text mapping corruption during image restoration (was: Re: ktime_get_ts64() splat during resume) "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-06-27 16:30 +0200
Re: [PATCH v3] x86/power/64: Fix kernel text mapping corruption during image restoration (was: Re: ktime_get_ts64() splat during resume) Borislav Petkov <bp@alien8.de> - 2016-06-27 22:10 +0200
Re: [PATCH v3] x86/power/64: Fix kernel text mapping corruption during image restoration Logan Gunthorpe <logang@deltatee.com> - 2016-06-28 01:40 +0200
Re: [PATCH v3] x86/power/64: Fix kernel text mapping corruption during image restoration Kees Cook <keescook@chromium.org> - 2016-06-29 16:50 +0200
Re: [PATCH v3] x86/power/64: Fix kernel text mapping corruption during image restoration Logan Gunthorpe <logang@deltatee.com> - 2016-06-30 04:00 +0200
Re: [PATCH v3] x86/power/64: Fix kernel text mapping corruption during image restoration "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-06-30 04:20 +0200
Re: [PATCH v3] x86/power/64: Fix kernel text mapping corruption during image restoration "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-06-30 05:00 +0200
Re: [PATCH v3] x86/power/64: Fix kernel text mapping corruption during image restoration Logan Gunthorpe <logang@deltatee.com> - 2016-06-30 06:00 +0200
Re: [PATCH v3] x86/power/64: Fix kernel text mapping corruption during image restoration "Rafael J. Wysocki" <rafael@kernel.org> - 2016-06-30 14:20 +0200
Re: [PATCH v3] x86/power/64: Fix kernel text mapping corruption during image restoration Borislav Petkov <bp@alien8.de> - 2016-06-30 12:00 +0200
Re: [PATCH v3] x86/power/64: Fix kernel text mapping corruption during image restoration "Rafael J. Wysocki" <rafael@kernel.org> - 2016-06-30 13:30 +0200
[PATCH v4] x86/power/64: Fix kernel text mapping corruption during image restoration "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-06-30 15:20 +0200
Re: [PATCH v4] x86/power/64: Fix kernel text mapping corruption during image restoration Borislav Petkov <bp@alien8.de> - 2016-06-30 17:10 +0200
Re: [PATCH v4] x86/power/64: Fix kernel text mapping corruption during image restoration Andy Lutomirski <luto@amacapital.net> - 2016-06-30 17:30 +0200
Re: [PATCH v4] x86/power/64: Fix kernel text mapping corruption during image restoration "Rafael J. Wysocki" <rafael@kernel.org> - 2016-06-30 17:50 +0200
Re: [PATCH v4] x86/power/64: Fix kernel text mapping corruption during image restoration Andy Lutomirski <luto@amacapital.net> - 2016-06-30 19:30 +0200
Re: [PATCH v4] x86/power/64: Fix kernel text mapping corruption during image restoration "Rafael J. Wysocki" <rafael@kernel.org> - 2016-06-30 17:40 +0200
[PATCH v5] x86/power/64: Fix kernel text mapping corruption during image restoration "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-06-30 18:10 +0200
Re: [PATCH v5] x86/power/64: Fix kernel text mapping corruption during image restoration Borislav Petkov <bp@alien8.de> - 2016-06-30 19:10 +0200
Re: [PATCH v5] x86/power/64: Fix kernel text mapping corruption during image restoration Logan Gunthorpe <logang@deltatee.com> - 2016-06-30 23:50 +0200
csiph-web