Commit d663b8a2 authored by Paolo Bonzini's avatar Paolo Bonzini
Browse files

KVM: replace direct irq.h inclusion



virt/kvm/irqchip.c is including "irq.h" from the arch-specific KVM source
directory (i.e. not from arch/*/include) for the sole purpose of retrieving
irqchip_in_kernel.

Making the function inline in a header that is already included,
such as asm/kvm_host.h, is not possible because it needs to look at
struct kvm which is defined after asm/kvm_host.h is included.  So add a
kvm_arch_irqchip_in_kernel non-inline function; irqchip_in_kernel() is
only performance critical on arm64 and x86, and the non-inline function
is enough on all other architectures.

irq.h can then be deleted from all architectures except x86.

Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent de0f6195
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -2130,6 +2130,11 @@ struct kvm_vcpu *kvm_mpidr_to_vcpu(struct kvm *kvm, unsigned long mpidr)
	return NULL;
}

bool kvm_arch_irqchip_in_kernel(struct kvm *kvm)
{
	return irqchip_in_kernel(kvm);
}

bool kvm_arch_has_irq_bypass(void)
{
	return true;

arch/arm64/kvm/irq.h

deleted100644 → 0
+0 −16
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * irq.h: in kernel interrupt controller related definitions
 * Copyright (c) 2016 Red Hat, Inc.
 *
 * This header is included by irqchip.c. However, on ARM, interrupt
 * controller declarations are located in include/kvm/arm_vgic.h since
 * they are mostly shared between arm and arm64.
 */

#ifndef __IRQ_H
#define __IRQ_H

#include <kvm/arm_vgic.h>

#endif

arch/powerpc/kvm/irq.h

deleted100644 → 0
+0 −22
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __IRQ_H
#define __IRQ_H

#include <linux/kvm_host.h>

static inline int irqchip_in_kernel(struct kvm *kvm)
{
	int ret = 0;

#ifdef CONFIG_KVM_MPIC
	ret = ret || (kvm->arch.mpic != NULL);
#endif
#ifdef CONFIG_KVM_XICS
	ret = ret || (kvm->arch.xics != NULL);
	ret = ret || (kvm->arch.xive != NULL);
#endif
	smp_rmb();
	return ret;
}

#endif
+16 −2
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@
#include <asm/setup.h>

#include "timing.h"
#include "irq.h"
#include "../mm/mmu_decl.h"

#define CREATE_TRACE_POINTS
@@ -2165,10 +2164,25 @@ static int kvm_vm_ioctl_get_pvinfo(struct kvm_ppc_pvinfo *pvinfo)
	return 0;
}

bool kvm_arch_irqchip_in_kernel(struct kvm *kvm)
{
	int ret = 0;

#ifdef CONFIG_KVM_MPIC
	ret = ret || (kvm->arch.mpic != NULL);
#endif
#ifdef CONFIG_KVM_XICS
	ret = ret || (kvm->arch.xics != NULL);
	ret = ret || (kvm->arch.xive != NULL);
#endif
	smp_rmb();
	return ret;
}

int kvm_vm_ioctl_irq_line(struct kvm *kvm, struct kvm_irq_level *irq_event,
			  bool line_status)
{
	if (!irqchip_in_kernel(kvm))
	if (!kvm_arch_irqchip_in_kernel(kvm))
		return -ENXIO;

	irq_event->status = kvm_set_irq(kvm, KVM_USERSPACE_IRQ_SOURCE_ID,

arch/s390/kvm/irq.h

deleted100644 → 0
+0 −19
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * s390 irqchip routines
 *
 * Copyright IBM Corp. 2014
 *
 *    Author(s): Cornelia Huck <cornelia.huck@de.ibm.com>
 */
#ifndef __KVM_IRQ_H
#define __KVM_IRQ_H

#include <linux/kvm_host.h>

static inline int irqchip_in_kernel(struct kvm *kvm)
{
	return 1;
}

#endif
Loading