Linux ATA/IDE development
 help / color / mirror / Atom feed
* [PATCH 00/12] kbuild: enable some -Wextra warnings by default
@ 2024-03-26 14:47 Arnd Bergmann
  2024-03-26 14:53 ` [PATCH 10/12] sata: sx4: fix pdc20621_get_from_dimm() on 64-bit Arnd Bergmann
  0 siblings, 1 reply; 5+ messages in thread
From: Arnd Bergmann @ 2024-03-26 14:47 UTC (permalink / raw)
  To: linux-kbuild, Masahiro Yamada, Nathan Chancellor
  Cc: Nicolas Schier, Arnd Bergmann, Bill Metzenthen, Thomas Gleixner,
	x86, Damien Le Moal, Jean Delvare, Harry Wentland, Jani Nikula,
	Sergey Shtylyov, Jakub Kicinski, Sudip Mukherjee, Andrew Jeffery,
	Manoj N. Kumar, Martin K. Petersen, Alexei Starovoitov,
	Steven Rostedt, Luis Chamberlain, Andrew Morton,
	Greg Kroah-Hartman, linux-kernel, linux-ide, amd-gfx, dri-devel,
	intel-gfx, nouveau, intel-xe, netdev, linux-renesas-soc,
	linux-arm-kernel, linux-scsi, bpf, linux-trace-kernel,
	linux-modules, linux-mm, llvm

From: Arnd Bergmann <arnd@arndb.de>

This is a follow-up on a couple of patch series I sent in the past,
enabling -Wextra (aside from stuff that is explicitly disabled),
-Wcast-function-pointer-strict and -Wrestrict.

I have tested these on 'defconfig' and 'allmodconfig' builds across
all architectures, as well as many 'randconfig' builds on x86, arm and
arm64. It would be nice to have all the Makefile.extrawarn changes in
v6.10, hopefully with the driver fixes going in before that through
the respective subsystem trees.

     Arnd

Arnd Bergmann (12):
  kbuild: make -Woverride-init warnings more consistent
  [v3] parport: mfc3: avoid empty-body warning
  kbuild: turn on -Wextra by default
  kbuild: remove redundant extra warning flags
  firmware: dmi-id: add a release callback function
  nouveau: fix function cast warning
  cxlflash: fix function pointer cast warnings
  x86: math-emu: fix function cast warnings
  kbuild: enable -Wcast-function-type-strict unconditionally
  sata: sx4: fix pdc20621_get_from_dimm() on 64-bit
  [v4] kallsyms: rework symbol lookup return codes
  kbuild: turn on -Wrestrict by default

 arch/x86/math-emu/fpu_etc.c                   |  9 +++--
 arch/x86/math-emu/fpu_trig.c                  |  6 ++--
 arch/x86/math-emu/reg_constant.c              |  7 +++-
 drivers/ata/sata_sx4.c                        |  6 ++--
 drivers/firmware/dmi-id.c                     |  7 +++-
 .../gpu/drm/amd/display/dc/dce110/Makefile    |  2 +-
 .../gpu/drm/amd/display/dc/dce112/Makefile    |  2 +-
 .../gpu/drm/amd/display/dc/dce120/Makefile    |  2 +-
 drivers/gpu/drm/amd/display/dc/dce60/Makefile |  2 +-
 drivers/gpu/drm/amd/display/dc/dce80/Makefile |  2 +-
 drivers/gpu/drm/i915/Makefile                 |  6 ++--
 .../drm/nouveau/nvkm/subdev/bios/shadowof.c   |  7 +++-
 drivers/gpu/drm/xe/Makefile                   |  4 +--
 drivers/net/ethernet/renesas/sh_eth.c         |  2 +-
 drivers/parport/parport_mfc3.c                |  3 +-
 drivers/pinctrl/aspeed/Makefile               |  2 +-
 drivers/scsi/cxlflash/lunmgt.c                |  4 +--
 drivers/scsi/cxlflash/main.c                  | 14 ++++----
 drivers/scsi/cxlflash/superpipe.c             | 34 +++++++++----------
 drivers/scsi/cxlflash/superpipe.h             | 11 +++---
 drivers/scsi/cxlflash/vlun.c                  |  7 ++--
 fs/proc/Makefile                              |  2 +-
 include/linux/filter.h                        | 14 ++++----
 include/linux/ftrace.h                        |  6 ++--
 include/linux/module.h                        | 14 ++++----
 kernel/bpf/Makefile                           |  2 +-
 kernel/bpf/core.c                             |  7 ++--
 kernel/kallsyms.c                             | 23 +++++++------
 kernel/module/kallsyms.c                      | 26 +++++++-------
 kernel/trace/ftrace.c                         | 13 +++----
 mm/Makefile                                   |  3 +-
 scripts/Makefile.extrawarn                    | 33 ++++--------------
 32 files changed, 134 insertions(+), 148 deletions(-)

-- 
2.39.2

Cc: Bill Metzenthen <billm@melbpc.org.au>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: x86@kernel.org
Cc: Damien Le Moal <dlemoal@kernel.org>
Cc: Jean Delvare <jdelvare@suse.com>
Cc: Harry Wentland <harry.wentland@amd.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Sergey Shtylyov <s.shtylyov@omp.ru>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Cc: Andrew Jeffery <andrew@codeconstruct.com.au>
Cc: "Manoj N. Kumar" <manoj@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Luis Chamberlain <mcgrof@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Masahiro Yamada <masahiroy@kernel.org>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Nicolas Schier <nicolas@fjasle.eu>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Cc: linux-kernel@vger.kernel.org
Cc: linux-ide@vger.kernel.org
Cc: amd-gfx@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Cc: intel-gfx@lists.freedesktop.org
Cc: nouveau@lists.freedesktop.org
Cc: intel-xe@lists.freedesktop.org
Cc: netdev@vger.kernel.org
Cc: linux-renesas-soc@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-scsi@vger.kernel.org
Cc: bpf@vger.kernel.org
Cc: linux-trace-kernel@vger.kernel.org
Cc: linux-modules@vger.kernel.org
Cc: linux-mm@kvack.org
Cc: linux-kbuild@vger.kernel.org
Cc: llvm@lists.linux.dev

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

* [PATCH 10/12] sata: sx4: fix pdc20621_get_from_dimm() on 64-bit
  2024-03-26 14:47 [PATCH 00/12] kbuild: enable some -Wextra warnings by default Arnd Bergmann
@ 2024-03-26 14:53 ` Arnd Bergmann
  2024-03-27  1:36   ` Damien Le Moal
  0 siblings, 1 reply; 5+ messages in thread
From: Arnd Bergmann @ 2024-03-26 14:53 UTC (permalink / raw)
  To: linux-kbuild, Masahiro Yamada, Damien Le Moal, Niklas Cassel
  Cc: Nicolas Schier, Nathan Chancellor, Arnd Bergmann, John Garry,
	Martin K. Petersen, linux-ide, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

gcc warns about a memcpy() with overlapping pointers because of an
incorrect size calculation:

In file included from include/linux/string.h:369,
                 from drivers/ata/sata_sx4.c:66:
In function 'memcpy_fromio',
    inlined from 'pdc20621_get_from_dimm.constprop' at drivers/ata/sata_sx4.c:962:2:
include/linux/fortify-string.h:97:33: error: '__builtin_memcpy' accessing 4294934464 bytes at offsets 0 and [16, 16400] overlaps 6442385281 bytes at offset -2147450817 [-Werror=restrict]
   97 | #define __underlying_memcpy     __builtin_memcpy
      |                                 ^
include/linux/fortify-string.h:620:9: note: in expansion of macro '__underlying_memcpy'
  620 |         __underlying_##op(p, q, __fortify_size);                        \
      |         ^~~~~~~~~~~~~
include/linux/fortify-string.h:665:26: note: in expansion of macro '__fortify_memcpy_chk'
  665 | #define memcpy(p, q, s)  __fortify_memcpy_chk(p, q, s,                  \
      |                          ^~~~~~~~~~~~~~~~~~~~
include/asm-generic/io.h:1184:9: note: in expansion of macro 'memcpy'
 1184 |         memcpy(buffer, __io_virt(addr), size);
      |         ^~~~~~

The problem here is the overflow of an unsigned 32-bit number to a
negative that gets converted into a signed 'long', keeping a large
positive number.

Replace the complex calculation with a more readable min() variant
that avoids the warning.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/ata/sata_sx4.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/ata/sata_sx4.c b/drivers/ata/sata_sx4.c
index b51d7a9d0d90..a482741eb181 100644
--- a/drivers/ata/sata_sx4.c
+++ b/drivers/ata/sata_sx4.c
@@ -957,8 +957,7 @@ static void pdc20621_get_from_dimm(struct ata_host *host, void *psource,
 
 	offset -= (idx * window_size);
 	idx++;
-	dist = ((long) (window_size - (offset + size))) >= 0 ? size :
-		(long) (window_size - offset);
+	dist = min(size, window_size - offset);
 	memcpy_fromio(psource, dimm_mmio + offset / 4, dist);
 
 	psource += dist;
@@ -1005,8 +1004,7 @@ static void pdc20621_put_to_dimm(struct ata_host *host, void *psource,
 	readl(mmio + PDC_DIMM_WINDOW_CTLR);
 	offset -= (idx * window_size);
 	idx++;
-	dist = ((long)(s32)(window_size - (offset + size))) >= 0 ? size :
-		(long) (window_size - offset);
+	dist = min(size, window_size - offset);
 	memcpy_toio(dimm_mmio + offset / 4, psource, dist);
 	writel(0x01, mmio + PDC_GENERAL_CTLR);
 	readl(mmio + PDC_GENERAL_CTLR);
-- 
2.39.2


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

* Re: [PATCH 10/12] sata: sx4: fix pdc20621_get_from_dimm() on 64-bit
  2024-03-26 14:53 ` [PATCH 10/12] sata: sx4: fix pdc20621_get_from_dimm() on 64-bit Arnd Bergmann
@ 2024-03-27  1:36   ` Damien Le Moal
  2024-03-27 20:21     ` Arnd Bergmann
  0 siblings, 1 reply; 5+ messages in thread
From: Damien Le Moal @ 2024-03-27  1:36 UTC (permalink / raw)
  To: Arnd Bergmann, linux-kbuild, Masahiro Yamada, Niklas Cassel
  Cc: Nicolas Schier, Nathan Chancellor, Arnd Bergmann, John Garry,
	Martin K. Petersen, linux-ide, linux-kernel

On 3/26/24 23:53, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> gcc warns about a memcpy() with overlapping pointers because of an
> incorrect size calculation:
> 
> In file included from include/linux/string.h:369,
>                  from drivers/ata/sata_sx4.c:66:
> In function 'memcpy_fromio',
>     inlined from 'pdc20621_get_from_dimm.constprop' at drivers/ata/sata_sx4.c:962:2:
> include/linux/fortify-string.h:97:33: error: '__builtin_memcpy' accessing 4294934464 bytes at offsets 0 and [16, 16400] overlaps 6442385281 bytes at offset -2147450817 [-Werror=restrict]
>    97 | #define __underlying_memcpy     __builtin_memcpy
>       |                                 ^
> include/linux/fortify-string.h:620:9: note: in expansion of macro '__underlying_memcpy'
>   620 |         __underlying_##op(p, q, __fortify_size);                        \
>       |         ^~~~~~~~~~~~~
> include/linux/fortify-string.h:665:26: note: in expansion of macro '__fortify_memcpy_chk'
>   665 | #define memcpy(p, q, s)  __fortify_memcpy_chk(p, q, s,                  \
>       |                          ^~~~~~~~~~~~~~~~~~~~
> include/asm-generic/io.h:1184:9: note: in expansion of macro 'memcpy'
>  1184 |         memcpy(buffer, __io_virt(addr), size);
>       |         ^~~~~~
> 
> The problem here is the overflow of an unsigned 32-bit number to a
> negative that gets converted into a signed 'long', keeping a large
> positive number.
> 
> Replace the complex calculation with a more readable min() variant
> that avoids the warning.
> 
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")

That is old :)

> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Looks good to me. I can take the patch through libata tree, unless you prefer
taking the whole series ?

In case it is the latter:

Acked-by: Damien Le Moal <dlemoal@kernel.org>

-- 
Damien Le Moal
Western Digital Research


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

* Re: [PATCH 10/12] sata: sx4: fix pdc20621_get_from_dimm() on 64-bit
  2024-03-27  1:36   ` Damien Le Moal
@ 2024-03-27 20:21     ` Arnd Bergmann
  2024-03-28  0:14       ` Damien Le Moal
  0 siblings, 1 reply; 5+ messages in thread
From: Arnd Bergmann @ 2024-03-27 20:21 UTC (permalink / raw)
  To: Damien Le Moal, Arnd Bergmann, linux-kbuild, Masahiro Yamada,
	Niklas Cassel
  Cc: Nicolas Schier, Nathan Chancellor, John Garry, Martin K. Petersen,
	linux-ide, linux-kernel

On Wed, Mar 27, 2024, at 02:36, Damien Le Moal wrote:
> On 3/26/24 23:53, Arnd Bergmann wrote:
>
>> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>
> Looks good to me. I can take the patch through libata tree, unless you prefer
> taking the whole series ?

Please merge it through your tree.

> In case it is the latter:
>
> Acked-by: Damien Le Moal <dlemoal@kernel.org>
>

Thanks,

    Arnd

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

* Re: [PATCH 10/12] sata: sx4: fix pdc20621_get_from_dimm() on 64-bit
  2024-03-27 20:21     ` Arnd Bergmann
