未验证 提交 a413cd0d 编写于 作者: O openeuler-ci-bot 提交者: Gitee

!425 update patches for sw64 architecture

Merge Pull Request from: @guzitao 
 
These patches generally cover the following tasks:

1.optimize kernel cores, remove unused codes, fix compile errors
2.fixes for perf, iommu
3.add support, add CONFIG_THREAD_INFO_IN_TASK support, support SIMD IO access in guest, add DVFS support 
 
Link:https://gitee.com/openeuler/kernel/pulls/425 

Reviewed-by: Zheng Zengkai <zhengzengkai@huawei.com> 
Signed-off-by: Zheng Zengkai <zhengzengkai@huawei.com> 
......@@ -107,6 +107,7 @@ config SW64
select SET_FS
select SPARSEMEM_EXTREME if SPARSEMEM
select SWIOTLB
select THREAD_INFO_IN_TASK
config LOCKDEP_SUPPORT
def_bool y
......
......@@ -11,8 +11,6 @@
struct clk;
extern struct cpufreq_frequency_table sw64_clockmod_table[];
extern char curruent_policy[CPUFREQ_NAME_LEN];
struct clk_ops {
......@@ -44,7 +42,7 @@ struct clk {
int clk_init(void);
void sw64_set_rate(unsigned long rate);
void sw64_set_rate(unsigned int index);
struct clk *sw64_clk_get(struct device *dev, const char *id);
......
......@@ -2,9 +2,18 @@
#ifndef _ASM_SW64_CURRENT_H
#define _ASM_SW64_CURRENT_H
#include <linux/thread_info.h>
#ifndef __ASSEMBLY__
#define get_current() (current_thread_info()->task)
#define current get_current()
struct task_struct;
static __always_inline struct task_struct *get_current(void)
{
register struct task_struct *tp __asm__("$8");
return tp;
}
#define current get_current()
#endif /* __ASSEMBLY__ */
#endif /* _ASM_SW64_CURRENT_H */
......@@ -6,6 +6,10 @@
#include <asm/early_ioremap.h>
#ifdef CONFIG_EFI
extern void efi_init(void);
extern unsigned long entSuspend;
#define SLEEP_ENTRY_GUID EFI_GUID(0x59cb76bb, 0x9c3a, 0x4c8f, 0xbd, 0x5c, 0xc0, 0x0f, 0x20, 0x61, 0x18, 0x4b)
#else
#define efi_init()
#define efi_idmap_init()
......
......@@ -13,6 +13,8 @@
#define HMC_sleepen 0x05
#define HMC_rdksp 0x06
#define HMC_wrasid 0x08
#define HMC_rdktp 0x09
#define HMC_wrktp 0x0A
#define HMC_rdptbr 0x0B
#define HMC_wrptbr 0x0C
#define HMC_wrksp 0x0E
......@@ -150,6 +152,11 @@ __CALL_HMC_VOID(wrfen);
__CALL_HMC_VOID(sleepen);
__CALL_HMC_VOID(mtinten);
__CALL_HMC_VOID(rdktp);
#define restore_ktp() rdktp()
__CALL_HMC_VOID(wrktp);
#define save_ktp() wrktp()
__CALL_HMC_R0(rdps, unsigned long);
__CALL_HMC_R0(rdusp, unsigned long);
......
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _ASM_SW64_IDLE_H
#define _ASM_SW64_IDLE_H
extern void arch_cpu_idle(void);
#endif /* _ASM_SW64_IDLE_H */
......@@ -2,8 +2,10 @@
#ifndef _ASM_SW64_PLATFORM_H
#define _ASM_SW64_PLATFORM_H
#include <linux/types.h>
#include <asm/chip3_io.h>
struct sw64_platform_ops {
void (*kill_arch)(int mode);
void __iomem *(*ioportmap)(unsigned long);
void (*register_platform_devices)(void);
void (*ops_fixup)(void);
......@@ -13,5 +15,15 @@ struct sw64_platform_ops {
extern struct sw64_platform_ops *sw64_platform;
extern struct sw64_platform_ops xuelang_ops;
extern struct boot_params *sunway_boot_params;
extern void sw64_halt(void);
extern void sw64_poweroff(void);
extern void sw64_restart(void);
extern void (*pm_restart)(void);
extern void (*pm_halt)(void);
extern int i2c_set_adapter(void);
extern void cpld_write(uint8_t slave_addr, uint8_t reg, uint8_t data);
extern void fix_jm585_reset(void);
#endif /* _ASM_SW64_PLATFORM_H */
......@@ -12,7 +12,7 @@
#include <asm/ptrace.h>
#define task_pt_regs(task) \
((struct pt_regs *) (task_stack_page(task) + 2 * PAGE_SIZE) - 1)
((struct pt_regs *) (task->stack + THREAD_SIZE) - 1)
/*
* Returns current instruction pointer ("program counter").
......
......@@ -4,7 +4,6 @@
#include <uapi/asm/ptrace.h>
#include <asm/hmcall.h>
#include <asm/thread_info.h>
#include <asm/page.h>
/*
......@@ -58,11 +57,6 @@ struct pt_regs {
#define kernel_stack_pointer(regs) ((unsigned long)((regs) + 1))
#define instruction_pointer_set(regs, val) ((regs)->pc = val)
#define current_pt_regs() \
((struct pt_regs *) ((char *)current_thread_info() + 2 * PAGE_SIZE) - 1)
#define signal_pt_regs current_pt_regs
#define force_successful_syscall_return() (current_pt_regs()->r0 = 0)
#define MAX_REG_OFFSET (offsetof(struct pt_regs, r18))
......
......@@ -2,14 +2,16 @@
#ifndef _ASM_SW64_SMP_H
#define _ASM_SW64_SMP_H
#include <linux/threads.h>
#include <linux/cpumask.h>
#include <linux/bitops.h>
#include <asm/hmcall.h>
#include <asm/hcall.h>
#include <asm/core.h>
#include <asm/current.h>
#include <asm/hcall.h>
#include <asm/hmcall.h>
#include <asm/hw_init.h>
#include <linux/bitops.h>
#include <linux/cpumask.h>
#include <linux/threads.h>
/* HACK: Cabrio WHAMI return value is bogus if more than 8 bits used.. :-( */
extern cpumask_t core_start;
......@@ -55,7 +57,13 @@ struct smp_rcb_struct {
#define INIT_SMP_RCB ((struct smp_rcb_struct *) __va(0x820000UL))
#define hard_smp_processor_id() __hard_smp_processor_id()
#define raw_smp_processor_id() (current_thread_info()->cpu)
#ifdef GENERATING_ASM_OFFSETS
#define raw_smp_processor_id() (0)
#else
#include <asm/asm-offsets.h>
#define raw_smp_processor_id() (*((unsigned int *)((void *)current + TASK_CPU)))
#endif
/* The map from sequential logical cpu number to hard cid. */
extern int __cpu_to_rcid[NR_CPUS];
......
......@@ -5,7 +5,6 @@
#ifdef __KERNEL__
#ifndef __ASSEMBLY__
#include <asm/processor.h>
#include <asm/types.h>
#include <asm/sysinfo.h>
......@@ -25,12 +24,11 @@ struct pcb_struct {
struct thread_info {
struct pcb_struct pcb; /* hmcode state */
struct task_struct *task; /* main task structure */
unsigned int flags; /* low level flags */
unsigned int ieee_state; /* see fpu.h */
mm_segment_t addr_limit; /* thread address space */
unsigned int cpu; /* current CPU */
unsigned int cpu; /* current CPU */
int preempt_count; /* 0 => preemptible, <0 => BUG */
unsigned int status; /* thread-synchronous flags */
......@@ -58,14 +56,10 @@ static __always_inline u64 rtid(void)
*/
#define INIT_THREAD_INFO(tsk) \
{ \
.task = &tsk, \
.addr_limit = KERNEL_DS, \
.preempt_count = INIT_PREEMPT_COUNT, \
}
/* How to get the thread information struct from C. */
register struct thread_info *__current_thread_info __asm__("$8");
#define current_thread_info() __current_thread_info
#endif /* __ASSEMBLY__ */
......
......@@ -20,6 +20,9 @@ enum perf_event_sw64_regs {
PERF_REG_SW64_R13,
PERF_REG_SW64_R14,
PERF_REG_SW64_R15,
PERF_REG_SW64_R16,
PERF_REG_SW64_R17,
PERF_REG_SW64_R18,
PERF_REG_SW64_R19,
PERF_REG_SW64_R20,
PERF_REG_SW64_R21,
......@@ -30,16 +33,9 @@ enum perf_event_sw64_regs {
PERF_REG_SW64_R26,
PERF_REG_SW64_R27,
PERF_REG_SW64_R28,
PERF_REG_SW64_HAE,
PERF_REG_SW64_TRAP_A0,
PERF_REG_SW64_TRAP_A1,
PERF_REG_SW64_TRAP_A2,
PERF_REG_SW64_PS,
PERF_REG_SW64_PC,
PERF_REG_SW64_GP,
PERF_REG_SW64_R16,
PERF_REG_SW64_R17,
PERF_REG_SW64_R18,
PERF_REG_SW64_SP,
PERF_REG_SW64_PC,
PERF_REG_SW64_MAX,
};
#endif /* _UAPI_ASM_SW64_PERF_REGS_H */
......@@ -17,7 +17,7 @@ obj-y := entry.o fpu.o traps.o process.o sys_sw64.o irq.o \
irq_sw64.o signal.o setup.o ptrace.o time.o \
systbls.o dup_print.o tc.o timer.o \
insn.o early_init.o topology.o cacheinfo.o \
vdso.o vdso/ hmcall.o stacktrace.o
vdso.o vdso/ hmcall.o stacktrace.o idle.o reset.o
obj-$(CONFIG_ACPI) += acpi.o
obj-$(CONFIG_SMP) += smp.o
......
......@@ -5,6 +5,7 @@
* and format the required data.
*/
#define GENERATING_ASM_OFFSETS /* asm/smp.h */
#include <linux/stddef.h>
#include <linux/sched.h>
#include <linux/kbuild.h>
......@@ -15,11 +16,11 @@
#include "traps.c"
void foo(void)
{
DEFINE(TI_TASK, offsetof(struct thread_info, task));
DEFINE(ASM_THREAD_SIZE, THREAD_SIZE);
DEFINE(TI_FLAGS, offsetof(struct thread_info, flags));
DEFINE(TI_CPU, offsetof(struct thread_info, cpu));
BLANK();
DEFINE(TASK_BLOCKED, offsetof(struct task_struct, blocked));
......@@ -27,6 +28,10 @@ void foo(void)
DEFINE(TASK_REAL_PARENT, offsetof(struct task_struct, real_parent));
DEFINE(TASK_GROUP_LEADER, offsetof(struct task_struct, group_leader));
DEFINE(TASK_TGID, offsetof(struct task_struct, tgid));
DEFINE(TASK_STACK, offsetof(struct task_struct, stack));
#ifdef CONFIG_SMP
DEFINE(TASK_CPU, offsetof(struct task_struct, thread_info.cpu));
#endif
BLANK();
OFFSET(PSTATE_REGS, processor_state, regs);
......
// SPDX-License-Identifier: GPL-2.0
/*
* linux/arch/sw/kernel/setup.c
*
* Copyright (C) 1995 Linus Torvalds
*/
#include <linux/clk.h>
#include <linux/cpufreq.h>
......@@ -11,6 +6,7 @@
#include <linux/export.h>
#include <linux/delay.h>
#include <asm/sw64_init.h>
#include <asm/sw64io.h>
#include <asm/hw_init.h>
#include <asm/debug.h>
......@@ -29,73 +25,7 @@
#define CORE_PLL0_CFG_SHIFT 4
#define CORE_PLL2_CFG_SHIFT 18
char curruent_policy[CPUFREQ_NAME_LEN];
/* Minimum CLK support */
enum {
DC_0, DC_1, DC_2, DC_3, DC_4, DC_5, DC_6, DC_7, DC_8,
DC_9, DC_10, DC_11, DC_12, DC_13, DC_14, DC_15, DC_16, DC_RESV
};
static int cpu_freq[14] = {
0, 1200, 1800, 1900,
1950, 2000, 2050, 2100,
2150, 2200, 2250, 2300,
2350, 2400 };
struct cpufreq_frequency_table sw64_clockmod_table[] = {
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{0, DC_1, 0},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{0, DC_2, 0},
{-1, DC_RESV, CPUFREQ_ENTRY_INVALID},
{0, DC_3, 0},
{0, DC_4, 0},
{0, DC_5, 0},
{0, DC_6, 0},
{0, DC_7, 0},
{0, DC_8, 0},
{0, DC_9, 0},
{0, DC_10, 0},
{0, DC_11, 0},
{0, DC_12, 0},
{0, DC_13, 0},
{-1, DC_RESV, CPUFREQ_TABLE_END},
};
EXPORT_SYMBOL_GPL(sw64_clockmod_table);
char curruent_policy[CPUFREQ_NAME_LEN];
static struct clk cpu_clk = {
.name = "cpu_clk",
......@@ -113,13 +43,13 @@ unsigned int __sw64_cpufreq_get(struct cpufreq_policy *policy)
{
int i;
u64 val;
struct cpufreq_frequency_table *ft = policy->freq_table;
val = sw64_io_read(0, CLK_CTL);
val = val >> CORE_PLL2_CFG_SHIFT;
val = sw64_io_read(0, CLK_CTL) >> CORE_PLL2_CFG_SHIFT;
for (i = 0; i < sizeof(cpu_freq)/sizeof(int); i++) {
if (cpu_freq[val] == cpu_freq[i])
return cpu_freq[i];
for (i = 0; ft[i].frequency != CPUFREQ_TABLE_END; i++) {
if (val == ft[i].driver_data)
return ft[i].frequency;
}
return 0;
}
......@@ -131,61 +61,41 @@ void sw64_store_policy(struct cpufreq_policy *policy)
}
EXPORT_SYMBOL_GPL(sw64_store_policy);
void sw64_set_rate(unsigned long rate)
void sw64_set_rate(unsigned int index)
{
unsigned int i, val;
int index = -1;
int cpu_num;
rate /= 1000000;
cpu_num = sw64_chip->get_cpu_num();
for (i = 0; i < sizeof(cpu_freq)/sizeof(int); i++) {
if (rate == cpu_freq[i]) {
index = i;
update_cpu_freq(cpu_freq[i]);
break;
}
}
if (index < 0)
return -EINVAL;
for (i = 0; i < cpu_num; i++) {
sw64_io_write(i, CLK_CTL, CORE_CLK2_R | CORE_CLK2_V | CLK_PRT);
val = sw64_io_read(i, CLK_CTL);
sw64_io_write(0, CLK_CTL, CORE_CLK2_R | CORE_CLK2_V | CLK_PRT);
sw64_io_write(1, CLK_CTL, CORE_CLK2_R | CORE_CLK2_V | CLK_PRT);
val = sw64_io_read(0, CLK_CTL);
sw64_io_write(i, CLK_CTL, val | index << CORE_PLL2_CFG_SHIFT);
sw64_io_write(0, CLK_CTL, val | index << CORE_PLL2_CFG_SHIFT);
sw64_io_write(1, CLK_CTL, val | index << CORE_PLL2_CFG_SHIFT);
udelay(1);
udelay(1);
sw64_io_write(i, CLK_CTL, CORE_CLK2_V | CLK_PRT
| index << CORE_PLL2_CFG_SHIFT);
val = sw64_io_read(i, CLK_CTL);
sw64_io_write(0, CLK_CTL, CORE_CLK2_V | CLK_PRT
| index << CORE_PLL2_CFG_SHIFT);
sw64_io_write(1, CLK_CTL, CORE_CLK2_V | CLK_PRT
| index << CORE_PLL2_CFG_SHIFT);
val = sw64_io_read(0, CLK_CTL);
/* LV1 select PLL1/PLL2 */
sw64_io_write(i, CLU_LV1_SEL, CLK_LV1_SEL_MUXA | CLK_LV1_SEL_PRT);
/* LV1 select PLL1/PLL2 */
sw64_io_write(0, CLU_LV1_SEL, CLK_LV1_SEL_MUXA | CLK_LV1_SEL_PRT);
sw64_io_write(1, CLU_LV1_SEL, CLK_LV1_SEL_MUXA | CLK_LV1_SEL_PRT);
/* Set CLK_CTL PLL0 */
sw64_io_write(i, CLK_CTL, val | CORE_CLK0_R | CORE_CLK0_V);
/* Set CLK_CTL PLL0 */
sw64_io_write(0, CLK_CTL, val | CORE_CLK0_R | CORE_CLK0_V);
sw64_io_write(1, CLK_CTL, val | CORE_CLK0_R | CORE_CLK0_V);
sw64_io_write(i, CLK_CTL, val | CORE_CLK0_R | CORE_CLK0_V
| index << CORE_PLL0_CFG_SHIFT);
sw64_io_write(0, CLK_CTL, val | CORE_CLK0_R | CORE_CLK0_V
| index << CORE_PLL0_CFG_SHIFT);
sw64_io_write(1, CLK_CTL, val | CORE_CLK0_R | CORE_CLK0_V
| index << CORE_PLL0_CFG_SHIFT);
udelay(1);
udelay(1);
sw64_io_write(i, CLK_CTL, val | CORE_CLK0_V
| index << CORE_PLL0_CFG_SHIFT);
sw64_io_write(0, CLK_CTL, val | CORE_CLK0_V
| index << CORE_PLL0_CFG_SHIFT);
sw64_io_write(1, CLK_CTL, val | CORE_CLK0_V
| index << CORE_PLL0_CFG_SHIFT);
/* LV1 select PLL0/PLL1 */
sw64_io_write(0, CLU_LV1_SEL, CLK_LV1_SEL_MUXB | CLK_LV1_SEL_PRT);
sw64_io_write(1, CLU_LV1_SEL, CLK_LV1_SEL_MUXB | CLK_LV1_SEL_PRT);
/* LV1 select PLL0/PLL1 */
sw64_io_write(i, CLU_LV1_SEL, CLK_LV1_SEL_MUXB | CLK_LV1_SEL_PRT);
}
}
EXPORT_SYMBOL_GPL(sw64_set_rate);
......@@ -3,7 +3,7 @@
#include <linux/smp.h>
#include <linux/spinlock.h>
#include <asm/chip3_io.h>
#include <asm/platform.h>
#include <asm/io.h>
#ifdef CONFIG_SW64_RRK
......
......@@ -24,6 +24,7 @@ static void __init sw64_setup_platform_ops(void)
asmlinkage __visible void __init sw64_start_kernel(void)
{
fixup_hmcall();
save_ktp();
sw64_setup_chip_ops();
sw64_setup_platform_ops();
sw64_platform->ops_fixup();
......
......@@ -20,7 +20,7 @@
* regs 29-30 saved and set up by HMcode
*/
.macro SAVE_COMMON_REGS
.macro SAVE_ALL
ldi $sp, -PT_REGS_PS($sp)
stl $0, PT_REGS_R0($sp)
stl $1, PT_REGS_R1($sp)
......@@ -32,6 +32,13 @@
stl $6, PT_REGS_R6($sp)
stl $7, PT_REGS_R7($sp)
stl $8, PT_REGS_R8($sp)
stl $9, PT_REGS_R9($sp)
stl $10, PT_REGS_R10($sp)
stl $11, PT_REGS_R11($sp)
stl $12, PT_REGS_R12($sp)
stl $13, PT_REGS_R13($sp)
stl $14, PT_REGS_R14($sp)
stl $15, PT_REGS_R15($sp)
stl $19, PT_REGS_R19($sp)
stl $20, PT_REGS_R20($sp)
stl $21, PT_REGS_R21($sp)
......@@ -41,9 +48,10 @@
stl $25, PT_REGS_R25($sp)
stl $26, PT_REGS_R26($sp)
stl $27, PT_REGS_R27($sp)
sys_call HMC_rdktp
.endm
.macro RESTORE_COMMON_REGS
.macro RESTORE_ALL
ldl $0, PT_REGS_R0($sp)
ldl $1, PT_REGS_R1($sp)
ldl $2, PT_REGS_R2($sp)
......@@ -53,6 +61,13 @@
ldl $6, PT_REGS_R6($sp)
ldl $7, PT_REGS_R7($sp)
ldl $8, PT_REGS_R8($sp)
ldl $9, PT_REGS_R9($sp)
ldl $10, PT_REGS_R10($sp)
ldl $11, PT_REGS_R11($sp)
ldl $12, PT_REGS_R12($sp)
ldl $13, PT_REGS_R13($sp)
ldl $14, PT_REGS_R14($sp)
ldl $15, PT_REGS_R15($sp)
ldl $19, PT_REGS_R19($sp)
ldl $20, PT_REGS_R20($sp)
ldl $21, PT_REGS_R21($sp)
......@@ -66,36 +81,6 @@
ldi $sp, PT_REGS_PS($sp)
.endm
.macro SAVE_CALLEE_REGS
stl $9, PT_REGS_R9($sp)
stl $10, PT_REGS_R10($sp)
stl $11, PT_REGS_R11($sp)
stl $12, PT_REGS_R12($sp)
stl $13, PT_REGS_R13($sp)
stl $14, PT_REGS_R14($sp)
stl $15, PT_REGS_R15($sp)
.endm
.macro RESTORE_CALLEE_REGS
ldl $9, PT_REGS_R9($sp)
ldl $10, PT_REGS_R10($sp)
ldl $11, PT_REGS_R11($sp)
ldl $12, PT_REGS_R12($sp)
ldl $13, PT_REGS_R13($sp)
ldl $14, PT_REGS_R14($sp)
ldl $15, PT_REGS_R15($sp)
.endm
.macro SAVE_ALL
SAVE_COMMON_REGS
SAVE_CALLEE_REGS
.endm
.macro RESTORE_ALL
RESTORE_CALLEE_REGS
RESTORE_COMMON_REGS
.endm
/*
* Non-syscall kernel entry points.
*/
......@@ -105,9 +90,7 @@
.ent entInt
entInt:
SAVE_ALL
ldi $8, 0x3fff
ldi $26, ret_from_sys_call
bic $sp, $8, $8
mov $sp, $19
call $31, do_entInt
.end entInt
......@@ -117,9 +100,7 @@ entInt:
.ent entArith
entArith:
SAVE_ALL
ldi $8, 0x3fff
ldi $26, ret_from_sys_call
bic $sp, $8, $8
mov $sp, $18
call $31, do_entArith
.end entArith
......@@ -129,9 +110,7 @@ entArith:
.ent entMM
entMM:
SAVE_ALL
ldi $8, 0x3fff
ldi $26, ret_from_sys_call
bic $sp, $8, $8
mov $sp, $19
call $31, do_page_fault
.end entMM
......@@ -141,10 +120,8 @@ entMM:
.ent entIF
entIF:
SAVE_ALL
ldi $8, 0x3fff
ldi $26, ret_from_sys_call
bic $sp, $8, $8
mov $sp, $17
mov $sp, $18
call $31, do_entIF
.end entIF
......@@ -159,8 +136,6 @@ entIF:
.ent entUna
entUna:
SAVE_ALL
ldi $8, 0x3fff
bic $sp, $8, $8
mov $sp, $19
ldl $0, PT_REGS_PS($sp)
and $0, 8, $0 /* user mode ? */
......@@ -192,8 +167,6 @@ entUna:
entSys:
SAVE_ALL
ldi $8, 0x3fff
bic $sp, $8, $8
ldi $4, NR_SYSCALLS($31)
stl $16, PT_REGS_R16($sp)
ldi $5, sys_call_table
......@@ -411,8 +384,8 @@ __switch_to:
ldl $13, TASK_THREAD_S4($17)
ldl $14, TASK_THREAD_S5($17)
ldl $15, TASK_THREAD_S6($17)
ldi $8, 0x3fff
bic $sp, $8, $8
mov $17, $8
sys_call HMC_wrktp
mov $16, $0
ret
.end __switch_to
......
......@@ -100,10 +100,12 @@ void arch_ftrace_update_code(int command)
int __init ftrace_dyn_arch_init(void)
{
init_thread_info.dyn_ftrace_addr = FTRACE_ADDR;
struct thread_info *ti = task_thread_info(&init_task);
ti->dyn_ftrace_addr = FTRACE_ADDR;
#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
init_thread_info.dyn_ftrace_regs_addr = FTRACE_REGS_ADDR;
ti->dyn_ftrace_regs_addr = FTRACE_REGS_ADDR;
#endif
return 0;
}
......
......@@ -22,9 +22,11 @@ __start:
br $27, 1f
1: ldgp $29, 0($27)
/* We need to get current_task_info loaded up... */
ldi $8, init_thread_union
ldi $8, init_task
ldl $30, TASK_STACK($8)
/* ... and find our stack ... */
ldi $30, ASM_THREAD_SIZE($8)
ldi $30, ASM_THREAD_SIZE($30)
/* ... and then we can clear bss data. */
ldi $16, __bss_start
ldi $18, __bss_stop
......@@ -38,8 +40,10 @@ __start:
call $26, relocate_kernel
ldl $29, 0($30)
addl $29, $0, $29
addl $8, $0, $8
ldi $30, 8($30)
/* Repoint the sp into the new kernel image */
ldi $30, ASM_THREAD_SIZE($8)
addl $30, $0, $30
#endif
/* ... and then we can start the kernel. */
call $26, sw64_start_kernel
......@@ -68,11 +72,13 @@ __smp_callin:
s4addl $0, $1, $1
ldw $0, 0($1) # Get logical cpu number
ldi $2, tidle_ksp
ldi $2, idle_task_pointer
s8addl $0, $2, $2
ldl $30, 0($2) # Get ksp of idle thread
ldl $8, 0($2) # Get ksp of idle thread
sys_call HMC_wrktp
ldi $8, -ASM_THREAD_SIZE($30) # Find "current"
ldl $30, TASK_STACK($8)
ldi $30, ASM_THREAD_SIZE($30)
call $26, smp_callin
sys_call HMC_halt
......
......@@ -76,6 +76,22 @@ static inline void fixup_wrasid(void)
entry[9] = 0x1ef00000; /* pri_ret/b p23 */
}
static inline void fixup_rdktp(void)
{
unsigned int *entry = __va(HMCALL_ENTRY(rdktp));
entry[0] = 0x95161000; /* pri_ldl/p $8, VC__KTP(vcpucb) */
entry[1] = 0x1ee00000; /* pri_ret $23 */
}
static inline void fixup_wrktp(void)
{
unsigned int *entry = __va(HMCALL_ENTRY(wrktp));
entry[0] = 0xb5161000; /* pri_stl/p $8, VC__KTP(vcpucb) */
entry[1] = 0x1ee00000; /* pri_ret $23 */
}
void __init fixup_hmcall(void)
{
#if defined(CONFIG_SUBARCH_C3B)
......@@ -83,6 +99,8 @@ void __init fixup_hmcall(void)
fixup_wrtp();
fixup_tbiasid();
fixup_wrasid();
fixup_rdktp();
fixup_wrktp();
#endif
}
......
// SPDX-License-Identifier: GPL-2.0
/*
* sw64 idle loop support.
*
*/
#include <linux/cpu.h>
#include <linux/irqflags.h>
#include <asm/cpu.h>
#include <asm/idle.h>
#ifdef CONFIG_HOTPLUG_CPU
void arch_cpu_idle_dead(void)
{
play_dead();
}
#endif
void cpu_idle(void)
{
int i;
local_irq_enable();
cpu_relax();
if (is_in_guest())
hcall(HCALL_HALT, 0, 0, 0);
else {
for (i = 0; i < 16; i++)
asm("nop");
asm("halt");
}
}
void arch_cpu_idle(void)
{
cpu_idle();
}
此差异已折叠。
......@@ -8,7 +8,24 @@ u64 perf_reg_value(struct pt_regs *regs, int idx)
if (WARN_ON_ONCE((u32)idx >= PERF_REG_SW64_MAX))
return 0;
return ((unsigned long *)regs)[idx];
switch (idx) {
case PERF_REG_SW64_R16:
return regs->r16;
case PERF_REG_SW64_R17:
return regs->r17;
case PERF_REG_SW64_R18:
return regs->r18;
case PERF_REG_SW64_R19 ... PERF_REG_SW64_R28:
return ((unsigned long *)regs)[idx - 3];
case PERF_REG_SW64_GP:
return regs->gp;
case PERF_REG_SW64_SP:
return (user_mode(regs) ? rdusp() : (u64)(regs + 1));
case PERF_REG_SW64_PC:
return regs->pc;
default:
return ((unsigned long *)regs)[idx];
}
}
#define REG_RESERVED (~((1ULL << PERF_REG_SW64_MAX) - 1))
......
此差异已折叠。
......@@ -239,9 +239,6 @@ unsigned int __init relocate_kernel(void)
if (plat_post_relocation(offset))
goto out;
/* The current thread is now within the relocated image */
__current_thread_info = RELOCATED(&init_thread_union);
/* Return the new kernel's offset */
return offset;
}
......
此差异已折叠。
......@@ -34,7 +34,7 @@ EXPORT_SYMBOL(__cpu_to_rcid);
int __rcid_to_cpu[NR_CPUS]; /* Map physical to logical */
EXPORT_SYMBOL(__rcid_to_cpu);
void *tidle_ksp[NR_CPUS];
void *idle_task_pointer[NR_CPUS];
/* State of each CPU */
DEFINE_PER_CPU(int, cpu_state) = { 0 };
......@@ -130,7 +130,7 @@ static int secondary_cpu_start(int cpuid, struct task_struct *idle)
/*
* Precalculate the target ksp.
*/
tidle_ksp[cpuid] = idle->stack + THREAD_SIZE;
idle_task_pointer[cpuid] = idle;
DBGS("Starting secondary cpu %d: state 0x%lx\n", cpuid, idle->state);
......@@ -237,7 +237,6 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus)
memset(ipi_data, 0, sizeof(ipi_data));
init_cpu_topology();
current_thread_info()->cpu = 0;
store_cpu_topology(smp_processor_id());
numa_add_cpu(smp_processor_id());
......@@ -366,10 +365,7 @@ void handle_ipi(struct pt_regs *regs)
case IPI_CPU_STOP:
local_irq_disable();
pr_crit("other core panic, now halt...\n");
while (1)
asm("nop");
halt();
asm("halt");
default:
pr_crit("Unknown IPI on CPU %d: %lu\n", this_cpu, which);
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -25,6 +25,8 @@
#include <asm/efi.h>
unsigned long entSuspend;
static int __init is_memory(efi_memory_desc_t *md)
{
if (md->attribute & (EFI_MEMORY_WB|EFI_MEMORY_WT|EFI_MEMORY_WC))
......@@ -32,7 +34,8 @@ static int __init is_memory(efi_memory_desc_t *md)
return 0;
}
static efi_config_table_type_t arch_tables[] __initdata = {
{SMBIOS3_TABLE_GUID, NULL, NULL}
{SMBIOS3_TABLE_GUID, NULL, NULL},
{SLEEP_ENTRY_GUID, &entSuspend, "SLEEP ENTRY"}
};
static int __init uefi_init(u64 efi_system_table)
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
# SPDX-License-Identifier: GPL-2.0
obj-$(CONFIG_PLATFORM_XUELANG) += legacy_xuelang.o
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册