linux-stable/arch/arm64/kernel
Steve Capper e842dfb5a2 arm64: mm: Offset TTBR1 to allow 52-bit PTRS_PER_PGD
Enabling 52-bit VAs on arm64 requires that the PGD table expands from 64
entries (for the 48-bit case) to 1024 entries. This quantity,
PTRS_PER_PGD is used as follows to compute which PGD entry corresponds
to a given virtual address, addr:

pgd_index(addr) -> (addr >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1)

Userspace addresses are prefixed by 0's, so for a 48-bit userspace
address, uva, the following is true:
(uva >> PGDIR_SHIFT) & (1024 - 1) == (uva >> PGDIR_SHIFT) & (64 - 1)

In other words, a 48-bit userspace address will have the same pgd_index
when using PTRS_PER_PGD = 64 and 1024.

Kernel addresses are prefixed by 1's so, given a 48-bit kernel address,
kva, we have the following inequality:
(kva >> PGDIR_SHIFT) & (1024 - 1) != (kva >> PGDIR_SHIFT) & (64 - 1)

In other words a 48-bit kernel virtual address will have a different
pgd_index when using PTRS_PER_PGD = 64 and 1024.

If, however, we note that:
kva = 0xFFFF << 48 + lower (where lower[63:48] == 0b)
and, PGDIR_SHIFT = 42 (as we are dealing with 64KB PAGE_SIZE)

We can consider:
(kva >> PGDIR_SHIFT) & (1024 - 1) - (kva >> PGDIR_SHIFT) & (64 - 1)
 = (0xFFFF << 6) & 0x3FF - (0xFFFF << 6) & 0x3F	// "lower" cancels out
 = 0x3C0

In other words, one can switch PTRS_PER_PGD to the 52-bit value globally
provided that they increment ttbr1_el1 by 0x3C0 * 8 = 0x1E00 bytes when
running with 48-bit kernel VAs (TCR_EL1.T1SZ = 16).

