linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] arm64: mm: support setting page attributes for debug situation
@ 2020-01-10  7:47 yeyunfeng
  2020-01-16 11:09 ` Will Deacon
  0 siblings, 1 reply; 3+ messages in thread
From: yeyunfeng @ 2020-01-10  7:47 UTC (permalink / raw)
  To: catalin.marinas, will, anshuman.khandual, akpm, willy, yeyunfeng,
	ard.biesheuvel, tglx, linux-arm-kernel, linux-kernel
  Cc: hushiyuan, linfeilong

When rodata_full is set or pagealloc debug is enabled, block mappings or
contiguou hints are no longer used for linear address area. Therefore,
support setting page attributes in this case is useful for debugging
memory corruption problems.

Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com>
---
 arch/arm64/mm/pageattr.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/arch/arm64/mm/pageattr.c b/arch/arm64/mm/pageattr.c
index 9ce7bd9d4d9c..823143534a93 100644
--- a/arch/arm64/mm/pageattr.c
+++ b/arch/arm64/mm/pageattr.c
@@ -65,6 +65,9 @@ static int change_memory_common(unsigned long addr, int numpages,
 		WARN_ON_ONCE(1);
 	}

+	if (!numpages)
+		return 0;
+
 	/*
 	 * Kernel VA mappings are always live, and splitting live section
 	 * mappings into page mappings may cause TLB conflicts. This means
@@ -81,11 +84,18 @@ static int change_memory_common(unsigned long addr, int numpages,
 	area = find_vm_area((void *)addr);
 	if (!area ||
 	    end > (unsigned long)area->addr + area->size ||
-	    !(area->flags & VM_ALLOC))
+	    !(area->flags & VM_ALLOC)) {
+
+		/*
+		 * When rodata_full is set, or pagealloc debug is enabled,
+		 * the linear address is mapped with NO_BLOCK_MAPPINGS or
+		 * NO_CONT_MAPPINGS flags, so splitting is never needed.
+		 */
+		if (rodata_full || debug_pagealloc_enabled())
+			return __change_memory_common(start, size, set_mask,
+							clear_mask);
 		return -EINVAL;
-
-	if (!numpages)
-		return 0;
+	}

 	/*
 	 * If we are manipulating read-only permissions, apply the same
-- 
2.7.4


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

* Re: [PATCH] arm64: mm: support setting page attributes for debug situation
  2020-01-10  7:47 [PATCH] arm64: mm: support setting page attributes for debug situation yeyunfeng
@ 2020-01-16 11:09 ` Will Deacon
  2020-01-22  3:46   ` Yunfeng Ye
  0 siblings, 1 reply; 3+ messages in thread
From: Will Deacon @ 2020-01-16 11:09 UTC (permalink / raw)
  To: yeyunfeng
  Cc: catalin.marinas, anshuman.khandual, akpm, willy, ard.biesheuvel,
	tglx, linux-arm-kernel, linux-kernel, hushiyuan, linfeilong

On Fri, Jan 10, 2020 at 03:47:41PM +0800, yeyunfeng wrote:
> When rodata_full is set or pagealloc debug is enabled, block mappings or
> contiguou hints are no longer used for linear address area. Therefore,
> support setting page attributes in this case is useful for debugging
> memory corruption problems.
> 
> Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com>
> ---
>  arch/arm64/mm/pageattr.c | 18 ++++++++++++++----
>  1 file changed, 14 insertions(+), 4 deletions(-)

Although I can kind of see what you're getting at, I'm not keen on merging
this without a user. If you're just referring to random debug hacks, then I
think this change could be part of those too.

Will

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

* Re: [PATCH] arm64: mm: support setting page attributes for debug situation
  2020-01-16 11:09 ` Will Deacon
@ 2020-01-22  3:46   ` Yunfeng Ye
  0 siblings, 0 replies; 3+ messages in thread
From: Yunfeng Ye @ 2020-01-22  3:46 UTC (permalink / raw)
  To: Will Deacon
  Cc: catalin.marinas, anshuman.khandual, akpm, willy, ard.biesheuvel,
	tglx, linux-arm-kernel, linux-kernel, hushiyuan, linfeilong



On 2020/1/16 19:09, Will Deacon wrote:
> On Fri, Jan 10, 2020 at 03:47:41PM +0800, yeyunfeng wrote:
>> When rodata_full is set or pagealloc debug is enabled, block mappings or
>> contiguou hints are no longer used for linear address area. Therefore,
>> support setting page attributes in this case is useful for debugging
>> memory corruption problems.
>>
>> Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com>
>> ---
>>  arch/arm64/mm/pageattr.c | 18 ++++++++++++++----
>>  1 file changed, 14 insertions(+), 4 deletions(-)
> 
> Although I can kind of see what you're getting at, I'm not keen on merging
> this without a user. If you're just referring to random debug hacks, then I
> think this change could be part of those too.
> 
Ok, thanks, I think when pagealloc debug is enabled, it is better not limited
to the vmap area only. and when kernel memory corruption problems happen, it's
useful to call set_memory_ro() function to debug these problem.

> Will
> 
> .
> 


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

end of thread, other threads:[~2020-01-22  3:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-10  7:47 [PATCH] arm64: mm: support setting page attributes for debug situation yeyunfeng
2020-01-16 11:09 ` Will Deacon
2020-01-22  3:46   ` Yunfeng Ye

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