All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hyunwoo Kim <imv4bel@gmail.com>
To: Sean Christopherson <seanjc@google.com>
Cc: Michael Roth <michael.roth@amd.com>,
	pbonzini@redhat.com, tglx@kernel.org, mingo@redhat.com,
	bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org,
	hpa@zytor.com, kvm@vger.kernel.org, imv4bel@gmail.com
Subject: Re: [PATCH] KVM: SEV: Don't return a still-assigned gmem page to the host
Date: Fri, 12 Jun 2026 02:34:38 +0900	[thread overview]
Message-ID: <airxrhqF6YbatIcK@v4bel> (raw)
In-Reply-To: <airxMoy44ZxkbioH@google.com>

On Thu, Jun 11, 2026 at 10:32:34AM -0700, Sean Christopherson wrote:
> On Fri, Jun 12, 2026, Hyunwoo Kim wrote:
> > On Thu, Jun 11, 2026 at 08:23:00AM -0700, Sean Christopherson wrote:
> > > On Thu, Jun 11, 2026, Hyunwoo Kim wrote:
> > > > > > To handle this properly, the folio would need to be taken off the LRU
> > > > > > before leaking, with something like folio_isolate_lru(), but that is
> > > > > > mm-internal and does not look usable from KVM. How should we proceed?
> > > > > > Please let me know if I am missing something.
> > > > > 
> > > > > I'm inclined to do nothing.  rmp_make_shared() should only fail in this case if
> > > > > there's a fatal bug somewhere, no?  Either that or do BUG_ON(), because at some
> > > > > point these types of errors are simply unrecoverable.
> > > > 
> > > > A guest can make a gmem page a VMSA via AP creation,
> > > 
> > > Ugh, the bane of my existence.  Can we kill off that feature yet?  I'm only half
> > > joking.  Not even half.
> > > 
> > > > and if that gfn is then hole-punched, a page that is still assigned to the
> > > > guest is returned to the host in sev_gmem_invalidate(), which looked like it
> > > > could lead to a host RMP PF, so I sent the patch.
> > > 
> > > Yeah, I suspect you're right.  But leaking the page doesn't fix the underlying
> > > problem, which is that it's possible to free a page that's being used as a VMSA.
> > > 
> > > We can't simply pin the page, because IIUC ->free_folio() is called when the page
> > > is removed from the filemap, not when the folio/page is free back to the allocator.
> 
> ...
> 
> > > The right way to handle this is to treat the VMSA "mapping" like an MMU mapping.
> > > I.e. this is fundamentally the same mess we have to solve in order to not pin
> > > pages that are mapped into L2 via vmcs01/vmcb02 for nVMX/nSVM.
> > > 
> > > Something like this, sans the actually handling of the request.  The simple way
> > > to handle the request would be to invalidate control.vmsa_pa if snp_has_guest_vmsa
> > > is true, and then redo the mapping part of sev_snp_init_protected_guest_state().
> > 
> > Understood. This looks like a fairly large change, at least for me,
> 
> Heh, definitely not just for you, it'll be a large, painful change for anyone :-)
> 
> > so would you be able to handle the patch?
> 
> Yeah, I'll work with Mike and others to get a fix landed.  Thanks much for the
> bug report!

OK. Thank you for the review :)

      reply	other threads:[~2026-06-11 17:34 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-10 16:10 [PATCH] KVM: SEV: Don't return a still-assigned gmem page to the host Hyunwoo Kim
2026-06-10 16:26 ` sashiko-bot
2026-06-10 18:25   ` Sean Christopherson
2026-06-10 22:16 ` Michael Roth
2026-06-11 10:26   ` Hyunwoo Kim
2026-06-11 12:47     ` Sean Christopherson
2026-06-11 14:05       ` Hyunwoo Kim
2026-06-11 15:23         ` Sean Christopherson
2026-06-11 17:07           ` Hyunwoo Kim
2026-06-11 17:32             ` Sean Christopherson
2026-06-11 17:34               ` Hyunwoo Kim [this message]

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=airxrhqF6YbatIcK@v4bel \
    --to=imv4bel@gmail.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=kvm@vger.kernel.org \
    --cc=michael.roth@amd.com \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=tglx@kernel.org \
    --cc=x86@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.