public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Szabolcs Nagy <szabolcs.nagy@arm.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: Florian Weimer <fweimer@redhat.com>,
	libc-alpha@sourceware.org,
	"Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>,
	Joseph Myers <joseph@codesourcery.com>,
	Vedvyas Shanbhogue <vedvyas.shanbhogue@intel.com>
Subject: Re: [PATCH v4 1/2] <sys/tagged-address.h>: An API for tagged address
Date: Thu, 22 Apr 2021 10:43:10 +0100	[thread overview]
Message-ID: <20210422094309.GI9028@arm.com> (raw)
In-Reply-To: <CAMe9rOrsqKFj9pWb4fP+gVSoS9+J8P0gnPfLJdUfwk2zUoNm0A@mail.gmail.com>

The 04/21/2021 16:21, H.J. Lu via Libc-alpha wrote:
> On Tue, Apr 20, 2021 at 11:36 PM Florian Weimer <fweimer@redhat.com> wrote:
> > * H. J. Lu:
> > > diff --git a/manual/tagged-address.texi b/manual/tagged-address.texi
> > > new file mode 100644
> > > index 0000000000..ce10f7e752
> > > --- /dev/null
> > > +++ b/manual/tagged-address.texi
> > > @@ -0,0 +1,59 @@
> > > +@node Tagged Address, Character Handling, Memory, Top
> > > +@c %MENU% Tagged address functions and macros
> > > +@chapter Tagged Address
> > > +
> > > +By default, the number of the address bits used in address translation
> > > +is the number of address bits.  But it can be changed by ARM Top-byte
> > > +Ignore (TBI) or Intel Linear Address Masking (LAM).
> > > +
> > > +@Theglibc{} provides several functions and macros in the header file
> > > +@file{sys/tagged-address.h} to manipulate tagged address bits, which is
> > > +the number of the address bits used in address translation.
> > > +@pindex sys/tagged-address.h
> >
> > I don't under stand the “which is the number of address bits” part.
> 
> For tagged addresses, not all bits are used in address translation.
> For TBI, only the lower 48 bits are used in address translation.
> For LAM, it can be either the lower 48 bits or 57 bits.
> 
> > This section needs to describe under which circumstances it is valid to
> > alter the tag bits in pointers returned from glibc functions (including
> 
> Tagged address is enabled only when get_tagged_address_mask () != -1.
> 


> > system call wrappers).  I think at least historically, the kernel
> > required masking tag bits in user space for TBI.
> 
> I believe this has been fixed in the recent kernel.

on aarch64 we need

prctl(PR_SET_TAGGED_ADDR_CTRL, PR_TAGGED_ADDR_ENABLE, 0, 0, 0);

while single threaded to enable the tagged address syscall abi, see
https://www.kernel.org/doc/html/latest/arm64/tagged-pointers.html

we do this for heap tagging because that depends on it, but we
don't enable it otherwise because previously invalid addresses
now may succeed instead of EFAULT/EINVAL in syscalls.

i think glibc can just enable it by default (always run processes
with tagged address syscall abi), i don't think that would cause
regressions other than different errno in some odd mmap etc usage.
(i think one glibc test fails along this line with heap tagging
enabled, if that's considered risky then we can do some per process
opt-in, but a libc call is problematic as it can be too late)

  reply	other threads:[~2021-04-22  9:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-20  2:18 RFC [PATCH v4 0/2] " H.J. Lu
2021-04-20  2:18 ` [PATCH v4 1/2] " H.J. Lu
2021-04-21  6:36   ` Florian Weimer
2021-04-21 23:21     ` H.J. Lu
2021-04-22  9:43       ` Szabolcs Nagy [this message]
2021-04-20  2:18 ` [PATCH v4 2/2] <sys/tagged-address.h>: Update libc.abilist files H.J. Lu

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=20210422094309.GI9028@arm.com \
    --to=szabolcs.nagy@arm.com \
    --cc=fweimer@redhat.com \
    --cc=hjl.tools@gmail.com \
    --cc=joseph@codesourcery.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=libc-alpha@sourceware.org \
    --cc=vedvyas.shanbhogue@intel.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).