Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1669564

Re: [PATCH] mm/hwpoison: Clear PRESENT bit for kernel 1:1 mappings of poison pages

From Borislav Petkov <bp@suse.de>
Newsgroups linux.kernel
Subject Re: [PATCH] mm/hwpoison: Clear PRESENT bit for kernel 1:1 mappings of poison pages
Date 2017-06-19 20:10 +0200
Message-ID <tU9hE-674-27@gated-at.bofh.it> (permalink)
References <tT5SN-50W-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


(drop stable from CC)

You could use git's --suppress-cc= option when sending.

On Fri, Jun 16, 2017 at 12:02:00PM -0700, Luck, Tony wrote:
> From: Tony Luck <tony.luck@intel.com>
> 
> Speculative processor accesses may reference any memory that has a
> valid page table entry.  While a speculative access won't generate
> a machine check, it will log the error in a machine check bank. That
> could cause escalation of a subsequent error since the overflow bit
> will be then set in the machine check bank status register.

...

> @@ -1056,6 +1057,40 @@ static int do_memory_failure(struct mce *m)
>  	return ret;
>  }
>  
> +#ifdef CONFIG_X86_64
> +
> +void arch_unmap_kpfn(unsigned long pfn)
> +{

I guess you can move the ifdeffery inside the function.

> +	unsigned long decoy_addr;
> +
> +	/*
> +	 * Unmap this page from the kernel 1:1 mappings to make sure
> +	 * we don't log more errors because of speculative access to
> +	 * the page.
> +	 * We would like to just call:
> +	 *	set_memory_np((unsigned long)pfn_to_kaddr(pfn), 1);
> +	 * but doing that would radically increase the odds of a
> +	 * speculative access to the posion page because we'd have
> +	 * the virtual address of the kernel 1:1 mapping sitting
> +	 * around in registers.
> +	 * Instead we get tricky.  We create a non-canonical address
> +	 * that looks just like the one we want, but has bit 63 flipped.
> +	 * This relies on set_memory_np() not checking whether we passed
> +	 * a legal address.
> +	 */
> +
> +#if PGDIR_SHIFT + 9 < 63 /* 9 because cpp doesn't grok ilog2(PTRS_PER_PGD) */

Please no side comments.

Also, explain why the build-time check. (Sign-extension going away for VA
space yadda yadda..., 5 2/3 level paging :-))

Also, I'm assuming this whole "workaround" of sorts should be Intel-only?

> +	decoy_addr = (pfn << PAGE_SHIFT) + (PAGE_OFFSET ^ BIT(63));
> +#else
> +#error "no unused virtual bit available"
> +#endif
> +
> +	if (set_memory_np(decoy_addr, 1))
> +		pr_warn("Could not invalidate pfn=0x%lx from 1:1 map \n", pfn);

WARNING: unnecessary whitespace before a quoted newline
#107: FILE: arch/x86/kernel/cpu/mcheck/mce.c:1089:
+               pr_warn("Could not invalidate pfn=0x%lx from 1:1 map \n", pfn);


-- 
Regards/Gruss,
    Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- 

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] mm/hwpoison: Clear PRESENT bit for kernel 1:1 mappings of poison pages "Luck, Tony" <tony.luck@intel.com> - 2017-06-16 22:20 +0200
  Re: [PATCH] mm/hwpoison: Clear PRESENT bit for kernel 1:1 mappings  of poison pages Borislav Petkov <bp@suse.de> - 2017-06-19 20:10 +0200
    Re: [PATCH] mm/hwpoison: Clear PRESENT bit for kernel 1:1 mappings  of poison pages "Luck, Tony" <tony.luck@intel.com> - 2017-06-21 19:50 +0200
      RE: [PATCH] mm/hwpoison: Clear PRESENT bit for kernel 1:1 mappings of  poison pages "Elliott, Robert (Persistent Memory)" <elliott@hpe.com> - 2017-06-21 22:00 +0200
        RE: [PATCH] mm/hwpoison: Clear PRESENT bit for kernel 1:1 mappings  of poison pages "Luck, Tony" <tony.luck@intel.com> - 2017-06-21 22:20 +0200
      Re: [PATCH] mm/hwpoison: Clear PRESENT bit for kernel 1:1 mappings  of poison pages Borislav Petkov <bp@suse.de> - 2017-06-22 11:40 +0200
        git send-email (w/o Cc: stable) "Luck, Tony" <tony.luck@intel.com> - 2017-06-30 00:20 +0200
          Re: git send-email (w/o Cc: stable) Borislav Petkov <bp@suse.de> - 2017-06-30 09:10 +0200
      RE: [PATCH] mm/hwpoison: Clear PRESENT bit for kernel 1:1 mappings of  poison pages "Elliott, Robert (Persistent Memory)" <elliott@hpe.com> - 2017-06-24 00:30 +0200
        Re: [PATCH] mm/hwpoison: Clear PRESENT bit for kernel 1:1 mappings of  poison pages Dan Williams <dan.j.williams@intel.com> - 2017-06-28 00:10 +0200
        RE: [PATCH] mm/hwpoison: Clear PRESENT bit for kernel 1:1 mappings  of poison pages "Luck, Tony" <tony.luck@intel.com> - 2017-06-28 00:10 +0200
  Re: [PATCH] mm/hwpoison: Clear PRESENT bit for kernel 1:1 mappings  of poison pages Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> - 2017-06-21 04:20 +0200
    Re: [PATCH] mm/hwpoison: Clear PRESENT bit for kernel 1:1 mappings  of poison pages "Luck, Tony" <tony.luck@intel.com> - 2017-06-21 20:00 +0200
      RE: [PATCH] mm/hwpoison: Clear PRESENT bit for kernel 1:1 mappings of  poison pages "Elliott, Robert (Persistent Memory)" <elliott@hpe.com> - 2017-06-21 21:50 +0200
        RE: [PATCH] mm/hwpoison: Clear PRESENT bit for kernel 1:1 mappings  of poison pages "Luck, Tony" <tony.luck@intel.com> - 2017-06-21 22:40 +0200
          Re: [PATCH] mm/hwpoison: Clear PRESENT bit for kernel 1:1 mappings of  poison pages Dan Williams <dan.j.williams@intel.com> - 2017-06-23 07:10 +0200
            Re: [PATCH] mm/hwpoison: Clear PRESENT bit for kernel 1:1 mappings  of poison pages "Luck, Tony" <tony.luck@intel.com> - 2017-06-23 23:00 +0200

csiph-web