linux_dsm_epyc7002/arch
Sean Christopherson f19f5c49bb x86/speculation/l1tf: Exempt zeroed PTEs from inversion
It turns out that we should *not* invert all not-present mappings,
because the all zeroes case is obviously special.

clear_page() does not undergo the XOR logic to invert the address bits,
i.e. PTE, PMD and PUD entries that have not been individually written
will have val=0 and so will trigger __pte_needs_invert(). As a result,
{pte,pmd,pud}_pfn() will return the wrong PFN value, i.e. all ones
(adjusted by the max PFN mask) instead of zero. A zeroed entry is ok
because the page at physical address 0 is reserved early in boot
specifically to mitigate L1TF, so explicitly exempt them from the
inversion when reading the PFN.

Manifested as an unexpected mprotect(..., PROT_NONE) failure when called
on a VMA that has VM_PFNMAP and was mmap'd to as something other than
PROT_NONE but never used. mprotect() sends the PROT_NONE request down
prot_none_walk(), which walks the PTEs to check the PFNs.
prot_none_pte_entry() gets the bogus PFN from pte_pfn() and returns
-EACCES because it thinks mprotect() is trying to adjust a high MMIO
address.

[ This is a very modified version of Sean's original patch, but all
  credit goes to Sean for doing this and also pointing out that
  sometimes the __pte_needs_invert() function only gets the protection
  bits, not the full eventual pte.  But zero remains special even in
  just protection bits, so that's ok.   - Linus ]

Fixes: f22cc87f6c ("x86/speculation/l1tf: Invert all not present mappings")
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Acked-by: Andi Kleen <ak@linux.intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-08-17 10:27:36 -07:00
..
alpha Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2018-08-15 15:04:25 -07:00
arc Consolidation of Kconfig files by Christoph Hellwig. 2018-08-15 13:05:12 -07:00
arm The new and exciting feature this time around is in the clk core. 2018-08-15 21:41:21 -07:00
arm64 SCSI misc on 20180815 2018-08-15 22:06:26 -07:00
c6x kconfig: include kernel/Kconfig.preempt from init/Kconfig 2018-08-02 08:06:54 +09:00
h8300 Consolidation of Kconfig files by Christoph Hellwig. 2018-08-15 13:05:12 -07:00
hexagon Consolidation of Kconfig files by Christoph Hellwig. 2018-08-15 13:05:12 -07:00
ia64 Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2018-08-15 15:04:25 -07:00
m68k Consolidation of Kconfig files by Christoph Hellwig. 2018-08-15 13:05:12 -07:00
microblaze kconfig: include kernel/Kconfig.preempt from init/Kconfig 2018-08-02 08:06:54 +09:00
mips Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6 2018-08-15 16:01:47 -07:00
nds32 Consolidation of Kconfig files by Christoph Hellwig. 2018-08-15 13:05:12 -07:00
nios2 Consolidation of Kconfig files by Christoph Hellwig. 2018-08-15 13:05:12 -07:00
openrisc Consolidation of Kconfig files by Christoph Hellwig. 2018-08-15 13:05:12 -07:00
parisc Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2018-08-15 15:04:25 -07:00
powerpc pci-v4.19-changes 2018-08-16 09:21:54 -07:00
riscv Consolidation of Kconfig files by Christoph Hellwig. 2018-08-15 13:05:12 -07:00
s390 Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6 2018-08-15 16:01:47 -07:00
sh pci-v4.19-changes 2018-08-16 09:21:54 -07:00
sparc Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6 2018-08-15 16:01:47 -07:00
um Consolidation of Kconfig files by Christoph Hellwig. 2018-08-15 13:05:12 -07:00
unicore32 kconfig: include kernel/Kconfig.preempt from init/Kconfig 2018-08-02 08:06:54 +09:00
x86 x86/speculation/l1tf: Exempt zeroed PTEs from inversion 2018-08-17 10:27:36 -07:00
xtensa Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2018-08-15 15:04:25 -07:00
.gitignore
Kconfig Consolidation of Kconfig files by Christoph Hellwig. 2018-08-15 13:05:12 -07:00