User talk:Masterzorag

From PS3 Developer wiki
Revision as of 15:34, 27 June 2014 by Masterzorag (talk | contribs) (spkg speculation)
Jump to navigation Jump to search

SPU Problems on Linux > 3.2, OpenCL related

As far as I know, I'm the only coding OpenCL on the Cell here, if someone want to test something be warned that due some spufs changes that ppc-kernel-devs are (maybe) trying to fix, latest 3.3/3.4/3.5 branches falls into 'possible circular locking dependency detected' and slowdown runtime.

  • It's stable until 3.2 branch.
  • Even disabling lock debugging it slowdowns without warnings, it happens even with OpenCL samples from IBM.

http://permalink.gmane.org/gmane.linux.ports.ppc.embedded/50547

Latest tested kernels:

  • 3.2.55 works fine
# ./perlin
OpenCL took 22.496168 seconds to compute 1000 frames. Pixel Rate = 46.611316 Mpixels/sec, Frame Rate = 44.452015 frames/sec
Host code took 12.620616 seconds to compute 10 frames. Pixel Rate = 0.830844 Mpixels/sec, Frame Rate = 0.792354 frames/sec
OpenCL provided a 56.101182 speedup
  • 3.3.3/3.4.6/3.5.3 falls into 'possible circular locking dependency detected' and slowdown runtime

Here the slowdown effect:

# ./perlin
OpenCL took 93.280273 seconds to compute 1000 frames. Pixel Rate = 11.241133 Mpixels/sec, Frame Rate = 10.720380 frames/sec
Host code took 12.948244 seconds to compute 10 frames. Pixel Rate = 0.809821 Mpixels/sec, Frame Rate = 0.772305 frames/sec
OpenCL provided a 13.881010 speedup

In this specific case time spent is 4x to do the same thing!
When program runs something is going weird, e.g. in my program I'm used to query an OpenCL builtin function to tell me how many available SPEs there are, and its reply 8.
Using spu_base.enum_shared=1 parameter it should reply 7, so seems that the issue is OpenCL related.

OtherOS region

OtherOS/OtherOS++ region is on HDD (ps3dd), we have new linux tools (ps3sed) and drivers.
To resize ps3da I've tried new ps3sed (manually), unsuccesfully: GameOS always detect corruption and redo its own things.

I've found a way to force resize on 4.46, no emer_init patch, no downgrading: GameOS respect standards.
I can now resize ps3da at arbitrary size.
Swapping HDD on pc is necessary to me to send a couple to SET MAX ADDRESS ata commands to get the job done: set the limit, left GameOS (partition and) format, then reset size back the same way.
On boot all regions are fine, plus empty space as tail, nice to fit a fouth region.

Here I've forced ps3da to use 1216709344 sectors, this left me about 16G for ps3dd.
After that GameOS do it own things, I've resetted ps3da to its real geometry (1250263728) and booted a new petitboot.

root@ps3-linux:~# dmesg | grep ps3disk
[    3.220526] ps3disk_init:601: registered block device major 254
[    3.220549] ps3_system_bus_match:369: dev=6.0(sb_04), drv=6.0(ps3disk): match
[    3.220856] ps3disk sb_04: accessible region 0 start 0 size 1250263728
[    3.220952] ps3disk sb_04: accessible region 1 start 32 size 1212515008
[    3.221045] ps3disk sb_04: accessible region 2 start 1212515040 size 4194296
[    3.221051] ps3disk sb_04: ps3stor_probe_access:133: 3 accessible regions found
[    3.227341] ps3disk sb_04: ps3da is a SAMSUNG HM641JI (610480 MiB total, 610480 MiB region)
[    3.229035] ps3disk sb_04: ps3db is a SAMSUNG HM641JI (610480 MiB total, 592048 MiB region)
[    3.230008] ps3disk sb_04: ps3dc is a SAMSUNG HM641JI (610480 MiB total, 2047 MiB region)

root@ps3-linux:~# ps3sed print_region 3
   0                0       1250263728    1
   1               32       1212515008    8
   2       1212515040          4194296    8

root@ps3-linux:~# create_hdd_region.sh
INFO: device id 3
INFO: number of regions 3
INFO: total number of blocks 1250263728
INFO: last region start block 1212515040
INFO: last region number of blocks 4194296
INFO: new region start block 1216709344
INFO: new region number of blocks 33554376
INFO: new region id 3

root@ps3-linux:~# ps3sed print_region 3
   0                0       1250263728    1
   1               32       1212515008    8
   2       1212515040          4194296    8
   3       1216709344         33554376    1

root@ps3-linux:~# reboot && exit

Last number 1 is wrong, it says that last region has only one acl entry, we need to fix it at 8 entries:

  • manually with ps3sed
  • rebooting

Petitboot finally detect a new ps3dd device, the fourth region, of (33554376 * 512 =) 17179840512 bytes.
All of this with a 3.10.26 kernel and new tools: no vflash hacking involved, linux on vflash7 is deprecated.

Sometimes HDD is reported as second device (something buggy in my kernel?):

root@ps3-linux:~# ps3sed print_device
     flash    1      512           491008        7
     cdrom    3     2048       2147483647        1
      disk    2      512       1250263728        4

00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000010  00 00 00 00 0f ac e0 ff  00 00 00 00 de ad fa ce  |................|
00000020  00 00 00 00 00 00 00 03  00 00 00 00 00 00 00 02  |................|
00000030  00 00 00 00 00 00 00 20  00 00 00 00 48 45 82 c0  |....... ....HE..|
00000040  10 70 00 00 02 00 00 01  00 00 00 00 00 00 00 03  |.p..............|
00000050  10 70 00 00 01 00 00 01  00 00 00 00 00 00 00 03  |.p..............|
00000060  10 20 00 00 03 00 00 01  00 00 00 00 00 00 00 03  |. ..............|
00000070  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000000c0  00 00 00 00 48 45 82 e0  00 00 00 00 00 3f ff f8  |....HE.......?..|
000000d0  10 70 00 00 02 00 00 01  00 00 00 00 00 00 00 03  |.p..............|
000000e0  10 70 00 00 01 00 00 01  00 00 00 00 00 00 00 03  |.p..............|
000000f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000150  00 00 00 00 48 85 82 e0  00 00 00 00 01 ff ff c8  |....H...........|
00000160  10 70 00 00 02 00 00 01  00 00 00 00 00 00 00 03  |.p..............|
00000170  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000400

ps3vuart-tools

We miss some stuff from old ps3sm-utils, looking to port: temperature, get_fan_policy and set_fan_policy to new ps3vuart-tools.
We need to enable some sort of fan control on petitboot now.

root@fedora_clone ~]# /home/ps3vuart-tools-2012-09-01/ps3sm/ps3sm get_fan_policy 0
0x01 0x01 0x48 0x00

[root@fedora_clone ~]# /home/ps3vuart-tools-2012-09-01/ps3sm/ps3sm temperature 0
01 00 00 00 3f 49 00 00

Updating the Real Time Clock with hwclock results in error:

Mar 31 18:09:18 fedora_clone kernel: os_area_queue_work_handler: Could not update FLASH ROM

UPL.xml.pkg

Into

tar -t -f update_files.tar

ls UPL.xml.unpkg/
-rw-r--r-- 1 0 0 2.8K Jun 27 13:40 content
-rw-r--r-- 1 0 0   64 Jun 27 13:40 info0
-rw-r--r-- 1 0 0   64 Jun 27 13:40 info1
...
-rwxr-xr-x 1 0 0  640 Jun 27 15:20 UPL.xml.pkg.spkg_hdr.1

UPL.xml.unpkg/content:                XML document text
UPL.xml.unpkg/info0:                  data
UPL.xml.unpkg/info1:                  data
UPL.xml.unpkg/UPL.xml.pkg.spkg_hdr.1: data

