From: Eric Auger <eric.auger@redhat.com>
To: eric.auger.pro@gmail.com, eric.auger@redhat.com,
qemu-devel@nongnu.org, qemu-arm@nongnu.org,
peter.maydell@linaro.org, berrange@redhat.com,
skolothumtho@nvidia.com, nicolinc@nvidia.com, nathanc@nvidia.com
Subject: [PATCH v2 1/5] hw/arm/smmuv3: Fix off-by-one bug in alignment strtab mask
Date: Wed, 1 Jul 2026 11:11:38 +0200 [thread overview]
Message-ID: <20260701091209.2860306-2-eric.auger@redhat.com> (raw)
In-Reply-To: <20260701091209.2860306-1-eric.auger@redhat.com>
The stream table base address needs to be aligned to its size.
With FMT == 0, the spec says the linear stream table base address
musst have ADDR[LOG2SIZE + 5:0] = 0. STE are 64B
With FMT == 1, ADDR[MAX(5, (LOG2SIZE - SPLIT - 1 + 3)):0] = 0.
L1 descriptors are 8B.
MAKE_64BIT_MASK() second argument is a size and not a shift, so
there is an off-by-one computation.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
hw/arm/smmuv3.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
index 5e5a6a960c9..38aba9c0af9 100644
--- a/hw/arm/smmuv3.c
+++ b/hw/arm/smmuv3.c
@@ -664,7 +664,7 @@ int smmu_find_ste(SMMUv3State *s, uint32_t sid, STE *ste, SMMUEventInfo *event)
{
dma_addr_t addr, strtab_base;
uint32_t log2size;
- int strtab_size_shift;
+ int strtab_size;
int ret;
trace_smmuv3_find_ste(sid, s->features, s->sid_split);
@@ -685,9 +685,9 @@ int smmu_find_ste(SMMUv3State *s, uint32_t sid, STE *ste, SMMUEventInfo *event)
* Align strtab base address to table size. For this purpose, assume it
* is not bounded by SMMU_IDR1_SIDSIZE.
*/
- strtab_size_shift = MAX(5, (int)log2size - s->sid_split - 1 + 3);
+ strtab_size = MAX(6, (int)log2size - s->sid_split + 3);
strtab_base = s->strtab_base & SMMU_BASE_ADDR_MASK &
- ~MAKE_64BIT_MASK(0, strtab_size_shift);
+ ~MAKE_64BIT_MASK(0, strtab_size);
l1_ste_offset = sid >> s->sid_split;
l2_ste_offset = sid & ((1 << s->sid_split) - 1);
l1ptr = (dma_addr_t)(strtab_base + l1_ste_offset * sizeof(l1std));
@@ -729,9 +729,9 @@ int smmu_find_ste(SMMUv3State *s, uint32_t sid, STE *ste, SMMUEventInfo *event)
}
addr = l2ptr + l2_ste_offset * sizeof(*ste);
} else {
- strtab_size_shift = log2size + 5;
+ strtab_size = log2size + 6;
strtab_base = s->strtab_base & SMMU_BASE_ADDR_MASK &
- ~MAKE_64BIT_MASK(0, strtab_size_shift);
+ ~MAKE_64BIT_MASK(0, strtab_size);
addr = strtab_base + sid * sizeof(*ste);
}
--
2.53.0
next prev parent reply other threads:[~2026-07-01 9:17 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-01 9:11 [PATCH v2 0/5] SMMUV3: STE lookup fixes Eric Auger
2026-07-01 9:11 ` Eric Auger [this message]
2026-07-03 9:09 ` [PATCH v2 1/5] hw/arm/smmuv3: Fix off-by-one bug in alignment strtab mask Shameer Kolothum Thodi
2026-07-03 9:20 ` Philippe Mathieu-Daudé
2026-07-01 9:11 ` [PATCH v2 2/5] hw/arm/smmuv3: Sanitize SMMU_S_STRTAB_BASE_CFG.SPLIT Eric Auger
2026-07-01 9:11 ` [PATCH v2 3/5] hw/arm/smmuv3: Sanitize SMMU_S_STRTAB_BASE_CFG.LOG2SIZE Eric Auger
2026-07-03 9:22 ` Shameer Kolothum Thodi
2026-07-03 12:54 ` Peter Maydell
2026-07-07 8:30 ` Eric Auger
2026-07-01 9:11 ` [PATCH v2 4/5] hw/arm/smmuv3: Check L1STD.SPAN Eric Auger
2026-07-03 9:35 ` Shameer Kolothum Thodi
2026-07-01 9:11 ` [PATCH v2 5/5] hw/arm/smmuv3: Enforce alignment of L2Ptr according to the span Eric Auger
2026-07-03 9:37 ` Shameer Kolothum Thodi
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=20260701091209.2860306-2-eric.auger@redhat.com \
--to=eric.auger@redhat.com \
--cc=berrange@redhat.com \
--cc=eric.auger.pro@gmail.com \
--cc=nathanc@nvidia.com \
--cc=nicolinc@nvidia.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=skolothumtho@nvidia.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.