From patchwork Thu Oct 19 06:52:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abbott Liu X-Patchwork-Id: 10016121 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E4BB5600CC for ; Thu, 19 Oct 2017 07:04:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D6E6728B78 for ; Thu, 19 Oct 2017 07:04:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB58D28C03; Thu, 19 Oct 2017 07:04:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6D63528B78 for ; Thu, 19 Oct 2017 07:04:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=y0/7wgX2tZwBZNwgIxrj4TI0wzcEhlDDLsb3WytyjEs=; b=qyt0OasbZZafL1 WMsBO4sR1oD9NTjtE56H/PW7QA8AY/LWkI95IBaLmYztQnCF+nxrARh2Uj2DZ8eEvFwN7d0APfWNc LVkcJFMtHlqlJEHbMuausHnpP6Nu/UiYuBVR4s8i5Se8SYJjTHc0OkCqwSl1LfHTjgigcZ9e+zZM/ bAqy9msJdyBXpB4LZgjRAlJ/LAtF3IsLx0zHTs15UPfqEq82HppA6ocUwt/l+48asX5hiUTT+VOw8 1WPJxhbfWyTP8vNDzA1cIg/fiy9AdKg5DWIHz1oVKGG2nGIMJY0pfnYbGvHL8BES7rZOKCDHDyUUl J3UCgJFGXHbbIclft+6g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e54sO-0008HO-Vt; Thu, 19 Oct 2017 07:04:21 +0000 Received: from szxga02-in.huawei.com ([45.249.212.188]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e54sG-0008Cx-Rm for linux-arm-kernel@lists.infradead.org; Thu, 19 Oct 2017 07:04:19 +0000 Received: from 172.30.72.55 (EHLO DGGEMM403-HUB.china.huawei.com) ([172.30.72.55]) by dggrg02-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id AXE43824; Thu, 19 Oct 2017 14:53:07 +0800 (CST) Received: from DGGEMM510-MBX.china.huawei.com ([169.254.12.139]) by DGGEMM403-HUB.china.huawei.com ([10.3.20.211]) with mapi id 14.03.0301.000; Thu, 19 Oct 2017 14:52:54 +0800 From: "Liuwenliang (Lamb)" To: Dmitry Osipenko , "linux@armlinux.org.uk" , "aryabinin@virtuozzo.com" , "afzal.mohd.ma@gmail.com" , "f.fainelli@gmail.com" , "labbott@redhat.com" , "kirill.shutemov@linux.intel.com" , "mhocko@suse.com" , "cdall@linaro.org" , "marc.zyngier@arm.com" , "catalin.marinas@arm.com" , "akpm@linux-foundation.org" , "mawilcox@microsoft.com" , "tglx@linutronix.de" , "thgarnie@google.com" , "keescook@chromium.org" , "arnd@arndb.de" , "vladimir.murzin@arm.com" , "tixy@linaro.org" , "ard.biesheuvel@linaro.org" , "robin.murphy@arm.com" , "mingo@kernel.org" , "grygorii.strashko@linaro.org" Subject: Re: [PATCH 01/11] Initialize the mapping of KASan shadow memory Thread-Topic: [PATCH 01/11] Initialize the mapping of KASan shadow memory Thread-Index: AQHTQmokZ5ece1W6v0+GfMCIss4ZwaLeylqAgAvXCwA= Date: Thu, 19 Oct 2017 06:52:54 +0000 Message-ID: References: <20171011082227.20546-1-liuwenliang@huawei.com> <20171011082227.20546-2-liuwenliang@huawei.com> <31b16c9d-48c7-bc0a-51d1-cc6cf892329b@gmail.com> In-Reply-To: <31b16c9d-48c7-bc0a-51d1-cc6cf892329b@gmail.com> Accept-Language: en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.57.90.243] MIME-Version: 1.0 X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090203.59E84BD5.0079, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=169.254.12.139, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 902178c3f21c86561dbedc3fb2c69c2e X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171019_000413_327398_D781E3AC X-CRM114-Status: UNSURE ( 8.38 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "opendmb@gmail.com" , "linux-kernel@vger.kernel.org" , "kasan-dev@googlegroups.com" , Zengweilin , "linux-mm@kvack.org" , Dailei , "glider@google.com" , "dvyukov@google.com" , Jiazhenghua , "linux-arm-kernel@lists.infradead.org" , Heshaoliang 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 On 2017.10.12 7:43AM Dmitry Osipenko [mailto:digetx@gmail.com] wrote: >Shouldn't all __pgprot's contain L_PTE_MT_WRITETHROUGH ? > >[...] > >-- >Dmitry Thanks for your review. I'm sorry that my replay is so late. I don't think L_PTE_MT_WRITETHROUGH is need for all arm soc. So I think kasan's mapping can use PAGE_KERNEL which can be initialized for different arm soc and __pgprot(pgprot_val(PAGE_KERNEL) | L_PTE_RDONLY)). I don't think the mapping table flags in kasan_early_init need be changed because of the follow reason: 1) PAGE_KERNEL can't be used in early_kasan_init because the pgprot_kernel which is used to define PAGE_KERNEL doesn't be initialized. 2) all of the kasan shadow's mapping table is going to be created again in kasan_init function. All what I say is: I think only the mapping table flags in kasan_init function need to be changed into PAGE_KERNEL or __pgprot(pgprot_val(PAGE_KERNEL) | L_PTE_RDONLY)). Here is the code, I has already tested: --- a/arch/arm/mm/kasan_init.c +++ b/arch/arm/mm/kasan_init.c @@ -124,7 +124,7 @@ pte_t * __meminit kasan_pte_populate(pmd_t *pmd, unsigned long addr, int node) void *p = kasan_alloc_block(PAGE_SIZE, node); if (!p) return NULL; - entry = pfn_pte(virt_to_pfn(p), __pgprot(_L_PTE_DEFAULT | L_PTE_DIRTY | L_PTE_XN)); + entry = pfn_pte(virt_to_pfn(p), __pgprot(pgprot_val(PAGE_KERNEL))); set_pte_at(&init_mm, addr, pte, entry); } return pte; @@ -253,7 +254,7 @@ void __init kasan_init(void) set_pte_at(&init_mm, KASAN_SHADOW_START + i*PAGE_SIZE, &kasan_zero_pte[i], pfn_pte( virt_to_pfn(kasan_zero_page), - __pgprot(_L_PTE_DEFAULT | L_PTE_DIRTY | L_PTE_XN | L_PTE_RDONLY))); + __pgprot(pgprot_val(PAGE_KERNEL) | L_PTE_RDONLY))); memset(kasan_zero_page, 0, PAGE_SIZE); cpu_set_ttbr0(orig_ttbr0); flush_cache_all();