Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1542688ybh; Tue, 14 Jul 2020 00:05:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjeNt80qZlPyN0qWN/LorRGvC/ovn2gdTEhkFY2X+G6TgzHbF0HxH1SfcbtMCho3VSB4kA X-Received: by 2002:a17:906:8595:: with SMTP id v21mr3271868ejx.333.1594710351397; Tue, 14 Jul 2020 00:05:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594710351; cv=none; d=google.com; s=arc-20160816; b=vp0yqOuL4uO4enef2quEC/+iaBlzQndO6gCeM2wPThc+SPCNb207jPim0BNhhAyiH9 KZzWcYke6rwsDrUIH9EvakwUZ66phte3tjM95dK4VWBAOknwFhG0iyXcS5AAyBVHwWDS bLnWgyU+3RxW7WJJrYmexwo/ONol/M993XFn9UomTP8yY7O5cKhY6GA10gEVXaEOAI0r Pdr2D+anofoT3yyIDu7q000R9VU9cVgbxqa+pE1cxB+Wh5UTpdo5BDZj93FfJNXP4jtw YMuYlZhrddNN7BWH9pyMpVsibNeewVTYQKBuh/o4VLXbSjElwi7jwfD1Vl72x8pRNm7Z a2Fg== 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=o/+qcRU+DuRCktahrVq1Ah3WTuJ1nDpngreivMauXmg=; b=WywhO7hH67fa1xok0u5J8eufxS2AMHVTl1MWQgL34yh494Ts4JLPPtP8ORCFvqAfI5 CpgPk+zrQCTP6Il0NT6TyIlNwiRVVqnqB6d6C895DqtpZ966lPszpvgLyO6heWJmhzvB TzGI5fsCtm/U39XCQq+AUwz++4N/B+olHUmIOiq4dyYtXfs+7qjfezK5vTBodN1YTRUO ywVnqhdZXv6tcB0gxfsR+Q5ihiR1idBpzJB1lcRc551lyO59BoUVvRvlV0PreCQEDLm1 aEFnlVtPj3esI7jJXymEF168PT6x389FeY8I6aDGSYKVVmsxOtby/JcTtIT/TxmsXBk+ 2aHA== 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 y19si9934175edv.611.2020.07.14.00.05.28; Tue, 14 Jul 2020 00:05: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; 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 S1727060AbgGNHEe (ORCPT + 99 others); Tue, 14 Jul 2020 03:04:34 -0400 Received: from mga09.intel.com ([134.134.136.24]:61109 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727029AbgGNHE3 (ORCPT ); Tue, 14 Jul 2020 03:04:29 -0400 IronPort-SDR: /KgLZW4dFvREbw1hbd/0VuJ+D/5ZkkxHP23O7JcRBzVKZ5kBY8G0qeUyPItldvf6eR8wDCH6pU XnnPra5O9u8g== X-IronPort-AV: E=McAfee;i="6000,8403,9681"; a="150261214" X-IronPort-AV: E=Sophos;i="5.75,350,1589266800"; d="scan'208";a="150261214" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2020 00:04:28 -0700 IronPort-SDR: M1818UDpOziaMV+1NuZExXbDGKfxAHE7xxsE/1/8eIxmubbVe3Yh1zWgdqipkeJC59admPi65v orXIGfMQFVpQ== X-IronPort-AV: E=Sophos;i="5.75,350,1589266800"; d="scan'208";a="390397762" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.147]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2020 00:04:26 -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 13/15] dax: Stray write protection for dax_direct_access() Date: Tue, 14 Jul 2020 00:02:18 -0700 Message-Id: <20200714070220.3500839-14-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 dax_direct_access() is a special case of accessing pmem via a page offset and without a struct page. Because the dax driver is well aware of the special protections it has mapped memory with, call dev_access_[en|dis]able() directly instead of the unnecessary overhead of trying to get a page to kmap. Like kmap though, leverage the existing dax_read[un]lock() functions because they are already required to surround the use of the memory returned from dax_direct_access(). Signed-off-by: Ira Weiny --- drivers/dax/super.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/dax/super.c b/drivers/dax/super.c index 021739768093..e8d0a28e6ed2 100644 --- a/drivers/dax/super.c +++ b/drivers/dax/super.c @@ -30,12 +30,14 @@ static DEFINE_SPINLOCK(dax_host_lock); int dax_read_lock(void) { + dev_access_enable(); return srcu_read_lock(&dax_srcu); } EXPORT_SYMBOL_GPL(dax_read_lock); void dax_read_unlock(int id) { + dev_access_disable(); srcu_read_unlock(&dax_srcu, id); } EXPORT_SYMBOL_GPL(dax_read_unlock); -- 2.25.1