Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2837704lqt; Tue, 23 Apr 2024 03:13:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXIL54D/doMH093cah+EwxrDhwE/uKOY8+GjhQjPcEPi1v6fT2S4gV0iDsyaeFo5jug+Tp+5EgbGDeGbkYu3P21yJ3NVubLjhP1V7qncQ== X-Google-Smtp-Source: AGHT+IFgPbfX6ApB+1XAI/TTzIdjux2P1xXCn/W8cB5M5Wn5MCZTdVrfP+NCswhewdGHozukhHXd X-Received: by 2002:a17:903:41c3:b0:1e8:5923:2f60 with SMTP id u3-20020a17090341c300b001e859232f60mr2476512ple.18.1713867235322; Tue, 23 Apr 2024 03:13:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713867235; cv=pass; d=google.com; s=arc-20160816; b=DjquHLVbtBcufbfU/vKOGgc7VjgWj6ZHbA3wlOBIFE/YEsQZguA4KIRd0qRcXlEDVs nE7yJuyloseh/SExHjHDTK9k4fRdQr7OeWzgpzVLorvxZQBNPiX7Wnoe2/51BSIdjNZ+ Fz9gyk23yZuOPgn5iRHdXe7JDUbJGKO78SzrbU/nLr8QHlquGxuaiDrvJKFyHgjz6RMS jGqE8Au4Il+t5lL+ZXkooVPuFBMa7T8Zzh97bjtRgLMYJ7RzHF0FoFMOx1q3UqWzMN5O 61uRa2iMH8UTUnQ3RCluk3Bi0SaSLiz95c2nnJUqCtulpaCOY9FWo6ukMe68mhT5mF2h ow2g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:message-id:date :subject:cc:to:from; bh=OmkRmWWxXfASGnV6dPTYJtsacFd9tj6qab+OYpj8l4c=; fh=8ILEPbTaKT4BIFlglaO/oGEL98hwOWtzoteeCXNb2Fk=; b=nySfgd/H4+Fzk7EEZS/6C47wZ4j7LXd60Bx9cUmfeRf8YRR4j6aBT9yLjopJv4bpJs fJPxJXTMx2OLZE7Bp12dwQoie6hjxcgh9dHN1OeZvNeDE3/JeIL0iv48DUmAaeY4tjI9 zwcULe6tFJ4kR78ctSOi/v0XK7Ay+ZHA/bCSrRTdXMYS5FdkO7oiHjzPGsd85d0uehuV qCAg4rgOKA4TZa5RGjQ9dAJnFSvvMax/Uzyn77u9/9yE7qVMEzbr0eGuzVLskYwUWEkQ QrZ2juoKJbchsFoZpFn43TxziN7+H7m5ad1kF+gb+PKAfEvcOisjDh/Px/P2hG3jPUzs iKNg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=sk.com); spf=pass (google.com: domain of linux-kernel+bounces-154845-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154845-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id lm16-20020a170903299000b001e4638c95a5si9557385plb.543.2024.04.23.03.13.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 03:13:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-154845-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=sk.com); spf=pass (google.com: domain of linux-kernel+bounces-154845-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154845-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 8A84528140F for ; Tue, 23 Apr 2024 10:13:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6C55360882; Tue, 23 Apr 2024 10:13:48 +0000 (UTC) Received: from invmail4.hynix.com (exvmail4.hynix.com [166.125.252.92]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2C3B254BF7 for ; Tue, 23 Apr 2024 10:13:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=166.125.252.92 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713867227; cv=none; b=tzxM0uX72e+bpu/Kr9oqzFn+0FBA1ciNC97F+DLI/Uwcny26BIYJnn0pK38lflgXcAjFpPVRRb9BfbpL7Wa+Af7k8opKZaZwcCQoDWbabVhSLJh8QbSzj98MZtVmA21n6Y4emjoGHkpT9LBIbZ8w4PYlqjp6DoRCYaug7H0+/pc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713867227; c=relaxed/simple; bh=exKsQQI+SVpy3NWrsM6z84rlDwOJ4z0c0uu0gCoMWs8=; h=From:To:Cc:Subject:Date:Message-Id; b=E6txadllFYvh7BlOK5mVLCcp1yj3gX1ZjtmxjoYv51PPjNXb/J4bHiUOnaLpRyyZJ25Pk7ZrX6MEqDwzVi+4Pklm3RdN6DnxO97aNQCztpGljAO0VAMonUSWvQ0xEB1Eyh3Gl2WkJQtg6TpnZ4bUfM2GpOB4yplFfr72u/bEUQA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sk.com; spf=pass smtp.mailfrom=sk.com; arc=none smtp.client-ip=166.125.252.92 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sk.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sk.com X-AuditID: a67dfc5b-d85ff70000001748-a0-662789ce657b From: Byungchul Park To: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, jbohac@suse.cz, dyoung@redhat.com Cc: kernel_team@skhynix.com, linux-kernel@vger.kernel.org Subject: [PATCH] x86/e820: apply 'mem=' boot command while reserving memory using boot_params Date: Tue, 23 Apr 2024 19:13:23 +0900 Message-Id: <20240423101323.40968-1-byungchul@sk.com> X-Mailer: git-send-email 2.17.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupnluLIzCtJLcpLzFFi42LhesuzUPdcp3qaQcdMYYvPG/6xWbzY0M5o 0TCxgcVi2kZxixsHN7NZXN41h83i0oEFTBabN01ltvix4TGrA6fH99Y+Fo9NqzrZPN6dO8fu Me9koMf7fVfZPM4sOMLu8XmTnMeJli+sARxRXDYpqTmZZalF+nYJXBnTuo+xF/wQrHj78Ctj A+Nlvi5GTg4JAROJiVMmMsHYk25+ZgGx2QTUJW7c+MncxcjFISKwmFHixLt3rCAJZgFriTuH u8CKhAViJeZf3sEGYrMIqEqc+3oazOYVMJW49/YyC8RQeYnVGw4wQ9iNbBI33wpB2JISB1fc YJnAyL2AkWEVo1BmXlluYmaOiV5GZV5mhV5yfu4mRmAwLav9E72D8dOF4EOMAhyMSjy8DL/U 0oRYE8uKK3MPMUpwMCuJ8P76o5ImxJuSWFmVWpQfX1Sak1p8iFGag0VJnNfoW3mKkEB6Yklq dmpqQWoRTJaJg1OqgXHp0aUVufKHi1wj+jrKohWU/y1kDtR6pXa2/q5UdtHTneWvTNWCW24W 2qx6PGWaQJAm46OdkxTbI807t6132lLl3fD68fcrJ/O/pjx+es+GY+FJlduHz+283/X+RLbm +WoZbUaVhHiryXxSHCeZHlY35Ob4P3/t9fMn4ynmZSU2388qXHqz/JYSS3FGoqEWc1FxIgBt LZREIgIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrOJMWRmVeSWpSXmKPExsXC5WfdrHuuUz3NYPokNovPG/6xWbzY0M5o 0TCxgcVi2kZxixsHN7NZHJ57ktXi8q45bBaXDixgsti8aSqzxY8Nj1kduDy+t/axeGxa1cnm 8e7cOXaPeScDPd7vu8rmsfjFByaPMwuOsHt83iTncaLlC2sAZxSXTUpqTmZZapG+XQJXxrTu Y+wFPwQr3j78ytjAeJmvi5GTQ0LARGLSzc8sIDabgLrEjRs/mbsYuThEBBYzSpx4944VJMEs YC1x53AXWJGwQKzE/Ms72EBsFgFViXNfT4PZvAKmEvfeXmaBGCovsXrDAeYJjBwLGBlWMYpk 5pXlJmbmmOoVZ2dU5mVW6CXn525iBAbHsto/E3cwfrnsfohRgINRiYf3xye1NCHWxLLiytxD jBIczEoivL/+qKQJ8aYkVlalFuXHF5XmpBYfYpTmYFES5/UKT00QEkhPLEnNTk0tSC2CyTJx cEo1MFr4Xjr43m+DfYNc9ZVFRw7sSud7dHnyf7u7Eac11cXtKxZ+ebf3wPw0mTbPWBnvcxfe TN/RoautoSp45bJK4/eYh0yPMia8dQwMcz3rnjh1xV6Wq+1hZrdEDAxmeSy4nZhh/bbtmVtP +q6X15iWmLd7nyxTP7yaY9rkI+nLX6V5mO/oEpm3KEOJpTgj0VCLuag4EQChPUY4CgIAAA== X-CFilter-Loop: Reflected Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: I might miss something. Please lemme know if I go wrong. Thanks. Byungchul --->8--- From 51f3b5b9bf9685aa431c00908771151edd702483 Mon Sep 17 00:00:00 2001 From: Byungchul Park Date: Tue, 23 Apr 2024 18:54:48 +0900 Subject: [PATCH] x86/e820: apply 'mem=' boot command while reserving memory using boot_params When a user specifies 'mem=' boot command, it's expected to limit the maximum address of usable memory for the kernel no matter what the memory map source is. However, 'mem=' boot command doesn't work since it doesn't respect it when reserving memory using boot_params. Applied the restriction when reserving memory using boot_params. While at it, renamed mem_size to a more specific name, boot_mem_limit. Signed-off-by: Byungchul Park --- arch/x86/kernel/e820.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c index 6f1b379e3b38..af9d1d95ef5a 100644 --- a/arch/x86/kernel/e820.c +++ b/arch/x86/kernel/e820.c @@ -880,11 +880,11 @@ static void __init early_panic(char *msg) static int userdef __initdata; +static u64 boot_mem_limit = U64_MAX; + /* The "mem=nopentium" boot option disables 4MB page tables on 32-bit kernels: */ static int __init parse_memopt(char *p) { - u64 mem_size; - if (!p) return -EINVAL; @@ -899,16 +899,16 @@ static int __init parse_memopt(char *p) } userdef = 1; - mem_size = memparse(p, &p); + boot_mem_limit = memparse(p, &p); /* Don't remove all memory when getting "mem={invalid}" parameter: */ - if (mem_size == 0) + if (boot_mem_limit == 0) return -EINVAL; - e820__range_remove(mem_size, ULLONG_MAX - mem_size, E820_TYPE_RAM, 1); + e820__range_remove(boot_mem_limit, ULLONG_MAX - boot_mem_limit, E820_TYPE_RAM, 1); #ifdef CONFIG_MEMORY_HOTPLUG - max_mem_size = mem_size; + max_mem_size = boot_mem_limit; #endif return 0; @@ -1036,6 +1036,8 @@ void __init e820__reserve_setup_data(void) early_memunmap(data, len); } + e820__range_remove(boot_mem_limit, ULLONG_MAX - boot_mem_limit, + E820_TYPE_RESERVED_KERN, 1); e820__update_table(e820_table); pr_info("extended physical RAM map:\n"); -- 2.17.1