hc
2024-01-31 f9004dbfff8a3fbbd7e2a88c8a4327c7f2f8e5b2
kernel/arch/x86/kvm/irq_comm.c
....@@ -1,19 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * irq_comm.c: Common API for in kernel interrupt controller
34 * Copyright (c) 2007, Intel Corporation.
45 *
5
- * This program is free software; you can redistribute it and/or modify it
6
- * under the terms and conditions of the GNU General Public License,
7
- * version 2, as published by the Free Software Foundation.
8
- *
9
- * This program is distributed in the hope it will be useful, but WITHOUT
10
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
- * more details.
13
- *
14
- * You should have received a copy of the GNU General Public License along with
15
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
16
- * Place - Suite 330, Boston, MA 02111-1307 USA.
176 * Authors:
187 * Yaozu (Eddie) Dong <Eddie.dong@intel.com>
198 *
....@@ -63,14 +52,14 @@
6352 unsigned long dest_vcpu_bitmap[BITS_TO_LONGS(KVM_MAX_VCPUS)];
6453 unsigned int dest_vcpus = 0;
6554
66
- if (irq->dest_mode == 0 && irq->dest_id == 0xff &&
67
- kvm_lowest_prio_delivery(irq)) {
55
+ if (kvm_irq_delivery_to_apic_fast(kvm, src, irq, &r, dest_map))
56
+ return r;
57
+
58
+ if (irq->dest_mode == APIC_DEST_PHYSICAL &&
59
+ irq->dest_id == 0xff && kvm_lowest_prio_delivery(irq)) {
6860 printk(KERN_INFO "kvm: apic: phys broadcast and lowest prio\n");
6961 irq->delivery_mode = APIC_DM_FIXED;
7062 }
71
-
72
- if (kvm_irq_delivery_to_apic_fast(kvm, src, irq, &r, dest_map))
73
- return r;
7463
7564 memset(dest_vcpu_bitmap, 0, sizeof(dest_vcpu_bitmap));
7665
....@@ -86,7 +75,7 @@
8675 if (r < 0)
8776 r = 0;
8877 r += kvm_apic_set_irq(vcpu, irq, dest_map);
89
- } else if (kvm_lapic_enabled(vcpu)) {
78
+ } else if (kvm_apic_sw_enabled(vcpu->arch.apic)) {
9079 if (!kvm_vector_hashing_enabled()) {
9180 if (!lowest)
9281 lowest = vcpu;
....@@ -125,13 +114,14 @@
125114 irq->dest_id |= MSI_ADDR_EXT_DEST_ID(e->msi.address_hi);
126115 irq->vector = (e->msi.data &
127116 MSI_DATA_VECTOR_MASK) >> MSI_DATA_VECTOR_SHIFT;
128
- irq->dest_mode = (1 << MSI_ADDR_DEST_MODE_SHIFT) & e->msi.address_lo;
117
+ irq->dest_mode = kvm_lapic_irq_dest_mode(
118
+ !!((1 << MSI_ADDR_DEST_MODE_SHIFT) & e->msi.address_lo));
129119 irq->trig_mode = (1 << MSI_DATA_TRIGGER_SHIFT) & e->msi.data;
130120 irq->delivery_mode = e->msi.data & 0x700;
131121 irq->msi_redir_hint = ((e->msi.address_lo
132122 & MSI_ADDR_REDIRECTION_LOWPRI) > 0);
133123 irq->level = 1;
134
- irq->shorthand = 0;
124
+ irq->shorthand = APIC_DEST_NOSHORT;
135125 }
136126 EXPORT_SYMBOL_GPL(kvm_set_msi_irq);
137127
....@@ -295,7 +285,7 @@
295285 switch (ue->u.irqchip.irqchip) {
296286 case KVM_IRQCHIP_PIC_SLAVE:
297287 e->irqchip.pin += PIC_NUM_PINS / 2;
298
- /* fall through */
288
+ fallthrough;
299289 case KVM_IRQCHIP_PIC_MASTER:
300290 if (ue->u.irqchip.pin >= PIC_NUM_PINS / 2)
301291 return -EINVAL;
....@@ -427,7 +417,8 @@
427417
428418 kvm_set_msi_irq(vcpu->kvm, entry, &irq);
429419
430
- if (irq.trig_mode && kvm_apic_match_dest(vcpu, NULL, 0,
420
+ if (irq.trig_mode &&
421
+ kvm_apic_match_dest(vcpu, NULL, APIC_DEST_NOSHORT,
431422 irq.dest_id, irq.dest_mode))
432423 __set_bit(irq.vector, ioapic_handled_vectors);
433424 }