Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp145274imj; Thu, 14 Feb 2019 17:18:28 -0800 (PST) X-Google-Smtp-Source: AHgI3Iaa12wD8NhFsesmUhk8c/iiJkgnxOrh2H97VMqkT1JX9Ww9ZyjLvtEzZ6cdoNAzgVZKfttk X-Received: by 2002:aa7:8042:: with SMTP id y2mr7119801pfm.39.1550193508251; Thu, 14 Feb 2019 17:18:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550193508; cv=none; d=google.com; s=arc-20160816; b=Tu5511oIVZHQ9QD+TFY3Y+oOW2mtjI05EY4SrvYUtraYpJvN/J7zpPHgaVP8Orpquy GfARMXk9FKGMD9TwfeHqOEb8K8KCwlKwsGTaBa2UY0xIhLe26VU8fUa67GDHf50mfWCh HDhOzepHGtqBjypkk2HcxGU8WprJHnniUrN+sC2K7V3D56sa5wS4uTm1/clK82xOtihf mmkZRKPTJ9Lt5WgwfYanmGCGSoSsRHp3RSP1ydZr+9I5ElxZxzO9cFVo1iAlySY8KiFM /d5rzdloBevbiktmGqMKXK8hxGW8VxD8cuKhNby/nH5ZxHqLEfx6VpCh+cKFKX57KDK+ gFsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ANs0KXyVl1itNeqe46nRlAralSJekcIJY9UIIgxw9oQ=; b=f6Jfq2WY9/0yGD4kcnQ2H/jeGnhB1wmDYA9HqtRNwE1VhbLkX/eJVTFDNHAAzYOsA4 9+nYH8KWyVmZ12cW/BdpjvEFuDbgoG1WplkghKiJdOPkRQrTBapB4Nl6j1jCUzb4qgAU tbtAsHd3t3swS9Glm9gfdXC6i2au1PytxTYysJDDQdxzwR8Sro3XhoHwScrsAv48J8qQ Pudn/SjbTnzfthnQ3nn2OE+3rJHTKmBTudxsqSKt/upMGKmPm+JLodwEETWpTg6KY4VE 520tM4Girv+Wb/tOdqQv+fc+zccqnGiqubpFmvMoNm/dF/fSRz+IeaLlGjQMUHSwft3m pUCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rbguojB5; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b5si3893090pfi.286.2019.02.14.17.18.11; Thu, 14 Feb 2019 17:18:28 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rbguojB5; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437580AbfBNRj4 (ORCPT + 99 others); Thu, 14 Feb 2019 12:39:56 -0500 Received: from mail-qt1-f193.google.com ([209.85.160.193]:42348 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2437540AbfBNRjy (ORCPT ); Thu, 14 Feb 2019 12:39:54 -0500 Received: by mail-qt1-f193.google.com with SMTP id b8so7761224qtr.9 for ; Thu, 14 Feb 2019 09:39:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=ANs0KXyVl1itNeqe46nRlAralSJekcIJY9UIIgxw9oQ=; b=rbguojB5aTsDrlXZcUbRrsjwObxyS5Iz6JOvp6dXq3lmeKjgB0bilmvGMMSKW3osgv +ex059Ss749IyBSgFkYyAVRO4AatmXwB6d4BhhlRZ/2rXuyaqDi15BpKRp5XCKJjhjqH 9Ew3KetirOR2RDRYmUB7bB/cyOK8aWGNAnoqnj5hyryLskF7uagL1C7gfkinH/K1JucZ 3SuF6QDpqGHvIE1meKS61z7448WJD2TzGX6XsHicGif1DGqYg9wm/Ptjtc5ep6wqSPVr uUO/LZvaMmDO5CuDawuEy0WR0oP5GXFA5OOyufOGFjLDLuMvY8436GNOApUgf/67m990 xwKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=ANs0KXyVl1itNeqe46nRlAralSJekcIJY9UIIgxw9oQ=; b=a5w+ChE1TbSlCcPApOhlnfykQz/Sx4jv/w7L+uQ4OLr0TTrkDyK2cpNFelQH5o35r/ HMyeo/nPNQRSJRVIKmtheKr1HIfzgwXrEK7v3vt+elFswGHs82c2Lg5zNRYX+uhb3fOe bwHy5+ShkFONiwtVfFZbNsz/C/GxnK1xV6QxSE5mKf0vUxB7BQG4xwdHwlpjes0EgkhN FjVo4POEHlA1YmW+cin0gpDqTHaWQFeLJ80afkKMzCZbFKU+6ftpaWTKvEcgUVM82GO7 9lBVFC4lA/6PjBU3/th/kdUONBK0DD/UR0tx6Rr8d6c7NV31OiiM5ARwXr8l4Q+USgLD tmdA== X-Gm-Message-State: AHQUAubCDuX8NzI9mNUqSHEoR6Sby1FyTJfb2HiihhVdqz5hVWW+8LmI ZqP5fwX3+uCJliP38P4bTw== X-Received: by 2002:a0c:98c8:: with SMTP id g8mr4004554qvd.161.1550165993403; Thu, 14 Feb 2019 09:39:53 -0800 (PST) Received: from gabell (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id o4sm1639140qke.30.2019.02.14.09.39.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Feb 2019 09:39:52 -0800 (PST) Date: Thu, 14 Feb 2019 12:39:46 -0500 From: Masayoshi Mizuma To: Baoquan He Cc: Borislav Petkov , Ingo Molnar , "H. Peter Anvin" , "kirill@shutemov.name Thomas Gleixner" , x86@kernel.org, Masayoshi Mizuma , linux-kernel@vger.kernel.org, Chao Fan Subject: Re: [PATCH v2] x86/mm: Adjust the padding size for KASLR Message-ID: <20190214173945.utbawbfbdjkw7dif@gabell> References: <20190212013118.28203-1-msys.mizuma@gmail.com> <20190214101236.GE14858@MiWiFi-R3L-srv> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190214101236.GE14858@MiWiFi-R3L-srv> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Baoquan, Thank you for your review. On Thu, Feb 14, 2019 at 06:12:36PM +0800, Baoquan He wrote: > Hi Masa, > > On 02/11/19 at 08:31pm, Masayoshi Mizuma wrote: > > From: Masayoshi Mizuma > > > > The system sometimes crashes while memory hot-adding on KASLR > > enabled system. The crash happens because the regions pointed by > > kaslr_regions[].base are overwritten by the hot-added memory. > > > > It happens because of the padding size for kaslr_regions[].base isn't > > enough for the system whose physical memory layout has huge space for > > memory hotplug. kaslr_regions[].base points "actual installed > > memory size + padding" or higher address. So, if the "actual + padding" > > is lower address than the maximum memory address, which means the memory > > address reachable by memory hot-add, kaslr_regions[].base is destroyed by > > the overwritten. > > > > address > > ^ > > |------- maximum memory address (Hotplug) > > | ^ > > |------- kaslr_regions[0].base | Hotadd-able region > > | ^ | > > | | padding | > > | V V > > |------- actual memory address (Installed on boot) > > | > > > > Fix it by getting the maximum memory address from SRAT and store > > the value in boot_param, then set the padding size while kaslr > > initializing if the default padding size isn't enough. > > Thanks for the effort on fixing this KASLR&hotplug conflict issue. > I roughly go through this patch, seems three parts are contained: > > 1) Wrap up the SRAT travesing code into subtable_parse(); > 2) Add a field max_addr in struct boot_params, and get the max address > from SRAT and write it into boot_params->max_addr; > 3) Add kaslr_padding() to adjust the padding size for the direct > mapping. > > So could you split them into three patches for better reviewing? Yes, I will split into the three. > > Another thing is for the 3rd part, I also queued several patches in my > local branch, they are code bug fix patches, and several clean up > patches suggested by Ingo and Kirill. They can be found here: > > https://github.com/baoquan-he/linux/commits/kaslar-mm-bug-fix > > In my local patches, Ingo suggested opening code get_padding(), and > about the SGI UV bug, he suggested adding another function to calculate > the needed size for the direct mapping region. So I am wondering if you > can rebase the part 3 on top of it, or you add a new function to > calculate the size for the direct mapping region so that I can rebase on > top of your patch and reuse it. > > What do you think about it? OK, I will rebase my patches on top of your patch. Could you add CCing me when you post your patches? Thanks! Masa