Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/linux-milkymist
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 919c3d59ec3b
Choose a base ref
...
head repository: m-labs/linux-milkymist
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: e7f8b2eb45d1
Choose a head ref
  • 15 commits
  • 11 files changed
  • 1 contributor

Commits on Feb 26, 2013

  1. lm32: Get rid of pm_idle

    This is currently unused and will be gone in upstream soon.
    
    Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
    larsclausen committed Feb 26, 2013
    Copy the full SHA
    64d30a6 View commit details
  2. lm32: Use _save_altstack helper

    Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
    larsclausen committed Feb 26, 2013
    Copy the full SHA
    b533446 View commit details
  3. lm32: switch to generic sys_sigaltstack

    Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
    larsclausen committed Feb 26, 2013
    Copy the full SHA
    a94271a View commit details
  4. lm32: sys_rt_sigreturn: Use current_pt_regs()

    Use current_pt_regs() to get a pointer to the registers of the current process.
    None of the syscalls expect a pointer to registers of the current process in r7
    anymore, so we can also get rid of that.
    
    Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
    larsclausen committed Feb 26, 2013
    Copy the full SHA
    d2374d9 View commit details
  5. lm32: Properly update stack pointer copy_thread()

    If we get a new stack pointer address for the new thread in copy_thread() we
    need to update the register set to the new stack address.
    
    Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
    larsclausen committed Feb 26, 2013
    Copy the full SHA
    fa7fba2 View commit details
  6. lm32: Don't clobber userspace stack during syscall

    We shouldn't use the userspace stack to backup the registers which we using
    during the early syscall code, this only works by chance.
    
    Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
    larsclausen committed Feb 26, 2013
    Copy the full SHA
    0a92396 View commit details
  7. lm32: Switch to kernel stack during interrupts

    Don't run the interrupt handlers on userspace stack, this is quite wrong and
    quite dangerous and may cause random process corruption. Instead switch to the
    kernel space stack as soon as we enter kernel space.
    
    Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
    larsclausen committed Feb 26, 2013
    Copy the full SHA
    fbc42a6 View commit details
  8. lm32: Simplify current_thread_info()

    Now that we are always on kernel stack in kernel mode we can calculate the
    current thread info address based on the stack pointer. The thread info is
    always stored at the lowest address of the kernel stack of a process.
    
    Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
    larsclausen committed Feb 26, 2013
    Copy the full SHA
    b1ea119 View commit details
  9. lm32: We are always on kernel stack in resume

    We are always on kernel stack now and always resume to kernel stack during a
    context switch. So there is no need to check on which stack we are.
    
    Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
    larsclausen committed Feb 26, 2013
    Copy the full SHA
    664ec9d View commit details
  10. lm32: Inline _{save,restore}_irq_frame

    There is really no point in having these as separate functions since there is
    only one invocation of them. And making them a macro aslo means we can reuse
    them in _{save,restore}_syscall_frame to get rid of some duplicated code.
    
    Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
    larsclausen committed Feb 26, 2013
    Copy the full SHA
    d5c38bd View commit details
  11. lm32: Remove usp field from thread_struct struct

    The usp is always stored in the sp field of the pt_regs of the process. No need
    to track it separately.
    
    Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
    larsclausen committed Feb 26, 2013
    Copy the full SHA
    c6e4d95 View commit details
  12. lm32: Simplify mode switching

    Whenever we enter kernel mode we'll switch to the kernel stack. We will always
    start at the bottom of the kernel stack, once we leave kernel mode we'll be at
    the bottom of the kernel stack again. Since we can calculate the kernel stack
    address based on the current thread_info address (current thread_info address is
    always at the lowest address of the kernel stack) we do not have to track the
    kernel stack address of a process separately. Also the which_stack field is
    redundant since we are always on kernel stack in kernel mode and always on user
    stack in user mode, so we can remove it altogether as well.
    
    Finally as a minor optimization put all the global variables used during mode
    switch in a common struct. This is for one quite cache friendly and we only have
    to load the address of the struct and can use relative addressing to access the
    members instead of loading the address of each global variable individually.
    
    Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
    larsclausen committed Feb 26, 2013
    Copy the full SHA
    50c3718 View commit details
  13. lm32: Save the process state in the thread_info struct

    Put the process state which is saved during process switching in the thread_info
    stack instead of on top of the stack. This has the advantage that we know where
    the registers are saved and don't need to track this, so we can finally get rid
    of the ksp field of the thread_struct struct. Also only save those registers
    which are callee saved. All other register will already be saved on previous
    stack frames. As a result copy_thread() also looks much nicer.
    
    Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
    larsclausen committed Feb 26, 2013
    Copy the full SHA
    52d0953 View commit details
  14. lm32: Cleanup start_thread()

    There is no need to call set_fs(USER_DS) in since start_thread() since this is
    already done in generic places. Also don't memset regs to 0 since some of the
    callers pass in preinitialized registers.
    
    Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
    larsclausen committed Feb 26, 2013
    Copy the full SHA
    9a504d6 View commit details
  15. lm32: Cleanup processor.h/process.c a bit

    Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
    larsclausen committed Feb 26, 2013
    Copy the full SHA
    e7f8b2e View commit details
