1. 25 Aug, 2015 1 commit
  2. 20 Aug, 2015 1 commit
  3. 29 Jul, 2015 1 commit
    • Luis R. Rodriguez's avatar
      arch/*/io.h: Add ioremap_uc() to all architectures · 4c73e892
      Luis R. Rodriguez authored
      This adds ioremap_uc() only for architectures that do not
      include asm-generic.h/io.h as that already provides a default
      definition for them for both cases where you have CONFIG_MMU
      and you do not, and because of this, the number of architectures
      this patch address is less than the architectures that the
      ioremap_wt() patch addressed, "arch/*/io.h: Add ioremap_wt() to
      all architectures").
      
      In order to reduce the number of architectures we have to
      modify by adding new architecture IO APIs we'll have to review
      the architectures in this patch, see why they can't add
      asm-generic.h/io.h or issues that would be created by doing
      so and then spread a consistent inclusion of this header
      towards the end of their own header. For instance arch/metag
      includes the asm-generic/io.h *before* the ioremap*()
      definitions, this should be the other way around but only
      once we have guard wrappers for the non-MMU case also for
      asm-generic/io.h.
      Reported-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
      Signed-off-by: default avatarLuis R. Rodriguez <mcgrof@suse.com>
      Cc: Abhilash Kesavan <a.kesavan@samsung.com>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: Chris Metcalf <cmetcalf@ezchip.com>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Fengguang Wu <fengguang.wu@intel.com>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Greg Ungerer <gerg@uclinux.org>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Haavard Skinnemoen <hskinnemoen@gmail.com>
      Cc: Hans-Christian Egtvedt <egtvedt@samfundet.no>
      Cc: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
      Cc: Kyle McMartin <kyle@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Hurley <peter@hurleysoftware.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rob Herring <robh@kernel.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Toshi Kani <toshi.kani@hp.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: linux-am33-list@redhat.com
      Cc: linux-arch@vger.kernel.org
      Cc: linux-m68k@lists.linux-m68k.org
      Cc: linux-sh@vger.kernel.org
      Cc: linuxppc-dev@lists.ozlabs.org
      Link: http://lkml.kernel.org/r/20150728181713.GB30479@wotan.suse.deSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      4c73e892
  4. 21 Jul, 2015 5 commits
    • Luis R. Rodriguez's avatar
      drivers/video/fbdev/atyfb: Use arch_phys_wc_add() and ioremap_wc() · 7d89a3cb
      Luis R. Rodriguez authored
      This driver uses strong UC for the MMIO region, and ioremap_wc()
      for the framebuffer to whitelist for the WC MTRR that can be
      changed to WC. On PAT systems we don't need the MTRR call so
      just use arch_phys_wc_add() there, this lets us remove all those
      ifdefs. Let's also be consistent and use ioremap_wc() for ATARI
      as well.
      
      There are a few motivations for this:
      
        a) Take advantage of PAT when available.
      
        b) Help bury MTRR code away, MTRR is architecture specific and
           on x86 it is being replaced by PAT.
      
        c) Help with the goal of eventually using _PAGE_CACHE_UC over
           _PAGE_CACHE_UC_MINUS on x86 on ioremap_nocache() (see commit
           de33c442 titled "x86 PAT: fix performance drop for glx,
           use UC minus for ioremap(), ioremap_nocache() and
           pci_mmap_page_range()").
      
      The conversion done is expressed by the following Coccinelle
      SmPL patch, it additionally required manual intervention to
      address all the ifdeffery and removal of redundant things which
      arch_phys_wc_add() already addresses such as verbose message
      about when MTRR fails and doing nothing when we didn't get an
      MTRR:
      
      	@ mtrr_found @
      	expression index, base, size;
      	@@
      
      	-index = mtrr_add(base, size, MTRR_TYPE_WRCOMB, 1);
      	+index = arch_phys_wc_add(base, size);
      
      	@ mtrr_rm depends on mtrr_found @
      	expression mtrr_found.index, mtrr_found.base, mtrr_found.size;
      	@@
      
      	-mtrr_del(index, base, size);
      	+arch_phys_wc_del(index);
      
      	@ mtrr_rm_zero_arg depends on mtrr_found @
      	expression mtrr_found.index;
      	@@
      
      	-mtrr_del(index, 0, 0);
      	+arch_phys_wc_del(index);
      
      	@ mtrr_rm_fb_info depends on mtrr_found @
      	struct fb_info *info;
      	expression mtrr_found.index;
      	@@
      
      	-mtrr_del(index, info->fix.smem_start, info->fix.smem_len);
      	+arch_phys_wc_del(index);
      
      	@ ioremap_replace_nocache depends on mtrr_found @
      	struct fb_info *info;
      	expression base, size;
      	@@
      
      	-info->screen_base = ioremap_nocache(base, size);
      	+info->screen_base = ioremap_wc(base, size);
      
      	@ ioremap_replace_default depends on mtrr_found @
      	struct fb_info *info;
      	expression base, size;
      	@@
      
      	-info->screen_base = ioremap(base, size);
      	+info->screen_base = ioremap_wc(base, size);
      Signed-off-by: default avatarLuis R. Rodriguez <mcgrof@suse.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andrzej Hajda <a.hajda@samsung.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Antonino Daplas <adaplas@gmail.com>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: Dave Airlie <airlied@redhat.com>
      Cc: Davidlohr Bueso <dbueso@suse.de>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
      Cc: Juergen Gross <jgross@suse.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Mathias Krause <minipli@googlemail.com>
      Cc: Mel Gorman <mgorman@suse.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rob Clark <robdclark@gmail.com>
      Cc: Suresh Siddha <sbsiddha@gmail.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
      Cc: Toshi Kani <toshi.kani@hp.com>
      Cc: Ville Syrjälä <syrjala@sci.fi>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Cc: arnd@arndb.de
      Cc: benh@kernel.crashing.org
      Cc: dan.j.williams@intel.com
      Cc: geert@linux-m68k.org
      Cc: hch@lst.de
      Cc: hmh@hmh.eng.br
      Cc: linux-fbdev@vger.kernel.org
      Cc: linux-mm@kvack.org
      Cc: linux-pci@vger.kernel.org
      Cc: mpe@ellerman.id.au
      Cc: mst@redhat.com
      Cc: ralf@linux-mips.org
      Cc: ross.zwisler@linux.intel.com
      Cc: stefan.bader@canonical.com
      Cc: tj@kernel.org
      Cc: ville.syrjala@linux.intel.com
      Link: http://lkml.kernel.org/r/1436491499-3289-5-git-send-email-mcgrof@do-not-panic.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      7d89a3cb
    • Luis R. Rodriguez's avatar
      drivers/video/fbdev/atyfb: Replace MTRR UC hole with strong UC · 3cc2dac5
      Luis R. Rodriguez authored
      Replace a WC MTRR call followed by a UC MTRR "hole" call with a
      single WC MTRR call and use strong UC to protect the MMIO region
      and account for the device's architecture and MTRR size
      requirements.
      
      The atyfb driver relies on two overlapping MTRRs. It does this
      to account for the fact that, on some devices, it has the MMIO
      region bundled together with the framebuffer on the same PCI BAR
      and the hardware requirement on MTRRs on both base and size to
      be powers of two.
      
      In the worst case, the PCI BAR is of 16 MiB while the MMIO
      region is on the last 4 KiB of the same PCI BAR. If we use just
      one MTRR for WC, we can only end up with an 8 MiB or 16 MiB
      framebuffer. Using a 16 MiB WC framebuffer area is unacceptable
      since we need the MMIO region to not be write-combined. An 8 MiB
      WC framebuffer option does not let use quite a bit of
      framebuffer space, it would reduce the resolution capability of
      the device considerably.
      
      An alternative is to use many MTRRs but on some systems that
      could mean not having enough MTRRs to cover the framebuffer. The
      current solution is to issue a 16 MiB WC MTRR followed by a 4
      KiB UC MTRR on the last 4 KiB. Its worth mentioning and
      documenting that the current ioremap*() strategy as well: the
      first ioremap() is used only for the MMIO region, a second
      ioremap() call is used for the framebuffer *and* the MMIO
      region, the MMIO region then ends up mmapped twice.
      
      Two ioremap() calls are used since in some situations the
      framebuffer actually ends up on a separate auxiliary PCI BAR,
      but this is not always true. In the worst case, the PCI BAR is
      shared for both MMIO and the framebuffer. By allowing
      overlapping ioremap() calls, the driver enables two types of
      devices with one simple ioremap() strategy.
      
      See also:
      
        2f9e8973 ("x86/mm/mtrr, pat: Document Write Combining MTRR type effects on PAT / non-PAT pages")
      
      By default, Linux today defaults both pci_mmap_page_range() and
      ioremap_nocache() to use _PAGE_CACHE_MODE_UC_MINUS. On x86,
      ioremap() aliases ioremap_nocache(). The preferred value for
      Linux may soon change, however, the goal is to use
      _PAGE_CACHE_MODE_UC by default in the future.
      
      We can use ioremap_uc() to set PCD=1, PWT=1 on non-PAT systems
      and use a PAT value of UC for PAT systems. This will ensure the
      same settings are in place regardless of what Linux decides to
      use by default later and to not regress our MTRR strategy since
      the effective memory type will differ depending on the value
      used. Using a WC MTRR on such an area will be nullified. This
      technique can be used to protect the MMIO region in this
      driver's case and address the restrictions of the device's
      architecture as well as restrictions set upon us by powers of 2
      when using MTRRs.
      
      This allows us to replace the two MTRR calls with a single 16
      MiB WC MTRR and use page-attribute settings for non-PAT and PAT
      entry values for PAT systems to ensure the appropriate effective
      memory type won't have a write-combining effect on the MMIO
      region on both non-PAT and PAT systems. The framebuffer area
      will be sure to get the write-combined effective memory type by
      white-listing it with ioremap_wc().
      
      We ensure the desired effective memory types are set by:
      
      0) Using one ioremap_uc() for the MMIO region alone.
         This will set the page attribute settings for the MMIO
         region to PCD=1, PWT=1 for non-PAT systems while using a
         strong UC value on PAT systems.
      
      1) Fixing the framebuffer ioremapped area to exclude the
         MMIO region and using ioremap_wc() instead to whitelist
         the area we want for write-combining.
      
      In both cases, an implementation defined (as per 2f9e8973)
      effective memory type of WC is used for the framebuffer for
      non-PAT systems.
      Signed-off-by: default avatarLuis R. Rodriguez <mcgrof@suse.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andrzej Hajda <a.hajda@samsung.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Antonino Daplas <adaplas@gmail.com>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: Dave Airlie <airlied@redhat.com>
      Cc: Davidlohr Bueso <dbueso@suse.de>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
      Cc: Juergen Gross <jgross@suse.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Mathias Krause <minipli@googlemail.com>
      Cc: Mel Gorman <mgorman@suse.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rob Clark <robdclark@gmail.com>
      Cc: Suresh Siddha <sbsiddha@gmail.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
      Cc: Toshi Kani <toshi.kani@hp.com>
      Cc: Ville Syrjälä <syrjala@sci.fi>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Cc: arnd@arndb.de
      Cc: benh@kernel.crashing.org
      Cc: dan.j.williams@intel.com
      Cc: geert@linux-m68k.org
      Cc: hch@lst.de
      Cc: hmh@hmh.eng.br
      Cc: linux-fbdev@vger.kernel.org
      Cc: linux-mm@kvack.org
      Cc: linux-pci@vger.kernel.org
      Cc: mpe@ellerman.id.au
      Cc: mst@redhat.com
      Cc: ralf@linux-mips.org
      Cc: ross.zwisler@linux.intel.com
      Cc: stefan.bader@canonical.com
      Cc: tj@kernel.org
      Cc: ville.syrjala@linux.intel.com
      Link: http://lkml.kernel.org/r/1435196060-27350-3-git-send-email-mcgrof@do-not-panic.com
      Link: http://lkml.kernel.org/r/1436491499-3289-4-git-send-email-mcgrof@do-not-panic.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      3cc2dac5
    • Luis R. Rodriguez's avatar
      drivers/video/fbdev/atyfb: Clarify ioremap() base and length used · f55de6ec
      Luis R. Rodriguez authored
      Adjust the ioremap() call for the framebuffer to use the same
      values we later use for the framebuffer. This will make it
      easier to review the next change.
      
      The size of the framebuffer varies but since this is for PCI we
      *know* this defaults to 0x800000. atyfb_setup_generic() is
      *only* used on PCI probe.
      
      No functional change.
      Signed-off-by: default avatarLuis R. Rodriguez <mcgrof@suse.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andrzej Hajda <a.hajda@samsung.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Antonino Daplas <adaplas@gmail.com>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: Dave Airlie <airlied@redhat.com>
      Cc: Davidlohr Bueso <dbueso@suse.de>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
      Cc: Juergen Gross <jgross@suse.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Mathias Krause <minipli@googlemail.com>
      Cc: Mel Gorman <mgorman@suse.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rob Clark <robdclark@gmail.com>
      Cc: Suresh Siddha <sbsiddha@gmail.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
      Cc: Toshi Kani <toshi.kani@hp.com>
      Cc: Ville Syrjälä <syrjala@sci.fi>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Cc: arnd@arndb.de
      Cc: benh@kernel.crashing.org
      Cc: dan.j.williams@intel.com
      Cc: geert@linux-m68k.org
      Cc: hch@lst.de
      Cc: hmh@hmh.eng.br
      Cc: linux-fbdev@vger.kernel.org
      Cc: linux-mm@kvack.org
      Cc: linux-pci@vger.kernel.org
      Cc: mpe@ellerman.id.au
      Cc: mst@redhat.com
      Cc: ralf@linux-mips.org
      Cc: ross.zwisler@linux.intel.com
      Cc: stefan.bader@canonical.com
      Cc: tj@kernel.org
      Cc: ville.syrjala@linux.intel.com
      Link: http://lkml.kernel.org/r/1436491499-3289-3-git-send-email-mcgrof@do-not-panic.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      f55de6ec
    • Luis R. Rodriguez's avatar
      drivers/video/fbdev/atyfb: Carve out framebuffer length fudging into a helper · eacd2d54
      Luis R. Rodriguez authored
      The size of the framebuffer to be used needs to be fudged to
      account for the different type of devices that are out there.
      This captures what is required to do well, we'll reuse this
      later.
      
      This has no functional changes.
      Signed-off-by: default avatarLuis R. Rodriguez <mcgrof@suse.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Mathias Krause <minipli@googlemail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
      Cc: airlied@redhat.com
      Cc: arnd@arndb.de
      Cc: benh@kernel.crashing.org
      Cc: dan.j.williams@intel.com
      Cc: geert@linux-m68k.org
      Cc: hch@lst.de
      Cc: hmh@hmh.eng.br
      Cc: jgross@suse.com
      Cc: linux-fbdev@vger.kernel.org
      Cc: linux-mm@kvack.org
      Cc: luto@amacapital.net
      Cc: mpe@ellerman.id.au
      Cc: mst@redhat.com
      Cc: ralf@linux-mips.org
      Cc: ross.zwisler@linux.intel.com
      Cc: stefan.bader@canonical.com
      Cc: syrjala@sci.fi
      Cc: tj@kernel.org
      Cc: toshi.kani@hp.com
      Cc: ville.syrjala@linux.intel.com
      Link: http://lkml.kernel.org/r/1435251019-32421-1-git-send-email-mcgrof@do-not-panic.com
      Link: http://lkml.kernel.org/r/1436491499-3289-2-git-send-email-mcgrof@do-not-panic.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      eacd2d54
    • Luis R. Rodriguez's avatar
      x86/mm, asm-generic: Add IOMMU ioremap_uc() variant default · 8c7ea50c
      Luis R. Rodriguez authored
      We currently have no safe way of currently defining architecture
      agnostic IOMMU ioremap_*() variants. The trend is for folks to
      *assume* that ioremap_nocache() should be the default everywhere
      and then add this mapping on each architectures -- this is not
      correct today for a variety of reasons.
      
      We have two options:
      
        1) Sit and wait for every architecture in Linux to get a
           an ioremap_*() variant defined before including it upstream.
      
        2) Gather consensus on a safe architecture agnostic ioremap_*()
           default.
      
      Approach 1) introduces development latencies, and since 2) will
      take time and work on clarifying semantics the only remaining
      sensible thing to do to avoid issues is returning NULL on
      ioremap_*() variants.
      
      In order for this to work we must have all architectures declare
      their own ioremap_*() variants as defined. This will take some
      work, do this for ioremp_uc() to set the example as its only
      currently implemented on x86. Document all this.
      
      We only provide implementation support for ioremap_uc() as the
      other ioremap_*() variants are well defined all over the kernel
      for other architectures already.
      Signed-off-by: default avatarLuis R. Rodriguez <mcgrof@suse.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: arnd@arndb.de
      Cc: benh@kernel.crashing.org
      Cc: bp@suse.de
      Cc: dan.j.williams@intel.com
      Cc: geert@linux-m68k.org
      Cc: hch@lst.de
      Cc: hmh@hmh.eng.br
      Cc: jgross@suse.com
      Cc: linux-mm@kvack.org
      Cc: luto@amacapital.net
      Cc: mpe@ellerman.id.au
      Cc: mst@redhat.com
      Cc: ralf@linux-mips.org
      Cc: ross.zwisler@linux.intel.com
      Cc: stefan.bader@canonical.com
      Cc: tj@kernel.org
      Cc: tomi.valkeinen@ti.com
      Cc: toshi.kani@hp.com
      Link: http://lkml.kernel.org/r/1436488096-3165-1-git-send-email-mcgrof@do-not-panic.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      8c7ea50c
  5. 20 Jul, 2015 1 commit
  6. 18 Jun, 2015 2 commits
    • Luis R. Rodriguez's avatar
      x86/mm/pat, drivers/infiniband/ipath: Use arch_phys_wc_add() and require PAT disabled · 7ea402d0
      Luis R. Rodriguez authored
      We are burrying direct access to MTRR code support on
      x86 in order to take advantage of PAT. In the future, we
      also want to make the default behaviour of ioremap_nocache()
      to use strong UC, use of mtrr_add() on those systems
      would make write-combining void.
      
      In order to help both enable us to later make strong
      UC default and in order to phase out direct MTRR access
      code port the driver over to arch_phys_wc_add() and
      annotate that the device driver requires systems to
      boot with PAT disabled, with the 'nopat' kernel parameter.
      
      This is a workable compromise given that the ipath device
      driver powers the old HTX bus cards that only work in
      AMD systems, while the newer IB/qib device driver
      powers all PCI-e cards. The ipath device driver is
      obsolete, hardware is hard to find and because of this
      its a reasonable compromise to require users of ipath
      to boot with 'nopat'.
      Signed-off-by: default avatarLuis R. Rodriguez <mcgrof@suse.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Acked-by: default avatarDoug Ledford <dledford@redhat.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Andy Walls <awalls@md.metrocast.net>
      Cc: Antonino Daplas <adaplas@gmail.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Bjorn Helgaas <bhelgaas@google.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: Dave Airlie <airlied@redhat.com>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Hal Rosenstock <hal.rosenstock@gmail.com>
      Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
      Cc: Juergen Gross <jgross@suse.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Cc: Mike Marciniszyn <mike.marciniszyn@intel.com>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
      Cc: Roger Pau Monné <roger.pau@citrix.com>
      Cc: Roland Dreier <roland@purestorage.com>
      Cc: Sean Hefty <sean.hefty@intel.com>
      Cc: Stefan Bader <stefan.bader@canonical.com>
      Cc: Suresh Siddha <sbsiddha@gmail.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
      Cc: Ville Syrjälä <syrjala@sci.fi>
      Cc: infinipath@intel.com
      Cc: jbeulich@suse.com
      Cc: konrad.wilk@oracle.com
      Cc: linux-rdma@vger.kernel.org
      Cc: mchehab@osg.samsung.com
      Cc: toshi.kani@hp.com
      Link: http://lkml.kernel.org/r/1434053994-2196-4-git-send-email-mcgrof@do-not-panic.com
      Link: http://lkml.kernel.org/r/1434356898-25135-5-git-send-email-bp@alien8.deSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      7ea402d0
    • Luis R. Rodriguez's avatar
      x86/mm/pat, drivers/media/ivtv: Use arch_phys_wc_add() and require PAT disabled · 1bf1735b
      Luis R. Rodriguez authored
      We are burrying direct access to MTRR code support on
      x86 in order to take advantage of PAT. In the future, we
      also want to make the default behavior of ioremap_nocache()
      to use strong UC, at which point the use of mtrr_add() on
      those systems would make write-combining void.
      
      In order to help both enable us to later make strong
      UC default and in order to phase out direct MTRR access
      code, port the driver over to the arch_phys_wc_add() API
      and annotate that the device driver requires systems to
      boot with PAT disabled, with the 'nopat' kernel parameter.
      
      This is a workable compromise given that the hardware is
      really rare these days, and perhaps only some lost souls
      stuck with obsolete hardware are expected to be using this
      feature of the device driver.
      Signed-off-by: default avatarLuis R. Rodriguez <mcgrof@suse.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Acked-by: default avatarAndy Walls <awalls@md.metrocast.net>
      Acked-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Antonino Daplas <adaplas@gmail.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: Dave Airlie <airlied@redhat.com>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Doug Ledford <dledford@redhat.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
      Cc: Juergen Gross <jgross@suse.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Roger Pau Monné <roger.pau@citrix.com>
      Cc: Stefan Bader <stefan.bader@canonical.com>
      Cc: Suresh Siddha <sbsiddha@gmail.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ville Syrjälä <syrjala@sci.fi>
      Cc: bhelgaas@google.com
      Cc: konrad.wilk@oracle.com
      Cc: linux-media@vger.kernel.org
      Cc: tomi.valkeinen@ti.com
      Cc: toshi.kani@hp.com
      Link: http://lkml.kernel.org/r/1434053994-2196-2-git-send-email-mcgrof@do-not-panic.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      1bf1735b
  7. 07 Jun, 2015 13 commits
    • Toshi Kani's avatar
      drivers/block/pmem: Map NVDIMM in Write-Through mode · 957561ec
      Toshi Kani authored
      The pmem driver maps NVDIMM uncacheable so that we don't lose
      data which hasn't reached non-volatile storage in the case of a
      crash. Change this to Write-Through mode which provides uncached
      writes but cached reads, thus improving read performance.
      Signed-off-by: default avatarToshi Kani <toshi.kani@hp.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Acked-by: default avatarDan Williams <dan.j.williams@intel.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Elliott@hp.com
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Luis R. Rodriguez <mcgrof@suse.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: arnd@arndb.de
      Cc: hch@lst.de
      Cc: hmh@hmh.eng.br
      Cc: jgross@suse.com
      Cc: konrad.wilk@oracle.com
      Cc: linux-mm <linux-mm@kvack.org>
      Cc: linux-nvdimm@lists.01.org
      Cc: stefan.bader@canonical.com
      Cc: yigal@plexistor.com
      Link: http://lkml.kernel.org/r/1433436928-31903-14-git-send-email-bp@alien8.deSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      957561ec
    • Toshi Kani's avatar
      x86/mm/pat: Add set_memory_wt() for Write-Through type · 623dffb2
      Toshi Kani authored
      Now that reserve_ram_pages_type() accepts the WT type, add
      set_memory_wt(), set_memory_array_wt() and set_pages_array_wt()
      in order to be able to set memory to Write-Through page cache
      mode.
      
      Also, extend ioremap_change_attr() to accept the WT type.
      Signed-off-by: default avatarToshi Kani <toshi.kani@hp.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Elliott@hp.com
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Luis R. Rodriguez <mcgrof@suse.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: arnd@arndb.de
      Cc: hch@lst.de
      Cc: hmh@hmh.eng.br
      Cc: jgross@suse.com
      Cc: konrad.wilk@oracle.com
      Cc: linux-mm <linux-mm@kvack.org>
      Cc: linux-nvdimm@lists.01.org
      Cc: stefan.bader@canonical.com
      Cc: yigal@plexistor.com
      Link: http://lkml.kernel.org/r/1433436928-31903-13-git-send-email-bp@alien8.deSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      623dffb2
    • Toshi Kani's avatar
      x86/mm/pat: Extend set_page_memtype() to support Write-Through type · 35a5a104
      Toshi Kani authored
      As set_memory_wb() calls free_ram_pages_type(), which then calls
      set_page_memtype() with -1, _PGMT_DEFAULT is used for tracking
      the WB type. _PGMT_WB is defined but unused. Thus, rename
      _PGMT_DEFAULT to _PGMT_WB to clarify the usage, and release the
      slot used by _PGMT_WB.
      
      Furthermore, change free_ram_pages_type() to call
      set_page_memtype() with _PGMT_WB, and get_page_memtype() to
      return _PAGE_CACHE_MODE_WB for _PGMT_WB.
      
      Then, define _PGMT_WT in the freed slot. This allows
      set_page_memtype() to track the WT type.
      Signed-off-by: default avatarToshi Kani <toshi.kani@hp.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Elliott@hp.com
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Luis R. Rodriguez <mcgrof@suse.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: arnd@arndb.de
      Cc: hch@lst.de
      Cc: hmh@hmh.eng.br
      Cc: jgross@suse.com
      Cc: konrad.wilk@oracle.com
      Cc: linux-mm <linux-mm@kvack.org>
      Cc: linux-nvdimm@lists.01.org
      Cc: stefan.bader@canonical.com
      Cc: yigal@plexistor.com
      Link: http://lkml.kernel.org/r/1433436928-31903-12-git-send-email-bp@alien8.deSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      35a5a104
    • Toshi Kani's avatar
      x86/mm/pat: Add pgprot_writethrough() · d1b4bfbf
      Toshi Kani authored
      Add pgprot_writethrough() for setting page protection flags to
      Write-Through mode.
      Signed-off-by: default avatarToshi Kani <toshi.kani@hp.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Elliott@hp.com
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Luis R. Rodriguez <mcgrof@suse.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: arnd@arndb.de
      Cc: hch@lst.de
      Cc: hmh@hmh.eng.br
      Cc: jgross@suse.com
      Cc: konrad.wilk@oracle.com
      Cc: linux-mm <linux-mm@kvack.org>
      Cc: linux-nvdimm@lists.01.org
      Cc: stefan.bader@canonical.com
      Cc: yigal@plexistor.com
      Link: http://lkml.kernel.org/r/1433436928-31903-11-git-send-email-bp@alien8.deSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      d1b4bfbf
    • Toshi Kani's avatar
      video/fbdev, asm/io.h: Remove ioremap_writethrough() · c7c95f19
      Toshi Kani authored
      Replace all calls to ioremap_writethrough() with ioremap_wt().
      Remove ioremap_writethrough() too.
      Signed-off-by: default avatarToshi Kani <toshi.kani@hp.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Acked-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Elliott@hp.com
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Luis R. Rodriguez <mcgrof@suse.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: arnd@arndb.de
      Cc: hch@lst.de
      Cc: hmh@hmh.eng.br
      Cc: jgross@suse.com
      Cc: konrad.wilk@oracle.com
      Cc: linux-mm <linux-mm@kvack.org>
      Cc: linux-nvdimm@lists.01.org
      Cc: stefan.bader@canonical.com
      Cc: yigal@plexistor.com
      Link: http://lkml.kernel.org/r/1433436928-31903-10-git-send-email-bp@alien8.deSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      c7c95f19
    • Toshi Kani's avatar
      arch/*/io.h: Add ioremap_wt() to all architectures · 556269c1
      Toshi Kani authored
      Add ioremap_wt() to all arch-specific asm/io.h headers which
      define ioremap_wc() locally. These headers do not include
      <asm-generic/iomap.h>. Some of them include <asm-generic/io.h>,
      but ioremap_wt() is defined for consistency since they define
      all ioremap_xxx locally.
      
      In all architectures without Write-Through support, ioremap_wt()
      is defined indentical to ioremap_nocache().
      
      frv and m68k already have ioremap_writethrough(). On those we
      add ioremap_wt() indetical to ioremap_writethrough() and defines
      ARCH_HAS_IOREMAP_WT in both architectures.
      
      The ioremap_wt() interface is exported to drivers.
      Signed-off-by: default avatarToshi Kani <toshi.kani@hp.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Elliott@hp.com
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Luis R. Rodriguez <mcgrof@suse.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: arnd@arndb.de
      Cc: hch@lst.de
      Cc: hmh@hmh.eng.br
      Cc: jgross@suse.com
      Cc: konrad.wilk@oracle.com
      Cc: linux-mm <linux-mm@kvack.org>
      Cc: linux-nvdimm@lists.01.org
      Cc: stefan.bader@canonical.com
      Cc: yigal@plexistor.com
      Link: http://lkml.kernel.org/r/1433436928-31903-9-git-send-email-bp@alien8.deSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      556269c1
    • Toshi Kani's avatar
      x86/mm, asm-generic: Add ioremap_wt() for creating Write-Through mappings · d838270e
      Toshi Kani authored
      Add ioremap_wt() for creating Write-Through mappings on x86. It
      follows the same model as ioremap_wc() for multi-arch support.
      Define ARCH_HAS_IOREMAP_WT in the x86 version of io.h to
      indicate that ioremap_wt() is implemented on x86.
      
      Also update the PAT documentation file to cover ioremap_wt().
      Signed-off-by: default avatarToshi Kani <toshi.kani@hp.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Elliott@hp.com
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Luis R. Rodriguez <mcgrof@suse.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: arnd@arndb.de
      Cc: hch@lst.de
      Cc: hmh@hmh.eng.br
      Cc: jgross@suse.com
      Cc: konrad.wilk@oracle.com
      Cc: linux-mm <linux-mm@kvack.org>
      Cc: linux-nvdimm@lists.01.org
      Cc: stefan.bader@canonical.com
      Cc: yigal@plexistor.com
      Link: http://lkml.kernel.org/r/1433436928-31903-8-git-send-email-bp@alien8.deSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      d838270e
    • Toshi Kani's avatar
      x86/mm: Teach is_new_memtype_allowed() about Write-Through type · ecb2feba
      Toshi Kani authored
      __ioremap_caller() calls reserve_memtype() and the passed down
      @new_pcm contains the actual page cache type it reserved in the
      success case.
      
      is_new_memtype_allowed() verifies if converting to the new page
      cache type is allowed when @pcm (the requested type) is
      different from @new_pcm.
      
      When WT is requested, the caller expects that writes are ordered
      and uncached. Therefore, enhance is_new_memtype_allowed() to
      disallow the following cases:
      
       - If the request is WT, mapping type cannot be WB
       - If the request is WT, mapping type cannot be WC
      Signed-off-by: default avatarToshi Kani <toshi.kani@hp.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Reviewed-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Elliott@hp.com
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Luis R. Rodriguez <mcgrof@suse.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: arnd@arndb.de
      Cc: hch@lst.de
      Cc: hmh@hmh.eng.br
      Cc: jgross@suse.com
      Cc: konrad.wilk@oracle.com
      Cc: linux-mm <linux-mm@kvack.org>
      Cc: linux-nvdimm@lists.01.org
      Cc: stefan.bader@canonical.com
      Cc: yigal@plexistor.com
      Link: http://lkml.kernel.org/r/1433436928-31903-7-git-send-email-bp@alien8.deSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      ecb2feba
    • Toshi Kani's avatar
      x86/mm/pat: Change reserve_memtype() for Write-Through type · 0d69bdff
      Toshi Kani authored
      When a target range is in RAM, reserve_ram_pages_type() verifies
      the requested type. Change it to fail WT and WP requests with
      -EINVAL since set_page_memtype() is limited to handle three
      types: WB, WC and UC-.
      Signed-off-by: default avatarToshi Kani <toshi.kani@hp.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Elliott@hp.com
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Luis R. Rodriguez <mcgrof@suse.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: arnd@arndb.de
      Cc: hch@lst.de
      Cc: hmh@hmh.eng.br
      Cc: jgross@suse.com
      Cc: konrad.wilk@oracle.com
      Cc: linux-mm <linux-mm@kvack.org>
      Cc: linux-nvdimm@lists.01.org
      Cc: stefan.bader@canonical.com
      Cc: yigal@plexistor.com
      Link: http://lkml.kernel.org/r/1433436928-31903-6-git-send-email-bp@alien8.deSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      0d69bdff
    • Toshi Kani's avatar
      x86/mm/pat: Use 7th PAT MSR slot for Write-Through PAT type · d79a40ca
      Toshi Kani authored
      Assign Write-Through type to the PA7 slot in the PAT MSR when
      the processor is not affected by PAT errata. The PA7 slot is
      chosen to improve robustness in the presence of errata that
      might cause the high PAT bit to be ignored. This way a buggy PA7
      slot access will hit the PA3 slot, which is UC, so at worst we
      lose performance without causing a correctness issue.
      
      The following Intel processors are affected by the PAT errata.
      
        Errata               CPUID
        ----------------------------------------------------
        Pentium 2, A52       family 0x6, model 0x5
        Pentium 3, E27       family 0x6, model 0x7, 0x8
        Pentium 3 Xenon, G26 family 0x6, model 0x7, 0x8, 0xa
        Pentium M, Y26       family 0x6, model 0x9
        Pentium M 90nm, X9   family 0x6, model 0xd
        Pentium 4, N46       family 0xf, model 0x0
      
      Instead of making sharp boundary checks, we remain conservative
      and exclude all Pentium 2, 3, M and 4 family processors. For
      those, _PAGE_CACHE_MODE_WT is redirected to UC- per the default
      setup in __cachemode2pte_tbl[].
      Signed-off-by: default avatarToshi Kani <toshi.kani@hp.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Elliott@hp.com
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Luis R. Rodriguez <mcgrof@suse.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: arnd@arndb.de
      Cc: hch@lst.de
      Cc: hmh@hmh.eng.br
      Cc: jgross@suse.com
      Cc: konrad.wilk@oracle.com
      Cc: linux-mm <linux-mm@kvack.org>
      Cc: linux-nvdimm@lists.01.org
      Cc: stefan.bader@canonical.com
      Cc: yigal@plexistor.com
      Link: https://lkml.kernel.org/r/1433187393-22688-2-git-send-email-toshi.kani@hp.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      d79a40ca
    • Borislav Petkov's avatar
      x86/mm/pat: Remove pat_enabled() checks · 7202fdb1
      Borislav Petkov authored
      Now that we emulate a PAT table when PAT is disabled, there's no
      need for those checks anymore as the PAT abstraction will handle
      those cases too.
      
      Based on a conglomerate patch from Toshi Kani.
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Reviewed-by: default avatarToshi Kani <toshi.kani@hp.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Elliott@hp.com
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Luis R. Rodriguez <mcgrof@suse.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: arnd@arndb.de
      Cc: hch@lst.de
      Cc: hmh@hmh.eng.br
      Cc: jgross@suse.com
      Cc: konrad.wilk@oracle.com
      Cc: linux-mm <linux-mm@kvack.org>
      Cc: linux-nvdimm@lists.01.org
      Cc: stefan.bader@canonical.com
      Cc: yigal@plexistor.com
      Link: http://lkml.kernel.org/r/1433436928-31903-4-git-send-email-bp@alien8.deSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      7202fdb1
    • Borislav Petkov's avatar
      x86/mm/pat: Emulate PAT when it is disabled · 9cd25aac
      Borislav Petkov authored
      In the case when PAT is disabled on the command line with
      "nopat" or when virtualization doesn't support PAT (correctly) -
      see
      
        9d34cfdf ("x86: Don't rely on VMWare emulating PAT MSR correctly").
      
      we emulate it using the PWT and PCD cache attribute bits. Get
      rid of boot_pat_state while at it.
      
      Based on a conglomerate patch from Toshi Kani.
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Reviewed-by: default avatarToshi Kani <toshi.kani@hp.com>
      Acked-by: default avatarJuergen Gross <jgross@suse.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Elliott@hp.com
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Luis R. Rodriguez <mcgrof@suse.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: arnd@arndb.de
      Cc: hch@lst.de
      Cc: hmh@hmh.eng.br
      Cc: konrad.wilk@oracle.com
      Cc: linux-mm <linux-mm@kvack.org>
      Cc: linux-nvdimm@lists.01.org
      Cc: stefan.bader@canonical.com
      Cc: yigal@plexistor.com
      Link: http://lkml.kernel.org/r/1433436928-31903-3-git-send-email-bp@alien8.deSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      9cd25aac
    • Borislav Petkov's avatar
      x86/mm/pat: Untangle pat_init() · 9dac6290
      Borislav Petkov authored
      Split it into a BSP and AP version which makes the PAT
      initialization path actually readable again.
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Reviewed-by: default avatarToshi Kani <toshi.kani@hp.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Elliott@hp.com
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Luis R. Rodriguez <mcgrof@suse.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: arnd@arndb.de
      Cc: hch@lst.de
      Cc: hmh@hmh.eng.br
      Cc: jgross@suse.com
      Cc: konrad.wilk@oracle.com
      Cc: linux-mm <linux-mm@kvack.org>
      Cc: linux-nvdimm@lists.01.org
      Cc: stefan.bader@canonical.com
      Cc: yigal@plexistor.com
      Link: http://lkml.kernel.org/r/1433436928-31903-2-git-send-email-bp@alien8.deSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      9dac6290
  8. 03 Jun, 2015 1 commit
    • Stephen Rothwell's avatar
      x86/mm: Decouple <linux/vmalloc.h> from <asm/io.h> · d6472302
      Stephen Rothwell authored
      Nothing in <asm/io.h> uses anything from <linux/vmalloc.h>, so
      remove it from there and fix up the resulting build problems
      triggered on x86 {64|32}-bit {def|allmod|allno}configs.
      
      The breakages were triggering in places where x86 builds relied
      on vmalloc() facilities but did not include <linux/vmalloc.h>
      explicitly and relied on the implicit inclusion via <asm/io.h>.
      
      Also add:
      
        - <linux/init.h> to <linux/io.h>
        - <asm/pgtable_types> to <asm/io.h>
      
      ... which were two other implicit header file dependencies.
      Suggested-by: default avatarDavid Miller <davem@davemloft.net>
      Signed-off-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
      [ Tidied up the changelog. ]
      Acked-by: default avatarDavid Miller <davem@davemloft.net>
      Acked-by: default avatarTakashi Iwai <tiwai@suse.de>
      Acked-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
      Acked-by: default avatarVinod Koul <vinod.koul@intel.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Anton Vorontsov <anton@enomsg.org>
      Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
      Cc: Colin Cross <ccross@android.com>
      Cc: David Vrabel <david.vrabel@citrix.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Haiyang Zhang <haiyangz@microsoft.com>
      Cc: James E.J. Bottomley <JBottomley@odin.com>
      Cc: Jaroslav Kysela <perex@perex.cz>
      Cc: K. Y. Srinivasan <kys@microsoft.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Cc: Kristen Carlson Accardi <kristen@linux.intel.com>
      Cc: Len Brown <lenb@kernel.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rafael J. Wysocki <rjw@rjwysocki.net>
      Cc: Suma Ramars <sramars@cisco.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Tony Luck <tony.luck@intel.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      d6472302
  9. 28 May, 2015 1 commit
  10. 27 May, 2015 13 commits
    • Luis R. Rodriguez's avatar
      x86/mm/pat: Export pat_enabled() · fbe7193a
      Luis R. Rodriguez authored
      Two Linux device drivers cannot work with PAT and the work
      required to make them work is significant. There is not enough
      motivation to convert these drivers over to use PAT properly,
      the compromise reached is to let drivers that cannot be ported
      to PAT check if PAT was enabled and if so fail on probe with a
      recommendation to boot with the "nopat" kernel parameter.
      Signed-off-by: default avatarLuis R. Rodriguez <mcgrof@suse.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Andy Walls <awalls@md.metrocast.net>
      Cc: Bjorn Helgaas <bhelgaas@google.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: Dave Airlie <airlied@redhat.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Doug Ledford <dledford@redhat.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Juergen Gross <jgross@suse.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/1430425520-22275-4-git-send-email-mcgrof@do-not-panic.com
      Link: http://lkml.kernel.org/r/1432628901-18044-14-git-send-email-bp@alien8.deSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      fbe7193a
    • Luis R. Rodriguez's avatar
      x86/mm/pat: Wrap pat_enabled into a function API · cb32edf6
      Luis R. Rodriguez authored
      We use pat_enabled in x86-specific code to see if PAT is enabled
      or not but we're granting full access to it even though readers
      do not need to set it. If, for instance, we granted access to it
      to modules later they then could override the variable
      setting... no bueno.
      
      This renames pat_enabled to a new static variable __pat_enabled.
      Folks are redirected to use pat_enabled() now.
      
      Code that sets this can only be internal to pat.c. Apart from
      the early kernel parameter "nopat" to disable PAT, we also have
      a few cases that disable it later and make use of a helper
      pat_disable(). It is wrapped under an ifdef but since that code
      cannot run unless PAT was enabled its not required to wrap it
      with ifdefs, unwrap that. Likewise, since "nopat" doesn't really
      change non-PAT systems just remove that ifdef as well.
      
      Although we could add and use an early_param_off(), these
      helpers don't use __read_mostly but we want to keep
      __read_mostly for __pat_enabled as this is a hot path -- upon
      boot, for instance, a simple guest may see ~4k accesses to
      pat_enabled(). Since __read_mostly early boot params are not
      that common we don't add a helper for them just yet.
      Signed-off-by: default avatarLuis R. Rodriguez <mcgrof@suse.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Andy Walls <awalls@md.metrocast.net>
      Cc: Bjorn Helgaas <bhelgaas@google.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Christoph Lameter <cl@linux.com>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: Dave Airlie <airlied@redhat.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Doug Ledford <dledford@redhat.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Juergen Gross <jgross@suse.com>
      Cc: Kyle McMartin <kyle@kernel.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/1430425520-22275-3-git-send-email-mcgrof@do-not-panic.com
      Link: http://lkml.kernel.org/r/1432628901-18044-13-git-send-email-bp@alien8.deSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      cb32edf6
    • Luis R. Rodriguez's avatar
      x86/mm/mtrr: Generalize runtime disabling of MTRRs · f9626104
      Luis R. Rodriguez authored
      It is possible to enable CONFIG_MTRR and CONFIG_X86_PAT and end
      up with a system with MTRR functionality disabled but PAT
      functionality enabled. This can happen, for instance, when the
      Xen hypervisor is used where MTRRs are not supported but PAT is.
      This can happen on Linux as of commit
      
        47591df5 ("xen: Support Xen pv-domains using PAT")
      
      by Juergen, introduced in v3.19.
      
      Technically, we should assume the proper CPU bits would be set
      to disable MTRRs but we can't always rely on this. At least on
      the Xen Hypervisor, for instance, only X86_FEATURE_MTRR was
      disabled as of Xen 4.4 through Xen commit 586ab6a [0], but not
      X86_FEATURE_K6_MTRR, X86_FEATURE_CENTAUR_MCR, or
      X86_FEATURE_CYRIX_ARR for instance.
      
      Roger Pau Monné has clarified though that although this is
      technically true we will never support PVH on these CPU types so
      Xen has no need to disable these bits on those systems. As per
      Roger, AMD K6, Centaur and VIA chips don't have the necessary
      hardware extensions to allow running PVH guests [1].
      
      As per Toshi it is also possible for the BIOS to disable MTRR
      support, in such cases get_mtrr_state() would update the MTRR
      state as per the BIOS, we need to propagate this information as
      well.
      
      x86 MTRR code relies on quite a bit of checks for mtrr_if being
      set to check to see if MTRRs did get set up. Instead, lets
      provide a generic getter for that. This also adds a few checks
      where they were not before which could potentially safeguard
      ourselves against incorrect usage of MTRR where this was not
      desirable.
      
      Where possible match error codes as if MTRRs were disabled on
      arch/x86/include/asm/mtrr.h.
      
      Lastly, since disabling MTRRs can happen at run time and we
      could end up with PAT enabled, best record now in our logs when
      MTRRs are disabled.
      
      [0] ~/devel/xen (git::stable-4.5)$ git describe --contains 586ab6a 4.4.0-rc1~18
      [1] http://lists.xenproject.org/archives/html/xen-devel/2015-03/msg03460.htmlSigned-off-by: default avatarLuis R. Rodriguez <mcgrof@suse.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Antonino Daplas <adaplas@gmail.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: Dave Airlie <airlied@redhat.com>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Davidlohr Bueso <dbueso@suse.de>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
      Cc: Juergen Gross <jgross@suse.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Mel Gorman <mgorman@suse.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Roger Pau Monné <roger.pau@citrix.com>
      Cc: Stefan Bader <stefan.bader@canonical.com>
      Cc: Suresh Siddha <sbsiddha@gmail.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
      Cc: Toshi Kani <toshi.kani@hp.com>
      Cc: Ville Syrjälä <syrjala@sci.fi>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Cc: bhelgaas@google.com
      Cc: david.vrabel@citrix.com
      Cc: jbeulich@suse.com
      Cc: konrad.wilk@oracle.com
      Cc: venkatesh.pallipadi@intel.com
      Cc: ville.syrjala@linux.intel.com
      Cc: xen-devel@lists.xensource.com
      Link: http://lkml.kernel.org/r/1426893517-2511-3-git-send-email-mcgrof@do-not-panic.com
      Link: http://lkml.kernel.org/r/1432628901-18044-12-git-send-email-bp@alien8.deSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      f9626104
    • Luis R. Rodriguez's avatar
      x86/mm/mtrr: Avoid #ifdeffery with phys_wc_to_mtrr_index() · 7d010fdf
      Luis R. Rodriguez authored
      There is only one user but since we're going to bury MTRR next
      out of access to drivers, expose this last piece of API to
      drivers in a general fashion only needing io.h for access to
      helpers.
      Signed-off-by: default avatarLuis R. Rodriguez <mcgrof@suse.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: Abhilash Kesavan <a.kesavan@samsung.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Antonino Daplas <adaplas@gmail.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Cristian Stoica <cristian.stoica@freescale.com>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: Dave Airlie <airlied@redhat.com>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Davidlohr Bueso <dbueso@suse.de>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
      Cc: Juergen Gross <jgross@suse.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Matthias Brugger <matthias.bgg@gmail.com>
      Cc: Mel Gorman <mgorman@suse.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Suresh Siddha <sbsiddha@gmail.com>
      Cc: Thierry Reding <treding@nvidia.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
      Cc: Toshi Kani <toshi.kani@hp.com>
      Cc: Ville Syrjälä <syrjala@sci.fi>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: dri-devel@lists.freedesktop.org
      Link: http://lkml.kernel.org/r/1429722736-4473-1-git-send-email-mcgrof@do-not-panic.com
      Link: http://lkml.kernel.org/r/1432628901-18044-11-git-send-email-bp@alien8.deSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      7d010fdf
    • Luis R. Rodriguez's avatar
      x86/mm/mtrr, pat: Document Write Combining MTRR type effects on PAT / non-PAT pages · 2f9e8973
      Luis R. Rodriguez authored
      As part of the effort to phase out MTRR use document
      write-combining MTRR effects on pages with different non-PAT
      page attributes flags and different PAT entry values. Extend
      arch_phys_wc_add() documentation to clarify power of two sizes /
      boundary requirements as we phase out mtrr_add() use.
      
      Lastly hint towards ioremap_uc() for corner cases on device
      drivers working with devices with mixed regions where MTRR size
      requirements would otherwise not enable write-combining
      effective memory types.
      Signed-off-by: default avatarLuis R. Rodriguez <mcgrof@suse.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Antonino Daplas <adaplas@gmail.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: Dave Airlie <airlied@redhat.com>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Davidlohr Bueso <dbueso@suse.de>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Juergen Gross <jgross@suse.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Mel Gorman <mgorman@suse.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Suresh Siddha <sbsiddha@gmail.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
      Cc: Ville Syrjälä <syrjala@sci.fi>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Cc: linux-fbdev@vger.kernel.org
      Link: http://lkml.kernel.org/r/1430343851-967-3-git-send-email-mcgrof@do-not-panic.com
      Link: http://lkml.kernel.org/r/1432628901-18044-10-git-send-email-bp@alien8.deSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      2f9e8973
    • Luis R. Rodriguez's avatar
      x86/mm/pat: Convert to pr_*() usage · 9e76561f
      Luis R. Rodriguez authored
      Use pr_info() instead of the old printk to prefix the component
      where things are coming from. With this readers will know
      exactly where the message is coming from. We use pr_* helpers
      but define pr_fmt to the empty string for easier grepping for
      those error messages.
      
      We leave the users of dprintk() in place, this will print only
      when the debugpat kernel parameter is enabled. We want to leave
      those enabled as a debug feature, but also make them use the
      same prefix.
      Signed-off-by: default avatarLuis R. Rodriguez <mcgrof@suse.com>
      [ Kill pr_fmt. ]
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Andy Walls <awalls@md.metrocast.net>
      Cc: Bjorn Helgaas <bhelgaas@google.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: Dave Airlie <airlied@redhat.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Doug Ledford <dledford@redhat.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Juergen Gross <jgross@suse.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: cocci@systeme.lip6.fr
      Cc: plagnioj@jcrosoft.com
      Cc: tomi.valkeinen@ti.com
      Link: http://lkml.kernel.org/r/1430425520-22275-2-git-send-email-mcgrof@do-not-panic.com
      Link: http://lkml.kernel.org/r/1432628901-18044-9-git-send-email-bp@alien8.deSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      9e76561f
    • Toshi Kani's avatar
      x86/mm/mtrr: Enhance MTRR checks in kernel mapping helpers · b73522e0
      Toshi Kani authored
      This patch adds the argument 'uniform' to mtrr_type_lookup(),
      which gets set to 1 when a given range is covered uniformly by
      MTRRs, i.e. the range is fully covered by a single MTRR entry or
      the default type.
      
      Change pud_set_huge() and pmd_set_huge() to honor the 'uniform'
      flag to see if it is safe to create a huge page mapping in the
      range.
      
      This allows them to create a huge page mapping in a range
      covered by a single MTRR entry of any memory type. It also
      detects a non-optimal request properly. They continue to check
      with the WB type since it does not effectively change the
      uniform mapping even if a request spans multiple MTRR entries.
      
      pmd_set_huge() logs a warning message to a non-optimal request
      so that driver writers will be aware of such a case. Drivers
      should make a mapping request aligned to a single MTRR entry
      when the range is covered by MTRRs.
      Signed-off-by: default avatarToshi Kani <toshi.kani@hp.com>
      [ Realign, flesh out comments, improve warning message. ]
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Elliott@hp.com
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Luis R. Rodriguez <mcgrof@suse.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: dave.hansen@intel.com
      Cc: linux-mm <linux-mm@kvack.org>
      Cc: pebolle@tiscali.nl
      Link: http://lkml.kernel.org/r/1431714237-880-7-git-send-email-toshi.kani@hp.com
      Link: http://lkml.kernel.org/r/1432628901-18044-8-git-send-email-bp@alien8.deSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      b73522e0
    • Toshi Kani's avatar
      x86/mm/mtrr: Clean up mtrr_type_lookup() · 0cc705f5
      Toshi Kani authored
      MTRRs contain fixed and variable entries. mtrr_type_lookup() may
      repeatedly call __mtrr_type_lookup() to handle a request that
      overlaps with variable entries.
      
      However, __mtrr_type_lookup() also handles the fixed entries,
      which do not have to be repeated. Therefore, this patch creates
      separate functions, mtrr_type_lookup_fixed() and
      mtrr_type_lookup_variable(), to handle the fixed and variable
      ranges respectively.
      
      The patch also updates the function headers to clarify the
      return values and output argument. It updates comments to
      clarify that the repeating is necessary to handle overlaps with
      the default type, since overlaps with multiple entries alone can
      be handled without such repeating.
      
      There is no functional change in this patch.
      Signed-off-by: default avatarToshi Kani <toshi.kani@hp.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Elliott@hp.com
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Luis R. Rodriguez <mcgrof@suse.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: dave.hansen@intel.com
      Cc: linux-mm <linux-mm@kvack.org>
      Cc: pebolle@tiscali.nl
      Link: http://lkml.kernel.org/r/1431714237-880-6-git-send-email-toshi.kani@hp.com
      Link: http://lkml.kernel.org/r/1432628901-18044-6-git-send-email-bp@alien8.deSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      0cc705f5
    • Toshi Kani's avatar
      x86/mm/mtrr: Use symbolic define as a retval for disabled MTRRs · 3d3ca416
      Toshi Kani authored
      mtrr_type_lookup() returns verbatim 0xFF when MTRRs are
      disabled. This patch defines MTRR_TYPE_INVALID to clarify the
      meaning of this value, and documents its usage.
      
      Document the return values of the kernel virtual address mapping
      helpers pud_set_huge(), pmd_set_huge, pud_clear_huge() and
      pmd_clear_huge().
      
      There is no functional change in this patch.
      Signed-off-by: default avatarToshi Kani <toshi.kani@hp.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Elliott@hp.com
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Luis R. Rodriguez <mcgrof@suse.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: dave.hansen@intel.com
      Cc: linux-mm <linux-mm@kvack.org>
      Cc: pebolle@tiscali.nl
      Link: http://lkml.kernel.org/r/1431714237-880-5-git-send-email-toshi.kani@hp.com
      Link: http://lkml.kernel.org/r/1432628901-18044-5-git-send-email-bp@alien8.deSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      3d3ca416
    • Toshi Kani's avatar
      x86/mm/mtrr: Fix MTRR state checks in mtrr_type_lookup() · 9b3aca62
      Toshi Kani authored
      'mtrr_state.enabled' contains the FE (fixed MTRRs enabled)
      and E (MTRRs enabled) flags in MSR_MTRRdefType.  Intel SDM,
      section 11.11.2.1, defines these flags as follows:
      
       - All MTRRs are disabled when the E flag is clear.
         The FE flag has no affect when the E flag is clear.
       - The default type is enabled when the E flag is set.
       - MTRR variable ranges are enabled when the E flag is set.
       - MTRR fixed ranges are enabled when both E and FE flags
         are set.
      
      MTRR state checks in __mtrr_type_lookup() do not match with SDM.
      
      Hence, this patch makes the following changes:
       - The current code detects MTRRs disabled when both E and
         FE flags are clear in mtrr_state.enabled.  Fix to detect
         MTRRs disabled when the E flag is clear.
       - The current code does not check if the FE bit is set in
         mtrr_state.enabled when looking at the fixed entries.
         Fix to check the FE flag.
       - The current code returns the default type when the E flag
         is clear in mtrr_state.enabled. However, the default type
         is UC when the E flag is clear.  Remove the code as this
         case is handled as MTRR disabled with the 1st change.
      
      In addition, this patch defines the E and FE flags in
      mtrr_state.enabled as follows.
       - FE flag: MTRR_STATE_MTRR_FIXED_ENABLED
       - E  flag: MTRR_STATE_MTRR_ENABLED
      
      print_mtrr_state() and x86_get_mtrr_mem_range() are also updated
      accordingly.
      Signed-off-by: default avatarToshi Kani <toshi.kani@hp.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Elliott@hp.com
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Luis R. Rodriguez <mcgrof@suse.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: dave.hansen@intel.com
      Cc: linux-mm <linux-mm@kvack.org>
      Cc: pebolle@tiscali.nl
      Link: http://lkml.kernel.org/r/1431714237-880-4-git-send-email-toshi.kani@hp.com
      Link: http://lkml.kernel.org/r/1432628901-18044-4-git-send-email-bp@alien8.deSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      9b3aca62
    • Toshi Kani's avatar
      x86/mm/mtrr: Fix MTRR lookup to handle an inclusive entry · 7f0431e3
      Toshi Kani authored
      When an MTRR entry is inclusive to a requested range, i.e. the
      start and end of the request are not within the MTRR entry range
      but the range contains the MTRR entry entirely:
      
        range_start ... [mtrr_start ... mtrr_end] ... range_end
      
      __mtrr_type_lookup() ignores such a case because both
      start_state and end_state are set to zero.
      
      This bug can cause the following issues:
      
      1) reserve_memtype() tracks an effective memory type in case
         a request type is WB (ex. /dev/mem blindly uses WB). Missing
         to track with its effective type causes a subsequent request
         to map the same range with the effective type to fail.
      
      2) pud_set_huge() and pmd_set_huge() check if a requested range
         has any overlap with MTRRs. Missing to detect an overlap may
         cause a performance penalty or undefined behavior.
      
      This patch fixes the bug by adding a new flag, 'inclusive',
      to detect the inclusive case.  This case is then handled in
      the same way as end_state:1 since the first region is the same.
      With this fix, __mtrr_type_lookup() handles the inclusive case
      properly.
      Signed-off-by: default avatarToshi Kani <toshi.kani@hp.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Elliott@hp.com
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Luis R. Rodriguez <mcgrof@suse.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: dave.hansen@intel.com
      Cc: linux-mm <linux-mm@kvack.org>
      Cc: pebolle@tiscali.nl
      Link: http://lkml.kernel.org/r/1431714237-880-3-git-send-email-toshi.kani@hp.com
      Link: http://lkml.kernel.org/r/1432628901-18044-3-git-send-email-bp@alien8.deSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      7f0431e3
    • Toshi Kani's avatar
      x86/mm/kconfig: Simplify conditions for HAVE_ARCH_HUGE_VMAP · 10455f64
      Toshi Kani authored
      Simplify the conditions selecting HAVE_ARCH_HUGE_VMAP since
      X86_PAE depends on X86_32 already.
      Signed-off-by: default avatarToshi Kani <toshi.kani@hp.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Elliott@hp.com
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Luis R. Rodriguez <mcgrof@suse.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: dave.hansen@intel.com
      Cc: linux-mm <linux-mm@kvack.org>
      Cc: pebolle@tiscali.nl
      Link: http://lkml.kernel.org/r/1431714237-880-2-git-send-email-toshi.kani@hp.com
      Link: http://lkml.kernel.org/r/1432628901-18044-2-git-send-email-bp@alien8.deSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      10455f64
    • Ingo Molnar's avatar
  11. 25 May, 2015 1 commit