1. Feb 08, 2023
    • Himanshu Chauhan's avatar
      lib: utils: Mark only the largest region as reserved in FDT · 199189bd
      Himanshu Chauhan authored
      In commit 230278dc, RX and RW regions were marked separately.
      When the RW region grows (e.g. with more harts) and it isn't a
      power-of-two, sbi_domain_memregion_init will upgrade the region
      to the next power-of-two. This will make RX and RW both start
      at the same base address, like so (with 64 harts):
      Domain0 Region01 : 0x0000000080000000-0x000000008001ffff M: (R,X) S/U: ()
      Domain0 Region02 : 0x0000000080000000-0x00000000800fffff M: (R,W) S/U: ()
      
      This doesn't break the permission enforcement because of static
      priorities in PMP but makes the kernel complain about the regions
      overlapping each other. Like so:
      [    0.000000] OF: reserved mem: OVERLAP DETECTED!
      [    0.000000] mmode_resv0@80000000 (0x0000000080000000--0x0000000080020000) \
      	overlaps with mmode_resv1@80000000 (0x0000000080000000--0x0000000080100000)
      
      To fix this warning, among the multiple regions having same base
      address but different sizes, add only the largest region as reserved
      region during fdt fixup.
      
      Fixes: 230278dc
      
       (lib: sbi: Add separate entries for firmware RX and RW regions)
      Signed-off-by: default avatarHimanshu Chauhan <hchauhan@ventanamicro.com>
      Reviewed-by: default avatarAnup Patel <anup@brainfault.org>
      199189bd
    • Nick Hu's avatar
      lib: sbi_hsm: Use csr_set to restore the MIP · 84d15f4f
      Nick Hu authored
      
      
      If we use the csr_write to restore the MIP, we may clear the SEIP.
      In generic behavior of QEMU, if the pending bits of PLIC are set and we
      clear the SEIP, the QEMU may not set it back immediately. It may cause
      the interrupts won't be handled anymore until the new interrupts arrived
      and QEMU set the bits back.
      
      Signed-off-by: default avatarNick Hu <nick.hu@sifive.com>
      Signed-off-by: default avatarJim Shu <jim.shu@sifive.com>
      Reviewed-by: default avatarAnup Patel <anup@brainfault.org>
      84d15f4f
    • Nick Hu's avatar
      firmware: Not to clear all the MIP · 8050081f
      Nick Hu authored
      
      
      In generic behavior of QEMU, if the pending bits of PLIC are still set and
      we clear the SEIP, the QEMU may not set the SEIP back immediately and the
      interrupt may not be handled anymore until the new interrupts arrived and
      QEMU set the SEIP back which is a generic behavior in QEMU.
      
      Signed-off-by: default avatarNick Hu <nick.hu@sifive.com>
      Signed-off-by: default avatarJim Shu <jim.shu@sifive.com>
      Reviewed-by: default avatarAnup Patel <anup@brainfault.org>
      8050081f
  2. Jan 27, 2023
  3. Jan 24, 2023
    • Samuel Holland's avatar
      platform: generic: allwinner: Advertise nonretentive suspend · c45992cc
      Samuel Holland authored
      
      
      Add D1's nonretentive suspend state to the devicetree so S-mode software
      knows about it and can use it.
      
      Latency and power measurements were taken on an Allwinner Nezha board:
       - Entry latency was measured from the beginning of sbi_ecall_handler()
         to before the call to wfi() in sun20i_d1_hart_suspend().
       - Exit latency was measured from the beginning of sbi_init() to before
         the call to sbi_hart_switch_mode() in init_warmboot().
       - There was a 17.5 mW benefit from non-retentive suspend compared to
         WFI, with a 170 mW cost during the 107 us entry/exit period. This
         provides a break-even point around 1040 us. Residency includes entry
         latency, so round this up to 1100 us.
       - The hardware power sequence latency (after the WFI) is assumed to be
         negligible, so set the wakeup latency to the exit latency.
      
      Reviewed-by: default avatarAnup Patel <anup@brainfault.org>
      Signed-off-by: default avatarSamuel Holland <samuel@sholland.org>
      c45992cc
    • Samuel Holland's avatar
      lib: utils: Add fdt_add_cpu_idle_states() helper function · 33bf9174
      Samuel Holland authored
      
      
      Since the availability and latency properties of CPU idle states depend
      on the specific SBI HSM implementation, it is appropriate that the idle
      states are added to the devicetree at runtime by that implementation.
      
      This helper function adds a platform-provided array of idle states to
      the devicetree, following the SBI idle state binding.
      
      Reviewed-by: default avatarAnup Patel <anup@brainfault.org>
      Signed-off-by: default avatarSamuel Holland <samuel@sholland.org>
      33bf9174
  4. Jan 23, 2023
  5. Jan 22, 2023
  6. Jan 13, 2023
    • Samuel Holland's avatar
      platform: generic: allwinner: Fix PLIC array bounds · da5594bf
      Samuel Holland authored
      The two referenced commits passed incorrect bounds to the PLIC save/
      restore functions, causing out-of-bounds memory access. The functions
      expect "num" to be the 1-based number of interrupt sources, equivalent
      to the "riscv,ndev" devicetree property. Thus, "num" must be strictly
      smaller than the 0-based size of the array storing the register values.
      
      However, the referenced commits incorrectly passed in the unmodified
      size of the array as "num". Fix this by reducing PLIC_SOURCES (matching
      "riscv,ndev" on this platform), while keeping the same array sizes.
      
      Addresses-Coverity-ID: 1530251 ("Out-of-bounds access")
      Addresses-Coverity-ID: 1530252 ("Out-of-bounds access")
      Fixes: 8509e46c ("lib: utils/irqchip: plic: Ensure no out-of-bound access in priority save/restore helpers")
      Fixes: 9a2eeb4a
      
       ("lib: utils/irqchip: plic: Ensure no out-of-bound access in context save/restore helpers")
      Signed-off-by: default avatarSamuel Holland <samuel@sholland.org>
      Reviewed-by: default avatarAnup Patel <anup@brainfault.org>
      da5594bf
  7. Jan 09, 2023
  8. Jan 07, 2023
  9. Jan 06, 2023
  10. Dec 24, 2022