2026-05-12 23:01:40 +02:00
|
|
|
#include "main.h"
|
2026-05-12 23:32:23 +02:00
|
|
|
#include "boot_linux.h"
|
2026-05-16 09:43:48 +02:00
|
|
|
#include "hv_defeat_0304.h"
|
2026-05-12 23:01:40 +02:00
|
|
|
#include "utils.h"
|
2026-05-13 16:31:10 +02:00
|
|
|
#include <stddef.h>
|
2026-05-12 23:01:40 +02:00
|
|
|
|
2026-05-13 11:09:19 +02:00
|
|
|
shellcode_kernel_args args = {0};
|
2026-05-12 23:01:40 +02:00
|
|
|
|
2026-05-13 11:09:19 +02:00
|
|
|
// We are being called instead of AcpiSetFirmwareWakingVector
|
2026-05-12 23:01:40 +02:00
|
|
|
__attribute__((section(".entry_point"))) uint32_t main(uint64_t add1,
|
|
|
|
|
uint64_t add2) {
|
2026-05-13 11:09:19 +02:00
|
|
|
// We will do main checks on .text only with a reference to .data
|
2026-05-12 23:01:40 +02:00
|
|
|
volatile shellcode_kernel_args *args_ptr =
|
|
|
|
|
(volatile shellcode_kernel_args
|
|
|
|
|
*)0x11AA11AA11AA11AA; // To be replaced with proper address in .kdata
|
|
|
|
|
|
|
|
|
|
// "Hide" the pointer from the optimizer
|
|
|
|
|
__asm__ volatile("" : "+r"(args_ptr));
|
|
|
|
|
|
|
|
|
|
// We don't have required information - Abort
|
|
|
|
|
if ((args_ptr->fun_printf & 0xFFFF) == 0) {
|
2026-05-13 16:31:10 +02:00
|
|
|
return -1;
|
2026-05-12 23:01:40 +02:00
|
|
|
}
|
|
|
|
|
|
2026-05-13 16:31:10 +02:00
|
|
|
activate_uart(args_ptr);
|
2026-05-12 23:01:40 +02:00
|
|
|
|
2026-05-13 16:31:10 +02:00
|
|
|
if ((0x0300 <= args_ptr->fw_version) && (args_ptr->fw_version < 0x0500)) {
|
2026-05-16 09:43:48 +02:00
|
|
|
if (hv_defeat_0304(args_ptr))
|
2026-05-13 16:31:10 +02:00
|
|
|
return -1;
|
|
|
|
|
} else if ((0x0500 <= args_ptr->fw_version) &&
|
|
|
|
|
(args_ptr->fw_version < 0x0650)) {
|
2026-05-17 11:54:10 +02:00
|
|
|
// Already escaped.
|
2026-05-12 23:01:40 +02:00
|
|
|
} else {
|
2026-05-13 16:31:10 +02:00
|
|
|
return 0;
|
2026-05-12 23:01:40 +02:00
|
|
|
}
|
|
|
|
|
|
2026-05-17 11:54:10 +02:00
|
|
|
// Now we can R/W on .text
|
|
|
|
|
init_global_pointers(args_ptr);
|
|
|
|
|
|
|
|
|
|
// Disable CFI to allow smp_rendezvous.
|
|
|
|
|
*(uint8_t *)args_ptr->kernel_cfi_check = 0xC3;
|
|
|
|
|
|
2026-05-13 16:31:10 +02:00
|
|
|
boot_linux();
|
|
|
|
|
printf("Linux prepared OK\n");
|
|
|
|
|
|
|
|
|
|
printf("Good Bye VM :)\n");
|
|
|
|
|
smp_rendezvous(smp_no_rendevous_barrier, vmmcall_dummy,
|
|
|
|
|
smp_no_rendevous_barrier, NULL);
|
|
|
|
|
|
|
|
|
|
printf("We shouldn't be here :(\n");
|
2026-05-12 23:01:40 +02:00
|
|
|
return 0;
|
|
|
|
|
}
|