Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2915842pxb; Tue, 24 Aug 2021 10:30:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw75W4ou0fvr0sF+W8/O5W/eoXw8Rh6rAqzkP5qTeuQAz5SCCqiRUrjVgqmRzwGFQLPeTDC X-Received: by 2002:a6b:7d0c:: with SMTP id c12mr31726604ioq.187.1629826251722; Tue, 24 Aug 2021 10:30:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629826251; cv=none; d=google.com; s=arc-20160816; b=P4jFJ2s4ff4BLyGtURUf2lEuNcXz6M463JJjGa6gjydEx922m2GKpTwejRXrUVmIe8 //vvr7UJ9UzqwGnwTEIOF2qiQ+W9WfHokTYL5nRXnQbIg2xEMeoJJCNczy6BKw3PN5mB QWYuzALNOyrfoX8PXzCx3JEuPZJ1PMXoWrmzKburUzVNFCbcBiPl+C+aWSPIyv9SGDg6 FWzjqFF+mqDkwwdTDBlUybhP1x3wDVPSVpenynWFMPpBSgp0nzXaFe0nOKsfqqfWoyv0 fHhkkvSBw00FdAmV3Ey2zrXa6TdAKFA/Hg/GBTzlUwcWilh2vv6Ig1DwNmN9gdkPm2/u XreA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=DDyLJ3Sn93UUEevHc5YYOzmebS21uB/1jvCOEwiMzFA=; b=tGFd9DCSNhWk4ii2sJW5eX4eGrBpKG7Vfk4Izpi90GTs+EVDrm3TrG5zsNu01E4c61 vT1W9IORKsdr2ztVtwpZyIfCn/e6UdHDvazdP6IzQxloGk8zIU4Q/A5IhWn0JrUWeVEH WyvHMZGjlH50kRLlNA34Ke9Z2iddKiqYq0PxGizv4h4upGNR8ZToNNQqt16DRa6e1Ggb Cq3PrE93/VHCPyOHxCX2d4XP8Gd6nGB/zzt8X35FacYgv9xmoXTHaLhq39ibISAAogA9 TDQ6kQSMhzu7HOuEOTSR/3sK9Yfdon1Yfh82wwCqTjxbXGuGTv+OPD4SMICX789qaUvR xRWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PZsl2kc6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s10si16713396ioo.6.2021.08.24.10.30.38; Tue, 24 Aug 2021 10:30:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PZsl2kc6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240939AbhHXR25 (ORCPT + 99 others); Tue, 24 Aug 2021 13:28:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:35606 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240105AbhHXR0p (ORCPT ); Tue, 24 Aug 2021 13:26:45 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 40D0F61B47; Tue, 24 Aug 2021 17:05:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1629824704; bh=k8LWtFNWTOBE9dh4NNpRe9OQfT5EPwhu5gmckkYV/FA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PZsl2kc6xF//ZlUXe0NNvfY7FRSJzl+8SYJdT0sulO2GVzlzN446eHG/deKXRfGux 8oy43rKetQeBeqinMAaysE/so7TI+wMStamrOHLW5adwvso7lLUHJHpBTWXFZxOBK6 MuRPLxHHFV5LZTwe5TFp0Ex7rpuAgqmUaQUdnk3zldF/k7IBOC5JGflpYsR1f2+nBT CwoO52gUxgxKqIF6Q41L2R20GvpwX23bxvW8rEPMPTvzGOFzplfZ5IZSxLIN8HqKqa l4pjkkoXQPtsD3ppK8ItYYiZbgdRVbxyRFgqc2fvwI+ZtSJM8ugeRiyaSkOYYZpCe+ PndWbBsGG29kA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Dan Williams , Jacek Zloch , Lukasz Sobieraj , "Lee, Chun-Yi" , Krzysztof Rusocki , Damian Bassa , Jeff Moyer , Greg Kroah-Hartman Subject: [PATCH 4.14 05/64] ACPI: NFIT: Fix support for virtual SPA ranges Date: Tue, 24 Aug 2021 13:03:58 -0400 Message-Id: <20210824170457.710623-6-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210824170457.710623-1-sashal@kernel.org> References: <20210824170457.710623-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.14.245-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-4.14.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 4.14.245-rc1 X-KernelTest-Deadline: 2021-08-26T17:04+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dan Williams commit b93dfa6bda4d4e88e5386490f2b277a26958f9d3 upstream. Fix the NFIT parsing code to treat a 0 index in a SPA Range Structure as a special case and not match Region Mapping Structures that use 0 to indicate that they are not mapped. Without this fix some platform BIOS descriptions of "virtual disk" ranges do not result in the pmem driver attaching to the range. Details: In addition to typical persistent memory ranges, the ACPI NFIT may also convey "virtual" ranges. These ranges are indicated by a UUID in the SPA Range Structure of UUID_VOLATILE_VIRTUAL_DISK, UUID_VOLATILE_VIRTUAL_CD, UUID_PERSISTENT_VIRTUAL_DISK, or UUID_PERSISTENT_VIRTUAL_CD. The critical difference between virtual ranges and UUID_PERSISTENT_MEMORY, is that virtual do not support associations with Region Mapping Structures. For this reason the "index" value of virtual SPA Range Structures is allowed to be 0. If a platform BIOS decides to represent NVDIMMs with disconnected "Region Mapping Structures" (range-index == 0), the kernel may falsely associate them with standalone ranges where the "SPA Range Structure Index" is also zero. When this happens the driver may falsely require labels where "virtual disks" are expected to be label-less. I.e. "label-less" is where the namespace-range == region-range and the pmem driver attaches with no user action to create a namespace. Cc: Jacek Zloch Cc: Lukasz Sobieraj Cc: "Lee, Chun-Yi" Cc: Fixes: c2f32acdf848 ("acpi, nfit: treat virtual ramdisk SPA as pmem region") Reported-by: Krzysztof Rusocki Reported-by: Damian Bassa Reviewed-by: Jeff Moyer Link: https://lore.kernel.org/r/162870796589.2521182.1240403310175570220.stgit@dwillia2-desk3.amr.corp.intel.com Signed-off-by: Dan Williams Signed-off-by: Greg Kroah-Hartman --- drivers/acpi/nfit/core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c index 20fd197ef74c..bfa163e9d6c3 100644 --- a/drivers/acpi/nfit/core.c +++ b/drivers/acpi/nfit/core.c @@ -2454,6 +2454,9 @@ static int acpi_nfit_register_region(struct acpi_nfit_desc *acpi_desc, struct acpi_nfit_memory_map *memdev = nfit_memdev->memdev; struct nd_mapping_desc *mapping; + /* range index 0 == unmapped in SPA or invalid-SPA */ + if (memdev->range_index == 0 || spa->range_index == 0) + continue; if (memdev->range_index != spa->range_index) continue; if (count >= ND_MAX_MAPPINGS) { -- 2.30.2