2017-11-27 08:14:56

by Jan Kiszka

[permalink] [raw]
Subject: [PATCH v2 00/12] x86: Add support for running as secondary Jailhouse guest

This series paves the way to run Linux in so-called non-root cells
(guest partitions) of the Jailhouse hypervisor.

Jailhouse [1] was started 4 years ago as an open-source (GPL) leight-
weight hypervisor that statically partitions SMP systems. It's unique in
that it uses one Linux instance, the root cell, as boot loader and
management console. Jailhouse targets use cases for hard real-time and
safety-critical systems that KVM cannot cater due to its inherent
complexity.

Jaihouse can run bare-metal, free and closed-source RTOSes as secondary
guests and, with this series, also x86 Linux instances. While ARM and
ARM64 non-root Linux guests are feasible without extra patches, thanks
to the high configurability via device trees, x86 requires special
platform support, mostly to step away from non-existing resources in a
non-root Jailhouse cell. These differences are:

- no legacy devices such as PIC, PIT, RTC/CMOS, i8042
- no HPET
- no ACPI, no other BIOS services; platform information is provided
from hypervisor config
- APIC and IOAPIC (if any) are available at fixed MMIO addresses and
the APIC is limited to flat physical mode
- no complete PCI topology
- no restart supported
- use precalibrated TSC and APIC timer frequencies

This series ensures that Linux can boot in a non-root cell, including
SMP cells, has working timekeeping and can use the platform UARTs and
PCI devices as assigned to it. In follow-up series, we will propose
optimizations and enhancements for the PCI support, a simplistic debug
console, and some improvement for Linux guests on ARM.

What is not yet in upstream-ready state is a driver for inter-cell
communication. The current implementation of virtual peer-to-peer
network [2] uses an enhanced version of the QEMU ivshmem shared memory
device. However we still need to finish the evaluation of virtio /
vhost-pci options prior to settling over the final interface.

This patch series is also available at

git://git.kiszka.org/linux.git e8d19494b96b

Changes in v2:
- removed calibration in favor of static values now passed from boot
loader
- refactored hypervisor platform setup according to feedback,
specifically
- proper switch to x2APIC ops
- APIC and IOAPIC registration from x86_init.mpparse.get_smp_config
- PCI setup from x86_init.pci.arch_init
- disabled i8042 devices
- control of warm reset setup via platform feature flag
- proper walk of setup data linked list
- decoupled CONFIG_JAILHOUSE from CONFIG_PARAVIRT
- fixed IOAPIC routing setup for UARTs (trigger and polarity set)
- symbolic irqflag values in MP config tables

Jan

[1] http://jailhouse-project.org
[2] http://git.kiszka.org/?p=linux.git;a=shortlog;h=refs/heads/queues/jailhouse

Jan Kiszka (12):
x86/apic: Install an empty physflat_init_apic_ldr
x86: Control warm reset setup via legacy feature flag
x86: Introduce and use MP IRQ trigger and polarity defines
x86/jailhouse: Add infrastructure for running in non-root cell
x86/jailhouse: Enable APIC and SMP support
x86/jailhouse: Enable PMTIMER
x86/jailhouse: Set up timekeeping
x86/jailhouse: Avoid access of unsupported platform resources
x86/jailhouse: Silence ACPI warning
x86/jailhouse: Halt instead of failing to restart
x86/jailhouse: Wire up IOAPIC for legacy UART ports
x86/jailhouse: Initialize PCI support

arch/x86/Kconfig | 9 ++
arch/x86/include/asm/hypervisor.h | 1 +
arch/x86/include/asm/jailhouse_para.h | 27 +++++
arch/x86/include/asm/mpspec_def.h | 14 ++-
arch/x86/include/asm/x86_init.h | 1 +
arch/x86/include/uapi/asm/bootparam.h | 22 ++++
arch/x86/kernel/Makefile | 2 +
arch/x86/kernel/apic/apic_flat_64.c | 16 ++-
arch/x86/kernel/apic/io_apic.c | 20 ++--
arch/x86/kernel/apic/x2apic_uv_x.c | 1 +
arch/x86/kernel/cpu/hypervisor.c | 4 +
arch/x86/kernel/jailhouse.c | 205 ++++++++++++++++++++++++++++++++++
arch/x86/kernel/mpparse.c | 23 ++--
arch/x86/kernel/platform-quirks.c | 1 +
arch/x86/kernel/smpboot.c | 4 +-
arch/x86/platform/intel-mid/sfi.c | 5 +-
drivers/acpi/Kconfig | 32 +++---
17 files changed, 341 insertions(+), 46 deletions(-)
create mode 100644 arch/x86/include/asm/jailhouse_para.h
create mode 100644 arch/x86/kernel/jailhouse.c

--
2.12.3


From 1585212606042281198@xxx Mon Nov 27 09:55:48 +0000 2017
X-GM-THRID: 1585212606042281198
X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread


2017-11-27 08:16:48

by Jan Kiszka

[permalink] [raw]
Subject: [PATCH v2 01/12] x86/apic: Install an empty physflat_init_apic_ldr

From: Jan Kiszka <[email protected]>

As the comment already stated, there is no need for setting up LDR (and
DFR) in physflat mode as it remains unused (see SDM, 10.6.2.1).
flat_init_apic_ldr only served as a placeholder for a nop operation so
far, causing no harm.

That will change when running over the Jailhouse hypervisor. Here we
must not touch LDR in a way that destroys the mapping originally set up
by the Linux root cell. Jailhouse enforces this setting in order to
efficiently validate any IPI requests sent by a cell.

Avoid a needless clash caused by flat_init_apic_ldr by installing a true
nop handler.

Signed-off-by: Jan Kiszka <[email protected]>
---
arch/x86/kernel/apic/apic_flat_64.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
index aa85690e9b64..226a6ab22b35 100644
--- a/arch/x86/kernel/apic/apic_flat_64.c
+++ b/arch/x86/kernel/apic/apic_flat_64.c
@@ -218,6 +218,15 @@ static int physflat_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
return 0;
}

