Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp958614ybl; Fri, 6 Dec 2019 08:58:08 -0800 (PST) X-Google-Smtp-Source: APXvYqzw1BIclxCop1j3/ETWmXyUMBW6lnO1uRYgcAXW/2Q5oT8x0ECMjILX31EfGYURkVFPvxmB X-Received: by 2002:a05:6808:197:: with SMTP id w23mr13514561oic.46.1575651487904; Fri, 06 Dec 2019 08:58:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575651487; cv=none; d=google.com; s=arc-20160816; b=UMYpYBEPpUvYEgy+xLp4vRxro3giw2kSl3N1uXCwfeCYRCXC+Mka0JNWQzB3hTCNTh cunfPXx0h8Oeyk64RhTacJCjjiT0kkfsgWkVRfill2nrHIarrB/Hx55MzsLt2k7mj4s7 FErJcxSmCt89ExPkNnLLq6Ujkpc21j+di/LOheu68hOC73dISI52JxlW1xpclRAm4Tio aQ2mjBAajS/CZTt5OjKFfjTXZ0GEFdEh8J9fhlxt4EJk5DFdg8PDjLRMNagJOj00Z89x c8YD9XybFSW15XIfnwIMiDxxQzKtPbeTkLkIyugssXuUKyV58YUdGk5uW3ipFkuShLCU T3rQ== 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 :dkim-signature; bh=hycUEsK4+AHVYJBhD0DGv1lWVDhbwtIkRIrkRMdi4BI=; b=wEo46PCHiVBn85AyK0kXncBJKdJ4xo0EyO6yQfoU5iZQ0UHQUvjfkVQTjbS6uaX8IJ 8KfEiZvr4tbNtOqmZft4zeaUC99Swo4i+fZbmnTNiiXLgjSBuNILQXBL0v/sqigFTg6Z AY2jSnVsZbu1qDfTPy7cRXQjF4D7Pe8aHron/eD8pfudDFzfLKzYVZsgndIrJFERz3NC Z3l4O5F4vCsHS87T6HXNkHZttvIBPaHZLP7LOqiO4iY4eTatCQUdi/do/zDpRBEX41ie ruA2l4Aklz0+3DASENTbTnGwhF2hP3Zka8VMqq7P3RKBI+iMO95RIcH+2zslbmGSinOm FKcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NiaLVM8p; 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 r21si6923051otd.276.2019.12.06.08.57.55; Fri, 06 Dec 2019 08:58:07 -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=NiaLVM8p; 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 S1726325AbfLFQ52 (ORCPT + 99 others); Fri, 6 Dec 2019 11:57:28 -0500 Received: from mail-qv1-f66.google.com ([209.85.219.66]:44549 "EHLO mail-qv1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726261AbfLFQ52 (ORCPT ); Fri, 6 Dec 2019 11:57:28 -0500 Received: by mail-qv1-f66.google.com with SMTP id n8so128900qvg.11 for ; Fri, 06 Dec 2019 08:57:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=hycUEsK4+AHVYJBhD0DGv1lWVDhbwtIkRIrkRMdi4BI=; b=NiaLVM8pj5F89CXXsG58cxHyab7XSzCbczynY/FlweyL/djwzUeygdt83U7DaCAzvq MOKOitUyeiMLikGNQsLtCsmqK+CGHGdxBUYU3GnEGKnKqAAtDPn0oDIF496f8luJ7/jh BHNGuDIsZqsscFzSzdVWpPaUa8alT+EOM5GfuizfqDpmWG1AnUWZIBtl4OgNC4M9gli1 xbZj6Ko9L8oUMnZRqTQjdF2uWsAejcR388w0+yz0+rUSffeJK381CA4WyK3tJ9MoOJ8H 4TXujn3psfQGeAHbZnw5LvacFS0EuH5QWsRPVfYwN8clAqUYkBWvQSjw7XwO/FklJtK8 lSyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=hycUEsK4+AHVYJBhD0DGv1lWVDhbwtIkRIrkRMdi4BI=; b=scQjBhZ42bmhNtS9h32baq/4G0ktb4QnRzjE8XSZ21B+NEU5QpQuVpo595Ttg7T8Ur tTClcUmvlWfbYeepTkShcEobOBelNp3LfcS/1GaJKKLRNYxKMe5DLovnUqJQr29UkYf4 3EKRlSvsHNyEiobcwkJGIZBdjN3mTD1jQwG7zlUD6xZ1CZ49b2GMQFxZabW2gn32nOEr Slobo0wfVlSgEWpnGirgS/huzp/ysBm479kP6+VXgPpUf98HJGyttFtXNTD90rl/nZZN ZrycQXZcVr4O7qi05dpCIeo2B/8PkdC+9yaTHyKjzCOcQdXWsSwbEITegF9zrVKsVguV jMJw== X-Gm-Message-State: APjAAAWOdsZfBGAUkMDj5CFnqloctdHVq+8HcRpnGxP4tgX8uMDfcJ4h CfUHjnch/9wGy/bh9wrLHA== X-Received: by 2002:a0c:e9cf:: with SMTP id q15mr13408287qvo.137.1575651447514; Fri, 06 Dec 2019 08:57:27 -0800 (PST) Received: from gabell.bos.redhat.com (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id y28sm6531373qtk.65.2019.12.06.08.57.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2019 08:57:27 -0800 (PST) From: Masayoshi Mizuma To: Borislav Petkov , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, Baoquan He Cc: Masayoshi Mizuma , Masayoshi Mizuma , linux-kernel@vger.kernel.org Subject: [PATCH v6 0/4] Adjust the padding size for KASLR Date: Fri, 6 Dec 2019 11:57:03 -0500 Message-Id: <20191206165707.20806-1-msys.mizuma@gmail.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Changelog: v6: - Add documents to top of calc_direct_mapping_size() to explain why the size of direct mapping area is configured as boot_params.max_addr (0004 patch). - Add Acked-by from Baoquan (0004 patch). Masayoshi Mizuma (4): x86/boot: Wrap up the SRAT traversing code into subtable_parse() x86/boot: Add max_addr field in struct boot_params x86/boot: Get the max address from SRAT x86/mm/KASLR: Adjust the padding size for the direct mapping. Documentation/x86/zero-page.rst | 4 ++ arch/x86/boot/compressed/acpi.c | 42 +++++++++++++++--- arch/x86/include/uapi/asm/bootparam.h | 2 +- arch/x86/mm/kaslr.c | 63 ++++++++++++++++++++------- 4 files changed, 88 insertions(+), 23 deletions(-) -- 2.20.1