From: "Edgecombe, Rick P" <rick.p.edgecombe@intel.com>
To: "luto@kernel.org" <luto@kernel.org>,
"x86@kernel.org" <x86@kernel.org>,
"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
"peterz@infradead.org" <peterz@infradead.org>,
"bp@alien8.de" <bp@alien8.de>,
"mingo@redhat.com" <mingo@redhat.com>,
"rppt@kernel.org" <rppt@kernel.org>,
"tglx@kernel.org" <tglx@kernel.org>
Cc: "hpa@zytor.com" <hpa@zytor.com>,
"thomas.lendacky@amd.com" <thomas.lendacky@amd.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 4/9] x86/mm/pat: don't BUG() on inconsistent page count
Date: Tue, 24 Nov 2026 22:57:39 +0000 [thread overview]
Message-ID: <4edee4db91a92b3231644688afbc950bb880ff8c.camel@intel.com> (raw)
In-Reply-To: <20261112-fixes-x86-v1-4-791adb8d6670@kernel.org>
On Thu, 2026-11-12 at 18:31 +0200, Mike Rapoport (Microsoft) wrote:
> If a step of __change_page_attr_set_clr() covers more pages than remain
> in the range, or no pages at all, that's a bug in CPA, but it does not
> justify crashing the kernel.
Agreed, but does it also justify special handling to try to return an error to
the caller about the bug in CPA? Why not just change the BUG_ON() to WARN?
>
> Warn and fail the request instead.
>
> Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
> ---
> arch/x86/mm/pat/set_memory.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c
> index aa7052d247e60..a1bea16a3c3bb 100644
> --- a/arch/x86/mm/pat/set_memory.c
> +++ b/arch/x86/mm/pat/set_memory.c
> @@ -2101,7 +2101,10 @@ static int __change_page_attr_set_clr(struct cpa_data *cpa, int primary)
> * CPA operation. Either a large page has been
> * preserved or a single page update happened.
> */
> - BUG_ON(cpa->numpages > rempages || !cpa->numpages);
> + if (WARN_ON_ONCE(cpa->numpages > rempages || !cpa->numpages)) {
> + ret = -EINVAL;
> + goto out;
> + }
> rempages -= cpa->numpages;
> cpa->curpage += cpa->numpages;
> }
>
> --
next prev parent reply other threads:[~2026-11-24 22:57 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-12 16:31 [PATCH 0/9] x86/mm: CPA robustness fixes and cleanups Mike Rapoport (Microsoft)
2026-11-12 16:31 ` [PATCH 1/9] x86/mm/pat: flush the TLB when only an alias mapping changed Mike Rapoport (Microsoft)
2026-11-24 22:49 ` Edgecombe, Rick P
2026-11-12 16:31 ` [PATCH 2/9] x86/mm: don't set kernel_set_to_readonly when write protecting fails Mike Rapoport (Microsoft)
2026-11-24 23:01 ` Edgecombe, Rick P
2026-11-12 16:31 ` [PATCH 3/9] x86/mm/pat: don't populate page tables in set_memory_{en,de}crypted() Mike Rapoport (Microsoft)
2026-11-17 16:15 ` Tom Lendacky
2026-11-12 16:31 ` [PATCH 4/9] x86/mm/pat: don't BUG() on inconsistent page count Mike Rapoport (Microsoft)
2026-11-24 22:57 ` Edgecombe, Rick P [this message]
2026-11-12 16:31 ` [PATCH 5/9] x86/mm/pat: don't warn about W^X violations before mark_rodata_ro() Mike Rapoport (Microsoft)
2026-11-12 21:46 ` Salvatore Bonaccorso
2026-11-15 6:25 ` Mike Rapoport
2026-11-15 13:52 ` Salvatore Bonaccorso
2026-11-12 16:31 ` [PATCH 6/9] x86/mm/pat: remove CPA_ARRAY Mike Rapoport (Microsoft)
2026-11-12 16:31 ` [PATCH 7/9] x86/mm/pat: pass the address to CPA by value Mike Rapoport (Microsoft)
2026-11-12 16:31 ` [PATCH 8/9] x86/mm/pat: move the collapse of large pages out of cpa_flush() Mike Rapoport (Microsoft)
2026-11-12 16:31 ` [PATCH 9/9] x86/mm/pat: use cpa_flush() on CPA errors Mike Rapoport (Microsoft)
2026-11-24 15:57 ` [PATCH 0/9] x86/mm: CPA robustness fixes and cleanups Mike Rapoport
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=4edee4db91a92b3231644688afbc950bb880ff8c.camel@intel.com \
--to=rick.p.edgecombe@intel.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rppt@kernel.org \
--cc=tglx@kernel.org \
--cc=thomas.lendacky@amd.com \
--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 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®