Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <qiyaoltc@gmail.com>
To: Pedro Alves <palves@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] [AArch64 Linux] Get rid of top byte from tagged address
Date: Thu, 19 Oct 2017 10:51:00 -0000	[thread overview]
Message-ID: <86po9jv29n.fsf@gmail.com> (raw)
In-Reply-To: <561ea277-4b4c-ae82-01e1-1cde96cb54f2@redhat.com> (Pedro Alves's	message of "Thu, 19 Oct 2017 10:52:20 +0100")

Pedro Alves <palves@redhat.com> writes:

> I'm fine with doing this if it's what arm/linaro folks want,
> though personally (with absolutely no experience in this) I have
> reservations about whether stripping the top byte in the special
> case of memory accesses is a good idea, since it may puzzle folks
> when they pass such pointers/addresses in registers/structures and
> things don't magically work then (and then gdb masks the problem when
> folks try to diagnose it, as in "but I can access the object
> via "p *s->ptr", why isn't this working???  bad gdb.").
>
> So I think this should be documented in the manual somewhere.

I don't understand how does GDB affect the program.  ARMv8 architecture
supports tagged address for data values, and top byte of virtual address
is ignored in some cases,

  struct s s1;
  s1.i = 1234;
  struct s *p1 = &s1;
  struct s *p2 = &s1;
  uint64_t t = (uint64_t) p2;

  t |= 0xf000000000000000ULL;
  p2 = (struct s *) t;

  printf ("%p %d\n", p2, p2->i);

The program output is "0xf000ffffc2e51720 1234".

However, linux kernel applies an restriction that top one byte should be
zero when user space passes address to syscall or access /proc file
system.  When GDB debugs inferior, it needs to either pass address to
kernel through syscall (ptrace) or access /proc, kernel complains on the
address.  The point of this patch is to keep tagged bits in VA, and only
get rid of them at the point when the address is to be passed to kernel.
GDB has no problem debugging the example above,

(gdb) p p2
$1 = (struct s *) 0xf000fffffffff500
(gdb) p *p2
$2 = {i = 1234}
(gdb) p p2->i
$3 = 1234

-- 
Yao (齐尧)


  parent reply	other threads:[~2017-10-19 10:51 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-19  8:08 Yao Qi
2017-10-19  9:51 ` Ramana Radhakrishnan
2017-10-19 10:53   ` Yao Qi
2017-10-19  9:52 ` Pedro Alves
2017-10-19  9:55   ` Ramana Radhakrishnan
2017-10-19 10:51   ` Yao Qi [this message]
2017-10-19 11:09     ` Pedro Alves
2017-10-19 13:17       ` Yao Qi
2017-10-19 13:22         ` Pedro Alves
2017-10-19 11:21 ` Pedro Alves
2017-10-19 13:25   ` Yao Qi

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=86po9jv29n.fsf@gmail.com \
    --to=qiyaoltc@gmail.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    /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