public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Huacai Chen <chenhuacai@loongson.cn>, Guo Ren <guoren@kernel.org>,
	Sasha Levin <sashal@kernel.org>,
	chenhuacai@kernel.org, akpm@linux-foundation.org,
	rppt@kernel.org, jiaxun.yang@flygoat.com, git@xen0n.name,
	loongarch@lists.linux.dev
Subject: [PATCH AUTOSEL 6.0 25/39] LoongArch: Set _PAGE_DIRTY only if _PAGE_MODIFIED is set in {pmd,pte}_mkwrite()
Date: Mon, 28 Nov 2022 12:36:05 -0500	[thread overview]
Message-ID: <20221128173642.1441232-25-sashal@kernel.org> (raw)
In-Reply-To: <20221128173642.1441232-1-sashal@kernel.org>

From: Huacai Chen <chenhuacai@loongson.cn>

[ Upstream commit 54e6cd42a183b602e3627ad3aaeeed44f7443e67 ]

Set _PAGE_DIRTY only if _PAGE_MODIFIED is set in {pmd,pte}_mkwrite().
Otherwise, _PAGE_DIRTY silences the TLB modify exception and make us
have no chance to mark a pmd/pte dirty (_PAGE_MODIFIED) for software.

Reviewed-by: Guo Ren <guoren@kernel.org>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/loongarch/include/asm/pgtable.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/loongarch/include/asm/pgtable.h b/arch/loongarch/include/asm/pgtable.h
index 8ea57e2f0e04..79981ee8a171 100644
--- a/arch/loongarch/include/asm/pgtable.h
+++ b/arch/loongarch/include/asm/pgtable.h
@@ -355,7 +355,9 @@ static inline pte_t pte_mkdirty(pte_t pte)
 
 static inline pte_t pte_mkwrite(pte_t pte)
 {
-	pte_val(pte) |= (_PAGE_WRITE | _PAGE_DIRTY);
+	pte_val(pte) |= _PAGE_WRITE;
+	if (pte_val(pte) & _PAGE_MODIFIED)
+		pte_val(pte) |= _PAGE_DIRTY;
 	return pte;
 }
 
@@ -452,7 +454,9 @@ static inline int pmd_write(pmd_t pmd)
 
 static inline pmd_t pmd_mkwrite(pmd_t pmd)
 {
-	pmd_val(pmd) |= (_PAGE_WRITE | _PAGE_DIRTY);
+	pmd_val(pmd) |= _PAGE_WRITE;
+	if (pmd_val(pmd) & _PAGE_MODIFIED)
+		pmd_val(pmd) |= _PAGE_DIRTY;
 	return pmd;
 }
 
