Skip to content

Commit 8faef71

Browse files
committed
Merge branch 'x86-platform-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 platform updayes from Ingo Molnar: "Most of the commits add ACRN hypervisor guest support, plus two cleanups" * 'x86-platform-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/jailhouse: Mark jailhouse_x2apic_available() as __init x86/platform/geode: Drop <linux/gpio.h> includes x86/acrn: Use HYPERVISOR_CALLBACK_VECTOR for ACRN guest upcall vector x86: Add support for Linux guests on an ACRN hypervisor x86/Kconfig: Add new X86_HV_CALLBACK_VECTOR config symbol
2 parents da17702 + d97ee99 commit 8faef71

File tree

15 files changed

+110
-6
lines changed

15 files changed

+110
-6
lines changed

arch/x86/Kconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,9 @@ config PARAVIRT_SPINLOCKS
785785

786786
If you are unsure how to answer this question, answer Y.
787787

788+
config X86_HV_CALLBACK_VECTOR
789+
def_bool n
790+
788791
source "arch/x86/xen/Kconfig"
789792

790793
config KVM_GUEST
@@ -836,6 +839,17 @@ config JAILHOUSE_GUEST
836839
cell. You can leave this option disabled if you only want to start
837840
Jailhouse and run Linux afterwards in the root cell.
838841

842+
config ACRN_GUEST
843+
bool "ACRN Guest support"
844+
depends on X86_64
845+
select X86_HV_CALLBACK_VECTOR
846+
help
847+
This option allows to run Linux as guest in the ACRN hypervisor. ACRN is
848+
a flexible, lightweight reference open-source hypervisor, built with
849+
real-time and safety-criticality in mind. It is built for embedded
850+
IOT with small footprint and real-time features. More details can be
851+
found in https://projectacrn.org/.
852+
839853
endif #HYPERVISOR_GUEST
840854

841855
source "arch/x86/Kconfig.cpu"

arch/x86/entry/entry_64.S

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,6 +1164,11 @@ apicinterrupt3 HYPERV_STIMER0_VECTOR \
11641164
hv_stimer0_callback_vector hv_stimer0_vector_handler
11651165
#endif /* CONFIG_HYPERV */
11661166

1167+
#if IS_ENABLED(CONFIG_ACRN_GUEST)
1168+
apicinterrupt3 HYPERVISOR_CALLBACK_VECTOR \
1169+
acrn_hv_callback_vector acrn_hv_vector_handler
1170+
#endif
1171+
11671172
idtentry debug do_debug has_error_code=0 paranoid=1 shift_ist=IST_INDEX_DB ist_offset=DB_STACK_OFFSET
11681173
idtentry int3 do_int3 has_error_code=0 create_gap=1
11691174
idtentry stack_segment do_stack_segment has_error_code=1

arch/x86/include/asm/acrn.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef _ASM_X86_ACRN_H
3+
#define _ASM_X86_ACRN_H
4+
5+
extern void acrn_hv_callback_vector(void);
6+
#ifdef CONFIG_TRACING
7+
#define trace_acrn_hv_callback_vector acrn_hv_callback_vector
8+
#endif
9+
10+
extern void acrn_hv_vector_handler(struct pt_regs *regs);
11+
#endif /* _ASM_X86_ACRN_H */

