The branch main has been updated by br:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=c7e0b94b7de76fec57f4ac25e02de39088ee77d3

commit c7e0b94b7de76fec57f4ac25e02de39088ee77d3
Author:     Ruslan Bukin <b...@freebsd.org>
AuthorDate: 2025-02-03 11:48:18 +0000
Commit:     Ruslan Bukin <b...@freebsd.org>
CommitDate: 2025-02-03 11:49:48 +0000

    riscv vmm: consider hart_mask_base argument in the SBI IPI handler.
    
    From the spec:
    
    Any SBI function, requiring a hart mask, must take the following
    two arguments:
    
    - unsigned long hart_mask is a scalar bit-vector containing hartids
    - unsigned long hart_mask_base is the starting hartid from which the
      bit-vector must be computed.
    
    hart_mask_base can be set to -1 to indicate that hart_mask shall be
    ignored and all available harts must be considered.
    
    Differential Revision:  https://reviews.freebsd.org/D48717
---
 sys/riscv/vmm/vmm_sbi.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sys/riscv/vmm/vmm_sbi.c b/sys/riscv/vmm/vmm_sbi.c
index 586eb7c4d41c..3ba90e349b3c 100644
--- a/sys/riscv/vmm/vmm_sbi.c
+++ b/sys/riscv/vmm/vmm_sbi.c
@@ -154,6 +154,7 @@ vmm_sbi_handle_ipi(struct vcpu *vcpu, struct hypctx *hypctx)
        cpuset_t active_cpus;
        struct hyp *hyp;
        uint64_t hart_mask;
+       uint64_t hart_mask_base;
        uint64_t func_id;
        int hart_id;
        int bit;
@@ -161,6 +162,7 @@ vmm_sbi_handle_ipi(struct vcpu *vcpu, struct hypctx *hypctx)
 
        func_id = hypctx->guest_regs.hyp_a[6];
        hart_mask = hypctx->guest_regs.hyp_a[0];
+       hart_mask_base = hypctx->guest_regs.hyp_a[1];
 
        dprintf("%s: hart_mask %lx\n", __func__, hart_mask);
 
@@ -173,6 +175,8 @@ vmm_sbi_handle_ipi(struct vcpu *vcpu, struct hypctx *hypctx)
                while ((bit = ffs(hart_mask))) {
                        hart_id = (bit - 1);
                        hart_mask &= ~(1u << hart_id);
+                       if (hart_mask_base != -1)
+                               hart_id += hart_mask_base;
                        if (CPU_ISSET(hart_id, &active_cpus)) {
                                /* TODO. */
                                target_vcpu = vm_vcpu(hyp->vm, hart_id);

Reply via email to