* 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>
453 lines
10 KiB
C
453 lines
10 KiB
C
/*
|
|
* Based on arch/arm/include/asm/assembler.h, arch/arm/mm/proc-macros.S
|
|
*
|
|
* Copyright (C) 1996-2000 Russell King
|
|
* Copyright (C) 2012 ARM Ltd.
|
|
*
|
|
* 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/>.
|
|
*/
|
|
#ifndef __ASSEMBLY__
|
|
#error "Only include this from assembly code"
|
|
#endif
|
|
|
|
#ifndef __ASM_ASSEMBLER_H
|
|
#define __ASM_ASSEMBLER_H
|
|
|
|
#include <asm/asm-offsets.h>
|
|
#include <asm/cpufeature.h>
|
|
#include <asm/page.h>
|
|
#include <asm/pgtable-hwdef.h>
|
|
#include <asm/cputype.h>
|
|
#include <asm/ptrace.h>
|
|
#include <asm/thread_info.h>
|
|
|
|
/*
|
|
* Stack pushing/popping (register pairs only). Equivalent to store decrement
|
|
* before, load increment after.
|
|
*/
|
|
.macro push, xreg1, xreg2
|
|
stp \xreg1, \xreg2, [sp, #-16]!
|
|
.endm
|
|
|
|
.macro pop, xreg1, xreg2
|
|
ldp \xreg1, \xreg2, [sp], #16
|
|
.endm
|
|
|
|
/*
|
|
* Enable and disable interrupts.
|
|
*/
|
|
.macro disable_irq
|
|
msr daifset, #2
|
|
.endm
|
|
|
|
.macro enable_irq
|
|
msr daifclr, #2
|
|
.endm
|
|
|
|
.macro save_and_disable_irq, flags
|
|
mrs \flags, daif
|
|
msr daifset, #2
|
|
.endm
|
|
|
|
.macro restore_irq, flags
|
|
msr daif, \flags
|
|
.endm
|
|
|
|
/*
|
|
* Save/disable and restore interrupts.
|
|
*/
|
|
.macro save_and_disable_irqs, olddaif
|
|
mrs \olddaif, daif
|
|
disable_irq
|
|
.endm
|
|
|
|
.macro restore_irqs, olddaif
|
|
msr daif, \olddaif
|
|
.endm
|
|
|
|
/*
|
|
* Enable and disable debug exceptions.
|
|
*/
|
|
.macro disable_dbg
|
|
msr daifset, #8
|
|
.endm
|
|
|
|
.macro enable_dbg
|
|
msr daifclr, #8
|
|
.endm
|
|
|
|
.macro disable_step_tsk, flgs, tmp
|
|
tbz \flgs, #TIF_SINGLESTEP, 9990f
|
|
mrs \tmp, mdscr_el1
|
|
bic \tmp, \tmp, #1
|
|
msr mdscr_el1, \tmp
|
|
isb // Synchronise with enable_dbg
|
|
9990:
|
|
.endm
|
|
|
|
.macro enable_step_tsk, flgs, tmp
|
|
tbz \flgs, #TIF_SINGLESTEP, 9990f
|
|
disable_dbg
|
|
mrs \tmp, mdscr_el1
|
|
orr \tmp, \tmp, #1
|
|
msr mdscr_el1, \tmp
|
|
9990:
|
|
.endm
|
|
|
|
/*
|
|
* Enable both debug exceptions and interrupts. This is likely to be
|
|
* faster than two daifclr operations, since writes to this register
|
|
* are self-synchronising.
|
|
*/
|
|
.macro enable_dbg_and_irq
|
|
msr daifclr, #(8 | 2)
|
|
.endm
|
|
|
|
/*
|
|
* SMP data memory barrier
|
|
*/
|
|
.macro smp_dmb, opt
|
|
dmb \opt
|
|
.endm
|
|
|
|
/*
|
|
* NOP sequence
|
|
*/
|
|
.macro nops, num
|
|
.rept \num
|
|
nop
|
|
.endr
|
|
.endm
|
|
|
|
/*
|
|
* Emit an entry into the exception table
|
|
*/
|
|
.macro _asm_extable, from, to
|
|
.pushsection __ex_table, "a"
|
|
.align 3
|
|
.long (\from - .), (\to - .)
|
|
.popsection
|
|
.endm
|
|
|
|
#define USER(l, x...) \
|
|
9999: x; \
|
|
_asm_extable 9999b, l
|
|
|
|
/*
|
|
* Register aliases.
|
|
*/
|
|
lr .req x30 // link register
|
|
|
|
/*
|
|
* Vector entry
|
|
*/
|
|
.macro ventry label
|
|
.align 7
|
|
b \label
|
|
.endm
|
|
|
|
/*
|
|
* Select code when configured for BE.
|
|
*/
|
|
#ifdef CONFIG_CPU_BIG_ENDIAN
|
|
#define CPU_BE(code...) code
|
|
#else
|
|
#define CPU_BE(code...)
|
|
#endif
|
|
|
|
/*
|
|
* Select code when configured for LE.
|
|
*/
|
|
#ifdef CONFIG_CPU_BIG_ENDIAN
|
|
#define CPU_LE(code...)
|
|
#else
|
|
#define CPU_LE(code...) code
|
|
#endif
|
|
|
|
/*
|
|
* Define a macro that constructs a 64-bit value by concatenating two
|
|
* 32-bit registers. Note that on big endian systems the order of the
|
|
* registers is swapped.
|
|
*/
|
|
#ifndef CONFIG_CPU_BIG_ENDIAN
|
|
.macro regs_to_64, rd, lbits, hbits
|
|
#else
|
|
.macro regs_to_64, rd, hbits, lbits
|
|
#endif
|
|
orr \rd, \lbits, \hbits, lsl #32
|
|
.endm
|
|
|
|
/*
|
|
* Pseudo-ops for PC-relative adr/ldr/str <reg>, <symbol> where
|
|
* <symbol> is within the range +/- 4 GB of the PC.
|
|
*/
|
|
/*
|
|
* @dst: destination register (64 bit wide)
|
|
* @sym: name of the symbol
|
|
* @tmp: optional scratch register to be used if <dst> == sp, which
|
|
* is not allowed in an adrp instruction
|
|
*/
|
|
.macro adr_l, dst, sym, tmp=
|
|
.ifb \tmp
|
|
adrp \dst, \sym
|
|
add \dst, \dst, :lo12:\sym
|
|
.else
|
|
adrp \tmp, \sym
|
|
add \dst, \tmp, :lo12:\sym
|
|
.endif
|
|
.endm
|
|
|
|
/*
|
|
* @dst: destination register (32 or 64 bit wide)
|
|
* @sym: name of the symbol
|
|
* @tmp: optional 64-bit scratch register to be used if <dst> is a
|
|
* 32-bit wide register, in which case it cannot be used to hold
|
|
* the address
|
|
*/
|
|
.macro ldr_l, dst, sym, tmp=
|
|
.ifb \tmp
|
|
adrp \dst, \sym
|
|
ldr \dst, [\dst, :lo12:\sym]
|
|
.else
|
|
adrp \tmp, \sym
|
|
ldr \dst, [\tmp, :lo12:\sym]
|
|
.endif
|
|
.endm
|
|
|
|
/*
|
|
* @src: source register (32 or 64 bit wide)
|
|
* @sym: name of the symbol
|
|
* @tmp: mandatory 64-bit scratch register to calculate the address
|
|
* while <src> needs to be preserved.
|
|
*/
|
|
.macro str_l, src, sym, tmp
|
|
adrp \tmp, \sym
|
|
str \src, [\tmp, :lo12:\sym]
|
|
.endm
|
|
|
|
/*
|
|
* @dst: Result of per_cpu(sym, smp_processor_id())
|
|
* @sym: The name of the per-cpu variable
|
|
* @tmp: scratch register
|
|
*/
|
|
.macro adr_this_cpu, dst, sym, tmp
|
|
adr_l \dst, \sym
|
|
mrs \tmp, tpidr_el1
|
|
add \dst, \dst, \tmp
|
|
.endm
|
|
|
|
/*
|
|
* @dst: Result of READ_ONCE(per_cpu(sym, smp_processor_id()))
|
|
* @sym: The name of the per-cpu variable
|
|
* @tmp: scratch register
|
|
*/
|
|
.macro ldr_this_cpu dst, sym, tmp
|
|
adr_l \dst, \sym
|
|
mrs \tmp, tpidr_el1
|
|
ldr \dst, [\dst, \tmp]
|
|
.endm
|
|
|
|
/*
|
|
* vma_vm_mm - get mm pointer from vma pointer (vma->vm_mm)
|
|
*/
|
|
.macro vma_vm_mm, rd, rn
|
|
ldr \rd, [\rn, #VMA_VM_MM]
|
|
.endm
|
|
|
|
/*
|
|
* mmid - get context id from mm pointer (mm->context.id)
|
|
*/
|
|
.macro mmid, rd, rn
|
|
ldr \rd, [\rn, #MM_CONTEXT_ID]
|
|
.endm
|
|
|
|
/*
|
|
* dcache_line_size - get the minimum D-cache line size from the CTR register.
|
|
*/
|
|
.macro dcache_line_size, reg, tmp
|
|
mrs \tmp, ctr_el0 // read CTR
|
|
ubfm \tmp, \tmp, #16, #19 // cache line size encoding
|
|
mov \reg, #4 // bytes per word
|
|
lsl \reg, \reg, \tmp // actual cache line size
|
|
.endm
|
|
|
|
/*
|
|
* icache_line_size - get the minimum I-cache line size from the CTR register.
|
|
*/
|
|
.macro icache_line_size, reg, tmp
|
|
mrs \tmp, ctr_el0 // read CTR
|
|
and \tmp, \tmp, #0xf // cache line size encoding
|
|
mov \reg, #4 // bytes per word
|
|
lsl \reg, \reg, \tmp // actual cache line size
|
|
.endm
|
|
|
|
/*
|
|
* tcr_set_idmap_t0sz - update TCR.T0SZ so that we can load the ID map
|
|
*/
|
|
.macro tcr_set_idmap_t0sz, valreg, tmpreg
|
|
#ifndef CONFIG_ARM64_VA_BITS_48
|
|
ldr_l \tmpreg, idmap_t0sz
|
|
bfi \valreg, \tmpreg, #TCR_T0SZ_OFFSET, #TCR_TxSZ_WIDTH
|
|
#endif
|
|
.endm
|
|
|
|
/*
|
|
* Macro to perform a data cache maintenance for the interval
|
|
* [kaddr, kaddr + size)
|
|
*
|
|
* op: operation passed to dc instruction
|
|
* domain: domain used in dsb instruciton
|
|
* kaddr: starting virtual address of the region
|
|
* size: size of the region
|
|
* Corrupts: kaddr, size, tmp1, tmp2
|
|
*/
|
|
.macro dcache_by_line_op op, domain, kaddr, size, tmp1, tmp2
|
|
dcache_line_size \tmp1, \tmp2
|
|
add \size, \kaddr, \size
|
|
sub \tmp2, \tmp1, #1
|
|
bic \kaddr, \kaddr, \tmp2
|
|
9998:
|
|
.if (\op == cvau || \op == cvac)
|
|
alternative_if_not ARM64_WORKAROUND_CLEAN_CACHE
|
|
dc \op, \kaddr
|
|
alternative_else
|
|
dc civac, \kaddr
|
|
alternative_endif
|
|
.else
|
|
dc \op, \kaddr
|
|
.endif
|
|
add \kaddr, \kaddr, \tmp1
|
|
cmp \kaddr, \size
|
|
b.lo 9998b
|
|
dsb \domain
|
|
.endm
|
|
|
|
/*
|
|
* reset_pmuserenr_el0 - reset PMUSERENR_EL0 if PMUv3 present
|
|
*/
|
|
.macro reset_pmuserenr_el0, tmpreg
|
|
mrs \tmpreg, id_aa64dfr0_el1 // Check ID_AA64DFR0_EL1 PMUVer
|
|
sbfx \tmpreg, \tmpreg, #8, #4
|
|
cmp \tmpreg, #1 // Skip if no PMU present
|
|
b.lt 9000f
|
|
msr pmuserenr_el0, xzr // Disable PMU access from EL0
|
|
9000:
|
|
.endm
|
|
|
|
/*
|
|
* copy_page - copy src to dest using temp registers t1-t8
|
|
*/
|
|
.macro copy_page dest:req src:req t1:req t2:req t3:req t4:req t5:req t6:req t7:req t8:req
|
|
9998: ldp \t1, \t2, [\src]
|
|
ldp \t3, \t4, [\src, #16]
|
|
ldp \t5, \t6, [\src, #32]
|
|
ldp \t7, \t8, [\src, #48]
|
|
add \src, \src, #64
|
|
stnp \t1, \t2, [\dest]
|
|
stnp \t3, \t4, [\dest, #16]
|
|
stnp \t5, \t6, [\dest, #32]
|
|
stnp \t7, \t8, [\dest, #48]
|
|
add \dest, \dest, #64
|
|
tst \src, #(PAGE_SIZE - 1)
|
|
b.ne 9998b
|
|
.endm
|
|
|
|
/*
|
|
* Annotate a function as position independent, i.e., safe to be called before
|
|
* the kernel virtual mapping is activated.
|
|
*/
|
|
#define ENDPIPROC(x) \
|
|
.globl __pi_##x; \
|
|
.type __pi_##x, %function; \
|
|
.set __pi_##x, x; \
|
|
.size __pi_##x, . - x; \
|
|
ENDPROC(x)
|
|
|
|
/*
|
|
* Emit a 64-bit absolute little endian symbol reference in a way that
|
|
* ensures that it will be resolved at build time, even when building a
|
|
* PIE binary. This requires cooperation from the linker script, which
|
|
* must emit the lo32/hi32 halves individually.
|
|
*/
|
|
.macro le64sym, sym
|
|
.long \sym\()_lo32
|
|
.long \sym\()_hi32
|
|
.endm
|
|
|
|
/*
|
|
* mov_q - move an immediate constant into a 64-bit register using
|
|
* between 2 and 4 movz/movk instructions (depending on the
|
|
* magnitude and sign of the operand)
|
|
*/
|
|
.macro mov_q, reg, val
|
|
.if (((\val) >> 31) == 0 || ((\val) >> 31) == 0x1ffffffff)
|
|
movz \reg, :abs_g1_s:\val
|
|
.else
|
|
.if (((\val) >> 47) == 0 || ((\val) >> 47) == 0x1ffff)
|
|
movz \reg, :abs_g2_s:\val
|
|
.else
|
|
movz \reg, :abs_g3:\val
|
|
movk \reg, :abs_g2_nc:\val
|
|
.endif
|
|
movk \reg, :abs_g1_nc:\val
|
|
.endif
|
|
movk \reg, :abs_g0_nc:\val
|
|
.endm
|
|
|
|
/*
|
|
* Return the current thread_info.
|
|
*/
|
|
.macro get_thread_info, rd
|
|
mrs \rd, sp_el0
|
|
.endm
|
|
|
|
/*
|
|
* Check the MIDR_EL1 of the current CPU for a given model and a range of
|
|
* variant/revision. See asm/cputype.h for the macros used below.
|
|
*
|
|
* model: MIDR_CPU_PART of CPU
|
|
* rv_min: Minimum of MIDR_CPU_VAR_REV()
|
|
* rv_max: Maximum of MIDR_CPU_VAR_REV()
|
|
* res: Result register.
|
|
* tmp1, tmp2, tmp3: Temporary registers
|
|
*
|
|
* Corrupts: res, tmp1, tmp2, tmp3
|
|
* Returns: 0, if the CPU id doesn't match. Non-zero otherwise
|
|
*/
|
|
.macro cpu_midr_match model, rv_min, rv_max, res, tmp1, tmp2, tmp3
|
|
mrs \res, midr_el1
|
|
mov_q \tmp1, (MIDR_REVISION_MASK | MIDR_VARIANT_MASK)
|
|
mov_q \tmp2, MIDR_CPU_PART_MASK
|
|
and \tmp3, \res, \tmp2 // Extract model
|
|
and \tmp1, \res, \tmp1 // rev & variant
|
|
mov_q \tmp2, \model
|
|
cmp \tmp3, \tmp2
|
|
cset \res, eq
|
|
cbz \res, .Ldone\@ // Model matches ?
|
|
|
|
.if (\rv_min != 0) // Skip min check if rv_min == 0
|
|
mov_q \tmp3, \rv_min
|
|
cmp \tmp1, \tmp3
|
|
cset \res, ge
|
|
.endif // \rv_min != 0
|
|
/* Skip rv_max check if rv_min == rv_max && rv_min != 0 */
|
|
.if ((\rv_min != \rv_max) || \rv_min == 0)
|
|
mov_q \tmp2, \rv_max
|
|
cmp \tmp1, \tmp2
|
|
cset \tmp2, le
|
|
and \res, \res, \tmp2
|
|
.endif
|
|
.Ldone\@:
|
|
.endm
|
|
|
|
#endif /* __ASM_ASSEMBLER_H */
|