Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp12650ima; Thu, 31 Jan 2019 21:51:55 -0800 (PST) X-Google-Smtp-Source: ALg8bN61IO/bcE6wV+RRnb/Am9QO/GtATP82DUM5Kot96hS71PjgvY0YMR54Z0of19+65vU8Cakr X-Received: by 2002:a17:902:7882:: with SMTP id q2mr39090308pll.305.1549000315791; Thu, 31 Jan 2019 21:51:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549000315; cv=none; d=google.com; s=arc-20160816; b=t5x5WCeBEkTWK+sU1BGyNAO9rgQMztXt/HILrCtXEZoatLjKfmoNgsVFU/fFWq+pHK DNyuhh6Rc3mJsn1//Q+mwZ61TP37sy4wEmoKD/0iO3hNgqmCdfcOJ41E1ORd7dvdGtbi TjQXb6SYGPfalsclINJz7Dq3QSc0rPgPlYoh6/PbO4lY/gccvCk+6X/Ww/fE1pbJLqSn a1SyikXK3+/J5o8kqMkHs4/O/NU8/xWvc8usUeiIE4WMnAEixQQtAPrZm4s32VawVh3R sVTsVY2q7qfQcq3IF0GVlJBn6xx0Y0oeaL/Paklm6pRdlshUWhs8Kwyny3ewiTQqyQhm axkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=vBrJwIczXlw/NOnrTfK+W9GEf+lzDnxRPyhNE3LNVCg=; b=Gg7nyvhjRDzrtWnz5Mpx7BCR6k2JkLYsW2QpRWtX2EaK89uFsrXRbErs7HgROCwnKq 2SjEgjFO/krsyBUThMIn6jFa0ieOIa/xiIFGC0C+PqhFaUeri74ZrBQEAgPCd4cByMX3 /JdrIU2XUZ1ERhb6ilzcvMJEr05SA3rY7jsWkld/4TLg1ZR6DDQPPIux0yyi5ATs6kAD WtF1dTy1CbzJ6VpzXdwUEpIGjXvtzomUsbgzCtun1Zm0yTPWzMxMcQ56fNHSUeYPV5c1 8rSkIQIQCele8JRcGeKgmNnGphmpGk1CR6rEAn3Dem+ZsI3jiBJPJvYPhxi5GNauFXF0 IMag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 128si4615004pfe.4.2019.01.31.21.51.39; Thu, 31 Jan 2019 21:51:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726696AbfBAFva (ORCPT + 99 others); Fri, 1 Feb 2019 00:51:30 -0500 Received: from mail.cn.fujitsu.com ([183.91.158.132]:15511 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725854AbfBAFva (ORCPT ); Fri, 1 Feb 2019 00:51:30 -0500 X-IronPort-AV: E=Sophos;i="5.56,547,1539619200"; d="scan'208";a="53383465" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 01 Feb 2019 13:51:25 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (unknown [10.167.33.83]) by cn.fujitsu.com (Postfix) with ESMTP id 90ACE4C4BB95; Fri, 1 Feb 2019 13:51:24 +0800 (CST) Received: from TSAO.g08.fujitsu.local (10.167.226.60) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.408.0; Fri, 1 Feb 2019 13:51:24 +0800 From: Cao jin To: , CC: , , , , , , Subject: [PATCH] x86/boot: minor improvement in kaslr Date: Fri, 1 Feb 2019 13:48:53 +0800 Message-ID: <20190201054853.28541-1-caoj.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.17.2 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.226.60] X-yoursite-MailScanner-ID: 90ACE4C4BB95.AB9CD X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: caoj.fnst@cn.fujitsu.com X-Spam-Status: No Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org comments fix: input_size is ZO image size which just don't count .bss in, but has .text, .data, etc; drop unecessary alignment: minimum is either 512M or output, both are CONFIG_PHYSICAL_ALIGN aligned(output is aligned in head_32/64.S). But mention it in earlier comments. Signed-off-by: Cao jin --- arch/x86/boot/compressed/kaslr.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c index 9ed9709d9947..a947c5aba34e 100644 --- a/arch/x86/boot/compressed/kaslr.c +++ b/arch/x86/boot/compressed/kaslr.c @@ -360,7 +360,7 @@ static void handle_mem_options(void) * (i.e. it does not include its run size). This range must be avoided * because it contains the data used for decompression. * - * [input+input_size, output+init_size) is [_text, _end) for ZO. This + * [input+input_size, output+init_size) is [_bss, _end) for ZO. This * range includes ZO's heap and stack, and must be avoided since it * performs the decompression. * @@ -763,9 +763,6 @@ static unsigned long find_random_phys_addr(unsigned long minimum, return 0; } - /* Make sure minimum is aligned. */ - minimum = ALIGN(minimum, CONFIG_PHYSICAL_ALIGN); - if (process_efi_entries(minimum, image_size)) return slots_fetch_random(); @@ -831,8 +828,8 @@ void choose_random_location(unsigned long input, /* * Low end of the randomization range should be the - * smaller of 512M or the initial kernel image - * location: + * smaller of 512M or the initial kernel image location. + * Should be aligned to CONFIG_PHYSICAL_ALIGN. */ min_addr = min(*output, 512UL << 20); -- 2.17.0