1 // SPDX-License-Identifier: GPL-2.0
3 * ACRN detection support
5 * Copyright (C) 2019 Intel Corporation. All rights reserved.
7 * Jason Chen CJ <jason.cj.chen@intel.com>
8 * Zhao Yakui <yakui.zhao@intel.com>
12 #include <linux/interrupt.h>
16 #include <asm/hypervisor.h>
17 #include <asm/irq_regs.h>
19 static uint32_t __init acrn_detect(void)
21 return hypervisor_cpuid_base("ACRNACRNACRN\0\0", 0);
24 static void __init acrn_init_platform(void)
26 /* Setup the IDT for ACRN hypervisor callback */
27 alloc_intr_gate(HYPERVISOR_CALLBACK_VECTOR, acrn_hv_callback_vector);
30 static bool acrn_x2apic_available(void)
33 * x2apic is not supported for now. Future enablement will have to check
34 * X86_FEATURE_X2APIC to determine whether x2apic is supported in the
40 static void (*acrn_intr_handler)(void);
42 __visible void __irq_entry acrn_hv_vector_handler(struct pt_regs *regs)
44 struct pt_regs *old_regs = set_irq_regs(regs);
47 * The hypervisor requires that the APIC EOI should be acked.
48 * If the APIC EOI is not acked, the APIC ISR bit for the
49 * HYPERVISOR_CALLBACK_VECTOR will not be cleared and then it
50 * will block the interrupt whose vector is lower than
51 * HYPERVISOR_CALLBACK_VECTOR.
54 inc_irq_stat(irq_hv_callback_count);
56 if (acrn_intr_handler)
60 set_irq_regs(old_regs);
63 const __initconst struct hypervisor_x86 x86_hyper_acrn = {
65 .detect = acrn_detect,
66 .type = X86_HYPER_ACRN,
67 .init.init_platform = acrn_init_platform,
68 .init.x2apic_available = acrn_x2apic_available,