For kernel configuration where 52-bit userspace VAs are possible, this
patch offsets ttbr1_el1 and sets PTRS_PER_PGD corresponding to the
52-bit value.

Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Suggested-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Steve Capper <steve.capper@arm.com>
[will: added comment to TTBR1_BADDR_4852_OFFSET calculation]
Signed-off-by: Will Deacon <will.deacon@arm.com>
2018-12-10 18:42:17 +00:00
..
probes arm64: kprobe: make page to RO mode when allocate it 2018-11-02 18:15:07 +00:00
vdso arm64: Add build salt to the vDSO 2018-07-18 01:18:05 +09:00
.gitignore
acpi.c mm: remove include/linux/bootmem.h 2018-10-31 08:54:16 -07:00
acpi_numa.c mm: remove include/linux/bootmem.h 2018-10-31 08:54:16 -07:00
acpi_parking_protocol.c
alternative.c arm64: alternative: Use true and false for boolean values 2018-08-08 11:20:54 +01:00
armv8_deprecated.c arm64: kill config_sctlr_el1() 2018-07-12 14:40:38 +01:00
asm-offsets.c arm64: KVM: Handle guest's ARCH_WORKAROUND_2 requests 2018-05-31 18:00:57 +01:00
cacheinfo.c arm64: Add support for ACPI based firmware tables 2018-05-17 17:28:09 +01:00
cpu-reset.h arm64: kexec: always reset to EL2 if present 2018-07-04 18:34:24 +01:00
cpu-reset.S arm64: idmap: Use "awx" flags for .idmap.text .pushsection directives 2018-02-06 22:53:27 +00:00
cpu_errata.c arm64: capabilities: Merge duplicate entries for Qualcomm erratum 1003 2018-12-06 11:47:44 +00:00
cpu_ops.c arm64: cpu_ops: Add missing 'const' qualifiers 2017-12-01 13:05:08 +00:00
cpufeature.c arm64: Add support for SB barrier and patch in over DSB; ISB sequences 2018-12-06 16:47:04 +00:00
cpuidle.c ARM64 / cpuidle: Use new cpuidle macro for entering retention state 2018-01-02 13:50:34 +00:00
cpuinfo.c arm64: Add support for SB barrier and patch in over DSB; ISB sequences 2018-12-06 16:47:04 +00:00
crash_core.c arm64: kernel: arch_crash_save_vmcoreinfo() should depend on CONFIG_CRASH_CORE 2018-09-11 11:08:49 +01:00
crash_dump.c arm64: kdump: fix small typo 2018-11-02 17:24:17 +00:00
debug-monitors.c signal/arm64: Add and use arm64_force_sig_fault where appropriate 2018-09-27 21:54:43 +02:00
efi-entry.S arm64: Add software workaround for Falkor erratum 1041 2018-02-06 22:53:13 +00:00
efi-header.S
efi-rt-wrapper.S efi/arm64: Check whether x18 is preserved by runtime services calls 2018-03-09 08:58:22 +01:00
efi.c efi/arm64: Check whether x18 is preserved by runtime services calls 2018-03-09 08:58:22 +01:00
entry-fpsimd.S arm64/sve: Write ZCR_EL1 on context switch only if changed 2018-05-17 18:19:53 +01:00
entry-ftrace.S arm64: frace: use asm EXPORT_SYMBOL() 2018-12-10 11:50:12 +00:00
entry.S arm64: entry: Remove confusing comment 2018-12-06 16:47:05 +00:00
fpsimd.c signal/arm64: Use send_sig_fault where appropriate 2018-09-27 21:55:23 +02:00
ftrace.c arm64: ftrace: always pass instrumented pc in x0 2018-11-30 13:29:05 +00:00
head.S arm64: mm: Offset TTBR1 to allow 52-bit PTRS_PER_PGD 2018-12-10 18:42:17 +00:00
hibernate-asm.S arm64: mm: Offset TTBR1 to allow 52-bit PTRS_PER_PGD 2018-12-10 18:42:17 +00:00
hibernate.c arm64: ssbd: Restore mitigation status on CPU resume 2018-05-31 17:35:19 +01:00
hw_breakpoint.c perf/arch/arm64: Implement hw_breakpoint_arch_parse() 2018-06-26 09:07:56 +02:00
hyp-stub.S
image.h arm64: drop linker script hack to hide __efistub_ symbols 2018-11-30 12:49:51 +00:00
insn.c arm64/insn: add support for emitting ADR/ADRP instructions 2018-11-27 18:47:33 +00:00
io.c arm64: Avoid aligning normal memory pointers in __memcpy_{to,from}io 2017-10-24 16:23:07 +01:00
irq.c arm64: Use the new GENERIC_IRQ_MULTI_HANDLER 2018-08-03 12:14:09 +02:00
jump_label.c arm64/kernel: jump_label: Switch to relative references 2018-09-27 17:56:47 +02:00
kaslr.c arm64/kernel: kaslr: reduce module randomization range to 4 GB 2018-03-08 13:49:26 +00:00
kgdb.c arm64/debug: Fix registers on sleeping tasks 2018-03-06 18:52:34 +00:00
kuser32.S
machine_kexec.c arm64: kernel: arch_crash_save_vmcoreinfo() should depend on CONFIG_CRASH_CORE 2018-09-11 11:08:49 +01:00
Makefile arm64: remove arm64ksyms.c 2018-12-10 11:50:12 +00:00
module-plts.c arm64/module: switch to ADRP/ADD sequences for PLT entries 2018-11-27 19:00:45 +00:00
module.c arm64/module: switch to ADRP/ADD sequences for PLT entries 2018-11-27 19:00:45 +00:00
module.lds arm64: ftrace: emit ftrace-mod.o contents through code 2017-12-01 13:04:59 +00:00
paravirt.c x86/paravirt: Use a single ops structure 2018-09-03 16:50:35 +02:00
pci.c arm64: PCI: Remove node-local allocations when initialising host controller 2018-09-17 16:33:23 -05:00
perf_callchain.c arm64: unwind: remove sp from struct stackframe 2017-08-09 14:10:29 +01:00
perf_event.c arm64: perf: Reject stand-alone CHAIN events for PMUv3 2018-10-12 15:25:17 +01:00
perf_regs.c compat: Move compat_timespec/ timeval to compat_time.h 2018-04-19 13:29:54 +02:00
process.c New gcc plugin: stackleak 2018-11-01 11:46:27 -07:00
psci.c arm64: remove unused asm/compiler.h header file 2018-10-01 11:57:04 +01:00
ptrace.c signal/arm64: Add and use arm64_force_sig_ptrace_errno_trap 2018-09-27 21:55:15 +02:00
reloc_test_core.c arm64: fix undefined reference to 'printk' 2018-03-19 18:14:25 +00:00
reloc_test_syms.S arm64: fix undefined reference to 'printk' 2018-03-19 18:14:25 +00:00
relocate_kernel.S arm64: Add software workaround for Falkor erratum 1041 2018-02-06 22:53:13 +00:00
return_address.c arm64: unwind: remove sp from struct stackframe 2017-08-09 14:10:29 +01:00
sdei.c arm64: sdei: Mark sdei stack helper functions as static 2018-07-31 12:08:22 +01:00
setup.c efi/arm: Defer persistent reservations until after paging_init() 2018-11-15 10:04:46 +01:00
signal.c arm64: use {COMPAT,}SYSCALL_DEFINE0 for sigreturn 2018-07-12 14:49:48 +01:00
signal32.c arm64: use {COMPAT,}SYSCALL_DEFINE0 for sigreturn 2018-07-12 14:49:48 +01:00
sleep.S arm64/mm: Pass ttbr1 as a parameter to __enable_mmu() 2018-09-25 15:10:54 +01:00
smccc-call.S arm64: smccc: use asm EXPORT_SYMBOL() 2018-12-10 11:50:11 +00:00
smp.c arm64: use for_each_of_cpu_node iterator 2018-09-28 14:25:58 -05:00
smp_spin_table.c
ssbd.c arm64: ssbd: Add support for PSTATE.SSBS rather than trapping to EL3 2018-09-14 17:46:19 +01:00
stacktrace.c arm64: Add stack information to on_accessible_stack 2018-07-26 11:36:07 +01:00
suspend.c arm64: mm: Support Common Not Private translations 2018-09-18 12:02:27 +01:00
sys.c arm64: implement syscall wrappers 2018-07-12 14:49:48 +01:00
sys32.c arm64: implement syscall wrappers 2018-07-12 14:49:48 +01:00
sys_compat.c signal/arm64: Push siginfo generation into arm64_notify_die 2018-09-27 21:52:54 +02:00
syscall.c arm64: svc: Ensure hardirq tracing is updated before return 2018-07-30 17:43:39 +01:00
time.c arm64: fix unwind_frame() for filtered out fn for function graph tracing 2018-02-23 13:46:38 +00:00
topology.c arm64: topology: re-introduce numa mask check for scheduler MC selection 2018-07-06 13:18:18 +01:00
trace-events-emulation.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
traps.c Merge branch 'siginfo-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace 2018-10-24 11:22:39 +01:00
vdso.c
vmlinux.lds.S arm64: relocatable: fix inconsistencies in linker script and options 2018-12-04 12:48:25 +00:00