From patchwork Sat Apr 11 00:09:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Verma, Vishal L" X-Patchwork-Id: 11483833 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1159314B4 for ; Sat, 11 Apr 2020 00:09:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D93282084D for ; Sat, 11 Apr 2020 00:09:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D93282084D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 19C538E008B; Fri, 10 Apr 2020 20:09:33 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 14CCC8E0067; Fri, 10 Apr 2020 20:09:33 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 089EC8E008B; Fri, 10 Apr 2020 20:09:33 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0046.hostedemail.com [216.40.44.46]) by kanga.kvack.org (Postfix) with ESMTP id E66F38E0067 for ; Fri, 10 Apr 2020 20:09:32 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id ACAEF180AD801 for ; Sat, 11 Apr 2020 00:09:32 +0000 (UTC) X-FDA: 76693640184.06.waste65_705c16e8fab2d X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,vishal.l.verma@intel.com,,RULES_HIT:30003:30012:30029:30041:30054:30056:30064:30070,0,RBL:134.134.136.100:@intel.com:.lbl8.mailshell.net-62.18.0.100 64.95.201.95,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:ft,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:22,LUA_SUMMARY:none X-HE-Tag: waste65_705c16e8fab2d X-Filterd-Recvd-Size: 4452 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by imf27.hostedemail.com (Postfix) with ESMTP for ; Sat, 11 Apr 2020 00:09:31 +0000 (UTC) IronPort-SDR: fX7eVJp92+hMYlQIpfI7qcoJXnuzQXegCjj0L7LCm4Ec/sGH7mKJNmHkZfztpYWZfUBj+ASY1E Mgkr+lc88qCA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2020 17:09:28 -0700 IronPort-SDR: 7BcNaqm+J64TVfPlQwwzm/cOtuANdguHOHjksmNmSTEIHMGk5S30POGIjgV6PTeRG+dlD5DPFs rLLYJ61XL8WA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,368,1580803200"; d="scan'208";a="331316197" Received: from vverma7-mobl4.lm.intel.com ([10.251.142.92]) by orsmga001.jf.intel.com with ESMTP; 10 Apr 2020 17:09:29 -0700 From: Vishal Verma To: Cc: , Dan Williams , Dave Hansen , Vishal Verma Subject: [PATCH] dax/kmem: refrain from adding memory into an impossible node Date: Fri, 10 Apr 2020 18:09:16 -0600 Message-Id: <20200411000916.13656-1-vishal.l.verma@intel.com> X-Mailer: git-send-email 2.21.1 MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: A misbehaving qemu created a situation where the ACPI SRAT table advertised one fewer proximity domains than intended. The NFIT table did describe all the expected proximity domains. This caused the device dax driver to assign an impossible target_node to the device, and when hotplugged as system memory, this would fail with the following signature: [ +0.001627] BUG: kernel NULL pointer dereference, address: 0000000000000088 [ +0.001331] #PF: supervisor read access in kernel mode [ +0.000975] #PF: error_code(0x0000) - not-present page [ +0.000976] PGD 80000001767d4067 P4D 80000001767d4067 PUD 10e0c4067 PMD 0 [ +0.001338] Oops: 0000 [#1] SMP PTI [ +0.000676] CPU: 4 PID: 22737 Comm: kswapd3 Tainted: G O 5.6.0-rc5 #9 [ +0.001457] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014 [ +0.001990] RIP: 0010:prepare_kswapd_sleep+0x7c/0xc0 [ +0.000780] Code: 89 df e8 87 fd ff ff 89 c2 31 c0 84 d2 74 e6 0f 1f 44 00 00 48 8b 05 fb af 7a 01 48 63 93 88 1d 01 00 48 8b 84 d0 20 0f 00 00 <48> 3b 98 88 00 00 00 75 28 f0 80 a0 80 00 00 00 fe f0 80 a3 38 20 [ +0.002877] RSP: 0018:ffffc900017a3e78 EFLAGS: 00010202 [ +0.000805] RAX: 0000000000000000 RBX: ffff8881209e0000 RCX: 0000000000000000 [ +0.001115] RDX: 0000000000000003 RSI: 0000000000000000 RDI: ffff8881209e0e80 [ +0.001098] RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000008000 [ +0.001092] R10: 0000000000000000 R11: 0000000000000003 R12: 0000000000000003 [ +0.001092] R13: 0000000000000003 R14: 0000000000000000 R15: ffffc900017a3ec8 [ +0.001091] FS: 0000000000000000(0000) GS:ffff888318c00000(0000) knlGS:0000000000000000 [ +0.001275] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ +0.000882] CR2: 0000000000000088 CR3: 0000000120b50002 CR4: 00000000001606e0 [ +0.001095] Call Trace: [ +0.000388] kswapd+0x103/0x520 [ +0.000494] ? finish_wait+0x80/0x80 [ +0.000547] ? balance_pgdat+0x5a0/0x5a0 [ +0.000607] kthread+0x120/0x140 [ +0.000508] ? kthread_create_on_node+0x60/0x60 [ +0.000706] ret_from_fork+0x3a/0x50 Add a check in the kmem driver to ensure that the target_node for the device in question is in the nodes_possible mask. Cc: Dan Williams Acked-by: Dave Hansen Signed-off-by: Vishal Verma --- drivers/dax/kmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/dax/kmem.c b/drivers/dax/kmem.c index 3d0a7e702c94..760c5b4e88c8 100644 --- a/drivers/dax/kmem.c +++ b/drivers/dax/kmem.c @@ -32,7 +32,7 @@ int dev_dax_kmem_probe(struct device *dev) * unavoidable performance issues. */ numa_node = dev_dax->target_node; - if (numa_node < 0) { + if (numa_node < 0 || !node_possible(numa_node)) { dev_warn(dev, "rejecting DAX region %pR with invalid node: %d\n", res, numa_node); return -EINVAL;