stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Hongchen Zhang <zhanghongchen@loongson.cn>,
	Huacai Chen <chenhuacai@loongson.cn>,
	Sasha Levin <sashal@kernel.org>,
	chenhuacai@kernel.org, akpm@linux-foundation.org,
	david@redhat.com, anshuman.khandual@arm.com, rppt@kernel.org,
	chenfeiyang@loongson.cn, zhengqi.arch@bytedance.com,
	wangkefeng.wang@huawei.com, loongarch@lists.linux.dev
Subject: [PATCH AUTOSEL 6.1 13/15] LoongArch: Let pmd_present() return true when splitting pmd
Date: Mon, 26 Jun 2023 17:50:29 -0400	[thread overview]
Message-ID: <20230626215031.179159-13-sashal@kernel.org> (raw)
In-Reply-To: <20230626215031.179159-1-sashal@kernel.org>

From: Hongchen Zhang <zhanghongchen@loongson.cn>

[ Upstream commit ddc1729b07cc84bb29f577698b8d2e74a4004a6e ]

When we split a pmd into ptes, pmd_present() and pmd_trans_huge() should
return true, otherwise it would be treated as a swap pmd.

This is the same as arm64 does in commit b65399f6111b ("arm64/mm: Change
THP helpers to comply with generic MM semantics"), we also add a new bit
named _PAGE_PRESENT_INVALID for LoongArch.

Signed-off-by: Hongchen Zhang <zhanghongchen@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/loongarch/include/asm/pgtable-bits.h | 2 ++
 arch/loongarch/include/asm/pgtable.h      | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/loongarch/include/asm/pgtable-bits.h b/arch/loongarch/include/asm/pgtable-bits.h
index 3d1e0a69975a5..5f2ebcea509cd 100644
--- a/arch/loongarch/include/asm/pgtable-bits.h
+++ b/arch/loongarch/include/asm/pgtable-bits.h
@@ -21,12 +21,14 @@
 #define	_PAGE_HGLOBAL_SHIFT	12 /* HGlobal is a PMD bit */
 #define	_PAGE_PFN_SHIFT		12
 #define	_PAGE_PFN_END_SHIFT	48
+#define	_PAGE_PRESENT_INVALID_SHIFT 60
 #define	_PAGE_NO_READ_SHIFT	61
 #define	_PAGE_NO_EXEC_SHIFT	62
 #define	_PAGE_RPLV_SHIFT	63
 
 /* Used by software */
 #define _PAGE_PRESENT		(_ULCAST_(1) << _PAGE_PRESENT_SHIFT)
+#define _PAGE_PRESENT_INVALID	(_ULCAST_(1) << _PAGE_PRESENT_INVALID_SHIFT)
 #define _PAGE_WRITE		(_ULCAST_(1) << _PAGE_WRITE_SHIFT)
 #define _PAGE_ACCESSED		(_ULCAST_(1) << _PAGE_ACCESSED_SHIFT)
 #define _PAGE_MODIFIED		(_ULCAST_(1) << _PAGE_MODIFIED_SHIFT)
diff --git a/arch/loongarch/include/asm/pgtable.h b/arch/loongarch/include/asm/pgtable.h
index 79d5bfd913e0f..e748fad82f13e 100644
--- a/arch/loongarch/include/asm/pgtable.h
+++ b/arch/loongarch/include/asm/pgtable.h
@@ -208,7 +208,7 @@ static inline int pmd_bad(pmd_t pmd)
 static inline int pmd_present(pmd_t pmd)
 {
 	if (unlikely(pmd_val(pmd) & _PAGE_HUGE))
-		return !!(pmd_val(pmd) & (_PAGE_PRESENT | _PAGE_PROTNONE));
+		return !!(pmd_val(pmd) & (_PAGE_PRESENT | _PAGE_PROTNONE | _PAGE_PRESENT_INVALID));
 
 	return pmd_val(pmd) != (unsigned long)invalid_pte_table;
 }
@@ -525,6 +525,7 @@ static inline pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot)
 
 static inline pmd_t pmd_mkinvalid(pmd_t pmd)
 {
+	pmd_val(pmd) |= _PAGE_PRESENT_INVALID;
 	pmd_val(pmd) &= ~(_PAGE_PRESENT | _PAGE_VALID | _PAGE_DIRTY | _PAGE_PROTNONE);
 
 	return pmd;
-- 
2.39.2


  parent reply	other threads:[~2023-06-26 21:55 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-26 21:50 [PATCH AUTOSEL 6.1 01/15] wifi: cfg80211: remove links only on AP Sasha Levin
2023-06-26 21:50 ` [PATCH AUTOSEL 6.1 02/15] wifi: mac80211: Use active_links instead of valid_links in Tx Sasha Levin
2023-06-26 21:50 ` [PATCH AUTOSEL 6.1 03/15] netlabel: fix shift wrapping bug in netlbl_catmap_setlong() Sasha Levin
2023-06-26 21:50 ` [PATCH AUTOSEL 6.1 04/15] bnx2x: fix page fault following EEH recovery Sasha Levin
2023-06-26 21:50 ` [PATCH AUTOSEL 6.1 05/15] smb/client: print "Unknown" instead of bogus link speed value Sasha Levin
2023-06-26 21:50 ` [PATCH AUTOSEL 6.1 06/15] cifs: fix sockaddr comparison in iface_cmp Sasha Levin
2023-07-11 20:49   ` Pavel Machek
2023-06-26 21:50 ` [PATCH AUTOSEL 6.1 07/15] cifs: fix max_credits implementation Sasha Levin
2023-06-26 21:50 ` [PATCH AUTOSEL 6.1 08/15] sctp: handle invalid error codes without calling BUG() Sasha Levin
2023-06-26 21:50 ` [PATCH AUTOSEL 6.1 09/15] cifs: add a warning when the in-flight count goes negative Sasha Levin
2023-06-26 21:50 ` [PATCH AUTOSEL 6.1 10/15] scsi: aacraid: Reply queue mapping to CPUs based on IRQ affinity Sasha Levin
2023-06-26 21:50 ` [PATCH AUTOSEL 6.1 11/15] scsi: storvsc: Always set no_report_opcodes Sasha Levin
2023-06-26 21:50 ` [PATCH AUTOSEL 6.1 12/15] scsi: lpfc: Fix incorrect big endian type assignment in bsg loopback path Sasha Levin
2023-06-26 21:50 ` Sasha Levin [this message]
2023-06-26 21:50 ` [PATCH AUTOSEL 6.1 14/15] LoongArch: Fix the write_fcsr() macro Sasha Levin
2023-06-26 21:50 ` [PATCH AUTOSEL 6.1 15/15] ALSA: seq: oss: Fix racy open/close of MIDI devices Sasha Levin
  -- strict thread matches above, loose matches on Subject: below --
2023-08-29 13:32 [PATCH AUTOSEL 6.1 01/15] wifi: cfg80211: remove links only on AP Sasha Levin
2023-08-29 13:32 ` [PATCH AUTOSEL 6.1 13/15] LoongArch: Let pmd_present() return true when splitting pmd Sasha Levin

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=20230626215031.179159-13-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=anshuman.khandual@arm.com \
    --cc=chenfeiyang@loongson.cn \
    --cc=chenhuacai@kernel.org \
    --cc=chenhuacai@loongson.cn \
    --cc=david@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=loongarch@lists.linux.dev \
    --cc=rppt@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=wangkefeng.wang@huawei.com \
    --cc=zhanghongchen@loongson.cn \
    --cc=zhengqi.arch@bytedance.com \
    /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 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).