mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Sean Christopherson <seanjc@google.com>,
	Michael Roth <michael.roth@amd.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/6] KVM: selftests: Add a test to verify SEV {en,de}crypt debug ioctls
Date: Thu, 23 Jul 2026 17:17:26 +0200	[thread overview]
Message-ID: <2b4d5faf-1568-4080-92b3-1e525a11b194@redhat.com> (raw)
In-Reply-To: <ajx1Y93iX2oV-DLa@google.com>

On 6/25/26 02:25, Sean Christopherson wrote:
> On Wed, Jun 24, 2026, Michael Roth wrote:
>> So maybe the bounce buffer approach would work for DBG_DECRYPT at
>> least,
> 
> Yeah, DECRYPT worked fine, it's all the others that break.
> 
>>> pread() doesn't work, because the source or destination needs to be a userspace
>>> address, and so any RMP #PFs will get eaten.  But copy_file_range() makes the
>>> world go kablooie.
> 
> And the risk isn't limited to copy_file_range(), that just happens to be the first
> syscall I found that did what I want.  E.g. any memory that is kernel allocated
> and mapped into userspace would be problematic, because that memory could be fed
> back into KVM.
>
> So I don't think we can fix this by playing games in KVM.  Which is pretty much
> why we ended up with guest_memfd: the only way to lock down memory to the point
> where we're 100% certain it's safe to "poison" the pages is if KVM sequesters
> them away in a dedicated file system.

Yes, I agree that it's basically the same issue that led to using 
guest_memfd for SNP.  Another one would be io_submit().

>>> I'm fairly certain the issue is that the encryption is salted with the physical
>>> address, and so encrypting at X instead of Y will yield different ciphertext.
>>> I.e. any command that encrypts the contents in the destination (or in theory,
>>> decrypts, though AFAICT none of the commands do so) *can't* be bounce buffered.

Yep. :/

>>> I don't see a way to salvage SEV/SEV-ES on SNP systems, short of requiring
>>> CAP_SYS_BOOT or some other elevated permission to do *anything*.  Or redo SEV/SEV-ES
>>> support to require guest_memfd for operations that require putting pages into
>>> Firmware state.
>>
>> Yah, short of maybe the above approach, I don't see any way around it atm :(
>> If you think it's worth pursuing though I can give that a shot on my
>> end.

The unavoidable ones include, if I understand correctly, not just 
DBG_ENCRYPT but also LAUNCH_UPDATE_DATA?

For encrypt the destination is the guest memory, so how would adding 
guest_memfd support for SEV/SEV-ES work?  The guest doesn't have a 
page-state-change call and neither does it have RMP nested page faults, 
so how would you communicate the private<->shared switch to userspace?

> I say we wait for Paolo to get back from holiday (in a few weeks) before doing
> anything drastic.  I'll send a patch to fix the existing selftest though, no
> reason to leave that hole open.

Well, everything is drastic.  "Fortunately" AMD helped us with the 
firmware update that already hides SEV-ES on SNP machines 
(CVE-2025-48514), so at least there's a precedent.

Could we say CAP_SYS_BOOT is only be required to create the VM, after 
which it's up to userspace to not screw up?  Probably not, because 
userspace can then drop privileges and operate on the file descriptor; 
which is the actual dangerous part.

The only not-horrible alternative would be a default-disabled module 
parameter that allows SEV/SEV-ES on SNP systems but adds TAINT_USER when 
you create one.  And downstreams that don't like the idea can just rip 
out the taint.

Paolo


  reply	other threads:[~2026-07-23 15:17 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-01 20:35 [PATCH v2 0/6] KVM: SEV: sev_dbg_crypt() fix and overhaul Sean Christopherson
2026-05-01 20:35 ` [PATCH v2 1/6] KVM: SVM: Fix page overflow in sev_dbg_crypt() for ENCRYPT path Sean Christopherson
2026-05-01 20:35 ` [PATCH v2 2/6] KVM: selftests: Add a test to verify SEV {en,de}crypt debug ioctls Sean Christopherson
2026-05-21  7:04   ` [PATCH v2 2/6] KVM: selftests: Add a test to verify SEV {en,de}crypt kernel test robot
2026-05-21 14:28     ` Sean Christopherson
     [not found]   ` <ajNQ_Ix5e0p6FuFT@google.com>
     [not found]     ` <tx3hcnrhfbcz2p7e7umc5o2zrw74pluzuzgtlqt4dz5cc5nhxx@6tzzorc25nqw>
     [not found]       ` <s7jfbw3tnfgmp6blfqlfoi7yhq6f5n6xl62zzty5up45cqtsty@ljpjlvqw2gyy>
2026-06-23 19:55         ` [PATCH v2 2/6] KVM: selftests: Add a test to verify SEV {en,de}crypt debug ioctls Sean Christopherson
2026-06-23 23:22           ` Michael Roth
2026-06-24  0:22             ` Sean Christopherson
2026-06-24 21:24               ` Sean Christopherson
2026-06-24 23:11                 ` Michael Roth
2026-06-25  0:25                   ` Sean Christopherson
2026-07-23 15:17                     ` Paolo Bonzini [this message]
2026-07-23 21:07                       ` Michael Roth
2026-07-23 21:29                         ` Sean Christopherson
2026-05-01 20:35 ` [PATCH v2 3/6] KVM: SEV: Explicitly validate the dst buffer for debug operations Sean Christopherson
2026-05-01 20:35 ` [PATCH v2 4/6] KVM: SEV: Add helper function to pin/unpin a single page Sean Christopherson
2026-05-01 20:35 ` [PATCH v2 5/6] KVM: SEV: Rewrite logic to {de,en}crypt memory for debug Sean Christopherson
2026-05-01 20:35 ` [PATCH v2 6/6] KVM: SEV: Allocate only as many bytes as needed for temp crypt buffers Sean Christopherson
2026-05-19  0:41 ` [PATCH v2 0/6] KVM: SEV: sev_dbg_crypt() fix and overhaul Sean Christopherson
  -- strict thread matches above, loose matches on Subject: below --
2026-04-16 23:10 Sean Christopherson
2026-04-16 23:10 ` [PATCH v2 2/6] KVM: selftests: Add a test to verify SEV {en,de}crypt debug ioctls Sean Christopherson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2b4d5faf-1568-4080-92b3-1e525a11b194@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael.roth@amd.com \
    --cc=seanjc@google.com \
    --cc=thomas.lendacky@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®