1 change: 1 addition & 0 deletions arch/lm32/Kconfig
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@ config LM32
select GENERIC_CPU_DEVICES
select GENERIC_SYSCALL_TABLE
select GENERIC_ATOMIC64
select GENERIC_SIGALTSTACK
select ARCH_REQUIRE_GPIOLIB
select OF
select OF_EARLY_FLATTREE
40 changes: 9 additions & 31 deletions arch/lm32/include/asm/processor.h
Original file line number Diff line number Diff line change
@@ -54,29 +54,14 @@
*/
#define TASK_UNMAPPED_BASE 0

/*
* if you change this structure, you must change the code and offsets
* in asm-offsets.c
*/

struct thread_struct {
unsigned long ksp; /* kernel stack pointer */
unsigned long usp; /* user stack pointer */
unsigned long which_stack; /* 0 if we are on kernel stack, 1 if we are on user stack */
};
struct thread_struct {};
#define INIT_THREAD {}

#define KSTK_TOS(tsk) ((unsigned long)task_stack_page(tsk) + THREAD_SIZE - 32)
#define task_pt_regs(tsk) ((struct pt_regs *)KSTK_TOS(tsk) - 1)
#define KSTK_EIP(tsk) 0
#define KSTK_ESP(tsk) 0

#define INIT_THREAD { \
sizeof(init_stack) + (unsigned long) init_stack, 0, \
0, \
0 \
}

#define reformat(_regs) do { } while (0)

/*
* Do necessary setup to start up a newly executed thread.
@@ -86,26 +71,19 @@ extern void start_thread(struct pt_regs * regs, unsigned long pc, unsigned long
/* Forward declaration, a strange C thing */
struct task_struct;

/* Free all resources held by a thread. */
static inline void release_thread(struct task_struct *dead_task)
static inline void release_thread(struct task_struct *dead_task) { }
static inline void exit_thread(void) { }

static inline unsigned long thread_saved_pc(struct task_struct *tsk)
{
return 0;
}

/* Prepare to copy thread state - unlazy all lazy status */
#define prepare_to_copy(tsk) do { } while (0)

extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);

/*
* Free current thread data structures etc..
*/
static inline void exit_thread(void)
static inline unsigned long get_wchan(struct task_struct *p)
{
return 0;
}

unsigned long thread_saved_pc(struct task_struct *tsk);
unsigned long get_wchan(struct task_struct *p);

#define cpu_relax() barrier()

#endif
15 changes: 7 additions & 8 deletions arch/lm32/include/asm/switch_to.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
#ifndef __LM32_SYSTEM_H
#define __LM32_SYSTEM_H

#include <linux/thread_info.h>
#include <linux/linkage.h>
#include <linux/thread_info.h>

struct task_struct;
extern asmlinkage struct task_struct* resume(struct task_struct* last, struct task_struct* next);
extern asmlinkage struct task_struct* _switch_to(struct task_struct *,
struct thread_info *, struct thread_info *);

#define switch_to(prev, next, last) \
do { \
lm32_current_thread = task_thread_info(next); \
((last) = resume((prev), (next))); \
} while (0)
#define switch_to(prev,next,last) \
do { \
last = _switch_to(prev, task_thread_info(prev), task_thread_info(next)); \
} while (0)

#endif
40 changes: 37 additions & 3 deletions arch/lm32/include/asm/thread_info.h
Original file line number Diff line number Diff line change
@@ -25,6 +25,30 @@ typedef struct {
unsigned long seg;
} mm_segment_t;

struct cpu_context_save {
unsigned long r11;
unsigned long r12;
unsigned long r13;
unsigned long r14;
unsigned long r15;
unsigned long r16;
unsigned long r17;
unsigned long r18;
unsigned long r19;
unsigned long r20;
unsigned long r21;
unsigned long r22;
unsigned long r23;
unsigned long r24;
unsigned long r25;
unsigned long gp;
unsigned long fp;
unsigned long sp;
unsigned long ra;
unsigned long ea;
unsigned long ba;
};

