From: sashiko-bot@kernel.org
To: "Claudio Imbrenda" <imbrenda@linux.ibm.com>, kvm@vger.kernel.org
Cc: linux-s390@vger.kernel.org, "Heiko Carstens" <hca@linux.ibm.com>,
"Vasily Gorbik" <gor@linux.ibm.com>,
"Alexander Gordeev" <agordeev@linux.ibm.com>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>
Subject: Re: [PATCH v2 08/12] KVM: s390: Fix *_test_and_clear_softdirty() functions
Date: Wed, 02 Dec 2026 19:11:22 +0000 [thread overview]
Message-ID: <sashiko-outbox-246529@kernel.org> (raw)
In-Reply-To: <20261202185020.241132-9-imbrenda@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] KVM: s390: lost dirty page tracking in
__pte_test_and_clear_softdirty()
--
commit 45534fc2296382ab64a7218f46f3ed17915a0fe0
Author: Claudio Imbrenda <imbrenda@linux.ibm.com>
KVM: s390: Fix *_test_and_clear_softdirty() functions
This commit adjusts soft-dirty checking and clearing in
__pte_test_and_clear_softdirty() and _crste_test_and_clear_softdirty() to
handle non-present and invalid entries and skip marking zero-flagged pages
as dirty.
> diff --git a/arch/s390/kvm/gmap/gmap.c b/arch/s390/kvm/gmap/gmap.c
> index ca196a474f833..2ba3d8e4e23dd 100644
> --- a/arch/s390/kvm/gmap/gmap.c
> +++ b/arch/s390/kvm/gmap/gmap.c
> @@ -584,8 +584,9 @@ static union pgste __pte_test_and_clear_softdirty(union pte *ptep, union pgste p
> struct gmap *gmap)
> {
> union pte pte = READ_ONCE(*ptep);
> + bool zero = pgste.zero;
>
> - if (!pte.s.pr || (pte.h.p && !pte.s.sd))
> + if ((pte.h.p || pte.h.i) && !pte.s.sd)
> return pgste;
>
> /*
> @@ -593,12 +594,16 @@ static union pgste __pte_test_and_clear_softdirty(union pte *ptep, union pgste p
> * running, do not reset the protection, leave it marked as dirty.
> */
> if (!pgste.prefix_notif || gmap_mkold_prefix(gmap, gfn, gfn + 1)) {
> - pte.h.p = 1;
> + if (!pte.h.i)
> + pte.h.p = 1;
> pte.s.sd = 0;
> pgste = gmap_ptep_xchg(gmap, ptep, pte, pgste, gfn);
> + pgste.zero = zero;
> }
>
> - mark_page_dirty(gmap->kvm, gfn);
> + /* dirty but unused, does not need to be migrated */
> + if (!zero)
> + mark_page_dirty(gmap->kvm, gfn);
>
> return pgste;
> }
[Severity: High]
Can clearing pte.s.sd while skipping mark_page_dirty() when pgste.zero is
set lose dirty page notifications across live migration?
When a dirty page (pte.s.sd == 1) is aged by gmap_clear_young_pte(),
pte.h.i is set to 1 while pte.s.pr remains 1 and the host folio keeps the
modified contents. If the guest then issues ESSA (for example,
ESSA_SET_VOLATILE or ESSA_SET_UNUSED), dat_perform_essa() sees ptep->h.i
and sets pgste.zero = 1, while _essa_clear_cbrl() does not zap the page
because ptep->s.pr is still 1.
When __pte_test_and_clear_softdirty() runs next, it clears pte.s.sd = 0 and
skips mark_page_dirty(). A subsequent guest read fault resolves in
_gmap_handle_minor_pte_fault() by clearing newpte.h.i = 0 and pgste.zero = 0
without setting newpte.s.sd = 1, leaving the modified resident page omitted
from the dirty log. In addition, because __dat_get_cmma_pte() only exports
pgste.usage and pgste.nodat (not pgste.zero), skipping mark_page_dirty()
for a page already transferred in an earlier migration round leaves stale
data on the destination host.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261202185020.241132-1-imbrenda@linux.ibm.com?part=8
next prev parent reply other threads:[~2026-12-02 19:11 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 18:50 [PATCH v2 00/12] KVM: s390: More fixes Claudio Imbrenda
2026-12-02 18:50 ` [PATCH v2 01/12] KVM: s390: ucontrol: Do not mask -ENOMEM when translating Claudio Imbrenda
2026-12-02 18:50 ` [PATCH v2 02/12] KVM: s390: Fix potential leak in kvm_s390_get_io_int() Claudio Imbrenda
2026-12-02 18:50 ` [PATCH v2 03/12] KVM: s390: Small miscellaneous CMMA fixes Claudio Imbrenda
2026-12-02 18:50 ` [PATCH v2 04/12] KVM: s390: Fix dat_entry_walk() with DAT_WALK_CONTINUE Claudio Imbrenda
2026-12-02 18:50 ` [PATCH v2 05/12] KVM: s390: Fix soft-dirty handling in _gmap_link() Claudio Imbrenda
2026-12-02 18:50 ` [PATCH v2 06/12] KVM: s390: Fix race in gmap_clear_young_pte() Claudio Imbrenda
2026-12-02 18:50 ` [PATCH v2 07/12] KVM: s390: Properly adjust page size before calling _gmap_link() Claudio Imbrenda
2026-12-02 18:50 ` [PATCH v2 08/12] KVM: s390: Fix *_test_and_clear_softdirty() functions Claudio Imbrenda
2026-12-02 19:11 ` sashiko-bot [this message]
2026-12-02 18:50 ` [PATCH v2 09/12] KVM: s390: Do not unnecessarily drop the soft-dirty bit Claudio Imbrenda
2026-12-02 18:50 ` [PATCH v2 10/12] KVM: s390: Disallow 2G pages for guests up to 2G Claudio Imbrenda
2026-12-02 18:50 ` [PATCH v2 11/12] KVM: s390: vsie: Fix improper shadowing of non-present host ptes Claudio Imbrenda
2026-12-02 18:50 ` [PATCH v2 12/12] KVM: s390: vsie: Drop shadow gmaps when a memslot is deleted or moved Claudio Imbrenda
2026-12-02 19:20 ` [PATCH v2 00/12] KVM: s390: More fixes sashiko-bot
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=sashiko-outbox-246529@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=imbrenda@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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