linux-sh.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sh: pgtable-3level: Fix cast to pointer from integer of different size
@ 2021-09-15 13:50 Geert Uytterhoeven
  2021-09-15 13:58 ` Daniel Palmer
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Geert Uytterhoeven @ 2021-09-15 13:50 UTC (permalink / raw)
  To: Yoshinori Sato, Rich Felker, Aneesh Kumar K . V, Andrew Morton
  Cc: Jacopo Mondi, Daniel Palmer, linux-sh, linux-mm, linux-kernel,
	Geert Uytterhoeven

If X2TLB=y (CPU_SHX2=y or CPU_SHX3=y, e.g. migor_defconfig), pgd_t.pgd
is "unsigned long long", causing:

    In file included from arch/sh/include/asm/pgtable.h:13,
		     from include/linux/pgtable.h:6,
		     from include/linux/mm.h:33,
		     from arch/sh/kernel/asm-offsets.c:14:
    arch/sh/include/asm/pgtable-3level.h: In function ‘pud_pgtable’:
    arch/sh/include/asm/pgtable-3level.h:37:9: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
       37 |  return (pmd_t *)pud_val(pud);
	  |         ^

Fix this by adding an intermediate cast to "unsigned long", which is
basically what the old code did before.

Fixes: 9cf6fa2458443118 ("mm: rename pud_page_vaddr to pud_pgtable and make it return pmd_t *")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
Compile-tested only, as the remote Migo-R is MIA.
Anyone with e.g. a Migo-R or Ecovec to boot-test?
The truncation to "unsigned long" has been there since forever, so
probably it still works fine ;-)

... once the other build issues are fixed.
---
 arch/sh/include/asm/pgtable-3level.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/sh/include/asm/pgtable-3level.h b/arch/sh/include/asm/pgtable-3level.h
index 56bf35c2f29c2b83..cdced80a7ffa3944 100644
--- a/arch/sh/include/asm/pgtable-3level.h
+++ b/arch/sh/include/asm/pgtable-3level.h
@@ -34,7 +34,7 @@ typedef struct { unsigned long long pmd; } pmd_t;
 
 static inline pmd_t *pud_pgtable(pud_t pud)
 {
-	return (pmd_t *)pud_val(pud);
+	return (pmd_t *)(unsigned long)pud_val(pud);
 }
 
 /* only used by the stubbed out hugetlb gup code, should never be called */
-- 
2.25.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] sh: pgtable-3level: Fix cast to pointer from integer of different size
  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
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Daniel Palmer @ 2021-09-15 13:58 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Yoshinori Sato, Rich Felker, Aneesh Kumar K . V, Andrew Morton,
	Jacopo Mondi, Linux-sh list, linux-mm, Linux Kernel Mailing List

Hi Geert,

On Wed, 15 Sept 2021 at 22:52, Geert Uytterhoeven
<geert+renesas@glider.be> wrote:
> Compile-tested only, as the remote Migo-R is MIA.
> Anyone with e.g. a Migo-R or Ecovec to boot-test?

Yes. It's 11pm here right now so I'll do it tomorrow and get back to you.

Cheers,

Daniel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] sh: pgtable-3level: Fix cast to pointer from integer of different size
  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-23 15:20 ` John Paul Adrian Glaubitz
  3 siblings, 0 replies; 8+ messages in thread
From: Daniel Palmer @ 2021-09-16 12:06 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Yoshinori Sato, Rich Felker, Aneesh Kumar K . V, Andrew Morton,
	Jacopo Mondi, Linux-sh list, linux-mm, Linux Kernel Mailing List

On Wed, 15 Sept 2021 at 22:52, Geert Uytterhoeven
<geert+renesas@glider.be> wrote:
> Anyone with e.g. a Migo-R or Ecovec to boot-test?

Tested-by: Daniel Palmer <daniel@thingy.jp>

--- Massive boot log from an ecovec ---

Bytes transferred = 25788416 (1898000 hex)
## Booting kernel from Legacy Image at 89000000 ...
  Image Name:   Linux-5.15.0-rc1
  Image Type:   SuperH Linux Kernel Image (gzip compressed)
  Data Size:    3175191 Bytes =  3 MB
  Load Address: 88001000
  Entry Point:  88002000
  Verifying Checksum ... OK
  Uncompressing Kernel Image ... OK
Linux version 5.15.0-rc1 (daniel@shiro)
(sh4-buildroot-linux-gnu-gcc.br_real (Buildroot
2021.02-715-g5e3799213236) 10.3.0, GNU ld (GNU Binutils) 2.36.1) #6
Thu Sep 16 21
Boot params:
... MOUNT_ROOT_RDONLY - 00000000
... RAMDISK_FLAGS     - 00000000
... ORIG_ROOT_DEV     - 00000000
... LOADER_TYPE       - 00000000
... INITRD_START      - 00000000
... INITRD_SIZE       - 00000000
Memory limited to 248MB
Booting machvec: R0P7724 (EcoVec)
initrd disabled
Zone ranges:
 Normal   [mem 0x0000000008000000-0x00000000177fffff]
Movable zone start for each node
Early memory node ranges
 node   0: [mem 0x0000000008000000-0x00000000177fffff]
Initmem setup node 0 [mem 0x0000000008000000-0x00000000177fffff]
Built 1 zonelists, mobility grouping on.  Total pages: 62930
Kernel command line: console=tty0, console=ttySC0,115200
phram.phram=rootfs,0x8a000000,32Mi memmap=32M$0x8a000000
root=/dev/mmcblk0 ro rootwait mem=248M memchunk.vpu=8mm
Unknown command line parameters: memmap=32M$0x8a000000
Dentry cache hash table entries: 32768 (order: 5, 131072 bytes, linear)
Inode-cache hash table entries: 16384 (order: 4, 65536 bytes, linear)
Sorting __ex_table...
mem auto-init: stack:off, heap alloc:off, heap free:off
PVR=10300b00 CVR=7144040d PRR=00002200
I-cache : n_ways=4 n_sets=256 way_incr=8192
I-cache : entry_mask=0x00001fe0 alias_mask=0x00001000 n_aliases=2
D-cache : n_ways=4 n_sets=256 way_incr=8192
D-cache : entry_mask=0x00001fe0 alias_mask=0x00001000 n_aliases=2
S-cache : n_ways=4 n_sets=2048 way_incr=65536
S-cache : entry_mask=0x0000ffe0 alias_mask=0x0000f000 n_aliases=16
virtual kernel memory layout:
   fixmap  : 0xdffd7000 - 0xdffff000   ( 160 kB)
   vmalloc : 0xc0000000 - 0xdffd5000   ( 511 MB)
   lowmem  : 0x88000000 - 0x97800000   ( 248 MB) (cached)
           : 0xa0000000 - 0xc0000000   ( 512 MB) (uncached)
     .init : 0x884eb000 - 0x8850a000   ( 124 kB)
     .data : 0x883ab8e8 - 0x884ea3ec   (1274 kB)
     .text : 0x88001000 - 0x883ab8e8   (3754 kB)
