[PATCH 06/10] x86: jailhouse: Avoid access of unsupported platform resources

From: Jan Kiszka
Date: Thu Nov 16 2017 - 02:36:15 EST


From: Jan Kiszka <jan.kiszka@xxxxxxxxxxx>

We don't have CMOS access, thus we can't set the warm-reset vectors in
do_boot_cpu. There is no RTC, thus also no wall clock. Furthermore,
there are no ISA IRQs and no PIC. So fill the platform callbacks
accordingly.

Signed-off-by: Jan Kiszka <jan.kiszka@xxxxxxxxxxx>
---
arch/x86/kernel/jailhouse.c | 10 ++++++++++
arch/x86/kernel/smpboot.c | 7 +++++--
2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/jailhouse.c b/arch/x86/kernel/jailhouse.c
index 8e5b2f0c8a34..cfe8ae0c33a2 100644
--- a/arch/x86/kernel/jailhouse.c
+++ b/arch/x86/kernel/jailhouse.c
@@ -15,6 +15,7 @@
#include <asm/apic.h>
#include <asm/cpu.h>
#include <asm/hypervisor.h>
+#include <asm/i8259.h>
#include <asm/setup.h>

#define SETUP_JAILHOUSE 0x53484c4a /* "JLHS" */
@@ -50,6 +51,11 @@ static uint32_t __init jailhouse_detect(void)
return jailhouse_cpuid_base();
}

+static void jailhouse_get_wallclock(struct timespec *now)
+{
+ memset(now, 0, sizeof(*now));
+}
+
#define MAX_RETRIES 5
#define SMI_TRESHOLD 50000

@@ -139,7 +145,11 @@ static void __init jailhouse_init_platform(void)
unsigned int cpu;

x86_init.timers.timer_init = jailhouse_timer_init;
+ x86_init.irqs.pre_vector_init = x86_init_noop;
+ legacy_pic = &null_legacy_pic;

+ x86_platform.legacy.rtc = 0;
+ x86_platform.get_wallclock = jailhouse_get_wallclock;
x86_platform.calibrate_cpu = jailhouse_calibrate_cpu;
x86_platform.calibrate_tsc = jailhouse_calibrate_tsc;

diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 5f59e6bee123..81339dbafeba 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -78,6 +78,7 @@
#include <asm/realmode.h>
#include <asm/misc.h>
#include <asm/qspinlock.h>
+#include <asm/jailhouse_para.h>

/* Number of siblings per CPU package */
int smp_num_siblings = 1;
@@ -1006,7 +1007,8 @@ 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 (get_uv_system_type() != UV_NON_UNIQUE_APIC &&
+ !jailhouse_paravirt()) {

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

@@ -1078,7 +1080,8 @@ 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 (get_uv_system_type() != UV_NON_UNIQUE_APIC &&
+ !jailhouse_paravirt()) {
/*
* Cleanup possible dangling ends...
*/
--
2.12.3