All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Daney <ddaney@caviumnetworks.com>
To: Earl Chew <echew@ixiacom.com>
Cc: "linux-mips@linux-mips.org" <linux-mips@linux-mips.org>
Subject: Re: Filling in struct mips64_watch_regs from a 32 bit process
Date: Mon, 31 Jan 2011 17:03:07 -0800	[thread overview]
Message-ID: <4D475BCB.9050403@caviumnetworks.com> (raw)
In-Reply-To: <4D4756B5.4010100@ixiacom.com>

On 01/31/2011 04:41 PM, Earl Chew wrote:
> I notice that a 32 bit process running on a 64 bit kernel is expected to
> know that it should fill in mips64_watch_regs --- even though it is running
> against a 32 bit ABI.
>
> Is this an oversight, or am I missing something ?

It is intentional.

>
> [ That same 32 bit process must fill in mips32_watch_regs when running on
>    a 32 bit kernel. ]
>
>
> In arch/mips/include/asm/ptrace.h:
>
> struct mips32_watch_regs {
> 	unsigned int watchlo[8];
> 	...
> };
>
> and
>
> struct mips64_watch_regs {
> 	unsigned long long watchlo[8];
> 	...
> };
>
> These are used in a union, but sizeof(mips64_watch_regs.watchlo) will not
> match sizeof(mips32_watch_regs.watchlo).
>

The sizes are different and thus are ... different.  struct 
pt_watch_regs however, has a well defined size.

The important thing is that the style element of struct pt_watch_regs is 
always in the same place.

>
>
> For a 64 bit kernel, the code in arch/mips/kernel/ptrace.c reads:
>
>
>          /* Check the values. */
>          for (i = 0; i<  current_cpu_data.watch_reg_use_cnt; i++) {
>                  __get_user(lt[i],&addr->WATCH_STYLE.watchlo[i]);
> #ifdef CONFIG_32BIT
>                  if (lt[i]&  __UA_LIMIT)
>                          return -EINVAL;
> #else
>                  if (test_tsk_thread_flag(child, TIF_32BIT_ADDR)) {
>                          if (lt[i]&  0xffffffff80000000UL)
>                                  return -EINVAL;
>                  } else {
>                          if (lt[i]&  __UA_LIMIT)
>                                  return -EINVAL;
>                  }
> #endif
>
>
> Thus for a 64 bit kernel, WATCH_STYLE is defined to be mips64, and the code
> goes on to obtain:
>
> 	addr->mips64.watchlo[i]
>
> and to verify it based on TIF_32BIT_ADDR.
>
>
> In other words, the 32 bit process is expected to fill in mips64_watch_regs
> when it is running on a 64 bit kernel, and mips32_watch_regs when it is running
> on a 32 bit kernel.
>

Yes.  The debugging agent must check struct pt_watch_regs style to 
determine which type of watch registers the hardware is using.

Take a look at how GDB handles this in mips-linux-nat.c.

David Daney

  reply	other threads:[~2011-02-01  1:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-01  0:41 Filling in struct mips64_watch_regs from a 32 bit process Earl Chew
2011-02-01  1:03 ` David Daney [this message]
2011-02-01  1:12   ` Earl Chew
2011-02-01  1:24     ` David Daney
2011-02-01  1:26       ` Earl Chew

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=4D475BCB.9050403@caviumnetworks.com \
    --to=ddaney@caviumnetworks.com \
    --cc=echew@ixiacom.com \
    --cc=linux-mips@linux-mips.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.