Received: by 10.223.164.202 with SMTP id h10csp4865530wrb; Tue, 21 Nov 2017 00:39:25 -0800 (PST) X-Google-Smtp-Source: AGs4zMZNnxjEnp8mydr8oOrBJReMvrOxosbuKHhBzMiot3sx9FZyuFqnidVrQqXdPNmHB5YL2CVm X-Received: by 10.84.244.75 with SMTP id e11mr16681202plt.18.1511253565470; Tue, 21 Nov 2017 00:39:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511253565; cv=none; d=google.com; s=arc-20160816; b=KqrJ+CMmsnUfo8OUqao+uwHeErO76a0pX8vSMqWNtj0JiSAskgNFXTwsgc93JslM5o 5FAJjIfJcbTwSS8DyzPhKD7sc6kR/bt+H/k2OQECz1Z9RzehFcuEJtd68UAjragRjDKt OwN+thwxnYMgie6pr6y7PM8twMEDmMDXTnxG1gICHlM/uT8cpKoQG+ESCZ33YSowsb+P QluCuDJrpL3uLAWYgrH0ymqLyxNXWNK5p1jqzlQumD4rfb2GFkTHmB/LdNztudUUBrre AvlbJyRebpud+LRZdhz3bK0B9s+FQQQ2bPoL/hwiwTj9GKpm+khpM7RgnE8DCeCJQ8xd 17Vg== 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:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:arc-authentication-results; bh=18/r5pjPlcGv/QAPXBAeP5ESULLEzUOSdd0exVFfS7s=; b=RuWZbKMZ9Zt4mZFXBuEtDVu9ncsDlbhwtFEl48t8PjObk3VLATIh4x5BE0PSMYEOgX vw1j1CCqVXqqziPxZDoy2yjOwzxe/UFBynKZ0Mc/vEdYagyVlcMfJpKTpyTBdeaiW4YS htWdc2XYcb1oVq1Csf+2bouwG5q7OE19gCgygTtpNaAxKWf5tsdd31ubt1p4gh2JFF3u qsAiUA9pPzjz5GwVKR09tes3Ya22flAMtjog1VKp8EHg3CiKjUMzCjbY86HeOCAks/X1 zLaL2+inSMVOPHdRCcB2mr1Txp00Kw/4zHslhlTCBx30wCf7ODFfXMLJRBKWnp/zGvle Ybkg== 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 l17si10350128pgn.160.2017.11.21.00.39.14; Tue, 21 Nov 2017 00:39:25 -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 S1751634AbdKUIih (ORCPT + 73 others); Tue, 21 Nov 2017 03:38:37 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:10961 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751382AbdKUIic (ORCPT ); Tue, 21 Nov 2017 03:38:32 -0500 Received: from 172.30.72.58 (EHLO DGGEMS411-HUB.china.huawei.com) ([172.30.72.58]) by dggrg04-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DLG26853; Tue, 21 Nov 2017 16:37:57 +0800 (CST) Received: from [127.0.0.1] (10.142.193.64) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.361.1; Tue, 21 Nov 2017 16:37:31 +0800 Subject: Re: [PATCH] arm64: kaslr: Fix kaslr end boundary of virt addr To: , , , , References: <1511235853-8407-1-git-send-email-puck.chen@hisilicon.com> CC: , , , , , , From: Chen Feng Message-ID: <5A13E5BD.70000@hisilicon.com> Date: Tue, 21 Nov 2017 16:37:17 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <1511235853-8407-1-git-send-email-puck.chen@hisilicon.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.142.193.64] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090204.5A13E5E5.01AD,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 814208103658f0a000697dedc392176f Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2017/11/21 11:44, Chen Feng wrote: > With kaslr and kasan enable both, I got the follow issue. > > [ 16.130523s]kasan: reg->base = 100000000, phys_end =1c0000000,start = ffffffff40000000, end = ffffffc000000000 > [ 16.142517s]___alloc_bootmem_nopanic:257 > [ 16.148284s]__alloc_memory_core_early:63, addr = 197fc7fc0 > [ 16.155670s]__alloc_memory_core_early:65, virt = ffffffffd7fc7fc0 > [ 16.163635s]__alloc_memory_core_early:67, toshow = ffffff8ffaff8ff8 > [ 16.171783s]__alloc_memory_core_early:69, show_phy = ffffffe2649f8ff8 > [ 16.180145s]Unable to handle kernel paging request at virtual address ffffff8ffaff8ff8 > [ 16.189971s]pgd = ffffffad9c507000 > [ 16.195220s][ffffff8ffaff8ff8] *pgd=0000000197fc8003, *pud=0000000197fc8003 > > *reg->base = 100000000, phys_end =1c0000000,start = ffffffff40000000, end = ffffffc000000000* > > memstart_addr 0 > ARM64_MEMSTART_ALIGN 0x40000000 > memstart_offset_seed 0xffc7 > PHYS_OFFSET = 0 - memstart_addr = 0 - 3E40000000 = FFFFFFC1C0000000 > > reg->base = 0x100000000 -> 0xffffffff40000000 > phys_end = 0x1c0000000 -> 0xffffffc000000000 This is confused, end less than start. > > And In memblock it use "start_addr + size" as the end addr. So in function kasan_init, > if the start >= end, it will not map the hole block address. But the memory in this > block is valid. And it can be allocated as well. > > So donot use the last memory region. Changing "range = range / ARM64_MEMSTART_ALIGN + 1" to > range = range / ARM64_MEMSTART_ALIGN; > > Signed-off-by: Chen Feng > Signed-off-by: Chen Xiang > --- > arch/arm64/mm/init.c | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c > index 716d122..60112c0 100644 > --- a/arch/arm64/mm/init.c > +++ b/arch/arm64/mm/init.c > @@ -267,11 +267,8 @@ void __init arm64_memblock_init(void) > * margin, the size of the region that the available physical > * memory spans, randomize the linear region as well. > */ > - if (memstart_offset_seed > 0 && range >= ARM64_MEMSTART_ALIGN) { > - range = range / ARM64_MEMSTART_ALIGN + 1; > - memstart_addr -= ARM64_MEMSTART_ALIGN * > - ((range * memstart_offset_seed) >> 16); > - } > + if (memstart_offset_seed > 0 && range >= ARM64_MEMSTART_ALIGN) > + memstart_addr -= (range * memstart_offset_seed) >> 16; > } Sorry, here is not align to ARM64_MEMSTART_ALIGN Should be: if (memstart_offset_seed > 0 && range >= ARM64_MEMSTART_ALIGN) { range = range / ARM64_MEMSTART_ALIGN; memstart_addr -= ARM64_MEMSTART_ALIGN * ((range * memstart_offset_seed) >> 16); } > > /* > From 1584645711853213335@xxx Tue Nov 21 03:45:15 +0000 2017 X-GM-THRID: 1584645711853213335 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread