summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-07-08 20:49:45 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2019-07-08 20:49:45 -0400
commit8faef7125d02c0bbd7a1ceb4e3b599a9b8c42e58 (patch)
tree5d6c28a0f5654b5bae84e65dbb5563049b7b497e
parentda1770238597a4619b7845583881543ca81270cd (diff)
parentd97ee99bf225d35a50ed8812c3d037b2ba7ad2ea (diff)
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
-rw-r--r--arch/x86/Kconfig14
-rw-r--r--arch/x86/entry/entry_64.S5
-rw-r--r--arch/x86/include/asm/acrn.h11
-rw-r--r--arch/x86/include/asm/hardirq.h2
-rw-r--r--arch/x86/include/asm/hypervisor.h1
-rw-r--r--arch/x86/kernel/cpu/Makefile1
-rw-r--r--arch/x86/kernel/cpu/acrn.c69
-rw-r--r--arch/x86/kernel/cpu/hypervisor.c4
-rw-r--r--arch/x86/kernel/irq.c2
-rw-r--r--arch/x86/kernel/jailhouse.c2
-rw-r--r--arch/x86/platform/geode/alix.c1
-rw-r--r--arch/x86/platform/geode/geos.c1
-rw-r--r--arch/x86/platform/geode/net5501.c1
-rw-r--r--arch/x86/xen/Kconfig1
-rw-r--r--drivers/hv/Kconfig1
15 files changed, 110 insertions, 6 deletions
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 3b3acb7f1b07..5a72c98e60bc 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -785,6 +785,9 @@ config PARAVIRT_SPINLOCKS
785 785
786 If you are unsure how to answer this question, answer Y. 786 If you are unsure how to answer this question, answer Y.
787 787
788config X86_HV_CALLBACK_VECTOR
789 def_bool n
790
788source "arch/x86/xen/Kconfig" 791source "arch/x86/xen/Kconfig"
789 792
790config KVM_GUEST 793config KVM_GUEST
@@ -836,6 +839,17 @@ config JAILHOUSE_GUEST
836 cell. You can leave this option disabled if you only want to start 839 cell. You can leave this option disabled if you only want to start
837 Jailhouse and run Linux afterwards in the root cell. 840 Jailhouse and run Linux afterwards in the root cell.
838 841
842config 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
839endif #HYPERVISOR_GUEST 853endif #HYPERVISOR_GUEST
840 854
841source "arch/x86/Kconfig.cpu" 855source "arch/x86/Kconfig.cpu"
diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
index 15f0749d0a15..a829dd3117d0 100644
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -1164,6 +1164,11 @@ apicinterrupt3 HYPERV_STIMER0_VECTOR \
1164 hv_stimer0_callback_vector hv_stimer0_vector_handler 1164 hv_stimer0_callback_vector hv_stimer0_vector_handler
1165#endif /* CONFIG_HYPERV */ 1165#endif /* CONFIG_HYPERV */
1166 1166
1167#if IS_ENABLED(CONFIG_ACRN_GUEST)
1168apicinterrupt3 HYPERVISOR_CALLBACK_VECTOR \
1169 acrn_hv_callback_vector acrn_hv_vector_handler
1170#endif
1171
1167idtentry debug do_debug has_error_code=0 paranoid=1 shift_ist=IST_INDEX_DB ist_offset=DB_STACK_OFFSET 1172idtentry debug do_debug has_error_code=0 paranoid=1 shift_ist=IST_INDEX_DB ist_offset=DB_STACK_OFFSET
1168idtentry int3 do_int3 has_error_code=0 create_gap=1 1173idtentry int3 do_int3 has_error_code=0 create_gap=1
1169idtentry stack_segment do_stack_segment has_error_code=1 1174idtentry stack_segment do_stack_segment has_error_code=1
diff --git a/arch/x86/include/asm/acrn.h b/arch/x86/include/asm/acrn.h
new file mode 100644
index 000000000000..4adb13f08af7
--- /dev/null
+++ b/arch/x86/include/asm/acrn.h
@@ -0,0 +1,11 @@
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _ASM_X86_ACRN_H
3#define _ASM_X86_ACRN_H
4
5extern void acrn_hv_callback_vector(void);
6#ifdef CONFIG_TRACING
7#define trace_acrn_hv_callback_vector acrn_hv_callback_vector
8#endif
9
10extern void acrn_hv_vector_handler(struct pt_regs *regs);
11#endif /* _ASM_X86_ACRN_H */
diff --git a/arch/x86/include/asm/hardirq.h b/arch/x86/include/asm/hardirq.h
index d9069bb26c7f..07533795b8d2 100644
--- a/arch/x86/include/asm/hardirq.h
+++ b/arch/x86/include/asm/hardirq.h
@@ -37,7 +37,7 @@ typedef struct {
37#ifdef CONFIG_X86_MCE_AMD 37#ifdef CONFIG_X86_MCE_AMD
38 unsigned int irq_deferred_error_count; 38 unsigned int irq_deferred_error_count;
39#endif 39#endif
40#if IS_ENABLED(CONFIG_HYPERV) || defined(CONFIG_XEN) 40#ifdef CONFIG_X86_HV_CALLBACK_VECTOR
41 unsigned int irq_hv_callback_count; 41 unsigned int irq_hv_callback_count;
42#endif 42#endif
43#if IS_ENABLED(CONFIG_HYPERV) 43#if IS_ENABLED(CONFIG_HYPERV)
diff --git a/arch/x86/include/asm/hypervisor.h b/arch/x86/include/asm/hypervisor.h
index 8c5aaba6633f..50a30f6c668b 100644
--- a/arch/x86/include/asm/hypervisor.h
+++ b/arch/x86/include/asm/hypervisor.h
@@ -29,6 +29,7 @@ enum x86_hypervisor_type {
29 X86_HYPER_XEN_HVM, 29 X86_HYPER_XEN_HVM,
30 X86_HYPER_KVM, 30 X86_HYPER_KVM,
31 X86_HYPER_JAILHOUSE, 31 X86_HYPER_JAILHOUSE,
32 X86_HYPER_ACRN,
32}; 33};
33 34
34#ifdef CONFIG_HYPERVISOR_GUEST 35#ifdef CONFIG_HYPERVISOR_GUEST
diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
index 89e76523cedc..d7a1e5a9331c 100644
--- a/arch/x86/kernel/cpu/Makefile
+++ b/arch/x86/kernel/cpu/Makefile
@@ -49,6 +49,7 @@ obj-$(CONFIG_X86_CPU_RESCTRL) += resctrl/
49obj-$(CONFIG_X86_LOCAL_APIC) += perfctr-watchdog.o 49obj-$(CONFIG_X86_LOCAL_APIC) += perfctr-watchdog.o
50 50
51obj-$(CONFIG_HYPERVISOR_GUEST) += vmware.o hypervisor.o mshyperv.o 51obj-$(CONFIG_HYPERVISOR_GUEST) += vmware.o hypervisor.o mshyperv.o
52obj-$(CONFIG_ACRN_GUEST) += acrn.o
52 53
53ifdef CONFIG_X86_FEATURE_NAMES 54ifdef CONFIG_X86_FEATURE_NAMES
54quiet_cmd_mkcapflags = MKCAP $@ 55quiet_cmd_mkcapflags = MKCAP $@
diff --git a/arch/x86/kernel/cpu/acrn.c b/arch/x86/kernel/cpu/acrn.c
new file mode 100644
index 000000000000..676022e71791
--- /dev/null
+++ b/arch/x86/kernel/cpu/acrn.c
@@ -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 <jason.cj.chen@intel.com>
8 * Zhao Yakui <yakui.zhao@intel.com>
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
19static uint32_t __init acrn_detect(void)
20{
21 return hypervisor_cpuid_base("ACRNACRNACRN\0\0", 0);
22}
23
24static 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
30static 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
40static 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
63const __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};
diff --git a/arch/x86/kernel/cpu/hypervisor.c b/arch/x86/kernel/cpu/hypervisor.c
index 479ca4728de0..87e39ad8d873 100644
--- a/arch/x86/kernel/cpu/hypervisor.c
+++ b/arch/x86/kernel/cpu/hypervisor.c
@@ -32,6 +32,7 @@ extern const struct hypervisor_x86 x86_hyper_xen_pv;
32extern const struct hypervisor_x86 x86_hyper_xen_hvm; 32extern const struct hypervisor_x86 x86_hyper_xen_hvm;
33extern const struct hypervisor_x86 x86_hyper_kvm; 33extern const struct hypervisor_x86 x86_hyper_kvm;
34extern const struct hypervisor_x86 x86_hyper_jailhouse; 34extern const struct hypervisor_x86 x86_hyper_jailhouse;
35extern const struct hypervisor_x86 x86_hyper_acrn;
35 36
36static const __initconst struct hypervisor_x86 * const hypervisors[] = 37static const __initconst struct hypervisor_x86 * const hypervisors[] =
37{ 38{
@@ -49,6 +50,9 @@ static const __initconst struct hypervisor_x86 * const hypervisors[] =
49#ifdef CONFIG_JAILHOUSE_GUEST 50#ifdef CONFIG_JAILHOUSE_GUEST
50 &x86_hyper_jailhouse, 51 &x86_hyper_jailhouse,
51#endif 52#endif
53#ifdef CONFIG_ACRN_GUEST
54 &x86_hyper_acrn,
55#endif
52}; 56};
53 57
54enum x86_hypervisor_type x86_hyper_type; 58enum x86_hypervisor_type x86_hyper_type;
diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
index cc496eb7a8d2..4215653f8a8e 100644
--- a/arch/x86/kernel/irq.c
+++ b/arch/x86/kernel/irq.c
@@ -135,7 +135,7 @@ int arch_show_interrupts(struct seq_file *p, int prec)
135 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j)); 135 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
136 seq_puts(p, " Machine check polls\n"); 136 seq_puts(p, " Machine check polls\n");
137#endif 137#endif
138#if IS_ENABLED(CONFIG_HYPERV) || defined(CONFIG_XEN) 138#ifdef CONFIG_X86_HV_CALLBACK_VECTOR
139 if (test_bit(HYPERVISOR_CALLBACK_VECTOR, system_vectors)) { 139 if (test_bit(HYPERVISOR_CALLBACK_VECTOR, system_vectors)) {
140 seq_printf(p, "%*s: ", prec, "HYP"); 140 seq_printf(p, "%*s: ", prec, "HYP");
141 for_each_online_cpu(j) 141 for_each_online_cpu(j)
diff --git a/arch/x86/kernel/jailhouse.c b/arch/x86/kernel/jailhouse.c
index ba95bc70460d..6857b4577f17 100644
--- a/arch/x86/kernel/jailhouse.c
+++ b/arch/x86/kernel/jailhouse.c
@@ -203,7 +203,7 @@ bool jailhouse_paravirt(void)
203 return jailhouse_cpuid_base() != 0; 203 return jailhouse_cpuid_base() != 0;
204} 204}
205 205
206static bool jailhouse_x2apic_available(void) 206static bool __init jailhouse_x2apic_available(void)
207{ 207{
208 /* 208 /*
209 * The x2APIC is only available if the root cell enabled it. Jailhouse 209 * The x2APIC is only available if the root cell enabled it. Jailhouse
diff --git a/arch/x86/platform/geode/alix.c b/arch/x86/platform/geode/alix.c
index 8d4daca81eda..c33f744b5388 100644
--- a/arch/x86/platform/geode/alix.c
+++ b/arch/x86/platform/geode/alix.c
@@ -20,7 +20,6 @@
20#include <linux/moduleparam.h> 20#include <linux/moduleparam.h>
21#include <linux/leds.h> 21#include <linux/leds.h>
22#include <linux/platform_device.h> 22#include <linux/platform_device.h>
23#include <linux/gpio.h>
24#include <linux/input.h> 23#include <linux/input.h>
25#include <linux/gpio_keys.h> 24#include <linux/gpio_keys.h>
26#include <linux/dmi.h> 25#include <linux/dmi.h>
diff --git a/arch/x86/platform/geode/geos.c b/arch/x86/platform/geode/geos.c
index 136974ec9a90..73a3f49b4eb6 100644
--- a/arch/x86/platform/geode/geos.c
+++ b/arch/x86/platform/geode/geos.c
@@ -18,7 +18,6 @@
18#include <linux/string.h> 18#include <linux/string.h>
19#include <linux/leds.h> 19#include <linux/leds.h>
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <linux/gpio.h>
22#include <linux/input.h> 21#include <linux/input.h>
23#include <linux/gpio_keys.h> 22#include <linux/gpio_keys.h>
24#include <linux/dmi.h> 23#include <linux/dmi.h>
diff --git a/arch/x86/platform/geode/net5501.c b/arch/x86/platform/geode/net5501.c
index 2c24d8d30436..163e1b545517 100644
--- a/arch/x86/platform/geode/net5501.c
+++ b/arch/x86/platform/geode/net5501.c
@@ -18,7 +18,6 @@
18#include <linux/string.h> 18#include <linux/string.h>
19#include <linux/leds.h> 19#include <linux/leds.h>
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <linux/gpio.h>
22#include <linux/input.h> 21#include <linux/input.h>
23#include <linux/gpio_keys.h> 22#include <linux/gpio_keys.h>
24 23
diff --git a/arch/x86/xen/Kconfig b/arch/x86/xen/Kconfig
index e07abefd3d26..ba5a41828e9d 100644
--- a/arch/x86/xen/Kconfig
+++ b/arch/x86/xen/Kconfig
@@ -7,6 +7,7 @@ config XEN
7 bool "Xen guest support" 7 bool "Xen guest support"
8 depends on PARAVIRT 8 depends on PARAVIRT
9 select PARAVIRT_CLOCK 9 select PARAVIRT_CLOCK
10 select X86_HV_CALLBACK_VECTOR
10 depends on X86_64 || (X86_32 && X86_PAE) 11 depends on X86_64 || (X86_32 && X86_PAE)
11 depends on X86_LOCAL_APIC && X86_TSC 12 depends on X86_LOCAL_APIC && X86_TSC
12 help 13 help
diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig
index c423e57ae888..9a59957922d4 100644
--- a/drivers/hv/Kconfig
+++ b/drivers/hv/Kconfig
@@ -6,6 +6,7 @@ config HYPERV
6 tristate "Microsoft Hyper-V client drivers" 6 tristate "Microsoft Hyper-V client drivers"
7 depends on X86 && ACPI && X86_LOCAL_APIC && HYPERVISOR_GUEST 7 depends on X86 && ACPI && X86_LOCAL_APIC && HYPERVISOR_GUEST
8 select PARAVIRT 8 select PARAVIRT
9 select X86_HV_CALLBACK_VECTOR
9 help 10 help
10 Select this option to run Linux as a Hyper-V client operating 11 Select this option to run Linux as a Hyper-V client operating
11 system. 12 system.