* [PATCH AUTOSEL 6.3 13/16] LoongArch: Let pmd_present() return true when splitting pmd
[not found] <20230626214956.178942-1-sashal@kernel.org>
@ 2023-06-26 21:49 ` Sasha Levin
2023-06-26 21:49 ` [PATCH AUTOSEL 6.3 14/16] LoongArch: Fix the write_fcsr() macro Sasha Levin
2023-06-26 21:49 ` [PATCH AUTOSEL 6.3 15/16] LoongArch: Avoid uninitialized alignment_mask Sasha Levin
2 siblings, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2023-06-26 21:49 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Hongchen Zhang, Huacai Chen, Sasha Levin, chenhuacai, akpm,
anshuman.khandual, david, rppt, arnd, chenfeiyang,
wangkefeng.wang, loongarch
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 8b98d22a145b1..de46a6b1e9f11 100644
--- a/arch/loongarch/include/asm/pgtable-bits.h
+++ b/arch/loongarch/include/asm/pgtable-bits.h
@@ -22,12 +22,14 @@
#define _PAGE_PFN_SHIFT 12
#define _PAGE_SWP_EXCLUSIVE_SHIFT 23
#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 d28fb9dbec596..9a9f9ff9b7098 100644
--- a/arch/loongarch/include/asm/pgtable.h
+++ b/arch/loongarch/include/asm/pgtable.h
@@ -213,7 +213,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;
}
@@ -558,6 +558,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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH AUTOSEL 6.3 14/16] LoongArch: Fix the write_fcsr() macro
[not found] <20230626214956.178942-1-sashal@kernel.org>
2023-06-26 21:49 ` [PATCH AUTOSEL 6.3 13/16] LoongArch: Let pmd_present() return true when splitting pmd Sasha Levin
@ 2023-06-26 21:49 ` Sasha Levin
2023-06-26 21:49 ` [PATCH AUTOSEL 6.3 15/16] LoongArch: Avoid uninitialized alignment_mask Sasha Levin
2 siblings, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2023-06-26 21:49 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Qi Hu, Miao HAO, Huacai Chen, Sasha Levin, chenhuacai, git,
zhangqing, lienze, loongarch
From: Qi Hu <huqi@loongson.cn>
[ Upstream commit 346dc929623cef70ff7832a4fa0ffd1b696e312a ]
The "write_fcsr()" macro uses wrong the positions for val and dest in
asm. Fix it!
Reported-by: Miao HAO <haomiao19@mails.ucas.ac.cn>
Signed-off-by: Qi Hu <huqi@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/loongarch/include/asm/loongarch.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/loongarch/include/asm/loongarch.h b/arch/loongarch/include/asm/loongarch.h
index 83da5d29e2d17..f0d32112dafd9 100644
--- a/arch/loongarch/include/asm/loongarch.h
+++ b/arch/loongarch/include/asm/loongarch.h
@@ -1491,7 +1491,7 @@ __BUILD_CSR_OP(tlbidx)
#define write_fcsr(dest, val) \
do { \
__asm__ __volatile__( \
- " movgr2fcsr %0, "__stringify(dest)" \n" \
+ " movgr2fcsr "__stringify(dest)", %0 \n" \
: : "r" (val)); \
} while (0)
--
2.39.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH AUTOSEL 6.3 15/16] LoongArch: Avoid uninitialized alignment_mask
[not found] <20230626214956.178942-1-sashal@kernel.org>
2023-06-26 21:49 ` [PATCH AUTOSEL 6.3 13/16] LoongArch: Let pmd_present() return true when splitting pmd Sasha Levin
2023-06-26 21:49 ` [PATCH AUTOSEL 6.3 14/16] LoongArch: Fix the write_fcsr() macro Sasha Levin
@ 2023-06-26 21:49 ` Sasha Levin
2 siblings, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2023-06-26 21:49 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Qing Zhang, Colin King, Huacai Chen, Sasha Levin, chenhuacai,
loongarch
From: Qing Zhang <zhangqing@loongson.cn>
[ Upstream commit 0246d0aaf0a634a65135050011767b56ba351a8f ]
The hardware monitoring points for instruction fetching and load/store
operations need to align 4 bytes and 1/2/4/8 bytes respectively.
Reported-by: Colin King <colin.i.king@gmail.com>
Signed-off-by: Qing Zhang <zhangqing@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/loongarch/kernel/hw_breakpoint.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/loongarch/kernel/hw_breakpoint.c b/arch/loongarch/kernel/hw_breakpoint.c
index 2406c95b34cc4..021b59c248fac 100644
--- a/arch/loongarch/kernel/hw_breakpoint.c
+++ b/arch/loongarch/kernel/hw_breakpoint.c
@@ -396,6 +396,8 @@ int hw_breakpoint_arch_parse(struct perf_event *bp,
if (hw->ctrl.type != LOONGARCH_BREAKPOINT_EXECUTE)
alignment_mask = 0x7;
+ else
+ alignment_mask = 0x3;
offset = hw->address & alignment_mask;
hw->address &= ~alignment_mask;
--
2.39.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-06-26 21:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20230626214956.178942-1-sashal@kernel.org>
2023-06-26 21:49 ` [PATCH AUTOSEL 6.3 13/16] LoongArch: Let pmd_present() return true when splitting pmd Sasha Levin
2023-06-26 21:49 ` [PATCH AUTOSEL 6.3 14/16] LoongArch: Fix the write_fcsr() macro Sasha Levin
2023-06-26 21:49 ` [PATCH AUTOSEL 6.3 15/16] LoongArch: Avoid uninitialized alignment_mask Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox