From: Claudio Imbrenda <imbrenda@linux.ibm.com>
To: David Hildenbrand <david@redhat.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-s390@vger.kernel.org, frankja@linux.ibm.com,
borntraeger@de.ibm.com, nrb@linux.ibm.com, seiden@linux.ibm.com,
nsg@linux.ibm.com, schlameuss@linux.ibm.com, hca@linux.ibm.com
Subject: Re: [PATCH v1 2/2] KVM: s390: pv: fix race when making a page secure
Date: Fri, 14 Feb 2025 11:41:39 +0100 [thread overview]
Message-ID: <20250214114139.2121f9ea@p-imbrenda> (raw)
In-Reply-To: <ad8ae139-546d-4ade-abb9-455b339a8a92@redhat.com>
On Fri, 14 Feb 2025 11:27:15 +0100
David Hildenbrand <david@redhat.com> wrote:
> On 14.02.25 11:17, Claudio Imbrenda wrote:
> > On Thu, 13 Feb 2025 21:16:03 +0100
> > David Hildenbrand <david@redhat.com> wrote:
> >
> >> On 13.02.25 21:07, Claudio Imbrenda wrote:
> >>> Holding the pte lock for the page that is being converted to secure is
> >>> needed to avoid races. A previous commit removed the locking, which
> >>> caused issues. Fix by locking the pte again.
> >>>
> >>> Fixes: 5cbe24350b7d ("KVM: s390: move pv gmap functions into kvm")
> >>
> >> If you found this because of my report about the changed locking,
> >> consider adding a Suggested-by / Reported-y.
> >
> > yes, sorry; I sent the patch in haste and forgot. Which one would you
> > prefer (or both?)
> >
>
> Maybe Reported-by.
>
> > [...]
> >
> >>> @@ -127,8 +128,11 @@ int gmap_make_secure(struct gmap *gmap, unsigned long gaddr, void *uvcb)
> >>>
> >>> page = gfn_to_page(kvm, gpa_to_gfn(gaddr));
> >>> mmap_read_lock(gmap->mm);
> >>> - if (page)
> >>> - rc = __gmap_make_secure(gmap, page, uvcb);
> >>> + vmaddr = gfn_to_hva(gmap->private, gpa_to_gfn(gaddr));
> >>> + if (kvm_is_error_hva(vmaddr))
> >>> + rc = -ENXIO;
> >>> + if (!rc && page)
> >>> + rc = __gmap_make_secure(gmap, page, vmaddr, uvcb);
> >>> kvm_release_page_clean(page);
> >>> mmap_read_unlock(gmap->mm);
> >>>
> >>
> >> You effectively make the code more complicated and inefficient than
> >> before. Now you effectively walk the page table twice in the common
> >> small-folio case ...
> >
> > I think in every case, but see below
> >
> >>
> >> Can we just go back to the old handling that we had before here?
> >>
> >
> > I'd rather not, this is needed to prepare for the next series (for
> > 6.15) in a couple of weeks, where gmap gets completely removed from
> > s390/mm, and gmap dat tables will not share ptes with userspace anymore
> > (i.e. we will use mmu_notifiers, like all other archs)
>
> I think for the conversion we would still:
>
> GFN -> HVA
>
> Walk to the folio mapped at HVA, lock the PTE and perform the conversion.
>
> So even with memory notifiers, that should be fine, no?
yes
>
> So not necessarily "the old handling that we had before" but rather "the
> old way of looking up what's mapped and performing the conversion under
> the PTL".
ahhh, yes
>
> For me to fix the refcount freezing properly on top of your work, we'll
> need the PTL (esp. to exclude concurrent GUP-slow) etc.
let's discuss this off-list
prev parent reply other threads:[~2025-02-14 10:41 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-13 20:07 [PATCH v1 0/2] KVM: s390: fix two newly introduced bugs Claudio Imbrenda
2025-02-13 20:07 ` [PATCH v1 1/2] KVM: s390: fix issues when splitting folios Claudio Imbrenda
2025-02-13 20:17 ` David Hildenbrand
2025-02-14 9:43 ` Claudio Imbrenda
2025-02-13 20:07 ` [PATCH v1 2/2] KVM: s390: pv: fix race when making a page secure Claudio Imbrenda
2025-02-13 20:16 ` David Hildenbrand
2025-02-13 20:33 ` David Hildenbrand
2025-02-14 10:17 ` Claudio Imbrenda
2025-02-14 10:27 ` David Hildenbrand
2025-02-14 10:41 ` Claudio Imbrenda [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=20250214114139.2121f9ea@p-imbrenda \
--to=imbrenda@linux.ibm.com \
--cc=borntraeger@de.ibm.com \
--cc=david@redhat.com \
--cc=frankja@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=nrb@linux.ibm.com \
--cc=nsg@linux.ibm.com \
--cc=schlameuss@linux.ibm.com \
--cc=seiden@linux.ibm.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