From patchwork Mon Mar 21 17:38:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 64121 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp1544871lbc; Mon, 21 Mar 2016 10:40:23 -0700 (PDT) X-Received: by 10.98.89.22 with SMTP id n22mr47200638pfb.55.1458582023708; Mon, 21 Mar 2016 10:40:23 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id pz7si4279172pab.216.2016.03.21.10.40.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Mar 2016 10:40:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dkim=neutral (body hash did not verify) header.i=@linaro.org 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 1ai3nW-0007kv-8D; Mon, 21 Mar 2016 17:39:22 +0000 Received: from mail-wm0-x235.google.com ([2a00:1450:400c:c09::235]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ai3nS-0007fQ-7H for linux-arm-kernel@lists.infradead.org; Mon, 21 Mar 2016 17:39:19 +0000 Received: by mail-wm0-x235.google.com with SMTP id r129so60440807wmr.1 for ; Mon, 21 Mar 2016 10:38:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0030uVNV82aE9F2crDqzuYO/605+YpUszrMqDlZEXyg=; b=dxjbgkhYwmOCIzhmF+VT/mUPqztO6LTf2hjWRzysCejlSa4vlXTtwFxU0JAsP7BuYU aOISofjEzzwkWK0vo2QYbrc8TSHaJKy0CJ9mtdN/ZqY1bOKXwIyEsITVJdNlBpScACZL /bSbMyFIIjbqh2GxTpTsQVklUCA99eaLn7MXs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0030uVNV82aE9F2crDqzuYO/605+YpUszrMqDlZEXyg=; b=cGK93WiIY8Voj3jvFVXnk2KZlLbEC9FzdMi0aDDS1jNyHK8R7qj64dlMwhbMmpRaY5 +ySqJddSu/65Jq9nTLpRXNyis5cp4yje3IG98WVvaIsGG6E6M6TQUrKfcgKPzaG2h5xH /8wZZW0prr6Tk5VyTTKwPgbW3V4Zhqp5c2tZO3GIAXx7cBzfxbum0Cect9eKbj3C1Mv6 NzsQ42N9z6ewlj0DrD73AQ0JW9w+TA1KfOTS3SrWey9+BB5J67oShY8QgH+0fY0ybARv WY41wi0Ffhyp7RkRr7YYBAVsInOdL+UN4UHDsu4fFOxa+8H4+U8IZhvpO/nAGaRd+3Yc f5Qg== X-Gm-Message-State: AD7BkJJNj3YQvwUp9fOKl0DaGY6SftR4rGJcXL1lmEhizsUQcZiPll6OhyaYjSqWQKVksbeh X-Received: by 10.28.224.132 with SMTP id x126mr15959359wmg.88.1458581935362; Mon, 21 Mar 2016 10:38:55 -0700 (PDT) Received: from localhost.localdomain (106.202.154.77.rev.sfr.net. [77.154.202.106]) by smtp.gmail.com with ESMTPSA id g203sm13430927wmf.23.2016.03.21.10.38.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 21 Mar 2016 10:38:54 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com Subject: [PATCH 2/2] arm64: choose memstart_addr based on minimum sparsemem section alignment Date: Mon, 21 Mar 2016 18:38:44 +0100 Message-Id: <1458581924-14462-2-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1458581924-14462-1-git-send-email-ard.biesheuvel@linaro.org> References: <1458581924-14462-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160321_103918_497028_0FC961B8 X-CRM114-Status: GOOD ( 10.87 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:400c:c09:0:0:0:235 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ard Biesheuvel MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org This reverts commit 36e5cd6b897e, which was needed in v4.5 and before to ensure the correct alignment of the base of the vmemmap region. However, since commit a7f8de168ace ("arm64: allow kernel Image to be loaded anywhere in physical memory"), the alignment of memstart_addr itself can be freely chosen, which means we can choose it such that additional rounding in the definition of vmemmap is no longer necessary. So redefine ARM64_MEMSTART_ALIGN in terms of the minimal alignment required by sparsemem, and drop the redundant rounding in the definition of vmemmap. Note that the net result of this change is that we align memstart_addr to 1 GB in all cases, since sparsemem is mandatory on arm64. Signed-off-by: Ard Biesheuvel --- arch/arm64/include/asm/kernel-pgtable.h | 17 +++++++++++++++-- arch/arm64/include/asm/pgtable.h | 5 ++--- 2 files changed, 17 insertions(+), 5 deletions(-) -- 1.9.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/arch/arm64/include/asm/kernel-pgtable.h b/arch/arm64/include/asm/kernel-pgtable.h index 5c6375d8528b..a144ae2953a2 100644 --- a/arch/arm64/include/asm/kernel-pgtable.h +++ b/arch/arm64/include/asm/kernel-pgtable.h @@ -19,6 +19,7 @@ #ifndef __ASM_KERNEL_PGTABLE_H #define __ASM_KERNEL_PGTABLE_H +#include /* * The linear mapping and the start of memory are both 2M aligned (per @@ -87,9 +88,21 @@ * in the page tables: 32 * PMD_SIZE (16k granule) */ #ifdef CONFIG_ARM64_64K_PAGES -#define ARM64_MEMSTART_ALIGN SZ_512M +#define ARM64_MEMSTART_BITS 29 #else -#define ARM64_MEMSTART_ALIGN SZ_1G +#define ARM64_MEMSTART_BITS 30 +#endif + +/* + * sparsemem imposes an additional requirement on the alignment of + * memstart_addr, due to the fact that the base of the vmemmap region + * has a direct correspondence, and needs to appear sufficiently aligned + * in the virtual address space. + */ +#if defined(CONFIG_SPARSEMEM_VMEMMAP) && ARM64_MEMSTART_BITS < SECTION_SIZE_BITS +#define ARM64_MEMSTART_ALIGN (1UL << SECTION_SIZE_BITS) +#else +#define ARM64_MEMSTART_ALIGN (1UL << ARM64_MEMSTART_BITS) #endif #endif /* __ASM_KERNEL_PGTABLE_H */ diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 989fef16d461..aa6106ac050c 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -32,14 +32,13 @@ * VMALLOC_END: extends to the available space below vmmemmap, PCI I/O space, * fixed mappings and modules */ -#define VMEMMAP_SIZE ALIGN((1UL << (VA_BITS - PAGE_SHIFT)) * sizeof(struct page), PUD_SIZE) +#define VMEMMAP_SIZE ALIGN((1UL << (VA_BITS - PAGE_SHIFT - 1)) * sizeof(struct page), PUD_SIZE) #define VMALLOC_START (MODULES_END) #define VMALLOC_END (PAGE_OFFSET - PUD_SIZE - VMEMMAP_SIZE - SZ_64K) #define VMEMMAP_START (VMALLOC_END + SZ_64K) -#define vmemmap ((struct page *)VMEMMAP_START - \ - SECTION_ALIGN_DOWN(memstart_addr >> PAGE_SHIFT)) +#define vmemmap ((struct page *)VMEMMAP_START - (memstart_addr >> PAGE_SHIFT)) #define FIRST_USER_ADDRESS 0UL