-- 
2.35.1


  parent reply	other threads:[~2022-11-28 17:40 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-28 17:35 [PATCH AUTOSEL 6.0 01/39] arm64: dts: rockchip: Fix gmac failure of rgmii-id from rk3566-roc-pc Sasha Levin
2022-11-28 17:35 ` [PATCH AUTOSEL 6.0 02/39] arm64: dts: rockchip: Fix i2c3 pinctrl on rk3566-roc-pc Sasha Levin
2022-11-28 17:35 ` [PATCH AUTOSEL 6.0 03/39] arm64: dts: rockchip: remove i2c5 from rk3566-roc-pc Sasha Levin
2022-11-28 17:35 ` [PATCH AUTOSEL 6.0 04/39] arm64: dts: rockchip: keep I2S1 disabled for GPIO function on ROCK Pi 4 series Sasha Levin
2022-11-28 17:35 ` [PATCH AUTOSEL 6.0 05/39] arm64: dts: rockchip: fix node name for hym8563 rtc Sasha Levin
2022-11-28 17:35 ` [PATCH AUTOSEL 6.0 06/39] arm: " Sasha Levin
2022-11-28 17:35 ` [PATCH AUTOSEL 6.0 07/39] arm: dts: rockchip: remove clock-frequency from rtc Sasha Levin
2022-11-28 17:35 ` [PATCH AUTOSEL 6.0 08/39] ARM: dts: rockchip: fix adc-keys sub node names Sasha Levin
2022-11-28 17:35 ` [PATCH AUTOSEL 6.0 09/39] arm64: " Sasha Levin
2022-11-28 17:35 ` [PATCH AUTOSEL 6.0 10/39] ARM: dts: rockchip: fix ir-receiver " Sasha Levin
2022-11-28 17:35 ` [PATCH AUTOSEL 6.0 11/39] arm64: " Sasha Levin
2022-11-28 17:35 ` [PATCH AUTOSEL 6.0 12/39] ARM: dts: rockchip: rk3188: fix lcdc1-rgb24 node name Sasha Levin
2022-11-28 17:35 ` [PATCH AUTOSEL 6.0 13/39] fs: use acquire ordering in __fget_light() Sasha Levin
2022-11-28 17:35 ` [PATCH AUTOSEL 6.0 14/39] ARM: 9251/1: perf: Fix stacktraces for tracepoint events in THUMB2 kernels Sasha Levin
2022-11-28 17:35 ` [PATCH AUTOSEL 6.0 15/39] ARM: 9266/1: mm: fix no-MMU ZERO_PAGE() implementation Sasha Levin
2022-11-28 17:35 ` [PATCH AUTOSEL 6.0 16/39] ASoC: wm8962: Wait for updated value of WM8962_CLOCKING1 register Sasha Levin
2022-11-28 17:35 ` [PATCH AUTOSEL 6.0 17/39] spi: mediatek: Fix DEVAPC Violation at KO Remove Sasha Levin
2022-11-28 17:35 ` [PATCH AUTOSEL 6.0 18/39] ARM: dts: rockchip: disable arm_global_timer on rk3066 and rk3188 Sasha Levin
2022-11-28 17:35 ` [PATCH AUTOSEL 6.0 19/39] ASoC: rt711-sdca: fix the latency time of clock stop prepare state machine transitions Sasha Levin
2022-11-28 17:36 ` [PATCH AUTOSEL 6.0 20/39] 9p/fd: Use P9_HDRSZ for header size Sasha Levin
2022-11-28 17:36 ` [PATCH AUTOSEL 6.0 21/39] regulator: slg51000: Wait after asserting CS pin Sasha Levin
2022-11-28 17:36 ` [PATCH AUTOSEL 6.0 22/39] ALSA: seq: Fix function prototype mismatch in snd_seq_expand_var_event Sasha Levin
2022-11-28 17:36 ` [PATCH AUTOSEL 6.0 23/39] LoongArch: Makefile: Use "grep -E" instead of "egrep" Sasha Levin
2022-11-28 17:36 ` [PATCH AUTOSEL 6.0 24/39] LoongArch: Combine acpi_boot_table_init() and acpi_boot_init() Sasha Levin
2022-11-28 17:36 ` Sasha Levin [this message]
2022-11-28 17:36 ` [PATCH AUTOSEL 6.0 26/39] LoongArch: Fix unsigned comparison with less than zero Sasha Levin
2022-11-28 17:36 ` [PATCH AUTOSEL 6.0 27/39] selftests/net: Find nettest in current directory Sasha Levin
2022-11-28 17:36 ` [PATCH AUTOSEL 6.0 28/39] btrfs: send: avoid unaligned encoded writes when attempting to clone range Sasha Levin
2022-11-28 17:36 ` [PATCH AUTOSEL 6.0 29/39] net/mlx5: Lag, avoid lockdep warnings Sasha Levin
2022-11-28 17:36 ` [PATCH AUTOSEL 6.0 30/39] ASoC: soc-pcm: Add NULL check in BE reparenting Sasha Levin
2022-11-28 17:36 ` [PATCH AUTOSEL 6.0 31/39] regulator: twl6030: fix get status of twl6032 regulators Sasha Levin
2022-11-28 17:36 ` [PATCH AUTOSEL 6.0 32/39] fbcon: Use kzalloc() in fbcon_prepare_logo() Sasha Levin
2022-11-28 17:36 ` [PATCH AUTOSEL 6.0 33/39] usb: dwc3: gadget: Disable GUSB2PHYCFG.SUSPHY for End Transfer Sasha Levin
2022-11-28 17:36 ` [PATCH AUTOSEL 6.0 34/39] 9p/xen: check logical size for buffer size Sasha Levin
2022-11-28 17:36 ` [PATCH AUTOSEL 6.0 35/39] net: usb: qmi_wwan: add u-blox 0x1342 composition Sasha Levin
2022-11-28 17:36 ` [PATCH AUTOSEL 6.0 36/39] drm/amd/display: Use viewport height for subvp mall allocation size Sasha Levin
2022-11-28 17:36 ` [PATCH AUTOSEL 6.0 37/39] drm/amd/display: Avoid setting pixel rate divider to N/A Sasha Levin
2022-11-28 17:36 ` [PATCH AUTOSEL 6.0 38/39] drm/amd/display: Use new num clk levels struct for max mclk index Sasha Levin
2022-11-28 17:36 ` [PATCH AUTOSEL 6.0 39/39] drm/amdgpu: fix use-after-free during gpu recovery 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=20221128173642.1441232-25-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=chenhuacai@kernel.org \
    --cc=chenhuacai@loongson.cn \
    --cc=git@xen0n.name \
    --cc=guoren@kernel.org \
    --cc=jiaxun.yang@flygoat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=loongarch@lists.linux.dev \
    --cc=rppt@kernel.org \
    --cc=stable@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox