From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Rob Landley <rob@landley.net>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>,
Rich Felker <dalias@libc.org>,
"Aneesh Kumar K . V" <aneesh.kumar@linux.ibm.com>,
Andrew Morton <akpm@linux-foundation.org>,
Jacopo Mondi <jacopo+renesas@jmondi.org>,
Daniel Palmer <daniel@0x0f.com>,
Linux-sh list <linux-sh@vger.kernel.org>,
Linux MM <linux-mm@kvack.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] sh: pgtable-3level: Fix cast to pointer from integer of different size
Date: Fri, 17 Sep 2021 11:21:09 +0200 [thread overview]
Message-ID: <CAMuHMdUYUbjPSitt3wTi-YY5CEKwDJNJKPp9Pbfewm7B0CXP2A@mail.gmail.com> (raw)
In-Reply-To: <1acace03-4273-a5ad-50b4-5ab8e3baa551@landley.net>
Hi Rob,
On Fri, Sep 17, 2021 at 3:12 AM Rob Landley <rob@landley.net> wrote:
> On 9/15/21 8:50 AM, Geert Uytterhoeven wrote:
> > arch/sh/include/asm/pgtable-3level.h:37:9: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
> ...
> > The truncation to "unsigned long" has been there since forever, so
> > probably it still works fine ;-)
>
> 1) Linux is LP64 so sizeof(long) and sizeof(pointer) always match, so it's not
> truncating.
>
> 2) The sh5 only ever shipped evaluation units, it never had a production run,
> and we haven't implemented j64 yet, so all superh targets are currently 32 bit.
> (I.E. it's complaining about _expanding_ the pointer, which shouldn't be a
> problem as long as endianness is respected.)
The build error is for 32-bit.
If CONFIG_X2TLB=y, pgd_t.pgd is "unsigned long long", i.e. 64-bit, so
casting it to a pointer needs an intermediate cast to "unsigned long".
See arch/sh/include/asm/page.h:
#ifdef CONFIG_X2TLB
typedef struct { unsigned long pte_low, pte_high; } pte_t;
typedef struct { unsigned long long pgprot; } pgprot_t;
typedef struct { unsigned long long pgd; } pgd_t;
#define pte_val(x) \
((x).pte_low | ((unsigned long long)(x).pte_high << 32))
#define __pte(x) \
({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
#else
typedef struct { unsigned long pte_low; } pte_t;
typedef struct { unsigned long pgprot; } pgprot_t;
typedef struct { unsigned long pgd; } pgd_t;
#define pte_val(x) ((x).pte_low)
#define __pte(x) ((pte_t) { (x) } )
#endif
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
next prev parent reply other threads:[~2021-09-17 9:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-15 13:50 [PATCH] sh: pgtable-3level: Fix cast to pointer from integer of different size Geert Uytterhoeven
2021-09-15 13:58 ` Daniel Palmer
2021-09-16 12:06 ` Daniel Palmer
2021-09-17 1:32 ` Rob Landley
2021-09-17 9:21 ` Geert Uytterhoeven [this message]
2021-09-18 5:04 ` Rob Landley
2021-09-18 11:20 ` Geert Uytterhoeven
2021-09-23 15:20 ` John Paul Adrian Glaubitz
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=CAMuHMdUYUbjPSitt3wTi-YY5CEKwDJNJKPp9Pbfewm7B0CXP2A@mail.gmail.com \
--to=geert@linux-m68k.org \
--cc=akpm@linux-foundation.org \
--cc=aneesh.kumar@linux.ibm.com \
--cc=dalias@libc.org \
--cc=daniel@0x0f.com \
--cc=jacopo+renesas@jmondi.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-sh@vger.kernel.org \
--cc=rob@landley.net \
--cc=ysato@users.sourceforge.jp \
/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;
as well as URLs for NNTP newsgroup(s).