summaryrefslogtreecommitdiff
path: root/tools/perf/scripts/python/stackcollapse.py
diff options
context:
space:
mode:
authorChaithanya Lagisetty <nagachaithanya9911@gmail.com>2026-09-08 05:37:22 +0000
committerSean Christopherson <seanjc@google.com>2026-09-11 15:02:42 -0700
commitc5991239b148d40d4981901968b3a6a838ff517b (patch)
tree89565eb3b44736b66362e10e935fc98a73e2a93c /tools/perf/scripts/python/stackcollapse.py
parentd4b7fb647204f0c81dfeae2d1a708e4d858e0c94 (diff)
downloadlinux-next-c5991239b148d40d4981901968b3a6a838ff517b.tar.gz
linux-next-c5991239b148d40d4981901968b3a6a838ff517b.zip
x86/svm: Avoid sign extension of SVM_EVTINJ_VALID in 64-bit expressions
SVM_EVTINJ_VALID is defined as (1 << 31), i.e. as an int with the sign bit set. Whenever it is used in a 64-bit expression the int is sign extended, so bits 63:32 end up set as well. Two 64-bit users are affected. verify_exception_info() uses the macro as a mask against a 64-bit value when it sanity checks hypervisor supplied exception information: u64 info = ghcb->save.sw_exit_info_2; ... if ((info & SVM_EVTINJ_VALID) && The mask is 0xffffffff80000000, so the check also passes when any bit of the error code in 63:32 is set while the valid bit itself is clear. svm_vmgexit_inject_exception() builds the value that KVM hands to an SEV-ES guest in GHCB SW_EXITINFO2: u64 data = SVM_EVTINJ_VALID | SVM_EVTINJ_TYPE_EXEPT | vector; For vector == X86_TRAP_GP this yields 0xffffffff8000030d instead of 0x000000008000030d. The field uses the EVENTINJ format, which holds the error code in bits 63:32, so KVM asks the guest to inject #GP with an error code of 0xffffffff. Linux guests only consume the error code when SVM_EVTINJ_VALID_ERR is set, which it is not here, so they are not affected in practice, but the value KVM writes is not the one it intends. Use BIT() instead, as is already done for most single bit definitions in this header. Every other user applies the macro to a u32, where the resulting bits are unchanged. Opportunistically give SVM_EVTINJ_VALID_ERR the same treatment, there's zero reason to open code BIT(). Fixes: 597cfe48212a ("x86/boot/compressed/64: Setup a GHCB-based VC Exception handler") Fixes: c3392d0ab714 ("KVM: SVM: Provide helpers to set the error code") Signed-off-by: Chaithanya Lagisetty <nagachaithanya9911@gmail.com> Link: https://patch.msgid.link/20260908053722.3917934-1-nagachaithanya9911@gmail.com [sean: use BIT() for SVM_EVTINJ_VALID_ERR as well] Signed-off-by: Sean Christopherson <seanjc@google.com>
Diffstat (limited to 'tools/perf/scripts/python/stackcollapse.py')
0 files changed, 0 insertions, 0 deletions