Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp935497ybl; Fri, 13 Dec 2019 06:57:24 -0800 (PST) X-Google-Smtp-Source: APXvYqyuG9gQRTV+HwrHY4reOVPZyNWWbVsSckdcpKcDKr1M2K02RmJtmK3adsnQuUU27sE2c+d5 X-Received: by 2002:a9d:6b17:: with SMTP id g23mr14465509otp.265.1576249044565; Fri, 13 Dec 2019 06:57:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576249044; cv=none; d=google.com; s=arc-20160816; b=hB3YpOrZVRwY6dGFc1fldXIBiV+HSRCPGe/dgxQloOxIS6LDB15Myf+5ltX+tjX70z 3jl4GMdQ5yP91a5goGpR/98Tiq8p72/1Twd8XRwmUehXnZcHPWYiC/0h66090sEOWaCG 9291obsnnW++6jEGdCSlcA9jlUQExrCxFOwtcEHyKKWpZ+b0Yb1ScVuyYBBIzDg2odRe aPZH29WgCY02bPcnBij4FWIZMku0AKM+fyldChyyAAX8HG6nvtAbd4uOYzcqG9RaXViT eckuQ/3t5KikuLudk3ayY+2xS3RSo9BcKzOyHfvzYBSUwjAVzILdvOthFgr7LSS6YiYW qJQA== 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=gntSwDNDnzHe3/thZbUD4KWSDrrpcmgp8bqbLa8CMa0=; b=CE8fGs7eVVPu3QjaUd3OkcOpKON5z14HsCL2rpPNkGKBxVar67KvHfcds4aVd3HW/V oXErGqcG501bY0uJcXHzoIUCY7wEeZ27Cu5/niw5jKfWc+GBaMNCh9wGGt8kGLADsZKg Wo55QUNS/SINFlA4/kbW5zn0q3pfoIYoR/sw+5cIaIv3BcF4zzoIreyTlO1tbWIQwvpz mCsOj3WGSXJ20ab8Gt4l2lwx8aCGOcvnMfJ6e/ff2aT5iv31qTooV5sxDNXe5QGB/EDI UTKQHC0rYbIbc8VJvYzUVgrSYfW06hmQwNOaHM44YKDsbLW01xa4LgIa6NNXzv6frOlv T+pA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="ciqbZ/Ru"; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f17si5533535otq.96.2019.12.13.06.56.59; Fri, 13 Dec 2019 06:57:24 -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=@redhat.com header.s=mimecast20190719 header.b="ciqbZ/Ru"; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727842AbfLMOzB (ORCPT + 99 others); Fri, 13 Dec 2019 09:55:01 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:46653 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727673AbfLMOzB (ORCPT ); Fri, 13 Dec 2019 09:55:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576248899; 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: in-reply-to:in-reply-to:references:references; bh=gntSwDNDnzHe3/thZbUD4KWSDrrpcmgp8bqbLa8CMa0=; b=ciqbZ/Ru+IADPhb+B4Jkhk0zMVadryQZlVHzrRP6JTgwnJC7NXmuk3HpjCLdff7K13R07g o+XhvEHOrTgm6mUya6fHTx3bKEMEJBaANDqNmqYSe2d4v4L89jznmZsgZkVMM/RwjEOat1 Du8XsJSJD2nUjV8POy+ezirCAgzQhW8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-346-n5LdeNYkMJyouqVkjHcDAA-1; Fri, 13 Dec 2019 09:54:56 -0500 X-MC-Unique: n5LdeNYkMJyouqVkjHcDAA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E7B998017DF; Fri, 13 Dec 2019 14:54:53 +0000 (UTC) Received: from localhost (ovpn-12-63.pek2.redhat.com [10.72.12.63]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5132C5C219; Fri, 13 Dec 2019 14:54:53 +0000 (UTC) Date: Fri, 13 Dec 2019 22:54:48 +0800 From: Baoquan He To: Borislav Petkov Cc: Masayoshi Mizuma , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, 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: <20191213145448.GH28917@MiWiFi-R3L-srv> References: <20191115144917.28469-1-msys.mizuma@gmail.com> <20191115144917.28469-5-msys.mizuma@gmail.com> <20191212201916.GL4991@zn.tnic> <20191213132850.GG28917@MiWiFi-R3L-srv> <20191213141543.GA25899@zn.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191213141543.GA25899@zn.tnic> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/13/19 at 03:15pm, Borislav Petkov wrote: > On Fri, Dec 13, 2019 at 09:28:50PM +0800, Baoquan He wrote: > > In Documentation/x86/x86_64/mm.rst, the physical memory regions mapping > > with page_offset is called as the direct mapping of physical memory. > > The fact that it happens to compute the *first* region's size, which > *happens* to be the direct mapping of all physical memory is immaterial > here. > > It is actually causing more confusion in an already complex piece of > code. You can call this function just as well > > calc_region_size() > > which won't confuse readers. Because all you care about here is the > region's size - not which region it is. Won't calc_region_size be too generic? We also have vmalloc and vmemmap, and here we are specifically calculating the direct mapping of physical memory. > > > kernel_randomize_memory() is invoked much earlier than > > acpi_table_parse_srat(). > > And? What are we going to do about that? void __init setup_arch(char **cmdline_p) { ... kernel_randomize_memory(); ... init_mem_mapping(); ... initmem_init(); ... } In kernel_randomize_memory(), KASLR builds the layout of these regions, including their starting address and the gap between them. Once finished, __PAGE_OFFSET, VMALLOC_START, VMEMMAP_START are settled. If not knowing the max address to cover all the possible hotplugged memory, later memory hotplug will fail. Thanks Baoquan