aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2023-05-23 13:25:44 +0100
committerMichael Brown <mcb30@ipxe.org>2023-05-23 13:47:42 +0100
commitcf79f3514c5f08ce518e4374c37179aabc88d5df (patch)
treea34cf7ab02828a94183278c757bb6658a0a4f9fa
parent95b8338f0d4674b9f8bb51adf6886212d2b97e4b (diff)
downloadipxe-cf79f3514c5f08ce518e4374c37179aabc88d5df.zip
ipxe-cf79f3514c5f08ce518e4374c37179aabc88d5df.tar.gz
ipxe-cf79f3514c5f08ce518e4374c37179aabc88d5df.tar.bz2
WIP - first successful sbat hack
-rw-r--r--src/config/console.h2
-rw-r--r--src/interface/efi/efi_file.c3
-rw-r--r--src/interface/efi/efi_shim.c55
3 files changed, 59 insertions, 1 deletions
diff --git a/src/config/console.h b/src/config/console.h
index 9f770d0..689e051 100644
--- a/src/config/console.h
+++ b/src/config/console.h
@@ -39,7 +39,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
//#define CONSOLE_SYSLOG /* Syslog console */
//#define CONSOLE_SYSLOGS /* Encrypted syslog console */
//#define CONSOLE_VMWARE /* VMware logfile console */
-//#define CONSOLE_DEBUGCON /* Bochs/QEMU/KVM debug port console */
+#define CONSOLE_DEBUGCON /* Bochs/QEMU/KVM debug port console */
//#define CONSOLE_INT13 /* INT13 disk log console */
/*
diff --git a/src/interface/efi/efi_file.c b/src/interface/efi/efi_file.c
index 2ae3a0c..8aa694a 100644
--- a/src/interface/efi/efi_file.c
+++ b/src/interface/efi/efi_file.c
@@ -538,6 +538,9 @@ static EFI_STATUS efi_file_read_dir ( struct efi_file *file, UINTN *len,
/* Construct directory entries for image-backed files */
index = file->pos;
+ //
+ DBG ( "***** readdir %d\n", index );
+
for_each_image ( image ) {
/* Skip hidden images */
diff --git a/src/interface/efi/efi_shim.c b/src/interface/efi/efi_shim.c
index 9b1b69e..517d64d 100644
--- a/src/interface/efi/efi_shim.c
+++ b/src/interface/efi/efi_shim.c
@@ -179,6 +179,7 @@ static int efi_shim_inhibit_pxe ( EFI_HANDLE handle ) {
* @ret rc Return status code
*/
static int efi_shim_cmdline ( struct image *shim, wchar_t **cmdline ) {
+ struct image *crutch = find_image_tag ( &efi_shim_crutch );
wchar_t *shimcmdline;
int len;
int rc;
@@ -187,6 +188,9 @@ static int efi_shim_cmdline ( struct image *shim, wchar_t **cmdline ) {
len = ( shim->cmdline ?
efi_asprintf ( &shimcmdline, "%s %s", shim->name,
shim->cmdline ) :
+ crutch ?
+ efi_asprintf ( &shimcmdline, "%s %s wtf does this do", shim->name,
+ crutch->name ) :
efi_asprintf ( &shimcmdline, "%s %ls", shim->name,
*cmdline ) );
if ( len < 0 ) {
@@ -203,6 +207,50 @@ static int efi_shim_cmdline ( struct image *shim, wchar_t **cmdline ) {
return 0;
}
+static EFI_GET_VARIABLE orig_get_var;
+static EFI_SET_VARIABLE orig_set_var;
+static int just_set;
+
+//
+static EFI_STATUS EFIAPI
+efi_shim_get_variable ( CHAR16 *name, EFI_GUID *guid, UINT32 *attrs,
+ UINTN *size, VOID *data ) {
+ static const CHAR16 foo[] = L"SbatLevel";
+ EFI_STATUS efirc;
+
+ efirc = orig_get_var ( name, guid, attrs, size, data );
+ DBGC ( &efi_shim, "**** GetVariable ( %ls, %s ):\n", name,
+ efi_guid_ntoa ( guid ) );
+
+ if ( ( ! just_set ) &&
+ ( memcmp ( name, foo, sizeof ( foo ) ) == 0 ) ) {
+ UINT8 *thing = data;
+ DBGC ( &efi_shim, "**** HAHAHAHAHA\n" );
+ *thing = '\0';
+ }
+ if ( data )
+ just_set = 0;
+
+ if ( data )
+ DBGC_HDA ( &efi_shim, 0, data, *size );
+ return efirc;
+}
+
+static EFI_STATUS EFIAPI
+efi_shim_set_variable ( CHAR16 *name, EFI_GUID *guid, UINT32 attrs,
+ UINTN size, VOID *data ) {
+ EFI_STATUS efirc;
+
+ DBGC ( &efi_shim, "**** SetVariable ( %ls, %s ):\n", name,
+ efi_guid_ntoa ( guid ) );
+ DBGC_HDA ( &efi_shim, 0, data, size );
+ efirc = orig_set_var ( name, guid, attrs, size, data );
+
+ just_set = 1;
+
+ return efirc;
+}
+
/**
* Install UEFI shim special handling
*
@@ -214,8 +262,15 @@ static int efi_shim_cmdline ( struct image *shim, wchar_t **cmdline ) {
int efi_shim_install ( struct image *shim, EFI_HANDLE handle,
wchar_t **cmdline ) {
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
+ EFI_RUNTIME_SERVICES *rs = efi_systab->RuntimeServices;
int rc;
+ //
+ orig_get_var = rs->GetVariable;
+ orig_set_var = rs->SetVariable;
+ rs->GetVariable = efi_shim_get_variable;
+ rs->SetVariable = efi_shim_set_variable;
+
/* Intercept GetMemoryMap() via boot services table */
efi_shim_orig_map = bs->GetMemoryMap;
if ( ! efi_shim_require_loader )