From patchwork Sun Jun 19 12:49:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yigal Korman X-Patchwork-Id: 9186149 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 77C1E60465 for ; Sun, 19 Jun 2016 12:49:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 520191FF45 for ; Sun, 19 Jun 2016 12:49:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 430EE28211; Sun, 19 Jun 2016 12:49:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=no version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B169D1FF45 for ; Sun, 19 Jun 2016 12:49:49 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 41E621A1DF5; Sun, 19 Jun 2016 05:50:17 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mail-wm0-x231.google.com (mail-wm0-x231.google.com [IPv6:2a00:1450:400c:c09::231]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B1ABE1A1DF5 for ; Sun, 19 Jun 2016 05:50:15 -0700 (PDT) Received: by mail-wm0-x231.google.com with SMTP id 187so2061183wmz.1 for ; Sun, 19 Jun 2016 05:49:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=plexistor-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=5hVc0FPWRxRSziGVLw6TQbkjae5+pxBZNnpINuFfZSg=; b=K6AcShkH+Fg90+Ubg+JVK4GcWnWConkzWvcbtW7J4WRhrfi8tvdnnTB+jthBfXv4Av 1rAlTmjrvtDXCCIat+azSCsEloKKjJbloqOJRQG53lY6s6s3iVRfHmNLIKvG0VAdpqaY vuG6HsFcT7N9Qc9fc7WHMvMk7qG3FET72pic8ED8SQlghHz81PzGvcHJbE+KGMB29jMt nADyFDB0FUb/tMHwbq1ekPdcp8PIU49yosgcdvpdrBRff+pNaHIQwconlTpveDxkt9+D oHQUAL4g8B/E7HNf7Iuppq9vTuKNh6PQGhnQUG3RqFfITgdC2YXWkm2PxO6AW/c/UxMc 01HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=5hVc0FPWRxRSziGVLw6TQbkjae5+pxBZNnpINuFfZSg=; b=iLe8CJawm9d75AhrLDEMxjmSM0tG7iYTNN4JKgrkTu4Te5SvB9uqKn6JQGFpQR0vry FbXt9HbZ64tx+WPWXIh7JDf/H+M1G/xAMGekWlkVDGRPgEOl0+UguCtl0bv9PNMZh4zn DKhsBzB+vVKYgqBEDF7LKxPU3uoqL2riYGIc2qb+YzJesY58xmOfkSR1z8YyV/svOQfG aOiQctxglrHlhJGNj6OvOIxfkHlUe/4hOzUNUbqmjm2vS0DfzGvTm1UKVbCjetDIgnXQ zYOPpPba9w/SzPQ2Bue+WNMZpRHSMW7rvIaV5OyQwA+j2rIAdWCRXqsmoh34a/KLZcfg 4bxg== X-Gm-Message-State: ALyK8tLfYG1hobYLaZDHTVE/V+XrvAcUU3VwWVs432+sphvjoMStcxurYS96sw1YoWoKJA== X-Received: by 10.194.164.98 with SMTP id yp2mr9523782wjb.85.1466340585069; Sun, 19 Jun 2016 05:49:45 -0700 (PDT) Received: from yigal-pc.plexistor.com.localdomain ([207.232.55.62]) by smtp.gmail.com with ESMTPSA id r6sm8395492wme.14.2016.06.19.05.49.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 Jun 2016 05:49:44 -0700 (PDT) From: Yigal Korman To: matt@codeblueprint.co.uk, linux-efi@vger.kernel.org Subject: [RFC] x86/mm: only allow memmap=XX!YY over existing RAM Date: Sun, 19 Jun 2016 15:49:30 +0300 Message-Id: <1466340570-2471502-1-git-send-email-yigal@plexistor.com> X-Mailer: git-send-email 1.9.3 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-nvdimm@lists.01.org MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP Before this patch, passing a range that is beyond the physical memory range will succeed, the user will see a /dev/pmem0 and will be able to access it. Reads will always return 0 and writes will be silently ignored. I've gotten more than one bug report about mkfs.{xfs,ext4} or nvml failing that were eventually tracked down to be wrong values passed to memmap. This patch prevents the above issue by instead of adding a new memory range, only update a RAM memory range with the PRAM type. This way, passing the wrong memmap will either not give you a pmem at all or give you a smaller one that actually has RAM behind it. And if someone still needs to fake a pmem that doesn't have RAM behind it, they can simply do memmap=XX@YY,XX!YY. Signed-off-by: Yigal Korman --- arch/x86/kernel/e820.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c index 569c1e4..bcd2ebb1 100644 --- a/arch/x86/kernel/e820.c +++ b/arch/x86/kernel/e820.c @@ -877,7 +877,7 @@ static int __init parse_memmap_one(char *p) e820_add_region(start_at, mem_size, E820_RESERVED); } else if (*p == '!') { start_at = memparse(p+1, &p); - e820_add_region(start_at, mem_size, E820_PRAM); + e820_update_range(start_at, mem_size, E820_RAM, E820_PRAM); } else e820_remove_range(mem_size, ULLONG_MAX - mem_size, E820_RAM, 1);