Subject: Re: unexpected machine check on AlphaStation 500
To: None <port-alpha@netbsd.org>
From: ITOH Yasufumi <itohy@netbsd.org>
List: port-alpha
Date: 08/06/2001 12:40:59
  Hello,

I wrote:
> The logout frame seems similar to the ev5 one.
> Okay, I'll try and write some code in the weekend.

I wrote the system dependent check code
which just use the EV5 one (see below),
and I have output like this.
I haven't analyzed it, though. :)

      Processor Machine Check (670), Code 0x98
	PAL temp[0-1]		= 0x               1 0x           f0c8c
	PAL temp[2-3]		= 0xfffffc0000300498 0x            5200
	PAL temp[4-5]		= 0x       1204715a8 0x       120101830
	PAL temp[6-7]		= 0x       120148000 0xfffffc00003003a0
	PAL temp[8-9]		= 0x1f1e161514020100 0xfffffc000030042c
	PAL temp[10-11]		= 0xfffffc00003002d8 0xfffffc00003003d0
	PAL temp[12-13]		= 0xfffffc0000300370 0x             a0d
	PAL temp[14-15]		= 0x              e4 0x             1f0
	PAL temp[16-17]		= 0x      9806700001 0x               0
	PAL temp[18-19]		= 0x       1fffff390 0xfffffe0016d3e000
	PAL temp[20-21]		= 0x         706c000 0xfffffc00003003fc
	PAL temp[22-23]		= 0xfffffc000066a7e8 0x         8cfc000
	shadow[0-1]			= 0x               0 0x               0
	shadow[2-3]			= 0x               0 0x               0
	shadow[4-5]			= 0x               0 0x               0
	shadow[6-7]			= 0x               0 0x               0

        Excepting Instruction Addr     = 0xfffffc00003002d8
        Summary of arithmetic traps    = 0x0000000000000000
        Exception mask                 = 0x0000000000000000
        Base address for PALcode       = 0x0000000000018000
        Interrupt Status Reg           = 0x0000000000400000
        Current setup of EV5 IBOX      = 0x0000004160020000
        I-CACHE Reg Tag parity error   = 0x0000000000002000
        D-CACHE error Reg              = 0x0000000000000000
        Effective VA                   = 0xfffffe0016d3dfd0
        Reason for D-stream            = 0x0000000000016ad1
        EV5 SCache address             = 0xffffff000001d10f
        EV5 SCache TAG/Data parity     = 0x0000000000000000
        EV5 BC_TAG_ADDR                = 0xffffff800b0d6fff
        EV5 EI_ADDR Phys addr of Xfer  = 0xffffff000004000f
        Fill Syndrome                  = 0x0000000000000c0c
        ei_stat reg                    = 0xfffffff001ffffff
        ld_lock                        = 0xffffff0002a6875f

unexpected machine check:

    mces    = 0x1
    vector  = 0x670
    param   = 0xfffffc0000006060
    pc      = 0xfffffc00003002d8
    ra      = 0xfffffc00003003e0
    code    = 0x98
    curproc = 0xfffffc0007052018
        pid = 329, comm = skkdic-sort


diff -uF^[a-zA-Z_][a-z 	A-Z0-9_]*([^;]*$ sys/arch/alpha/alpha/dec_kn20aa.c.orig sys/arch/alpha/alpha/dec_kn20aa.c
--- sys/arch/alpha/alpha/dec_kn20aa.c.orig	Tue Jun  5 15:12:33 2001
+++ sys/arch/alpha/alpha/dec_kn20aa.c	Sun Aug  5 19:44:01 2001
@@ -46,6 +46,8 @@
 #include <machine/autoconf.h>
 #include <machine/conf.h>
 #include <machine/bus.h>
+#include <machine/alpha.h>
+#include <machine/logout.h>
 
 #include <dev/ic/comreg.h>
 #include <dev/ic/comvar.h>
@@ -75,6 +77,12 @@
 static void dec_kn20aa_cons_init __P((void));
 static void dec_kn20aa_device_register __P((struct device *, void *));
 
+static void dec_kn20aa_mcheck_handler
+	__P((unsigned long, struct trapframe *, unsigned long, unsigned long));
+
+static void dec_kn20aa_mcheck __P((unsigned long, unsigned long,
+				     unsigned long, struct trapframe *));
+
 #ifdef KGDB
 #include <machine/db_machdep.h>
 
@@ -106,6 +114,7 @@ dec_kn20aa_init()
 	platform.iobus = "cia";
 	platform.cons_init = dec_kn20aa_cons_init;
 	platform.device_register = dec_kn20aa_device_register;
+	platform.mcheck_handler = dec_kn20aa_mcheck_handler;
 }
 
 static void
@@ -287,5 +296,56 @@ dec_kn20aa_device_register(dev, aux)
 			found = 1;
 			return;
 		}
+	}
+}
+
+static void
+dec_kn20aa_mcheck(mces, type, logout, framep)
+	unsigned long mces;
+	unsigned long type;
+	unsigned long logout;
+	struct trapframe *framep;
+{
+	struct mchkinfo *mcp;
+	mc_hdr_ev5 *hdr;
+	mc_uc_ev5 *mptr;
+
+	/*
+	 * If we expected a machine check, just go handle it in common code.
+	 */
+	mcp = &curcpu()->ci_mcinfo;
+	if (mcp->mc_expected) {
+		machine_check(mces, framep, type, logout);
+		return;
+	}
+
+	hdr = (mc_hdr_ev5 *) logout;
+	mptr = (mc_uc_ev5 *) (logout + sizeof (*hdr));
+
+	/*
+	 * Now we can finally print some stuff...
+	 */
+	ev5_logout_print(hdr, mptr);
+
+	machine_check(mces, framep, type, logout);
+}
+
+static void
+dec_kn20aa_mcheck_handler(mces, framep, vector, param)
+	unsigned long mces;
+	struct trapframe *framep;
+	unsigned long vector;
+	unsigned long param;
+{
+
+	switch (vector) {
+	case ALPHA_SYS_MCHECK:
+	case ALPHA_PROC_MCHECK:
+		dec_kn20aa_mcheck(mces, vector, param, framep);
+		break;
+	default:
+		printf("KN20AA_MCHECK: unknown check vector 0x%lx\n", vector);
+		machine_check(mces, framep, vector, param);
+		break;
 	}
 }