Major cleanup and prepare for new hv exploit.

This commit is contained in:
Andy Nguyen
2026-05-16 09:43:48 +02:00
parent 85a16afa80
commit fbe5ae0c32
24 changed files with 210 additions and 326 deletions

View File

@@ -3,7 +3,6 @@
#include "../include/linux.h"
#include "utils.h"
#include <stddef.h>
#include <stdint.h>
static struct linux_info info;

View File

@@ -2,11 +2,11 @@
#define MSR_EFER 0xc0000080
#define EFER_SVM (1ULL << 12) // Bit 12: Secure Virtual Machine Enable
// // Virtual Machine Control Register (VM_CR)
// Virtual Machine Control Register (VM_CR)
#define MSR_VM_CR 0xc0010114
#define VM_CR_R_INIT (1ULL << 1) // Bit 1: Intercept INIT
// // MTRRs (Memory Type Range Registers)
// MTRRs (Memory Type Range Registers)
#define MSR_MTRR4kBase 0x00000268
#define MSR_MTRRVarBase 0x00000200

View File

@@ -1,7 +1,6 @@
#include "../include/config.h"
#include "boot_linux.h"
#include "utils.h"
#include <stdint.h>
__attribute__((section(".entry_point"), naked)) uint32_t main(void) {
// We enter this function after CR3 was updated to 1:1 mapping

View File

@@ -1,3 +0,0 @@
#include "shellcode_hv_args.h"
#include <stdarg.h>
#include <stdint.h>

View File

@@ -1,7 +1,5 @@
// This file is shared between kernel shellcode and hypervisor shellcode
#include <stdint.h>
typedef struct {
uint64_t bzimage_pa; // Already relocated by Kernel shellcode
uint64_t initrd_pa; // Already relocated by Kernel shellcode

View File

@@ -18,21 +18,6 @@ __attribute__((noinline, optimize("O0"))) uint32_t putc_uart(uint8_t tx_byte) {
return 0;
}
// Variable for val to hex
uint8_t hex_val[17];
__attribute__((noinline, optimize("O0"))) uint8_t *
u64_to_hex_custom(uint64_t val, uint8_t *dest) {
const uint8_t hex_chars[] = "0123456789abcdef";
dest[16] = '\0';
for (int i = 15; i >= 0; i--) {
dest[i] = hex_chars[val & 0xf];
val >>= 4;
}
return dest;
}
__attribute__((noinline, optimize("O0"))) int printf(const uint8_t *msg) {
uint32_t max = 255;
int ret = 0;

View File

@@ -5,13 +5,6 @@
uint32_t putc_uart(uint8_t tx_byte);
int printf(const uint8_t *msg);
uint8_t *u64_to_hex_custom(uint64_t val, uint8_t *dest);
extern uint8_t hex_val[17];
inline int print_val64(uint64_t val) {
return printf(u64_to_hex_custom(val, hex_val));
}
void memcpy(void *dest, void *src, uint64_t len);
char *strcpy(char *dest, const char *src);