Received: by 10.223.176.5 with SMTP id f5csp43723wra; Thu, 1 Feb 2018 15:15:10 -0800 (PST) X-Google-Smtp-Source: AH8x226+AFfnfvJ09hQdz/hiCplRwZctRzvooA2T8e+SY/8iQ1yFDpvS+O0k/p61Txtk6ZbHYw1m X-Received: by 10.99.123.8 with SMTP id w8mr29996008pgc.201.1517526910468; Thu, 01 Feb 2018 15:15:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517526910; cv=none; d=google.com; s=arc-20160816; b=JPNOOoB+moWMaHNgUxbz1GuDKdIxzdtF3qyoeVxRaAaFI7YJaXKbMgvZ52oF6M8Ybi X1/eNYDdygepy2z67pMP5wDNpDcTVI0WTS6qN/eushx4GidTfLxFSJqqmTTw590YTin0 pxV21EWLfoMZWTHA9c8NvOKHWCrJHwJtnd8YWomNWa3hd+0vdkP4LRJkgE0BUlr3kQGW BimMjgn29b80WYEuYE/d0wThY6tH9yJzSGmljpuIrrC2M7U6Xrc0P6190SjFRndkb0CH +ITGATlr5vE2mX3OMo9h2IJlNImzTLz9WFA8Gr2mb0cZJVHvemsK7LjFUbPod4DKa6ad 6isQ== 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 :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=Om8O7rPhiDj6jIq+GPgdOjYN8ZdWkBcOli6IXDEAeQ4=; b=jtzq2qH417owXYtiE97Ttzs/czDnzAfowO0SxITPmvYotYaAMGy5YwiMQw5uRnOnNT gRnch56xxlM76gwOl9h7TZ5RhwKvLgfVNLzBusiSqjMAYy6YMz2OBNsN73aRr6ZJeuMl klaI+t8X1IPGtcgf3DpkdgP+7pC9YT2AMacaGtq/fHo7ncDAu/UHWbDq4MAzt4NN0DAE qDHFFCyV/ldrs7ikSR/Fvn27+GYHa1cxrUq9PoBGTR5a8s/gWS4UBEFK0A+d+G/4Nh8u 2CgAcRADjJMK7L3oS2SXhOvsSvzwYtH/OtFQoQPjO3Ngo9UGHnNRanP2OYD6n50KwuwA KGmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.de header.s=amazon201209 header.b=K3f00fwD; 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 j18si433507pgn.47.2018.02.01.15.14.53; Thu, 01 Feb 2018 15:15:10 -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=K3f00fwD; 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 S1751641AbeBAXNb (ORCPT + 99 others); Thu, 1 Feb 2018 18:13:31 -0500 Received: from smtp-fw-4101.amazon.com ([72.21.198.25]:11523 "EHLO smtp-fw-4101.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751508AbeBAXNZ (ORCPT ); Thu, 1 Feb 2018 18:13:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1517526804; x=1549062804; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=Om8O7rPhiDj6jIq+GPgdOjYN8ZdWkBcOli6IXDEAeQ4=; b=K3f00fwDlRYJoXltpLVUe5WVNkrKmQ4Z0Ef1uIXwZmRNDv0kAqJmoQ0V XUuZDheNkp5r84s8q3/GVEiOpVNbrRGrt+uUTJr5lGK2MkkiduPRhETki STa17r1Jgh09rqzxw3gl1U2EKyKf91nN5fi+68co6ohbJ6kL1iEXdhA4h k=; X-IronPort-AV: E=Sophos;i="5.46,444,1511827200"; d="scan'208";a="706380342" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1a-e34f1ddc.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-4101.iad4.amazon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 01 Feb 2018 23:13:23 +0000 Received: from u7588a65da6b65f.ant.amazon.com (iad1-ws-svc-lb91-vlan2.amazon.com [10.0.103.146]) by email-inbound-relay-1a-e34f1ddc.us-east-1.amazon.com (8.14.7/8.14.7) with ESMTP id w11NDI2N003252 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Thu, 1 Feb 2018 23:13:20 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 w11NDHqI028510 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 2 Feb 2018 00:13:17 +0100 Received: (from jschoenh@localhost) by u7588a65da6b65f.ant.amazon.com (8.15.2/8.15.2/Submit) id w11NDGTv028509; Fri, 2 Feb 2018 00:13:16 +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?= , "H. Peter Anvin" , linux-kernel@vger.kernel.org Subject: [PATCH] x86: e820: Implement a range manipulation operator Date: Fri, 2 Feb 2018 00:13:13 +0100 Message-Id: <20180201231313.28458-1-jschoenh@amazon.de> X-Mailer: git-send-email 2.9.3.1.gcba166c.dirty 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 --- 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..94609eaff2a9 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, eg, 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..cd22c6a07632 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