[Skiboot] [PATCH v2 5/7] Disable attn instruction on boot
Michael Neuling
mikey at neuling.org
Mon May 2 15:26:19 AEST 2016
Currently we don't touch the attn enable bit in HID0 on boot.
When attn is enabled, it's available everywhere including HV=0. This
is very dangerous for the host kernel.
This explicitly disables the attn instruction on all CPUs on boot.
Signed-off-by: Michael Neuling <mikey at neuling.org>
---
core/cpu.c | 16 ++++++++++++++++
core/init.c | 2 ++
include/cpu.h | 1 +
3 files changed, 19 insertions(+)
diff --git a/core/cpu.c b/core/cpu.c
index d113d77..1611562 100644
--- a/core/cpu.c
+++ b/core/cpu.c
@@ -408,6 +408,15 @@ static void enable_attn(void)
set_hid0(hid0);
}
+static void disable_attn(void)
+{
+ unsigned long hid0;
+
+ hid0 = mfspr(SPR_HID0);
+ hid0 &= ~SPR_HID0_ENABLE_ATTN;
+ set_hid0(hid0);
+}
+
extern void __trigger_attn(void);
void trigger_attn(void)
{
@@ -415,6 +424,12 @@ void trigger_attn(void)
__trigger_attn();
}
+void init_hid(void)
+{
+ /* attn is enabled even when HV=0, so make sure it's off */
+ disable_attn();
+}
+
void pre_init_boot_cpu(void)
{
struct cpu_thread *cpu = this_cpu();
@@ -481,6 +496,7 @@ void init_boot_cpu(void)
init_cpu_thread(boot_cpu, cpu_state_active, pir);
init_boot_tracebuf(boot_cpu);
assert(this_cpu() == boot_cpu);
+ init_hid();
list_head_init(&global_job_queue);
}
diff --git a/core/init.c b/core/init.c
index 15fff18..a72972d 100644
--- a/core/init.c
+++ b/core/init.c
@@ -809,6 +809,8 @@ void __noreturn __secondary_cpu_entry(void)
/* Secondary CPU called in */
cpu_callin(cpu);
+ init_hid();
+
/* Wait for work to do */
while(true) {
int i;
diff --git a/include/cpu.h b/include/cpu.h
index 9eaf59c..587cd52 100644
--- a/include/cpu.h
+++ b/include/cpu.h
@@ -120,6 +120,7 @@ static inline void __nomcount cpu_relax(void)
void pre_init_boot_cpu(void);
void init_boot_cpu(void);
void init_all_cpus(void);
+void init_hid(void);
/* This brings up our secondaries */
extern void cpu_bringup(void);
--
2.7.4
More information about the Skiboot
mailing list