diff options
| author | Alexander Potapenko <glider@google.com> | 2025-07-23 12:41:10 +0200 |
|---|---|---|
| committer | Alexander Potapenko <glider@google.com> | 2025-07-24 12:46:04 +0000 |
| commit | 1b2a3c574905e3e59aa8e2f338bd6fbe2e7898d7 (patch) | |
| tree | 5fd308d1413ae13830d08b1ab81f12d1148cafcd /executor/common_kvm_amd64_syzos.h | |
| parent | 65d60d733b607360c8fd958b556954f71bfcdda9 (diff) | |
executor: sys/linux: use sparse IDs for SYZOS API
Like we already do on ARM, use prime numbers multiplied by 10 for
SYZOS API IDs to prevent the compiler from emitting a jump table in
guest_main().
Diffstat (limited to 'executor/common_kvm_amd64_syzos.h')
| -rw-r--r-- | executor/common_kvm_amd64_syzos.h | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/executor/common_kvm_amd64_syzos.h b/executor/common_kvm_amd64_syzos.h index 706396d1a..787b982de 100644 --- a/executor/common_kvm_amd64_syzos.h +++ b/executor/common_kvm_amd64_syzos.h @@ -18,10 +18,14 @@ // Start/end of the guest section. extern char *__start_guest, *__stop_guest; +// Compilers will eagerly try to transform the switch statement in guest_main() +// into a jump table, unless the cases are sparse enough. +// We use prime numbers multiplied by 10 to prevent this behavior. +// Remember these constants must match those in sys/linux/dev_kvm_amd64.txt. typedef enum { - SYZOS_API_UEXIT, - SYZOS_API_CODE, - SYZOS_API_CPUID, + SYZOS_API_UEXIT = 0, + SYZOS_API_CODE = 10, + SYZOS_API_CPUID = 20, SYZOS_API_STOP, // Must be the last one } syzos_api_id; |