+static void physflat_init_apic_ldr(void)
+{
+ /*
+ * LDR and DFR are not involved in physflat mode, rather:
+ * "In physical destination mode, the destination processor is
+ * specified by its local APIC ID [...]." (Intel SDM, 10.6.2.1)
+ */
+}
+
static void physflat_send_IPI_allbutself(int vector)
{
default_send_IPI_mask_allbutself_phys(cpu_online_mask, vector);
@@ -251,8 +260,7 @@ static struct apic apic_physflat __ro_after_init = {
.dest_logical = 0,
.check_apicid_used = NULL,

- /* not needed, but shouldn't hurt: */
- .init_apic_ldr = flat_init_apic_ldr,
+ .init_apic_ldr = physflat_init_apic_ldr,

.ioapic_phys_id_map = NULL,
.setup_apic_routing = NULL,
--
2.12.3


From 1585198618007457043@xxx Mon Nov 27 06:13:28 +0000 2017
X-GM-THRID: 1585198618007457043
X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread

2017-11-27 08:13:14

by Jan Kiszka

[permalink] [raw]
Subject: [PATCH v2 02/12] x86: Control warm reset setup via legacy feature flag

From: Jan Kiszka <[email protected]>

Allow to turn off the setup of BIOS-managed warm reset via a new flag in
x86_legacy_features. Besides the UV1, we will soon add another platform
that needs this switched off.

Signed-off-by: Jan Kiszka <[email protected]>
---
arch/x86/include/asm/x86_init.h | 1 +
arch/x86/kernel/apic/x2apic_uv_x.c | 1 +
arch/x86/kernel/platform-quirks.c | 1 +
arch/x86/kernel/smpboot.c | 4 ++--
4 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
index aa4747569e23..fc2f082ac635 100644
--- a/arch/x86/include/asm/x86_init.h
+++ b/arch/x86/include/asm/x86_init.h
@@ -212,6 +212,7 @@ enum x86_legacy_i8042_state {
struct x86_legacy_features {
enum x86_legacy_i8042_state i8042;
int rtc;
+ int warm_reset;
int no_vga;
int reserve_bios_regions;
struct x86_legacy_devices devices;
diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
index e1b8e8bf6b3c..6de35fc8fb3a 100644
--- a/arch/x86/kernel/apic/x2apic_uv_x.c
+++ b/arch/x86/kernel/apic/x2apic_uv_x.c
@@ -316,6 +316,7 @@ static int __init uv_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
} else if (!strcmp(oem_table_id, "UVH")) {
/* Only UV1 systems: */
uv_system_type = UV_NON_UNIQUE_APIC;
+ x86_platform.legacy.warm_reset = 0;
__this_cpu_write(x2apic_extra_bits, pnodeid << uvh_apicid.s.pnode_shift);
uv_set_apicid_hibit();
uv_apic = 1;
diff --git a/arch/x86/kernel/platform-quirks.c b/arch/x86/kernel/platform-quirks.c
index 39a59299bfa0..235fe6008ac8 100644
--- a/arch/x86/kernel/platform-quirks.c
+++ b/arch/x86/kernel/platform-quirks.c
@@ -9,6 +9,7 @@ void __init x86_early_init_platform_quirks(void)
{
x86_platform.legacy.i8042 = X86_LEGACY_I8042_EXPECTED_PRESENT;
x86_platform.legacy.rtc = 1;
+ x86_platform.legacy.warm_reset = 1;
x86_platform.legacy.reserve_bios_regions = 0;
x86_platform.legacy.devices.pnpbios = 1;

diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 3d01df7d7cf6..21995490fc5e 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -947,7 +947,7 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle,
* the targeted processor.
*/

- if (get_uv_system_type() != UV_NON_UNIQUE_APIC) {
+ if (x86_platform.legacy.warm_reset) {

pr_debug("Setting warm reset code and vector.\n");

@@ -1019,7 +1019,7 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle,
/* mark "stuck" area as not stuck */
*trampoline_status = 0;

- if (get_uv_system_type() != UV_NON_UNIQUE_APIC) {
+ if (x86_platform.legacy.warm_reset) {
/*
* Cleanup possible dangling ends...
*/
--
2.12.3


From 1588614065554618165@xxx Wed Jan 03 23:00:33 +0000 2018
X-GM-THRID: 1585184727332713868
X-Gmail-Labels: Inbox,Category Forums,Downloaded_2018-01

2017-11-27 08:16:34

by Jan Kiszka

[permalink] [raw]
Subject: [PATCH v2 04/12] x86/jailhouse: Add infrastructure for running in non-root cell

From: Jan Kiszka <[email protected]>

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 <[email protected]>
---
arch/x86/Kconfig | 8 ++++
arch/x86/include/asm/hypervisor.h | 1 +
arch/x86/include/asm/jailhouse_para.h | 27 +++++++++++++
arch/x86/include/uapi/asm/bootparam.h | 22 ++++++++++
arch/x86/kernel/Makefile | 2 +
arch/x86/kernel/cpu/hypervisor.c | 4 ++
arch/x86/kernel/jailhouse.c | 75 +++++++++++++++++++++++++++++++++++
7 files changed, 139 insertions(+)
create mode 100644 arch/x86/include/asm/jailhouse_para.h
create mode 100644 arch/x86/kernel/jailhouse.c

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 8eed3f94bfc7..93c67ae5cfaf 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -797,6 +797,14 @@ config PARAVIRT_TIME_ACCOUNTING
config PARAVIRT_CLOCK
bool

+config JAILHOUSE_GUEST
+ bool "Jailhouse non-root cell support"
+ depends on X86_64
+ ---help---
+ This option allows to run Linux as guest in a Jailhouse non-root
+ cell. You can leave this option disabled if you only want to start
+ Jailhouse and run Linux afterwards in the root cell.
+
endif #HYPERVISOR_GUEST

config NO_BOOTMEM
diff --git a/arch/x86/include/asm/hypervisor.h b/arch/x86/include/asm/hypervisor.h
index 1b0a5abcd8ae..376085cb6244 100644
--- a/arch/x86/include/asm/hypervisor.h
+++ b/arch/x86/include/asm/hypervisor.h
@@ -37,6 +37,7 @@ enum x86_hypervisor_type {
X86_HYPER_XEN_PV,
X86_HYPER_XEN_HVM,
X86_HYPER_KVM,
+ X86_HYPER_JAILHOUSE,
};

struct hypervisor_x86 {
diff --git a/arch/x86/include/asm/jailhouse_para.h b/arch/x86/include/asm/jailhouse_para.h
new file mode 100644
index 000000000000..06a5f41d5451
--- /dev/null
+++ b/arch/x86/include/asm/jailhouse_para.h
@@ -0,0 +1,27 @@
+/*
+ * Jailhouse paravirt_ops implementation
+ *
+ * Copyright (c) Siemens AG, 2015-2017
+ *
+ * Authors:
+ * Jan Kiszka <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2. See
+ * the COPYING file in the top-level directory.
+ */
+
+#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 */
diff --git a/arch/x86/include/uapi/asm/bootparam.h b/arch/x86/include/uapi/asm/bootparam.h
index afdd5ae0fcc4..aebf60357758 100644
--- a/arch/x86/include/uapi/asm/bootparam.h
+++ b/arch/x86/include/uapi/asm/bootparam.h
@@ -9,6 +9,7 @@
#define SETUP_PCI 3
#define SETUP_EFI 4
#define SETUP_APPLE_PROPERTIES 5
+#define SETUP_JAILHOUSE 6

/* ram_size flags */
#define RAMDISK_IMAGE_START_MASK 0x07FF
@@ -126,6 +127,27 @@ struct boot_e820_entry {
__u32 type;
} __attribute__((packed));

+/*
+ * Smallest compatible version of jailhouse_setup_data required by this kernel.
+ */
+#define JAILHOUSE_SETUP_REQUIRED_VERSION 1
+
+/*
+ * The boot loader is passing platform information via this Jailhouse-specific
+ * setup data structure.
+ */
+struct jailhouse_setup_data {
+ u16 version;
+ u16 compatible_version;
+ u16 pm_timer_address;
+ u16 num_cpus;
+ u64 pci_mmconfig_base;
+ u32 tsc_khz;
+ u32 apic_khz;
+ u8 standard_ioapic;
+ u8 cpu_ids[255];
+} __attribute__((packed));
+
/* The so-called "zeropage" */
struct boot_params {
struct screen_info screen_info; /* 0x000 */
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index 81bb565f4497..aed9296dccd3 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -112,6 +112,8 @@ obj-$(CONFIG_PARAVIRT_SPINLOCKS)+= paravirt-spinlocks.o
obj-$(CONFIG_PARAVIRT_CLOCK) += pvclock.o
obj-$(CONFIG_X86_PMEM_LEGACY_DEVICE) += pmem.o

+obj-$(CONFIG_JAILHOUSE_GUEST) += jailhouse.o
+
obj-$(CONFIG_EISA) += eisa.o
obj-$(CONFIG_PCSPKR_PLATFORM) += pcspeaker.o

diff --git a/arch/x86/kernel/cpu/hypervisor.c b/arch/x86/kernel/cpu/hypervisor.c
index bea8d3e24f50..479ca4728de0 100644
--- a/arch/x86/kernel/cpu/hypervisor.c
+++ b/arch/x86/kernel/cpu/hypervisor.c
@@ -31,6 +31,7 @@ extern const struct hypervisor_x86 x86_hyper_ms_hyperv;
extern const struct hypervisor_x86 x86_hyper_xen_pv;
extern const struct hypervisor_x86 x86_hyper_xen_hvm;
extern const struct hypervisor_x86 x86_hyper_kvm;
+extern const struct hypervisor_x86 x86_hyper_jailhouse;

static const __initconst struct hypervisor_x86 * const hypervisors[] =
{
@@ -45,6 +46,9 @@ static const __initconst struct hypervisor_x86 * const hypervisors[] =
#ifdef CONFIG_KVM_GUEST
&x86_hyper_kvm,
#endif
+#ifdef CONFIG_JAILHOUSE_GUEST
+ &x86_hyper_jailhouse,
+#endif
};

enum x86_hypervisor_type x86_hyper_type;
diff --git a/arch/x86/kernel/jailhouse.c b/arch/x86/kernel/jailhouse.c
new file mode 100644
index 000000000000..fd71b278c308
--- /dev/null
+++ b/arch/x86/kernel/jailhouse.c
@@ -0,0 +1,75 @@
+/*
+ * Jailhouse paravirt_ops implementation
+ *
+ * Copyright (c) Siemens AG, 2015-2017
+ *
+ * Authors:
+ * Jan Kiszka <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2. See
+ * the COPYING file in the top-level directory.
+ */
+
+#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,
+};
--
2.12.3


From 1585184980843999002@xxx Mon Nov 27 02:36:42 +0000 2017
X-GM-THRID: 1585184980843999002
X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread

2017-11-27 08:13:33

by Jan Kiszka

[permalink] [raw]
Subject: [PATCH v2 06/12] x86/jailhouse: Enable PMTIMER

From: Jan Kiszka <[email protected]>

Jailhouse exposes the PMTIMER as only reference clock to all cells. Pick
up its address from the setup data. Allow to enable the Linux support of
it by relaxing its strict dependency on ACPI.

Signed-off-by: Jan Kiszka <[email protected]>
Reviewed-by: Thomas Gleixner <[email protected]>
---
arch/x86/Kconfig | 1 +
arch/x86/kernel/jailhouse.c | 4 ++++
drivers/acpi/Kconfig | 32 ++++++++++++++++----------------
3 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 93c67ae5cfaf..bbcbe21ca664 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -800,6 +800,7 @@ config PARAVIRT_CLOCK
config JAILHOUSE_GUEST
bool "Jailhouse non-root cell support"
depends on X86_64
+ select X86_PM_TIMER
---help---
This option allows to run Linux as guest in a Jailhouse non-root
cell. You can leave this option disabled if you only want to start
diff --git a/arch/x86/kernel/jailhouse.c b/arch/x86/kernel/jailhouse.c
index 9682e7089402..267547162a2c 100644
--- a/arch/x86/kernel/jailhouse.c
+++ b/arch/x86/kernel/jailhouse.c
@@ -10,6 +10,7 @@
* the COPYING file in the top-level directory.
*/

+#include <linux/acpi_pmtmr.h>
#include <linux/kernel.h>
#include <asm/apic.h>
#include <asm/cpu.h>
@@ -93,6 +94,9 @@ static void __init jailhouse_init_platform(void)

if (setup_data.compatible_version > JAILHOUSE_SETUP_REQUIRED_VERSION)
panic("Jailhouse: Unsupported setup data structure");
+
+ pmtmr_ioport = setup_data.pm_timer_address;
+ pr_debug("Jailhouse: PM-Timer IO Port: %#x\n", pmtmr_ioport);
}

bool jailhouse_paravirt(void)
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 46505396869e..d650c5b6ec90 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -361,22 +361,6 @@ config ACPI_PCI_SLOT
i.e., segment/bus/device/function tuples, with physical slots in
the system. If you are unsure, say N.

-config X86_PM_TIMER
- bool "Power Management Timer Support" if EXPERT
- depends on X86
- default y
- help
- The Power Management Timer is available on all ACPI-capable,
- in most cases even if ACPI is unusable or blacklisted.
-
- This timing source is not affected by power management features
- like aggressive processor idling, throttling, frequency and/or
- voltage scaling, unlike the commonly used Time Stamp Counter
- (TSC) timing source.
-
- You should nearly always say Y here because many modern
- systems require this timer.
-
config ACPI_CONTAINER
bool "Container and Module Devices"
default (ACPI_HOTPLUG_MEMORY || ACPI_HOTPLUG_CPU)
@@ -564,3 +548,19 @@ config TPS68470_PMIC_OPREGION
using this, are probed.

endif # ACPI
+
+config X86_PM_TIMER
+ bool "Power Management Timer Support" if EXPERT
+ depends on X86 && (ACPI || JAILHOUSE_GUEST)
+ default y
+ help
+ The Power Management Timer is available on all ACPI-capable,
+ in most cases even if ACPI is unusable or blacklisted.
+
+ This timing source is not affected by power management features
+ like aggressive processor idling, throttling, frequency and/or
+ voltage scaling, unlike the commonly used Time Stamp Counter
+ (TSC) timing source.
+
+ You should nearly always say Y here because many modern
+ systems require this timer.
--
2.12.3


From 1598802418335229697@xxx Thu Apr 26 10:00:03 +0000 2018
X-GM-THRID: 1585131103893860787
X-Gmail-Labels: Inbox,Category Forums,Downloaded_2018-04

2017-11-27 08:14:10

by Jan Kiszka

[permalink] [raw]
Subject: [PATCH v2 10/12] x86/jailhouse: Halt instead of failing to restart

From: Jan Kiszka <[email protected]>

Jailhouse provides no guest-initiated restart. So, do not even try to.

Signed-off-by: Jan Kiszka <[email protected]>
---
arch/x86/kernel/jailhouse.c | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/arch/x86/kernel/jailhouse.c b/arch/x86/kernel/jailhouse.c
index 36feb0e4b4fe..c8ee638b6bce 100644
--- a/arch/x86/kernel/jailhouse.c
+++ b/arch/x86/kernel/jailhouse.c
@@ -12,10 +12,12 @@

#include <linux/acpi_pmtmr.h>
#include <linux/kernel.h>
+#include <linux/reboot.h>
#include <asm/apic.h>
#include <asm/cpu.h>
#include <asm/hypervisor.h>
#include <asm/i8259.h>
+#include <asm/reboot.h>
#include <asm/setup.h>

static __initdata struct jailhouse_setup_data setup_data;
@@ -79,6 +81,12 @@ static void __init jailhouse_get_smp_config(unsigned int early)
smp_found_config = 1;
}

+static void jailhouse_no_restart(void)
+{
+ pr_notice("Jailhouse: Restart not supported, halting\n");
+ machine_halt();
+}
+
static void __init jailhouse_init_platform(void)
{
u64 pa_data = boot_params.hdr.setup_data;
@@ -98,6 +106,8 @@ static void __init jailhouse_init_platform(void)

legacy_pic = &null_legacy_pic;

+ machine_ops.emergency_restart = jailhouse_no_restart;
+
while (pa_data) {
mapping = early_memremap(pa_data, sizeof(header));
memcpy(&header, mapping, sizeof(header));
--
2.12.3


From 1585224807652611285@xxx Mon Nov 27 13:09:44 +0000 2017
X-GM-THRID: 1585224807652611285
X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread

2017-11-27 08:13:42

by Jan Kiszka

[permalink] [raw]
Subject: [PATCH v2 07/12] x86/jailhouse: Set up timekeeping

From: Jan Kiszka <[email protected]>

Get the precalibrated frequencies for the TSC and the APIC timer from
the Jailhouse platform info and set the kernel values accordingly.

Signed-off-by: Jan Kiszka <[email protected]>
---
arch/x86/kernel/jailhouse.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)

diff --git a/arch/x86/kernel/jailhouse.c b/arch/x86/kernel/jailhouse.c
index 267547162a2c..effec7d2b480 100644
--- a/arch/x86/kernel/jailhouse.c
+++ b/arch/x86/kernel/jailhouse.c
@@ -18,6 +18,7 @@
#include <asm/setup.h>

static __initdata struct jailhouse_setup_data setup_data;
+static unsigned int precalibrated_tsc_khz;

static uint32_t jailhouse_cpuid_base(void)
{
@@ -33,6 +34,16 @@ static uint32_t __init jailhouse_detect(void)
return jailhouse_cpuid_base();
}

+static void __init jailhouse_timer_init(void)
+{
+ lapic_timer_frequency = setup_data.apic_khz * (1000 / HZ);
+}
+
+static unsigned long jailhouse_get_tsc(void)
+{
+ return precalibrated_tsc_khz;
+}
+
static void __init jailhouse_get_smp_config(unsigned int early)
{
unsigned int cpu;
@@ -68,8 +79,12 @@ static void __init jailhouse_init_platform(void)
struct setup_data header;
void *mapping;

+ x86_init.timers.timer_init = jailhouse_timer_init;
x86_init.mpparse.get_smp_config = jailhouse_get_smp_config;

+ x86_platform.calibrate_cpu = jailhouse_get_tsc;
+ x86_platform.calibrate_tsc = jailhouse_get_tsc;
+
while (pa_data) {
mapping = early_memremap(pa_data, sizeof(header));
memcpy(&header, mapping, sizeof(header));
@@ -97,6 +112,8 @@ static void __init jailhouse_init_platform(void)

pmtmr_ioport = setup_data.pm_timer_address;
pr_debug("Jailhouse: PM-Timer IO Port: %#x\n", pmtmr_ioport);
+
+ precalibrated_tsc_khz = setup_data.tsc_khz;
}

bool jailhouse_paravirt(void)
--
2.12.3


From 1585262596344296996@xxx Mon Nov 27 23:10:22 +0000 2017
X-GM-THRID: 1585262596344296996
X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread

2017-11-27 08:15:56

by Jan Kiszka

[permalink] [raw]
Subject: [PATCH v2 09/12] x86/jailhouse: Silence ACPI warning

From: Jan Kiszka <[email protected]>

Jailhouse support does not depend on ACPI, and does not even use it. But
if it should be enabled, avoid warning about its absence in the
platform.

Signed-off-by: Jan Kiszka <[email protected]>
---
arch/x86/kernel/jailhouse.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/arch/x86/kernel/jailhouse.c b/arch/x86/kernel/jailhouse.c
index f5f459bb7aac..36feb0e4b4fe 100644
--- a/arch/x86/kernel/jailhouse.c
+++ b/arch/x86/kernel/jailhouse.c
@@ -127,6 +127,12 @@ static void __init jailhouse_init_platform(void)
pr_debug("Jailhouse: PM-Timer IO Port: %#x\n", pmtmr_ioport);

precalibrated_tsc_khz = setup_data.tsc_khz;
+
+ /*
+ * Avoid that the kernel complains about missing ACPI tables - there
+ * are none in a non-root cell.
+ */
+ disable_acpi();
}

bool jailhouse_paravirt(void)
--
2.12.3


From 1618425704855905524@xxx Thu Nov 29 00:23:47 +0000 2018
X-GM-THRID: 1586272073717234041
X-Gmail-Labels: Inbox,Category Forums,Downloaded_2018-11

2017-11-27 08:14:28

by Jan Kiszka

[permalink] [raw]
Subject: [PATCH v2 12/12] x86/jailhouse: Initialize PCI support

From: Jan Kiszka <[email protected]>

With this change, PCI devices can be detected and used inside a non-root
cell.

Signed-off-by: Jan Kiszka <[email protected]>
---
arch/x86/kernel/jailhouse.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)

diff --git a/arch/x86/kernel/jailhouse.c b/arch/x86/kernel/jailhouse.c
index 8ff21e1534de..70b857d4b1f5 100644
--- a/arch/x86/kernel/jailhouse.c
+++ b/arch/x86/kernel/jailhouse.c
@@ -18,6 +18,7 @@
#include <asm/hypervisor.h>
#include <asm/i8259.h>
#include <asm/irqdomain.h>
+#include <asm/pci_x86.h>
#include <asm/reboot.h>
#include <asm/setup.h>

@@ -108,6 +109,19 @@ static void jailhouse_no_restart(void)
machine_halt();
}

+static int __init jailhouse_pci_arch_init(void)
+{
+ pci_direct_init(1);
+
+ /*
+ * There are no bridges on the virtual PCI root bus under Jailhouse,
+ * thus no other way to discover all devices than a full scan.
+ */
+ pcibios_last_bus = 0xff;
+
+ return 0;
+}
+
static void __init jailhouse_init_platform(void)
{
u64 pa_data = boot_params.hdr.setup_data;
@@ -117,6 +131,7 @@ static void __init jailhouse_init_platform(void)
x86_init.irqs.pre_vector_init = x86_init_noop;
x86_init.timers.timer_init = jailhouse_timer_init;
x86_init.mpparse.get_smp_config = jailhouse_get_smp_config;
+ x86_init.pci.arch_init = jailhouse_pci_arch_init;

x86_platform.calibrate_cpu = jailhouse_get_tsc;
x86_platform.calibrate_tsc = jailhouse_get_tsc;
@@ -159,6 +174,8 @@ static void __init jailhouse_init_platform(void)

precalibrated_tsc_khz = setup_data.tsc_khz;

+ pci_probe = 0;
+
/*
* Avoid that the kernel complains about missing ACPI tables - there
* are none in a non-root cell.
--
2.12.3


From 1586015025922156460@xxx Wed Dec 06 06:29:55 +0000 2017
X-GM-THRID: 1583334148445829702
X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread