From: Heiko Carstens <hca@linux.ibm.com>
To: Claudio Imbrenda <imbrenda@linux.ibm.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
linux-s390@vger.kernel.org, borntraeger@de.ibm.com,
frankja@linux.ibm.com, david@kernel.org, seiden@linux.ibm.com,
nrb@linux.ibm.com, schlameuss@linux.ibm.com, gra@linux.ibm.com,
gerald.schaefer@linux.ibm.com, gor@linux.ibm.com,
agordeev@linux.ibm.com, svens@linux.ibm.com
Subject: Re: [PATCH v3 1/4] s390/mm: Fix handling of _PAGE_UNUSED pte bit
Date: Fri, 19 Jun 2026 10:05:52 +0200 [thread overview]
Message-ID: <20260619080552.18590C8b-hca@linux.ibm.com> (raw)
In-Reply-To: <20260616165110.360921-2-imbrenda@linux.ibm.com>
On Tue, Jun 16, 2026 at 06:51:07PM +0200, Claudio Imbrenda wrote:
> The _PAGE_UNUSED softbit should not really be lying around. Its sole
> purpose is to signal to try_to_unmap_one() and try_to_migrate_one()
> that the page can be discarded instead of being moved / swapped.
>
> KVM has no way to know why a page is being unmapped, so it sets the bit
> on userspace ptes corresponding to unused guest pages every time they
> get unmapped. KVM has no reasonable way to clear the bit once the page
> is in use again.
>
> Without appropriate cleanup, the _PAGE_UNUSED bit will linger around
> and cause guest corruption when a used page is instead thrown out.
>
> While set_ptes() checks and clears the bit, other paths that set new
> ptes did not. This led to used pages being thrown out as if they were
> unused, causing guest corruption.
>
> This patch fixes the issue by clearing the _PAGE_UNUSED bit in
> set_pte(), so whenever a present pte is getting set. The check in
> set_ptes() is then redundant and can be removed.
>
> Also fix gmap_helper_try_set_pte_unused() to only set the bit if the
> pte is present; the _PAGE_UNUSED bit is only defined for present ptes
> and thus should not be set for non-present ptes.
>
> Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
> Fixes: c98175b7917f ("KVM: s390: Add gmap_helper_set_unused()")
> ---
> arch/s390/include/asm/pgtable.h | 4 ++--
> arch/s390/mm/gmap_helpers.c | 3 ++-
> 2 files changed, 4 insertions(+), 3 deletions(-)
Acked-by: Heiko Carstens <hca@linux.ibm.com>
next prev parent reply other threads:[~2026-06-19 8:06 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-16 16:51 [PATCH v3 0/4] KVM: s390: Fixes for gmap and _PAGE_UNUSED Claudio Imbrenda
2026-06-16 16:51 ` [PATCH v3 1/4] s390/mm: Fix handling of _PAGE_UNUSED pte bit Claudio Imbrenda
2026-06-19 8:05 ` Heiko Carstens [this message]
2026-06-16 16:51 ` [PATCH v3 2/4] KVM: s390: Fix dat_peek_cmma() overflow Claudio Imbrenda
2026-06-16 17:03 ` sashiko-bot
2026-06-16 16:51 ` [PATCH v3 3/4] KVM: s390: Do not set special large pages dirty Claudio Imbrenda
2026-06-16 17:10 ` sashiko-bot
2026-06-16 16:51 ` [PATCH v3 4/4] KVM: s390: Fix code typo in gmap_protect_asce_top_level() Claudio Imbrenda
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=20260619080552.18590C8b-hca@linux.ibm.com \
--to=hca@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@de.ibm.com \
--cc=david@kernel.org \
--cc=frankja@linux.ibm.com \
--cc=gerald.schaefer@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=gra@linux.ibm.com \
--cc=imbrenda@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=schlameuss@linux.ibm.com \
--cc=seiden@linux.ibm.com \
--cc=svens@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