I added a couple changes but wasn't sure how to best make a pull request so here there are.
Would be nice if you could merge:
Patch1: Add --no-dynamic-linker flag
src/payloads/linux/ps4-kexec/Makefile
- -Os -Wall -Werror -Wl,--build-id=none,-T,kexec.ld,--nmagic \
+ -Os -Wall -Werror -Wl,--no-dynamic-linker,--build-id=none,-T,kexec.ld,--nmagic \
Patch2: Add -fno-stack-protector flag
src/payloads/lib/Makefile
- gcc -c -isystem ../../8cc/freebsd-headers -nostdinc dl.c -o dl.o
+ gcc -c -isystem ../../8cc/freebsd-headers -nostdinc dl.c -o dl.o -fno-stack-protector
Patch3:
- Prefer USB over local config
- make bootargs and vram configurable from file
src/payloads/linux/main.c
---------------------------------- PATCHFILE -----------------------------------------
diff --git a/src/payloads/linux/main.c b/src/payloads/linux/main.c
index 4e0db5a..eb1fd53 100644
--- a/src/payloads/linux/main.c
+++ b/src/payloads/linux/main.c
@@ -103,6 +103,15 @@ void alert(const char* msg)
#define VRAM_GB 1
#endif
+#ifndef VRAM_GB_MIN
+#define VRAM_GB_MIN 1
+#endif
+
+#ifndef VRAM_GB_MAX
+#define VRAM_GB_MAX 3
+#endif
+
+
int main()
{
struct sigaction sa = {
@@ -113,23 +122,55 @@ int main()
sigaction(SIGSTOP, &sa, NULL);
sigaction(SIGTERM, &sa, NULL);
sigaction(SIGKILL, &sa, NULL);
- char* kernel;
- unsigned long long kernel_size;
- char* initrd;
- unsigned long long initrd_size;
-#define L(name, where, wheresz)\
- if(read_file("/user/system/boot/" name, where, wheresz)\
- && read_file("/mnt/usb0/" name, where, wheresz)\
- && read_file("/mnt/usb1/" name, where, wheresz))\
+ char* kernel = NULL;
+ unsigned long long kernel_size = 0;
+ char* initrd = NULL;
+ unsigned long long initrd_size = 0;
+ char* cmdline = NULL;
+ unsigned long long cmdline_size = 0;
+ char* vramstr = NULL;
+ unsigned long long vramstr_size = 0;
+
+ int vramgb = 0;
+
+#define L(name, where, wheresz, is_fatal)\
+ if(read_file("/mnt/usb0/" name, where, wheresz)\
+ && read_file("/mnt/usb1/" name, where, wheresz)\
+ && read_file("/user/system/boot/" name, where, wheresz))\
{\
alert("Failed to load file: " name ".\nPaths checked:\n/user/system/boot/" name "\n/mnt/usb0/" name "\n/mnt/usb1/" name);\
- return 1;\
+ if (is_fatal) return 1;\
}
- L("bzImage", &kernel, &kernel_size);
- L("initramfs.cpio.gz", &initrd, &initrd_size);
- char* cmdline = "panic=0 clocksource=tsc radeon.dpm=0 console=tty0 console=ttyS0,115200n8 "
- "console=uart8250,mmio32,0xd0340000 video=HDMI-A-1:1920x1080-24@60 "
- "consoleblank=0 net.ifnames=0 drm.debug=0";
+ L("bzImage", &kernel, &kernel_size, 1);
+ L("initramfs.cpio.gz", &initrd, &initrd_size, 1);
+
+ L("bootargs.txt", &cmdline, &cmdline_size, 0);
+
+ if (cmdline && cmdline_size){
+ for (int i=0; i<cmdline_size; i++) {
+ if (cmdline[i] == '\n') {
+ cmdline[i] = '\0';
+ break;
+ }
+ }
+ }else{
+ cmdline = "panic=0 clocksource=tsc radeon.dpm=0 console=tty0 console=ttyS0,115200n8 "
+ "console=uart8250,mmio32,0xd0340000 video=HDMI-A-1:1920x1080-24@60 "
+ "consoleblank=0 net.ifnames=0 drm.debug=0";
+ }
+
+ L("vram.txt", &vramstr, &vramstr_size, 0);
+
+ if (vramstr && vramstr_size){
+ vramgb = atoi(vramstr);
+ if (vramgb < VRAM_GB_MIN || vramgb > VRAM_GB_MAX){
+ vramgb = VRAM_GB;
+ }
+ }else{
+ vramgb = VRAM_GB;
+ }
+
+
kexec(kernel_main, (void*)0);
long x, y;
struct thr_param thr = {
```