qemu-riscv
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/7] hw/intc: sifive_plic: Cleanup the write function


From: Richard Henderson
Subject: Re: [PATCH 2/7] hw/intc: sifive_plic: Cleanup the write function
Date: Wed, 8 Dec 2021 09:30:22 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0

On 12/7/21 10:42 PM, Alistair Francis wrote:
From: Alistair Francis <alistair.francis@wdc.com>

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
---
  hw/intc/sifive_plic.c | 82 +++++++++++++++++--------------------------
  1 file changed, 33 insertions(+), 49 deletions(-)

diff --git a/hw/intc/sifive_plic.c b/hw/intc/sifive_plic.c
index 35f097799a..c1fa689868 100644
--- a/hw/intc/sifive_plic.c
+++ b/hw/intc/sifive_plic.c
@@ -33,6 +33,17 @@
#define RISCV_DEBUG_PLIC 0 +static bool addr_between(uint32_t addr, uint32_t base, uint32_t num)
+{
+    uint32_t end = base + num;
+
+    if (addr >= base && addr < end) {
+        return true;
+    }
+
+    return false;
+}

It may well not matter for your use case, but this will fail for addresses at the end of the range. Better as

    return addr >= base && addr - base < num;


r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]