public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
* [Linux-ia64] Unwind can load wrong data from pt_regs
@ 2002-12-09  8:35 Keith Owens
  2002-12-09 21:21 ` David Mosberger
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Keith Owens @ 2002-12-09  8:35 UTC (permalink / raw)
  To: linux-ia64

2.4.19-ia64-020821/arch/ia64/kernel/unwind.c, compile_reg() contains

  case UNW_WHERE_FR:
    if (rval <= 5)
	    val = unw.preg_index[UNW_REG_F2  + (rval -  1)];
    else if (rval >= 16 && rval <= 31)
	    val = unw.preg_index[UNW_REG_F16 + (rval - 16)];
    else {
	    opc = UNW_INSN_ADD_SP;
	    val = -sizeof(struct pt_regs);
	    if (rval <= 9)
		    val += struct_offset(struct pt_regs, f6) + 16*(rval - 6);
	    else
		    dprintk("unwind: kernel may not touch f%lu\n", rval);
    }
    break;

    case UNW_WHERE_BR:
      if (rval >= 1 && rval <= 5)
	      val = unw.preg_index[UNW_REG_B1 + (rval - 1)];
      else {
	      opc = UNW_INSN_ADD_SP;
	      val = -sizeof(struct pt_regs);
	      if (rval = 0)
		      val += struct_offset(struct pt_regs, b0);
	      else if (rval = 6)
		      val += struct_offset(struct pt_regs, b6);
	      else
		      val += struct_offset(struct pt_regs, b7);
      }
      break;

This implicitly assumes that when a fr or br register is required from
pt_regs, info->sp is pointing to pt_regs.  But info->sp is modified as
the code unwinds through each function.  The above code only gives
correct results for register lookups from the failing function.
Unwinding and accessing a fr or br register from earlier functions
loads incorrect values for those registers.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Linux-ia64] Unwind can load wrong data from pt_regs
  2002-12-09  8:35 [Linux-ia64] Unwind can load wrong data from pt_regs Keith Owens
@ 2002-12-09 21:21 ` David Mosberger
  2002-12-09 22:04 ` Keith Owens
  2002-12-09 22:17 ` David Mosberger
  2 siblings, 0 replies; 4+ messages in thread
From: David Mosberger @ 2002-12-09 21:21 UTC (permalink / raw)
  To: linux-ia64

>>>>> On Mon, 09 Dec 2002 19:35:03 +1100, Keith Owens <kaos@sgi.com> said:

  Keith> This implicitly assumes that when a fr or br register is
  Keith> required from pt_regs, info->sp is pointing to pt_regs.  But
  Keith> info->sp is modified as the code unwinds through each
  Keith> function.  The above code only gives correct results for
  Keith> register lookups from the failing function.  Unwinding and
  Keith> accessing a fr or br register from earlier functions loads
  Keith> incorrect values for those registers.

Yes, this is something that has been fixed already in the user-level
libunwind.  It's not hard to fix, just someone needs to get around to
do it.  I don't think it's a critical issue, since it only happens for
nested traps.  I assume you saw this with kdb?

	--david


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Linux-ia64] Unwind can load wrong data from pt_regs
  2002-12-09  8:35 [Linux-ia64] Unwind can load wrong data from pt_regs Keith Owens
  2002-12-09 21:21 ` David Mosberger
@ 2002-12-09 22:04 ` Keith Owens
  2002-12-09 22:17 ` David Mosberger
  2 siblings, 0 replies; 4+ messages in thread
From: Keith Owens @ 2002-12-09 22:04 UTC (permalink / raw)
  To: linux-ia64

On Mon, 9 Dec 2002 13:21:07 -0800, 
David Mosberger <davidm@napali.hpl.hp.com> wrote:
>>>>>> On Mon, 09 Dec 2002 19:35:03 +1100, Keith Owens <kaos@sgi.com> said:
>
>  Keith> This implicitly assumes that when a fr or br register is
>  Keith> required from pt_regs, info->sp is pointing to pt_regs.  But
>  Keith> info->sp is modified as the code unwinds through each
>  Keith> function.  The above code only gives correct results for
>  Keith> register lookups from the failing function.  Unwinding and
>  Keith> accessing a fr or br register from earlier functions loads
>  Keith> incorrect values for those registers.
>
>Yes, this is something that has been fixed already in the user-level
>libunwind.  It's not hard to fix, just someone needs to get around to
>do it.  I don't think it's a critical issue, since it only happens for
>nested traps.  I assume you saw this with kdb?

How did you guess :).  I will look at libunwind and do a kernel fix.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Linux-ia64] Unwind can load wrong data from pt_regs
  2002-12-09  8:35 [Linux-ia64] Unwind can load wrong data from pt_regs Keith Owens
  2002-12-09 21:21 ` David Mosberger
  2002-12-09 22:04 ` Keith Owens
@ 2002-12-09 22:17 ` David Mosberger
  2 siblings, 0 replies; 4+ messages in thread
From: David Mosberger @ 2002-12-09 22:17 UTC (permalink / raw)
  To: linux-ia64

>>>>> On Tue, 10 Dec 2002 09:04:25 +1100, Keith Owens <kaos@sgi.com> said:

  Keith> How did you guess :).  I will look at libunwind and do a
  Keith> kernel fix.

The basic idea for the fix is to add a new variable (pt_regs_addr) to
unw_frame_info to track the sp of the latest UNW_FLAG_INTERRUPT_FRAME
encountered.

	--david


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-12-09 22:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-12-09  8:35 [Linux-ia64] Unwind can load wrong data from pt_regs Keith Owens
2002-12-09 21:21 ` David Mosberger
2002-12-09 22:04 ` Keith Owens
2002-12-09 22:17 ` David Mosberger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox