public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Luis Machado <luis.machado@linaro.org>
To: gdb-patches@sourceware.org
Subject: [PATCH] [GDB,AArch64] Fix off-by-one when calculating tag granules.
Date: Tue, 11 May 2021 10:20:26 -0300	[thread overview]
Message-ID: <20210511132026.3673157-1-luis.machado@linaro.org> (raw)

When we want to fetch tags from a memory range, the last address in that
range is not included.

There is a off-by-one error in aarch64_mte_get_tag_granules, which this
patch fixes.

gdb/ChangeLog:

YYYY-MM-DD  Luis Machado  <luis.machado@linaro.org>

	* arch/aarch64-mte-linux.c (aarch64_mte_get_tag_granules): Don't
	include the last address in the range.
---
 gdb/arch/aarch64-mte-linux.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gdb/arch/aarch64-mte-linux.c b/gdb/arch/aarch64-mte-linux.c
index 959c0247ed5..7c2ae9a7058 100644
--- a/gdb/arch/aarch64-mte-linux.c
+++ b/gdb/arch/aarch64-mte-linux.c
@@ -31,9 +31,10 @@ aarch64_mte_get_tag_granules (CORE_ADDR addr, size_t len, size_t granule_size)
   /* Start address */
   CORE_ADDR s_addr = align_down (addr, granule_size);
   /* End address */
-  CORE_ADDR e_addr = align_down (addr + len, granule_size);
+  CORE_ADDR e_addr = align_down (addr + len - 1, granule_size);
 
-  /* We always have at least 1 granule.  */
+  /* We always have at least 1 granule because len is non-zero at this
+     point.  */
   return 1 + (e_addr - s_addr) / granule_size;
 }
 
-- 
2.25.1


             reply	other threads:[~2021-05-11 13:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-11 13:20 Luis Machado [this message]
2021-05-13 10:50 ` Alan Hayward
2021-05-13 10:56   ` Luis Machado
2021-05-13 11:24     ` Alan Hayward
2021-05-13 11:50       ` Luis Machado
2021-05-13 12:59         ` Alan Hayward
2021-05-13 13:15           ` Luis Machado
2021-05-13 10:50 ` Alan Hayward

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=20210511132026.3673157-1-luis.machado@linaro.org \
    --to=luis.machado@linaro.org \
    --cc=gdb-patches@sourceware.org \
    /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).