Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) ==================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) Memory Attribute Aliasing on IA-64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) ==================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) Bjorn Helgaas <bjorn.helgaas@hp.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) May 4, 2006
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) Memory Attributes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) =================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)     Itanium supports several attributes for virtual memory references.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)     The attribute is part of the virtual translation, i.e., it is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)     contained in the TLB entry.  The ones of most interest to the Linux
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)     kernel are:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 	==		======================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)         WB		Write-back (cacheable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 	UC		Uncacheable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	WC		Write-coalescing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	==		======================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)     System memory typically uses the WB attribute.  The UC attribute is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)     used for memory-mapped I/O devices.  The WC attribute is uncacheable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)     like UC is, but writes may be delayed and combined to increase
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)     performance for things like frame buffers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)     The Itanium architecture requires that we avoid accessing the same
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)     page with both a cacheable mapping and an uncacheable mapping[1].
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)     The design of the chipset determines which attributes are supported
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)     on which regions of the address space.  For example, some chipsets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)     support either WB or UC access to main memory, while others support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)     only WB access.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) Memory Map
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) ==========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)     Platform firmware describes the physical memory map and the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)     supported attributes for each region.  At boot-time, the kernel uses
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)     the EFI GetMemoryMap() interface.  ACPI can also describe memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43)     devices and the attributes they support, but Linux/ia64 currently
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44)     doesn't use this information.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46)     The kernel uses the efi_memmap table returned from GetMemoryMap() to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47)     learn the attributes supported by each region of physical address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48)     space.  Unfortunately, this table does not completely describe the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49)     address space because some machines omit some or all of the MMIO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50)     regions from the map.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52)     The kernel maintains another table, kern_memmap, which describes the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53)     memory Linux is actually using and the attribute for each region.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54)     This contains only system memory; it does not contain MMIO space.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56)     The kern_memmap table typically contains only a subset of the system
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57)     memory described by the efi_memmap.  Linux/ia64 can't use all memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58)     in the system because of constraints imposed by the identity mapping
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59)     scheme.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61)     The efi_memmap table is preserved unmodified because the original
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62)     boot-time information is required for kexec.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) Kernel Identify Mappings
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) ========================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67)     Linux/ia64 identity mappings are done with large pages, currently
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68)     either 16MB or 64MB, referred to as "granules."  Cacheable mappings
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69)     are speculative[2], so the processor can read any location in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70)     page at any time, independent of the programmer's intentions.  This
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)     means that to avoid attribute aliasing, Linux can create a cacheable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)     identity mapping only when the entire granule supports cacheable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)     access.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75)     Therefore, kern_memmap contains only full granule-sized regions that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76)     can referenced safely by an identity mapping.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78)     Uncacheable mappings are not speculative, so the processor will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)     generate UC accesses only to locations explicitly referenced by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80)     software.  This allows UC identity mappings to cover granules that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81)     are only partially populated, or populated with a combination of UC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82)     and WB regions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) User Mappings
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) =============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87)     User mappings are typically done with 16K or 64K pages.  The smaller
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88)     page size allows more flexibility because only 16K or 64K has to be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89)     homogeneous with respect to memory attributes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) Potential Attribute Aliasing Cases
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) ==================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94)     There are several ways the kernel creates new mappings:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) mmap of /dev/mem
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) ----------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	This uses remap_pfn_range(), which creates user mappings.  These
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	mappings may be either WB or UC.  If the region being mapped
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	happens to be in kern_memmap, meaning that it may also be mapped
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	by a kernel identity mapping, the user mapping must use the same
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	attribute as the kernel mapping.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	If the region is not in kern_memmap, the user mapping should use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	an attribute reported as being supported in the EFI memory map.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	Since the EFI memory map does not describe MMIO on some
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	machines, this should use an uncacheable mapping as a fallback.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) mmap of /sys/class/pci_bus/.../legacy_mem
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) -----------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	This is very similar to mmap of /dev/mem, except that legacy_mem
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	only allows mmap of the one megabyte "legacy MMIO" area for a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	specific PCI bus.  Typically this is the first megabyte of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	physical address space, but it may be different on machines with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	several VGA devices.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	"X" uses this to access VGA frame buffers.  Using legacy_mem
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	rather than /dev/mem allows multiple instances of X to talk to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	different VGA cards.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	The /dev/mem mmap constraints apply.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) mmap of /proc/bus/pci/.../??.?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) ------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	This is an MMIO mmap of PCI functions, which additionally may or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	may not be requested as using the WC attribute.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	If WC is requested, and the region in kern_memmap is either WC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	or UC, and the EFI memory map designates the region as WC, then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	the WC mapping is allowed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	Otherwise, the user mapping must use the same attribute as the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	kernel mapping.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) read/write of /dev/mem
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) ----------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	This uses copy_from_user(), which implicitly uses a kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	identity mapping.  This is obviously safe for things in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	kern_memmap.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	There may be corner cases of things that are not in kern_memmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	but could be accessed this way.  For example, registers in MMIO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	space are not in kern_memmap, but could be accessed with a UC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	mapping.  This would not cause attribute aliasing.  But
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	registers typically can be accessed only with four-byte or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	eight-byte accesses, and the copy_from_user() path doesn't allow
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	any control over the access size, so this would be dangerous.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) ioremap()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) ---------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	This returns a mapping for use inside the kernel.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	If the region is in kern_memmap, we should use the attribute
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	specified there.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	If the EFI memory map reports that the entire granule supports
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	WB, we should use that (granules that are partially reserved
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	or occupied by firmware do not appear in kern_memmap).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	If the granule contains non-WB memory, but we can cover the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	region safely with kernel page table mappings, we can use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	ioremap_page_range() as most other architectures do.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	Failing all of the above, we have to fall back to a UC mapping.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) Past Problem Cases
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) ==================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) mmap of various MMIO regions from /dev/mem by "X" on Intel platforms
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) --------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)       The EFI memory map may not report these MMIO regions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)       These must be allowed so that X will work.  This means that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)       when the EFI memory map is incomplete, every /dev/mem mmap must
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)       succeed.  It may create either WB or UC user mappings, depending
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)       on whether the region is in kern_memmap or the EFI memory map.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) mmap of 0x0-0x9FFFF /dev/mem by "hwinfo" on HP sx1000 with VGA enabled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) ----------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)       The EFI memory map reports the following attributes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)         =============== ======= ==================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)         0x00000-0x9FFFF WB only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)         0xA0000-0xBFFFF UC only (VGA frame buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)         0xC0000-0xFFFFF WB only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)         =============== ======= ==================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)       This mmap is done with user pages, not kernel identity mappings,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)       so it is safe to use WB mappings.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)       The kernel VGA driver may ioremap the VGA frame buffer at 0xA0000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)       which uses a granule-sized UC mapping.  This granule will cover some
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)       WB-only memory, but since UC is non-speculative, the processor will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)       never generate an uncacheable reference to the WB-only areas unless
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)       the driver explicitly touches them.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) mmap of 0x0-0xFFFFF legacy_mem by "X"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) -------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)       If the EFI memory map reports that the entire range supports the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)       same attributes, we can allow the mmap (and we will prefer WB if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)       supported, as is the case with HP sx[12]000 machines with VGA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)       disabled).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)       If EFI reports the range as partly WB and partly UC (as on sx[12]000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)       machines with VGA enabled), we must fail the mmap because there's no
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)       safe attribute to use.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)       If EFI reports some of the range but not all (as on Intel firmware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)       that doesn't report the VGA frame buffer at all), we should fail the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)       mmap and force the user to map just the specific region of interest.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) mmap of 0xA0000-0xBFFFF legacy_mem by "X" on HP sx1000 with VGA disabled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) ------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)       The EFI memory map reports the following attributes::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)         0x00000-0xFFFFF WB only (no VGA MMIO hole)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)       This is a special case of the previous case, and the mmap should
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)       fail for the same reason as above.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) read of /sys/devices/.../rom
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) ----------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)       For VGA devices, this may cause an ioremap() of 0xC0000.  This
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)       used to be done with a UC mapping, because the VGA frame buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)       at 0xA0000 prevents use of a WB granule.  The UC mapping causes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)       an MCA on HP sx[12]000 chipsets.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)       We should use WB page table mappings to avoid covering the VGA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240)       frame buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) Notes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) =====
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)     [1] SDM rev 2.2, vol 2, sec 4.4.1.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246)     [2] SDM rev 2.2, vol 2, sec 4.4.6.