From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755839AbbCBO7d (ORCPT ); Mon, 2 Mar 2015 09:59:33 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55096 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755819AbbCBO72 (ORCPT ); Mon, 2 Mar 2015 09:59:28 -0500 From: Baoquan He To: hpa@zytor.com, yinghai@kernel.org, keescook@chromium.org, vgoyal@redhat.com, luto@amacapital.net, akpm@linux-foundation.org, tglx@linutronix.de, mingo@redhat.com Cc: linux-kernel@vger.kernel.org, Baoquan He Subject: [PATCH v2 4/9] introduce struct slot_area to manage randomization slot info Date: Mon, 2 Mar 2015 22:58:25 +0800 Message-Id: <1425308310-2318-5-git-send-email-bhe@redhat.com> In-Reply-To: <1425308310-2318-1-git-send-email-bhe@redhat.com> References: <1425308310-2318-1-git-send-email-bhe@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Kernel is expected to be randomly reloaded anywhere in the whole physical memory area, it could be near 64T at most. In this case there could be about 4*1024*1024 randomization slots. Hence the old slot array will cost too much memory and can not be used any more. Here introduce struct slot_area to manage randomization slot info in one contiguous memory area excluding the avoid area. slot_areas is used to store all slot area info. Since setup_data is a linked list, could contain many datas by pointer to point one by one, excluding them will split RAM memory into many smaller areas, here only take the first 100 slot areas if too many of them. Signed-off-by: Baoquan He --- arch/x86/boot/compressed/aslr.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/arch/x86/boot/compressed/aslr.c b/arch/x86/boot/compressed/aslr.c index 6a22129..26610a2 100644 --- a/arch/x86/boot/compressed/aslr.c +++ b/arch/x86/boot/compressed/aslr.c @@ -215,8 +215,20 @@ static bool mem_avoid_overlap(struct mem_vector *img) static unsigned long slots[CONFIG_RANDOMIZE_BASE_MAX_OFFSET / CONFIG_PHYSICAL_ALIGN]; + +struct slot_area { + unsigned long addr; + int num; +}; + +#define MAX_SLOT_AREA 100 + +static struct slot_area slot_areas[MAX_SLOT_AREA]; + static unsigned long slot_max; +static unsigned long slot_area_index; + static void slots_append(unsigned long addr) { /* Overflowing the slots list should be impossible. */ -- 1.9.3