Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp374558ybl; Thu, 9 Jan 2020 23:50:12 -0800 (PST) X-Google-Smtp-Source: APXvYqx7ofKXa+nZApAYEl6j0i9Ei4ucVoHU+v6A0iSmJ+0wCy31P8eWeGYkb64btIwcE/S38jFA X-Received: by 2002:a05:6808:b18:: with SMTP id s24mr1180251oij.31.1578642612810; Thu, 09 Jan 2020 23:50:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578642612; cv=none; d=google.com; s=arc-20160816; b=mFrhq8SN+ewn8+blTCD6QWB7OP6O5epJmEDkkWdc1UMuMtJt3HMTIJEcbterBsKsha FyR6XsfO2mgtTvcYZo7EOM5macp3mhhAdLKnM/mdTzrKdrPsRr65HP2dRB8nMD6IG0fm jWbEBB0hAhRsEbnhn+3IV3E7IV6/GrS9nCondfv6a1o5hLCzeFnkKKnygY+OkXXmRFfY /vZmJWxdkz28wrRfQbm72vk74CA1rPd2AET/QNib6U8n+oZ5c/xSvluITxVgRhbMRAbw xs9quWA+cfZwjYQBiyHHTdbGGIKiqwOJ44x1d3LM+lw4QEXflwG7sNLE0FQC+kdlZ2hh dxFA== 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 :content-language:mime-version:user-agent:date:message-id:subject :from:cc:to; bh=sRzs1RM971G99AkqHKAVSftwSyNGzpLQqZIpPpjDpl4=; b=wsHrPxUgIac5JUMr/RC3SnzYkNfkt7ns419Kgq2bfhGPWcGXtojj7Me47ZMYHYATDz HOuG8uvrJEhlst7qvSdzioZ6zzi6Mv5HeCVgDHJbhd00R7tSxBKOLmIsCb21UOurB/TU umBW6OlsXAwp1VziEO7k+cWC0/a3dP3DpRfn3/ONFIDf90QQ/HJGIcKrc2AVjvhVTwNb vajWn98UxXPmWZRtVyhWzrLcveQlI/8biI5rhIcd9febPqfo4oCUCbSKIQgKW64DvRVZ 5/7mqb/R+gdplH2mF4OQ3M0WRSzPt+Pi+6UX607WaywkutN2S34SturPnyYTIjJW6STX Hy7w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r6si695238otq.95.2020.01.09.23.50.01; Thu, 09 Jan 2020 23:50:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726598AbgAJHr5 (ORCPT + 99 others); Fri, 10 Jan 2020 02:47:57 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:60672 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726549AbgAJHr5 (ORCPT ); Fri, 10 Jan 2020 02:47:57 -0500 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 40D871CBDB19189F9994; Fri, 10 Jan 2020 15:47:52 +0800 (CST) Received: from [127.0.0.1] (10.173.221.31) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.439.0; Fri, 10 Jan 2020 15:47:43 +0800 To: , , , , , , , , , CC: , From: yeyunfeng Subject: [PATCH] arm64: mm: support setting page attributes for debug situation Message-ID: <5a3ab728-b895-0930-9540-5e9c586e8858@huawei.com> Date: Fri, 10 Jan 2020 15:47:41 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.173.221.31] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When rodata_full is set or pagealloc debug is enabled, block mappings or contiguou hints are no longer used for linear address area. Therefore, support setting page attributes in this case is useful for debugging memory corruption problems. Signed-off-by: Yunfeng Ye --- arch/arm64/mm/pageattr.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/arch/arm64/mm/pageattr.c b/arch/arm64/mm/pageattr.c index 9ce7bd9d4d9c..823143534a93 100644 --- a/arch/arm64/mm/pageattr.c +++ b/arch/arm64/mm/pageattr.c @@ -65,6 +65,9 @@ static int change_memory_common(unsigned long addr, int numpages, WARN_ON_ONCE(1); } + if (!numpages) + return 0; + /* * Kernel VA mappings are always live, and splitting live section * mappings into page mappings may cause TLB conflicts. This means @@ -81,11 +84,18 @@ static int change_memory_common(unsigned long addr, int numpages, area = find_vm_area((void *)addr); if (!area || end > (unsigned long)area->addr + area->size || - !(area->flags & VM_ALLOC)) + !(area->flags & VM_ALLOC)) { + + /* + * When rodata_full is set, or pagealloc debug is enabled, + * the linear address is mapped with NO_BLOCK_MAPPINGS or + * NO_CONT_MAPPINGS flags, so splitting is never needed. + */ + if (rodata_full || debug_pagealloc_enabled()) + return __change_memory_common(start, size, set_mask, + clear_mask); return -EINVAL; - - if (!numpages) - return 0; + } /* * If we are manipulating read-only permissions, apply the same -- 2.7.4