From patchwork Fri Jul 6 08:56:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 10511095 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 B3306600CA for ; Fri, 6 Jul 2018 08:56:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A39FA28470 for ; Fri, 6 Jul 2018 08:56:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 951FD284CE; Fri, 6 Jul 2018 08:56:35 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 2938528470 for ; Fri, 6 Jul 2018 08:56:35 +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:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Reply-To:Content-ID:Content-Description :Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=OOWwOwU/YPzr+om0fPfoT3cnbHhgqH+1EgJmCHKuyAA=; b=VgOtrEG6Rf1NMO ehY/zz3p5NiUEudJALnh5H3RHNMnOlP+4QwsmRDw5ZTC3fk8p3iAQehpiBo/TrsrE1UYOrKQYknDf S2ih0u+1zKfE9qm6LIc5pnJSp1Wwjgbodb4XDPuUza8Diyzp9Nl8GBK7Lx3CQc/ORqKUX20G5ybtX fnq27zXDLoSdHG87P4V76rU3UmlwA1t3U+XLmDGT40JMKLVzZv2S09LY3V3W6hcy5/lrOcJZW3id6 icgtFfusdwadPgyjwe0zifCPiJWGspKb2kNc7Z+rjO95MR+PNZr0+Up5RpGtEw8KNKZ4WQ5zmI9Z7 KoQYLXmxDlrhsWsopwhg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fbMXY-0005iz-7U; Fri, 06 Jul 2018 08:56:32 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fbMXV-0005g2-Ay for linux-arm-kernel@lists.infradead.org; Fri, 06 Jul 2018 08:56:30 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 25BAFED1; Fri, 6 Jul 2018 01:56:19 -0700 (PDT) Received: from [10.1.206.34] (melchizedek.cambridge.arm.com [10.1.206.34]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0D6E83F2EA; Fri, 6 Jul 2018 01:56:17 -0700 (PDT) Subject: Re: [PATCH v3 1/5] arm64/mm: Introduce init_pg_dir To: Jun Yao , linux-arm-kernel@lists.infradead.org References: <20180702111659.25570-1-yaojun8558363@gmail.com> <20180702111659.25570-2-yaojun8558363@gmail.com> From: James Morse Message-ID: Date: Fri, 6 Jul 2018 09:56:16 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180702111659.25570-2-yaojun8558363@gmail.com> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180706_015629_394372_33DE5EE1 X-CRM114-Status: GOOD ( 23.74 ) 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: catalin.marinas@arm.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, suzuki.poulose@arm.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 Hi Jun, On 02/07/18 12:16, Jun Yao wrote: > Add init_pg_dir to vmlinux.lds.S and boiler-plate > clearing/cleaning/invalidating it in head.S. With just this patch I get a weird link error from ld[0]: aarch64-linux-gnu-ld:./arch/arm64/kernel/vmlinux.lds:90 cannot move location counter backwards (from ffff000008fa8000 to fffefffff8ead000) make[2]: *** [/home/morse/linux/Makefile:1015: vmlinux] Error 1 make[1]: *** [Makefile:146: sub-make] Error 2 make: *** [Makefile:24: __sub-make] Error 2 Where line 90 is your INIT_DIR macro. I'm going to guess that this is because SWAPPER_DIR_SIZE is defined in terms of '_end', and that this can't be used inside '.init.data'. Moving it outside the '.init.data' section fixes this [1]. We only need this to be within the __init_begin/__init_end markers that free_initmem() uses, which it still is after this change. A side effect of this is we shouldn't label the C externs '__initdata' as they are no longer in the '.init.data' section. (looks like I was wrong about sparse being able to pick that up...) (Could we make it clearer INIT_DIR is related to the page tables, e.g. INIT_PG_TABLES? INIT_DIR makes me think of the rootfs for some reason) Otherwise some boring nits: > diff --git a/arch/arm64/include/asm/assembler.h b/arch/arm64/include/asm/assembler.h > index 0bcc98dbba56..414fb167e3e7 100644 > --- a/arch/arm64/include/asm/assembler.h > +++ b/arch/arm64/include/asm/assembler.h > @@ -456,6 +456,29 @@ USER(\label, ic ivau, \tmp2) // invalidate I line PoU > b.ne 9998b > .endm > > +/* > + * clear_page - clear one page > + */ > + .macro clear_page, start:req > +9996: stp xzr, xzr, [\start], #16 > + stp xzr, xzr, [\start], #16 > + stp xzr, xzr, [\start], #16 > + stp xzr, xzr, [\start], #16 > + tst \start, #(PAGE_SIZE - 1) (This will match any page-aligned end address, so this macro only clears one page if you give it a page aligned start address. Just something for us to remember.) > + b.ne 9996b > + .endm The rest of this file uses the white-space $instruction[tab]$arg, $arg, here you mix and match. > +/* > + * clear_pages - clear contiguous pages > + */ > + .macro clear_pages, start:req, count:req > +9997: cbz \count, 9998f > + clear_page \start > + sub \count, \count, #1 > + b 9997b > +9998: > + .endm Both callers of this have a start/end address, you may as well move the 'count' calculation in here to save duplicating it. With the link-error fixed: Reviewed-by: James Morse Thanks, James > diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S > index 605d1b60469c..d4fc68286a49 100644 > --- a/arch/arm64/kernel/vmlinux.lds.S > +++ b/arch/arm64/kernel/vmlinux.lds.S > @@ -68,6 +68,12 @@ jiffies = jiffies_64; > #define TRAMP_TEXT > #endif > > +#define INIT_DIR \ > + . = ALIGN(PAGE_SIZE); \ > + init_pg_dir = .; \ > + . += SWAPPER_DIR_SIZE; \ > + init_pg_end = .; > + > /* > * The size of the PE/COFF section that covers the kernel image, which > * runs from stext to _edata, must be a round multiple of the PE/COFF > @@ -168,6 +174,7 @@ SECTIONS > CON_INITCALL > SECURITY_INITCALL > INIT_RAM_FS > + INIT_DIR > *(.init.rodata.* .init.bss) /* from the EFI stub */ > } > .exit.data : { > [0] aarch64-linux-gnu-ld --version GNU ld (GNU Binutils for Debian) 2.30.90.20180627 Copyright (C) 2018 Free Software Foundation, Inc. This program is free software; you may redistribute it under the terms of the GNU General Public License version 3 or (at your option) a later version. This program has absolutely no warranty. [1] Move INIT_DIR outside the .init.data section diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S index d4fc68286a49..169abc3d01c8 100644 --- a/arch/arm64/kernel/vmlinux.lds.S +++ b/arch/arm64/kernel/vmlinux.lds.S @@ -167,6 +167,8 @@ SECTIONS __inittext_end = .; __initdata_begin = .; + INIT_DIR + .init.data : { INIT_DATA INIT_SETUP(16) @@ -174,7 +176,6 @@ SECTIONS CON_INITCALL SECURITY_INITCALL INIT_RAM_FS - INIT_DIR *(.init.rodata.* .init.bss) /* from the EFI stub */ } .exit.data : {