scetool -v -i update_files.untar/UPL.xml.pkg [*] Using keyset [pkg 0x0000 03.55] [*] Header decrypted. [*] Data decrypted. [*] SCE Header: Magic 0x53434500 [OK] Version 0x00000002 Key Revision 0x0000 Header Type [PKG] Metadata Offset 0x00000000 Header Length 0x0000000000000280 Data Length 0x0000000000000B9D // 2973 bytes, content + info0 + info1 [*] Metadata Info: Key 87 EE 46 44 60 DA DA EA 49 74 58 F9 02 1D 6D 11 IV F4 9F 43 D8 D0 6A F0 FC 33 AF 5E 6E CF 2F 30 1E [*] Metadata Header: Signature Input Length 0x0000000000000250 unknown_0 0x00000001 Section Count 0x00000003 Key Count 0x00000014 Optional Header Size 0x00000000 unknown_1 0x00000000 unknown_2 0x00000000 [*] Metadata Section Headers: Idx Offset Size Type Index Hashed SHA1 Encrypted Key IV Compressed 000 00000280 00000040 01 01 [YES] 00 [NO ] -- -- [NO ] 001 000002C0 00000040 02 02 [YES] 06 [NO ] -- -- [NO ] 002 00000300 0000016B 03 03 [YES] 0C [YES] 12 13 [YES] [*] SCE File Keys: n 14

Signature Input Length 0x0000000000000250

00000020 25 b7 b7 25 8f 96 e9 7c 29 ee 2d 51 51 04 f4 da |%..%...|).-QQ...| 00000030 29 ea 39 dc 81 1a 66 65 fd 5d 22 46 17 e5 9b ee |).9...fe.]"F....| 00000040 64 e6 cd 3f bf de e7 17 ed 2d 00 f3 6f 03 59 88 |d..?.....-..o.Y.| 00000050 78 b9 6e bc 14 21 a0 99 19 1d 64 23 fb 49 8e c6 |x.n..!....d#.I..| 00000060 da 4d 44 bf 40 ac 25 16 98 58 6f ba bc dc 78 d0 |.MD.@.%..Xo...x.| 00000070 f9 f5 eb 7f 4e 02 c6 c8 41 ab b9 25 51 08 fb 98 |....N...A..%Q...| 00000080 87 e4 6b 15 b2 8e fc 30 11 a3 a3 3c 63 e7 e0 0a |..k....0...<c...| 00000090 d6 0a 5c 0f 35 5a 14 ed 63 49 ec 7e 4c b2 bb be |..\.5Z..cI.~L...| 000000a0 ce aa 0e 0f c4 30 e5 e2 fd d0 4d 7e 6f 49 c8 b7 |.....0....M~oI..| 000000b0 1d 93 d1 bb 8e 59 73 cd 35 e3 08 31 e7 14 96 64 |.....Ys.5..1...d| 000000c0 da da 2a 1d 6a e5 7d b9 19 0c ef d2 20 57 cc bb |..*.j.}..... W..| 000000d0 70 22 4a 47 f9 11 ec dc 96 dd e9 47 aa 06 56 18 |p"JG.......G..V.| 000000e0 39 b5 98 cd 36 08 33 3f fa e7 fd fc bf 61 a1 f0 |9...6.3?.....a..| 000000f0 f4 d4 b7 f5 14 7b 37 d2 9f aa 16 9c de f2 64 79 |.....{7.......dy| 00000100 e9 e0 a8 e9 6d 07 f7 fa da 61 8d ca 97 2c f9 10 |....m....a...,..| 00000110 0c 2f af bc 96 f8 00 2e 47 08 5d 15 53 7f 97 c8 |./......G.].S...| 00000120 58 a5 66 39 85 62 1d 1d 0b fc 8a 43 e1 d5 dc 08 |X.f9.b.....C....| 00000130 b5 67 aa 56 74 3b d7 fb 3a 6e 93 9b d5 eb c0 90 |.g.Vt;..:n......| 00000140 ae 97 3f af 33 4b 92 87 13 fe 8f 3c 61 28 9b 91 |..?.3K.....<a(..| 00000150 14 f7 13 fd 20 d3 b4 3a 91 d5 9e bc 9a 99 da d5 |.... ..:........| 00000160 fd 6f 89 55 ef ab f4 8b 5a 5b 79 8d e6 4f 0c 51 |.o.U....Z[y..O.Q| 00000170 6f be 61 1a 8d b4 45 f7 ab c9 d7 69 35 68 0e 57 |o.a...E....i5h.W| 00000180 83 2d b9 6c b4 45 a2 31 5b 0a 70 c9 4e 09 48 a1 |.-.l.E.1[.p.N.H.| 00000190 7c b4 b8 93 91 6c f4 ad ec 5c 4a f3 66 5b 18 94 ||....l...\J.f[..| 000001a0 bb b5 1a 59 4f 90 fe c3 eb 10 fe 57 22 45 51 e7 |...YO......W"EQ.| 000001b0 1c 2e 55 87 6a d8 0b 0f 80 40 a7 aa 6f cc 47 0c |[email protected].| 000001c0 ff 41 b4 6a bf 08 94 5b bd 32 60 12 d2 f3 25 c0 |.A.j...[.2`...%.| 000001d0 62 29 c3 76 78 f0 dc b3 85 d7 91 98 36 24 f6 f6 |b).vx.......6$..| 000001e0 33 3a 35 b0 e9 d1 b6 05 31 65 7a f5 05 2d f2 3c |3:5.....1ez..-.<| 000001f0 a5 90 de c9 74 94 e1 47 96 ec b8 e2 a7 29 18 ba |....t..G.....)..| 00000200 12 a8 54 81 98 3c 0a e2 b2 42 4c 1d 75 03 c3 86 |..T..<...BL.u...| 00000210 29 27 34 9c 83 d9 01 34 8e c6 ca e7 a6 c0 c8 ef |)'4....4........| 00000220 25 b2 43 8e e8 b1 77 5c c0 e8 02 44 6a 92 f1 17 |%.C...w\...Dj...| 00000230 7c 7c c4 a1 1e 75 13 42 99 8c c2 7d 7b 85 56 87 |||...u.B...}{.V.| 00000240 e2 b3 0e e3 05 bf 19 7d 70 83 d5 c2 00 e4 5b 47 |.......}p.....[G| 00000250 1e af b4 96 f3 9e 3b ec c4 85 29 50 13 79 55 f1 |......;...)P.yU.| 00000260 ab bb a2 c2 12 f8 d0 60 1d 8a 08 16 8f a5 bd 08 |.......`........| 00000270 ed b6 f0 a7 11 21 92 b5 ce 11 dd 13 4e 80 60 3d |.....!......N.`=|

hexdump -C UPL.xml.pkg.spkg_hdr.1

00000020  7b be 81 a6 f2 8d 41 3e  cf 59 63 bc 22 03 54 44  |{.....A>.Yc.".TD|
00000030  3d 17 d9 a3 ee 72 21 c4  38 21 fe 81 79 52 b2 29  |=....r!.8!..yR.)|
00000040  a9 dc ea 8c 91 5b 45 81  3d ee f3 e0 04 bd 2e 74  |.....[E.=......t|
00000050  d5 1e 11 23 86 f2 29 a2  df f1 64 94 a0 1f 7d de  |...#..)...d...}.|
00000060  68 4e 60 50 85 ea 64 bd  c8 df 6d 94 f1 db ff 65  |hN`P..d...m....e|
00000070  31 e7 62 09 f5 dc 63 d4  53 3c 25 06 f6 60 64 19  |1.b...c.S<%..`d.|
00000080  40 89 05 1e e2 30 5e 10  9d ec 0f ad 04 6d a5 ef  |@....0^......m..|
00000090  1b 90 10 8f 8e d8 a7 04  8f 9f a5 19 d5 89 d7 c3  |................|
000000a0  07 92 19 52 b7 1e 61 cb  af 93 71 b7 fd 55 02 67  |...R..a...q..U.g|
000000b0  97 98 0f 72 0c 20 e9 45  11 78 9d fd d7 1b 54 68  |...r. .E.x....Th|
000000c0  d3 26 91 58 9e 02 5f dc  72 67 3b 16 9c 84 ce 96  |.&.X.._.rg;.....|
000000d0  70 d8 af d8 72 79 a0 f6  5a 9d 12 69 49 aa 6a 4a  |p...ry..Z..iI.jJ|
000000e0  39 9a 8c 21 b0 d0 34 08  46 52 0a 62 07 cc 9b dd  |9..!..4.FR.b....|
000000f0  de 39 62 85 07 19 1a 40  67 14 c8 60 26 bf 6a 90  |.9b....@g..`&.j.|
00000100  8d 85 4a 12 d4 56 69 b5  01 a1 32 ad 3e 23 ae 36  |..J..Vi...2.>#.6|
00000110  41 fc f4 c2 f7 0e 64 88  f1 51 0a 6f af 87 e5 4f  |A.....d..Q.o...O|
00000120  8a 33 f7 d8 3d 11 76 98  e3 72 ac fb 3a 12 64 6d  |.3..=.v..r..:.dm|
00000130  fc 06 06 9d 69 c1 1d 50  9c cb 50 72 a4 6e ff d1  |....i..P..Pr.n..|
00000140  1e cc 14 13 d4 19 c9 15  f0 8c ad 35 19 46 e6 aa  |...........5.F..|
00000150  bb e0 0f d1 9a b7 5b 4f  98 1f f0 28 89 ab 31 db  |......[O...(..1.|
00000160  0a ef e2 3a 14 a6 7d 3b  2f 9f 9d d1 30 9c aa a9  |...:..};/...0...|
00000170  f3 6f 48 fb 18 93 82 bc  6c 57 e6 3d 93 db 8d 76  |.oH.....lW.=...v|
00000180  4a e0 01 1a 5c dd d7 74  08 54 03 d5 83 75 db 60  |J...\..t.T...u.`|
00000190  4a b8 21 3d 8c 83 e2 b0  ac 5d 7e e5 df 4f 27 8b  |J.!=.....]~..O'.|
000001a0  62 e1 7d 38 14 f5 1b 1c  bb 90 8a 39 15 45 33 4f  |b.}8.......9.E3O|
000001b0  a2 d7 e2 24 55 12 f2 27  71 a6 ee 55 aa b2 01 d1  |...$U..'q..U....|
000001c0  4c ba 77 82 41 17 05 da  0f d7 06 06 20 1c 96 eb  |L.w.A....... ...|
000001d0  10 e5 60 46 f6 02 5a 40  2a 48 07 6a ce 0a fd 3b  |..`F..Z@*H.j...;|
000001e0  06 e4 99 dc 4e b4 7f f8  08 94 7d b3 0a 33 04 2d  |....N.....}..3.-|
000001f0  e8 20 0f 31 9a c2 9c b3  b1 9a ad 0d 82 5d bd 43  |. .1.........].C|
00000200  d7 41 90 2c 33 aa 57 5b  01 97 f9 8b 1b 80 2b f4  |.A.,3.W[......+.|
00000210  03 21 31 58 16 0a ba a0  bb 62 20 d4 5e c6 a6 78  |.!1X.....b .^..x|
00000220  69 22 71 e7 b0 af 76 c8  c0 7e 6d e1 cc 87 7d 67  |i"q...v..~m...}g|
00000230  7a fe 9d 24 18 0e 16 90  c2 b1 79 49 28 9b 04 9d  |z..$......yI(...|
00000240  18 0d fd 51 93 c0 60 83  59 e2 9c 5e 80 1a cd ae  |...Q..`.Y..^....|
00000250  1a d4 d3 41 0a 74 fd 79  c0 be 15 0d 1c 0a e0 15  |...A.t.y........|
00000260  fe d6 14 69 9a 16 41 2b  d5 4d 32 f3 69 14 48 6f  |...i..A+.M2.i.Ho|
00000270  49 81 92 4c e2 04 ec 05  8b d8 a0 88 6e 19 50 ea  |I..L........n.P.|

hexdump -C UPL.xml.pkg


00000280  00 00 00 03 00 00 00 04  00 00 00 00 00 00 00 0a  |................|
00000290  20 14 06 19 01 15 45 00  00 00 00 00 00 00 0b 1d  | .....E.........|
000002a0  00 00 00 00 00 00 01 6b  00 00 00 00 00 00 00 00  |.......k........|
000002b0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

000002c0  00 00 00 00 00 00 00 03  00 00 00 00 00 00 00 40  |...............@|
000002d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 0b 1d  |................|
000002e0  00 00 00 00 00 00 00 01  00 00 00 00 00 00 00 01  |................|
000002f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

We got info0 + info1, 64bytes each
content is 2845bytes, total is data lenght 2973
info0, info1 are not encrypted
  • How the Signature Input in UPL.xml.pkg is verified by UPL.xml.pkg.spkg_hdr.1

. are info0/info1 involved in check or hashing function?

. is .spkg_hdr.1 a resulting data of crypto-hashed Signature Input?