]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
KVM: SEV: Rewrite logic to {de,en}crypt memory for debug
authorSean Christopherson <seanjc@google.com>
Fri, 1 May 2026 20:35:36 +0000 (13:35 -0700)
committerSean Christopherson <seanjc@google.com>
Wed, 13 May 2026 22:03:19 +0000 (15:03 -0700)
commit8d6297a3e73e08f86aebdeeafb968816175ce39a
tree117bdf3a076f4084acfe399a7bf6be56cf9662c4
parent99694add4af382a8fd594e3fc8d02342b1afde02
KVM: SEV: Rewrite logic to {de,en}crypt memory for debug

Wholesale rewrite the guts of the debug {de,en}crypt flows, as the existing
code is broken, e.g. doesn't handle cases where the access isn't naturally
sized and aligned, and is so wildly flawed that attempting to salvage the
current code in an iterative fashion would be more risky than a rewrite.

E.g. when encrypting 9 bytes at offset 8, KVM needs to _decrypt_
destination[31:0] into a temporary buffer, buffer[31:0], then copy 9 bytes
from source[8:0] to buffer[16:8], then encrypt buffer[31:0] back into
destination[31:0].  The current code only ever copies 16 bytes, and
bizarrely uses a temporary buffer for the source as well.

To keep the code easier to read and maintain, send the unaligned cases
down dedicated "slow" paths instead of trying to mix and match the possible
combinations in one helper.

For now, preserve the basic approach of the current code, e.g. allocate an
entire page for the temporary buffer, to minimize unwanted changes in
functionality.

Link: https://patch.msgid.link/20260501203537.2120074-6-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/svm/sev.c