Skip to content

Commit

Permalink
CAF Upstream to LA.UM.6.6.r1-09600-89xx.0
Browse files Browse the repository at this point in the history
"LA.UM.6.6.r1-09600-89xx.0"
  • Loading branch information
mountaser committed Aug 30, 2018
2 parents 884750f + 36fe96f commit f475431
Show file tree
Hide file tree
Showing 30 changed files with 916 additions and 313 deletions.
2 changes: 1 addition & 1 deletion arch/arm/boot/dts/qcom/mdm9650.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<286 0x10000>, <283 0x10000>, <359 0x10000>;
interrupt-parent = <&intc>;

reserved-memory {
reserved_mem: reserved-memory {
#address-cells = <1>;
#size-cells = <1>;
ranges;
Expand Down
11 changes: 11 additions & 0 deletions arch/arm/boot/dts/qcom/sdx20.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@
reg = <0x88000000 0x7300000>;
};

&reserved_mem {
linux,cma {
compatible = "shared-dma-pool";
alloc-ranges = <0 0x00000000 0 0x90000000>;
reusable;
alignment = <0 0x400000>;
size = <0 0xc00000>;
linux,cma-default;
};
};

&soc {
/* SD card 2.95 V supply */
sdc_vreg: sdc_vreg {
Expand Down
1 change: 0 additions & 1 deletion arch/arm/configs/msmcortex_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,6 @@ CONFIG_CRYPTO_CTR=y
CONFIG_CRYPTO_XCBC=y
CONFIG_CRYPTO_MD4=y
CONFIG_CRYPTO_TWOFISH=y
CONFIG_FIPS_ENABLE=y
CONFIG_CRYPTO_DEV_QCRYPTO=y
CONFIG_CRYPTO_DEV_QCOM_MSM_QCE=y
CONFIG_CRYPTO_DEV_QCEDEV=y
Expand Down
1 change: 1 addition & 0 deletions arch/arm64/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ config ARM64
select SPARSE_IRQ
select SYSCTL_EXCEPTION_TRACE
select HAVE_CONTEXT_TRACKING
select THREAD_INFO_IN_TASK
select MSM_JTAGV8 if CORESIGHT_ETMV4
help
ARM 64-bit (AArch64) Linux support.
Expand Down
27 changes: 27 additions & 0 deletions arch/arm64/include/asm/current.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#ifndef __ASM_CURRENT_H
#define __ASM_CURRENT_H

#include <linux/compiler.h>

#include <asm/sysreg.h>

#ifndef __ASSEMBLY__

#ifdef CONFIG_THREAD_INFO_IN_TASK
struct task_struct;

static __always_inline struct task_struct *get_current(void)
{
return (struct task_struct *)read_sysreg(sp_el0);
}
#define current get_current()
#else
#include <linux/thread_info.h>
#define get_current() (current_thread_info()->task)
#define current get_current()
#endif

#endif /* __ASSEMBLY__ */

#endif /* __ASM_CURRENT_H */

3 changes: 3 additions & 0 deletions arch/arm64/include/asm/smp.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ asmlinkage void secondary_start_kernel(void);
*/
struct secondary_data {
void *stack;
#ifdef CONFIG_THREAD_INFO_IN_TASK
struct task_struct *task;
#endif
};
extern struct secondary_data secondary_data;
extern void secondary_entry(void);
Expand Down
15 changes: 14 additions & 1 deletion arch/arm64/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,26 @@ typedef unsigned long mm_segment_t;
struct thread_info {
unsigned long flags; /* low level flags */
mm_segment_t addr_limit; /* address limit */
#ifndef CONFIG_THREAD_INFO_IN_TASK
struct task_struct *task; /* main task structure */
#endif
struct exec_domain *exec_domain; /* execution domain */
#ifdef CONFIG_ARM64_SW_TTBR0_PAN
u64 ttbr0; /* saved TTBR0_EL1 */
#endif
int preempt_count; /* 0 => preemptable, <0 => bug */
#ifndef CONFIG_THREAD_INFO_IN_TASK
int cpu; /* cpu */
#endif
};

#ifdef CONFIG_THREAD_INFO_IN_TASK
#define INIT_THREAD_INFO(tsk) \
{ \
.preempt_count = INIT_PREEMPT_COUNT, \
.addr_limit = KERNEL_DS, \
}
#else
#define INIT_THREAD_INFO(tsk) \
{ \
.task = &tsk, \
Expand All @@ -65,7 +76,6 @@ struct thread_info {
}

#define init_thread_info (init_thread_union.thread_info)
#define init_stack (init_thread_union.stack)

/*
* how to get the current stack pointer from C
Expand All @@ -88,6 +98,9 @@ static inline struct thread_info *current_thread_info(void)

return (struct thread_info *)sp_el0;
}
#endif

#define init_stack (init_thread_union.stack)

#define thread_saved_pc(tsk) \
((unsigned long)(tsk->thread.cpu_context.pc))
Expand Down
14 changes: 12 additions & 2 deletions arch/arm64/kernel/asm-offsets.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,17 @@ int main(void)
{
DEFINE(TSK_ACTIVE_MM, offsetof(struct task_struct, active_mm));
BLANK();
#ifdef CONFIG_THREAD_INFO_IN_TASK
DEFINE(TSK_TI_FLAGS, offsetof(struct task_struct, thread_info.flags));
DEFINE(TSK_TI_PREEMPT, offsetof(struct task_struct, thread_info.preempt_count));
DEFINE(TSK_TI_ADDR_LIMIT, offsetof(struct task_struct, thread_info.addr_limit));
DEFINE(TSK_STACK, offsetof(struct task_struct, stack));
#else
DEFINE(TI_FLAGS, offsetof(struct thread_info, flags));
DEFINE(TI_PREEMPT, offsetof(struct thread_info, preempt_count));
DEFINE(TI_ADDR_LIMIT, offsetof(struct thread_info, addr_limit));
DEFINE(TI_TASK, offsetof(struct thread_info, task));
DEFINE(TI_EXEC_DOMAIN, offsetof(struct thread_info, exec_domain));
DEFINE(TI_CPU, offsetof(struct thread_info, cpu));
#endif
#ifdef CONFIG_ARM64_SW_TTBR0_PAN
DEFINE(TSK_TI_TTBR0, offsetof(struct thread_info, ttbr0));
#endif
Expand Down Expand Up @@ -113,6 +118,11 @@ int main(void)
DEFINE(TZ_MINWEST, offsetof(struct timezone, tz_minuteswest));
DEFINE(TZ_DSTTIME, offsetof(struct timezone, tz_dsttime));
BLANK();
#ifdef CONFIG_THREAD_INFO_IN_TASK
DEFINE(CPU_BOOT_STACK, offsetof(struct secondary_data, stack));
DEFINE(CPU_BOOT_TASK, offsetof(struct secondary_data, task));
BLANK();
#endif
#ifdef CONFIG_KVM_ARM_HOST
DEFINE(VCPU_CONTEXT, offsetof(struct kvm_vcpu, arch.ctxt));
DEFINE(CPU_GP_REGS, offsetof(struct kvm_cpu_context, gp_regs));
Expand Down
45 changes: 45 additions & 0 deletions arch/arm64/kernel/entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,31 @@ alternative_else_nop_endif

.if \el == 0
mrs x21, sp_el0
#ifdef CONFIG_THREAD_INFO_IN_TASK
ldr_this_cpu tsk, __entry_task, x20 // Ensure MDSCR_EL1.SS is clear,
ldr x19, [tsk, #TSK_TI_FLAGS] // since we can unmask debug
#else
mov tsk, sp
and tsk, tsk, #~(THREAD_SIZE - 1) // Ensure MDSCR_EL1.SS is clear,
ldr x19, [tsk, #TI_FLAGS] // since we can unmask debug
#endif
disable_step_tsk x19, x20 // exceptions when scheduling.
.else
add x21, sp, #S_FRAME_SIZE
get_thread_info tsk
/* Save the task's original addr_limit and set USER_DS (TASK_SIZE_64) */
#ifdef CONFIG_THREAD_INFO_IN_TASK
ldr x20, [tsk, #TSK_TI_ADDR_LIMIT]
#else
ldr x20, [tsk, #TI_ADDR_LIMIT]
#endif
str x20, [sp, #S_ORIG_ADDR_LIMIT]
mov x20, #TASK_SIZE_64
#ifdef CONFIG_THREAD_INFO_IN_TASK
str x20, [tsk, #TSK_TI_ADDR_LIMIT]
#else
str x20, [tsk, #TI_ADDR_LIMIT]
#endif
ALTERNATIVE(nop, SET_PSTATE_UAO(0), ARM64_HAS_UAO, CONFIG_ARM64_UAO)
.endif /* \el == 0 */
mrs x22, elr_el1
Expand Down Expand Up @@ -189,7 +202,11 @@ alternative_else_nop_endif
.if \el != 0
/* Restore the task's original addr_limit. */
ldr x20, [sp, #S_ORIG_ADDR_LIMIT]
#ifdef CONFIG_THREAD_INFO_IN_TASK
str x20, [tsk, #TSK_TI_ADDR_LIMIT]
#else
str x20, [tsk, #TI_ADDR_LIMIT]
#endif

/* No need to restore UAO, it will be restored from SPSR_EL1 */
.endif
Expand Down Expand Up @@ -487,9 +504,17 @@ el1_irq:

#ifdef CONFIG_PREEMPT
get_thread_info tsk
#ifdef CONFIG_THREAD_INFO_IN_TASK
ldr w24, [tsk, #TSK_TI_PREEMPT] // get preempt count
#else
ldr w24, [tsk, #TI_PREEMPT] // get preempt count
#endif
cbnz w24, 1f // preempt count != 0
#ifdef CONFIG_THREAD_INFO_IN_TASK
ldr x0, [tsk, #TSK_TI_FLAGS] // get flags
#else
ldr x0, [tsk, #TI_FLAGS] // get flags
#endif
tbz x0, #TIF_NEED_RESCHED, 1f // needs rescheduling?
bl el1_preempt
1:
Expand All @@ -504,7 +529,11 @@ ENDPROC(el1_irq)
el1_preempt:
mov x24, lr
1: bl preempt_schedule_irq // irq en/disable is done inside
#ifdef CONFIG_THREAD_INFO_IN_TASK
ldr x0, [tsk, #TSK_TI_FLAGS] // get new tasks TI_FLAGS
#else
ldr x0, [tsk, #TI_FLAGS] // get new tasks TI_FLAGS
#endif
tbnz x0, #TIF_NEED_RESCHED, 1b // needs rescheduling?
ret x24
#endif
Expand Down Expand Up @@ -771,8 +800,12 @@ ENTRY(cpu_switch_to)
mov v15.16b, v15.16b
#endif
mov sp, x9
#ifdef CONFIG_THREAD_INFO_IN_TASK
msr sp_el0, x1
#else
and x9, x9, #~(THREAD_SIZE - 1)
msr sp_el0, x9
#endif
ret
ENDPROC(cpu_switch_to)

Expand All @@ -783,7 +816,11 @@ ENDPROC(cpu_switch_to)
ret_fast_syscall:
disable_irq // disable interrupts
str x0, [sp, #S_X0] // returned x0
#ifdef CONFIG_THREAD_INFO_IN_TASK
ldr x1, [tsk, #TSK_TI_FLAGS] // re-check for syscall tracing
#else
ldr x1, [tsk, #TI_FLAGS] // re-check for syscall tracing
#endif
and x2, x1, #_TIF_SYSCALL_WORK
cbnz x2, ret_fast_syscall_trace
and x2, x1, #_TIF_WORK_MASK
Expand Down Expand Up @@ -815,7 +852,11 @@ work_resched:
*/
ret_to_user:
disable_irq // disable interrupts
#ifdef CONFIG_THREAD_INFO_IN_TASK
ldr x1, [tsk, #TSK_TI_FLAGS]
#else
ldr x1, [tsk, #TI_FLAGS]
#endif
and x2, x1, #_TIF_WORK_MASK
cbnz x2, work_pending
enable_step_tsk x1, x2
Expand Down Expand Up @@ -848,7 +889,11 @@ el0_svc_naked: // compat entry point
enable_dbg_and_irq
ct_user_exit 1

#ifdef CONFIG_THREAD_INFO_IN_TASK
ldr x16, [tsk, #TSK_TI_FLAGS] // check for syscall hooks
#else
ldr x16, [tsk, #TI_FLAGS] // check for syscall hooks
#endif
tst x16, #_TIF_SYSCALL_WORK
b.ne __sys_trace
cmp scno, sc_nr // check upper syscall limit
Expand Down
16 changes: 16 additions & 0 deletions arch/arm64/kernel/head.S
Original file line number Diff line number Diff line change
Expand Up @@ -456,10 +456,18 @@ __mmap_switched:
bl __pi_memset
dsb ishst // Make zero page visible to PTW

#ifdef CONFIG_THREAD_INFO_IN_TASK
adrp x4, init_thread_union
add sp, x4, #THREAD_SIZE
adr_l x5, init_task
msr sp_el0, x5 // Save thread_info
#else
adr_l sp, initial_sp, x4
mov x4, sp
and x4, x4, #~(THREAD_SIZE - 1)
msr sp_el0, x4 // Save thread_info
#endif

str_l x21, __fdt_pointer, x5 // Save FDT pointer
str_l x24, memstart_addr, x6 // Save PHYS_OFFSET
mov x29, #0
Expand Down Expand Up @@ -642,10 +650,18 @@ ENTRY(secondary_startup)
ENDPROC(secondary_startup)

ENTRY(__secondary_switched)
#ifdef CONFIG_THREAD_INFO_IN_TASK
adr_l x0, secondary_data
ldr x1, [x0, #CPU_BOOT_STACK] // get secondary_data.stack
mov sp, x1
ldr x2, [x0, #CPU_BOOT_TASK]
msr sp_el0, x2
#else
ldr x0, [x21] // get secondary_data.stack
mov sp, x0
and x0, x0, #~(THREAD_SIZE - 1)
msr sp_el0, x0 // save thread_info
#endif
mov x29, #0
b secondary_start_kernel
ENDPROC(__secondary_switched)
Expand Down
22 changes: 22 additions & 0 deletions arch/arm64/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
#include <linux/personality.h>
#include <linux/notifier.h>

#ifdef CONFIG_THREAD_INFO_IN_TASK
#include <linux/percpu.h>
#endif
#include <asm/alternative.h>
#include <asm/compat.h>
#include <asm/cacheflush.h>
Expand Down Expand Up @@ -391,6 +394,22 @@ static void uao_thread_switch(struct task_struct *next)
}
}

#ifdef CONFIG_THREAD_INFO_IN_TASK
/*
* We store our current task in sp_el0, which is clobbered by userspace. Keep a
* shadow copy so that we can restore this upon entry from userspace.
*
* This is *only* for exception entry from EL0, and is not valid until we
* __switch_to() a user task.
*/
DEFINE_PER_CPU(struct task_struct *, __entry_task);

static void entry_task_switch(struct task_struct *next)
{
__this_cpu_write(__entry_task, next);
}
#endif

/*
* Thread switching.
*/
Expand All @@ -403,6 +422,9 @@ struct task_struct *__switch_to(struct task_struct *prev,
tls_thread_switch(next);
hw_breakpoint_thread_switch(next);
contextidr_thread_switch(next);
#ifdef CONFIG_THREAD_INFO_IN_TASK
entry_task_switch(next);
#endif
uao_thread_switch(next);

/*
Expand Down
6 changes: 6 additions & 0 deletions arch/arm64/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ int __cpu_up(unsigned int cpu, struct task_struct *idle)
* We need to tell the secondary core where to find its stack and the
* page tables.
*/
#ifdef CONFIG_THREAD_INFO_IN_TASK
secondary_data.task = idle;
#endif
secondary_data.stack = task_stack_page(idle) + THREAD_START_SP;
__flush_dcache_area(&secondary_data, sizeof(secondary_data));

Expand All @@ -120,6 +123,9 @@ int __cpu_up(unsigned int cpu, struct task_struct *idle)
pr_err("CPU%u: failed to boot: %d\n", cpu, ret);
}

#ifdef CONFIG_THREAD_INFO_IN_TASK
secondary_data.task = NULL;
#endif
secondary_data.stack = NULL;

return ret;
Expand Down
Loading

0 comments on commit f475431

Please sign in to comment.