|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v2] xen: gic-v3: Introduce CONFIG_GICV3_NR_LRS
Hi Ayan, On 18/03/2026 23:09, Ayan Kumar Halder wrote: One key requirement of Xen functional safety is to reduce the number of lines of code to be safety certified. Besides, a safety certified Xen requires a static hardware configuration to be defined. This static hardware configuration is described as per the test hardware/emulator hardware configuration against which Xen is verified. Introduce GICV3_NR_LRS with the two aims in mind: Out of interest, why is this limited to GICv3? 1. User should set the number of GICV3 list registers as per the test hardware so that the unwanted code can be removed using GCC's dead code elimination or preprocessor's config. We discussed this offline, I am not fully convinced you can rely on dead code elimination to always remove the BUG() in gicv3_ich_read_lr(). If you want to rely on dead code eliminitation, then you will want to call a function which have a prototype defined but not implemented (similar to what we do for bitops with __bad_atomic_read()) which would fail a link time if the compiler didn't remove the code. 2. By doing #1, one can ensure that there is no untested code due to unsupported hardware platform and thus there is no safety impact due to untested code. However if the user does not set GICV3_NR_LRS, then it is set to 0. Thus Xen will fallback to the default scenario (i.e. read the hardware register to determine the number of LRS). 1. In gicv3_save_lrs()/gicv3_restore_lrs(), use the number of list registers from GICV3_NR_LRS (if defined) instead of gicv3_info.nr_lrs. This ensures that if the hardware does not support more than 4 LRs (for example), the code accessing LR 4-15 is never reached. The compiler can eliminate the unsupported cases as the switch case uses a constant conditional. 2. RAZ/WI for the unsupported LRs. Signed-off-by: Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx> Signed-off-by: Michal Orzel <michal.orzel@xxxxxxx> --- Changelog: v1 - 1. s/lrs/LRS 2. Implement RAZ/WI instead of panic Few comments which were not addressed 1. Do "gicv3_info.nr_lrs to LRS" in gicv3_hyp_init() and keep the code unchanged in gicv3_save_lrs()/gicv3_restore_lrs() -- This prevents the compiler from doing dead code elimination as the switch condition cannot be evaluated at compile time. I am not sure how to get around this issue. xen/arch/arm/Kconfig | 9 +++++++++ xen/arch/arm/gic-v3.c | 14 ++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig index 2f2b501fda..6540013f97 100644 --- a/xen/arch/arm/Kconfig +++ b/xen/arch/arm/Kconfig @@ -276,6 +276,15 @@ config PCI_PASSTHROUGHendmenu +config GICV3_NR_LRS+ int "Number of GICv3 Link Registers supported" if EXPERT Supported by who? The hardware? Xen? Asking, because I could forsee an integrator wanted to limit the number of LRs to something smaller than what the HW supports (in a lot of cases, 2 LRs is sufficient). + depends on GICV3 + range 0 16 + default 0 + help + Controls the number of Link registers to be accessed. + Keep it set to 0 to use a value obtained from a hardware register. I still strongly think that if GICV3_NR_LRS is set, then it needs to be checked against the value read by the hardware
IMHO, LRS is a little bit vague. What about MAX_LRS? Or maybe NR_LRS? /* AFAIU, this path is really not meant to happen. So I don't think we want to silently ignore the write as it would mean an interrupt is missing. I think in debug build, we probably want to use ASSERT_UNREACHABLE(). If we want something for production as well, then we could instead use WARN(). Cheers, -- Julien Grall
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |