Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andreas Arnez <arnez@linux.vnet.ibm.com>
To: "Marcin Kościelnicki" <koriakin@0x04.net>
Cc: gdb-patches@sourceware.org, antoine.tremblay@ericsson.com
Subject: Re: [PATCH v2] gdbserver/s390: Add fast tracepoint support.
Date: Mon, 14 Mar 2016 16:19:00 -0000	[thread overview]
Message-ID: <m3egbdxcac.fsf@oc1027705133.ibm.com> (raw)
In-Reply-To: <1457088025-3118-1-git-send-email-koriakin@0x04.net> ("Marcin	\=\?utf-8\?Q\?Ko\=C5\=9Bcielnicki\=22's\?\= message of "Fri, 4 Mar 2016 11:40:25 +0100")

On Fri, Mar 04 2016, Marcin Kościelnicki wrote:

> Fast tracepoints will only work on 6-byte intructions, and assume at least
> a z900 CPU.  s390 also has 4-byte jump instructions, which also work on
> pre-z900, but their range is limitted to +-64kiB, which is not very useful
> (and wouldn't work at all with current jump pad allocation).
>
> There's a little problem with s390_relocate_instruction function: it
> converts BRAS/BRASL instructions to LARL of the return address + JG
> to the target address.  On 31-bit, this sets the high bit of the target
> register to 0, while BRAS/BRASL would set it to 1.  While this is not
> a problem when the result is only used to address memory, it could
> possibly break something that expects to compare such addresses for
> equality without first masking the bit off.  In particular, I'm not sure
> whether leaving the return address high bit unset is ABI-compliant
> (could confuse some unwinder?).  If that's a problem, it could be fixed
> by handling it in the jump pad (since at that point we can just modify
> the GPRs in the save area without having to worry about preserving
> CCs and only having that one GPR to work with - I'm not sure if it's
> even possible to set the high bit with such constraints).
>
> gdb/gdbserver/ChangeLog:
>
> 	* Makefile.in: Add s390 IPA files.
> 	* configure.srv: Build IPA for s390.
> 	* linux-s390-ipa.c: New file.
> 	* linux-s390-low.c: New includes - inttypes.h and linux-s390-tdesc.h.
> 	(init_registers_s390_linux32): Move declaration to linux-s390-tdesc.h.
> 	(tdesc_s390_linux32): Ditto.
> 	(init_registers_s390_linux32v1): Ditto.
> 	(tdesc_s390_linux32v1): Ditto.
> 	(init_registers_s390_linux32v2): Ditto.
> 	(tdesc_s390_linux32v2): Ditto.
> 	(init_registers_s390_linux64): Ditto.
> 	(tdesc_s390_linux64): Ditto.
> 	(init_registers_s390_linux64v1): Ditto.
> 	(tdesc_s390_linux64v1): Ditto.
> 	(init_registers_s390_linux64v2): Ditto.
> 	(tdesc_s390_linux64v2): Ditto.
> 	(init_registers_s390_te_linux64): Ditto.
> 	(tdesc_s390_te_linux64): Ditto.
> 	(init_registers_s390_vx_linux64): Ditto.
> 	(tdesc_s390_vx_linux64): Ditto.
> 	(init_registers_s390_tevx_linux64): Ditto.
> 	(tdesc_s390_tevx_linux64): Ditto.
> 	(init_registers_s390x_linux64): Ditto.
> 	(tdesc_s390x_linux64): Ditto.
> 	(init_registers_s390x_linux64v1): Ditto.
> 	(tdesc_s390x_linux64v1): Ditto.
> 	(init_registers_s390x_linux64v2): Ditto.
> 	(tdesc_s390x_linux64v2): Ditto.
> 	(init_registers_s390x_te_linux64): Ditto.
> 	(tdesc_s390x_te_linux64): Ditto.
> 	(init_registers_s390x_vx_linux64): Ditto.
> 	(tdesc_s390x_vx_linux64): Ditto.
> 	(init_registers_s390x_tevx_linux64): Ditto.
> 	(tdesc_s390x_tevx_linux64): Ditto.
> 	(have_hwcap_s390_vx): New static variable.
> 	(s390_arch_setup): Fill have_hwcap_s390_vx.
> 	(s390_get_thread_area): New function.
> 	(s390_ft_entry_gpr_esa): New const.
> 	(s390_ft_entry_gpr_zarch): New const.
> 	(s390_ft_entry_misc): New const.
> 	(s390_ft_entry_fr): New const.
> 	(s390_ft_entry_vr): New const.
> 	(s390_ft_main_31): New const.
> 	(s390_ft_main_64): New const.
> 	(s390_ft_exit_fr): New const.
> 	(s390_ft_exit_vr): New const.
> 	(s390_ft_exit_misc): New const.
> 	(s390_ft_exit_gpr_esa): New const.
> 	(s390_ft_exit_gpr_zarch): New const.
> 	(append_insns): New function.
> 	(s390_relocate_instruction): New function.
> 	(s390_install_fast_tracepoint_jump_pad): New function.
> 	(s390_get_min_fast_tracepoint_insn_len): New function.
> 	(s390_get_ipa_tdesc_idx): New function.
> 	(struct linux_target_ops): Wire in the above functions.
> 	(initialize_low_arch) [!__s390x__]: Don't initialize s390x tdescs.
> 	* linux-s390-tdesc.h: New file.

This is OK, apart from some minor nits (see below).  Note that we
usually say "likewise" instead of "ditto".

> +static int
> +s390_relocate_instruction (CORE_ADDR *to, CORE_ADDR oldloc, int is_64)
> +{

[...]

> +
> +	  /* XXX: this is not fully correct.  In 31-bit mode, LARL will write
> +	     an address with the top bit 0, while BRAS/BRASL will write it
> +	     with top bit 1.  It should not matter much, since linux compilers
> +	     use BR and not BSM to return from functions, but it could confuse
> +	     some poor stack unwinder.  */

We'll probably keep the logic like that anyway unless it's found to
cause real problems, so better replace the "XXX:" by a mere "Note:".
Also, "linux" should be "GNU/Linux".

> +
> +	  /* We'll now be writing a JG.  */
> +	  mode = 2;
> +	  buf[0] = 0xc0;
> +	  buf[1] = 0xf4;
> +	  ilen = 6;
> +	}
> +
> +      /* Compute the new offset and write it to the buffer.  */
> +      loffset = target - *to;
> +      loffset >>= 1;
> +
> +      if (mode == 1)
> +	{
> +	  int16_t soffset = loffset;
> +	  if (soffset != loffset)
> +	    return 1;
> +	  memcpy (buf+2, &soffset, 2);

"buf+2" -> "buf + 2".

> +	}
> +      else if (mode == 2)
> +	{
> +	  int32_t soffset = loffset;
> +	  if (soffset != loffset && is_64)
> +	    return 1;
> +	  memcpy (buf+2, &soffset, 4);

Same here.

[...]

> +static int
> +s390_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint,
> +				       CORE_ADDR tpaddr,
> +				       CORE_ADDR collector,
> +				       CORE_ADDR lockaddr,
> +				       ULONGEST orig_size,
> +				       CORE_ADDR *jump_entry,
> +				       CORE_ADDR *trampoline,
> +				       ULONGEST *trampoline_size,
> +				       unsigned char *jjump_pad_insn,
> +				       ULONGEST *jjump_pad_insn_size,
> +				       CORE_ADDR *adjusted_insn_addr,
> +				       CORE_ADDR *adjusted_insn_addr_end,
> +				       char *err)
> +{
> +  int i;
> +  int64_t loffset;
> +  int32_t offset;
> +  unsigned char jbuf[6] = { 0xc0, 0xf4, 0, 0, 0, 0 };	/* jg ... */
> +  CORE_ADDR buildaddr = *jump_entry;
> +#ifdef __s390x__
> +  struct regcache *regcache = get_thread_regcache (current_thread, 0);
> +  int is_64 = register_size (regcache->tdesc, 0) == 8;
> +  int is_zarch = is_64 || have_hwcap_s390_high_gprs;
> +  int has_vx = have_hwcap_s390_vx;
> +#else
> +  int is_64 = 0, is_zarch = 0, has_vx = 0;
> +#endif
> +  CORE_ADDR literals[4] = {
> +    tpaddr,
> +    tpoint,
> +    collector,
> +    lockaddr,
> +  };
> +
> +  /* First, store the GPRs.  */
> +  if (!is_zarch)
> +    append_insns (&buildaddr, sizeof s390_ft_entry_gpr_esa, s390_ft_entry_gpr_esa);
> +  else
> +    append_insns (&buildaddr, sizeof s390_ft_entry_gpr_zarch, s390_ft_entry_gpr_zarch);

Lines too long.  Also, non-reversed logic might be a bit clearer here
and in further such conditionals below.

[...]

> +
> +  /* Restore the GPRs.  */
> +  if (!is_zarch)
> +    append_insns (&buildaddr, sizeof s390_ft_exit_gpr_esa, s390_ft_exit_gpr_esa);
> +  else
> +    append_insns (&buildaddr, sizeof s390_ft_exit_gpr_zarch, s390_ft_exit_gpr_zarch);

Lines too long.

Otherwise the patch looks good to me.

Thanks,
Andreas


  reply	other threads:[~2016-03-14 16:19 UTC|newest]

Thread overview: 89+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-24 12:12 [PATCH 0/8] gdb/s390: Add regular and " Marcin Kościelnicki
2016-01-24 12:12 ` [PATCH 3/8] gdb/s390: Fill pseudo register agent expression hooks Marcin Kościelnicki
2016-02-07 14:01   ` Marcin Kościelnicki
2016-02-25 19:23     ` Marcin Kościelnicki
2016-03-04 10:42       ` Marcin Kościelnicki
2016-03-11  2:20         ` Marcin Kościelnicki
2016-03-11  9:58     ` Andreas Arnez
2016-03-11 10:04       ` Marcin Kościelnicki
2016-01-24 12:12 ` [PATCH 1/8] gdb: Add write_guessed_tracepoint_pc hook to gdbarch Marcin Kościelnicki
2016-01-26 14:58   ` Andreas Arnez
2016-02-07 13:59     ` [PATCH 1/8] gdb: Add supply_pseudo_pc " Marcin Kościelnicki
2016-02-16 18:28       ` Ulrich Weigand
2016-02-16 21:32         ` Marcin Kościelnicki
2016-02-18 10:35         ` [PATCH 1/2] gdb: Add guess_tracepoint_registers " Marcin Kościelnicki
2016-02-18 10:35           ` [PATCH 2/2] gdb/s390: Fill guess_tracepoint_registers hook Marcin Kościelnicki
2016-02-18 16:03             ` Ulrich Weigand
2016-02-18 16:36               ` [PATCH] " Marcin Kościelnicki
2016-02-18 16:48                 ` Ulrich Weigand
2016-02-18 16:58                   ` Marcin Kościelnicki
2016-02-18 11:38           ` [PATCH 1/2] gdb: Add guess_tracepoint_registers hook to gdbarch Luis Machado
2016-02-18 11:39             ` Marcin Kościelnicki
2016-02-18 11:45             ` [PATCH] " Marcin Kościelnicki
2016-02-18 15:40               ` Ulrich Weigand
2016-02-18 15:41                 ` Marcin Kościelnicki
2016-02-18 15:58                   ` Ulrich Weigand
2016-02-18 16:01                     ` Marcin Kościelnicki
2016-02-18 16:06                       ` Ulrich Weigand
2016-02-18 16:11                         ` Marcin Kościelnicki
2016-02-18 16:13                           ` Ulrich Weigand
2016-02-18 16:22                             ` Marcin Kościelnicki
2016-01-24 12:12 ` [PATCH 4/8] gdb/s390: Fill gen_return_address hook Marcin Kościelnicki
2016-02-07 14:02   ` Marcin Kościelnicki
2016-02-25 19:23     ` Marcin Kościelnicki
2016-03-04 10:42       ` Marcin Kościelnicki
2016-03-11 11:20     ` Andreas Arnez
2016-03-11 11:35       ` Marcin Kościelnicki
2016-03-11 12:18         ` Andreas Arnez
2016-03-11 12:26           ` Marcin Kościelnicki
2016-03-11 15:31             ` Andreas Arnez
2016-03-11 15:44               ` Pedro Alves
2016-03-11 16:45                 ` Andreas Arnez
2016-03-11 17:02                   ` Pedro Alves
2016-03-11 18:17                     ` Eli Zaretskii
2016-03-11 18:37                       ` Pedro Alves
2016-03-11 19:34                         ` Eli Zaretskii
2016-03-15 11:11                           ` Pedro Alves
2016-03-15 11:23                             ` Andreas Arnez
2016-03-15 11:30                               ` Pedro Alves
2016-03-11 18:07                   ` Eli Zaretskii
2016-03-13  9:53               ` Marcin Kościelnicki
2016-03-14 10:07                 ` Andreas Arnez
2016-01-24 12:12 ` [PATCH 5/8] gdbserver/s390: Switch on tracepoint support Marcin Kościelnicki
2016-02-07 14:04   ` Marcin Kościelnicki
2016-02-22  7:38     ` [PATCH] " Marcin Kościelnicki
2016-03-04 10:39       ` [PATCH v3] " Marcin Kościelnicki
2016-03-15 18:41         ` [PATCH v4] " Marcin Kościelnicki
2016-03-22  9:16           ` Marcin Kościelnicki
2016-03-23 15:25           ` Andreas Arnez
2016-03-24  1:15             ` Marcin Kościelnicki
2016-03-29 18:31               ` Ulrich Weigand
2016-03-29 21:40                 ` Marcin Kościelnicki
2016-03-29 21:40             ` [PATCH obv] gdb/NEWS: Add mention of s390*-linux tracepoints Marcin Kościelnicki
2016-03-30  2:49               ` Eli Zaretskii
2016-01-24 12:12 ` [PATCH 2/8] gdb/s390: Fill write_guessed_tracepoint_pc hook Marcin Kościelnicki
2016-01-26 18:12   ` Andreas Arnez
2016-01-26 19:26     ` Marcin Kościelnicki
2016-01-29 18:57       ` Andreas Arnez
2016-02-07 14:00         ` [PATCH 2/8] gdb/s390: Fill supply_pseudo_pc hook Marcin Kościelnicki
2016-01-24 12:12 ` [PATCH 8/8] gdbserver/s390: Add support for compiled agent expressions Marcin Kościelnicki
2016-03-04 10:41   ` [PATCH v2] " Marcin Kościelnicki
2016-03-14 16:19     ` Andreas Arnez
2016-01-24 12:12 ` [PATCH 7/8] gdb.trace: Bump tspeed.exp timeout to 600 seconds Marcin Kościelnicki
2016-01-26 18:17   ` Andreas Arnez
2016-01-29  9:53     ` [PATCH] " Marcin Kościelnicki
2016-02-12 11:20       ` Yao Qi
2016-02-18 18:54       ` Marcin Kościelnicki
2016-01-24 12:13 ` [PATCH 6/8] gdbserver/s390: Add fast tracepoint support Marcin Kościelnicki
2016-01-25 14:34   ` Antoine Tremblay
2016-02-19 13:41     ` Marcin Kościelnicki
2016-02-19 14:41       ` Antoine Tremblay
2016-03-04 10:40         ` [PATCH v2] " Marcin Kościelnicki
2016-03-14 16:19           ` Andreas Arnez [this message]
2016-03-14 16:25             ` Marcin Kościelnicki
2016-01-25 13:27 ` [PATCH 0/8] gdb/s390: Add regular and " Antoine Tremblay
2016-01-25 13:56 ` Pedro Alves
2016-01-25 14:28   ` Marcin Kościelnicki
2016-01-25 15:57     ` Pedro Alves
2016-01-25 16:03       ` Marcin Kościelnicki
2016-02-12 11:04 ` Marcin Kościelnicki

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=m3egbdxcac.fsf@oc1027705133.ibm.com \
    --to=arnez@linux.vnet.ibm.com \
    --cc=antoine.tremblay@ericsson.com \
    --cc=gdb-patches@sourceware.org \
    --cc=koriakin@0x04.net \
    /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