sparc64: Move offset calculation of several structures to asm-offset.c
PATCH 1/1 sparc64: Move offset calculation of several structures to asm-offset.c
1)Calculate offset of members of thread_info, trap_per_cpu and tsb_config in asm-offset.c
2)Replace DEFINE(*, offsetof(...)) with OFFSET(...)
3)Inify using of asm-offset.h in header files
--- arch/sparc/include/asm/hibernate.h | 8 +++ arch/sparc/include/asm/mmu_64.h | 13 ++--- arch/sparc/include/asm/thread_info_64.h | 29 +++-------- arch/sparc/include/asm/trap_block.h | 27 ++-------- arch/sparc/kernel/asm-offsets.c | 75 +++++++++++++++++++++++---- arch/sparc/kernel/traps_64.c | 84 ------------------------------- arch/sparc/power/hibernate_asm.S | 2 +- 7 files changed, 92 insertions(+), 146 deletions(-)
arch/sparc/include/asm/hibernate.h +8 -0
@@ -7,6 +7,8 @@ #ifndef ___SPARC_HIBERNATE_H #define ___SPARC_HIBERNATE_H +#ifndef __ASSEMBLY__ + struct saved_context { unsigned long fp; unsigned long cwp;
@@ -20,4 +22,10 @@ struct saved_context {unsigned long g6; }; +#else /* (__ASSEMBLY__) */ + +#include <asm/asm-offsets.h> + +#endif /* (__ASSEMBLY__) */ +#endif
arch/sparc/include/asm/mmu_64.h +5 -8
@@ -98,13 +98,10 @@ typedef struct {struct hv_tsb_descr tsb_descr[MM_NUM_TSBS ]; } mm_context_t; -#endif /* !__ASSEMBLY__ */ - -#define TSB_CONFIG_TSB 0x00 -#define TSB_CONFIG_RSS_LIMIT 0x08 -#define TSB_CONFIG_NENTRIES 0x10 -#define TSB_CONFIG_REG_VAL 0x18 -#define TSB_CONFIG_MAP_VADDR 0x20 -#define TSB_CONFIG_MAP_PTE 0x28 +#else /* __ASSEMBLY__ */ + +#include <asm/asm-offsets.h> + +#endif /* __ASSEMBLY__ */ #endif /* __MMU_H */
arch/sparc/include/asm/thread_info_64.h +7 -22
@@ -66,35 +66,20 @@ struct thread_info { unsigned long fpregs[0] __attribute__ ((aligned(64))); }; -#endif /* !(__ASSEMBLY__) */ +#endif /* (!__ASSEMBLY__) */ + +#ifndef _ASM_OFFSETS_C/* This is used from !__ASSEMBLY code too (switch_to) */ + +#include <asm/asm-offsets.h> -/* offsets into the thread_info struct for assembly code access */ -#define TI_TASK 0x00000000 -#define TI_FLAGS 0x00000008#define TI_FAULT_CODE (TI_FLAGS + TI_FLAG_BYTE_FAULT_CODE)#define TI_WSTATE (TI_FLAGS + TI_FLAG_BYTE_WSTATE)#define TI_CWP (TI_FLAGS + TI_FLAG_BYTE_CWP)#define TI_FPDEPTH (TI_FLAGS + TI_FLAG_BYTE_FPDEPTH)#define TI_WSAVED (TI_FLAGS + TI_FLAG_BYTE_WSAVED)#define TI_SYS_NOERROR (TI_FLAGS + TI_FLAG_BYTE_NOERROR) -#define TI_FPSAVED 0x00000010 -#define TI_KSP 0x00000018 -#define TI_FAULT_ADDR 0x00000020 -#define TI_KREGS 0x00000028 -#define TI_EXEC_DOMAIN 0x00000030 -#define TI_PRE_COUNT 0x00000038 -#define TI_NEW_CHILD 0x0000003c -#define TI_CURRENT_DS 0x0000003d -#define TI_CPU 0x0000003e -#define TI_UTRAPS 0x00000040 -#define TI_REG_WINDOW 0x00000048 -#define TI_RWIN_SPTRS 0x000003c8 -#define TI_GSR 0x00000400 -#define TI_XFSR 0x00000438 -#define TI_RESTART_BLOCK 0x00000470 -#define TI_KUNA_REGS 0x000004a0 -#define TI_KUNA_INSN 0x000004a8 -#define TI_FPREGS 0x000004c0 + +#endif /* (_ASM_OFFSETS_C) */ /* We embed this in the uppermost byte of thread_info->flags */ #define FAULT_CODE_WRITE 0x01/* Write access, implies D-TLB */
arch/sparc/include/asm/trap_block.h +5 -22
@@ -81,30 +81,11 @@ extern struct sun4v_2insn_patch_entry __sun4v_2insn_patch, __sun4v_2insn_patch_end; -#endif /* !(__ASSEMBLY__) */ - -#define TRAP_PER_CPU_THREAD 0x00 -#define TRAP_PER_CPU_PGD_PADDR 0x08 -#define TRAP_PER_CPU_CPU_MONDO_PA 0x10 -#define TRAP_PER_CPU_DEV_MONDO_PA 0x18 -#define TRAP_PER_CPU_RESUM_MONDO_PA 0x20 -#define TRAP_PER_CPU_RESUM_KBUF_PA 0x28 -#define TRAP_PER_CPU_NONRESUM_MONDO_PA 0x30 -#define TRAP_PER_CPU_NONRESUM_KBUF_PA 0x38 -#define TRAP_PER_CPU_FAULT_INFO 0x40 -#define TRAP_PER_CPU_CPU_MONDO_BLOCK_PA 0xc0 -#define TRAP_PER_CPU_CPU_LIST_PA 0xc8 -#define TRAP_PER_CPU_TSB_HUGE 0xd0 -#define TRAP_PER_CPU_TSB_HUGE_TEMP 0xd8 -#define TRAP_PER_CPU_IRQ_WORKLIST_PA 0xe0 -#define TRAP_PER_CPU_CPU_MONDO_QMASK 0xe8 -#define TRAP_PER_CPU_DEV_MONDO_QMASK 0xec -#define TRAP_PER_CPU_RESUM_QMASK 0xf0 -#define TRAP_PER_CPU_NONRESUM_QMASK 0xf4 -#define TRAP_PER_CPU_PER_CPU_BASE 0xf8 +#else /* (__ASSEMBLY__) */ #define TRAP_BLOCK_SZ_SHIFT 8 +#include <asm/asm-offsets.h> #include <asm/scratchpad.h> #define __GET_CPUID (REG ) \
@@ -179,7 +160,7 @@ extern struct sun4v_2insn_patch_entry __sun4v_2insn_patch,add REG2 ,REG1 ,REG2 ; \ ldx [REG2 +TRAP_PER_CPU_PER_CPU_BASE ],DEST ; -#else +#else /* !(CONFIG_SMP) */ #define TRAP_LOAD_TRAP_BLOCK (DEST ,TMP ) \ sethi %hi(trap_block), DEST; \
@@ -204,4 +185,6 @@ extern struct sun4v_2insn_patch_entry __sun4v_2insn_patch,#endif /* !(CONFIG_SMP) */ +#endif /* (__ASSEMBLY__) */ +#endif /* _SPARC_TRAP_BLOCK_H */
arch/sparc/kernel/asm-offsets.c +66 -9
102 lines not on this page · raw message
arch/sparc/kernel/traps_64.c +0 -60
66 lines not on this page · raw message
arch/sparc/power/hibernate_asm.S +1 -1
@@ -6,7 +6,7 @@ #include <linux/linkage.h> -#include <asm/asm-offsets.h> +#include <asm/hibernate.h> #include <asm/cpudata.h> #include <asm/page.h>
David Miller
maintainerFrom: Kirill Tkhai <[email protected]>
Date: Sat, 23 Mar 2013 15:44:55 +0400
Quoted 6 lines
1)Calculate offset of members of
thread_info,trap_per_cpuandtsb_configinasm-offset.c
2)ReplaceDEFINE(*, offsetof(...))with OFFSET(...)
3)Inify using ofasm-offset.hin header filesSigned-off-by Kirill Tkhai <[email protected]>
Things are done this way on purpose.
When the offsets change, I don't want the code to just automatically adjust the assembler offset defines.
Instead, I want whoever changes things in this area to carefully analyze the side effects.
For example, if anyone adds members, it now makes the trap block larger than the power of 2 it currently is, and that means the shift used to compute a cpu number to a trap block offset no longer works.
Also, if members are moved, cache alignment of adjoining members means that rearrangement must be done carefully.
This means, overall, nothing should happen automatically when people make changes to the trap block.