Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp2173844ybg; Fri, 5 Jun 2020 07:24:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOwleXAWZxM3Bx0o+nEVZs9CS2uN+09pnifQ8+PBw0M380PPwRKDn1zElfAy0sjhXhe0fb X-Received: by 2002:aa7:d48f:: with SMTP id b15mr10152035edr.8.1591367096739; Fri, 05 Jun 2020 07:24:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591367096; cv=none; d=google.com; s=arc-20160816; b=qm51Ar1iL1I6jmuq6vU+8yKkR9LXCObE9LhcrFqk0PMuWTkCVLendx9xlN6mUwqOp+ EWlnh1fzsQbqK3dSfiygU6bVKro74ISwF0SYBVnMV8IX+V5pzEuiQ0gWd1szqVaH+0us mzcVWVij4baYaZQqea07kgvkq+DclhuysPvPp3KgJh6gTEVU5bgpRrgLPIhpPXq2yTLf ni9MK6oeSEMEId30hm7QsoPBP4ThUZT7KHEh5M+y4/0k5RRuFCkVnw4cwO1huBnxfLdo af5Z9fwj233W4VR1IMpKeIYN9KblkH9hz/azg2Qk+McpDXoObLgulwE19aAc5ghW8QvW ZBiQ== 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=Tk8uubC3ZPo2X5MG65ia+o99moHrp3sWjgpqiClhVWCG3rb0N7P+y3KH9gzjdSEeAA yuxI4S7I3TBDoO1s71o2s28t97X0adVrw7hXYPTF26ZnG3tMKibUnmRlfGHLrvJahzJJ /fALMimYrBP/aNFhOtw+uVFuhz5hdqZTFQYNXa5bNoNaFWmblLcBvW0eVsWhbxjxwPtf Y1/y9glulSksGi/tX0NLn5h/gBkSg9sMA+i8FSRxAOKIv9KS5YBmiPoii++LsR6AikSb +IpUBhEI6c39ubGtMdzsjE2+eas8hZvZ+jclFm+QLL5/69dge2b9XxZV8Em7kzqw2IBW PJag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hrn1HZs1; 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 d18si3658234edr.366.2020.06.05.07.24.34; Fri, 05 Jun 2020 07:24:56 -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=hrn1HZs1; 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 S1729029AbgFEOVo (ORCPT + 99 others); Fri, 5 Jun 2020 10:21:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:51190 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728917AbgFEOUE (ORCPT ); Fri, 5 Jun 2020 10:20:04 -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 54B28208B6; Fri, 5 Jun 2020 14:20:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591366803; bh=ZmwBUR7+DZZ6gNJAh78+DU1YLOyaYWC2FmNmChYEAxw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hrn1HZs13g7Rkm9EG30fVAYmXeLIZtJE7iQc/Cvd9ki36QEvv+wq9TvUoe+ylFjjQ fo+srkZRnqhs7feS/766pq8gWAHWwpYW1b+itwApWS+rYYANbiaD7xEFQtDCFJ9xk6 SyQ4fPATTA9M+P+g/BDxF72TbAR8TBXyrXwne86Y= 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 4.19 24/28] s390/mm: fix set_huge_pte_at() for empty ptes Date: Fri, 5 Jun 2020 16:15:26 +0200 Message-Id: <20200605140253.810716415@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200605140252.338635395@linuxfoundation.org> References: <20200605140252.338635395@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