All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Jeff Moyer <jmoyer@redhat.com>, dan.j.williams@intel.com
Cc: Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	Tony Luck <tony.luck@intel.com>, Borislav Petkov <bp@alien8.de>,
	linux-edac@vger.kernel.org, x86@kernel.org,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [patch] x86/pat: pass correct address to sanitize_phys
Date: Tue, 10 Aug 2021 08:38:46 +0200	[thread overview]
Message-ID: <87wnotst1l.ffs@tglx> (raw)
In-Reply-To: <x49tuknmosl.fsf@segfault.boston.devel.redhat.com>

Jeff,

On Wed, Jul 21 2021 at 15:48, Jeff Moyer wrote:

Please write function names with brackets, i.e. sanitize_phys().

> memtype_reserve takes an address range of the form [start, end).  It

[start, end]


> then passes the start and end addresses to sanitize_phys, which is meant
> to operate on the inclusive addresses.  If end falls at the end of the
> physical address space, sanitize_phys will return 0.  This can result in
> drivers failing to load:
>
> [   10.000087] mpt3sas_cm0: unable to map adapter memory! or resource not found
> [   10.000334] mpt3sas_cm0: failure at drivers/scsi/mpt3sas/mpt3sas_scsih.c:10597/_scsih_probe()!

Doesn't this trigger the WARN() right below that offending line?

> Fix this by passing the inclusive end address to sanitize_phys.
>
> Fixes: 510ee090abc3 ("x86/mm/pat: Prepare {reserve, free}_memtype() for "decoy" addresses")
> Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
> --
> It might be worth adding a comment, here.  If there are any suggestions
> on what a sane wording would be, I'm all ears.

See below.

> diff --git a/arch/x86/mm/pat/memtype.c b/arch/x86/mm/pat/memtype.c
> index 3112ca7786ed..482557905294 100644
> --- a/arch/x86/mm/pat/memtype.c
> +++ b/arch/x86/mm/pat/memtype.c
> @@ -583,7 +583,7 @@ int memtype_reserve(u64 start, u64 end, enum page_cache_mode req_type,
>  	int err = 0;
>  
>  	start = sanitize_phys(start);
> -	end = sanitize_phys(end);

        /*
         * [start, end] is an exclusive address range, but
         * sanitize_phys() expects an inclusive end address
         */

> +	end = sanitize_phys(end - 1) + 1;
>  	if (start >= end) {
>  		WARN(1, "%s failed: [mem %#010Lx-%#010Lx], req %s\n", __func__,
>  				start, end - 1, cattr_name(req_type));

Thanks,

        tglx

  parent reply	other threads:[~2021-08-10  6:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-21 19:48 [patch] x86/pat: pass correct address to sanitize_phys Jeff Moyer
2021-08-09 15:58 ` Jeff Moyer
2021-08-09 17:25 ` David Hildenbrand
2021-08-10  6:38 ` Thomas Gleixner [this message]
2021-08-10 19:22   ` Jeff Moyer

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=87wnotst1l.ffs@tglx \
    --to=tglx@linutronix.de \
    --cc=bp@alien8.de \
    --cc=dan.j.williams@intel.com \
    --cc=hpa@zytor.com \
    --cc=jmoyer@redhat.com \
    --cc=linux-edac@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mingo@redhat.com \
    --cc=tony.luck@intel.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 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.