Fix IA32x64 pointer corruption, invalid generation on ARM.
diff --git a/generator/sections/gen-section-arm.c b/generator/sections/gen-section-arm.c
index 53fb24c..bce04c5 100644
--- a/generator/sections/gen-section-arm.c
+++ b/generator/sections/gen-section-arm.c
@@ -52,6 +52,10 @@
*(section + 12) = rand() % 4;
//Reserved zero bytes.
+ UINT64* validation = (UINT64*)section;
+ *validation &= 0b111;
+ UINT32* running_state = (UINT32*)(section + 32);
+ *running_state &= 0b1;
memset(section + 13, 0, 3);
//Copy in the sections/context structures, free resources.
@@ -87,6 +91,10 @@
UINT8 error_type = rand() % 4;
*(error_info + 4) = error_type;
+ //Reserved bits for error information.
+ UINT16* validation = (UINT16*)(error_info + 2);
+ *validation &= 0x1F;
+
//Make sure reserved bits are zero according with the type.
UINT64* error_subinfo = (UINT64*)(error_info + 8);
switch (error_type)
diff --git a/generator/sections/gen-section-ia32x64.c b/generator/sections/gen-section-ia32x64.c
index 0f6f709..2fb6585 100644
--- a/generator/sections/gen-section-ia32x64.c
+++ b/generator/sections/gen-section-ia32x64.c
@@ -6,6 +6,7 @@
#include <stdlib.h>
#include <string.h>
+#include <stdio.h>
#include "../../edk/Cper.h"
#include "../gen-utils.h"
#include "gen-sections.h"
@@ -114,7 +115,7 @@
memcpy(guid, &gEfiIa32x64ErrorTypeMsCheckGuid, sizeof(EFI_GUID));
//Set reserved space to zero.
- *check_info &= ~0xFF30;
+ *check_info &= ~0xFFE0;
*check_info &= 0xFFFFFF;
break;
}
@@ -135,7 +136,7 @@
if (reg_type == 3)
reg_size = 244; //x64 registers.
else
- reg_size = rand() % 64; //Not table defined.
+ reg_size = (rand() % 5) * 32; //Not table defined.
//Create structure randomly.
int total_size = 16 + reg_size;
@@ -144,6 +145,7 @@
//Set header information.
*(context_structure) = reg_type;
*(context_structure + 1) = reg_size;
+ printf("set reg size to %d (for type %d).\n", reg_size, reg_type);
//Set return values and exit.
*location = context_structure;