Commit 2654ebb7 authored by He Sheng's avatar He Sheng Committed by guzitao
Browse files

sw64: activate CONFIG_THREAD_INFO_IN_TASK

Sunway inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I6ILGG



--------------------------------

This patch activates CONFIG_THREAD_INFO_IN_TASK which moves the
thread_info into task_struct.

This has the following consequences:
  - thread_info is now located at the beginning of task_struct.
  - thread_info doesn't have anymore the `task` field.

This patch:
  - Adds hmcall wrktp and rdktp to save/restore `current` task
    pointer.
  - Changes the current_thread_info() macro to point to `current`.
  - Selects CONFIG_THREAD_INFO_IN_TASK.
  - Modifies raw_smp_processor_id() to get ->cpu from `current`
    without including linux/sched.h to avoid circular inclusion and
    without including asm/asm-offsets.h to avoid symbol names
    duplication between ASM constants and C constants.
  - Modifies task_pt_regs() macro to avoid error which says that
    task_stack_page() is undefined. This error can not be fixed by
    including linux/sched.h which results in circular inclusion.

Signed-off-by: default avatarHe Sheng <hesheng@wxiat.com>
Reviewed-by: default avatarCui Wei <cuiwei@wxiat.com>
Signed-off-by: default avatarGu Zitao <guzitao@wxiat.com>
parent 8b3e7f37
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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
+12 −3
Original line number Diff line number Diff line
@@ -2,9 +2,18 @@
#ifndef _ASM_SW64_CURRENT_H
#define _ASM_SW64_CURRENT_H

#include <linux/thread_info.h>
#ifndef __ASSEMBLY__

struct task_struct;
static __always_inline struct task_struct *get_current(void)
{
	register struct task_struct *tp __asm__("$8");

	return tp;
}

#define get_current()	(current_thread_info()->task)
#define current get_current()

#endif /* __ASSEMBLY__ */

#endif /* _ASM_SW64_CURRENT_H */
+7 −0
Original line number Diff line number Diff line
@@ -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);
+1 −1
Original line number Diff line number Diff line
@@ -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").
+0 −6
Original line number Diff line number Diff line
@@ -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))
Loading