mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] checkpatch: Ignore attribute macros ending with nGnRnE or nGnRE
@ 2026-03-07  7:27 Liu Dalin
  2026-03-07 19:53 ` Joe Perches
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Liu Dalin @ 2026-03-07  7:27 UTC (permalink / raw)
  To: Andy Whitcroft, Joe Perches, Dwaipayan Ray, Lukas Bulwahn; +Cc: linux-kernel

On arm and arm64 platforms, there are several attribute macros that
end with nGnRnE or nGnRE, such as PROT_DEVICE_nGnRnE, PROT_DEVICE_nGnRE,
MT_DEVICE_nGnRnE, and MT_DEVICE_nGnRE.

Signed-off-by: Liu Dalin <liudalin@kylinsec.com.cn>
---
 scripts/checkpatch.pl | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index e56374662ff7..f5b5d72cb069 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -5896,7 +5896,10 @@ sub process {
 #(ie: max_uV, regulator_min_uA_show, RANGE_mA_VALUE)
 			    $var !~ /^(?:[a-z0-9_]*|[A-Z0-9_]*)?_?[a-z][A-Z](?:_[a-z0-9_]+|_[A-Z0-9_]+)?$/ &&
 #Ignore some three character SI units explicitly, like MiB and KHz
-			    $var !~ /^(?:[a-z_]*?)_?(?:[KMGT]iB|[KMGT]?Hz)(?:_[a-z_]+)?$/) {
+			    $var !~ /^(?:[a-z_]*?)_?(?:[KMGT]iB|[KMGT]?Hz)(?:_[a-z_]+)?$/ &&
+#Ignore macros end with nGnRnE or nGnRE
+#(ie: PROT_DEVICE_<foo>, MT_DEVICE_<foo> MT_S2_DEVICE_<foo> ...)
+			    $var !~ /^[A-Z0-9_]+_(nGnRnE|nGnRE)$/) {
 				while ($var =~ m{\b($Ident)}g) {
 					my $word = $1;
 					next if ($word !~ /[A-Z][a-z]|[a-z][A-Z]/);
-- 
2.43.0


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

* Re: [PATCH] checkpatch: Ignore attribute macros ending with nGnRnE or nGnRE
  2026-03-07  7:27 [PATCH] checkpatch: Ignore attribute macros ending with nGnRnE or nGnRE Liu Dalin
@ 2026-03-07 19:53 ` Joe Perches
  2026-03-09  2:12   ` Liu Dalin
  2026-03-09  2:45 ` [PATCH 0/1] checkpatch: ignore memory attribute macros ending with nGnRnE, nGnRE, or nGRE Liu Dalin
       [not found] ` <20260309024545.122002-1-liudalin@kylinsec.com.cn>
  2 siblings, 1 reply; 7+ messages in thread
From: Joe Perches @ 2026-03-07 19:53 UTC (permalink / raw)
  To: Liu Dalin, Andy Whitcroft, Dwaipayan Ray, Lukas Bulwahn; +Cc: linux-kernel

On Sat, 2026-03-07 at 15:27 +0800, Liu Dalin wrote:
> On arm and arm64 platforms, there are several attribute macros that
> end with nGnRnE or nGnRE, such as PROT_DEVICE_nGnRnE, PROT_DEVICE_nGnRE,
> MT_DEVICE_nGnRnE, and MT_DEVICE_nGnRE.

+			    $var !~ /^[A-Z0-9_]+_(nGnRnE|nGnRE)$/) {

Maybe better if you add nGRE too and no capture group using (?:...)$

FYI: These appear unused to date:

$ git grep FFA_DEV
include/linux/arm_ffa.h:#define FFA_DEV_nGnRnE          (0 << 2)
include/linux/arm_ffa.h:#define FFA_DEV_nGnRE           (1 << 2)
include/linux/arm_ffa.h:#define FFA_DEV_nGRE            (2 << 2)
include/linux/arm_ffa.h:#define FFA_DEV_GRE             (3 << 2)

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

* Re: [PATCH] checkpatch: Ignore attribute macros ending with nGnRnE or nGnRE
  2026-03-07 19:53 ` Joe Perches
@ 2026-03-09  2:12   ` Liu Dalin
  2026-03-09  2:47     ` Joe Perches
  0 siblings, 1 reply; 7+ messages in thread
From: Liu Dalin @ 2026-03-09  2:12 UTC (permalink / raw)
  To: Joe Perches, Andy Whitcroft, Dwaipayan Ray, Lukas Bulwahn; +Cc: linux-kernel

Thanks for the review!

在 2026/3/8 3:53, Joe Perches 写道:
> On Sat, 2026-03-07 at 15:27 +0800, Liu Dalin wrote:
>> On arm and arm64 platforms, there are several attribute macros that
>> end with nGnRnE or nGnRE, such as PROT_DEVICE_nGnRnE, PROT_DEVICE_nGnRE,
>> MT_DEVICE_nGnRnE, and MT_DEVICE_nGnRE.
> +			    $var !~ /^[A-Z0-9_]+_(nGnRnE|nGnRE)$/) {
>
> Maybe better if you add nGRE too and no capture group using (?:...)$

OK!  This is a good suggestion.

I will add it in patch v2.

> FYI: These appear unused to date:

On other ARM platforms, these memory attribute macros are used in arch, 
drivers, or KVM.

likes:

$ git grep PROT_DEVICE_nGnRnE
arch/arm64/include/asm/io.h:#define pci_remap_cfgspace(addr, size) 
__ioremap((addr), (size), __pgprot(PROT_DEVICE_nGnRnE))
arch/arm64/include/asm/pgtable-prot.h:#define PROT_DEVICE_nGnRnE       
(PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_WRITE | 
PTE_ATTRINDX(MT_DEVICE_nGnRnE))
arch/arm64/kernel/acpi.c:       return __pgprot(PROT_DEVICE_nGnRnE);
drivers/net/ethernet/huawei/hinic/hinic_lld.c:                     
__pgprot(PROT_DEVICE_nGnRnE));
drivers/net/ethernet/phytium/phytmac.h:#define phytmac_ioremap_np(addr, 
size)   __ioremap((addr), (size), __pgprot(PROT_DEVICE_nGnRnE))
drivers/scsi/huawei/hifc/hifc_lld.c:             
__pgprot(PROT_DEVICE_nGnRnE));

> $ git grep FFA_DEV
> include/linux/arm_ffa.h:#define FFA_DEV_nGnRnE          (0 << 2)
> include/linux/arm_ffa.h:#define FFA_DEV_nGnRE           (1 << 2)
> include/linux/arm_ffa.h:#define FFA_DEV_nGRE            (2 << 2)
> include/linux/arm_ffa.h:#define FFA_DEV_GRE             (3 << 2)
>

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

* [PATCH 0/1] checkpatch: ignore memory attribute macros ending with nGnRnE, nGnRE, or nGRE
  2026-03-07  7:27 [PATCH] checkpatch: Ignore attribute macros ending with nGnRnE or nGnRE Liu Dalin
  2026-03-07 19:53 ` Joe Perches
@ 2026-03-09  2:45 ` Liu Dalin
       [not found] ` <20260309024545.122002-1-liudalin@kylinsec.com.cn>
  2 siblings, 0 replies; 7+ messages in thread
From: Liu Dalin @ 2026-03-09  2:45 UTC (permalink / raw)
  To: Andy Whitcroft, Joe Perches, Dwaipayan Ray, Lukas Bulwahn
  Cc: linux-kernel, liudalin

Changes in v2:
- add nGRE and using (?:...)$
- update commit tile and info

Liu Dalin (1):
  checkpatch: ignore memory attribute macros ending with nGnRnE, nGnRE,
    or nGRE

 scripts/checkpatch.pl | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

-- 
2.43.0


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

* [PATCH 1/1] checkpatch: ignore memory attribute macros ending with nGnRnE, nGnRE, or nGRE
       [not found] ` <20260309024545.122002-1-liudalin@kylinsec.com.cn>
