Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1435878ybl; Fri, 13 Dec 2019 15:30:33 -0800 (PST) X-Google-Smtp-Source: APXvYqzkudFHEoFMKIqGCIMiAMyHI31EEcKUyyszfisKMd3FOJIGlfIjR0iQVatTxoKrjmWqXDBa X-Received: by 2002:a05:6830:1c8a:: with SMTP id v10mr16484522otf.115.1576279833842; Fri, 13 Dec 2019 15:30:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576279833; cv=none; d=google.com; s=arc-20160816; b=Y+OuciF5AQeQ32+cZS7iWzGrw6hbj9VB+u2SY9JAx6tBqEq+EOkZdUWtaC+OL9SuDm 7St8/In7+tYxvtJYdVKG8j7w7yZl32HOA0/T/TnepcMpSiE4dzfLD7LHViQGNQfB37Do GJBwSB6S17jm9/1x0OQYrMvgcuGfnMznjAH6TWupcf9r8JhT+S5NXO6n0tM47e08DQqB WXfk6VHIgjbVeSufAfTTa3ZBTesLT+zQungdjulkAUkzMvvFo290MAoplSFxeLYptr8A uwXA/z20H/g5VEXKsQc8EvmiU5fiO9MN2rPCzOG+GDYmmBccxOjH2wugK9ZWA1/2JTWZ 6N+w== 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=VFmb6qrBMJ+Zh10r30rcfLXRGYfYdeTl00YdMSRkzR8=; b=dJ6hvbnYpDdfJLH0XmJnLjG7XgAk6rmiexOacJ7+7dBK2xr0g4ZiFqtxzw+hTHpqvH Yb4fNNwo4SW6C94qYpLf+GdtaIN3on3wM8Eu0YjyUG5l69hSdoKBrMgM5Uc0tIo5kbYu f+KTlLRFZnDiCwjBpxWvBa+/GK83/PUini0dhlzlwFzAXFkenRzg03uwRFglAMeycJus 34e7Zfm4Ken85KYooawvHM+acDTdhjCe9DJXqTCil4jyAU8VX53n640nTufUQ/p//ISZ cSDJafUnS4kXctd4v8Q6FQan+WifZo0vb6Zu/JJCgGqCvSldrGXxXDFEcRBwFg25WPfn OG0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=N6UVxpJ6; 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 m3si6184903otq.321.2019.12.13.15.30.21; Fri, 13 Dec 2019 15:30:33 -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=N6UVxpJ6; 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 S1726774AbfLMX3j (ORCPT + 99 others); Fri, 13 Dec 2019 18:29:39 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:40089 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726623AbfLMX3i (ORCPT ); Fri, 13 Dec 2019 18:29:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576279777; 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=VFmb6qrBMJ+Zh10r30rcfLXRGYfYdeTl00YdMSRkzR8=; b=N6UVxpJ6eNjVzB1E8OxEZ6vZSqpQQ8FuYnOPRXvkF6xhLpGXlfexqH2rym1Ds67WF5F6I4 ujiFWDxMS7BwzL36txuvtTTPmhQznzRO0nUiTTOnE6PfebOF5xjbXJKdQ9nc/Mj/yNzuPO 7mfT5YIkPqFn7QVEtM+T78CCKlXecHg= 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-292-VFM_yLJiNo28ubn7fiSaeQ-1; Fri, 13 Dec 2019 18:29:34 -0500 X-MC-Unique: VFM_yLJiNo28ubn7fiSaeQ-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 B891A100550E; Fri, 13 Dec 2019 23:29:32 +0000 (UTC) Received: from localhost (ovpn-12-17.pek2.redhat.com [10.72.12.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BE8665C219; Fri, 13 Dec 2019 23:29:31 +0000 (UTC) Date: Sat, 14 Dec 2019 07:29:28 +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: <20191213232928.GI28917@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> <20191213145448.GH28917@MiWiFi-R3L-srv> <20191213163818.GB25899@zn.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191213163818.GB25899@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 05:38pm, Borislav Petkov wrote: > On Fri, Dec 13, 2019 at 10:54:48PM +0800, Baoquan He wrote: > > 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. > > It sounds like you didn't read what I wrote above so read it again pls. Got it, I believe people won't be confused with calc_region_size(). It's fine to me. > > > If not knowing the max address to cover all the possible hotplugged > > memory, later memory hotplug will fail. > > You don't have to state the obvious - I can see that in the code. > > So let me ask you differently: can the parsing of the SRAT table happen > shortly before kernel_randomize_memory() *without* adding all that gunk > to the compressed stage, and without adding the boot_params member and > done only for memory hot_add machines? OK, you mean parsing SRAT again before kernel_randomize_memory(). I think this is what Masa made this patchset to avoid. Then we will have three times SRAT parsing. Passing the max addr from boot to kernel_randomize_memory() was raised when review Chao Fan's patchset, I vaguely remember. Chao didn't take the SRAT parsing way in boot code firstly, later someone suggested to parse, and said the issue in kernel_randomize_memory() can be fixed with the parsed value. Surely, parsing SRAT here is also good. Maybe Masa can make a draft patch, let people see what it looks like. Thanks Baoquan