From patchwork Sun Oct 22 12:12:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abbott Liu X-Patchwork-Id: 10021695 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 EE6DE60234 for ; Sun, 22 Oct 2017 12:18:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E1D34287C5 for ; Sun, 22 Oct 2017 12:18:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D630A287DA; Sun, 22 Oct 2017 12:18:51 +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=unavailable 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 3D26E287C5 for ; Sun, 22 Oct 2017 12:18:50 +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=7ycPCIrfojzayNgPkbixEVJ234p/Zd7rLZ/27In6E/0=; b=GDVM2GHsMdtEY0 LT2JsKdoUSJ85UyMH5+aWnZOTWxOuBJKJSaDxuQaefYgaz3HfcnW82pGjfdMR8sq/jbki5/jgO1f6 yQphl+ahdiv5/e9syIi6Ioqs5dNHt25EEbShiHk15qWzjPAbpeYRM0Z+vCtZ8w4ZUjQ0BDZcY6ARW AkXA/8X3gw/OhmqfnnEfcU1GysBv4uDVCZx9dlWsdZwWyJf6KglO4eaSi5AQ0wb2TXP1tUJv1zv8o wVVnm0fT8DpkpwQUDDK8oDo8P7SS1BAI0FvNpV9YvG9qPy3z0GDiEyY7UlRHQ5ilKaqRbvR2Pr7pv uIWPAeGxA1wVe37Yu/Vg==; 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 1e6FD9-0000yG-Bi; Sun, 22 Oct 2017 12:18:35 +0000 Received: from szxga01-in.huawei.com ([45.249.212.187]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e6FCx-0000wA-2m for linux-arm-kernel@lists.infradead.org; Sun, 22 Oct 2017 12:18:33 +0000 Received: from 172.30.72.55 (EHLO DGGEMM404-HUB.china.huawei.com) ([172.30.72.55]) by dggrg01-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id AYO71091; Sun, 22 Oct 2017 20:13:10 +0800 (CST) Received: from DGGEMM510-MBX.china.huawei.com ([169.254.12.139]) by DGGEMM404-HUB.china.huawei.com ([10.3.20.212]) with mapi id 14.03.0301.000; Sun, 22 Oct 2017 20:12:59 +0800 From: "Liuwenliang (Lamb)" To: Russell King - ARM Linux Subject: Re: [PATCH 04/11] Define the virtual space of KASan's shadow region Thread-Topic: [PATCH 04/11] Define the virtual space of KASan's shadow region Thread-Index: AQHTQmojF4blZnsX90GevfXlGaKSjKLit+AAgAOfd2D//453AIABXTkAgANh5ICAAZcQcA== Date: Sun, 22 Oct 2017 12:12:58 +0000 Message-ID: References: <20171011082227.20546-5-liuwenliang@huawei.com> <201710141957.mbxeZJHB%fengguang.wu@intel.com> <20171019124357.GY20805@n2100.armlinux.org.uk> In-Reply-To: <20171019124357.GY20805@n2100.armlinux.org.uk> 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.59EC8B5B.0085, 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: b7edbcd560109b755f3087462a3e2cb3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171022_051831_923896_CFB60CC0 X-CRM114-Status: GOOD ( 15.02 ) 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: "tixy@linaro.org" , "mhocko@suse.com" , "grygorii.strashko@linaro.org" , "catalin.marinas@arm.com" , "linux-mm@kvack.org" , "glider@google.com" , "afzal.mohd.ma@gmail.com" , "mingo@kernel.org" , "cdall@linaro.org" , "f.fainelli@gmail.com" , kbuild test robot , "mawilcox@microsoft.com" , "kasan-dev@googlegroups.com" , Dailei , "linux-arm-kernel@lists.infradead.org" , "aryabinin@virtuozzo.com" , "labbott@redhat.com" , "vladimir.murzin@arm.com" , "keescook@chromium.org" , "arnd@arndb.de" , "marc.zyngier@arm.com" , Zengweilin , "opendmb@gmail.com" , Heshaoliang , "tglx@linutronix.de" , "dvyukov@google.com" , Ard Biesheuvel , "linux-kernel@vger.kernel.org" , "kbuild-all@01.org" , Jiazhenghua , "akpm@linux-foundation.org" , "robin.murphy@arm.com" , "thgarnie@google.com" , "kirill.shutemov@linux.intel.com" 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 Tue, Oct 19, 2017 at 20:41 17PM +0000, Russell King - ARM Linux: >On Mon, Oct 16, 2017 at 11:42:05AM +0000, Liuwenliang (Lamb) wrote: >> On 10/16/2017 07:03 PM, Abbott Liu wrote: > >arch/arm/kernel/entry-armv.S:348: Error: selected processor does not support `movw r1, >> #:lower16:((((0xC0000000-0x01000000)>>3)+((0xC0000000-0x01000000)-(1<<29))))' in ARM mode >> >arch/arm/kernel/entry-armv.S:348: Error: selected processor does not support `movt r1, >> #:upper16:((((0xC0000000-0x01000000)>>3)+((0xC0000000-0x01000000)-(1<<29))))' in ARM mode >> >> Thanks for building test. This error can be solved by following code: >> --- a/arch/arm/kernel/entry-armv.S >> +++ b/arch/arm/kernel/entry-armv.S >> @@ -188,8 +188,7 @@ ENDPROC(__und_invalid) >> get_thread_info tsk >> ldr r0, [tsk, #TI_ADDR_LIMIT] >> #ifdef CONFIG_KASAN >> - movw r1, #:lower16:TASK_SIZE >> - movt r1, #:upper16:TASK_SIZE >> + ldr r1, =TASK_SIZE >> #else >> mov r1, #TASK_SIZE >> #endif > >We can surely do better than this with macros and condition support - >we can build-time test in the assembler whether TASK_SIZE can fit in a >normal "mov", whether we can use the movw/movt instructions, or fall >back to ldr if necessary. I'd rather we avoided "ldr" here where >possible. Thanks for your review. I don't know why we need to avoided "ldr". The "ldr" maybe cause the performance fall down, but it will be very limited, and as we know the performance of kasan version is lower than the normal version. And usually we don't use kasan version in our product, we only use kasan version when we want to debug some memory corruption problem in laboratory(not not in commercial product) because the performance of kasan version is lower than normal version. So I think we can accept the influence of the performance by using "ldr" here. On Tue, Oct 19, 2017 at 20:44 17PM +0000, Russell King - ARM Linux: >On Tue, Oct 17, 2017 at 11:27:19AM +0000, Liuwenliang (Lamb) wrote: >> ---c0a3b198: b6e00000 .word 0xb6e00000 //TASK_SIZE:0xb6e00000 > >It's probably going to be better all round to round TASK_SIZE down >to something that fits in an 8-bit rotated constant anyway (like >we already guarantee) which would mean this patch is not necessary. Thanks for you review. If we enable CONFIG_KASAN, we need steal 130MByte(0xb6e00000 ~ 0xbf000000) from user space. If we change to steal 130MByte(0xb6000000 ~ 0xbe200000) , the 14MB of user space is going to be wasted. I think it is better to to use "ldr" whose influence to the system are very limited than to waste 14MB user space by chaned TASK_SIZE from 0xb6e00000 from 0xb6000000. If TASK_SIZE is an 8-bit rotated constant, the compiler can convert "ldr rx,=TASK_SIZE" into mov rx, #TASK_SIZE If TASK_SIZE is not an 8-bit rotated constant, the compiler can convert "ldr rx,=TASK_SIZE" into ldr rx, [pc,xxx], So we can use ldr to replace mov. Here is the code which is tested by me: diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S index f9efea3..00a1833 100644 --- a/arch/arm/kernel/entry-armv.S +++ b/arch/arm/kernel/entry-armv.S @@ -187,12 +187,7 @@ ENDPROC(__und_invalid) get_thread_info tsk ldr r0, [tsk, #TI_ADDR_LIMIT] -#ifdef CONFIG_KASAN - movw r1, #:lower16:TASK_SIZE - movt r1, #:upper16:TASK_SIZE -#else - mov r1, #TASK_SIZE -#endif + ldr r1, =TASK_SIZE str r1, [tsk, #TI_ADDR_LIMIT] str r0, [sp, #SVC_ADDR_LIMIT] @@ -446,7 +441,8 @@ ENDPROC(__fiq_abt) @ if it was interrupted in a critical region. Here we @ perform a quick test inline since it should be false @ 99.9999% of the time. The rest is done out of line. - cmp r4, #TASK_SIZE + ldr r0, =TASK_SIZE + cmp r4, r0 blhs kuser_cmpxchg64_fixup #endif #endif