* refs/heads/tmp-3f51ea2 Linux 4.4.133 x86/kexec: Avoid double free_page() upon do_kexec_load() failure hfsplus: stop workqueue when fill_super() failed cfg80211: limit wiphy names to 128 bytes gpio: rcar: Add Runtime PM handling for interrupts time: Fix CLOCK_MONOTONIC_RAW sub-nanosecond accounting dmaengine: ensure dmaengine helpers check valid callback scsi: zfcp: fix infinite iteration on ERP ready list scsi: sg: allocate with __GFP_ZERO in sg_build_indirect() scsi: libsas: defer ata device eh commands to libata s390: use expoline thunks in the BPF JIT s390: extend expoline to BC instructions s390: move spectre sysfs attribute code s390/kernel: use expoline for indirect branches s390/lib: use expoline for indirect branches s390: move expoline assembler macros to a header s390: add assembler macros for CPU alternatives ext2: fix a block leak tcp: purge write queue in tcp_connect_init() sock_diag: fix use-after-free read in __sk_free packet: in packet_snd start writing at link layer allocation net: test tailroom before appending to linear skb btrfs: fix reading stale metadata blocks after degraded raid1 mounts btrfs: fix crash when trying to resume balance without the resume flag Btrfs: fix xattr loss after power failure ARM: 8772/1: kprobes: Prohibit kprobes on get_user functions ARM: 8770/1: kprobes: Prohibit probing on optimized_callback ARM: 8769/1: kprobes: Fix to use get_kprobe_ctlblk after irq-disabed tick/broadcast: Use for_each_cpu() specially on UP kernels ARM: 8771/1: kprobes: Prohibit kprobes on do_undefinstr efi: Avoid potential crashes, fix the 'struct efi_pci_io_protocol_32' definition for mixed mode s390: remove indirect branch from do_softirq_own_stack s390/qdio: don't release memory in qdio_setup_irq() s390/cpum_sf: ensure sample frequency of perf event attributes is non-zero s390/qdio: fix access to uninitialized qdio_q fields mm: don't allow deferred pages with NEED_PER_CPU_KM powerpc/powernv: Fix NVRAM sleep in invalid context when crashing procfs: fix pthread cross-thread naming if !PR_DUMPABLE proc read mm's {arg,env}_{start,end} with mmap semaphore taken. tracing/x86/xen: Remove zero data size trace events trace_xen_mmu_flush_tlb{_all} cpufreq: intel_pstate: Enable HWP by default signals: avoid unnecessary taking of sighand->siglock mm: filemap: avoid unnecessary calls to lock_page when waiting for IO to complete during a read mm: filemap: remove redundant code in do_read_cache_page proc: meminfo: estimate available memory more conservatively vmscan: do not force-scan file lru if its absolute size is small powerpc: Don't preempt_disable() in show_cpuinfo() cpuidle: coupled: remove unused define cpuidle_coupled_lock powerpc/powernv: remove FW_FEATURE_OPALv3 and just use FW_FEATURE_OPAL powerpc/powernv: Remove OPALv2 firmware define and references powerpc/powernv: panic() on OPAL < V3 spi: pxa2xx: Allow 64-bit DMA ALSA: control: fix a redundant-copy issue ALSA: hda: Add Lenovo C50 All in one to the power_save blacklist ALSA: usb: mixer: volume quirk for CM102-A+/102S+ usbip: usbip_host: fix bad unlock balance during stub_probe() usbip: usbip_host: fix NULL-ptr deref and use-after-free errors usbip: usbip_host: run rebind from exit when module is removed usbip: usbip_host: delete device from busid_table after rebind usbip: usbip_host: refine probe and disconnect debug msgs to be useful kernel/exit.c: avoid undefined behaviour when calling wait4() futex: futex_wake_op, fix sign_extend32 sign bits pipe: cap initial pipe capacity according to pipe-max-size limit l2tp: revert "l2tp: fix missing print session offset info" Revert "ARM: dts: imx6qdl-wandboard: Fix audio channel swap" lockd: lost rollback of set_grace_period() in lockd_down_net() xfrm: fix xfrm_do_migrate() with AEAD e.g(AES-GCM) futex: Remove duplicated code and fix undefined behaviour futex: Remove unnecessary warning from get_futex_key arm64: Add work around for Arm Cortex-A55 Erratum 1024718 arm64: introduce mov_q macro to move a constant into a 64-bit register audit: move calcs after alloc and check when logging set loginuid ALSA: timer: Call notifier in the same spinlock sctp: delay the authentication for the duplicated cookie-echo chunk sctp: fix the issue that the cookie-ack with auth can't get processed tcp: ignore Fast Open on repair mode bonding: do not allow rlb updates to invalid mac tg3: Fix vunmap() BUG_ON() triggered from tg3_free_consistent(). sctp: use the old asoc when making the cookie-ack chunk in dupcook_d sctp: handle two v4 addrs comparison in sctp_inet6_cmp_addr r8169: fix powering up RTL8168h qmi_wwan: do not steal interfaces from class drivers openvswitch: Don't swap table in nlattr_set() after OVS_ATTR_NESTED is found net: support compat 64-bit time in {s,g}etsockopt net_sched: fq: take care of throttled flows before reuse net/mlx4_en: Verify coalescing parameters are in range net: ethernet: sun: niu set correct packet size in skb llc: better deal with too small mtu ipv4: fix memory leaks in udp_sendmsg, ping_v4_sendmsg dccp: fix tasklet usage bridge: check iface upper dev when setting master via ioctl 8139too: Use disable_irq_nosync() in rtl8139_poll_controller() BACKPORT, FROMLIST: fscrypt: add Speck128/256 support cgroup: Disable IRQs while holding css_set_lock Revert "cgroup: Disable IRQs while holding css_set_lock" cgroup: Disable IRQs while holding css_set_lock ANDROID: proc: fix undefined behavior in proc_uid_base_readdir x86: vdso: Fix leaky vdso linker with CC=clang. ANDROID: build: cuttlefish: Upgrade clang to newer version. ANDROID: build: cuttlefish: Upgrade clang to newer version. ANDROID: build: cuttlefish: Fix path to clang. UPSTREAM: dm bufio: avoid sleeping while holding the dm_bufio lock ANDROID: sdcardfs: Don't d_drop in d_revalidate Conflicts: arch/arm64/include/asm/cputype.h fs/ext4/crypto.c fs/ext4/ext4.h kernel/cgroup.c mm/vmscan.c Change-Id: Ic10c5722b6439af1cf423fd949c493f786764d7e Signed-off-by: Srinivasarao P <spathi@codeaurora.org>
323 lines
7.5 KiB
ArmAsm
323 lines
7.5 KiB
ArmAsm
/*
|
|
* Based on arch/arm/mm/proc.S
|
|
*
|
|
* Copyright (C) 2001 Deep Blue Solutions Ltd.
|
|
* Copyright (C) 2012 ARM Ltd.
|
|
* Author: Catalin Marinas <catalin.marinas@arm.com>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include <linux/init.h>
|
|
#include <linux/linkage.h>
|
|
#include <asm/assembler.h>
|
|
#include <asm/asm-offsets.h>
|
|
#include <asm/hwcap.h>
|
|
#include <asm/pgtable.h>
|
|
#include <asm/pgtable-hwdef.h>
|
|
#include <asm/cpufeature.h>
|
|
#include <asm/alternative.h>
|
|
|
|
#ifdef CONFIG_ARM64_64K_PAGES
|
|
#define TCR_TG_FLAGS TCR_TG0_64K | TCR_TG1_64K
|
|
#elif defined(CONFIG_ARM64_16K_PAGES)
|
|
#define TCR_TG_FLAGS TCR_TG0_16K | TCR_TG1_16K
|
|
#else /* CONFIG_ARM64_4K_PAGES */
|
|
#define TCR_TG_FLAGS TCR_TG0_4K | TCR_TG1_4K
|
|
#endif
|
|
|
|
#define TCR_SMP_FLAGS TCR_SHARED
|
|
|
|
/* PTWs cacheable, inner/outer WBWA */
|
|
#define TCR_CACHE_FLAGS TCR_IRGN_WBWA | TCR_ORGN_WBWA
|
|
|
|
#define MAIR(attr, mt) ((attr) << ((mt) * 8))
|
|
|
|
/*
|
|
* cpu_cache_off()
|
|
*
|
|
* Turn the CPU D-cache off.
|
|
*/
|
|
ENTRY(cpu_cache_off)
|
|
mrs x0, sctlr_el1
|
|
bic x0, x0, #1 << 2 // clear SCTLR.C
|
|
msr sctlr_el1, x0
|
|
isb
|
|
ret
|
|
ENDPROC(cpu_cache_off)
|
|
|
|
/*
|
|
* cpu_reset(loc)
|
|
*
|
|
* Perform a soft reset of the system. Put the CPU into the same state
|
|
* as it would be if it had been reset, and branch to what would be the
|
|
* reset vector. It must be executed with the flat identity mapping.
|
|
*
|
|
* - loc - location to jump to for soft reset
|
|
*/
|
|
.align 5
|
|
ENTRY(cpu_reset)
|
|
mrs x1, sctlr_el1
|
|
bic x1, x1, #1
|
|
msr sctlr_el1, x1 // disable the MMU
|
|
isb
|
|
ret x0
|
|
ENDPROC(cpu_reset)
|
|
|
|
ENTRY(cpu_soft_restart)
|
|
/* Save address of cpu_reset() and reset address */
|
|
mov x19, x0
|
|
mov x20, x1
|
|
|
|
/* Turn D-cache off */
|
|
bl cpu_cache_off
|
|
|
|
/* Push out all dirty data, and ensure cache is empty */
|
|
bl flush_cache_all
|
|
|
|
mov x0, x20
|
|
ret x19
|
|
ENDPROC(cpu_soft_restart)
|
|
|
|
/*
|
|
* cpu_do_idle()
|
|
*
|
|
* Idle the processor (wait for interrupt).
|
|
*/
|
|
ENTRY(cpu_do_idle)
|
|
dsb sy // WFI may enter a low-power mode
|
|
wfi
|
|
ret
|
|
ENDPROC(cpu_do_idle)
|
|
|
|
#ifdef CONFIG_CPU_PM
|
|
/**
|
|
* cpu_do_suspend - save CPU registers context
|
|
*
|
|
* x0: virtual address of context pointer
|
|
*/
|
|
ENTRY(cpu_do_suspend)
|
|
mrs x2, tpidr_el0
|
|
mrs x3, tpidrro_el0
|
|
mrs x4, contextidr_el1
|
|
mrs x5, cpacr_el1
|
|
mrs x6, tcr_el1
|
|
mrs x7, vbar_el1
|
|
mrs x8, mdscr_el1
|
|
mrs x9, oslsr_el1
|
|
mrs x10, sctlr_el1
|
|
mrs x11, tpidr_el1
|
|
mrs x12, sp_el0
|
|
stp x2, x3, [x0]
|
|
stp x4, xzr, [x0, #16]
|
|
stp x5, x6, [x0, #32]
|
|
stp x7, x8, [x0, #48]
|
|
stp x9, x10, [x0, #64]
|
|
stp x11, x12, [x0, #80]
|
|
ret
|
|
ENDPROC(cpu_do_suspend)
|
|
|
|
/**
|
|
* cpu_do_resume - restore CPU register context
|
|
*
|
|
* x0: Address of context pointer
|
|
*/
|
|
ENTRY(cpu_do_resume)
|
|
ldp x2, x3, [x0]
|
|
ldp x4, x5, [x0, #16]
|
|
ldp x6, x8, [x0, #32]
|
|
ldp x9, x10, [x0, #48]
|
|
ldp x11, x12, [x0, #64]
|
|
ldp x13, x14, [x0, #80]
|
|
msr tpidr_el0, x2
|
|
msr tpidrro_el0, x3
|
|
msr contextidr_el1, x4
|
|
msr cpacr_el1, x6
|
|
|
|
/* Don't change t0sz here, mask those bits when restoring */
|
|
mrs x5, tcr_el1
|
|
bfi x8, x5, TCR_T0SZ_OFFSET, TCR_TxSZ_WIDTH
|
|
|
|
msr tcr_el1, x8
|
|
msr vbar_el1, x9
|
|
msr mdscr_el1, x10
|
|
msr sctlr_el1, x12
|
|
msr tpidr_el1, x13
|
|
msr sp_el0, x14
|
|
/*
|
|
* Restore oslsr_el1 by writing oslar_el1
|
|
*/
|
|
ubfx x11, x11, #1, #1
|
|
msr oslar_el1, x11
|
|
reset_pmuserenr_el0 x0 // Disable PMU access from EL0
|
|
isb
|
|
ret
|
|
ENDPROC(cpu_do_resume)
|
|
#endif
|
|
|
|
/*
|
|
* cpu_do_switch_mm(pgd_phys, tsk)
|
|
*
|
|
* Set the translation table base pointer to be pgd_phys.
|
|
*
|
|
* - pgd_phys - physical address of new TTB
|
|
*/
|
|
ENTRY(cpu_do_switch_mm)
|
|
mrs x2, ttbr1_el1
|
|
mmid x1, x1 // get mm->context.id
|
|
#ifdef CONFIG_ARM64_SW_TTBR0_PAN
|
|
bfi x0, x1, #48, #16 // set the ASID field in TTBR0
|
|
#endif
|
|
bfi x2, x1, #48, #16 // set the ASID
|
|
msr ttbr1_el1, x2 // in TTBR1 (since TCR.A1 is set)
|
|
isb
|
|
msr ttbr0_el1, x0 // now update TTBR0
|
|
isb
|
|
b post_ttbr_update_workaround // Back to C code...
|
|
ENDPROC(cpu_do_switch_mm)
|
|
|
|
.pushsection ".idmap.text", "ax"
|
|
/*
|
|
* void idmap_cpu_replace_ttbr1(phys_addr_t new_pgd)
|
|
*
|
|
* This is the low-level counterpart to cpu_replace_ttbr1, and should not be
|
|
* called by anything else. It can only be executed from a TTBR0 mapping.
|
|
*/
|
|
ENTRY(idmap_cpu_replace_ttbr1)
|
|
mrs x2, daif
|
|
msr daifset, #0xf
|
|
|
|
adrp x1, empty_zero_page
|
|
msr ttbr1_el1, x1
|
|
isb
|
|
|
|
tlbi vmalle1
|
|
dsb nsh
|
|
isb
|
|
|
|
msr ttbr1_el1, x0
|
|
isb
|
|
|
|
msr daif, x2
|
|
|
|
ret
|
|
ENDPROC(idmap_cpu_replace_ttbr1)
|
|
.popsection
|
|
|
|
/*
|
|
* __cpu_setup
|
|
*
|
|
* Initialise the processor for turning the MMU on. Return in x0 the
|
|
* value of the SCTLR_EL1 register.
|
|
*/
|
|
ENTRY(__cpu_setup)
|
|
tlbi vmalle1 // Invalidate local TLB
|
|
dsb nsh
|
|
|
|
mov x0, #3 << 20
|
|
msr cpacr_el1, x0 // Enable FP/ASIMD
|
|
mov x0, #1 << 12 // Reset mdscr_el1 and disable
|
|
msr mdscr_el1, x0 // access to the DCC from EL0
|
|
isb // Unmask debug exceptions now,
|
|
enable_dbg // since this is per-cpu
|
|
reset_pmuserenr_el0 x0 // Disable PMU access from EL0
|
|
/*
|
|
* Memory region attributes for LPAE:
|
|
*
|
|
* n = AttrIndx[2:0]
|
|
* n MAIR
|
|
* DEVICE_nGnRnE 000 00000000
|
|
* DEVICE_nGnRE 001 00000100
|
|
* DEVICE_GRE 010 00001100
|
|
* NORMAL_NC 011 01000100
|
|
* NORMAL 100 11111111
|
|
* NORMAL_WT 101 10111011
|
|
*/
|
|
ldr x5, =MAIR(0x00, MT_DEVICE_nGnRnE) | \
|
|
MAIR(0x04, MT_DEVICE_nGnRE) | \
|
|
MAIR(0x0c, MT_DEVICE_GRE) | \
|
|
MAIR(0x44, MT_NORMAL_NC) | \
|
|
MAIR(0xff, MT_NORMAL) | \
|
|
MAIR(0xbb, MT_NORMAL_WT)
|
|
msr mair_el1, x5
|
|
/*
|
|
* Prepare SCTLR
|
|
*/
|
|
adr x5, crval
|
|
ldp w5, w6, [x5]
|
|
mrs x0, sctlr_el1
|
|
bic x0, x0, x5 // clear bits
|
|
orr x0, x0, x6 // set bits
|
|
/*
|
|
* Set/prepare TCR and TTBR. We use 512GB (39-bit) address range for
|
|
* both user and kernel.
|
|
*/
|
|
ldr x10, =TCR_TxSZ(VA_BITS) | TCR_CACHE_FLAGS | TCR_SMP_FLAGS | \
|
|
TCR_TG_FLAGS | TCR_ASID16 | TCR_TBI0 | TCR_A1
|
|
tcr_set_idmap_t0sz x10, x9
|
|
|
|
/*
|
|
* Read the PARange bits from ID_AA64MMFR0_EL1 and set the IPS bits in
|
|
* TCR_EL1.
|
|
*/
|
|
mrs x9, ID_AA64MMFR0_EL1
|
|
bfi x10, x9, #32, #3
|
|
#ifdef CONFIG_ARM64_HW_AFDBM
|
|
/*
|
|
* Hardware update of the Access and Dirty bits.
|
|
*/
|
|
mrs x9, ID_AA64MMFR1_EL1
|
|
and x9, x9, #0xf
|
|
cbz x9, 2f
|
|
cmp x9, #2
|
|
b.lt 1f
|
|
#ifdef CONFIG_ARM64_ERRATUM_1024718
|
|
/* Disable hardware DBM on Cortex-A55 r0p0, r0p1 & r1p0 */
|
|
cpu_midr_match MIDR_CORTEX_A55, MIDR_CPU_VAR_REV(0, 0), MIDR_CPU_VAR_REV(1, 0), x1, x2, x3, x4
|
|
cbnz x1, 1f
|
|
#endif
|
|
orr x10, x10, #TCR_HD // hardware Dirty flag update
|
|
1: orr x10, x10, #TCR_HA // hardware Access flag update
|
|
2:
|
|
#endif /* CONFIG_ARM64_HW_AFDBM */
|
|
msr tcr_el1, x10
|
|
ret // return to head.S
|
|
ENDPROC(__cpu_setup)
|
|
|
|
/*
|
|
* We set the desired value explicitly, including those of the
|
|
* reserved bits. The values of bits EE & E0E were set early in
|
|
* el2_setup, which are left untouched below.
|
|
*
|
|
* n n T
|
|
* U E WT T UD US IHBS
|
|
* CE0 XWHW CZ ME TEEA S
|
|
* .... .IEE .... NEAI TE.I ..AD DEN0 ACAM
|
|
* 0011 0... 1101 ..0. ..0. 10.. .0.. .... < hardware reserved
|
|
* .... .1.. .... 01.1 11.1 ..01 0.01 1101 < software settings
|
|
*/
|
|
.type crval, #object
|
|
crval:
|
|
#ifdef CONFIG_ARM64_ICACHE_DISABLE
|
|
#define CR_IBIT 0
|
|
#else
|
|
#define CR_IBIT 0x1000
|
|
#endif
|
|
|
|
#ifdef CONFIG_ARM64_DCACHE_DISABLE
|
|
#define CR_CBIT 0
|
|
#else
|
|
#define CR_CBIT 0x4
|
|
#endif
|
|
.word 0xfcffffff // clear
|
|
.word 0x34d5d91d | CR_IBIT | CR_CBIT // set
|