linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org,
	Gerald Schaefer <gerald.schaefer@de.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH 4.19 24/28] s390/mm: fix set_huge_pte_at() for empty ptes
Date: Fri,  5 Jun 2020 16:15:26 +0200	[thread overview]
Message-ID: <20200605140253.810716415@linuxfoundation.org> (raw)
In-Reply-To: <20200605140252.338635395@linuxfoundation.org>

From: Gerald Schaefer <gerald.schaefer@de.ibm.com>

[ Upstream commit ac8372f3b4e41015549b331a4f350224661e7fc6 ]

On s390, the layout of normal and large ptes (i.e. pmds/puds) differs.
Therefore, set_huge_pte_at() does a conversion from a normal pte to
the corresponding large pmd/pud. So, when converting an empty pte, this
should result in an empty pmd/pud, which would return true for
pmd/pud_none().

However, after conversion we also mark the pmd/pud as large, and
therefore present. For empty ptes, this will result in an empty pmd/pud
that is also marked as large, and pmd/pud_none() would not return true.

There is currently no issue with this behaviour, as set_huge_pte_at()
does not seem to be called for empty ptes. It would be valid though, so
let's fix this by not marking empty ptes as large in set_huge_pte_at().

This was found by testing a patch from from Anshuman Khandual, which is
currently discussed on LKML ("mm/debug: Add more arch page table helper
tests").

Signed-off-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/s390/mm/hugetlbpage.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/arch/s390/mm/hugetlbpage.c b/arch/s390/mm/hugetlbpage.c
index 5674710a4841..7dfae86afa47 100644
--- a/arch/s390/mm/hugetlbpage.c
+++ b/arch/s390/mm/hugetlbpage.c
@@ -159,10 +159,13 @@ void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
 		rste &= ~_SEGMENT_ENTRY_NOEXEC;
 
 	/* Set correct table type for 2G hugepages */
-	if ((pte_val(*ptep) & _REGION_ENTRY_TYPE_MASK) == _REGION_ENTRY_TYPE_R3)
-		rste |= _REGION_ENTRY_TYPE_R3 | _REGION3_ENTRY_LARGE;
-	else
+	if ((pte_val(*ptep) & _REGION_ENTRY_TYPE_MASK) == _REGION_ENTRY_TYPE_R3) {
+		if (likely(pte_present(pte)))
+			rste |= _REGION3_ENTRY_LARGE;
+		rste |= _REGION_ENTRY_TYPE_R3;
+	} else if (likely(pte_present(pte)))
 		rste |= _SEGMENT_ENTRY_LARGE;
+
 	clear_huge_pte_skeys(mm, rste);
 	pte_val(*ptep) = rste;
 }
-- 
2.25.1




  parent reply	other threads:[~2020-06-05 14:21 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-05 14:15 [PATCH 4.19 00/28] 4.19.127-rc1 review Greg Kroah-Hartman
2020-06-05 14:15 ` [PATCH 4.19 01/28] Revert "cgroup: Add memory barriers to plug cgroup_rstat_updated() race window" Greg Kroah-Hartman
2020-06-05 14:15 ` [PATCH 4.19 02/28] libnvdimm: Fix endian conversion issues Greg Kroah-Hartman
2020-06-05 14:15 ` [PATCH 4.19 03/28] mm: Fix mremap not considering huge pmd devmap Greg Kroah-Hartman
2020-06-05 14:15 ` [PATCH 4.19 04/28] HID: sony: Fix for broken buttons on DS3 USB dongles Greg Kroah-Hartman
2020-06-05 14:15 ` [PATCH 4.19 05/28] HID: i2c-hid: add Schneider SCL142ALM to descriptor override Greg Kroah-Hartman
2020-06-05 14:15 ` [PATCH 4.19 06/28] p54usb: add AirVasT USB stick device-id Greg Kroah-Hartman
2020-06-05 14:15 ` [PATCH 4.19 07/28] kernel/relay.c: handle alloc_percpu returning NULL in relay_open Greg Kroah-Hartman
2020-06-05 14:15 ` [PATCH 4.19 08/28] mmc: fix compilation of user API Greg Kroah-Hartman
2020-06-05 14:15 ` [PATCH 4.19 09/28] scsi: ufs: Release clock if DMA map fails Greg Kroah-Hartman
2020-06-05 14:15 ` [PATCH 4.19 10/28] net: dsa: mt7530: set CPU port to fallback mode Greg Kroah-Hartman
2020-06-05 14:15 ` [PATCH 4.19 11/28] airo: Fix read overflows sending packets Greg Kroah-Hartman
2020-06-05 14:15 ` [PATCH 4.19 12/28] drm/i915: fix port checks for MST support on gen >= 11 Greg Kroah-Hartman
2020-06-05 14:15 ` [PATCH 4.19 13/28] scsi: hisi_sas: Check sas_port before using it Greg Kroah-Hartman
2020-06-05 14:15 ` [PATCH 4.19 14/28] powerpc/powernv: Avoid re-registration of imc debugfs directory Greg Kroah-Hartman
2020-06-05 14:15 ` [PATCH 4.19 15/28] spi: dw: use "smp_mb()" to avoid sending spi data error Greg Kroah-Hartman
2020-06-07 20:09   ` Pavel Machek
2020-06-08 11:16     ` Mark Brown
2020-06-10 15:01       ` Pavel Machek
2020-06-05 14:15 ` [PATCH 4.19 16/28] s390/ftrace: save traced function caller Greg Kroah-Hartman
2020-06-05 14:15 ` [PATCH 4.19 17/28] ARC: Fix ICCM & DCCM runtime size checks Greg Kroah-Hartman
2020-06-05 14:15 ` [PATCH 4.19 18/28] ARC: [plat-eznps]: Restrict to CONFIG_ISA_ARCOMPACT Greg Kroah-Hartman
2020-06-05 14:15 ` [PATCH 4.19 19/28] evm: Fix RCU list related warnings Greg Kroah-Hartman
2020-06-05 14:15 ` [PATCH 4.19 20/28] i2c: altera: Fix race between xfer_msg and isr thread Greg Kroah-Hartman
2020-06-05 14:15 ` [PATCH 4.19 21/28] x86/mmiotrace: Use cpumask_available() for cpumask_var_t variables Greg Kroah-Hartman
2020-06-05 14:15 ` [PATCH 4.19 22/28] net: bmac: Fix read of MAC address from ROM Greg Kroah-Hartman
2020-06-05 14:15 ` [PATCH 4.19 23/28] drm/edid: Add Oculus Rift S to non-desktop list Greg Kroah-Hartman
2020-06-05 14:15 ` Greg Kroah-Hartman [this message]
2020-06-05 14:15 ` [PATCH 4.19 25/28] null_blk: return error for invalid zone size Greg Kroah-Hartman
2020-06-05 14:15 ` [PATCH 4.19 26/28] net/ethernet/freescale: rework quiesce/activate for ucc_geth Greg Kroah-Hartman
2020-06-05 14:15 ` [PATCH 4.19 27/28] net: ethernet: stmmac: Enable interface clocks on probe for IPQ806x Greg Kroah-Hartman
2020-06-05 14:15 ` [PATCH 4.19 28/28] net: smsc911x: Fix runtime PM imbalance on error Greg Kroah-Hartman
2020-06-05 22:19 ` [PATCH 4.19 00/28] 4.19.127-rc1 review Shuah Khan
2020-06-06  6:32 ` Jon Hunter
2020-06-07 11:19   ` Greg Kroah-Hartman
2020-06-06 13:33 ` Guenter Roeck
2020-06-07  5:44 ` Naresh Kamboju
2020-06-08  9:44 ` Chris Paterson

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=20200605140253.810716415@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=gerald.schaefer@de.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sashal@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;
as well as URLs for NNTP newsgroup(s).