| spuisofs [message #735] |
Sun, 04 March 2012 14:56  |
glevand
Messages: 955 Registered: July 2011 Location: SONY
|
Gitbrew God |
|
|
Currently i'm studying Linux and FreeBSD VFS layer.
And need a small project, filesystem, to implement in order to test my new knowledge.
It would be nice to have a file system which allows to run isolated SPUs, no need for /proc hacks anymore like in spp_verifier_direct module. And we could load metldr and isolated SPUs directly from user space. Nice project
[Updated on: Sun, 04 March 2012 14:57] Report message to a moderator
|
|
|
|
| Re: spuisofs [message #736 is a reply to message #735] |
Sun, 04 March 2012 15:01   |
glevand
Messages: 955 Registered: July 2011 Location: SONY
|
Gitbrew God |
|
|
A kernel module should register a new filesystem which is a memory filesystem.
The memory filesystem should use the shared 7th SPU of PS3, map its resources and create for each SPU resource a file
on the filesystem. Each file(resource) is accessible by user space. Resources are registers, local store and so on, just like in spufs from IBM.
[Updated on: Sun, 04 March 2012 15:02] Report message to a moderator
|
|
|
|
| Re: spuisofs [message #737 is a reply to message #736] |
Sun, 04 March 2012 15:06   |
glevand
Messages: 955 Registered: July 2011 Location: SONY
|
Gitbrew God |
|
|
One problem i encountered is that when we load metldr from user space, the SPU will use the page table of the current process.
What happens when the user process which loaded metldr into its memory address space is swapped out ? Have to check how spufs handles this problem.
[Updated on: Sun, 04 March 2012 15:08] Report message to a moderator
|
|
|
|
| Re: spuisofs [message #738 is a reply to message #737] |
Sun, 04 March 2012 16:27   |
glevand
Messages: 955 Registered: July 2011 Location: SONY
|
Gitbrew God |
|
|
One possible way to solve the problem is creating a buffer in kernel space where a user application can store metldr and isolated SPUs.
Memory space in kernel will not be swapped out and we are safe to run metldr even if our user process is swapped out. It solves the problem but only partially. The problem is still there in case we have to pass some data from PPE to SPU by pointer, e.g. in SPP verifier we are passing an encrypted profile to the SPU and the SPU decrypts it and stores the data back. As soon as the SPU tries to access the profile buffer, we will get data storage interrupt from the SPU and it will stop until we fix it.
[Updated on: Sun, 04 March 2012 16:33] Report message to a moderator
|
|
|
|
| Re: spuisofs [message #739 is a reply to message #738] |
Sun, 04 March 2012 16:36   |
glevand
Messages: 955 Registered: July 2011 Location: SONY
|
Gitbrew God |
|
|
So we need at least 2 buffers in kernel space which will be visible in spuisofs so user space applications can store metldr and isolated SPUs there. Max size of a buffer is 256kb because the locaal storage size is 256kb. A buffer may be noncontiguous even which simplifies a lot of things in kernel. Just allocate number of pages for each buffer.
[Updated on: Sun, 04 March 2012 16:36] Report message to a moderator
|
|
|
|
| Re: spuisofs [message #740 is a reply to message #739] |
Sun, 04 March 2012 16:43   |
glevand
Messages: 955 Registered: July 2011 Location: SONY
|
Gitbrew God |
|
|
Hmm, another possible solution is to use mlock syscall and lock down metldr and isolated SPU buffers in user space.
Probably the best solution because then we can store everything in user space but mlock syscall can be used by root only but that's not a problem anyways.
[Updated on: Sun, 04 March 2012 16:43] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Re: spuisofs [message #1635 is a reply to message #1633] |
Sun, 15 July 2012 10:01   |
glevand
Messages: 955 Registered: July 2011 Location: SONY
|
Gitbrew God |
|
|
Layout of filesystem:
[glevand@arch ~]$ ls -l /mnt
total 0
-rw-rw-rw- 1 root root 1048576 Jul 15 10:17 app
-rw-rw-rw- 1 root root 1048576 Jul 15 10:17 arg1
-rw-rw-rw- 1 root root 1048576 Jul 15 10:17 arg2
-rw-rw-rw- 1 root root 262144 Jul 15 10:17 ls
-rw-rw-rw- 1 root root 131072 Jul 15 10:17 priv2
-rw-rw-rw- 1 root root 131072 Jul 15 10:17 problem
-r--r--r-- 1 root root 4096 Jul 15 10:17 shadow
And we need one file more which we can use to trigger the execution of an SPE application.
1MB for application, 1MB for argument1 and 1MB for argument2 should be more than enough.
kmalloc is not a good choice for memory buffers of size >= 128kb.
vmalloc has no problems with allocating 1MB buffer in kernel space.
[Updated on: Sun, 15 July 2012 12:49] Report message to a moderator
|
|
|
|
|
|
| Re: spuisofs [message #1639 is a reply to message #1636] |
Tue, 17 July 2012 18:08   |
masterzorag
Messages: 99 Registered: August 2011 Location: maiworld
|
Gitbrew Member |
|
|
ready to test on FAT, Linux 3.4.5
[root@fedora_clone dev]# modinfo /home/testing_3.4.5/spuisofs.ko
filename: /home/testing_3.4.5/spuisofs.ko
license: GPL
author: glevand
description: PS3 spuisofs
depends:
vermagic: 3.4.5 SMP mod_unload
parm: spuisofs_spe_app_size:ulong
parm: spuisofs_spe_arg1_size:ulong
parm: spuisofs_spe_arg2_size:ulong
...
spusisofs: vas id 2
spusisofs: spe id 53
spusisofs: spe app ea d0000000008f0000 esid d000000008000000 vsid f09b89af5500
spusisofs: spe arg1 ea d0000000009f1000 esid d000000008000000 vsid f09b89af5500
spusisofs: spe arg2 ea d000000000af2000 esid d000000008000000 vsid f09b89af5500
...
-rw-rw-rw- 1 root root 1048576 Jul 16 13:08 app
-rw-rw-rw- 1 root root 1048576 Jul 16 13:08 arg1
-rw-rw-rw- 1 root root 1048576 Jul 16 13:08 arg2
-rw-rw-rw- 1 root root 262144 Jul 16 13:08 ls
-rw-rw-rw- 1 root root 131072 Jul 16 13:08 priv2
-rw-rw-rw- 1 root root 131072 Jul 16 13:08 problem
--w--w--w- 1 root root 8 Jul 16 13:08 run
-r--r--r-- 1 root root 4096 Jul 16 13:08 shadow
[Updated on: Tue, 17 July 2012 18:19] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Re: spuisofs [message #1647 is a reply to message #1645] |
Tue, 17 July 2012 21:03   |
glevand
Messages: 955 Registered: July 2011 Location: SONY
|
Gitbrew God |
|
|
Mega cool First working version of spuisofs released.
Now you can run your isolated apps without writing your own kernel modules.
Now it can be done from user space.
Currently no support for loading loaders like metldr or isoldr directly. For that purpose i will develop spuldrfs.
All tools you will find here: http://gitbrew.org/~glevand/ps3/linux/linux-3/spuisofs/
How to use it (example with spp_verifier.self):
First compile spuisofs kernel module
* http://gitbrew.org/~glevand/ps3/linux/linux-3/spuisofs/spuis ofs.tar.gz
You will need extra patches for kernel:
* http://gitbrew.org/~glevand/ps3/linux/linux-3/patches-3.4/01 80-lv1call-add-undocumented-spe-hvcalls.patch
* http://gitbrew.org/~glevand/ps3/linux/linux-3/patches-3.4/01 90-export-spe-irq-setup-destroy.patch
Load it:
Mount VFS:
mount -t spuisofs none /mnt
Layout of the filesystem:
[glevand@arch spp_verifier]$ ls -l /mnt/
total 0
-rw-rw-rw- 1 root root 1048576 Jul 17 21:35 app
-rw-rw-rw- 1 root root 1048576 Jul 17 21:35 arg1
-rw-rw-rw- 1 root root 1048576 Jul 17 21:35 arg2
--w--w--w- 1 root root 0 Jul 17 21:35 cont
-rw-rw-rw- 1 root root 262144 Jul 17 21:35 ls
-rw-rw-rw- 1 root root 131072 Jul 17 21:35 priv2
-rw-rw-rw- 1 root root 131072 Jul 17 21:35 problem
--w--w--w- 1 root root 8 Jul 17 21:35 run
-r--r--r-- 1 root root 4096 Jul 17 21:35 shadow
Compile spp_verifier application
* http://gitbrew.org/~glevand/ps3/linux/linux-3/spuisofs/spp_v erifier.tar.gz
And run it:
[glevand@arch spp_verifier]$ ./spp_verifier /mnt ../spp_verifier.self ../default.spp
shadow: execution status 7
priv2: puint_mb_R 2
shadow: execution status b
dmesg output:
spusisofs: vas id 2
spusisofs: spe id 50
spusisofs: got class 1 irq
spusisofs: status 1
spusisofs: data segment fault at d000000002a39000
spusisofs: out interrupt mbox 2
spusisofs: got class 2 irq
spusisofs: status 12
Now see the result of it:
[glevand@arch spp_verifier]$ hexdump -C /mnt/arg1 | less
000004f0 2f 66 6c 68 2f 6f 73 2f 6c 76 32 5f 6b 65 72 6e |/flh/os/lv2_kern|
00000500 65 6c 2e 73 65 6c 66 00 00 00 00 00 00 00 00 00 |el.self.........|
00000510 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
000005f0 00 00 00 00 00 00 00 1b 00 00 00 00 00 00 00 00 |................|
00000600 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 01 |................|
00000610 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00000710 00 00 00 00 0f 00 00 00 00 00 00 00 00 00 00 03 |................|
00000720 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 01 |................|
00000730 00 00 02 88 00 00 00 01 10 20 00 00 03 00 00 01 |......... ......|
00000740 00 00 00 00 00 00 00 00 50 53 32 5f 4c 50 41 52 |........PS2_LPAR|
00000750 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000760 00 00 00 00 00 00 00 00 00 00 00 06 00 00 02 50 |...............P|
00000770 10 20 00 00 03 00 00 01 2f 6c 6f 63 61 6c 5f 73 |. ....../local_s|
00000780 79 73 30 2f 70 73 32 65 6d 75 2f 70 73 32 5f 65 |ys0/ps2emu/ps2_e|
00000790 6d 75 2e 73 65 6c 66 00 00 00 00 00 00 00 00 00 |mu.self.........|
000007a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
Note: the first release of spuisofs can run SELFS only once, after that you have t umount the filesystem, unload the module and redo everything. I will fix it in the next release.
That's it. Have fun and report bugs to me.
I will try to upload some more applications which use other SELFs.
[Updated on: Tue, 17 July 2012 21:14] Report message to a moderator
|
|
|
|
| Re: spuisofs [message #1648 is a reply to message #1647] |
Tue, 17 July 2012 21:11   |
zecoxao
Messages: 24 Registered: April 2012 Location: Portugal
|
Gitbrew Noob |
|
|
spusisofs: vas id 2
spusisofs: spe id 50
spusisofs: spe app ea d000000000b9b000 esid d000000008000000 vsid f09b89af5500
spusisofs: spe arg1 ea d000000000c9c000 esid d000000008000000 vsid f09b89af5500
spusisofs: spe arg2 ea d000000000d9d000 esid d000000008000000 vsid f09b89af5500
------------[ cut here ]------------
WARNING: at fs/inode.c:336
Modules linked in: spuisofs(O) bnep rfcomm fuse vfat fat usb_storage evdev joydev usbhid ps3_jupiter_sta btusb bluetooth ps3_jupiter ohci_hcd ehci_hcd snd_ps3 snd_pcm usbcore snd_timer snd sg ps3flash ps3vram ps3_gelic soundcore ps3_disp_manager usb_common ps3rom ps3nflash ps3_lpm rtc_ps3 snd_page_alloc
NIP: c000000000121ef4 LR: d000000000b917fc CTR: c000000000121ee0
REGS: c00000000609b490 TRAP: 0700 Tainted: G O (3.4.4)
MSR: 8000000000028032 <SF,EE,IR,DR,RI> CR: 84442482 XER: 20000000
SOFTE: 1
TASK = c000000006094440[1900] 'mount' THREAD: c000000006098000 CPU: 1
GPR00: 0000000000000001 c00000000609b710 c0000000006e3fd0 c000000006c12b00
GPR04: 0000000000000001 c000000000121f84 0000000000000000 0000000000000000
GPR08: 000000000002a148 0000000000000000 000000002cd29bfb 0000000000000001
GPR12: d000000000b92510 c000000007ffe280 0000000000000000 0000000000000000
GPR16: d000000000b93202 d000000000b93208 0000000000040000 d000080080680000
GPR20: d0000800806c0000 d000080080700000 d00008008000e000 0000000000100000
GPR24: d000000000b93888 0000000000100000 d000000000c9c000 ffffffffffff8000
GPR28: c000000006c12b00 c00000000609b780 d000000000b9b508 c0000000067ef800
NIP [c000000000121ef4] .inc_nlink+0x14/0x50
LR [d000000000b917fc] .spuisofs_fill_super+0x1e4/0x344 [spuisofs]
Call Trace:
[c00000000609b710] [d000000000b917dc] .spuisofs_fill_super+0x1c4/0x344 [spuisofs] (unreliable)
[c00000000609b970] [c00000000010833c] .mount_single+0xec/0x120
[c00000000609ba10] [d000000000b91140] .spuisofs_mount+0x20/0x38 [spuisofs]
[c00000000609ba90] [c0000000001085d8] .mount_fs+0x40/0xf0
[c00000000609bb20] [c00000000012823c] .vfs_kern_mount+0x6c/0xf0
[c00000000609bbd0] [c00000000012884c] .do_kern_mount+0x64/0x138
[c00000000609bc80] [c00000000012a9cc] .do_mount+0x5c4/0x8e8
[c00000000609bd70] [c00000000015e438] .compat_sys_mount+0x110/0x278
[c00000000609be30] [c0000000000097b4] syscall_exit+0x0/0x38
Instruction dump:
7c60512d 40a2fff4 7c0004ac 3863fc00 78630020 4bffffc0 60000000 81230040
2f890000 7c000026 5400fffe 7c0b07b4 <0b000000> 2fab0000 409e0010 39290001
---[ end trace 022c6541e7ab41c9 ]---
Unable to handle kernel paging request for unknown fault
Faulting instruction address: 0xc000000000121f14
Oops: Kernel access of bad area, sig: 7 [#1]
SMP NR_CPUS=2 PS3
Modules linked in: spuisofs(O) bnep rfcomm fuse vfat fat usb_storage evdev joydev usbhid ps3_jupiter_sta btusb bluetooth ps3_jupiter ohci_hcd ehci_hcd snd_ps3 snd_pcm usbcore snd_timer snd sg ps3flash ps3vram ps3_gelic soundcore ps3_disp_manager usb_common ps3rom ps3nflash ps3_lpm rtc_ps3 snd_page_alloc
NIP: c000000000121f14 LR: d000000000b917fc CTR: c000000000121ee0
REGS: c00000000609b490 TRAP: 0600 Tainted: G W O (3.4.4)
MSR: 8000000000008032 <SF,EE,IR,DR,RI> CR: 84442484 XER: 20000000
SOFTE: 1
DAR: 0000000000001687, DSISR: 40000000
TASK = c000000006094440[1900] 'mount' THREAD: c000000006098000 CPU: 1
GPR00: 0000000000001687 c00000000609b710 c0000000006e3fd0 c000000006c12b00
GPR04: 0000000000000001 c000000000121f84 0000000000000000 0000000000000000
GPR08: 000000000002a148 0000000000001067 000000002cd29bfb 0000000000000001
GPR12: d000000000b92510 c000000007ffe280 0000000000000000 0000000000000000
GPR16: d000000000b93202 d000000000b93208 0000000000040000 d000080080680000
GPR20: d0000800806c0000 d000080080700000 d00008008000e000 0000000000100000
GPR24: d000000000b93888 0000000000100000 d000000000c9c000 ffffffffffff8000
GPR28: c000000006c12b00 c00000000609b780 d000000000b9b508 c0000000067ef800
NIP [c000000000121f14] .inc_nlink+0x34/0x50
LR [d000000000b917fc] .spuisofs_fill_super+0x1e4/0x344 [spuisofs]
Call Trace:
[c00000000609b710] [d000000000b917dc] .spuisofs_fill_super+0x1c4/0x344 [spuisofs] (unreliable)
[c00000000609b970] [c00000000010833c] .mount_single+0xec/0x120
[c00000000609ba10] [d000000000b91140] .spuisofs_mount+0x20/0x38 [spuisofs]
[c00000000609ba90] [c0000000001085d8] .mount_fs+0x40/0xf0
[c00000000609bb20] [c00000000012823c] .vfs_kern_mount+0x6c/0xf0
[c00000000609bbd0] [c00000000012884c] .do_kern_mount+0x64/0x138
[c00000000609bc80] [c00000000012a9cc] .do_mount+0x5c4/0x8e8
[c00000000609bd70] [c00000000015e438] .compat_sys_mount+0x110/0x278
[c00000000609be30] [c0000000000097b4] syscall_exit+0x0/0x38
Instruction dump:
2f890000 7c000026 5400fffe 7c0b07b4 0b000000 2fab0000 409e0010 39290001
91230040 4e800020 e9230028 38090620 <7d6000a8> 316bffff 7d6001ad 40a2fff4
---[ end trace 022c6541e7ab41ca ]---
i guess this is what you're looking for
|
|
|
|
|
|
|
|
|
|
| Re: spuisofs [message #1653 is a reply to message #1651] |
Tue, 17 July 2012 21:57   |
zecoxao
Messages: 24 Registered: April 2012 Location: Portugal
|
Gitbrew Noob |
|
|
you mean dtbImage? i'm not following sorry . i got the precompiled kernel from the site, patched with patches 0180 and 0190, compiled the kernel with those patches, and compiled spuisofs . normally to test the kernel i add an entry to kboot.conf with vmlinux as image and copy all the contents of precompiled kernel to root.
[Updated on: Tue, 17 July 2012 21:58] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
| Re: spuisofs [message #1679 is a reply to message #1665] |
Wed, 18 July 2012 18:53   |
glevand
Messages: 955 Registered: July 2011 Location: SONY
|
Gitbrew God |
|
|
lv1_undocumented_function_168(spuisofs_spe_id, 0x3000, 1ull << 32)
It restarts DMA controller of SPU after data segment/page fault.
The LV1 call modifies MFC_CNTL register.
[Updated on: Thu, 19 July 2012 22:09] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
| Re: spuisofs [message #1706 is a reply to message #1705] |
Thu, 19 July 2012 22:52   |
glevand
Messages: 955 Registered: July 2011 Location: SONY
|
Gitbrew God |
|
|
Another cool feature would be using LV1 call lv1_set_spe_transition_notifier.
This way we don't have to poll spe_execution_status from shadow area and just wait for an interrupt from LV1.
Another thing is why do i not get MBOX interrupt (class 2 spe interrupt) ??? Have to figure it out.
[Updated on: Thu, 19 July 2012 22:53] Report message to a moderator
|
|
|
|
|
|
|
|
| Re: spuisofs [message #1714 is a reply to message #1713] |
Fri, 20 July 2012 15:27   |
glevand
Messages: 955 Registered: July 2011 Location: SONY
|
Gitbrew God |
|
|
Ok, here is the second SELF application.
As promised here an example how to run aim_spu_module.self with spuisofs.
First you should update spuisofs.
[glevand@arch aim]$ make
gcc -O2 -Wall -c aim.c
gcc -o aim aim.o
[glevand@arch aim]$ ./aim ../aim_spu_module.self ../eid0 1
spuisofs found at /mnt
arg1 kernel virtual address d000000001390000
shadow: spe_execution_status 7
priv2: puint_mb_R 2
shadow: spe_execution_status b
[glevand@arch aim]$
[glevand@arch aim]$ hexdump -C /mnt/arg1 | less
00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 85 |................|
00000010 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00000080 28 73 70 75 29 73 74 61 72 74 20 61 69 6d 20 73 |(spu)start aim s|
00000090 70 75 20 6d 6f 64 75 6c 65 21 0a 00 00 00 00 00 |pu module!......|
000000a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
At offset 0x80 you see the debug buffer where aim_spu_module.self writes its messages.
When the application is done, first 0x10 bytes in arg1 is the result.
Here is the AIM application: http://gitbrew.org/~glevand/ps3/linux/linux-3/spuisofs/aim.t ar.gz
Have fun.
[Updated on: Fri, 20 July 2012 15:29] Report message to a moderator
|
|
|
|