Skip to content

Linux payload implementing HV exploits to run a custom bootloader

C

Fix the build after the 11.xx merge (#65)

Gabe Zimbric99c763386b03
diff --git a/shellcode_kernel_1160/display_ops_1160.c b/shellcode_kernel_1160/display_ops_1160.c
index 6265d07..6aef6bc 100644
--- a/shellcode_kernel_1160/display_ops_1160.c
+++ b/shellcode_kernel_1160/display_ops_1160.c
@@ -100,7 +100,6 @@ dispatch_ps5_display_op_1160(uint32_t index) {
case 0x1140: op = &ps5_display_ops_1140[index]; break;
default: op = &ps5_display_ops_1160[index]; break;
}
- const ps5_display_op_1160 *op = &ps5_display_ops_1160[index];
const uintptr_t target = args.ktext + op->ktext_offset;
if (op->mode == 2)
diff --git a/shellcode_kernel_1160/shellcode_kernel_args_validate.h b/shellcode_kernel_1160/shellcode_kernel_args_validate.h
index c380ffa..1a406e7 100644
--- a/shellcode_kernel_1160/shellcode_kernel_args_validate.h
+++ b/shellcode_kernel_1160/shellcode_kernel_args_validate.h
@@ -21,7 +21,6 @@ static inline int validate_shellcode_kernel_args_1160(
candidate->fw_version != 0x1120 &&
candidate->fw_version != 0x1140 &&
candidate->fw_version != 0x1160))
- if (candidate == NULL || candidate->fw_version != 0x1160)
return -1;
if (!shellcode_kernel_va_is_canonical(candidate->ktext) ||
diff --git a/source/hv_defeat_1160.c b/source/hv_defeat_1160.c
index fef264b..5621d70 100644
--- a/source/hv_defeat_1160.c
+++ b/source/hv_defeat_1160.c
@@ -135,7 +135,6 @@ static int offsets_present(void) {
/* Every 11.x build shares the same hypervisor image and CC cave. */
if (env_offset.HV_CODE_CAVE_PA != 0x62806F00ULL ||
env_offset.HV_HANDLE_VMEXIT_PA != 0x62847551ULL)
- if (kernel_get_fw_version() != FW_1160_RAW || fw != 0x1160)
return 0;
if (env_offset.KERNEL_CODE_CAVE != 0xD2B000ULL ||
env_offset.DATA_CAVE != 0x2D02000ULL)
diff --git a/source/loader.c b/source/loader.c
index 480ac83..af888a6 100644
--- a/source/loader.c
+++ b/source/loader.c
@@ -205,7 +205,6 @@ int fetch_linux(struct linux_info *info) {
strcpy(info->cmdline, cmdline);
if (PS5_FW_IS_11XX(fw)) {
- if (fw == 0x1160) {
// 11.60 stages the aliases with a checked, journaled transaction instead
// of the install_page_syscore loop below.
int staged = stage_linux_aliases_1160(
diff --git a/source/main.c b/source/main.c
index ab9bff9..56d1f0d 100644
--- a/source/main.c
+++ b/source/main.c
@@ -13,7 +13,6 @@
// files are staged, so it must not exit after that.
static int fail_after_staging(void) {
if (PS5_FW_IS_11XX(fw)) {
- if (fw == 0x1160) {
notify("Linux files are still staged. Cold reboot before trying again.\n");
while (1)
sleep(30);
@@ -53,7 +52,6 @@ int main(void) {
if (hv_defeat_13xx(shellcode_kernel, shellcode_kernel_len))
goto err;
} else if (PS5_FW_IS_11XX(fw)) {
- } else if (fw == 0x1160) {
if (hv_defeat_1160(shellcode_kernel, shellcode_kernel_len))
goto err;
} else {
diff --git a/source/prepare_resume.c b/source/prepare_resume.c
index bb090f8..b4cbada 100644
--- a/source/prepare_resume.c
+++ b/source/prepare_resume.c
@@ -165,7 +165,6 @@ int prepare_resume(void **shellcode_kernel, size_t *shellcode_kernel_len) {
shellcode_src = stock_shellcode_kernel_1360;
shellcode_len = stock_shellcode_kernel_1360_len;
} else if (PS5_FW_IS_11XX(fw)) {
- } else if (fw == 0x1160) {
shellcode_src = shellcode_kernel_1160_bin;
shellcode_len = shellcode_kernel_1160_bin_len;
}
@@ -173,7 +172,6 @@ int prepare_resume(void **shellcode_kernel, size_t *shellcode_kernel_len) {
if ((fw == 0x1300 || fw == 0x1320) && shellcode_len > 0x3910)
return -1;
if (PS5_FW_IS_11XX(fw) && shellcode_len > 0x5000)
- if (fw == 0x1160 && shellcode_len > 0x5000)
return -1;
*shellcode_kernel =
@@ -201,7 +199,6 @@ int prepare_resume(void **shellcode_kernel, size_t *shellcode_kernel_len) {
}
if (PS5_FW_IS_11XX(fw) ? remove_xotext_1160(shellcode_len) : remove_xotext()) {
- if (fw == 0x1160 ? remove_xotext_1160(shellcode_len) : remove_xotext()) {
printf("Error: could not remove xo from text\n");
return -1;
}
@@ -259,8 +256,8 @@ uint64_t prepare_sck_args(void) {
args.kernel_cfi_check = ktext + env_offset.KERNEL_CFI_CHECK;
args.hv_handle_vmexit_pa = env_offset.HV_HANDLE_VMEXIT_PA;
args.hv_code_cave_pa = env_offset.HV_CODE_CAVE_PA;
- if ((PS5_FW_IS_11XX(fw) || fw == 0x1320 || fw == 0x1360) &&
- if ((fw == 0x1320 || fw == 0x1340 || fw == 0x1342 || fw == 0x1360) &&
+ if ((PS5_FW_IS_11XX(fw) || fw == 0x1320 || fw == 0x1340 || fw == 0x1342 ||
+ fw == 0x1360) &&
linux_i.kit_type == KIT_RETAIL_PRO) {
uint64_t pro_base = derive_h() + HV_CODE_OFFSET_PRO;
uint64_t hv_offset = pro_base - HV_BASE_REGULAR;
@@ -271,14 +268,12 @@ uint64_t prepare_sck_args(void) {
args.linux_info_va = linux_i.linux_info;
if (PS5_FW_IS_11XX(fw) && validate_shellcode_kernel_args_1160(&args))
- if (fw == 0x1160 && validate_shellcode_kernel_args_1160(&args))
return 0;
uint64_t args_pa = alloc_page();
// Keep the args page off the page under the #SX stack, which the wake stack
// reaches past 0x1040 bytes. Pages taken here stay allocated.
while (PS5_FW_IS_11XX(fw) && args_pa && pa_under_sx_stack_1160(args_pa))
- while (fw == 0x1160 && args_pa && pa_under_sx_stack_1160(args_pa))
args_pa = alloc_page();
if (!args_pa)
return 0;
@@ -290,7 +285,6 @@ uint64_t prepare_sck_args(void) {
memcmp(&args, &readback, sizeof(args)))
return 0;
if (PS5_FW_IS_11XX(fw) && validate_shellcode_kernel_args_1160(&readback))
- if (fw == 0x1160 && validate_shellcode_kernel_args_1160(&readback))
return 0;
return args_cave;
diff --git a/source/utils.c b/source/utils.c
index 46a07b6..eb06ea3 100644
--- a/source/utils.c
+++ b/source/utils.c
@@ -118,7 +118,6 @@ int set_offsets(void) {
}
env_offset = off_1140;
break;
- case 0x1160:
case 0x1160:
// Only the retail 11.60 build on a regular PS5 has been tested.
if (kernel_get_fw_version() != 0x11600005U) {