/*
* low level task data.
* If you change this, change the TI_* offsets below to match.
@@ -37,20 +61,30 @@ struct thread_info {
int preempt_count; /* 0 => preemptable, <0 => BUG */
struct restart_block restart_block;
mm_segment_t addr_limit;
struct cpu_context_save cpu_context;
};

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


/* how to get the thread information struct from C */
static inline struct thread_info *current_thread_info(void) __attribute_const__;
static inline struct thread_info *current_thread_info(void) __pure;

struct lm32_state {
struct thread_info *current_thread;
unsigned long kernel_mode;
unsigned long saved_r9;
unsigned long saved_r10;
unsigned long saved_r11;
};

extern struct thread_info* lm32_current_thread;
extern struct lm32_state lm32_state;

static inline struct thread_info *current_thread_info(void)
{
return lm32_current_thread;
register unsigned long sp asm ("sp");
return (struct thread_info *)(sp & ~(THREAD_SIZE - 1));
}


34 changes: 27 additions & 7 deletions arch/lm32/kernel/asm-offsets.c
Original file line number Diff line number Diff line change
@@ -27,10 +27,6 @@ int main(void)
DEFINE(TASK_MM, offsetof(struct task_struct, mm));
DEFINE(TASK_ACTIVE_MM, offsetof(struct task_struct, active_mm));

DEFINE(TASK_KSP, offsetof(struct task_struct, thread.ksp));
DEFINE(TASK_USP, offsetof(struct task_struct, thread.usp));
DEFINE(TASK_WHICH_STACK, offsetof(struct task_struct, thread.which_stack));

DEFINE(PT_R0, offsetof(struct pt_regs, r0));
DEFINE(PT_R1, offsetof(struct pt_regs, r1));
DEFINE(PT_R2, offsetof(struct pt_regs, r2));
@@ -72,9 +68,33 @@ int main(void)
DEFINE(TI_ADDR_LIMIT, offsetof(struct thread_info, addr_limit));
DEFINE(_THREAD_SIZE, THREAD_SIZE);

DEFINE(THREAD_KSP, offsetof(struct thread_struct, ksp));
DEFINE(THREAD_USP, offsetof(struct thread_struct, usp));
DEFINE(THREAD_WHICH_STACK, offsetof(struct thread_struct, which_stack));
DEFINE(TI_CC_R11, offsetof(struct thread_info, cpu_context.r11));
DEFINE(TI_CC_R12, offsetof(struct thread_info, cpu_context.r12));
DEFINE(TI_CC_R13, offsetof(struct thread_info, cpu_context.r13));
DEFINE(TI_CC_R14, offsetof(struct thread_info, cpu_context.r14));
DEFINE(TI_CC_R15, offsetof(struct thread_info, cpu_context.r15));
DEFINE(TI_CC_R16, offsetof(struct thread_info, cpu_context.r16));
DEFINE(TI_CC_R17, offsetof(struct thread_info, cpu_context.r17));
DEFINE(TI_CC_R18, offsetof(struct thread_info, cpu_context.r18));
DEFINE(TI_CC_R19, offsetof(struct thread_info, cpu_context.r19));
DEFINE(TI_CC_R20, offsetof(struct thread_info, cpu_context.r20));
DEFINE(TI_CC_R21, offsetof(struct thread_info, cpu_context.r21));
DEFINE(TI_CC_R22, offsetof(struct thread_info, cpu_context.r22));
DEFINE(TI_CC_R23, offsetof(struct thread_info, cpu_context.r23));
DEFINE(TI_CC_R24, offsetof(struct thread_info, cpu_context.r24));
DEFINE(TI_CC_R25, offsetof(struct thread_info, cpu_context.r25));
DEFINE(TI_CC_GP, offsetof(struct thread_info, cpu_context.gp));
DEFINE(TI_CC_FP, offsetof(struct thread_info, cpu_context.fp));
DEFINE(TI_CC_SP, offsetof(struct thread_info, cpu_context.sp));
DEFINE(TI_CC_RA, offsetof(struct thread_info, cpu_context.ra));
DEFINE(TI_CC_EA, offsetof(struct thread_info, cpu_context.ea));
DEFINE(TI_CC_BA, offsetof(struct thread_info, cpu_context.ba));

DEFINE(STATE_CURRENT_THREAD, offsetof(struct lm32_state, current_thread));
DEFINE(STATE_KERNEL_MODE, offsetof(struct lm32_state, kernel_mode));
DEFINE(STATE_SAVED_R9, offsetof(struct lm32_state, saved_r9));
DEFINE(STATE_SAVED_R10, offsetof(struct lm32_state, saved_r10));
DEFINE(STATE_SAVED_R11, offsetof(struct lm32_state, saved_r11));

return 0;
}
Loading