Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3411075imm; Sun, 24 Jun 2018 20:18:11 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIrRJhlropQ7fBBz3+XVhDMuKuLzjs2YBGNMVzY09uqZxuVGYMBGjqbzgtF8ANyAdmwMrn1 X-Received: by 2002:a65:6210:: with SMTP id d16-v6mr8975329pgv.272.1529896691675; Sun, 24 Jun 2018 20:18:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529896691; cv=none; d=google.com; s=arc-20160816; b=iBdovVMvI1kQX4R4xHVppKw6AxSFkF7id7nRJhfHnmJfVCsiTU8bhIzROuL+nfaXY1 NZF7+5pw56g4YLQBifkrQn7mMcmdTr08QGBacsqtG8ZgbBeliICOIo+/4X8HOWbAZ5/A +gTBVyB0Ae4UbwVr+mb9yFrQg8NW7kEk1xZ59ZCm3JY0eO5D/i7YMhtrUUIG13l2rOiT eCmxOn2llYfOtGPa3YdfbHBa+hikivJo5dTxUstCFCbFpxoE0VvZZPooF4BRYHuYzx16 dAe2NNwdt7vb+jzCjc1WRGorup9/VxwVbhO10WyEv2aAmK3s22BCrxK9vIKOHacy4+MV jbsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=cjVRprMM3p1JHRPzFgig0L8w6Z0u8aL0xGUiA8K2JDU=; b=f4EZV87QTFM24gbMdaXBtHJSli4n5LU0QN+0I1Ah0Co88a8VMz+vrk2HJWC4Q0Oo/6 2LcOk9zBSgpjxDsqe1zWhXrOgvvdF8TvHfkimXE+Dd+kuWv75Ho6WB8lnEByCAj+kp+P +0nZLBYePwIhKiL8ytEWyAhVBP56WfwJ1BhV2ZcC+c3qP4LtqJcWNyPILj9JhIq5RiIE uttbgx97xcT4Q+R301vNfP8Xrc4ZvV1zveEnIoYiCqH+RvSGjMITh3WlfRtPgS2AVgk+ iki/dxF/ngwM/cDNMu9WOi4S4Y4CEYz/ZdojRHqRkWB/7JS9YlQ4AzfMk4k0T4zULHlZ g0Tg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 67-v6si8066450pgb.107.2018.06.24.20.17.57; Sun, 24 Jun 2018 20:18:11 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752859AbeFYDRK (ORCPT + 99 others); Sun, 24 Jun 2018 23:17:10 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:49128 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752405AbeFYDRJ (ORCPT ); Sun, 24 Jun 2018 23:17:09 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0211887928; Mon, 25 Jun 2018 03:17:09 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-8-18.pek2.redhat.com [10.72.8.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id B80D5111DCF7; Mon, 25 Jun 2018 03:17:00 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org, mingo@kernel.org, lcapitulino@redhat.com, keescook@chromium.org, tglx@linutronix.de Cc: x86@kernel.org, hpa@zytor.com, fanc.fnst@cn.fujitsu.com, yasu.isimatu@gmail.com, indou.takao@jp.fujitsu.com, douly.fnst@cn.fujitsu.com, Baoquan He Subject: [PATCH v2 0/2] x86/boot/KASLR: Skip specified number of 1GB huge pages when do physical randomization Date: Mon, 25 Jun 2018 11:16:54 +0800 Message-Id: <20180625031656.12443-1-bhe@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 25 Jun 2018 03:17:09 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 25 Jun 2018 03:17:09 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'bhe@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is a regression bug fix. Luiz's team reported that 1GB huge page allocation will get one less 1GB page randomly when KASLR is enabled. On their KVM guest with 4GB RAM, which only has one good 1GB huge page, they found the 1GB huge page allocation sometime failed with below kernel option adding. default_hugepagesz=1G hugepagesz=1G hugepages=1 This is because kernel may be randomized into those good 1GB huge pages. And also on those bare-metal machines with larger memory, one less 1GB huge page might be seen with KASLR enabled than 'nokaslr' specified case. It's also because that kernel might be randomized into one of those good 1GB huge pages. The solution in this patchset is to skip specified number of GB huge pages when do kernel physical randomization. If the specified number of GB huge pages is bigger than amount of good GB huge pages which system can provide, it's consistent with the current huge page implementation. v1->v2: There are several code style problems and typos which were pointed out by Ingo, fix them in this patchset. Baoquan He (2): x86/boot/KASLR: Add two functions for 1GB huge pages handling x86/boot/KASLR: Skip specified number of 1GB huge pages when do physical randomization arch/x86/boot/compressed/kaslr.c | 96 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 91 insertions(+), 5 deletions(-) -- 2.13.6