On Wed, 15 Apr 2009 09:55:08 -0400
David Boyes <[email protected]> wrote:

> Rather than testing for specific model numbers, why don't you test for
> specific capabilities that you need/want? That way you get a exception that
> you can handle and actually issue a useful message or load a specific PSW
> (similar to the way things work on other OSes), rather than just dying in a
> cryptic way.

How about this:

Subject: [PATCH] use facility list for cpu type safety check

From: Martin Schwidefsky <[email protected]>

Signed-off-by: Martin Schwidefsky <[email protected]>
---
 arch/s390/include/asm/lowcore.h |    1
 arch/s390/kernel/head.S         |   49 +++++++++++++++++++++++++++-------------
 2 files changed, 35 insertions(+), 15 deletions(-)

diff -urpN linux-2.6/arch/s390/include/asm/lowcore.h 
linux-2.6-patched/arch/s390/include/asm/lowcore.h
--- linux-2.6/arch/s390/include/asm/lowcore.h   2009-04-17 09:37:40.000000000 
+0200
+++ linux-2.6-patched/arch/s390/include/asm/lowcore.h   2009-04-17 
12:14:06.000000000 +0200
@@ -30,6 +30,7 @@
 #define __LC_SUBCHANNEL_NR             0x00ba
 #define __LC_IO_INT_PARM               0x00bc
 #define __LC_IO_INT_WORD               0x00c0
+#define __LC_STFL_FAC_LIST             0x00c8
 #define __LC_MCCK_CODE                 0x00e8

 #define __LC_DUMP_REIPL                        0x0e00
diff -urpN linux-2.6/arch/s390/kernel/head.S 
linux-2.6-patched/arch/s390/kernel/head.S
--- linux-2.6/arch/s390/kernel/head.S   2009-04-17 09:37:40.000000000 +0200
+++ linux-2.6-patched/arch/s390/kernel/head.S   2009-04-17 12:14:06.000000000 
+0200
@@ -478,27 +478,46 @@ startup:basr      %r13,0                  # get base
        mvc     __LC_LAST_UPDATE_TIMER(8),6f-.LPG0(%r13)
        mvc     __LC_EXIT_TIMER(8),5f-.LPG0(%r13)
 #ifndef CONFIG_MARCH_G5
-       # check processor version against MARCH_{G5,Z900,Z990,Z9_109,Z10}
-       stidp   __LC_CPUID              # store cpuid
-       lhi     %r0,(3f-2f) / 2
-       la      %r1,2f-.LPG0(%r13)
-0:     clc     __LC_CPUID+4(2),0(%r1)
-       jne     3f
-       lpsw    1f-.LPG0(13)            # machine type not good enough, crash
+       # check capabilities against MARCH_{G5,Z900,Z990,Z9_109,Z10}
+       xc      __LC_STFL_FAC_LIST(8),__LC_STFL_FAC_LIST
+       stfl    __LC_STFL_FAC_LIST      # store facility list
+       tm      __LC_STFL_FAC_LIST,0x01 # stfle available ?
+       jz      0f
+       la      %r0,0
+       stfle   __LC_STFL_FAC_LIST      # store facility list extended
+0:     l       %r0,__LC_STFL_FAC_LIST
+       n       %r0,2f+8-.LPG0(%r13)
+       cl      %r0,2f+8-.LPG0(%r13)
+       jne     1f
+       l       %r0,__LC_STFL_FAC_LIST
+       n       %r0,2f+12-.LPG0(%r13)
+       cl      %r0,2f+12-.LPG0(%r13)
+       je      3f
+1:     lpsw    2f-.LPG0(13)            # machine type not good enough, crash
        .align 16
-1:     .long   0x000a0000,0x00000000
-2:
+2:     .long   0x000a0000,0x8badcccc
+#if defined(CONFIG_64BIT)
 #if defined(CONFIG_MARCH_Z10)
-       .short 0x9672, 0x2064, 0x2066, 0x2084, 0x2086, 0x2094, 0x2096
+       .long 0xc100efe3, 0xf0680000
 #elif defined(CONFIG_MARCH_Z9_109)
-       .short 0x9672, 0x2064, 0x2066, 0x2084, 0x2086
+       .long 0xc100efc3, 0x00000000
 #elif defined(CONFIG_MARCH_Z990)
-       .short 0x9672, 0x2064, 0x2066
+       .long 0xc0002000, 0x00000000
 #elif defined(CONFIG_MARCH_Z900)
-       .short 0x9672
+       .long 0xc0000000, 0x00000000
 #endif
-3:     la      %r1,2(%r1)
-       brct    %r0,0b
+#else
+#if defined(CONFIG_MARCH_Z10)
+       .long 0x8100c880, 0x00000000
+#elif defined(CONFIG_MARCH_Z9_109)
+       .long 0x8100c880, 0x00000000
+#elif defined(CONFIG_MARCH_Z990)
+       .long 0x80002000, 0x00000000
+#elif defined(CONFIG_MARCH_Z900)
+       .long 0x80000000, 0x00000000
+#endif
+#endif
+3:
 #endif

        l       %r13,4f-.LPG0(%r13)


--
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.

----------------------------------------------------------------------
For LINUX-390 subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO LINUX-390 or visit
http://www.marist.edu/htbin/wlvindex?LINUX-390

Reply via email to