Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp2176387ybg; Fri, 5 Jun 2020 07:28:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJybu0QLLs68W1v6GPvKvDlI9vTxCH1IV+MS0oDYX1JgWGYd7kg1RtmsHLWjheG8QpEyaCay X-Received: by 2002:a17:906:3110:: with SMTP id 16mr8733142ejx.307.1591367300227; Fri, 05 Jun 2020 07:28:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591367300; cv=none; d=google.com; s=arc-20160816; b=zLkHUZelqs5y+CetvXS45MHC9C3RRiTJ1Kwy0SNEFvKY92yJeSd+QAHfyhAerMX9C4 jWSDyNK61XO91246Op3SMixfmOK64TENkTUuXSfIB/aI+m1f6ibss5UlxU3oeIUiP5Qr z8WtKZY5o8vAGBViVO4X/YB6nM96Lw8wjQO+t81Rz+w7npwvGOQeNRnXAy1uBmBUREF0 Mszc4+tfLQYaoqCVff2p9bqovkRta7SrGA6IyfJAA8VHxfhPa6RATaQlxyN+5sJ3tHr/ soGjDK8YJ9IBb/U7AW/rFncVYtQp57Dy7sw5Tl8VF05tKkH/Kq2Q9wuab/VWcOHZHqU+ I0cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ZTXFddaDwBEafFwdxd9iKb/+hgnFe5UlEYC6uCU1Ffs=; b=JjroRxffQMl7QiJC8Z1oFcOwO4E3yZOhPJtfwya1cEzTXT2MH34f530qNnrIpELJqm WojynhDR5KvR5ZaUqBi2CrKkUtnjKhtQjuDS3jtLi2K7YcnMWH734ed8ZwcGnvDmcBGj RgDWmKgktLAcMulfzBlHd4dSYTXdVkuDIKUHA62SF0Wv1F5yd2wlsgqfhvSpk+CxFEZr mEEu7uRsJNFy2v4Mjkn4YsHg5qemv/ukXgg87yOoYWrI69gV1mebkJKYlcVK4Xl2kZL3 bDGBy7X0wbbpahMic0HWO/fptqOlIbDPoaDxsGSV5lQxL9sCNP8ILZZtmNPbzhdzKNY4 iR7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HScNZvqO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f6si3668173ejr.283.2020.06.05.07.27.57; Fri, 05 Jun 2020 07:28:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HScNZvqO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728402AbgFEOZ1 (ORCPT + 99 others); Fri, 5 Jun 2020 10:25:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:45856 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728277AbgFEOQl (ORCPT ); Fri, 5 Jun 2020 10:16:41 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7FAA420835; Fri, 5 Jun 2020 14:16:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591366601; bh=ZmwBUR7+DZZ6gNJAh78+DU1YLOyaYWC2FmNmChYEAxw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HScNZvqOLofpHsgUll1TSxziHJWonw8fxkZrI+5RCaru6XJlsNN5peyZEdW/rpKLv iLnOSIsQlR2RppM4kmRDpYByTi+1GSKu7Wio3l37Qfsegrdq2QoOat/0N3wIGKqowT JXbNl6Ntn/GahX/n+ryWhgqZJisrIPK0Ry7pUPyw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gerald Schaefer , Vasily Gorbik , Sasha Levin Subject: [PATCH 5.6 19/43] s390/mm: fix set_huge_pte_at() for empty ptes Date: Fri, 5 Jun 2020 16:14:49 +0200 Message-Id: <20200605140153.529180967@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200605140152.493743366@linuxfoundation.org> References: <20200605140152.493743366@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Gerald Schaefer [ 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 Signed-off-by: Vasily Gorbik Signed-off-by: Sasha Levin --- 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