public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Pedro Franco de Carvalho <pedromfc@linux.ibm.com>,
	gdb-patches@sourceware.org
Cc: uweigand@de.ibm.com, edjunior@gmail.com
Subject: Re: [PATCH v4 12/12] [PowerPC] Add support for HTM registers
Date: Thu, 16 Aug 2018 16:53:00 -0000	[thread overview]
Message-ID: <540dad8e-f9a2-8173-a556-c919fbeeb43f@redhat.com> (raw)
In-Reply-To: <20180815000608.26840-13-pedromfc@linux.ibm.com>

On 08/15/2018 01:06 AM, Pedro Franco de Carvalho wrote:
> From: Edjunior Barbosa Machado <emachado@linux.vnet.ibm.com>
> 
> This patch adds support for Hardware Transactional Memory registers
> for the powerpc linux native and core file targets, and for the
> pwoerpc linux server stub.
> 
> These registers include both the HTM special-purpose registers (TFHAR,
> TEXASR and TFIAR) as well as the set of registers that are
> checkpointed (saved) when a transaction is initiated, which the
> processor restores in the event of a transaction failure.
> 
> The set of checkpointed general-purpose registers is returned by the
> linux kernel in the same format as the regular general-purpose
> registers, defined in struct pt_regs.  However, the architecture
> specifies that only some of the registers present in pt_regs are
> checkpointed (GPRs 0-31, CR, XER, LR and CTR).  The kernel fills the
> slots for other registers with other info (e.g., nip is filled with
> the contents of TFHAR).  GDB doesn't handle these other registers.
> This means that core files generated by GDB will show values of zero
> for these registers, while core files generated by the kernel will
> have other values.  Core files generated by the kernel have a note
> section for checkpointed GPRs with the same size for both 32-bit and
> 64-bit threads, and the values for the registers of a 32-bit thread
> are squeezed in the first half, with no useful data in the second
> half.  GDB generates a smaller note section for 32-bit threads, but
> can read both sizes.

I won't pretend to understand the above fully (not an Power expert),
but the question I ended up with was, after all this, will the
GDB-generated files end up looking like kernel-generated cores?
Or are there plans for that?

> 
> The checkpointed XER is required to be 32-bit in the target
> description documentation, even though the more recent ISAs define it
> as 64-bit wide, since the high-order 32-bits are reserved, and because
> in Linux there is no way to get a 64-bit checkpointed XER for 32-bit
> threads.  If this changes in the future, the target description
> feature requirement can be relaxed to allow for a 64-bit checkpointed
> XER.
> 
> Access to the checkpointed CR (condition register) can be confusing.
> The architecture only specifies that CR fields 1 to 7 (the 24 least
> significant bits) are checkpointed, but the kernel provides all 8
> fields (32 bits).  The value of field 0 is not masked by ptrace, so it
> will sometimes show the result of some kernel operation, probably
> treclaim., which sets this field.
> 
> The checkpointed registers are marked not to be saved and restored.
> Inferior function calls during an active transaction don't work well,
> and it's unclear what should be done in this case.  TEXASR and TFIAR
> can be altered asynchronously, during transaction failure recording,
> so they are also not saved and restored.  For consistency neither is
> TFHAR.
> 
> Record and replay also doesn't work well when transactions are
> involved.  This patch doesn't address this, so the values of the HTM
> SPRs will sometimes be innacurate when the record/relay target is
> enabled.  For instance, executing a "tbegin." alters TFHAR and TEXASR,
> but these changes are not currently recorded.
> 
> Because the checkpointed registers are only available when a
> transaction is active (or suspended), ptrace can return ENODATA when
> gdb tries to read these registers and the inferior is not in a
> transactional state.  The registers are set to the unavailable state
> when this happens.  When gbd tries to write to one of these registers,
> and it is unavailable, an error is raised.  When gdb tries to store to
> all registers in one go (when store_registers called with -1), the
> state of these registers is checked.  If they are all unavailable, no
> write is attempted, so that writes to all the other registers are
> unaffected.  If all are available, the write is attempted.  Otherwise
> an internal_error is raised.
> 
> The "fill" functions for checkpointed register sets in the server stub
> are not implemented for the same reason as for the EBB register set,
> since ptrace can also return ENODATA for checkpointed regsets.
> 
> Just like for the EBB registers, tracepoints will not mark the
> checkpointed registers as unavailable if the inferior was not in a
> transaction, so their content will also show 0 instead of
> <unavailable> when inspecting trace data.
> 
> The new tests record the values of the regular registers before
> stepping the inferior through a "tbegin." instruction to start a
> transaction, then the checkpointed registers are checked against the
> recorded pre-transactional values.  New values are written to the
> checkpointed registers and recorded, the inferior continues until the
> transaction aborts (which is usually immediately when it is resumed),
> and the regular registers are checked against the recorded values,
> because the abort should have reverted the registers to these values.

