From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E6CBDC43381 for ; Mon, 11 Mar 2019 11:59:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B9F222075C for ; Mon, 11 Mar 2019 11:59:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726592AbfCKL7S (ORCPT ); Mon, 11 Mar 2019 07:59:18 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:50228 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726688AbfCKL7R (ORCPT ); Mon, 11 Mar 2019 07:59:17 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x2BBx1VC102047 for ; Mon, 11 Mar 2019 07:59:16 -0400 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0b-001b2d01.pphosted.com with ESMTP id 2r5pnehg6w-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 11 Mar 2019 07:59:15 -0400 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 11 Mar 2019 11:59:14 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp03.uk.ibm.com (192.168.101.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 11 Mar 2019 11:59:11 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x2BBxAMQ52166772 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 11 Mar 2019 11:59:10 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3DE104C044; Mon, 11 Mar 2019 11:59:10 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A67F74C05A; Mon, 11 Mar 2019 11:59:07 +0000 (GMT) Received: from skywalker.linux.ibm.com (unknown [9.199.35.189]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 11 Mar 2019 11:59:07 +0000 (GMT) X-Mailer: emacs 26.1 (via feedmail 11-beta-1 I) From: "Aneesh Kumar K.V" To: Jan Kara , Andrew Morton Cc: linux-mm@kvack.org, Dan Williams , Chandan Rajendra , Jan Kara , stable@vger.kernel.org Subject: Re: [PATCH] mm: Fix modifying of page protection by insert_pfn() In-Reply-To: <20190311084537.16029-1-jack@suse.cz> References: <20190311084537.16029-1-jack@suse.cz> Date: Mon, 11 Mar 2019 17:29:05 +0530 MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-GCONF: 00 x-cbid: 19031111-0012-0000-0000-000003013D3F X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19031111-0013-0000-0000-000021385852 Message-Id: <874l89wrjq.fsf@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-03-11_09:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1903110091 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org Jan Kara writes: > Aneesh has reported that PPC triggers the following warning when > excercising DAX code: > > [c00000000007610c] set_pte_at+0x3c/0x190 > LR [c000000000378628] insert_pfn+0x208/0x280 > Call Trace: > [c0000002125df980] [8000000000000104] 0x8000000000000104 (unreliable) > [c0000002125df9c0] [c000000000378488] insert_pfn+0x68/0x280 > [c0000002125dfa30] [c0000000004a5494] dax_iomap_pte_fault.isra.7+0x734/0xa40 > [c0000002125dfb50] [c000000000627250] __xfs_filemap_fault+0x280/0x2d0 > [c0000002125dfbb0] [c000000000373abc] do_wp_page+0x48c/0xa40 > [c0000002125dfc00] [c000000000379170] __handle_mm_fault+0x8d0/0x1fd0 > [c0000002125dfd00] [c00000000037a9b0] handle_mm_fault+0x140/0x250 > [c0000002125dfd40] [c000000000074bb0] __do_page_fault+0x300/0xd60 > [c0000002125dfe20] [c00000000000acf4] handle_page_fault+0x18 > > Now that is WARN_ON in set_pte_at which is > > VM_WARN_ON(pte_hw_valid(*ptep) && !pte_protnone(*ptep)); > > The problem is that on some architectures set_pte_at() cannot cope with > a situation where there is already some (different) valid entry present. > > Use ptep_set_access_flags() instead to modify the pfn which is built to > deal with modifying existing PTE. > Reviewed-by: Aneesh Kumar K.V > CC: stable@vger.kernel.org > Fixes: b2770da64254 "mm: add vm_insert_mixed_mkwrite()" > Reported-by: "Aneesh Kumar K.V" > Signed-off-by: Jan Kara > --- > mm/memory.c | 11 ++++++----- > 1 file changed, 6 insertions(+), 5 deletions(-) > > diff --git a/mm/memory.c b/mm/memory.c > index 47fe250307c7..ab650c21bccd 100644 > --- a/mm/memory.c > +++ b/mm/memory.c > @@ -1549,10 +1549,12 @@ static vm_fault_t insert_pfn(struct vm_area_struct *vma, unsigned long addr, > WARN_ON_ONCE(!is_zero_pfn(pte_pfn(*pte))); > goto out_unlock; > } > - entry = *pte; > - goto out_mkwrite; > - } else > - goto out_unlock; > + entry = pte_mkyoung(*pte); > + entry = maybe_mkwrite(pte_mkdirty(entry), vma); > + if (ptep_set_access_flags(vma, addr, pte, entry, 1)) > + update_mmu_cache(vma, addr, pte); > + } > + goto out_unlock; > } > > /* Ok, finally just insert the thing.. */ > @@ -1561,7 +1563,6 @@ static vm_fault_t insert_pfn(struct vm_area_struct *vma, unsigned long addr, > else > entry = pte_mkspecial(pfn_t_pte(pfn, prot)); > > -out_mkwrite: > if (mkwrite) { > entry = pte_mkyoung(entry); > entry = maybe_mkwrite(pte_mkdirty(entry), vma); > -- > 2.16.4