Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2890759ybc; Thu, 14 Nov 2019 00:17:43 -0800 (PST) X-Google-Smtp-Source: APXvYqyJhdc88Xl/tIxzFWXLdTro4Ay951G8F+H8QFhXT3xECpATXUYojKRFoHy2mR4pFo5O5jsT X-Received: by 2002:a17:906:d143:: with SMTP id br3mr7243553ejb.215.1573719463630; Thu, 14 Nov 2019 00:17:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573719463; cv=none; d=google.com; s=arc-20160816; b=y96mC9Y55d8xWn4Jpp/TuaHYUjUJnyf9tOLakYPQYLbxzYbQHLrlYGxpaXwLL4KVll OBD2aevXVzGVPqakgOOEKck/t6TOyaE04xVlvpjuQu/TX6IYkWnMmYuqdbQoLOGzE9r9 4PA1sUeg7dQcjQnyl1B1Rkl73c/jbchywB/C08mih7xO+0pvS5sd/DdSeIMEIVpGEhju 4L9EGMdWoV32WbR2r12rWLz3WofFxEM4lOs9UTzTZx2IZ1t48Dfzm9VZn2uSK8oz1AuQ k44HR2QsNtTvhrWT4LqHUQXKkAUonxukYGQNINHcYvoVbHNA6o9XWx/Td7Lb3TakQb08 9o6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:user-agent:in-reply-to:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=7pz4h7KTvi15etsg91JTbTPY+IW6HvuoxNFsGvR7DmQ=; b=i5ftnsxNq6DJEvHkZP/sBOmvlUUfBrg8c68d+jeeAqqzmL4qMU+DfmF7qP4mfOj9K8 5G9RIzZU6zmJACRy+iP+KGYn3EDRViMNmHdZWH6DuUIaZ1zb9Vpc+0k8pUqPE77D+B4t VHF502KZRHAfAN+B1NiUWOl+YqPQRfRA9t1jTIUak/OdZAIJ4MLJEEdATI9wcEkS/Bfv 01L2+w07FimLLCK8eoFXYpME7myhODfh8i/4zWvW3LPSdudSp2NElUnzfdwrXQ6CPLdw DMm6U0Q1vb9hfAg9qDwAtRdfTroMUy2UpLf1JnluvSmglcaGYG5Il8Yaphko4RkzoN3i en1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dGVxUlgP; 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 e50si3514246ede.59.2019.11.14.00.17.19; Thu, 14 Nov 2019 00:17:43 -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=dGVxUlgP; 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 S1726428AbfKNIQs (ORCPT + 99 others); Thu, 14 Nov 2019 03:16:48 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:57068 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726024AbfKNIQs (ORCPT ); Thu, 14 Nov 2019 03:16:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573719407; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7pz4h7KTvi15etsg91JTbTPY+IW6HvuoxNFsGvR7DmQ=; b=dGVxUlgPyWJPXjJdKwYvVxg9Os8fsbMp3lDUGsPDnDiHTchJsQ5UocAMtdlhQ9ngl0tOWK VK1ixqxQODVYc999NSSUYr+65vdBF8W416H54A0ViTYerJvB0G8OzIDwzwoe/9xUW2cgps bOTiB9PUBU+x1TCWfEQ9QhbTu+vX2gY= 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-291-DvE3QywuOrGiB5fflIsqgg-1; Thu, 14 Nov 2019 03:16:43 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A76D1DB20; Thu, 14 Nov 2019 08:16:41 +0000 (UTC) Received: from localhost (ovpn-12-24.pek2.redhat.com [10.72.12.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DD4595E258; Thu, 14 Nov 2019 08:16:40 +0000 (UTC) Date: Thu, 14 Nov 2019 16:16:38 +0800 From: Baoquan He To: Masayoshi Mizuma Cc: Borislav Petkov , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, Masayoshi Mizuma , linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 4/4] x86/mm/KASLR: Adjust the padding size for the direct mapping. Message-ID: <20191114081638.GH30906@MiWiFi-R3L-srv> References: <20191102010911.21460-1-msys.mizuma@gmail.com> <20191102010911.21460-5-msys.mizuma@gmail.com> <20191104004825.GK7616@MiWiFi-R3L-srv> <20191112204707.jyruwkb4pbdj3jvv@gabell> MIME-Version: 1.0 In-Reply-To: <20191112204707.jyruwkb4pbdj3jvv@gabell> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: DvE3QywuOrGiB5fflIsqgg-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/12/19 at 03:47pm, Masayoshi Mizuma wrote: > Your suggesion makes it simpler, thanks! > So I'll modify calc_direct_mapping_size() as following. > Does it make sense? Yeah, it looks good to me. Thanks. >=20 > static inline unsigned long calc_direct_mapping_size(void) > { > unsigned long size_tb, memory_tb; >=20 > memory_tb =3D DIV_ROUND_UP(max_pfn << PAGE_SHIFT, 1UL << TB_SHIFT)= + > CONFIG_RANDOMIZE_MEMORY_PHYSICAL_PADDING; >=20 > #ifdef CONFIG_MEMORY_HOTPLUG > if (boot_params.max_addr) { > unsigned long maximum_tb; >=20 > maximum_tb =3D DIV_ROUND_UP(boot_params.max_addr, > 1UL << TB_SHIFT); >=20 > if (maximum_tb > memory_tb) > memory_tb =3D maximum_tb; > } > #endif > size_tb =3D 1 << (MAX_PHYSMEM_BITS - TB_SHIFT); >=20 > /* > * Adapt physical memory region size based on available memory > */ > if (memory_tb < size_tb) > size_tb =3D memory_tb; >=20 > return size_tb; > }