public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: James Hogan <james.hogan@imgtec.com>
To: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>,
	Ralf Baechle <ralf@linux-mips.org>,
	Markos Chandras <markos.chandras@imgtec.com>
Cc: Paul Burton <paul.burton@imgtec.com>,
	Leonid Yegoshin <Leonid.Yegoshin@imgtec.com>,
	John Crispin <blogic@openwrt.org>, <linux-mips@linux-mips.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] arch: mips: kernel: traps:  Remove some unused functions
Date: Fri, 2 Jan 2015 10:38:57 +0000	[thread overview]
Message-ID: <54A67541.7040707@imgtec.com> (raw)
In-Reply-To: <1420134507-540-1-git-send-email-rickard_strandqvist@spectrumdigital.se>

[-- Attachment #1: Type: text/plain, Size: 7232 bytes --]

On 01/01/15 17:48, Rickard Strandqvist wrote:
> Removes some functions that are not used anywhere:
> do_bp() do_ftlb() do_dsp() do_mcheck() do_mdmx() do_msa() do_msa_fpe()
> 
> This was partially found by using a static code analysis program called cppcheck.

To elaborate on Leonid's comment, These functions are used from
arch/mips/kernel/genex.S. See BUILD_HANDLER assembly macro. Each one
builds a handle_* assembly function which saves appropriate exception
state and calls do_*() with return address pointing to
ret_from_exception. The handle_* functions are set as handlers for
various exceptions by set_except_vector() in arch/mips/kernel/traps.c.

Cheers
James

> 
> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> ---
>  arch/mips/kernel/traps.c |  185 ----------------------------------------------
>  1 file changed, 185 deletions(-)
> 
> diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
> index 22b19c2..59c8e0d 100644
> --- a/arch/mips/kernel/traps.c
> +++ b/arch/mips/kernel/traps.c
> @@ -854,85 +854,6 @@ static void do_trap_or_bp(struct pt_regs *regs, unsigned int code,
>  	}
>  }
>  
> -asmlinkage void do_bp(struct pt_regs *regs)
> -{
> -	unsigned int opcode, bcode;
> -	enum ctx_state prev_state;
> -	unsigned long epc;
> -	u16 instr[2];
> -	mm_segment_t seg;
> -
> -	seg = get_fs();
> -	if (!user_mode(regs))
> -		set_fs(KERNEL_DS);
> -
> -	prev_state = exception_enter();
> -	if (get_isa16_mode(regs->cp0_epc)) {
> -		/* Calculate EPC. */
> -		epc = exception_epc(regs);
> -		if (cpu_has_mmips) {
> -			if ((__get_user(instr[0], (u16 __user *)msk_isa16_mode(epc)) ||
> -			    (__get_user(instr[1], (u16 __user *)msk_isa16_mode(epc + 2)))))
> -				goto out_sigsegv;
> -			opcode = (instr[0] << 16) | instr[1];
> -		} else {
> -			/* MIPS16e mode */
> -			if (__get_user(instr[0],
> -				       (u16 __user *)msk_isa16_mode(epc)))
> -				goto out_sigsegv;
> -			bcode = (instr[0] >> 6) & 0x3f;
> -			do_trap_or_bp(regs, bcode, "Break");
> -			goto out;
> -		}
> -	} else {
> -		if (__get_user(opcode,
> -			       (unsigned int __user *) exception_epc(regs)))
> -			goto out_sigsegv;
> -	}
> -
> -	/*
> -	 * There is the ancient bug in the MIPS assemblers that the break
> -	 * code starts left to bit 16 instead to bit 6 in the opcode.
> -	 * Gas is bug-compatible, but not always, grrr...
> -	 * We handle both cases with a simple heuristics.  --macro
> -	 */
> -	bcode = ((opcode >> 6) & ((1 << 20) - 1));
> -	if (bcode >= (1 << 10))
> -		bcode >>= 10;
> -
> -	/*
> -	 * notify the kprobe handlers, if instruction is likely to
> -	 * pertain to them.
> -	 */
> -	switch (bcode) {
> -	case BRK_KPROBE_BP:
> -		if (notify_die(DIE_BREAK, "debug", regs, bcode,
> -			       regs_to_trapnr(regs), SIGTRAP) == NOTIFY_STOP)
> -			goto out;
> -		else
> -			break;
> -	case BRK_KPROBE_SSTEPBP:
> -		if (notify_die(DIE_SSTEPBP, "single_step", regs, bcode,
> -			       regs_to_trapnr(regs), SIGTRAP) == NOTIFY_STOP)
> -			goto out;
> -		else
> -			break;
> -	default:
> -		break;
> -	}
> -
> -	do_trap_or_bp(regs, bcode, "Break");
> -
> -out:
> -	set_fs(seg);
> -	exception_exit(prev_state);
> -	return;
> -
> -out_sigsegv:
> -	force_sig(SIGSEGV, current);
> -	goto out;
> -}
> -
>  asmlinkage void do_tr(struct pt_regs *regs)
>  {
>  	u32 opcode, tcode = 0;
> @@ -1297,46 +1218,6 @@ out:
>  	exception_exit(prev_state);
>  }
>  
> -asmlinkage void do_msa_fpe(struct pt_regs *regs)
> -{
> -	enum ctx_state prev_state;
> -
> -	prev_state = exception_enter();
> -	die_if_kernel("do_msa_fpe invoked from kernel context!", regs);
> -	force_sig(SIGFPE, current);
> -	exception_exit(prev_state);
> -}
> -
> -asmlinkage void do_msa(struct pt_regs *regs)
> -{
> -	enum ctx_state prev_state;
> -	int err;
> -
> -	prev_state = exception_enter();
> -
> -	if (!cpu_has_msa || test_thread_flag(TIF_32BIT_FPREGS)) {
> -		force_sig(SIGILL, current);
> -		goto out;
> -	}
> -
> -	die_if_kernel("do_msa invoked from kernel context!", regs);
> -
> -	err = enable_restore_fp_context(1);
> -	if (err)
> -		force_sig(SIGILL, current);
> -out:
> -	exception_exit(prev_state);
> -}
> -
> -asmlinkage void do_mdmx(struct pt_regs *regs)
> -{
> -	enum ctx_state prev_state;
> -
> -	prev_state = exception_enter();
> -	force_sig(SIGILL, current);
> -	exception_exit(prev_state);
> -}
> -
>  /*
>   * Called with interrupts disabled.
>   */
> @@ -1370,36 +1251,6 @@ asmlinkage void do_watch(struct pt_regs *regs)
>  	exception_exit(prev_state);
>  }
>  
> -asmlinkage void do_mcheck(struct pt_regs *regs)
> -{
> -	const int field = 2 * sizeof(unsigned long);
> -	int multi_match = regs->cp0_status & ST0_TS;
> -	enum ctx_state prev_state;
> -
> -	prev_state = exception_enter();
> -	show_regs(regs);
> -
> -	if (multi_match) {
> -		printk("Index	: %0x\n", read_c0_index());
> -		printk("Pagemask: %0x\n", read_c0_pagemask());
> -		printk("EntryHi : %0*lx\n", field, read_c0_entryhi());
> -		printk("EntryLo0: %0*lx\n", field, read_c0_entrylo0());
> -		printk("EntryLo1: %0*lx\n", field, read_c0_entrylo1());
> -		printk("\n");
> -		dump_tlb_all();
> -	}
> -
> -	show_code((unsigned int __user *) regs->cp0_epc);
> -
> -	/*
> -	 * Some chips may have other causes of machine check (e.g. SB1
> -	 * graduation timer)
> -	 */
> -	panic("Caught Machine Check exception - %scaused by multiple "
> -	      "matching entries in the TLB.",
> -	      (multi_match) ? "" : "not ");
> -}
> -
>  asmlinkage void do_mt(struct pt_regs *regs)
>  {
>  	int subcode;
> @@ -1436,14 +1287,6 @@ asmlinkage void do_mt(struct pt_regs *regs)
>  }
>  
>  
> -asmlinkage void do_dsp(struct pt_regs *regs)
> -{
> -	if (cpu_has_dsp)
> -		panic("Unexpected DSP exception");
> -
> -	force_sig(SIGILL, current);
> -}
> -
>  asmlinkage void do_reserved(struct pt_regs *regs)
>  {
>  	/*
> @@ -1609,34 +1452,6 @@ asmlinkage void cache_parity_error(void)
>  	panic("Can't handle the cache error!");
>  }
>  
> -asmlinkage void do_ftlb(void)
> -{
> -	const int field = 2 * sizeof(unsigned long);
> -	unsigned int reg_val;
> -
> -	/* For the moment, report the problem and hang. */
> -	if (cpu_has_mips_r2 &&
> -	    ((current_cpu_data.processor_id & 0xff0000) == PRID_COMP_MIPS)) {
> -		pr_err("FTLB error exception, cp0_ecc=0x%08x:\n",
> -		       read_c0_ecc());
> -		pr_err("cp0_errorepc == %0*lx\n", field, read_c0_errorepc());
> -		reg_val = read_c0_cacheerr();
> -		pr_err("c0_cacheerr == %08x\n", reg_val);
> -
> -		if ((reg_val & 0xc0000000) == 0xc0000000) {
> -			pr_err("Decoded c0_cacheerr: FTLB parity error\n");
> -		} else {
> -			pr_err("Decoded c0_cacheerr: %s cache fault in %s reference.\n",
> -			       reg_val & (1<<30) ? "secondary" : "primary",
> -			       reg_val & (1<<31) ? "data" : "insn");
> -		}
> -	} else {
> -		pr_err("FTLB error exception\n");
> -	}
> -	/* Just print the cacheerr bits for now */
> -	cache_parity_error();
> -}
> -
>  /*
>   * SDBBP EJTAG debug exception handler.
>   * We skip the instruction and return to the next instruction.
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2015-01-02 10:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-01 17:48 [PATCH] arch: mips: kernel: traps: Remove some unused functions Rickard Strandqvist
2015-01-02 10:38 ` James Hogan [this message]
     [not found]   ` <CAKXHbyOLteCgVH8OMrB9zr6=eCmM8qQBN4o4_HN086mhHg+DJw@mail.gmail.com>
2015-01-02 11:54     ` James Hogan
  -- strict thread matches above, loose matches on Subject: below --
2015-01-01 19:34 Leonid Yegoshin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54A67541.7040707@imgtec.com \
    --to=james.hogan@imgtec.com \
    --cc=Leonid.Yegoshin@imgtec.com \
    --cc=blogic@openwrt.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=markos.chandras@imgtec.com \
    --cc=paul.burton@imgtec.com \
    --cc=ralf@linux-mips.org \
    --cc=rickard_strandqvist@spectrumdigital.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox