aboutsummaryrefslogtreecommitdiffstats
path: root/executor
diff options
context:
space:
mode:
authorAlexander Potapenko <glider@google.com>2025-09-10 14:14:57 +0200
committerAlexander Potapenko <glider@google.com>2025-09-11 08:49:06 +0000
commit4e737d7cdbccc4346473e64ae19614a66c1ddf6b (patch)
treed43ae61266c497b41b03da61c3a3947023490154 /executor
parent4d84111421bcf66c236e6ef9af5846514e66653b (diff)
executor: x86: fix check-syzos error
Replace the switch statement in guest_handle_wr_crn() with a series of if statements.
Diffstat (limited to 'executor')
-rw-r--r--executor/common_kvm_amd64_syzos.h30
1 files changed, 16 insertions, 14 deletions
diff --git a/executor/common_kvm_amd64_syzos.h b/executor/common_kvm_amd64_syzos.h
index 828cdebff..32e09e0ba 100644
--- a/executor/common_kvm_amd64_syzos.h
+++ b/executor/common_kvm_amd64_syzos.h
@@ -185,29 +185,31 @@ GUEST_CODE static noinline void guest_handle_rdmsr(uint64 reg)
GUEST_CODE static noinline void guest_handle_wr_crn(struct api_call_2* cmd)
{
uint64 value = cmd->args[1];
- switch (cmd->args[0]) {
- case 0:
+ // Prevent the compiler from generating a switch table.
+ volatile uint64 reg = cmd->args[0];
+ if (reg == 0) {
// Move value to CR0.
asm volatile("movq %0, %%cr0" ::"r"(value) : "memory");
- break;
- case 2:
+ return;
+ }
+ if (reg == 2) {
// Move value to CR2.
asm volatile("movq %0, %%cr2" ::"r"(value) : "memory");
- break;
- case 3:
+ return;
+ }
+ if (reg == 3) {
// Move value to CR3.
asm volatile("movq %0, %%cr3" ::"r"(value) : "memory");
- break;
- case 4:
+ return;
+ }
+ if (reg == 4) {
// Move value to CR4.
asm volatile("movq %0, %%cr4" ::"r"(value) : "memory");
- break;
- case 8:
+ return;
+ }
+ if (reg == 8) {
// Move value to CR8 (TPR - Task Priority Register).
asm volatile("movq %0, %%cr8" ::"r"(value) : "memory");
- break;
- default:
- // Do nothing.
- break;
+ return;
}
}