X

Change-Id: Ic9a712358f2aa9e29782bb4047447f2b60b6ccd9
diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c
index 5a7dbff..0d9e1d7 100644
--- a/arch/arm64/kvm/arm.c
+++ b/arch/arm64/kvm/arm.c
@@ -1400,7 +1400,8 @@
 	 */
 	switch (cmd) {
 	case CPU_PM_ENTER:
-		if (__this_cpu_read(kvm_arm_hardware_enabled))
+		if (!kvm_is_protected_mode() &&
+		    __this_cpu_read(kvm_arm_hardware_enabled))
 			/*
 			 * don't update kvm_arm_hardware_enabled here
 			 * so that the hardware will be re-enabled
@@ -1411,7 +1412,8 @@
 		return NOTIFY_OK;
 	case CPU_PM_ENTER_FAILED:
 	case CPU_PM_EXIT:
-		if (__this_cpu_read(kvm_arm_hardware_enabled))
+		if (!kvm_is_protected_mode() &&
+		    __this_cpu_read(kvm_arm_hardware_enabled))
 			/* The hardware was enabled before suspend. */
 			cpu_hyp_reinit();
 
diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-main.c b/arch/arm64/kvm/hyp/nvhe/hyp-main.c
index 822ed4c..27028c6 100644
--- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c
+++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c
@@ -14,6 +14,8 @@
 
 #include <kvm/arm_hypercalls.h>
 
+#include "../debug-pl011.h"
+
 typedef __noreturn unsigned long (*stub_hvc_handler_t)
 	(unsigned long, unsigned long, unsigned long, unsigned long,
 	 unsigned long, struct kvm_cpu_context *);
diff --git a/arch/arm64/kvm/hyp/nvhe/psci.c b/arch/arm64/kvm/hyp/nvhe/psci.c
index 97c562f..5be1f0a 100644
--- a/arch/arm64/kvm/hyp/nvhe/psci.c
+++ b/arch/arm64/kvm/hyp/nvhe/psci.c
@@ -118,7 +118,6 @@
 				  per_cpu_ptr(&kvm_cpu_params, cpu_id)->this_phys_addr,
 				  &res);
 		ret = res.a0;
-		hyp_putx32(ret);
 	} while (ret == PSCI_RET_ALREADY_ON);
 
 	vcpu->arch.power_off = false;
@@ -128,7 +127,7 @@
 	return ret;
 }
 
-int kvm_host_psci_cpu_off(void)
+static int kvm_host_psci_cpu_off(void)
 {
 	nvhe_spinlock_t *cpu_lock = this_cpu_ptr(&kvm_psci_cpu_lock);
 	struct kvm_vcpu *vcpu = this_cpu_ptr(&kvm_host_vcpu);
@@ -137,14 +136,15 @@
 	vcpu->arch.power_off = true;
 	nvhe_spin_unlock(cpu_lock);
 
+	hyp_puts("CPU_OFF");
 	arm_smccc_1_1_smc(PSCI_0_2_FN_CPU_OFF, NULL);
 
 	/* XXX - do we want to panic? */
 	return PSCI_RET_DENIED;
 }
 
-int kvm_host_psci_affinity_info(unsigned long target_affinity,
-				unsigned long lowest_affinity_level)
+static int kvm_host_psci_affinity_info(unsigned long target_affinity,
+				       unsigned long lowest_affinity_level)
 {
 	unsigned int cpu_id;
 	unsigned long target_affinity_mask;
@@ -171,7 +171,7 @@
 	return PSCI_0_2_AFFINITY_LEVEL_OFF;
 }
 
-void __noreturn kvm_host_psci_system_off(void)
+static void __noreturn kvm_host_psci_system_off(void)
 {
 	struct arm_smccc_res res;
 	arm_smccc_1_1_smc(PSCI_0_2_FN_SYSTEM_OFF, &res);
@@ -179,7 +179,7 @@
 	for (;;) {}
 }
 
-void __noreturn kvm_host_psci_system_reset(void)
+static void __noreturn kvm_host_psci_system_reset(void)
 {
 	struct arm_smccc_res res;
 	arm_smccc_1_1_smc(PSCI_0_2_FN_SYSTEM_RESET, &res);
@@ -187,7 +187,7 @@
 	for (;;) {}
 }
 
-int kvm_host_psci_0_2_call(unsigned long func_id, struct kvm_vcpu *host_vcpu)
+static int kvm_host_psci_0_2_call(unsigned long func_id, struct kvm_vcpu *host_vcpu)
 {
 	switch (func_id) {
 	case PSCI_0_2_FN_PSCI_VERSION:
@@ -222,10 +222,13 @@
 {
 	unsigned long func_id = smccc_get_function(host_vcpu);
 	unsigned long func_base = func_id & ~PSCI_0_2_FN_ID_MASK;
+	int ret;
 
 	/* Early exit if this clearly isn't a PSCI call. */
 	if (func_base != PSCI_0_2_FN_BASE && func_base != PSCI_0_2_FN64_BASE)
 		return -EINVAL;
 
-	return kvm_host_psci_0_2_call(func_id, host_vcpu);
+	hyp_putx32(func_id);
+	ret = kvm_host_psci_0_2_call(func_id, host_vcpu);
+	return ret;
 }
diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c
index 92013ec..0ceba72 100644
--- a/drivers/firmware/psci/psci.c
+++ b/drivers/firmware/psci/psci.c
@@ -175,8 +175,10 @@
 	int err;
 	u32 fn;
 
+	pr_info("CPU_OFF %lx...\n", smp_processor_id());
 	fn = psci_function_id[PSCI_FN_CPU_OFF];
 	err = invoke_psci_fn(fn, state, 0, 0);
+	pr_info("CPU_OFF %lx => %d\n", smp_processor_id(), err);
 	return psci_to_linux_errno(err);
 }
 
@@ -185,8 +187,10 @@
 	int err;
 	u32 fn;
 
+	pr_info("CPU_ON %lx...\n", cpuid);
 	fn = psci_function_id[PSCI_FN_CPU_ON];
 	err = invoke_psci_fn(fn, cpuid, entry_point, 0);
+	pr_info("CPU_ON %lx => %d\n", cpuid, err);
 	return psci_to_linux_errno(err);
 }
 
@@ -203,8 +207,12 @@
 static int psci_affinity_info(unsigned long target_affinity,
 		unsigned long lowest_affinity_level)
 {
-	return invoke_psci_fn(PSCI_FN_NATIVE(0_2, AFFINITY_INFO),
-			      target_affinity, lowest_affinity_level, 0);
+	int ret;
+	pr_info("AFFINITY_INFO %lx...\n", target_affinity);
+	ret = invoke_psci_fn(PSCI_FN_NATIVE(0_2, AFFINITY_INFO),
+			     target_affinity, lowest_affinity_level, 0);
+	pr_info("AFFINITY_INFO %lx => %d\n", target_affinity, ret);
+	return ret;
 }
 
 static int psci_migrate_info_type(void)
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index b71eaf5..046f04f 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2237,7 +2237,7 @@
 	return __add_preferred_console(name, idx, options, NULL, false);
 }
 
-bool console_suspend_enabled = true;
+bool console_suspend_enabled = false;
 EXPORT_SYMBOL(console_suspend_enabled);
 
 static int __init console_suspend_disable(char *str)
@@ -2261,9 +2261,13 @@
 	if (!console_suspend_enabled)
 		return;
 	pr_info("Suspending console(s) (use no_console_suspend to debug)\n");
+	pr_info("CHECKPOINT 0.0.1\n");
 	console_lock();
+	pr_info("CHECKPOINT 0.0.2\n");
 	console_suspended = 1;
+	pr_info("CHECKPOINT 0.0.3\n");
 	up_console_sem();
+	pr_info("CHECKPOINT 0.0.4\n");
 }
 
 void resume_console(void)