From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C909DC433F5 for ; Wed, 15 Dec 2021 14:54:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=N4+ACTUcjdXzSDFpzVuD58CvnfxNBbFvMuzkzP9vYLQ=; b=43Q+eIzUFbXsw9 1L1NqfBZ0daVWyk+EbOZMkuRsrX7f4/Gxl/ntDBW1g0PIgdbiY1rt4ysPcB6DSPTVTld8D8jNzO18 jkDTYVuOi/WL/k07CV2iOzYe2w/OD67M8/aO8+ywnlTZGB994G/105pIv7IopDebckQyy7LtSyxZW aM+QDK0+N0nZVqB5mT3QSD+HVVQvYnkZYvhJTXWqTI/jICV1k+hxOa9ZyH9iKCxN1wd5EGwgDkJEo oaAUGVTAvGf/UBphvvVa6yK/uON0yn3qcMQUK7jznephicC/eM4RZBQWexwqIj6vaQL4erewwkLuq wFyJkzVsTQWjkH9G59Jg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mxVeU-001CuM-DJ; Wed, 15 Dec 2021 14:53:06 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mxVeA-001CnO-4r for linux-arm-kernel@lists.infradead.org; Wed, 15 Dec 2021 14:52:47 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1F8CD618D8; Wed, 15 Dec 2021 14:52:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 336EAC34605; Wed, 15 Dec 2021 14:52:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1639579962; bh=mMEdTSiCXI2/gNbdn0NhpP6Yp7tsuHGHYuKH3FWRy7Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qFSwH3bu/LNJsiAj19ow4b3fcpmJeqchtyyjwQ2+ffbZeLCiYQWo0uGJWLx+wOJ1a sqfv3Cuo4YGPbkmXmyvBcNlszEikGf2omFzbLeQD1N2n21nIGEqJL2r1eO3jVRR7LE wjpVE7SCGs2w0v8D9kyeZXDvvbXTBCwX9Khd6vQBu1XWVXvSGKNYWHQdUaHFjFedap GvbaQtERKUofFuBZQ6yY8BX4T7xDjRqMMQugT7fo9VsqfxDqVXNJbgEx8vITU0VUHB xT4S8X7ryAsBDyGWg2Hr4dyh5t8GirDYDJ/pEPBw2sdoaZrddeKJTb8gHhCBe9NHkq tb3wUQEiaJQPQ== From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, Ard Biesheuvel , Kefeng Wang Subject: [PATCH 2/2] arm64: kaslr: take free space at start of DRAM into account Date: Wed, 15 Dec 2021 15:52:28 +0100 Message-Id: <20211215145228.953702-3-ardb@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211215145228.953702-1-ardb@kernel.org> References: <20211215145228.953702-1-ardb@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1566; h=from:subject; bh=mMEdTSiCXI2/gNbdn0NhpP6Yp7tsuHGHYuKH3FWRy7Q=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBhugErk8ESr7+G5JW57VahbRAnEf9fSG/q/IBsNAKf YCoVh9mJAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCYboBKwAKCRDDTyI5ktmPJNZGC/ 4kHU8l61NKiwxHN20oiTMkTWXkbfTtRo8VaUFKdurPqyrHMCVwDeGv6KUsi10u1rAwzyTWVkHLzvUq SSZRe9EWMzKoQ/4k0+qOCRZiyGym2UYmYbvo8Ne+MTdxk30TcsSOhtTJA8a5IwCA+d7P/jBGPsUnwG vKwta4aXQEyN3amF4RurZ4cgrXgl2TkdlT/kQw7jCiCHzAiWlFFm0dHM5he/iH0ySsEwpQ+opJzP/u EH/xpllcy/Y0SJs3HjCnlfEZ/yYHdHEJq2yQmYnCH7UqCUahqSl9AEA3hM+bc84MsIitkhMiGtgTLS v0gfOduPu5uiPEvOi2aQuwoaZCyUYP/RfodYKC0fxYurEzRmQwTehxbJPjERNJVxSJxK5XZmr8HzbH bqLy3OzzheHFRacbQwfDnwyhpX4TFlQ/+hz4a+9zecGxELbfUTS42HjeABcjBFz72XIn4RLrrazOgd vuGoHMh/C5wl1hmmCcAk6FcVhft/DzCL7skhTKwqaDBP0= X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211215_065246_254233_93C98B3E X-CRM114-Status: GOOD ( 13.93 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Commit 97d6786e0669 ("arm64: mm: account for hotplug memory when randomizing the linear region") limited the randomization range of the linear region substantially, or even eliminated it entirely for configurations where the VA range equals or exceeds the maximum PA range, even in cases where most of the PA range is not occupied to begin with. In such cases, we can recover this ability to some extent by taking advantage of the reduced value of ARM64_MEMSTART_ALIGN, and disregarding the physical region below the first memblock, allowing us to randomize the placement of physical DRAM within the linear region even in cases where the PArange equals the virtual range. NOTE: this relies on the assumption that hotpluggable memory will never appear below the lowest boot-time memblock memory region, but only above. Signed-off-by: Ard Biesheuvel --- arch/arm64/mm/init.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index a8834434af99..b3ffb356bc8b 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -288,7 +288,8 @@ void __init arm64_memblock_init(void) int parange = cpuid_feature_extract_unsigned_field( mmfr0, ID_AA64MMFR0_PARANGE_SHIFT); s64 range = linear_region_size - - BIT(id_aa64mmfr0_parange_to_phys_shift(parange)); + BIT(id_aa64mmfr0_parange_to_phys_shift(parange)) + + memblock_start_of_DRAM(); /* * If the size of the linear region exceeds, by a sufficient -- 2.30.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel