From patchwork Wed Mar 30 12:25:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 64698 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp2564997lbc; Wed, 30 Mar 2016 05:27:36 -0700 (PDT) X-Received: by 10.98.13.130 with SMTP id 2mr12689216pfn.97.1459340856536; Wed, 30 Mar 2016 05:27:36 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id z12si6249604pas.77.2016.03.30.05.27.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Mar 2016 05:27:36 -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; dkim=neutral (body hash did not verify) header.i=@linaro.org; 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; dmarc=fail (p=NONE dis=NONE) header.from=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 1alFCp-0006Xn-5f; Wed, 30 Mar 2016 12:26:39 +0000 Received: from mail-wm0-x233.google.com ([2a00:1450:400c:c09::233]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1alFCW-0006Pg-2w for linux-arm-kernel@lists.infradead.org; Wed, 30 Mar 2016 12:26:21 +0000 Received: by mail-wm0-x233.google.com with SMTP id 191so87491779wmq.0 for ; Wed, 30 Mar 2016 05:25:59 -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=Y7+ySKK262uwaMRo6s7vbkeS8aVaBL6YAdLlHA1CI/M=; b=QhjOqRrzBHTCXF2yPEhyHOAPy1NAYYfCICdwiAtFkyQIQfu8SuTadnrG4OvGmruu6/ M850DtdUv6LGsa8JuOSKayecUccrIkhXun2ntJC3zWOszJYktqWy6uxfZqDVJct0r/U1 tnCHSQqCVr9cobFEgosQD9djPBvItRiIxusyw= 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=Y7+ySKK262uwaMRo6s7vbkeS8aVaBL6YAdLlHA1CI/M=; b=eDmyjQnO14yeHpYmdYGR1a7uesuF+4UzNFZvjWHw+gP9hRZ9fJzCMLNK377hACxYHh qUReUdqGe2b1e+Lr54DnaEF9WDkuzLRt/pe1eiJnQ3NCtT+39BQF75nhaw8BldU0GSEm rNsQeCbpBnXkJnzyOEciEkc0ZZ+QLMT4aFpOxglHabbehhCgO1YpltaL0s0tf2MkXbpE TfGgJ4TNM83TOWN6aSZnnS8+KAdcJPBl8tJiQPjMOzy7HVof2r7JTQ93OB/n97pZeBYr rr/ZhiVk7GFE+axtDbFaz1pfFE/pc+r02JIedR7VqhjhU7JVhBdbLcqOouTUsH4AydEr gjlA== X-Gm-Message-State: AD7BkJLV1eg+mfz/hLTxwsQ0icseC4/DjWgLUqXut0CfBCp8G9cWf1viZYrRvgiDamaSEayl X-Received: by 10.194.83.101 with SMTP id p5mr9212495wjy.141.1459340758517; Wed, 30 Mar 2016 05:25:58 -0700 (PDT) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id u14sm19502511wmu.8.2016.03.30.05.25.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 30 Mar 2016 05:25:57 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com Subject: [PATCH v2 1/3] arm64/mm: ensure memstart_addr remains sufficiently aligned Date: Wed, 30 Mar 2016 14:25:46 +0200 Message-Id: <1459340748-14975-2-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1459340748-14975-1-git-send-email-ard.biesheuvel@linaro.org> References: <1459340748-14975-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160330_052620_406237_099B5C94 X-CRM114-Status: GOOD ( 14.86 ) 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:233 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_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 -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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: mark.rutland@arm.com, will.deacon@arm.com, Ard Biesheuvel MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org After choosing memstart_addr to be the highest multiple of ARM64_MEMSTART_ALIGN less than or equal to the first usable physical memory address, we clip the memblocks to the maximum size of the linear region. Since the kernel may be high up in memory, we take care not to clip the kernel itself, which means we have to clip some memory from the bottom if this occurs, to ensure that the distance between the first and the last usable physical memory address can be covered by the linear region. However, we fail to update memstart_addr if this clipping from the bottom occurs, which means that we may still end up with virtual addresses that wrap into the userland range. So increment memstart_addr as appropriate to prevent this from happening. Signed-off-by: Ard Biesheuvel --- arch/arm64/mm/init.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) -- 2.5.0 _______________________________________________ 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/mm/init.c b/arch/arm64/mm/init.c index ec4db8dfbe3a..82ced5fa1e66 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -190,8 +190,12 @@ void __init arm64_memblock_init(void) */ memblock_remove(max_t(u64, memstart_addr + linear_region_size, __pa(_end)), ULLONG_MAX); - if (memblock_end_of_DRAM() > linear_region_size) - memblock_remove(0, memblock_end_of_DRAM() - linear_region_size); + if (memstart_addr + linear_region_size < memblock_end_of_DRAM()) { + /* ensure that memstart_addr remains sufficiently aligned */ + memstart_addr = round_up(memblock_end_of_DRAM() - linear_region_size, + ARM64_MEMSTART_ALIGN); + memblock_remove(0, memstart_addr); + } /* * Apply the memory limit if it was set. Since the kernel may be loaded