From patchwork Tue Jun 28 08:31:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yigal Korman X-Patchwork-Id: 9202293 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 CDC976075F for ; Tue, 28 Jun 2016 08:32:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BA612285F7 for ; Tue, 28 Jun 2016 08:32:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD4E8285FB; Tue, 28 Jun 2016 08:32:00 +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 6AAD5285F7 for ; Tue, 28 Jun 2016 08:31:59 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 658BB1A1E03; Tue, 28 Jun 2016 01:32:34 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mail-wm0-x232.google.com (mail-wm0-x232.google.com [IPv6:2a00:1450:400c:c09::232]) (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 332FD1A1E03 for ; Tue, 28 Jun 2016 01:32:33 -0700 (PDT) Received: by mail-wm0-x232.google.com with SMTP id r190so25661938wmr.0 for ; Tue, 28 Jun 2016 01:31:58 -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=6gREdtRJMxHa6rdF8HRnip7IzXZepYiL3pwVhfHScu0=; b=eb1q4lUubaxHOHyKbbWryWx2BYeCT1sl/nkTsfpYu9+2StPOsPj8S6qLQbEF67MHhl ldp4VQ9lakHvOXN1kWb/4ICF/KPgDOxHjCVS03NLlEJ7i6BGqz3q1qQdvrrueh23092S kn42qKoUrDPrJ9gkv7EgDo8FYdAXdKJvIX7tp06M5yF8GYMWWgcT+t5FS+/TemTo61JZ bxZ6f4jUBMxCaysuH6Dn5ZUtqoH4QCIgXruuYlRH3DWJQ3/ID0LbaapmNqhMqBl0rPO5 uG3yL7DUydba0htr5yMt1/x6jSpuP1a2PuUj8sxVo6fmW/iLeE49dzOUCqczXXw1fvyW zkiQ== 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=6gREdtRJMxHa6rdF8HRnip7IzXZepYiL3pwVhfHScu0=; b=Bfyin5XNtgZrDZTdaBmInhbmwfuExaGQsrA2xj8CsO6VpcV1tDTt2WGVWIteiNdtLR OaSMz4p/5RZXO9AMhEV9pI0OCC7jD+1fFGm75PJcESBGhiVdbO2TqT9vlfo5i/BAJ3Hv UqPksw0cU0D1g62TDkzbROlo/6sFbgt29dohGYxqrn/IbM3PrGwQz3/3ISzAo4bmXY1P 4mDcPLpuNXtCEzbIzaiw/Lsg84FZ/2DZBwSXXjZjjrCSz/dTmTFTRTi6+oUB3jQh0Rpk raBMUSHhf8G4axgFCvr/pAJpsdeNBirIr2dC/qUbBdr6e05+JqS/nAErxUg9Xy7fGhL7 KE2w== X-Gm-Message-State: ALyK8tI5ClZINpIGJkQYIH5cD5Mrw6Miv9QFhsHU32w+YxOIgMd81OjDKxF3eOSMEFU2KQ== X-Received: by 10.28.146.9 with SMTP id u9mr15782704wmd.52.1467102716728; Tue, 28 Jun 2016 01:31:56 -0700 (PDT) Received: from yigal-pc.plexistor.com.localdomain ([207.232.55.62]) by smtp.gmail.com with ESMTPSA id jf3sm4084985wjb.41.2016.06.28.01.31.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Jun 2016 01:31:55 -0700 (PDT) From: Yigal Korman To: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com Subject: [RESEND PATCH] x86/mm: only allow memmap=XX!YY over existing RAM Date: Tue, 28 Jun 2016 11:31:11 +0300 Message-Id: <1467102671-593138-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: x86@kernel.org, linux-kernel@vger.kernel.org, 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 Acked-by: Dan Williams Acked-by: Johannes Thumshirn Tested-by: Boaz Harrosh --- 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 621b501..4bd4207 100644 --- a/arch/x86/kernel/e820.c +++ b/arch/x86/kernel/e820.c @@ -878,7 +878,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);