@ 2026-03-09  2:45   ` Liu Dalin
  0 siblings, 0 replies; 7+ messages in thread
From: Liu Dalin @ 2026-03-09  2:45 UTC (permalink / raw)
  To: Andy Whitcroft, Joe Perches, Dwaipayan Ray, Lukas Bulwahn
  Cc: linux-kernel, liudalin

On arm and arm64 platforms, there exist several memory attribute macros
that end with nGnRnE, nGnRE, or nGRE. Examples include:
- PROT_DEVICE_nGnRnE, PROT_DEVICE_nGnRE
- FFA_DEV_nGnRnE, FFA_DEV_nGnRE, FFA_DEV_nGRE

Signed-off-by: Liu Dalin <liudalin@kylinsec.com.cn>
---
 scripts/checkpatch.pl | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index e56374662ff7..2ea7b130e913 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -5896,7 +5896,10 @@ sub process {
 #(ie: max_uV, regulator_min_uA_show, RANGE_mA_VALUE)
 			    $var !~ /^(?:[a-z0-9_]*|[A-Z0-9_]*)?_?[a-z][A-Z](?:_[a-z0-9_]+|_[A-Z0-9_]+)?$/ &&
 #Ignore some three character SI units explicitly, like MiB and KHz
-			    $var !~ /^(?:[a-z_]*?)_?(?:[KMGT]iB|[KMGT]?Hz)(?:_[a-z_]+)?$/) {
+			    $var !~ /^(?:[a-z_]*?)_?(?:[KMGT]iB|[KMGT]?Hz)(?:_[a-z_]+)?$/ &&
+#Ignore memory attribute macros that end with nGnRnE, nGnRE, or nGRE
+#(ie: PROT_DEVICE_<foo>, FFA_DEV_<foo> MT_S2_DEVICE_<foo> ...)
+			    $var !~/^[A-Z0-9_]+_(?:nGnRnE|nGnRE|nGRE)$/) {
 				while ($var =~ m{\b($Ident)}g) {
 					my $word = $1;
 					next if ($word !~ /[A-Z][a-z]|[a-z][A-Z]/);
-- 
2.43.0


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

* Re: [PATCH] checkpatch: Ignore attribute macros ending with nGnRnE or nGnRE
  2026-03-09  2:12   ` Liu Dalin
@ 2026-03-09  2:47     ` Joe Perches
  2026-03-09  3:02       ` Liu Dalin
  0 siblings, 1 reply; 7+ messages in thread
From: Joe Perches @ 2026-03-09  2:47 UTC (permalink / raw)
  To: Liu Dalin, Andy Whitcroft, Dwaipayan Ray, Lukas Bulwahn; +Cc: linux-kernel

On Mon, 2026-03-09 at 10:12 +0800, Liu Dalin wrote:
> 在 2026/3/8 3:53, Joe Perches 写道:

> > FYI: These appear unused to date:

[]

I was referring to these #define FFA_DEV_<foo> below:

> > $ git grep FFA_DEV
> > include/linux/arm_ffa.h:#define FFA_DEV_nGnRnE          (0 << 2)
> > include/linux/arm_ffa.h:#define FFA_DEV_nGnRE           (1 << 2)
> > include/linux/arm_ffa.h:#define FFA_DEV_nGRE            (2 << 2)
> > include/linux/arm_ffa.h:#define FFA_DEV_GRE             (3 << 2)

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

* Re: [PATCH] checkpatch: Ignore attribute macros ending with nGnRnE or nGnRE
  2026-03-09  2:47     ` Joe Perches
@ 2026-03-09  3:02       ` Liu Dalin
  0 siblings, 0 replies; 7+ messages in thread
From: Liu Dalin @ 2026-03-09  3:02 UTC (permalink / raw)
  To: Joe Perches, Andy Whitcroft, Dwaipayan Ray, Lukas Bulwahn; +Cc: linux-kernel


在 2026/3/9 10:47, Joe Perches 写道:
> On Mon, 2026-03-09 at 10:12 +0800, Liu Dalin wrote:
>> 在 2026/3/8 3:53, Joe Perches 写道:
>>> FYI: These appear unused to date:
> []
>
> I was referring to these #define FFA_DEV_<foo> below:
Yes.
It looks like the memory attribute macros starting with FFA_DEV_are 
intended for use in ARM Trusted Firmware​ and Hypervisors, and are 
rarely seen in the kernel​ itself.
Maybe some TEE drivers will use these attributes.
>>> $ git grep FFA_DEV
>>> include/linux/arm_ffa.h:#define FFA_DEV_nGnRnE          (0 << 2)
>>> include/linux/arm_ffa.h:#define FFA_DEV_nGnRE           (1 << 2)
>>> include/linux/arm_ffa.h:#define FFA_DEV_nGRE            (2 << 2)
>>> include/linux/arm_ffa.h:#define FFA_DEV_GRE             (3 << 2)

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

end of thread, other threads:[~2026-03-09  3:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-07  7:27 [PATCH] checkpatch: Ignore attribute macros ending with nGnRnE or nGnRE Liu Dalin
2026-03-07 19:53 ` Joe Perches
2026-03-09  2:12   ` Liu Dalin
2026-03-09  2:47     ` Joe Perches
2026-03-09  3:02       ` Liu Dalin
2026-03-09  2:45 ` [PATCH 0/1] checkpatch: ignore memory attribute macros ending with nGnRnE, nGnRE, or nGRE Liu Dalin
     [not found] ` <20260309024545.122002-1-liudalin@kylinsec.com.cn>
2026-03-09  2:45   ` [PATCH 1/1] " Liu Dalin

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®