Memory: 246224K/253952K available (3750K kernel code, 266K rwdata,
1004K rodata, 124K init, 89K bss, 7724K reserved, 0K cma-reserved)
SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
NR_IRQS: 8, nr_irqs: 8, preallocated irqs: 0
intc: Registered controller 'sh7724' with 83 IRQs
random: get_random_bytes called from start_kernel+0x3d6/0x740 with crng_init=0
Console: colour dummy device 80x25
printk: console [tty0] enabled
sh-cmt-32.0: ch0: used for clock events
sh-cmt-32.0: ch0: used for periodic clock events
sh-cmt-32.0: ch0: used as clock source
clocksource: sh-cmt-32.0: mask: 0xffffffff max_cycles: 0xffffffff,
max_idle_ns: 466616319891357 ns
sh-tmu.0: ch0: used for clock events
sh-tmu.0: ch0: used for periodic clock events
sh-tmu.0: ch1: used as clock source
clocksource: sh-tmu.0: mask: 0xffffffff max_cycles: 0xffffffff,
max_idle_ns: 183481014613 ns
sched_clock: 32 bits at 250 Hz, resolution 4000000ns, wraps every
8589934590000000ns
Calibrating delay loop (skipped)... 499.99 BogoMIPS PRESET (lpj=999999)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
CPU: SH7724
Performance Events: sh4a support registered
devtmpfs: initialized
clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff,
max_idle_ns: 7645041785100000 ns
futex hash table entries: 256 (order: -1, 3072 bytes, linear)
pinctrl core: initialized pinctrl subsystem
NET: Registered PF_NETLINK/PF_ROUTE protocol family
DMA: preallocated 128 KiB GFP_KERNEL pool for atomic allocations
vpu: forcing memory chunk size to 0x00800000
veu0: forcing memory chunk size to 0x00400000
sh-pfc pfc-sh7724: sh7724_pfc handling gpio 0 -> 179
sh-pfc pfc-sh7724: sh7724_pfc handling gpio 180 -> 486
sh-pfc pfc-sh7724: sh7724_pfc support registered
HW Breakpoints: SH-4A UBC support registered
sh-pfc pfc-sh7724: Use of GPIO API for function requests is
deprecated, convert to pinctrl
USB1 function is selected
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
mc: Linux media interface: v0.10
videodev: Linux video capture interface: v2.00
pps_core: LinuxPPS API ver. 1 registered
pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti
<giometti@linux.it>
PTP clock support registered
sh_cmt sh-cmt-32.0: kept as earlytimer
sh_tmu sh-tmu.0: kept as earlytimer
sh_tmu sh-tmu.1: ch0: used for clock events
sh_tmu sh-tmu.1: ch1: used as clock source
clocksource: sh-tmu.1: mask: 0xffffffff max_cycles: 0xffffffff,
max_idle_ns: 183481014613 ns
Advanced Linux Sound Architecture Driver Initialized.
clocksource: Switched to clocksource sh-tmu.0
sh_tmu sh-tmu.0: ch0: used for oneshot clock events
NET: Registered PF_INET protocol family
IP idents hash table entries: 4096 (order: 3, 32768 bytes, linear)
tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 4096 bytes, linear)
TCP established hash table entries: 2048 (order: 1, 8192 bytes, linear)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes, linear)
TCP: Hash tables configured (established 2048 bind 2048)
UDP hash table entries: 256 (order: 0, 4096 bytes, linear)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes, linear)
sq: Registering store queue API.
unable to read sh_eth MAC address
workingset: timestamp_bits=14 max_order=16 bucket_order=2
squashfs: version 4.0 (2009/01/31) Phillip Lougher
Console: switching to colour frame buffer device 100x30
sh_mobile_lcdc_fb sh_mobile_lcdc_fb.0: registered
sh_mobile_lcdc_fb.0/mainlcd as 800x480 16bpp.
SuperH (H)SCI(F) driver initialized
sh-sci.0: ttySC0 at MMIO 0xffe00000 (irq = 80, base_baud = 0) is a scif
printk: console [ttySC0] enabled
sh-sci.1: ttySC1 at MMIO 0xffe10000 (irq = 81, base_baud = 0) is a scif
sh-sci.2: ttySC2 at MMIO 0xffe20000 (irq = 82, base_baud = 0) is a scif
sh-sci.3: ttySC3 at MMIO 0xa4e30000 (irq = 56, base_baud = 0) is a scifa
sh-sci.4: ttySC4 at MMIO 0xa4e40000 (irq = 88, base_baud = 0) is a scifa
sh-sci.5: ttySC5 at MMIO 0xa4e50000 (irq = 109, base_baud = 0) is a scifa
physmap-flash physmap-flash.0: physmap platform flash device: [mem
0x00000000-0x03ffffff]
physmap-flash.0: Found 1 x16 devices at 0x0 in 16-bit bank.
Manufacturer ID 0x000001 Chip ID 0x002301
Amd/Fujitsu Extended Query Table at 0x0040
 Amd/Fujitsu Extended Query version 1.3.
number of CFI chips: 1
Creating 2 MTD partitions on "physmap-flash.0":
0x000000000000-0x000000500000 : "boot loader"
0x000000500000-0x000004000000 : "free-area"
phram: rootfs device: 0x2000000 at 0x8a000000 for erasesize 0x1000
SMSC LAN8700: probe of sh7724-ether-0:1f failed with error -22
libphy: sh_mii: probed
sh-eth sh7724-ether.0 eth0: Base address at 0xa4600000,
00:00:87:6c:1d:c2, IRQ 91.
r8a66597_hcd r8a66597_hcd.0: USB Host Controller
r8a66597_hcd r8a66597_hcd.0: new USB bus registered, assigned bus number 1
r8a66597_hcd r8a66597_hcd.0: irq 65, io base 0xa4d80000
usb usb1: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 5.15
usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
usb usb1: Product: USB Host Controller
usb usb1: Manufacturer: Linux 5.15.0-rc1 r8a66597_hcd
usb usb1: SerialNumber: r8a66597_hcd
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 1 port detected
sh-rtc sh-rtc: registered as rtc0
sh-rtc sh-rtc: hctosys: unable to read the hardware clock
renesas-ceu renesas-ceu.0: Renesas Capture Engine Unit renesas-ceu.0
renesas-ceu renesas-ceu.1: Renesas Capture Engine Unit renesas-ceu.1
cpufreq: SuperH CPU frequency driver.
cpufreq: cpufreq_online: ->get() failed
sh_mmcif sh_mmcif.0: Platform OCR mask is ignored
heartbeat: version 0.1.2 loaded
ALSA device list:
 No soundcards found.
sh_mmcif sh_mmcif.0: Chip version 0x0000, clock rate 83MHz
sh_mobile_sdhi sh_mobile_sdhi.0: mmc0 base at 0x04ce0000, max clock rate 83 MHz
Waiting for root device /dev/mmcblk0...
random: fast init done
usb 1-1: new full-speed USB device number 2 using r8a66597_hcd
mmc0: new SDHC card at address fb83
mmcblk0: mmc0:fb83 SE08G 7.22 GiB
VFS: Mounted root (squashfs filesystem) readonly on device 179:0.
devtmpfs: mounted
Freeing unused kernel image (initmem) memory: 124K
This architecture does not have kernel memory protection.
Run /sbin/init as init process
usb 1-1: New USB device found, idVendor=10c4, idProduct=ea60, bcdDevice= 1.00
usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-1: Product: CP2102 USB to UART Bridge Controller
usb 1-1: Manufacturer: Silicon Labs
usb 1-1: SerialNumber: 0001
NET: Registered PF_UNIX/PF_LOCAL protocol family
Starting syslogd: OK
Starting klogd: OK
Running sysctl: OK
Starting mdev... OK
usbcore: registered new interface driver cp210x
usbserial: USB Serial support registered for cp210x
cp210x 1-1:1.0: cp210x converter detected
usb 1-1: cp210x converter now attached to ttyUSB0
Saving random seed: SKIP (read-only file system detected)
Starting haveged: haveged: command socket is listening at fd 3
OK
Starting network: Generic PHY sh7724-ether-0:1f: attached PHY driver
(mii_bus:phy_addr=sh7724-ether-0:1f, irq=POLL)
sh-eth sh7724-ether.0 eth0: Link is Up - 100Mbps/Full - flow control off
udhcpc: started, v1.33.0
NET: Registered PF_PACKET protocol family
udhcpc: sending discover
udhcpc: sending select for 192.168.3.251
udhcpc: lease of 192.168.3.251 obtained, lease time 3600
deleting routers
adding dns 192.168.3.1
adding dns 192.168.3.2
OK
Starting openntpd: -s option no longer works and will be removed soon.
Please reconfigure to use constraints or trusted servers.
constraint configured without libtls support
constraint configured without libtls support
constraint configured without libtls support
OK
No persistent location to store SSH host keys. New keys will be
generated at each boot. Are you sure this is what you want to do?
Starting dropbear sshd: NET: Registered PF_INET6 protocol family
Segment Routing with IPv6
In-situ OAM (IOAM) with IPv6
OK
Starting nodectrl: OK
Starting tlwbe_heartbeat: random: python3: uninitialized urandom read
(24 bytes read)
random: crng init done
CN12 SD/MMC Vdd: incomplete constraints, leaving on
OK

Welcome to Buildroot
ecovec24 login: sh4life
$ cat /proc/cpuinfo
machine         : R0P7724 (EcoVec)
processor       : 0
cpu family      : sh4a
cpu type        : SH7724
cut             : 11.x
cpu flags       : fpu perfctr llsc l2
cache type      : split (harvard)
icache size     : 32KiB (4-way)
dcache size     : 32KiB (4-way)
scache size     : 256KiB (4-way)
address sizes   : 29 bits physical
bogomips        : 499.99
$

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] sh: pgtable-3level: Fix cast to pointer from integer of different size
  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
  2021-09-23 15:20 ` John Paul Adrian Glaubitz
  3 siblings, 1 reply; 8+ messages in thread
From: Rob Landley @ 2021-09-17  1:32 UTC (permalink / raw)
  To: Geert Uytterhoeven, Yoshinori Sato, Rich Felker,
	Aneesh Kumar K . V, Andrew Morton
  Cc: Jacopo Mondi, Daniel Palmer, linux-sh, linux-mm, linux-kernel

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.)

Rob

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] sh: pgtable-3level: Fix cast to pointer from integer of different size
  2021-09-17  1:32 ` Rob Landley
@ 2021-09-17  9:21   ` Geert Uytterhoeven
  2021-09-18  5:04     ` Rob Landley
  0 siblings, 1 reply; 8+ messages in thread
From: Geert Uytterhoeven @ 2021-09-17  9:21 UTC (permalink / raw)
  To: Rob Landley
  Cc: Yoshinori Sato, Rich Felker, Aneesh Kumar K . V, Andrew Morton,
	Jacopo Mondi, Daniel Palmer, Linux-sh list, Linux MM,
	Linux Kernel Mailing List

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] sh: pgtable-3level: Fix cast to pointer from integer of different size
  2021-09-17  9:21   ` Geert Uytterhoeven
@ 2021-09-18  5:04     ` Rob Landley
  2021-09-18 11:20       ` Geert Uytterhoeven
  0 siblings, 1 reply; 8+ messages in thread
From: Rob Landley @ 2021-09-18  5:04 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Yoshinori Sato, Rich Felker, Aneesh Kumar K . V, Andrew Morton,
	Jacopo Mondi, Daniel Palmer, Linux-sh list, Linux MM,
	Linux Kernel Mailing List

On 9/17/21 4:21 AM, Geert Uytterhoeven wrote:
> 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.

I know. I'm just saying your fix doesn't seem wrong. (Personally I would have
just cast once to (void *) and let C not being C++ do the right thing, but eh...)

Not sure I understand the point of the original code though. Under what
conditions do you want 64 bit page tables on a 32 bit system? (Some PAE variant?)

> 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:

I can't find a user of it. None of the existing defconfigs select this option:

  $ grep -r X2TLB arch/sh/configs

And it's weird in other ways, like 8k page size. (Why...?)

Google finds sh-x2 mentioned in Renesas' sh4a debugger docs, but I've never
played with the renesas "a" variants. The stuff I'm familiar with is all
following up on what Hitachi did, not Renesas.

*shrug* You fix looks good enough to me.

Acked-by: Rob Landley <rob@landley.net>

Rob

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] sh: pgtable-3level: Fix cast to pointer from integer of different size
  2021-09-18  5:04     ` Rob Landley
@ 2021-09-18 11:20       ` Geert Uytterhoeven
  0 siblings, 0 replies; 8+ messages in thread
From: Geert Uytterhoeven @ 2021-09-18 11:20 UTC (permalink / raw)
  To: Rob Landley
  Cc: Yoshinori Sato, Rich Felker, Aneesh Kumar K . V, Andrew Morton,
	Jacopo Mondi, Daniel Palmer, Linux-sh list, Linux MM,
	Linux Kernel Mailing List

Hi Rob,

On Sat, Sep 18, 2021 at 6:45 AM Rob Landley <rob@landley.net> wrote:
> On 9/17/21 4:21 AM, Geert Uytterhoeven wrote:
> > 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.
>
> I know. I'm just saying your fix doesn't seem wrong. (Personally I would have
> just cast once to (void *) and let C not being C++ do the right thing, but eh...)

That would still give a warning, as "unsigned long long" us 64-bit, and
"void *" is 32-bit.

> Not sure I understand the point of the original code though. Under what
> conditions do you want 64 bit page tables on a 32 bit system? (Some PAE variant?)
>
> > 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:
>
> I can't find a user of it. None of the existing defconfigs select this option:
>
>   $ grep -r X2TLB arch/sh/configs

Note that these are reduced config files, so auto-selected symbols are
not present in the defconfig.

config X2TLB
        def_bool y
        depends on (CPU_SHX2 || CPU_SHX3) && MMU

and e.g.

config CPU_SUBTYPE_SH7723
        bool "Support SH7723 processor"
        select CPU_SH4A
        select CPU_SHX2

>
> And it's weird in other ways, like 8k page size. (Why...?)
>
> Google finds sh-x2 mentioned in Renesas' sh4a debugger docs, but I've never
> played with the renesas "a" variants. The stuff I'm familiar with is all
> following up on what Hitachi did, not Renesas.
>
> *shrug* You fix looks good enough to me.
>
> Acked-by: Rob Landley <rob@landley.net>

Thanks!

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] sh: pgtable-3level: Fix cast to pointer from integer of different size
  2021-09-15 13:50 [PATCH] sh: pgtable-3level: Fix cast to pointer from integer of different size Geert Uytterhoeven
                   ` (2 preceding siblings ...)
  2021-09-17  1:32 ` Rob Landley
@ 2021-09-23 15:20 ` John Paul Adrian Glaubitz
  3 siblings, 0 replies; 8+ messages in thread
From: John Paul Adrian Glaubitz @ 2021-09-23 15:20 UTC (permalink / raw)
  To: Geert Uytterhoeven, Yoshinori Sato, Rich Felker,
	Aneesh Kumar K . V, Andrew Morton
  Cc: Jacopo Mondi, Daniel Palmer, linux-sh, linux-mm, linux-kernel

Hi Geert!

On 9/15/21 15:50, Geert Uytterhoeven wrote:
> If X2TLB=y (CPU_SHX2=y or CPU_SHX3=y, e.g. migor_defconfig), pgd_t.pgd
> is "unsigned long long", causing:
> 
>     In file included from arch/sh/include/asm/pgtable.h:13,
> 		     from include/linux/pgtable.h:6,
> 		     from include/linux/mm.h:33,
> 		     from arch/sh/kernel/asm-offsets.c:14:
>     arch/sh/include/asm/pgtable-3level.h: In function ‘pud_pgtable’:
>     arch/sh/include/asm/pgtable-3level.h:37:9: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
>        37 |  return (pmd_t *)pud_val(pud);
> 	  |         ^
> 
> Fix this by adding an intermediate cast to "unsigned long", which is
> basically what the old code did before.

Thanks a lot for fixing this. My SH kernel build becomes much less noisy with
your patch. I can also confirm that it doesn't break the boot on my SH-7785LCR
as expected.

Tested-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaubitz@debian.org
`. `'   Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-09-23 15:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2021-09-18  5:04     ` Rob Landley
2021-09-18 11:20       ` Geert Uytterhoeven
2021-09-23 15:20 ` John Paul Adrian Glaubitz

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).