summaryrefslogtreecommitdiff
path: root/include/uapi/linux
diff options
context:
space:
mode:
authorJacky Li <jackyli@google.com>2026-09-23 20:18:12 +0000
committerSean Christopherson <seanjc@google.com>2026-09-28 17:55:11 -0700
commit003892d6e802a1c08ad03e8ea793453465cae7f4 (patch)
tree6fdae7e82b51df3eedb3e30c8a9aa38d79e1d739 /include/uapi/linux
parentbf260dc9e7b8bfcd06c1a8e739797b1cf0917c72 (diff)
downloadlinux-next-003892d6e802a1c08ad03e8ea793453465cae7f4.tar.gz
linux-next-003892d6e802a1c08ad03e8ea793453465cae7f4.zip
KVM: SEV: Return INVALID_INPUT on SNP req/resp buffer access failure
Currently, snp_handle_(ext_)guest_req() returns -EIO when kvm_{read/clear}_guest() fails while accessing guest-provided buffers. Returning -EIO causes KVM_RUN to exit to userspace, likely killing the VM. Fix this by returning GHCB_HV_RESP_MALFORMED_INPUT with sub-error code GHCB_ERR_INVALID_INPUT to the guest and resuming the vCPU. Per the GHCB specification, guest-provided GPA buffers that cannot be accessed by the hypervisor (e.g. private pages) should be treated as guest input errors. Because kvm_{read/write/clear}_guest() only returns -EFAULT on failure, treating this failure as an invalid input aligns with the definition of -EFAULT ("Bad address"). Returning GHCB_ERR_INVALID_INPUT also matches existing SNP handling in KVM, which already returns this error code for unaligned or overlapping buffers. It also aligns with other hypercall implementations in KVM (e.g. Hyper-V returning INVALID_HYPERCALL_INPUT on kvm_read_guest() failures in kvm_hv_flush_tlb()). Additionally, tickle the response buffer before issuing the PSP command so that an invalid resp_gpa fails upfront with GHCB_ERR_INVALID_INPUT, i.e. to avoid terminating the guest if it provides a bad buffer. Do not return an error to the guest if the post-firmware write fails, as the firmware has already incremented the VMPCK sequence number. Exiting to userspace avoids creating an ambiguous failure where the guest has no way to know whether to advance its VMPCK sequence number. I.e. the "tickle" is a best effort compromise between terminating the guest on bad input, and horribly confusing the guest on bad *host userspace* behavior. Fixes: 88caf544c930 ("KVM: SEV: Provide support for SNP_GUEST_REQUEST NAE event") Fixes: 74458e4859d8 ("KVM: SEV: Provide support for SNP_EXTENDED_GUEST_REQUEST NAE event") Signed-off-by: Jacky Li <jackyli@google.com> Link: https://patch.msgid.link/20260923-snp-invalid-input-v2-1-c00e0dd077ca@google.com [sean: massage comments and changelog regarding the tickle] Signed-off-by: Sean Christopherson <seanjc@google.com>
Diffstat (limited to 'include/uapi/linux')
0 files changed, 0 insertions, 0 deletions