arch/x86/include/asm/hardirq.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ typedef struct {
3737
#ifdef CONFIG_X86_MCE_AMD
3838
unsigned int irq_deferred_error_count;
3939
#endif
40-
#if IS_ENABLED(CONFIG_HYPERV) || defined(CONFIG_XEN)
40+
#ifdef CONFIG_X86_HV_CALLBACK_VECTOR
4141
unsigned int irq_hv_callback_count;
4242
#endif
4343
#if IS_ENABLED(CONFIG_HYPERV)

arch/x86/include/asm/hypervisor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ enum x86_hypervisor_type {
2929
X86_HYPER_XEN_HVM,
3030
X86_HYPER_KVM,
3131
X86_HYPER_JAILHOUSE,
32+
X86_HYPER_ACRN,
3233
};
3334

3435
#ifdef CONFIG_HYPERVISOR_GUEST

arch/x86/kernel/cpu/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ obj-$(CONFIG_X86_CPU_RESCTRL) += resctrl/
4949
obj-$(CONFIG_X86_LOCAL_APIC) += perfctr-watchdog.o
5050

5151
obj-$(CONFIG_HYPERVISOR_GUEST) += vmware.o hypervisor.o mshyperv.o
52+
obj-$(CONFIG_ACRN_GUEST) += acrn.o
5253

5354
ifdef CONFIG_X86_FEATURE_NAMES
5455
quiet_cmd_mkcapflags = MKCAP $@

arch/x86/kernel/cpu/acrn.c

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* ACRN detection support
4+
*
5+
* Copyright (C) 2019 Intel Corporation. All rights reserved.
6+
*
7+
* Jason Chen CJ <[email protected]>
8+
* Zhao Yakui <[email protected]>
9+
*
10+
*/
11+
12+
#include <linux/interrupt.h>
13+
#include <asm/acrn.h>
14+
#include <asm/apic.h>
15+
#include <asm/desc.h>
16+
#include <asm/hypervisor.h>
17+
#include <asm/irq_regs.h>
18+
19+
static uint32_t __init acrn_detect(void)
20+
{
21+
return hypervisor_cpuid_base("ACRNACRNACRN\0\0", 0);
22+
}
23+
24+
static void __init acrn_init_platform(void)
25+
{
26+
/* Setup the IDT for ACRN hypervisor callback */
27+
alloc_intr_gate(HYPERVISOR_CALLBACK_VECTOR, acrn_hv_callback_vector);
28+
}
29+
30+
static bool acrn_x2apic_available(void)
31+
{
32+
/*
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
35+
* guest.
36+
*/
37+
return false;
38+
}
39+
40+
static void (*acrn_intr_handler)(void);
41+
42+
__visible void __irq_entry acrn_hv_vector_handler(struct pt_regs *regs)
43+
{
44+
struct pt_regs *old_regs = set_irq_regs(regs);
45+
46+
/*
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.
52+
*/
53+
entering_ack_irq();
54+
inc_irq_stat(irq_hv_callback_count);
55+
56+
if (acrn_intr_handler)
57+
acrn_intr_handler();
58+
59+
exiting_irq();
60+
set_irq_regs(old_regs);
61+
}
62+
63+
const __initconst struct hypervisor_x86 x86_hyper_acrn = {
64+
.name = "ACRN",
65+
.detect = acrn_detect,
66+
.type = X86_HYPER_ACRN,
67+
.init.init_platform = acrn_init_platform,
68+
.init.x2apic_available = acrn_x2apic_available,
69+
};

arch/x86/kernel/cpu/hypervisor.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ extern const struct hypervisor_x86 x86_hyper_xen_pv;
3232
extern const struct hypervisor_x86 x86_hyper_xen_hvm;
3333
extern const struct hypervisor_x86 x86_hyper_kvm;
3434
extern const struct hypervisor_x86 x86_hyper_jailhouse;
35+
extern const struct hypervisor_x86 x86_hyper_acrn;
3536

3637
static const __initconst struct hypervisor_x86 * const hypervisors[] =
3738
{
@@ -49,6 +50,9 @@ static const __initconst struct hypervisor_x86 * const hypervisors[] =
4950
#ifdef CONFIG_JAILHOUSE_GUEST
5051
&x86_hyper_jailhouse,
5152
#endif
53+
#ifdef CONFIG_ACRN_GUEST
54+
&x86_hyper_acrn,
55+
#endif
5256
};
5357

5458
enum x86_hypervisor_type x86_hyper_type;

arch/x86/kernel/irq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ int arch_show_interrupts(struct seq_file *p, int prec)
135135
seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
136136
seq_puts(p, " Machine check polls\n");
137137
#endif
138-
#if IS_ENABLED(CONFIG_HYPERV) || defined(CONFIG_XEN)
138+
#ifdef CONFIG_X86_HV_CALLBACK_VECTOR
139139
if (test_bit(HYPERVISOR_CALLBACK_VECTOR, system_vectors)) {
140140
seq_printf(p, "%*s: ", prec, "HYP");
141141
for_each_online_cpu(j)

arch/x86/kernel/jailhouse.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ bool jailhouse_paravirt(void)
203203
return jailhouse_cpuid_base() != 0;
204204
}
205205

206-
static bool jailhouse_x2apic_available(void)
206+
static bool __init jailhouse_x2apic_available(void)
207207
{
208208
/*
209209
* The x2APIC is only available if the root cell enabled it. Jailhouse

arch/x86/platform/geode/alix.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include <linux/moduleparam.h>
2121
#include <linux/leds.h>
2222
#include <linux/platform_device.h>
23-
#include <linux/gpio.h>
2423
#include <linux/input.h>
2524
#include <linux/gpio_keys.h>
2625
#include <linux/dmi.h>

arch/x86/platform/geode/geos.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include <linux/string.h>
1919
#include <linux/leds.h>
2020
#include <linux/platform_device.h>
21-
#include <linux/gpio.h>
2221
#include <linux/input.h>
2322
#include <linux/gpio_keys.h>
2423
#include <linux/dmi.h>

arch/x86/platform/geode/net5501.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include <linux/string.h>
1919
#include <linux/leds.h>
2020
#include <linux/platform_device.h>
21-
#include <linux/gpio.h>
2221
#include <linux/input.h>
2322
#include <linux/gpio_keys.h>
2423

arch/x86/xen/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ config XEN
77
bool "Xen guest support"
88
depends on PARAVIRT
99
select PARAVIRT_CLOCK
10+
select X86_HV_CALLBACK_VECTOR
1011
depends on X86_64 || (X86_32 && X86_PAE)
1112
depends on X86_LOCAL_APIC && X86_TSC
1213
help

drivers/hv/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ config HYPERV
66
tristate "Microsoft Hyper-V client drivers"
77
depends on X86 && ACPI && X86_LOCAL_APIC && HYPERVISOR_GUEST
88
select PARAVIRT
9+
select X86_HV_CALLBACK_VECTOR
910
help
1011
Select this option to run Linux as a Hyper-V client operating
1112
system.

0 commit comments

Comments
 (0)