-
Notifications
You must be signed in to change notification settings - Fork 332
Description
We're seeing intermittent (~1/100) Synchronous Exceptions in early GRUB code on an ARM Cortex-A72-based platform. GRUB is being loaded by shim (Secure Boot is disabled fwiw). Curiously, the instruction $IP points to never seems like something that should cause an exception. One theory was that the instruction cache contained stale content, which seemed to be confirmed by manually flushing the cache within a debugger after hitting the exception, and re-executing the same code. This worked. Our working theory is that shim should be flushing the I-cache after loading the GRUB binary. (This story sounds pretty similar, btw).
We added the following code to a test shim build, and the test is no longer failing. Multiple machines have survived over 1000 reboots:
--- pe.c~ 2022-07-28 23:31:51.399506464 +0000
+++ pe.c 2022-07-28 23:51:25.398746245 +0000
@@ -963,6 +963,7 @@
CopyMem(buffer, data, context.SizeOfHeaders);
+ __builtin___clear_cache((char *)buffer, (char *)(buffer + context.ImageSize));
*entry_point = ImageAddress(buffer, context.ImageSize, context.EntryPoint);
if (!*entry_point) {
perror(L"Entry point is invalid\n");