From: Simon Marchi <simon.marchi@polymtl.ca>
To: Trent Piepho <tpiepho@impinj.com>
Cc: gdb-patches@sourceware.org, Alan Hayward <alan.hayward@arm.com>
Subject: Re: [PATCH v3 2/2] Check thumb2 load/store and cache hit addressing mode
Date: Tue, 02 Oct 2018 17:40:00 -0000 [thread overview]
Message-ID: <d0e57383174df5d64708deb8cc7835bc@polymtl.ca> (raw)
In-Reply-To: <20181001222544.4307-2-tpiepho@impinj.com>
This is a bit out of my comfort zone. I'm reading the code with the
reference manual on the side, and don't see the mapping. I'd prefer if
somebody from ARM took a look. In the mean time, could you point me to
the relevant sections in the manual for this patch?
I'll just note some formatting comments for now.
On 2018-10-01 18:26, Trent Piepho wrote:
> There are a number of different addressing forms available for these
> thumb2 instructions. However, not all modes are valid for all
> instructions, nor is every possible bit pattern a valid mode.
>
> PLD/PLI are not that complex so verify that one of the valid modes for
> those instructions was used.
>
> Other instructions are checked for a valid mode encoding, but not
> necessary that the particular mode is valid for the full instruction.
>
> gdb/ChangeLog:
>
> 2018-10-01 Trent Piepho <tpiepho@impinj.com>
>
> * arm-tdep.c (thumb2_ld_mem_hint_mode): Decode addressing mode.
> (thumb2_record_ld_mem_hints): Check addressing mode.
> ---
>
> Changes from v2:
> * Fix logic flaw that allowed invalid non PLI/D instructions to be
> considered PLI/D instructions.
>
> gdb/arm-tdep.c | 69
> +++++++++++++++++++++++++++++++++++++++++++++++++++-------
> 1 file changed, 61 insertions(+), 8 deletions(-)
>
> diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
> index 90936ada8e..f7b51d4805 100644
> --- a/gdb/arm-tdep.c
> +++ b/gdb/arm-tdep.c
> @@ -12661,6 +12661,51 @@ thumb2_record_str_single_data
> (insn_decode_record *thumb2_insn_r)
> return ARM_RECORD_SUCCESS;
> }
>
> +
> +/* Decode addressing mode of thumb2 load and store single data item,
> + and memory hints */
End the comment with a dot and two spaces.
> +
> +static int
> +thumb2_ld_mem_hint_mode (insn_decode_record *thumb2_insn_r)
> +{
> + /* Check Rn = 0b1111 */
> + if (bits (thumb2_insn_r->arm_insn, 16, 19) == 0xf)
> + {
> + if (bit (thumb2_insn_r->arm_insn, 20) == 1)
> + return 1; /* PC +/- imm12 */
> + else
> + return -1; /* reserved */
> + }
> +
> + /* Check U = 1 */
> + if (bit (thumb2_insn_r->arm_insn, 23) == 1)
> + return 2; /* Rn + imm2 */
> +
> + /* Check op2[5] = 0 */
> + if (bit (thumb2_insn_r->arm_insn, 11) == 0)
> + {
> + if (bits (thumb2_insn_r->arm_insn, 6, 10) == 0)
> + return 7; /* Rn + shifted register */
> + return -1; /* reserved */
> + }
> +
> + switch (bits (thumb2_insn_r->arm_insn, 8, 10))
> + {
> + case 0x4:
> + return 3; /* Rn - imm8 */
> + case 0x6:
> + return 4; /* Rn + imm8, User privilege */
> + case 0x1:
> + case 0x3:
> + return 5; /* Rn post-indexed by +/- imm8 */
> + case 0x5:
> + case 0x7:
> + return 6; /* Rn pre-indexed by +/- imm8 */
> + default:
> + return -1; /* reserved */
Do these modes have names? Could we define an enum instead of using
magic numbers?
> + }
> +}
> +
> /* Handler for thumb2 load memory hints instructions. */
>
> static int
> @@ -12668,27 +12713,35 @@ thumb2_record_ld_mem_hints
> (insn_decode_record *thumb2_insn_r)
> {
> uint32_t record_buf[8];
> uint32_t reg_rt, reg_rn;
> + uint32_t mode;
>
> reg_rt = bits (thumb2_insn_r->arm_insn, 12, 15);
> reg_rn = bits (thumb2_insn_r->arm_insn, 16, 19);
> + mode = thumb2_ld_mem_hint_mode(thumb2_insn_r);
>
> + /* This does not check every possible addressing mode + data size
> + * combination for validity */
Remove the asterisk at the beginning of the second line and finish the
sentence with a period and two spaces:
/* This does not check every possible addressing mode + data size
combination for validity. */
Thanks,
Simon
next prev parent reply other threads:[~2018-10-02 17:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-01 22:26 [PATCH v3 1/2] Record ARM THUMB2 PLD/PLI cache instructions Trent Piepho
2018-10-01 22:26 ` [PATCH v3 2/2] Check thumb2 load/store and cache hit addressing mode Trent Piepho
2018-10-02 17:40 ` Simon Marchi [this message]
2018-10-03 1:01 ` Trent Piepho
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=d0e57383174df5d64708deb8cc7835bc@polymtl.ca \
--to=simon.marchi@polymtl.ca \
--cc=alan.hayward@arm.com \
--cc=gdb-patches@sourceware.org \
--cc=tpiepho@impinj.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).