Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1543604ybh; Tue, 14 Jul 2020 00:07:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNa8vnwXyuRDjsrjb5DaWRdgGALK+MmIgt+mrXNMQgFgTYCRqlu8SRgP8BMJZpJUW1g9rK X-Received: by 2002:a05:6402:30b2:: with SMTP id df18mr3087950edb.229.1594710447497; Tue, 14 Jul 2020 00:07:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594710447; cv=none; d=google.com; s=arc-20160816; b=flGRgPnwvt8LTx8DcvRMGyWjPnNVSu2rl0fjFblPOaaVtSNsPGeTee4hdRx3S8q0Fs kuSV1u4urm2TcKqTvCSYsi5mYcXagcHzVN4Gcn6LdKY4B7UoSbt+lpHEhLSghXU0dlp2 vJAPI46abTlxGdphZ3BT5yLADL2x/U7klNoSZYbmCO7m5b3oYyb4NHUV/BaKUfmQmGpQ iabLvIAimzOrSSoO5GTKGfjz8mGDh6I9Ql8DJkqxAPKuPdO6u+5u9eUjVrK4zlhpmcso xxv93eIaMO2N2MLkUTXD9y7d6Wt/9SD0A8ohETi41e1dDPj2yvsXirgnWuSkAbzC588p fjyg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=oEuHuC4IMLLc7Y1V0M3UQ131tMvBYPnUrr/qFarngqk=; b=abDuGmLESM/dfH763+funsXvY7mb8/mjOldSMhTrjwoXRKdHIQ9c9V8DFCSz58EGR3 krZDhJsasKienvt/gUY8+9HLoeKGwUNHZpJKgJQtFcDuqRXHDmnok0gvJNqffmAAN4aH u3ABfXii/feSF4IuK0/j5rPFrwFlPsq1k5F6cANm6HqqYI6XWfqjrde6PMuVMw5uFRaJ +70PKCZqKCSyvpciPCrh9VaHki8BvqSdz9EwZV3u4KuZw2frblrOgQkgu11yhU/kEc8u 5KrmvtOwXFrhr9YJCwNFvmhEoGnAKtf29M6/Q5lC3MfgYjEuZrfrWUbRSGxJ5lBMtvTB aTew== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v22si9387978ejf.411.2020.07.14.00.07.04; Tue, 14 Jul 2020 00:07:27 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727098AbgGNHEi (ORCPT + 99 others); Tue, 14 Jul 2020 03:04:38 -0400 Received: from mga04.intel.com ([192.55.52.120]:50389 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727034AbgGNHEb (ORCPT ); Tue, 14 Jul 2020 03:04:31 -0400 IronPort-SDR: ich8xV8hFnmzCz3xenXCt5Gwp+Pu22XqcldrFpG6x50tDs0YTP3pCyVSc5MvlINldsLKGEd0I+ MNn2n1F8J6TA== X-IronPort-AV: E=McAfee;i="6000,8403,9681"; a="146304368" X-IronPort-AV: E=Sophos;i="5.75,350,1589266800"; d="scan'208";a="146304368" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2020 00:04:30 -0700 IronPort-SDR: OlctpnIJwdlGQxS+Bsa4EvBdFZhgaMgi6E93HtogmUqsYd+MIKqgpv8ZX2Fg+6KeQMAbeYu29A wm1rPhIk0yOg== X-IronPort-AV: E=Sophos;i="5.75,350,1589266800"; d="scan'208";a="459583558" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.147]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2020 00:04:29 -0700 From: ira.weiny@intel.com To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Andy Lutomirski , Peter Zijlstra Cc: Ira Weiny , x86@kernel.org, Dave Hansen , Dan Williams , Vishal Verma , Andrew Morton , Fenghua Yu , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org Subject: [RFC PATCH 15/15] [dax|pmem]: Enable stray write protection Date: Tue, 14 Jul 2020 00:02:20 -0700 Message-Id: <20200714070220.3500839-16-ira.weiny@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200714070220.3500839-1-ira.weiny@intel.com> References: <20200714070220.3500839-1-ira.weiny@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ira Weiny Protecting against stray writes is particularly important for PMEM because, unlike writes to anonymous memory, writes to PMEM persists across a reboot. Thus data corruption could result in permanent loss of data. Therefore, there is no option presented to the user. Enable stray write protection by setting the flag in pgmap which requests it. Note if Zone Device Access Protection not be supported this flag will have no affect. Signed-off-by: Ira Weiny --- drivers/dax/device.c | 2 ++ drivers/nvdimm/pmem.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/drivers/dax/device.c b/drivers/dax/device.c index 4c0af2eb7e19..884f66d73d32 100644 --- a/drivers/dax/device.c +++ b/drivers/dax/device.c @@ -430,6 +430,8 @@ int dev_dax_probe(struct device *dev) } dev_dax->pgmap.type = MEMORY_DEVICE_DEVDAX; + dev_dax->pgmap.flags |= PGMAP_PROT_ENABLED; + addr = devm_memremap_pages(dev, &dev_dax->pgmap); if (IS_ERR(addr)) return PTR_ERR(addr); diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index 46c11a09b813..9416a660eede 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -427,6 +427,8 @@ static int pmem_attach_disk(struct device *dev, return -EBUSY; } + pmem->pgmap.flags |= PGMAP_PROT_ENABLED; + q = blk_alloc_queue(pmem_make_request, dev_to_node(dev)); if (!q) return -ENOMEM; -- 2.25.1