diff options
| author | Alexander Potapenko <glider@google.com> | 2026-01-14 10:09:53 +0100 |
|---|---|---|
| committer | Alexander Potapenko <glider@google.com> | 2026-01-15 07:19:29 +0000 |
| commit | 0a1338c68f19bbea13b3ae7ce61a185b6a5f65ef (patch) | |
| tree | c3d8f5ed55ec4911b3fed2fcbd45900a5c618790 /executor | |
| parent | 8d22bd8bfc28c79be87ab5da9975cbfe8c78beee (diff) | |
executor: sys/linux: SYZOS: add support for AMD STGI and CLGI instructions
Implement the SYZOS_API_NESTED_AMD_STGI and SYZOS_API_NESTED_AMD_CLGI
primitives to toggle the Global Interrupt Flag (GIF). These commands
execute the stgi and clgi instructions respectively and require no
arguments.
Also add a test checking that CLGI correctly masks NMI injection from L0.
Diffstat (limited to 'executor')
| -rw-r--r-- | executor/common_kvm_amd64_syzos.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/executor/common_kvm_amd64_syzos.h b/executor/common_kvm_amd64_syzos.h index 58444fbc1..002308c3c 100644 --- a/executor/common_kvm_amd64_syzos.h +++ b/executor/common_kvm_amd64_syzos.h @@ -34,6 +34,8 @@ typedef enum { SYZOS_API_NESTED_INTEL_VMWRITE_MASK = 340, SYZOS_API_NESTED_AMD_VMCB_WRITE_MASK = 380, SYZOS_API_NESTED_AMD_INVLPGA = 381, + SYZOS_API_NESTED_AMD_STGI = 382, + SYZOS_API_NESTED_AMD_CLGI = 383, SYZOS_API_STOP, // Must be the last one } syzos_api_id; @@ -115,6 +117,8 @@ GUEST_CODE static void guest_handle_nested_vmresume(struct api_call_1* cmd, uint GUEST_CODE static void guest_handle_nested_intel_vmwrite_mask(struct api_call_5* cmd, uint64 cpu_id); GUEST_CODE static void guest_handle_nested_amd_vmcb_write_mask(struct api_call_5* cmd, uint64 cpu_id); GUEST_CODE static void guest_handle_nested_amd_invlpga(struct api_call_2* cmd, uint64 cpu_id); +GUEST_CODE static void guest_handle_nested_amd_stgi(); +GUEST_CODE static void guest_handle_nested_amd_clgi(); typedef enum { UEXIT_END = (uint64)-1, @@ -233,6 +237,12 @@ guest_main(uint64 size, uint64 cpu) } else if (call == SYZOS_API_NESTED_AMD_INVLPGA) { // Invalidate TLB mappings for the specified address/ASID. guest_handle_nested_amd_invlpga((struct api_call_2*)cmd, cpu); + } else if (call == SYZOS_API_NESTED_AMD_STGI) { + // Set Global Interrupt Flag (Enable Interrupts). + guest_handle_nested_amd_stgi(); + } else if (call == SYZOS_API_NESTED_AMD_CLGI) { + // Clear Global Interrupt Flag (Disable Interrupts, including NMI). + guest_handle_nested_amd_clgi(); } addr += cmd->size; size -= cmd->size; @@ -1300,4 +1310,20 @@ guest_handle_nested_amd_invlpga(struct api_call_2* cmd, uint64 cpu_id) asm volatile("invlpga" : : "a"(linear_addr), "c"(asid) : "memory"); } +GUEST_CODE static noinline void +guest_handle_nested_amd_stgi() +{ + if (get_cpu_vendor() != CPU_VENDOR_AMD) + return; + asm volatile("stgi" ::: "memory"); +} + +GUEST_CODE static noinline void +guest_handle_nested_amd_clgi() +{ + if (get_cpu_vendor() != CPU_VENDOR_AMD) + return; + asm volatile("clgi" ::: "memory"); +} + #endif // EXECUTOR_COMMON_KVM_AMD64_SYZOS_H |
