From: Jinank Jain <[email protected]>

Interrupt control structure (union hv_interupt_control) has different
fields when it comes to x86 vs ARM64. Bring in the correct structure
from HyperV header files and adjust the existing interrupt routing
code accordingly.

Signed-off-by: Jinank Jain <[email protected]>
Signed-off-by: Anirudh Rayabharam (Microsoft) <[email protected]>
---
 drivers/hv/mshv_eventfd.c      | 6 ++++++
 drivers/hv/mshv_irq.c          | 4 ++++
 drivers/hv/mshv_root_hv_call.c | 6 ++++++
 include/hyperv/hvhdk.h         | 6 ++++++
 4 files changed, 22 insertions(+)

diff --git a/drivers/hv/mshv_eventfd.c b/drivers/hv/mshv_eventfd.c
index 2a80af1d610a..d93a18f09c76 100644
--- a/drivers/hv/mshv_eventfd.c
+++ b/drivers/hv/mshv_eventfd.c
@@ -163,8 +163,10 @@ static int mshv_try_assert_irq_fast(struct mshv_irqfd 
*irqfd)
        if (hv_scheduler_type != HV_SCHEDULER_TYPE_ROOT)
                return -EOPNOTSUPP;
 
+#if IS_ENABLED(CONFIG_X86)
        if (irq->lapic_control.logical_dest_mode)
                return -EOPNOTSUPP;
+#endif
 
        vp = partition->pt_vp_array[irq->lapic_apic_id];
 
@@ -196,8 +198,10 @@ static void mshv_assert_irq_slow(struct mshv_irqfd *irqfd)
        unsigned int seq;
        int idx;
 
+#if IS_ENABLED(CONFIG_X86)
        WARN_ON(irqfd->irqfd_resampler &&
                !irq->lapic_control.level_triggered);
+#endif
 
        idx = srcu_read_lock(&partition->pt_irq_srcu);
        if (irqfd->irqfd_girq_ent.guest_irq_num) {
@@ -469,6 +473,7 @@ static int mshv_irqfd_assign(struct mshv_partition *pt,
        init_poll_funcptr(&irqfd->irqfd_polltbl, mshv_irqfd_queue_proc);
 
        spin_lock_irq(&pt->pt_irqfds_lock);
+#if IS_ENABLED(CONFIG_X86)
        if (args->flags & BIT(MSHV_IRQFD_BIT_RESAMPLE) &&
            !irqfd->irqfd_lapic_irq.lapic_control.level_triggered) {
                /*
@@ -479,6 +484,7 @@ static int mshv_irqfd_assign(struct mshv_partition *pt,
                ret = -EINVAL;
                goto fail;
        }
+#endif
        ret = 0;
        hlist_for_each_entry(tmp, &pt->pt_irqfds_list, irqfd_hnode) {
                if (irqfd->irqfd_eventfd_ctx != tmp->irqfd_eventfd_ctx)
diff --git a/drivers/hv/mshv_irq.c b/drivers/hv/mshv_irq.c
index d0fb9ef734f4..798e7e1ab06e 100644
--- a/drivers/hv/mshv_irq.c
+++ b/drivers/hv/mshv_irq.c
@@ -119,6 +119,10 @@ void mshv_copy_girq_info(struct mshv_guest_irq_ent *ent,
        lirq->lapic_vector = ent->girq_irq_data & 0xFF;
        lirq->lapic_apic_id = (ent->girq_addr_lo >> 12) & 0xFF;
        lirq->lapic_control.interrupt_type = (ent->girq_irq_data & 0x700) >> 8;
+#if IS_ENABLED(CONFIG_X86)
        lirq->lapic_control.level_triggered = (ent->girq_irq_data >> 15) & 0x1;
        lirq->lapic_control.logical_dest_mode = (ent->girq_addr_lo >> 2) & 0x1;
+#elif IS_ENABLED(CONFIG_ARM64)
+       lirq->lapic_control.asserted = 1;
+#endif
 }
diff --git a/drivers/hv/mshv_root_hv_call.c b/drivers/hv/mshv_root_hv_call.c
index caf02cfa49c9..598eaff4ff29 100644
--- a/drivers/hv/mshv_root_hv_call.c
+++ b/drivers/hv/mshv_root_hv_call.c
@@ -388,7 +388,13 @@ int hv_call_assert_virtual_interrupt(u64 partition_id, u32 
vector,
        memset(input, 0, sizeof(*input));
        input->partition_id = partition_id;
        input->vector = vector;
+       /*
+        * NOTE: dest_addr only needs to be provided while asserting an
+        * interrupt on x86 platform
+        */
+#if IS_ENABLED(CONFIG_X86)
        input->dest_addr = dest_addr;
+#endif
        input->control = control;
        status = hv_do_hypercall(HVCALL_ASSERT_VIRTUAL_INTERRUPT, input, NULL);
        local_irq_restore(flags);
diff --git a/include/hyperv/hvhdk.h b/include/hyperv/hvhdk.h
index 416c0d45b793..469186df7826 100644
--- a/include/hyperv/hvhdk.h
+++ b/include/hyperv/hvhdk.h
@@ -579,9 +579,15 @@ union hv_interrupt_control {
        u64 as_uint64;
        struct {
                u32 interrupt_type; /* enum hv_interrupt_type */
+#if IS_ENABLED(CONFIG_X86)
                u32 level_triggered : 1;
                u32 logical_dest_mode : 1;
                u32 rsvd : 30;
+#elif IS_ENABLED(CONFIG_ARM64)
+               u32 rsvd1 : 2;
+               u32 asserted : 1;
+               u32 rsvd2 : 29;
+#endif
        } __packed;
 };
 

base-commit: db7df69995ffbe806d60ad46d5fb9d959da9e549
-- 
2.34.1


Reply via email to