[PW_SID:1085386] RISC-V: KVM: AIA: Convert HGEI management to fully per-HART#1812
[PW_SID:1085386] RISC-V: KVM: AIA: Convert HGEI management to fully per-HART#1812linux-riscv-bot wants to merge 6 commits into
Conversation
…_TYPED_FUNC_START After commit 67bdd7b ("riscv: Split out measure_cycles() for reuse") and commit c03ad15 ("riscv: Reuse measure_cycles() in check_vector_unaligned_access()"), there are CFI failure when booting kernels with CONFIG_CFI=y: CFI failure at measure_cycles+0x38/0xe0 (target: __riscv_copy_words_unaligned+0x0/0x50; expected type: ...) CFI failure at measure_cycles+0x38/0xe0 (target: __riscv_copy_vec_words_unaligned+0x0/0x24; expected type: ...) The __riscv_copy_*_unaligned() functions are now called indirectly but they are not defined with SYM_TYPED_FUNC_START, which is required for assembly functions called indirectly from C to pass CFI checking. Switch to SYM_TYPED_FUNC_START to clear up the CFI failures. Fixes: 67bdd7b ("riscv: Split out measure_cycles() for reuse") Fixes: c03ad15 ("riscv: Reuse measure_cycles() in check_vector_unaligned_access()") Signed-off-by: Nathan Chancellor <nathan@kernel.org> Reviewed-by: Sami Tolvanen <samitolvanen@google.com> Reviewed-by: Nam Cao <namcao@linutronix.de> Link: https://patch.msgid.link/20260406-measure_cycles-cfi-failure-v1-1-03e0234ae02f@kernel.org Signed-off-by: Paul Walmsley <pjw@kernel.org>
Previously the number of Hypervisor Guest External Interrupt (HGEI)
lines was stored in a single global variable `kvm_riscv_aia_nr_hgei`
and assumed to be the same for all HARTs. This assumption does not
hold on heterogeneous RISC-V SoCs where different cores may expose
different HGEIE CSR widths.
Introduce `nr_hgei` field into the per-CPU `struct aia_hgei_control`
and probe the actual supported HGEI count for the current HART in
`kvm_riscv_aia_enable()` using the standard RISC-V CSR probe
technique:
csr_write(CSR_HGEIE, -1UL);
nr = fls_long(csr_read(CSR_HGEIE));
if (nr)
nr--;
All HGEI allocation, free and disable paths (`kvm_riscv_aia_free_hgei()`,
`kvm_riscv_aia_disable()`, etc.) now use the per-CPU value instead of
the global one.
The early global `kvm_riscv_aia_nr_hgei` is kept only for deciding
whether SGEI interrupt registration is needed; the real per-HART
initialization of lock and free_bitmap is moved to enable time.
This makes KVM AIA robust on big.LITTLE-style and multi-vendor
asymmetric platforms.
Signed-off-by: Guo Ren (Alibaba DAMO Academy) <guoren@kernel.org>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Now that HGEI line management is fully per-CPU (via struct aia_hgei_control::nr_hgei), the global `kvm_riscv_aia_nr_hgei` is no longer needed. Replace it with a simple `bool kvm_riscv_aia_hgei_enabled` that only indicates whether HGEI support is available at all. Signed-off-by: Guo Ren (Alibaba DAMO Academy) <guoren@kernel.org> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
With the recent KVM AIA per-HART HGEI conversion, the global nr_guest_files is no longer appropriate. Different HARTs in heterogeneous SoCs may have different numbers of guest interrupt files. Move `nr_guest_files` from `struct imsic_global_config` to `struct imsic_local_config`, and compute it per-CPU in imsic_setup_state() based on the actual MMIO guest file region size. Update the related comment to reflect that KVM now uses the per-HART value. This eliminates the last global assumption about guest files and completes the per-HART conversion series for RISC-V AIA/IMSIC. Signed-off-by: Guo Ren (Alibaba DAMO Academy) <guoren@kernel.org> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
…I count Now that `nr_guest_files` has been moved to `struct imsic_local_config` and is computed per-HART, KVM must respect the actual number of guest interrupt files available on each HART when setting up HGEI. In `kvm_riscv_aia_enable()`: - Retrieve the per-CPU IMSIC local config - Take `min(hgctrl->nr_hgei, lc->nr_guest_files)` as the final usable HGEI count for this HART - Use the result to initialize `free_bitmap` This ensures correct HGEI allocation on heterogeneous RISC-V SoCs where different cores may have different IMSIC guest file counts, and completes the per-HART conversion series. Signed-off-by: Guo Ren (Alibaba DAMO Academy) <guoren@kernel.org> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
|
Patch 1: "[V2,1/4] RISC-V: KVM: AIA: Make HGEI number and management fully per-CPU" |
|
Patch 1: "[V2,1/4] RISC-V: KVM: AIA: Make HGEI number and management fully per-CPU" |
|
Patch 1: "[V2,1/4] RISC-V: KVM: AIA: Make HGEI number and management fully per-CPU" |
|
Patch 1: "[V2,1/4] RISC-V: KVM: AIA: Make HGEI number and management fully per-CPU" |
|
Patch 1: "[V2,1/4] RISC-V: KVM: AIA: Make HGEI number and management fully per-CPU" |
|
Patch 1: "[V2,1/4] RISC-V: KVM: AIA: Make HGEI number and management fully per-CPU" |
|
Patch 1: "[V2,1/4] RISC-V: KVM: AIA: Make HGEI number and management fully per-CPU" |
|
Patch 1: "[V2,1/4] RISC-V: KVM: AIA: Make HGEI number and management fully per-CPU" |
|
Patch 1: "[V2,1/4] RISC-V: KVM: AIA: Make HGEI number and management fully per-CPU" |
|
Patch 1: "[V2,1/4] RISC-V: KVM: AIA: Make HGEI number and management fully per-CPU" |
|
Patch 1: "[V2,1/4] RISC-V: KVM: AIA: Make HGEI number and management fully per-CPU" |
|
Patch 1: "[V2,1/4] RISC-V: KVM: AIA: Make HGEI number and management fully per-CPU" |
|
Patch 2: "[V2,2/4] RISC-V: KVM: AIA: Replace global HGEI count with simple enabled bool" |
|
Patch 2: "[V2,2/4] RISC-V: KVM: AIA: Replace global HGEI count with simple enabled bool" |
|
Patch 2: "[V2,2/4] RISC-V: KVM: AIA: Replace global HGEI count with simple enabled bool" |
|
Patch 2: "[V2,2/4] RISC-V: KVM: AIA: Replace global HGEI count with simple enabled bool" |
|
Patch 2: "[V2,2/4] RISC-V: KVM: AIA: Replace global HGEI count with simple enabled bool" |
|
Patch 2: "[V2,2/4] RISC-V: KVM: AIA: Replace global HGEI count with simple enabled bool" |
|
Patch 2: "[V2,2/4] RISC-V: KVM: AIA: Replace global HGEI count with simple enabled bool" |
|
Patch 2: "[V2,2/4] RISC-V: KVM: AIA: Replace global HGEI count with simple enabled bool" |
|
Patch 2: "[V2,2/4] RISC-V: KVM: AIA: Replace global HGEI count with simple enabled bool" |
|
Patch 2: "[V2,2/4] RISC-V: KVM: AIA: Replace global HGEI count with simple enabled bool" |
|
Patch 2: "[V2,2/4] RISC-V: KVM: AIA: Replace global HGEI count with simple enabled bool" |
|
Patch 2: "[V2,2/4] RISC-V: KVM: AIA: Replace global HGEI count with simple enabled bool" |
|
Patch 3: "[V2,3/4] irqchip/riscv-imsic: Move nr_guest_files to per-HART local config" |
|
Patch 3: "[V2,3/4] irqchip/riscv-imsic: Move nr_guest_files to per-HART local config" |
|
Patch 3: "[V2,3/4] irqchip/riscv-imsic: Move nr_guest_files to per-HART local config" |
|
Patch 3: "[V2,3/4] irqchip/riscv-imsic: Move nr_guest_files to per-HART local config" |
|
Patch 3: "[V2,3/4] irqchip/riscv-imsic: Move nr_guest_files to per-HART local config" |
|
Patch 3: "[V2,3/4] irqchip/riscv-imsic: Move nr_guest_files to per-HART local config" |
|
Patch 3: "[V2,3/4] irqchip/riscv-imsic: Move nr_guest_files to per-HART local config" |
|
Patch 3: "[V2,3/4] irqchip/riscv-imsic: Move nr_guest_files to per-HART local config" |
|
Patch 3: "[V2,3/4] irqchip/riscv-imsic: Move nr_guest_files to per-HART local config" |
|
Patch 3: "[V2,3/4] irqchip/riscv-imsic: Move nr_guest_files to per-HART local config" |
|
Patch 3: "[V2,3/4] irqchip/riscv-imsic: Move nr_guest_files to per-HART local config" |
|
Patch 3: "[V2,3/4] irqchip/riscv-imsic: Move nr_guest_files to per-HART local config" |
|
Patch 4: "[V2,4/4] RISC-V: KVM: AIA: Use per-HART IMSIC guest files to compute final HGEI count" |
|
Patch 4: "[V2,4/4] RISC-V: KVM: AIA: Use per-HART IMSIC guest files to compute final HGEI count" |
|
Patch 4: "[V2,4/4] RISC-V: KVM: AIA: Use per-HART IMSIC guest files to compute final HGEI count" |
|
Patch 4: "[V2,4/4] RISC-V: KVM: AIA: Use per-HART IMSIC guest files to compute final HGEI count" |
|
Patch 4: "[V2,4/4] RISC-V: KVM: AIA: Use per-HART IMSIC guest files to compute final HGEI count" |
|
Patch 4: "[V2,4/4] RISC-V: KVM: AIA: Use per-HART IMSIC guest files to compute final HGEI count" |
|
Patch 4: "[V2,4/4] RISC-V: KVM: AIA: Use per-HART IMSIC guest files to compute final HGEI count" |
|
Patch 4: "[V2,4/4] RISC-V: KVM: AIA: Use per-HART IMSIC guest files to compute final HGEI count" |
|
Patch 4: "[V2,4/4] RISC-V: KVM: AIA: Use per-HART IMSIC guest files to compute final HGEI count" |
|
Patch 4: "[V2,4/4] RISC-V: KVM: AIA: Use per-HART IMSIC guest files to compute final HGEI count" |
|
Patch 4: "[V2,4/4] RISC-V: KVM: AIA: Use per-HART IMSIC guest files to compute final HGEI count" |
|
Patch 4: "[V2,4/4] RISC-V: KVM: AIA: Use per-HART IMSIC guest files to compute final HGEI count" |
f190ec6 to
2c3b264
Compare
PR for series 1085386 applied to workflow__riscv__fixes
Name: RISC-V: KVM: AIA: Convert HGEI management to fully per-HART
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=1085386
Version: 2