@ 2024-03-28  0:14       ` Damien Le Moal
  0 siblings, 0 replies; 5+ messages in thread
From: Damien Le Moal @ 2024-03-28  0:14 UTC (permalink / raw)
  To: Arnd Bergmann, Arnd Bergmann, linux-kbuild, Masahiro Yamada,
	Niklas Cassel
  Cc: Nicolas Schier, Nathan Chancellor, John Garry, Martin K. Petersen,
	linux-ide, linux-kernel

On 3/28/24 05:21, Arnd Bergmann wrote:
> On Wed, Mar 27, 2024, at 02:36, Damien Le Moal wrote:
>> On 3/26/24 23:53, Arnd Bergmann wrote:
>>
>>> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>>
>> Looks good to me. I can take the patch through libata tree, unless you prefer
>> taking the whole series ?
> 
> Please merge it through your tree.

Applied to for-6.9-fixes with a fixed up patch title prefix ("ata: sata_sx4:
..."). Thanks !

> 
>> In case it is the latter:
>>
>> Acked-by: Damien Le Moal <dlemoal@kernel.org>
>>
> 
> Thanks,
> 
>     Arnd

-- 
Damien Le Moal
Western Digital Research


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

end of thread, other threads:[~2024-03-28  0:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-26 14:47 [PATCH 00/12] kbuild: enable some -Wextra warnings by default Arnd Bergmann
2024-03-26 14:53 ` [PATCH 10/12] sata: sx4: fix pdc20621_get_from_dimm() on 64-bit Arnd Bergmann
2024-03-27  1:36   ` Damien Le Moal
2024-03-27 20:21     ` Arnd Bergmann
2024-03-28  0:14       ` Damien Le Moal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox