Received: by 10.223.176.5 with SMTP id f5csp6625wra; Fri, 2 Feb 2018 15:23:03 -0800 (PST) X-Google-Smtp-Source: AH8x224K812ibmUI/+wZ4nkTS9A1e+KOi2jthCfKYE/CztRsc84i2WIfSmqvajpfDtoHkkH0TcX7 X-Received: by 10.99.55.5 with SMTP id e5mr492667pga.237.1517613783440; Fri, 02 Feb 2018 15:23:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517613783; cv=none; d=google.com; s=arc-20160816; b=LMLCw3T/6TmUfSL1ybIWYDpTi/otLVUhQW5olzncrfGFFIVl2u0zANnuM37JHt7Wwu mz8RjQaD2pCq0O5ebMw5HSYXBrvqgV9bA1oJ08nHA6WYsOOhFZT2w4TOTmtM/lQZ4h5U 1IDNAzC461v85eP+HP7TkizEl+5q9wL2hEcQDcrf56ZOpsgrVQOhxXHDfGvAAMzbIASs JpYoYMMGqjT50fczlDUSXLSQiVaYmt5yburzHR8wTXHquytNdErbO4l2l7GETwOQrdK8 OHAqO+PVxA/mOrvQOS47LnXw/pybSnMWLXFuYU8HpGPCDHWSEqedYeF3sBVC3nLU/yfF jhbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=nEL62vAfMtmEMbcT2FM2xypNeroqe7xa5q7P6rwEecQ=; b=KYMf5E70gN9LajCM3np/4uxudDTC4ExZ+Zusu9LFxdO17nar5N5ZhU+ZioCW2JGpsk JZP+mUgrU+5ShWhQr1ZVdU8mlwz7CpB0nIBmJA2V6vniI5jF+x9xg0QfeA5TveQVz15W 35BppxkNKsWy+TjTUEcf0bmlHW6bGHQ0Sy2PRT75TjQmgqG1VjeR78pB/ScHSwBD1VpU Qz07Je0/4xiysw3mpE9ZHX1z6jM9TCoUSd9V4xt6kkQskvXwp7leTziu+yoVrwTFdfEA c/8tAmrtePhANVrqFm19avCc7l8Ct4vhgOe8ZzvuOJ9sHuiF2G+vdYXZmyuvJgzaX+Vf 7oNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.de header.s=amazon201209 header.b=pS/rpbzJ; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h71si169913pgc.707.2018.02.02.15.22.48; Fri, 02 Feb 2018 15:23:03 -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=@amazon.de header.s=amazon201209 header.b=pS/rpbzJ; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752643AbeBBXLL (ORCPT + 99 others); Fri, 2 Feb 2018 18:11:11 -0500 Received: from smtp-fw-6001.amazon.com ([52.95.48.154]:17884 "EHLO smtp-fw-6001.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751671AbeBBXKo (ORCPT ); Fri, 2 Feb 2018 18:10:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1517613044; x=1549149044; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nEL62vAfMtmEMbcT2FM2xypNeroqe7xa5q7P6rwEecQ=; b=pS/rpbzJ0r3Z6B8iMKUOlZ33PWlEHPTLUPZ99yXOtN9cFJfPrTlberJn x/mwfwob/CZTnTeg/XU/KvTJbigilqKEPctfx8iKkAV8V+HqSzxyJbxPQ T62WyEPaqZkFvBeOnn2cvrowyALWYeHiBWRlR2sdYeeD0Y63TuFWtMMLs M=; X-IronPort-AV: E=Sophos;i="5.46,451,1511827200"; d="scan'208";a="330369682" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-2c-c6afef2e.us-west-2.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6001.iad6.amazon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 02 Feb 2018 23:10:42 +0000 Received: from u7588a65da6b65f.ant.amazon.com (pdx2-ws-svc-lb17-vlan3.amazon.com [10.247.140.70]) by email-inbound-relay-2c-c6afef2e.us-west-2.amazon.com (8.14.7/8.14.7) with ESMTP id w12NAbPH093025 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Fri, 2 Feb 2018 23:10:39 GMT Received: from u7588a65da6b65f.ant.amazon.com (localhost [127.0.0.1]) by u7588a65da6b65f.ant.amazon.com (8.15.2/8.15.2/Debian-3) with ESMTPS id w12NAaYD015681 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 3 Feb 2018 00:10:36 +0100 Received: (from jschoenh@localhost) by u7588a65da6b65f.ant.amazon.com (8.15.2/8.15.2/Submit) id w12NAZ3E015680; Sat, 3 Feb 2018 00:10:35 +0100 From: =?UTF-8?q?Jan=20H=2E=20Sch=C3=B6nherr?= To: Ingo Molnar , Thomas Gleixner , x86@kernel.org Cc: =?UTF-8?q?Jan=20H=2E=20Sch=C3=B6nherr?= , Andy Shevchenko , "H. Peter Anvin" , linux-kernel@vger.kernel.org Subject: [PATCH v2] x86: e820: Implement a range manipulation operator Date: Sat, 3 Feb 2018 00:10:20 +0100 Message-Id: <20180202231020.15608-1-jschoenh@amazon.de> X-Mailer: git-send-email 2.9.3.1.gcba166c.dirty In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a more versatile memmap= operator, which -- in addition to all the things that were possible before -- allows you to: - redeclare existing ranges -- before, you were limited to adding ranges; - drop any range -- like a mem= for any location; - use any e820 memory type -- not just some predefined ones. The syntax is: memmap=%-+ Size and offset work as usual. The "-" and "+" are optional and their existence determine the behavior: The command works on the specified range of memory limited to type (if specified). This memory is then configured to show up as . If is not specified, the memory is removed from the e820 map. Signed-off-by: Jan H. Schönherr --- v2: Small coding style and typography adjustments Documentation/admin-guide/kernel-parameters.txt | 9 +++++++++ arch/x86/kernel/e820.c | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 46b26bfee27b..60926ae3ec06 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -2221,6 +2221,15 @@ The memory region may be marked as e820 type 12 (0xc) and is NVDIMM or ADR memory. + memmap=%-+ + [KNL,ACPI] Convert memory within the specified region + from to . If "-" is left + out, the whole region will be marked as , + even if previously unavailable. If "+" is left + out, matching memory will be removed. Types are + specified as e820 types, e.g., 1 = RAM, 2 = reserved, + 3 = ACPI, 12 = PRAM. + memory_corruption_check=0/1 [X86] Some BIOSes seem to corrupt the first 64k of memory when doing things like suspend/resume. diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c index 71c11ad5643e..6a2cb1442e05 100644 --- a/arch/x86/kernel/e820.c +++ b/arch/x86/kernel/e820.c @@ -924,6 +924,24 @@ static int __init parse_memmap_one(char *p) } else if (*p == '!') { start_at = memparse(p+1, &p); e820__range_add(start_at, mem_size, E820_TYPE_PRAM); + } else if (*p == '%') { + enum e820_type from = 0, to = 0; + + start_at = memparse(p + 1, &p); + if (*p == '-') + from = simple_strtoull(p + 1, &p, 0); + if (*p == '+') + to = simple_strtoull(p + 1, &p, 0); + if (*p != '\0') + return -EINVAL; + if (from && to) + e820__range_update(start_at, mem_size, from, to); + else if (to) + e820__range_add(start_at, mem_size, to); + else if (from) + e820__range_remove(start_at, mem_size, from, 1); + else + e820__range_remove(start_at, mem_size, 0, 0); } else { e820__range_remove(mem_size, ULLONG_MAX - mem_size, E820_TYPE_RAM, 1); } -- 2.9.3.1.gcba166c.dirty