From: Michael Ellerman <patch-notifications@ellerman•id.au>
To: Michael Ellerman <mpe@ellerman•id.au>, linuxppc-dev@ozlabs•org
Cc: keescook@chromium•org, paulus@samba•org, leitao@debian•org,
labbott@redhat•com, khandual@linux•vnet.ibm.com
Subject: Re: powerpc/mm: Fix virt_addr_valid() etc. on 64-bit hash
Date: Fri, 19 May 2017 19:45:54 +1000 (AEST) [thread overview]
Message-ID: <3wTjq63wtqz9s7k@ozlabs.org> (raw)
In-Reply-To: <1495103851-14916-1-git-send-email-mpe@ellerman.id.au>
On Thu, 2017-05-18 at 10:37:31 UTC, Michael Ellerman wrote:
> virt_addr_valid() is supposed to tell you if it's OK to call virt_to_page() on
> an address. What this means in practice is that it should only return true for
> addresses in the linear mapping which are backed by a valid PFN.
>
> We are failing to properly check that the address is in the linear mapping,
> because virt_to_pfn() will return a valid looking PFN for more or less any
> address. That bug is actually caused by __pa(), used in virt_to_pfn().
>
> eg: __pa(0xc000000000010000) = 0x10000 # Good
> __pa(0xd000000000010000) = 0x10000 # Bad!
> __pa(0x0000000000010000) = 0x10000 # Bad!
>
> This started happening after commit bdbc29c19b26 ("powerpc: Work around gcc
> miscompilation of __pa() on 64-bit") (Aug 2013), where we changed the definition
> of __pa() to work around a GCC bug. Prior to that we subtracted PAGE_OFFSET from
> the value passed to __pa(), meaning __pa() of a 0xd or 0x0 address would give
> you something bogus back.
>
> Until we can verify if that GCC bug is no longer an issue, or come up with
> another solution, this commit does the minimal fix to make virt_addr_valid()
> work, by explicitly checking that the address is in the linear mapping region.
>
> Fixes: bdbc29c19b26 ("powerpc: Work around gcc miscompilation of __pa() on 64-bit")
> Signed-off-by: Michael Ellerman <mpe@ellerman•id.au>
> Reviewed-by: Paul Mackerras <paulus@ozlabs•org>
> Reviewed-by: Balbir Singh <bsingharora@gmail•com>
> Tested-by: Breno Leitao <breno.leitao@gmail•com>
Applied to powerpc fixes.
https://git.kernel.org/powerpc/c/e41e53cd4fe331d0d1f06f8e4ed7e2
cheers
prev parent reply other threads:[~2017-05-19 9:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-18 10:37 [PATCH] powerpc/mm: Fix virt_addr_valid() etc. on 64-bit hash Michael Ellerman
2017-05-18 11:57 ` Paul Mackerras
2017-05-18 18:00 ` Balbir Singh
2017-05-18 19:04 ` Breno Leitao
2017-05-19 9:45 ` Michael Ellerman [this message]
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=3wTjq63wtqz9s7k@ozlabs.org \
--to=patch-notifications@ellerman$(echo .)id.au \
--cc=keescook@chromium$(echo .)org \
--cc=khandual@linux$(echo .)vnet.ibm.com \
--cc=labbott@redhat$(echo .)com \
--cc=leitao@debian$(echo .)org \
--cc=linuxppc-dev@ozlabs$(echo .)org \
--cc=mpe@ellerman$(echo .)id.au \
--cc=paulus@samba$(echo .)org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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