From patchwork Thu Dec 18 22:48:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 5516371 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 49AFCBEEA8 for ; Thu, 18 Dec 2014 22:51:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5CDC420435 for ; Thu, 18 Dec 2014 22:51:04 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5AE1720396 for ; Thu, 18 Dec 2014 22:51:03 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Y1js5-0001IM-Qt; Thu, 18 Dec 2014 22:48:37 +0000 Received: from smtp.codeaurora.org ([198.145.11.231]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Y1js2-0001DS-KP for linux-arm-kernel@lists.infradead.org; Thu, 18 Dec 2014 22:48:35 +0000 Received: from smtp.codeaurora.org (localhost [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 4FFF7140BAA; Thu, 18 Dec 2014 22:48:13 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 486) id 3D498140BAC; Thu, 18 Dec 2014 22:48:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from [10.42.111.116] (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: lauraa@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id D83FA140BAB; Thu, 18 Dec 2014 22:48:11 +0000 (UTC) Message-ID: <549359AA.8000006@codeaurora.org> Date: Thu, 18 Dec 2014 14:48:10 -0800 From: Laura Abbott User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: "zhichang.yuan" , Will Deacon Subject: Re: [PATCH v0] ARMv8:mm:Support the DEBUG_PAGEALLOC References: <1414382488-916-1-git-send-email-zhichang.yuan@linaro.org> <544EC65E.4060009@codeaurora.org> <544F338A.2060600@linaro.org> <545168C9.4010206@codeaurora.org> <5490E123.8060904@linaro.org> In-Reply-To: <5490E123.8060904@linaro.org> X-Virus-Scanned: ClamAV using ClamSMTP X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141218_144834_744416_0F54616B X-CRM114-Status: GOOD ( 26.31 ) X-Spam-Score: -0.0 (/) Cc: catalin.marinas@arm.com, dsaxena@linaro.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Hi, On 12/16/2014 5:49 PM, zhichang.yuan wrote: > Hi, Laura, > > > On 2014?10?30? 06:23, Laura Abbott wrote: >> On 10/27/2014 11:11 PM, zhichang.yuan wrote: >>> Hi, Laura, >>> >>> Thanks for your comments! >>> >>> >>> >> ... >>>>> +} >>>>> + >>>>> +void kernel_map_pages(struct page *page, int numpages, int enable) >>>>> +{ >>>>> + unsigned long start_addr, end_addr, addr; >>>>> + unsigned int level; >>>>> + >>>>> + pte_t *kpte; >>>>> + pteval_t old_pval, new_pval; >>>>> + >>>>> + int i, counter = 0; >>>>> + >>>>> + /*no highmem in ARMv8. */ >>>>> + addr = start_addr = (unsigned long)page_address(page); >>>>> + end_addr = start_addr + (numpages << PAGE_SHIFT); >>>>> + >>>>> + for (i = 0; i < numpages; addr += PAGE_SIZE, i++) { >>>>> + kpte = lookup_kaddress(addr, &level); >>>>> + /* >>>>> + * skip the memory holes. it is impossible if the input >>>>> + * parameter is valid. >>>>> + */ >>>>> + if (unlikely(!kpte || pte_none(*kpte))) { >>>>> + pr_err("Have no kernel linear mapping for 0x%0lx\n", addr); >>>>> + break; >>>>> + } >>>>> + >>>>> + if (level != PG_LEVEL_PAGE) { >>>>> + pr_err("Page entry for 0x%0lx is not PAGE LEVEL(%d)\n", >>>>> + addr, level); >>>>> + break; >>>>> + } >>>>> + >>>>> + old_pval = pte_val(*kpte); >>>>> + new_pval = (enable) ? (old_pval | PTE_VALID) : >>>>> + (old_pval & (~PTE_VALID)); >>>>> + if (unlikely(new_pval == old_pval)) { >>>>> + pr_warn("Page %s: same pte value at 0x%llx", >>>>> + (enable) ? "alloc" : "free", old_pval); >>>>> + continue; >>>>> + } >>>>> + >>>>> + set_pte(kpte, __pte(new_pval)); >>>>> + counter++; >>>>> + } >>>>> + >>>>> + if (counter) >>>>> + flush_tlb_kernel_range(start_addr, end_addr); >>>>> +} >>>> >>>> We already have some of this infrastructure to set page attributes >>>> in arch/arm64/mm/pageattr.c . We should be leveraging that for >>>> kernel_map_pages. >>>> >>> There is no pageattr.c for ARMv8. In X86, it exists. >>> Do you mean pmd_modify? >>> >> >> It was added to the kernel fairly recently >> >> https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=11d91a770f1fff44dafdf88d6089a3451f99c9b6 >> > > I browsed the pageattr.c, the functions which modify the page table entry attributes are good. But the base > function, change_memory_common, is limited for module memory space. It will make the relative functions are > not common. Can we do some changes on it? > > thanks, > -Zhichang > Yes, we should be able to adjust the bounds check there. The checks there are currently broken[1] anyways. I'd suggest changing it to something like this (to be folded in) ----8<---- From 8cc4cd7c72fc5ada01e44d943d00e0209c4304aa Mon Sep 17 00:00:00 2001 From: Laura Abbott Date: Thu, 18 Dec 2014 14:45:19 -0800 Subject: [PATCH] arm64: Update set memory_bounds_check Change-Id: Id2f308c44d49117aca18fe725f8f2f33ae6a5075 Signed-off-by: Laura Abbott --- arch/arm64/mm/pageattr.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) -- [1] http://lists.infradead.org/pipermail/linux-arm-kernel/2014-December/307839.html -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation diff --git a/arch/arm64/mm/pageattr.c b/arch/arm64/mm/pageattr.c index bb0ea94..0516cbc 100644 --- a/arch/arm64/mm/pageattr.c +++ b/arch/arm64/mm/pageattr.c @@ -51,8 +51,13 @@ static int change_memory_common(unsigned long addr, int numpages, WARN_ON_ONCE(1); } - if (!is_module_address(start) || !is_module_address(end - 1)) - return -EINVAL; + if (!IS_ENABLED(DEBUG_PAGEALLOC)) { + if (start < MODULES_VADDR || start >= MODULES_END) + return -EINVAL; + + if (end < MODULES_VADDR || end >= MODULES_END) + return -EINVAL; + } data.set_mask = set_mask; data.clear_mask = clear_mask;