I'd find it useful to have an intro description like this last paragraph
above as a comment in the .exp file directly.  Likewise other
explanations throughout the series felt like would be useful in the code, but
I really haven't double checked to see if they were there already.

Speaking of comments, I noticed that the series adds a number of
functions and globals with no leading comment.

Thanks,
Pedro Alves

  reply	other threads:[~2018-08-16 16:53 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-15  0:07 [PATCH v4 00/12] GDB support for more powerpc registers on linux Pedro Franco de Carvalho
2018-08-15  0:07 ` [PATCH v4 11/12] [PowerPC] Reject tdescs with VSX and no FPU or Altivec Pedro Franco de Carvalho
2018-08-15  0:07 ` [PATCH v4 01/12] Zero-initialize linux note sections Pedro Franco de Carvalho
2018-08-15  0:07 ` [PATCH v4 02/12] [PowerPC] Don't zero-initialize vector register buffers Pedro Franco de Carvalho
2018-08-15  0:07 ` [PATCH v4 05/12] [PowerPC] Fix two if statements in gdb/ppc-linux-nat.c Pedro Franco de Carvalho
2018-08-15  0:07 ` [PATCH v4 07/12] [PowerPC] Refactor have_ initializers in rs6000-tdep.c Pedro Franco de Carvalho
2018-08-15  0:07 ` [PATCH v4 06/12] [PowerPC] Fix indentation in arch/ppc-linux-common.c Pedro Franco de Carvalho
2018-08-15  0:07 ` [PATCH v4 09/12] [PowerPC] Add support for TAR Pedro Franco de Carvalho
2018-08-15  0:07 ` [PATCH v4 10/12] [PowerPC] Add support for EBB and PMU registers Pedro Franco de Carvalho
2018-08-16 16:51   ` Pedro Alves
2018-08-16 18:16     ` Pedro Franco de Carvalho
2018-08-15  0:07 ` [PATCH v4 04/12] [PowerPC] Remove rs6000_pseudo_register_reggroup_p Pedro Franco de Carvalho
2018-08-15  0:07 ` [PATCH v4 03/12] Add decfloat registers to float reggroup Pedro Franco de Carvalho
2018-08-15  0:55 ` [PATCH v4 12/12] [PowerPC] Add support for HTM registers Pedro Franco de Carvalho
2018-08-16 16:53   ` Pedro Alves [this message]
2018-08-16 17:50     ` Pedro Franco de Carvalho
2018-08-16 20:16       ` Pedro Franco de Carvalho
2018-08-16 23:47         ` Pedro Franco de Carvalho
2018-08-17 18:11           ` Pedro Alves
2018-08-17 19:25             ` Pedro Franco de Carvalho
2018-08-15  1:16 ` [PATCH v4 08/12] [PowerPC] Add support for PPR and DSCR Pedro Franco de Carvalho
2018-08-16 16:46 ` [PATCH v4 00/12] GDB support for more powerpc registers on linux Pedro Franco de Carvalho
2018-08-16 17:00   ` Pedro Alves
2018-08-16 17:42     ` Pedro Franco de Carvalho
2018-08-16 18:02       ` Eli Zaretskii
2018-08-16 18:08         ` Pedro Franco de Carvalho
2018-08-16 18:45           ` Eli Zaretskii
2018-08-16 19:23             ` Pedro Franco de Carvalho
2018-10-08 19:09     ` ping: " Jan Kratochvil
2018-10-08 19:32       ` Pedro Franco de Carvalho

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=540dad8e-f9a2-8173-a556-c919fbeeb43f@redhat.com \
    --to=palves@redhat.com \
    --cc=edjunior@gmail.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pedromfc@linux.ibm.com \
    --cc=uweigand@de.ibm.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).