-
Notifications
You must be signed in to change notification settings - Fork 54.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
x86/jailhouse: Add infrastructure for running in non-root cell
The Jailhouse hypervisor is able to statically partition a multicore system into multiple so-called cells. Linux is used as boot loader and continues to run in the root cell after Jailhouse is enabled. Linux can also run in non-root cells. Jailhouse does not emulate usual x86 devices. It also provides no complex ACPI but basic platform information that the boot loader forwards via setup data. This adds the infrastructure to detect when running in a non-root cell so that the platform can be configured as required in succeeding steps. Support is limited to x86-64 so far, primarily because no boot loader stub exists for i386 and, thus, we wouldn't be able to test the 32-bit path. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: jailhouse-dev@googlegroups.com Link: https://lkml.kernel.org/r/7f823d077b38b1a70c526b40b403f85688c137d3.1511770314.git.jan.kiszka@siemens.com
- Loading branch information
1 parent
a09c5ec
commit 4a36260
Showing
7 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* SPDX-License-Identifier: GPL2.0 */ | ||
|
||
/* | ||
* Jailhouse paravirt_ops implementation | ||
* | ||
* Copyright (c) Siemens AG, 2015-2017 | ||
* | ||
* Authors: | ||
* Jan Kiszka <jan.kiszka@siemens.com> | ||
*/ | ||
|
||
#ifndef _ASM_X86_JAILHOUSE_PARA_H | ||
#define _ASM_X86_JAILHOUSE_PARA_H | ||
|
||
#include <linux/types.h> | ||
|
||
#ifdef CONFIG_JAILHOUSE_GUEST | ||
bool jailhouse_paravirt(void); | ||
#else | ||
static inline bool jailhouse_paravirt(void) | ||
{ | ||
return false; | ||
} | ||
#endif | ||
|
||
#endif /* _ASM_X86_JAILHOUSE_PARA_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// SPDX-License-Identifier: GPL2.0 | ||
/* | ||
* Jailhouse paravirt_ops implementation | ||
* | ||
* Copyright (c) Siemens AG, 2015-2017 | ||
* | ||
* Authors: | ||
* Jan Kiszka <jan.kiszka@siemens.com> | ||
*/ | ||
|
||
#include <linux/kernel.h> | ||
#include <asm/cpu.h> | ||
#include <asm/hypervisor.h> | ||
#include <asm/setup.h> | ||
|
||
static __initdata struct jailhouse_setup_data setup_data; | ||
|
||
static uint32_t jailhouse_cpuid_base(void) | ||
{ | ||
if (boot_cpu_data.cpuid_level < 0 || | ||
!boot_cpu_has(X86_FEATURE_HYPERVISOR)) | ||
return 0; | ||
|
||
return hypervisor_cpuid_base("Jailhouse\0\0\0", 0); | ||
} | ||
|
||
static uint32_t __init jailhouse_detect(void) | ||
{ | ||
return jailhouse_cpuid_base(); | ||
} | ||
|
||
static void __init jailhouse_init_platform(void) | ||
{ | ||
u64 pa_data = boot_params.hdr.setup_data; | ||
struct setup_data header; | ||
void *mapping; | ||
|
||
while (pa_data) { | ||
mapping = early_memremap(pa_data, sizeof(header)); | ||
memcpy(&header, mapping, sizeof(header)); | ||
early_memunmap(mapping, sizeof(header)); | ||
|
||
if (header.type == SETUP_JAILHOUSE && | ||
header.len >= sizeof(setup_data)) { | ||
pa_data += offsetof(struct setup_data, data); | ||
|
||
mapping = early_memremap(pa_data, sizeof(setup_data)); | ||
memcpy(&setup_data, mapping, sizeof(setup_data)); | ||
early_memunmap(mapping, sizeof(setup_data)); | ||
|
||
break; | ||
} | ||
|
||
pa_data = header.next; | ||
} | ||
|
||
if (!pa_data) | ||
panic("Jailhouse: No valid setup data found"); | ||
|
||
if (setup_data.compatible_version > JAILHOUSE_SETUP_REQUIRED_VERSION) | ||
panic("Jailhouse: Unsupported setup data structure"); | ||
} | ||
|
||
bool jailhouse_paravirt(void) | ||
{ | ||
return jailhouse_cpuid_base() != 0; | ||
} | ||
|
||
const struct hypervisor_x86 x86_hyper_jailhouse __refconst = { | ||
.name = "Jailhouse", | ||
.detect = jailhouse_detect, | ||
.init.init_platform = jailhouse_init_platform, | ||
}; |