[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 01/13] hw/intc/arm_gicv3_its: Fix event ID bounds checks
From: |
Peter Maydell |
Subject: |
Re: [PATCH v2 01/13] hw/intc/arm_gicv3_its: Fix event ID bounds checks |
Date: |
Fri, 28 Jan 2022 10:50:48 +0000 |
On Fri, 28 Jan 2022 at 01:33, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> On 1/12/22 04:10, Peter Maydell wrote:
> > In process_its_cmd() and process_mapti() we must check the
> > event ID against a limit defined by the size field in the DTE,
> > which specifies the number of ID bits minus one. Convert
> > this code to our num_foo convention:
> > * change the variable names
> > * use uint64_t and 1ULL when calculating the number
> > of valid event IDs, because DTE.SIZE is 5 bits and
> > so num_eventids may be up to 2^32
> > * fix the off-by-one error in the comparison
> >
> > Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> > ---
> > hw/intc/arm_gicv3_its.c | 18 ++++++++++--------
> > 1 file changed, 10 insertions(+), 8 deletions(-)
>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>
>
> > + num_eventids = 1ULL << (FIELD_EX64(dte, DTE, SIZE) + 1);
>
> Could be written 2 << N, instead of 1 << (N + 1).
It could, but the spec defines the field as containing
"number of supported bits, minus 1", so I think that
using an expression that matches that is clearer.
Aside: clang optimizes both of these expressions to
the same thing; gcc does not:
https://godbolt.org/z/nsz4Mdxhq
(not that it will make a perf difference we care about here).
-- PMM
- [PATCH v2 00/13] arm gicv3 ITS: Various bug fixes and refactorings, Peter Maydell, 2022/01/11
- [PATCH v2 06/13] hw/intc/arm_gicv3_its: Fix return codes in process_its_cmd(), Peter Maydell, 2022/01/11
- [PATCH v2 08/13] hw/intc/arm_gicv3_its: Fix return codes in process_mapti(), Peter Maydell, 2022/01/11
- [PATCH v2 04/13] hw/intc/arm_gicv3_its: Don't use data if reading command failed, Peter Maydell, 2022/01/11
- [PATCH v2 02/13] hw/intc/arm_gicv3_its: Convert int ID check to num_intids convention, Peter Maydell, 2022/01/11
- [PATCH v2 01/13] hw/intc/arm_gicv3_its: Fix event ID bounds checks, Peter Maydell, 2022/01/11
- [PATCH v2 03/13] hw/intc/arm_gicv3_its: Fix handling of process_its_cmd() return value, Peter Maydell, 2022/01/11
- [PATCH v2 05/13] hw/intc/arm_gicv3_its: Use enum for return value of process_* functions, Peter Maydell, 2022/01/11
- [PATCH v2 07/13] hw/intc/arm_gicv3_its: Refactor process_its_cmd() to reduce nesting, Peter Maydell, 2022/01/11
- [PATCH v2 10/13] hw/intc/arm_gicv3_its: Fix return codes in process_mapd(), Peter Maydell, 2022/01/11
- [PATCH v2 09/13] hw/intc/arm_gicv3_its: Fix return codes in process_mapc(), Peter Maydell, 2022/01/11
- [PATCH v2 11/13] hw/intc/arm_gicv3_its: Factor out "find address of table entry" code, Peter Maydell, 2022/01/11
- [PATCH v2 13/13] hw/intc/arm_gicv3_its: Range-check ICID before indexing into collection table, Peter Maydell, 2022/01/11