From patchwork Wed May 10 05:01:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13236401 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 092F7C7EE22 for ; Wed, 10 May 2023 05:01:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A4AC26B0071; Wed, 10 May 2023 01:01:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9FB426B0072; Wed, 10 May 2023 01:01:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8EA776B0074; Wed, 10 May 2023 01:01:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 7DCDF6B0071 for ; Wed, 10 May 2023 01:01:23 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 4BF3480555 for ; Wed, 10 May 2023 05:01:23 +0000 (UTC) X-FDA: 80773146846.14.55086CF Received: from mail-yw1-f175.google.com (mail-yw1-f175.google.com [209.85.128.175]) by imf24.hostedemail.com (Postfix) with ESMTP id 7173C18000A for ; Wed, 10 May 2023 05:01:21 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=vuo7rYDM; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf24.hostedemail.com: domain of hughd@google.com designates 209.85.128.175 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1683694881; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=WSGFooIbg1YnCT+usP0CPskjqWFniw8CJbMJmY8IIY4=; b=gQfSs6xgYnbtu6B5Pub6R5g8WpUJ2V/IG2+StDGVE06DqaVFBx3v3fWnkQ5+pVO/enKxQf hI+7D9PaMzXdgZAxMq2qV1JHBQue24UBht8CHPjNBfhxrvqxlq/5eA+BeyyIK+72m29Ktt i5coo4G/+P9JmZKbBX7X3s8g+oiW3P4= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=vuo7rYDM; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf24.hostedemail.com: domain of hughd@google.com designates 209.85.128.175 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1683694881; a=rsa-sha256; cv=none; b=5gZ7sM+vkcxz6eZk/z2rEJTTL/TAZLVzLGLUHqbgY8NK+WEy02KDBOy0aZ27lhDCca+D/e MYmyLJDKtH7DaVZ4tk+fWz9remyeUXFCIk2Is6PCAJ7J6JIUEBdv7PxRkUEBjDF42p97Cv Hfa6pEIPQZ30uGPcge4bby9aWVrMST4= Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-55a829411b5so62527597b3.1 for ; Tue, 09 May 2023 22:01:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683694880; x=1686286880; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=WSGFooIbg1YnCT+usP0CPskjqWFniw8CJbMJmY8IIY4=; b=vuo7rYDMzaDeDPZgzHMtVp+kDDpzRoF+cP2Qnr93hh+pF6J9q5tC6QhVWjQR/dpJZs St4YSsmW5E0SKuQmRdibMqMztrKviA12bUxhXRBvVCQgZMikD8H0uj5+E9csqviYPTTF W/MWYfjHA/1NssscvDoyXC6tVcA1ciumq+qFhN9YZhl/AUe/TYRGPOpbxUr3CzSoAwDs 9ZIJx+k2kcTyg+8Yd6pO3A43gfTS5JygrpCg5CjFhHivuRBYVd+ivlToDlbyQHOK26G6 DP8KUWo0VQTsOYmO3ProNs6agiD4J9mWFi/qWhwm90YAcZbtyMXr/cNFlm/A7CEZL/+P HUIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683694880; x=1686286880; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=WSGFooIbg1YnCT+usP0CPskjqWFniw8CJbMJmY8IIY4=; b=YEDXpDe6nlRzVDRW0HhySZcjGN6adB06xe7UT8dB4NZLBJ70ndW+L+phGRjarf9lZO u6KMTKAHTAOCSOhQZXXe5kA3vVYjDFqbCXfKFnR6bGl2Tqpc+f1eIUMROBZBZHA5MpKy Geu2yD3EM75Tj2TD4lhk2rICjGI3GzbTrG+/+I3hFHNBAh5ni4N/MBO1PlXaP0tX3cMQ C1OmCQb//mjX3ibryoOcY2vIOsIsN345uegu5IX4Ghm+pABuJiIyQNEDtg/ADiLH1XZj FkHw11I2VZCD02yyr8o/oywDXrnViXpfCFKPHDocAouONsiV/+luHrkmT60ruWh4Dwyr V3MA== X-Gm-Message-State: AC+VfDxkS76eUH5pgsEJvBf4PUcTahEhIXXk6Bl1rQfPhb/ZTKvOhTgs /SplBNIYGdN74PmZ0w7UC1BtFA== X-Google-Smtp-Source: ACHHUZ5AoVobUeVID967V3Jmnothc2qu5Os8b3JQyJT6HUqgLFH4b1VRwh/1toL1vvMbGclLD2jjcg== X-Received: by 2002:a0d:d4c3:0:b0:55a:9d84:2e4e with SMTP id w186-20020a0dd4c3000000b0055a9d842e4emr17674451ywd.18.1683694880477; Tue, 09 May 2023 22:01:20 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id e2-20020a81dd02000000b00559f9e9eabcsm3815388ywn.98.2023.05.09.22.01.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 May 2023 22:01:20 -0700 (PDT) Date: Tue, 9 May 2023 22:01:16 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Greg Ungerer , Michal Simek , Thomas Bogendoerfer , Helge Deller , John David Anglin , "Aneesh Kumar K.V" , Michael Ellerman , Alexandre Ghiti , Palmer Dabbelt , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , John Paul Adrian Glaubitz , "David S. Miller" , Chris Zankel , Max Filippov , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 15/23] s390: allow pte_offset_map_lock() to fail In-Reply-To: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> Message-ID: <94aec8fe-383f-892-dcbf-d4c14e460a7@google.com> References: <77a5d8c-406b-7068-4f17-23b7ac53bc83@google.com> MIME-Version: 1.0 X-Stat-Signature: ay8ssnpqgxwdh6rekxeeywpf76xpb135 X-Rspam-User: X-Rspamd-Queue-Id: 7173C18000A X-Rspamd-Server: rspam07 X-HE-Tag: 1683694881-584906 X-HE-Meta: U2FsdGVkX19QINes88PpB2e4spaBI5NFViNJchXFQk1lQvbpfekTL8F/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CgekwxVGJnbx9k7j1eloM8YiOEIxjT3EMbUN5h5H+RW9PxjmvRcsx5doXlhOoi+4sRD2ry0SgtM9vFN4cejcKdPAAlPhRsWwZ62+EiaBzGQ/OOJz99jKPeiIAP9s0MHOxZV5bKAGzAvMBnvbQvYz7DS9A+hqdoOoqZR/Z1o6+9VnUOKYXLXQZOP5olmrELYY9/BKYW9kP0Ye8fR5EOaJ4mgBk3briZX5QG6R3s9tEtbxqas7o7+J3VMHMWthcut1Q6c6JeYJr1bMonehizd60bVES3ODQA== 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 rare transient cases, not yet made possible, pte_offset_map() and pte_offset_map_lock() may not find a page table: handle appropriately. Signed-off-by: Hugh Dickins --- arch/s390/kernel/uv.c | 2 ++ arch/s390/mm/gmap.c | 2 ++ arch/s390/mm/pgtable.c | 12 +++++++++--- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/arch/s390/kernel/uv.c b/arch/s390/kernel/uv.c index cb2ee06df286..3c62d1b218b1 100644 --- a/arch/s390/kernel/uv.c +++ b/arch/s390/kernel/uv.c @@ -294,6 +294,8 @@ int gmap_make_secure(struct gmap *gmap, unsigned long gaddr, void *uvcb) rc = -ENXIO; ptep = get_locked_pte(gmap->mm, uaddr, &ptelock); + if (!ptep) + goto out; if (pte_present(*ptep) && !(pte_val(*ptep) & _PAGE_INVALID) && pte_write(*ptep)) { page = pte_page(*ptep); rc = -EAGAIN; diff --git a/arch/s390/mm/gmap.c b/arch/s390/mm/gmap.c index dc90d1eb0d55..d198fc9475a2 100644 --- a/arch/s390/mm/gmap.c +++ b/arch/s390/mm/gmap.c @@ -2549,6 +2549,8 @@ static int __zap_zero_pages(pmd_t *pmd, unsigned long start, spinlock_t *ptl; ptep = pte_offset_map_lock(walk->mm, pmd, addr, &ptl); + if (!ptep) + break; if (is_zero_pfn(pte_pfn(*ptep))) ptep_xchg_direct(walk->mm, addr, ptep, __pte(_PAGE_INVALID)); pte_unmap_unlock(ptep, ptl); diff --git a/arch/s390/mm/pgtable.c b/arch/s390/mm/pgtable.c index 6effb24de6d9..3bd2ab2a9a34 100644 --- a/arch/s390/mm/pgtable.c +++ b/arch/s390/mm/pgtable.c @@ -829,7 +829,7 @@ int set_guest_storage_key(struct mm_struct *mm, unsigned long addr, default: return -EFAULT; } - +again: ptl = pmd_lock(mm, pmdp); if (!pmd_present(*pmdp)) { spin_unlock(ptl); @@ -850,6 +850,8 @@ int set_guest_storage_key(struct mm_struct *mm, unsigned long addr, spin_unlock(ptl); ptep = pte_offset_map_lock(mm, pmdp, addr, &ptl); + if (!ptep) + goto again; new = old = pgste_get_lock(ptep); pgste_val(new) &= ~(PGSTE_GR_BIT | PGSTE_GC_BIT | PGSTE_ACC_BITS | PGSTE_FP_BIT); @@ -938,7 +940,7 @@ int reset_guest_reference_bit(struct mm_struct *mm, unsigned long addr) default: return -EFAULT; } - +again: ptl = pmd_lock(mm, pmdp); if (!pmd_present(*pmdp)) { spin_unlock(ptl); @@ -955,6 +957,8 @@ int reset_guest_reference_bit(struct mm_struct *mm, unsigned long addr) spin_unlock(ptl); ptep = pte_offset_map_lock(mm, pmdp, addr, &ptl); + if (!ptep) + goto again; new = old = pgste_get_lock(ptep); /* Reset guest reference bit only */ pgste_val(new) &= ~PGSTE_GR_BIT; @@ -1000,7 +1004,7 @@ int get_guest_storage_key(struct mm_struct *mm, unsigned long addr, default: return -EFAULT; } - +again: ptl = pmd_lock(mm, pmdp); if (!pmd_present(*pmdp)) { spin_unlock(ptl); @@ -1017,6 +1021,8 @@ int get_guest_storage_key(struct mm_struct *mm, unsigned long addr, spin_unlock(ptl); ptep = pte_offset_map_lock(mm, pmdp, addr, &ptl); + if (!ptep) + goto again; pgste = pgste_get_lock(ptep); *key = (pgste_val(pgste) & (PGSTE_ACC_BITS | PGSTE_FP_BIT)) >> 56; paddr = pte_val(*ptep) & PAGE_MASK;