linux/arch/powerpc/mm
Suraj Jitindar Singh d7b4561522 KVM: PPC: Book3S HV: Implement functions to access quadrants 1 & 2
The POWER9 radix mmu has the concept of quadrants. The quadrant number
is the two high bits of the effective address and determines the fully
qualified address to be used for the translation. The fully qualified
address consists of the effective lpid, the effective pid and the
effective address. This gives then 4 possible quadrants 0, 1, 2, and 3.

When accessing these quadrants the fully qualified address is obtained
as follows:

Quadrant		| Hypervisor		| Guest
--------------------------------------------------------------------------
			| EA[0:1] = 0b00	| EA[0:1] = 0b00
0			| effLPID = 0		| effLPID = LPIDR
			| effPID  = PIDR	| effPID  = PIDR
--------------------------------------------------------------------------
			| EA[0:1] = 0b01	|
1			| effLPID = LPIDR	| Invalid Access
			| effPID  = PIDR	|
--------------------------------------------------------------------------
			| EA[0:1] = 0b10	|
2			| effLPID = LPIDR	| Invalid Access
			| effPID  = 0		|
--------------------------------------------------------------------------
			| EA[0:1] = 0b11	| EA[0:1] = 0b11
3			| effLPID = 0		| effLPID = LPIDR
			| effPID  = 0		| effPID  = 0
--------------------------------------------------------------------------

In the Guest;
Quadrant 3 is normally used to address the operating system since this
uses effPID=0 and effLPID=LPIDR, meaning the PID register doesn't need to
be switched.
Quadrant 0 is normally used to address user space since the effLPID and
effPID are taken from the corresponding registers.

In the Host;
Quadrant 0 and 3 are used as above, however the effLPID is always 0 to
address the host.

Quadrants 1 and 2 can be used by the host to address guest memory using
a guest effective address. Since the effLPID comes from the LPID register,
the host loads the LPID of the guest it would like to access (and the
PID of the process) and can perform accesses to a guest effective
address.

This means quadrant 1 can be used to address the guest user space and
quadrant 2 can be used to address the guest operating system from the
hypervisor, using a guest effective address.

Access to the quadrants can cause a Hypervisor Data Storage Interrupt
(HDSI) due to being unable to perform partition scoped translation.
Previously this could only be generated from a guest and so the code
path expects us to take the KVM trampoline in the interrupt handler.
This is no longer the case so we modify the handler to call
bad_page_fault() to check if we were expecting this fault so we can
handle it gracefully and just return with an error code. In the hash mmu
case we still raise an unknown exception since quadrants aren't defined
for the hash mmu.

Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
2018-12-17 11:33:50 +11:00
..
8xx_mmu.c Merge branch 'next' of https://git.kernel.org/pub/scm/linux/kernel/git/scottwood/linux into next 2018-10-29 22:32:52 +11:00
40x_mmu.c Replace <asm/uaccess.h> with <linux/uaccess.h> globally 2016-12-24 11:46:01 -08:00
44x_mmu.c powerpc/44x: Mark mmu_init_secondary() as __init 2018-07-30 22:48:22 +10:00
copro_fault.c mm: convert return type of handle_mm_fault() caller to vm_fault_t 2018-08-17 16:20:28 -07:00
dma-noncoherent.c powerpc: handover page flags with a pgprot_t parameter 2018-10-14 18:04:09 +11:00
drmem.c powerpc/mm/drmem: Fix unexpected flag value in ibm,dynamic-memory-v2 2018-02-23 16:45:51 +11:00
dump_hashpagetable.c powerpc: remove superflous inclusions of asm/fixmap.h 2018-07-30 22:48:18 +10:00
dump_linuxpagetables-8xx.c powerpc/8xx: change name of a few page flags to avoid confusion 2018-10-14 18:04:09 +11:00
dump_linuxpagetables-book3s64.c powerpc/book3s64: fix dump_linuxpagetables "present" flag 2018-10-20 13:26:47 +11:00
dump_linuxpagetables-generic.c powerpc/mm: Split dump_pagelinuxtables flag_array table 2018-10-14 18:04:09 +11:00
dump_linuxpagetables.c powerpc/mm: Fix page table dump to work on Radix 2018-10-20 13:26:47 +11:00
dump_linuxpagetables.h powerpc/mm: Split dump_pagelinuxtables flag_array table 2018-10-14 18:04:09 +11:00
fault.c KVM: PPC: Book3S HV: Implement functions to access quadrants 1 & 2 2018-12-17 11:33:50 +11:00
fsl_booke_mmu.c Replace <asm/uaccess.h> with <linux/uaccess.h> globally 2016-12-24 11:46:01 -08:00
hash64_4k.c powerpc/mm/hash: Remove the superfluous bitwise operation when find hpte group 2018-07-24 22:03:17 +10:00
hash64_64k.c powerpc/mm/hash: Remove the superfluous bitwise operation when find hpte group 2018-07-24 22:03:17 +10:00
hash_low_32.S powerpc: clean inclusions of asm/feature-fixups.h 2018-07-30 22:48:17 +10:00
hash_native_64.c powerpc/64s/hash: Do not use PPC_INVALIDATE_ERAT on CPUs before POWER9 2018-10-04 23:16:53 +10:00
hash_utils_64.c powerpc/64s/hash: Simplify slb_flush_and_rebolt() 2018-10-14 18:04:09 +11:00
highmem.c powerpc/mm: remove warning about ‘type’ being set 2018-08-10 22:12:38 +10:00
hugepage-hash64.c arch/powerpc/mm/hash: validate the pte entries before handling the hash fault 2018-10-03 15:39:59 +10:00
hugetlbpage-book3e.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
hugetlbpage-hash64.c arch/powerpc/mm/hash: validate the pte entries before handling the hash fault 2018-10-03 15:39:59 +10:00
hugetlbpage-radix.c powerpc updates for 4.15 2017-11-16 12:47:46 -08:00
hugetlbpage.c mm: remove include/linux/bootmem.h 2018-10-31 08:54:16 -07:00
init-common.c powerpc/mm: Fix crashes with 16G huge pages 2018-02-13 22:37:47 +11:00
init_32.c powerpc/mm/32: Remove the reserved memory hack 2018-04-01 00:47:44 +11:00
init_64.c KVM: PPC: Avoid marking DMA-mapped pages dirty in real mode 2018-09-12 08:49:54 +10:00
Makefile powerpc: Add -Werror at arch/powerpc level 2018-10-19 00:56:17 +11:00
mem.c mm: remove include/linux/bootmem.h 2018-10-31 08:54:16 -07:00
mmap.c exec: pass stack rlimit into mm layout functions 2018-04-11 10:28:37 -07:00
mmu_context.c Revert "convert SLB miss handlers to C" and subsequent commits 2018-10-03 15:32:49 +10:00
mmu_context_book3s64.c powerpc/64s/hash: Add a SLB preload cache 2018-10-14 18:04:09 +11:00
mmu_context_hash32.c powerpc: remove unnecessary inclusion of asm/tlbflush.h 2018-07-30 22:48:20 +10:00
mmu_context_iommu.c KVM: PPC: Avoid marking DMA-mapped pages dirty in real mode 2018-09-12 08:49:54 +10:00
mmu_context_nohash.c memblock: stop using implicit alignment to SMP_CACHE_BYTES 2018-10-31 08:54:16 -07:00
mmu_decl.h powerpc/mm: Trace tlbia instruction 2018-10-20 13:26:47 +11:00
numa.c powerpc/numa: Suppress "VPHN is not supported" messages 2018-11-14 14:32:47 +11:00
pgtable-book3e.c powerpc: handover page flags with a pgprot_t parameter 2018-10-14 18:04:09 +11:00
pgtable-book3s64.c powerpc/mm: Fix WARN_ON with THP NUMA migration 2018-10-20 13:26:47 +11:00
pgtable-hash64.c powerpc: handover page flags with a pgprot_t parameter 2018-10-14 18:04:09 +11:00
pgtable-radix.c powerpc/mm/radix: Display if mappings are exec or not 2018-10-20 13:26:47 +11:00
pgtable.c powerpc/mm: Fix WARN_ON with THP NUMA migration 2018-10-20 13:26:47 +11:00
pgtable_32.c memblock: rename memblock_alloc{_nid,_try_nid} to memblock_phys_alloc* 2018-10-31 08:54:15 -07:00
pgtable_64.c powerpc/mm: use pte helpers in generic code 2018-10-14 18:04:09 +11:00
pkeys.c powerpc/pkeys: Fix reading of ibm, processor-storage-keys property 2018-09-20 22:49:46 +10:00
ppc_mmu_32.c memblock: rename memblock_alloc{_nid,_try_nid} to memblock_phys_alloc* 2018-10-31 08:54:15 -07:00
slb.c powerpc/mm/64s: Fix preempt warning in slb_allocate_kernel() 2018-11-12 13:22:10 +11:00
slice.c powerpc/mm: fix always true/false warning in slice.c 2018-10-20 13:26:47 +11:00
subpage-prot.c powerpc: remove unnecessary inclusion of asm/tlbflush.h 2018-07-30 22:48:20 +10:00
tlb-radix.c powerpc updates for 4.20 2018-10-26 14:36:21 -07:00
tlb_hash32.c powerpc/sparse: Fix plain integer as NULL pointer warning 2018-05-25 12:04:38 +10:00
tlb_hash64.c powerpc/mm: Add support for handling > 512TB address in SLB miss 2018-03-31 00:10:38 +11:00
tlb_low_64e.S powerpc: clean inclusions of asm/feature-fixups.h 2018-07-30 22:48:17 +10:00
tlb_nohash.c powerpc/nohash: fix undefined behaviour when testing page size support 2018-10-04 16:54:41 +10:00
tlb_nohash_low.S powerpc: clean inclusions of asm/feature-fixups.h 2018-07-30 22:48:17 +10:00
vphn.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
vphn.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00