All of lore.kernel.org
 help / color / mirror / Atom feed
From: yeyunfeng <yeyunfeng@huawei.com>
To: <catalin.marinas@arm.com>, <will@kernel.org>,
	<anshuman.khandual@arm.com>, <akpm@linux-foundation.org>,
	<willy@infradead.org>, <yeyunfeng@huawei.com>,
	<ard.biesheuvel@arm.com>, <tglx@linutronix.de>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>
Cc: <hushiyuan@huawei.com>, <linfeilong@huawei.com>
Subject: [PATCH] arm64: mm: support setting page attributes for debug situation
Date: Fri, 10 Jan 2020 15:47:41 +0800	[thread overview]
Message-ID: <5a3ab728-b895-0930-9540-5e9c586e8858@huawei.com> (raw)

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


WARNING: multiple messages have this Message-ID (diff)
From: yeyunfeng <yeyunfeng@huawei.com>
To: <catalin.marinas@arm.com>, <will@kernel.org>,
	<anshuman.khandual@arm.com>,  <akpm@linux-foundation.org>,
	<willy@infradead.org>, <yeyunfeng@huawei.com>,
	<ard.biesheuvel@arm.com>, <tglx@linutronix.de>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>
Cc: hushiyuan@huawei.com, linfeilong@huawei.com
Subject: [PATCH] arm64: mm: support setting page attributes for debug situation
Date: Fri, 10 Jan 2020 15:47:41 +0800	[thread overview]
Message-ID: <5a3ab728-b895-0930-9540-5e9c586e8858@huawei.com> (raw)

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


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

             reply	other threads:[~2020-01-10  7:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-10  7:47 yeyunfeng [this message]
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-16 11:09   ` Will Deacon
2020-01-22  3:46   ` Yunfeng Ye
2020-01-22  3:46     ` Yunfeng Ye

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=5a3ab728-b895-0930-9540-5e9c586e8858@huawei.com \
    --to=yeyunfeng@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=anshuman.khandual@arm.com \
    --cc=ard.biesheuvel@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=hushiyuan@huawei.com \
    --cc=linfeilong@huawei.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=will@kernel.org \
    --cc=willy@infradead.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.