Skip to contentSkip to conversation

PPC64: Make OpenBIOS interrupt handlers 64bit aware

PATCH New Alexander Graf 1 participant 1 message Feb 28, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PPC64: Make OpenBIOS interrupt handlers 64bit aware

While booting a 64bit kernel, there is a small timeframe where OF and the kernel communicate with each other. Within that timeframe, DSI/ISI interrupts may occur, because some memory is not mapped yet.

Right now in case that happens, we jump into the DSI/ISI interrupt handler which clobbers the high 32 bits of the kernel's registers. In order to circumvent that, let's save/restore all 64 bits of all kernel registers when we get a DSI/ISI interrupt.

In order to make use of this patch in qemu, a separate patch is required that makes qemu not run the interrupt handlers from ROM, but from RAM. It will follow on the qemu list shortly.

This patch enables a PPC64 Linux kernel to boot up to the point where it tries to set up the SLB entries (slbmte), which is not yet implemented in qemu.

ppc/qemu/init.c +25 -0
Index: arch/ppc/qemu/init.c
===================================================================
@@ -238,7 +238,27 @@
     fword("finish-device");
 }
 
+/* In order to get 64 bit aware handlers that rescue all our
+   GPRs from getting truncated to 32 bits, we need to patch the
+   existing handlers so they jump to our 64 bit aware ones. */
 static void
+ppc64_patch_handlers(void)
+{
+    uint32_t *dsi = (uint32_t *)0x300UL;
+    uint32_t *isi = (uint32_t *)0x400UL;
+
+    // Patch the first DSI handler instruction to: ba 0x2000
+    *dsi = 0x48002002;
+
+    // Patch the first ISI handler instruction to: ba 0x2200
+    *isi = 0x48002202;
+
+    // Invalidate the cache lines
+    asm ( "icbi 0, %0" : : "r"(dsi) );
+    asm ( "icbi 0, %0" : : "r"(isi) );
+}
+
+static void
 cpu_970_init(const struct cpudef *cpu)
 {
     cpu_generic_init(cpu);
@@ -249,6 +269,11 @@
     fword("property");
 
     fword("finish-device");
+
+    /* The 970 is a PPC64 CPU, so we need to activate
+     * 64bit aware interrupt handlers */
+
+    ppc64_patch_handlers();
 }
 
 static const struct cpudef ppc_defs[] = {
ppc/qemu/start.S +155 -47

232 lines not on this page · raw message