Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1269347ybl; Thu, 12 Dec 2019 12:21:53 -0800 (PST) X-Google-Smtp-Source: APXvYqz6fRG+y830cHihII36MOsUD1biS9MkXNyAVs38j2kBlafbshVmyZo5fkOfwCPh0rnYqsX0 X-Received: by 2002:a05:6830:1bf1:: with SMTP id k17mr10073219otb.101.1576182112960; Thu, 12 Dec 2019 12:21:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576182112; cv=none; d=google.com; s=arc-20160816; b=cf61SH+C/8Zj89FQsz40lQOSM5p8uor27TbETtyHy7g8aNvJ1BVOeS+ko0dWA0syCv Zkcz5c1JrAGv2qWhQSU8nHMrpDL3Hz+BwqDqf9cAJlX9lRkmhAugQJ27EF2ySgx0TKcf u+Cive0Vj+y466fyvg/e5CvXkKS7xPtp+giGbNKWIwMJCrZPjMZjrAETiTgVBSxZBzbM RT7f5r4MmVQ0MYTY9PUq2D6UY20Lo+VEn7v0J0q1QQ1iGUtIHebfTIMtQGqxc8De7d+g BG9ezFzRV4j/fosfqP0mNqc3IwNkCbeN/uKn5g0rsdFlndIhG8MBumcW14mNIpl6V1+I kmUA== 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=oatlnVsZthR9KXlPmJ8zR/1CkHrsrTm6Ha2l+vUm12M=; b=Waac1VO1Qom/2idPixGcDksRmNlEsLIf05mY7FtxjTKI1k5kjZVHo0rWjSMYdqHoDV o3Ukn6BxKsCJc2I03qI9BSaogl8HC4WQ2thN/TtQZWeHO/xrvJ3UNkDGAQv5/jL/nT/V vRv/ke0VFWm9f75yqgLL5QuQPp+CPHR3B3k/guXsxQ48RF4/ppHL7sdd4fPlxVeBn7Ul aM8OdD6myt1MX3xDYlHHIyeK8aydlEGJSw03/UiWKM9SVz9pT0olVXpO0aSD1sCzVZAd xzDPf88uhMrkFJIHAj8sXcKqy17iBynKqo78u0Lu50TBO69YUBJ9t2oZC+UjSt5hvsAL 5VvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=PjvCNeQb; 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=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r22si3544705otn.192.2019.12.12.12.21.39; Thu, 12 Dec 2019 12:21:52 -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=@alien8.de header.s=dkim header.b=PjvCNeQb; 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=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730810AbfLLUTS (ORCPT + 99 others); Thu, 12 Dec 2019 15:19:18 -0500 Received: from mail.skyhub.de ([5.9.137.197]:34134 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730707AbfLLUTS (ORCPT ); Thu, 12 Dec 2019 15:19:18 -0500 Received: from zn.tnic (p200300EC2F0A5A00BC9FD9E905C0F14B.dip0.t-ipconnect.de [IPv6:2003:ec:2f0a:5a00:bc9f:d9e9:5c0:f14b]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id F2D5A1EC0B73; Thu, 12 Dec 2019 21:19:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1576181957; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=oatlnVsZthR9KXlPmJ8zR/1CkHrsrTm6Ha2l+vUm12M=; b=PjvCNeQbKtPMoji85bIhmfr/3z5GpoGkkMD5MdHRGrOT2F6Xgz3nCuyrn3J0YDB0M2nx97 I1rGJfIIAA8Lw1yJuWwIjX5i0AArBElPUZ65L7o7m41mdbYVw+7+mGyI0tCAOw6TZxW7CM i150REomX6xXWp8gLI+Gb9j4T8b9/GI= Date: Thu, 12 Dec 2019 21:19:16 +0100 From: Borislav Petkov To: Masayoshi Mizuma Cc: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, Baoquan He , Masayoshi Mizuma , linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 4/4] x86/mm/KASLR: Adjust the padding size for the direct mapping. Message-ID: <20191212201916.GL4991@zn.tnic> References: <20191115144917.28469-1-msys.mizuma@gmail.com> <20191115144917.28469-5-msys.mizuma@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20191115144917.28469-5-msys.mizuma@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 15, 2019 at 09:49:17AM -0500, Masayoshi Mizuma wrote: > +/* > + * Even though a huge virtual address space is reserved for the direct > + * mapping of physical memory, e.g in 4-level paging mode, it's 64TB, > + * rare system can own enough physical memory to use it up, most are > + * even less than 1TB. This sentence is unparseable. > So with KASLR enabled, we adapt the size of Who's "we"? > + * direct mapping area to the size of actual physical memory plus the > + * configured padding CONFIG_RANDOMIZE_MEMORY_PHYSICAL_PADDING. > + * The left part will be taken out to join memory randomization. > + */ > +static inline unsigned long calc_direct_mapping_size(void) What direct mapping?! The code is computing the physical memory regions base address and sizes. > +{ > + unsigned long size_tb, memory_tb; > + > + memory_tb = DIV_ROUND_UP(max_pfn << PAGE_SHIFT, 1UL << TB_SHIFT) + > + CONFIG_RANDOMIZE_MEMORY_PHYSICAL_PADDING; > + > +#ifdef CONFIG_MEMORY_HOTPLUG > + if (boot_params.max_addr) { > + unsigned long maximum_tb; > + > + maximum_tb = DIV_ROUND_UP(boot_params.max_addr, > + 1UL << TB_SHIFT); All that jumping through hoops and adding a member to boot_params which is useless on !hot-add systems - basically the majority out there - just so that you can use that max address here?! Did you not find acpi_table_parse_srat()? -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette