LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [patch] x86/pat: pass correct address to sanitize_phys
@ 2021-07-21 19:48 Jeff Moyer
2021-08-09 15:58 ` Jeff Moyer
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Jeff Moyer @ 2021-07-21 19:48 UTC (permalink / raw)
To: dan.j.williams
Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, Tony Luck,
Borislav Petkov, linux-edac, x86, linux-kernel, linux-mm
memtype_reserve takes an address range of the form [start, end). It
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()!
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.
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);
+ 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));
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch] x86/pat: pass correct address to sanitize_phys
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
2 siblings, 0 replies; 5+ messages in thread
From: Jeff Moyer @ 2021-08-09 15:58 UTC (permalink / raw)
To: dan.j.williams
Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, Tony Luck,
Borislav Petkov, linux-edac, x86, linux-kernel, linux-mm
Ping? This patch fixes a real problem seen in the field. Can I get
some review?
Thanks!
Jeff
Jeff Moyer <jmoyer@redhat.com> writes:
> memtype_reserve takes an address range of the form [start, end). It
> 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()!
>
> 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.
>
> 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);
> + 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));
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch] x86/pat: pass correct address to sanitize_phys
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
2 siblings, 0 replies; 5+ messages in thread
From: David Hildenbrand @ 2021-08-09 17:25 UTC (permalink / raw)
To: Jeff Moyer, dan.j.williams
Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, Tony Luck,
Borislav Petkov, linux-edac, x86, linux-kernel, linux-mm
On 21.07.21 21:48, Jeff Moyer wrote:
> memtype_reserve takes an address range of the form [start, end). It
> 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()!
>
> 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.
>
> 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);
> + 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));
>
>
LGTM
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Thanks,
David / dhildenb
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch] x86/pat: pass correct address to sanitize_phys
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
2021-08-10 19:22 ` Jeff Moyer
2 siblings, 1 reply; 5+ messages in thread
From: Thomas Gleixner @ 2021-08-10 6:38 UTC (permalink / raw)
To: Jeff Moyer, dan.j.williams
Cc: Ingo Molnar, H. Peter Anvin, Tony Luck, Borislav Petkov,
linux-edac, x86, linux-kernel, linux-mm
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch] x86/pat: pass correct address to sanitize_phys
2021-08-10 6:38 ` Thomas Gleixner
@ 2021-08-10 19:22 ` Jeff Moyer
0 siblings, 0 replies; 5+ messages in thread
From: Jeff Moyer @ 2021-08-10 19:22 UTC (permalink / raw)
To: Thomas Gleixner
Cc: dan.j.williams, Ingo Molnar, H. Peter Anvin, Tony Luck,
Borislav Petkov, linux-edac, x86, linux-kernel, linux-mm
Thomas Gleixner <tglx@linutronix.de> writes:
> Jeff,
>
> On Wed, Jul 21 2021 at 15:48, Jeff Moyer wrote:
>
> Please write function names with brackets, i.e. sanitize_phys().
OK, will do.
>> memtype_reserve takes an address range of the form [start, end). It
>
> [start, end]
Start is inclusive, end is exclusive, so start <= x < end. I used the
notation found here:
https://en.wikipedia.org/wiki/Interval_(mathematics)
If that's too confusing, I can stick to inclusive vs exclusive verbiage.
>> 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?
It does. I'll include the warning message in the v2 posting.
>> 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
> */
That works for me (modulo the interval notation), thanks for the
suggestion.
Thanks!
Jeff
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-08-10 19:21 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2021-08-10 19:22 ` Jeff Moyer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).