From: Mark Rutland <mark.rutland@arm.com>
To: Boyang Zhou <zhouby_cn@126.com>
Cc: catalin.marinas@arm.com, will.deacon@arm.com, haozhu@nudt.edu.cn,
linux@dominikbrodowski.net, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
arnd@arndb.de, viro@zeniv.linux.org.uk,
akpm@linux-foundation.org
Subject: Re: [PATCH] The patch solves the type error of the parameter “off” in syscall mmap on the ARM64 platform.
Date: Thu, 18 Apr 2019 12:28:18 +0100 [thread overview]
Message-ID: <20190418112818.GA31923@lakrids.cambridge.arm.com> (raw)
In-Reply-To: <1555504525-17962-1-git-send-email-zhouby_cn@126.com>
[adding linux-arch and relevant folk]
On Wed, Apr 17, 2019 at 08:35:25PM +0800, Boyang Zhou wrote:
> The error information is that “offset value too large for defined data type”.
> Reason:
> On the X86 platform, the data type of “off" is unsigned long; but on the ARM64 platform, the data type is defined as off_t, and off_t is by type long instead of unsigned long.
> When the off right shifts in the function “sys_mmap_pgoff(addr, len, prot, flags, fd, off >> PAGE_SHIFT)"on ARM64, high address of off is filled with sign bit 1instead of 0.
> In our case, we mmap GPU doorbell on both platform. On the x86 platform, the value of off is f009c00000000000, after shift the value becomes f009c00000000; while on the ARM64, the value of off changes from ed35c00000000000 to fffed35c00000000. This value is treated as unsigned long in later functions. So it is too big for off and the error happened.
> We have tested the patchs in Huawei ARM64 server with a couples of AMD GPUs.
It looks like the generic mmap uses unsigned long, as do sparc and x86.
However, arm64, microblase, powerpc and riscv all use off_t.
Should those all be using unsigned long? If so, that seems like it
should be a treewide cleanup.
Similar applies to pgoff for mmap2.
Thanks,
Mark.
>
> Signed-off-by: Boyang Zhou <zhouby_cn@126.com>
> ---
> arch/arm64/kernel/sys.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm64/kernel/sys.c b/arch/arm64/kernel/sys.c
> index b44065f..6f91e81 100644
> --- a/arch/arm64/kernel/sys.c
> +++ b/arch/arm64/kernel/sys.c
> @@ -31,7 +31,7 @@
>
> SYSCALL_DEFINE6(mmap, unsigned long, addr, unsigned long, len,
> unsigned long, prot, unsigned long, flags,
> - unsigned long, fd, off_t, off)
> + unsigned long, fd, unsigned long, off)
> {
> if (offset_in_page(off) != 0)
> return -EINVAL;
> --
> 2.7.4
>
next prev parent reply other threads:[~2019-04-18 11:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-17 12:35 Boyang Zhou
2019-04-18 11:28 ` Mark Rutland [this message]
2019-04-23 17:04 ` Will Deacon
2019-04-23 17:20 ` Mark Rutland
2019-04-24 8:31 ` David Howells
2019-04-24 13:50 ` Will Deacon
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=20190418112818.GA31923@lakrids.cambridge.arm.com \
--to=mark.rutland@arm.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=catalin.marinas@arm.com \
--cc=haozhu@nudt.edu.cn \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@dominikbrodowski.net \
--cc=viro@zeniv.linux.org.uk \
--cc=will.deacon@arm.com \
--cc=zhouby_cn@126.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
all inboxes | Powered by JetHome®