From patchwork Thu Sep 21 16:20:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13394009 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D029AE71093 for ; Thu, 21 Sep 2023 16:20:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 647336B0208; Thu, 21 Sep 2023 12:20:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5F7476B0209; Thu, 21 Sep 2023 12:20:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4BF456B020B; Thu, 21 Sep 2023 12:20:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 3D3346B0208 for ; Thu, 21 Sep 2023 12:20:45 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 082B640C33 for ; Thu, 21 Sep 2023 16:20:45 +0000 (UTC) X-FDA: 81261118050.18.477AC17 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf01.hostedemail.com (Postfix) with ESMTP id 244DC40018 for ; Thu, 21 Sep 2023 16:20:42 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf01.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1695313243; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vypF7oeKU3Uje4sDoCk7NF4kdS/Y+VzjMg+SzT44ILc=; b=gz78bKc9y91mdx0sYwWdd2NVl7AoxOtqK1JV5UIvfSgUrACSSzi+R+3GSBNxnBXZmAfCUm b4EKeWnRaFvaLkP9kZco0iKw+/IrCM4yKricpblWBUtyA+rdjSV8+cydFD22kuwJX3xlzD NExd5xsX23I4PP/93PmyhhkmZ07swb4= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf01.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695313243; a=rsa-sha256; cv=none; b=PCqLOoiiEzNrCwjPjBYmdWJfW81XPtEC6prPq3L9SPBL1YR9oaBPyYIvlNGMlt5ehYC+vB TOivBwyg+dwwXqX1Cv79sttfPVcmVRfmKYtdMpV2qhP+C2Wknm3+aKrwpHJwM7aA6voa7i 131HjLju6DbDh5h/QIoTofKHuVokzLw= Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 75302175A; Thu, 21 Sep 2023 09:21:19 -0700 (PDT) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 09E233F59C; Thu, 21 Sep 2023 09:20:37 -0700 (PDT) From: Ryan Roberts To: Catalin Marinas , Will Deacon , "James E.J. Bottomley" , Helge Deller , Nicholas Piggin , Christophe Leroy , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Gerald Schaefer , "David S. Miller" , Arnd Bergmann , Mike Kravetz , Muchun Song , SeongJae Park , Andrew Morton , Uladzislau Rezki , Christoph Hellwig , Lorenzo Stoakes , Anshuman Khandual , Peter Xu , Axel Rasmussen , Qi Zheng Cc: Ryan Roberts , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org, linux-mm@kvack.org, stable@vger.kernel.org Subject: [PATCH v1 4/8] s390: hugetlb: Convert set_huge_pte_at() to take vma Date: Thu, 21 Sep 2023 17:20:03 +0100 Message-Id: <20230921162007.1630149-5-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230921162007.1630149-1-ryan.roberts@arm.com> References: <20230921162007.1630149-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: dcr11ybujo5uxkeoirsp9n91saeksitw X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 244DC40018 X-HE-Tag: 1695313242-948688 X-HE-Meta: U2FsdGVkX1/7ozjvbF1g9Ir0wrDWvcK7yYSkmdSq65B2CCpl3jUb8ZfueDsigzSLujvggd/Q7d4JWOmL60+Eqkbrz6J9+a3oJA9Ok9QQV54cG5HESbHLq/BLRcyXB+5PkOlOf6JuKQLfDFAh4DpZIt/3YHGWjcmdD59p9hlxf2mz3XkZy+hFqJGXq4tRknqP8cimc5NjuZxPzUsbC4c+3jnQwyRUW/s9CG3HNBy4HSL/lxBiAUaPhU0SxLX0flfVdNtAyA4JbHTDOSBPQ1waTLIWe0jCdyND/Ya9Dukznsr9JNYRp20cf3Ku+EGyty8ZOirR7sB52BclENP5SfmII7X21ANtiJj8L4LKMjcg3F4+Yz4NcHWibwh9rR+DU6FMHbrylS8GTVAO9JKykwuTamH8+Ak0lOsrCu6wxoaAbPP+7mTkdEER3dIeJYfivZ/NDbnfkeiaMniWF9r4mn4VMUAiUXhKPPLJ4b6PKOjcI14Eu9pq8jZuNQPEppNWVlcZ185/EYkppXrtJ/OMzDdqStjEz4yt6zP/owVQR/+0djZRrjEmZo460c7tfChuF8IBzBXFxN/2slHCGH+kfN/xq6UEwOH+z2Fp8ZkokuQBJrjlA2y706sX9wHsI1fWbsHt3oYr+xTWTWVVHn+fVycJbnlgIui1jxz+UWXnLA29z9kKr6XJoQeLPVCksoBQkwqPsihDGl0UFjXPkFlLe60YsWB1l9YMEaBs4oLKai0EO7Jzv0SBqOUjbKwwOOrY99NFfYijtIj8yPT2v4DrykHKVBXAZAEFod6FMyzeFp8EGxMYsgj/eFhI4vgFOwQ8mJ4RMPUwAOI+5IQdS9GpgWXViQ47SiHnX5aLy+9b9MbUK5vq0wkflKE7kwdNzPEmOsRexnaxVkozpdVMfRkEEC9O/tsIY3RZWn19G5dhEkEr2SnBxwtQthORCTmKDlZHaWmIsoIx/o5qXEupxm29G0s mmCCoN4H SKGfCdX3xkBCjvLzq682i92Vr8rV08RDUzJCReaqKIA3w91eG2ZBNcFSuUnTcYzPITvHA1JFQPW9OPKzLogVOL/lRvmYKbWce4VCr/4Ywb1DaHBo+19JTGM6C+bWNQsMgbVIDHY6p2uvuhZMlXQtYYRqPBlsBZu/mf6jNKPiqBpcKxHjAGJZExxFu3toJlOYwX8uPW81YR2n6mVw= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: In order to fix a bug, arm64 needs access to the vma inside it's implementation of set_huge_pte_at(). Provide for this by converting the mm parameter to be a vma. Any implementations that require the mm can access it via vma->vm_mm. This commit makes the required s390 modifications. Separate commits update the other arches and core code, before the actual bug is fixed in arm64. No behavioral changes intended. Signed-off-by: Ryan Roberts --- arch/s390/include/asm/hugetlb.h | 8 +++++--- arch/s390/mm/hugetlbpage.c | 8 +++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/arch/s390/include/asm/hugetlb.h b/arch/s390/include/asm/hugetlb.h index f07267875a19..da7f43b1871f 100644 --- a/arch/s390/include/asm/hugetlb.h +++ b/arch/s390/include/asm/hugetlb.h @@ -15,7 +15,9 @@ #define hugetlb_free_pgd_range free_pgd_range #define hugepages_supported() (MACHINE_HAS_EDAT1) -void set_huge_pte_at(struct mm_struct *mm, unsigned long addr, +void set_huge_pte_at(struct vm_area_struct *vma, unsigned long addr, + pte_t *ptep, pte_t pte); +void __set_huge_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pte); pte_t huge_ptep_get(pte_t *ptep); pte_t huge_ptep_get_and_clear(struct mm_struct *mm, @@ -65,7 +67,7 @@ static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma, int changed = !pte_same(huge_ptep_get(ptep), pte); if (changed) { huge_ptep_get_and_clear(vma->vm_mm, addr, ptep); - set_huge_pte_at(vma->vm_mm, addr, ptep, pte); + __set_huge_pte_at(vma->vm_mm, addr, ptep, pte); } return changed; } @@ -74,7 +76,7 @@ static inline void huge_ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep) { pte_t pte = huge_ptep_get_and_clear(mm, addr, ptep); - set_huge_pte_at(mm, addr, ptep, pte_wrprotect(pte)); + __set_huge_pte_at(mm, addr, ptep, pte_wrprotect(pte)); } static inline pte_t mk_huge_pte(struct page *page, pgprot_t pgprot) diff --git a/arch/s390/mm/hugetlbpage.c b/arch/s390/mm/hugetlbpage.c index c718f2a0de94..d69e2dc6e508 100644 --- a/arch/s390/mm/hugetlbpage.c +++ b/arch/s390/mm/hugetlbpage.c @@ -142,7 +142,7 @@ static void clear_huge_pte_skeys(struct mm_struct *mm, unsigned long rste) __storage_key_init_range(paddr, paddr + size - 1); } -void set_huge_pte_at(struct mm_struct *mm, unsigned long addr, +void __set_huge_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pte) { unsigned long rste; @@ -163,6 +163,12 @@ void set_huge_pte_at(struct mm_struct *mm, unsigned long addr, set_pte(ptep, __pte(rste)); } +void set_huge_pte_at(struct vm_area_struct *vma, unsigned long addr, + pte_t *ptep, pte_t pte) +{ + __set_huge_pte_at(vma->vm_mm, addr, ptep, pte); +} + pte_t huge_ptep_get(pte_t *ptep) { return __rste_to_pte(pte_val(*ptep));