Skip to content

Commit ec7972c

Browse files
yakuizhaosuryasaimadhu
authored andcommitted
x86: Add support for Linux guests on an ACRN hypervisor
ACRN is an open-source hypervisor maintained by The Linux Foundation. It is built for embedded IOT with small footprint and real-time features. Add ACRN guest support so that it allows Linux to be booted under the ACRN hypervisor. This adds only the barebones implementation. [ bp: Massage commit message and help text. ] Co-developed-by: Jason Chen CJ <[email protected]> Signed-off-by: Jason Chen CJ <[email protected]> Signed-off-by: Zhao Yakui <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Reviewed-by: Thomas Gleixner <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: x86-ml <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent ecca250 commit ec7972c

File tree

5 files changed

+55
-0
lines changed

5 files changed

+55
-0
lines changed

arch/x86/Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,16 @@ config JAILHOUSE_GUEST
835835
cell. You can leave this option disabled if you only want to start
836836
Jailhouse and run Linux afterwards in the root cell.
837837

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

840850
source "arch/x86/Kconfig.cpu"

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
@@ -47,6 +47,7 @@ obj-$(CONFIG_X86_CPU_RESCTRL) += resctrl/
4747
obj-$(CONFIG_X86_LOCAL_APIC) += perfctr-watchdog.o
4848

4949
obj-$(CONFIG_HYPERVISOR_GUEST) += vmware.o hypervisor.o mshyperv.o
50+
obj-$(CONFIG_ACRN_GUEST) += acrn.o
5051

5152
ifdef CONFIG_X86_FEATURE_NAMES
5253
quiet_cmd_mkcapflags = MKCAP $@

arch/x86/kernel/cpu/acrn.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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 <asm/hypervisor.h>
13+
14+
static uint32_t __init acrn_detect(void)
15+
{
16+
return hypervisor_cpuid_base("ACRNACRNACRN\0\0", 0);
17+
}
18+
19+
static void __init acrn_init_platform(void)
20+
{
21+
}
22+
23+
static bool acrn_x2apic_available(void)
24+
{
25+
/*
26+
* x2apic is not supported for now. Future enablement will have to check
27+
* X86_FEATURE_X2APIC to determine whether x2apic is supported in the
28+
* guest.
29+
*/
30+
return false;
31+
}
32+
33+
const __initconst struct hypervisor_x86 x86_hyper_acrn = {
34+
.name = "ACRN",
35+
.detect = acrn_detect,
36+
.type = X86_HYPER_ACRN,
37+
.init.init_platform = acrn_init_platform,
38+
.init.x2apic_available = acrn_x2apic_available,
39+
};

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;

0 commit comments

Comments
 (0)