Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 163355
b: refs/heads/master
c: c791483
h: refs/heads/master
i:
  163353: 801cf2d
  163351: b87e29d
v: v3
  • Loading branch information
Paul Mundt committed Aug 4, 2009
1 parent b3e707a commit b1512b8
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 67 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c0fe478dbb14fd32e71d1383dbe302b54ce94134
refs/heads/master: c7914834ef3b8a396b7e82ea34ac07cdcfe6f868
6 changes: 6 additions & 0 deletions trunk/arch/sh/include/asm/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
#define NEFF_SIGN (1LL << (NEFF - 1))
#define NEFF_MASK (-1LL << NEFF)

static inline unsigned long long neff_sign_extend(unsigned long val)
{
unsigned long long extended = val;
return (extended & NEFF_SIGN) ? (extended | NEFF_MASK) : extended;
}

#ifdef CONFIG_29BIT
#define NPHYS 29
#else
Expand Down
24 changes: 10 additions & 14 deletions trunk/arch/sh/kernel/process_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,6 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
struct task_struct *p, struct pt_regs *regs)
{
struct pt_regs *childregs;
unsigned long long se; /* Sign extension */

#ifdef CONFIG_SH_FPU
if(last_task_used_math == current) {
Expand All @@ -441,11 +440,19 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,

*childregs = *regs;

/*
* Sign extend the edited stack.
* Note that thread.pc and thread.pc will stay
* 32-bit wide and context switch must take care
* of NEFF sign extension.
*/
if (user_mode(regs)) {
childregs->regs[15] = usp;
childregs->regs[15] = neff_sign_extend(usp);
p->thread.uregs = childregs;
} else {
childregs->regs[15] = (unsigned long)task_stack_page(p) + THREAD_SIZE;
childregs->regs[15] =
neff_sign_extend((unsigned long)task_stack_page(p) +
THREAD_SIZE);
}

childregs->regs[9] = 0; /* Set return value for child */
Expand All @@ -454,17 +461,6 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
p->thread.sp = (unsigned long) childregs;
p->thread.pc = (unsigned long) ret_from_fork;

/*
* Sign extend the edited stack.
* Note that thread.pc and thread.pc will stay
* 32-bit wide and context switch must take care
* of NEFF sign extension.
*/

se = childregs->regs[15];
se = (se & NEFF_SIGN) ? (se | NEFF_MASK) : se;
childregs->regs[15] = se;

return 0;
}

Expand Down
38 changes: 13 additions & 25 deletions trunk/arch/sh/kernel/signal_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -561,13 +561,11 @@ static int setup_frame(int sig, struct k_sigaction *ka,
/* Set up to return from userspace. If provided, use a stub
already in userspace. */
if (ka->sa.sa_flags & SA_RESTORER) {
DEREF_REG_PR = (unsigned long) ka->sa.sa_restorer | 0x1;

/*
* On SH5 all edited pointers are subject to NEFF
*/
DEREF_REG_PR = (DEREF_REG_PR & NEFF_SIGN) ?
(DEREF_REG_PR | NEFF_MASK) : DEREF_REG_PR;
DEREF_REG_PR = neff_sign_extend((unsigned long)
ka->sa.sa_restorer | 0x1);
} else {
/*
* Different approach on SH5.
Expand All @@ -580,9 +578,8 @@ static int setup_frame(int sig, struct k_sigaction *ka,
* . being code, linker turns ShMedia bit on, always
* dereference index -1.
*/
DEREF_REG_PR = (unsigned long) frame->retcode | 0x01;
DEREF_REG_PR = (DEREF_REG_PR & NEFF_SIGN) ?
(DEREF_REG_PR | NEFF_MASK) : DEREF_REG_PR;
DEREF_REG_PR = neff_sign_extend((unsigned long)
frame->retcode | 0x01);

if (__copy_to_user(frame->retcode,
(void *)((unsigned long)sa_default_restorer & (~1)), 16) != 0)
Expand All @@ -596,9 +593,7 @@ static int setup_frame(int sig, struct k_sigaction *ka,
* Set up registers for signal handler.
* All edited pointers are subject to NEFF.
*/
regs->regs[REG_SP] = (unsigned long) frame;
regs->regs[REG_SP] = (regs->regs[REG_SP] & NEFF_SIGN) ?
(regs->regs[REG_SP] | NEFF_MASK) : regs->regs[REG_SP];
regs->regs[REG_SP] = neff_sign_extend((unsigned long)frame);
regs->regs[REG_ARG1] = signal; /* Arg for signal handler */

/* FIXME:
Expand All @@ -613,8 +608,7 @@ static int setup_frame(int sig, struct k_sigaction *ka,
regs->regs[REG_ARG2] = (unsigned long long)(unsigned long)(signed long)&frame->sc;
regs->regs[REG_ARG3] = (unsigned long long)(unsigned long)(signed long)&frame->sc;

regs->pc = (unsigned long) ka->sa.sa_handler;
regs->pc = (regs->pc & NEFF_SIGN) ? (regs->pc | NEFF_MASK) : regs->pc;
regs->pc = neff_sign_extend((unsigned long)ka->sa.sa_handler);

set_fs(USER_DS);

Expand Down Expand Up @@ -676,13 +670,11 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
/* Set up to return from userspace. If provided, use a stub
already in userspace. */
if (ka->sa.sa_flags & SA_RESTORER) {
DEREF_REG_PR = (unsigned long) ka->sa.sa_restorer | 0x1;

/*
* On SH5 all edited pointers are subject to NEFF
*/
DEREF_REG_PR = (DEREF_REG_PR & NEFF_SIGN) ?
(DEREF_REG_PR | NEFF_MASK) : DEREF_REG_PR;
DEREF_REG_PR = neff_sign_extend((unsigned long)
ka->sa.sa_restorer | 0x1);
} else {
/*
* Different approach on SH5.
Expand All @@ -695,30 +687,26 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
* . being code, linker turns ShMedia bit on, always
* dereference index -1.
*/

DEREF_REG_PR = (unsigned long) frame->retcode | 0x01;
DEREF_REG_PR = (DEREF_REG_PR & NEFF_SIGN) ?
(DEREF_REG_PR | NEFF_MASK) : DEREF_REG_PR;
DEREF_REG_PR = neff_sign_extend((unsigned long)
frame->retcode | 0x01);

if (__copy_to_user(frame->retcode,
(void *)((unsigned long)sa_default_rt_restorer & (~1)), 16) != 0)
goto give_sigsegv;

/* Cohere the trampoline with the I-cache. */
flush_icache_range(DEREF_REG_PR-1, DEREF_REG_PR-1+15);
}

/*
* Set up registers for signal handler.
* All edited pointers are subject to NEFF.
*/
regs->regs[REG_SP] = (unsigned long) frame;
regs->regs[REG_SP] = (regs->regs[REG_SP] & NEFF_SIGN) ?
(regs->regs[REG_SP] | NEFF_MASK) : regs->regs[REG_SP];
regs->regs[REG_SP] = neff_sign_extend((unsigned long)frame);
regs->regs[REG_ARG1] = signal; /* Arg for signal handler */
regs->regs[REG_ARG2] = (unsigned long long)(unsigned long)(signed long)&frame->info;
regs->regs[REG_ARG3] = (unsigned long long)(unsigned long)(signed long)&frame->uc.uc_mcontext;
regs->pc = (unsigned long) ka->sa.sa_handler;
regs->pc = (regs->pc & NEFF_SIGN) ? (regs->pc | NEFF_MASK) : regs->pc;
regs->pc = neff_sign_extend((unsigned long)ka->sa.sa_handler);

set_fs(USER_DS);

Expand Down
11 changes: 1 addition & 10 deletions trunk/arch/sh/mm/fault_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,7 @@ inline void __do_tlb_refill(unsigned long address,
/*
* Set PTEH register
*/
pteh = address & MMU_VPN_MASK;

/* Sign extend based on neff. */
#if (NEFF == 32)
/* Faster sign extension */
pteh = (unsigned long long)(signed long long)(signed long)pteh;
#else
/* General case */
pteh = (pteh & NEFF_SIGN) ? (pteh | NEFF_MASK) : pteh;
#endif
pteh = neff_sign_extend(address & MMU_VPN_MASK);

/* Set the ASID. */
pteh |= get_asid() << PTEH_ASID_SHIFT;
Expand Down
21 changes: 5 additions & 16 deletions trunk/arch/sh/mm/tlb-sh5.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,26 +117,15 @@ int sh64_put_wired_dtlb_entry(unsigned long long entry)
* Load up a virtual<->physical translation for @eaddr<->@paddr in the
* pre-allocated TLB slot @config_addr (see sh64_get_wired_dtlb_entry).
*/
inline void sh64_setup_tlb_slot(unsigned long long config_addr,
unsigned long eaddr,
unsigned long asid,
unsigned long paddr)
void sh64_setup_tlb_slot(unsigned long long config_addr, unsigned long eaddr,
unsigned long asid, unsigned long paddr)
{
unsigned long long pteh, ptel;

/* Sign extension */
#if (NEFF == 32)
pteh = (unsigned long long)(signed long long)(signed long) eaddr;
#else
#error "Can't sign extend more than 32 bits yet"
#endif
pteh = neff_sign_extend(eaddr);
pteh &= PAGE_MASK;
pteh |= (asid << PTEH_ASID_SHIFT) | PTEH_VALID;
#if (NEFF == 32)
ptel = (unsigned long long)(signed long long)(signed long) paddr;
#else
#error "Can't sign extend more than 32 bits yet"
#endif
ptel = neff_sign_extend(paddr);
ptel &= PAGE_MASK;
ptel |= (_PAGE_CACHABLE | _PAGE_READ | _PAGE_WRITE);

Expand All @@ -152,5 +141,5 @@ inline void sh64_setup_tlb_slot(unsigned long long config_addr,
*
* Teardown any existing mapping in the TLB slot @config_addr.
*/
inline void sh64_teardown_tlb_slot(unsigned long long config_addr)
void sh64_teardown_tlb_slot(unsigned long long config_addr)
__attribute__ ((alias("__flush_tlb_slot")));
2 changes: 1 addition & 1 deletion trunk/arch/sh/mm/tlbflush_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ void local_flush_tlb_one(unsigned long asid, unsigned long page)
/*
* Sign-extend based on neff.
*/
lpage = (page & NEFF_SIGN) ? (page | NEFF_MASK) : page;
lpage = neff_sign_extend(page);
match = (asid << PTEH_ASID_SHIFT) | PTEH_VALID;
match |= lpage;

Expand Down

0 comments on commit b1512b8

Please sign in to comment.