Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1542369ybh; Tue, 14 Jul 2020 00:05:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyt7W2bb9jSD7XMBT27tsmEfE89BFKdKvG8c7x3l8hdAIhaQXPILNIWh9S4wG9dqRut9+fl X-Received: by 2002:aa7:cf02:: with SMTP id a2mr3071598edy.263.1594710319418; Tue, 14 Jul 2020 00:05:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594710319; cv=none; d=google.com; s=arc-20160816; b=rNWctu8mIqzJfMRA8OEQ31xb0DQc1paugEGOh0LHXxDxkM5JNwKDnwCzY829L5382n um8BAR0u7TDuzi/hkR/VuOLazRSVitYbaDuBHDkB5PQF+D/Ot9veHRLA+XM6rPhyt1vg qsuRoY6N8y8D96lBPqbqW8lD+J4yzzGUpVubgXRlWK69egO1vvcAdo8D8dSZvOQQRPWO MhZNDdYJINCz5MdcEXSeH7O1OzqhDITWT2IUp2DrC/eQTDtAJZUmYgzf6REHJfQVYaGT CcQioMxlLPfm3HdYmga2qDAQyaFQZz5VySlJTJNnGca2BL6CeC5t+Md5vmwixiw7gEjE 75xQ== 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=OrPPPJUjMLLj9a41uEAKPxyGpMSAEVcT6BJ/qMykjNs=; b=wthV+byMyT9sIxf2UGZ9CXhLuguKfsz3wE8k6Bw/RYOLYp/HAYpoqgL4JaDBCwU998 fbYrMTpXJLvBhY7EvhJzFzvNNqfhzU2dfwjsc8OR26a9xmpIzTaPmH4+adQZFmnaSUSO UXLUoOyW8BkuCmI0lp+iFDgBpPdhG+jBqxm5K+lDCPNzVNaKZtIJHyfVunnyRUaUogN7 dpeVqFZ57hm7aWaFEFc8nfBN385cTUAyjfrJgurqN2nT8EZ9dIQwbvXaVUUfOPJBVe2f fouU0TKC0sTfPwan+xmcX+P/hO7bBaGymXiuLp2YAF5xDjfacFxmVDJ5Vhop8mqSq1Al Smqg== 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 dm22si10752327edb.499.2020.07.14.00.04.56; Tue, 14 Jul 2020 00:05:19 -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 S1727085AbgGNHEg (ORCPT + 99 others); Tue, 14 Jul 2020 03:04:36 -0400 Received: from mga01.intel.com ([192.55.52.88]:38972 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727025AbgGNHE2 (ORCPT ); Tue, 14 Jul 2020 03:04:28 -0400 IronPort-SDR: i7PHFqUKWuxp5lv35VRP21KvIozxwHJg1WLpeQaFVUuVqNIbWjLGxpCJUzDAjII+uR5hshyBHH Bfdkih2LvyHg== X-IronPort-AV: E=McAfee;i="6000,8403,9681"; a="166930866" X-IronPort-AV: E=Sophos;i="5.75,350,1589266800"; d="scan'208";a="166930866" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2020 00:04:28 -0700 IronPort-SDR: 2GlF4QiJnNhoGgMJ5XMp7xdyQ0iPfyqW+HUR8m12RTg7zWuuTG19TEkAYr8cw+FwjIa2w1Dc3M MV33WpvpzAfw== X-IronPort-AV: E=Sophos;i="5.75,350,1589266800"; d="scan'208";a="269934896" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.147]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2020 00:04:28 -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 14/15] nvdimm/pmem: Stray write protection for pmem->virt_addr Date: Tue, 14 Jul 2020 00:02:19 -0700 Message-Id: <20200714070220.3500839-15-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 The pmem driver uses a cached virtual address to access its memory directly. Because the nvdimm driver is well aware of the special protections it has mapped memory with, we call dev_access_[en|dis]able() around the direct pmem->virt_addr (pmem_addr) usage instead of the unnecessary overhead of trying to get a page to kmap. Signed-off-by: Ira Weiny --- drivers/nvdimm/pmem.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index d25e66fd942d..46c11a09b813 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -148,7 +148,9 @@ static blk_status_t pmem_do_read(struct pmem_device *pmem, if (unlikely(is_bad_pmem(&pmem->bb, sector, len))) return BLK_STS_IOERR; + dev_access_enable(); rc = read_pmem(page, page_off, pmem_addr, len); + dev_access_disable(); flush_dcache_page(page); return rc; } @@ -180,11 +182,13 @@ static blk_status_t pmem_do_write(struct pmem_device *pmem, * after clear poison. */ flush_dcache_page(page); + dev_access_enable(); write_pmem(pmem_addr, page, page_off, len); if (unlikely(bad_pmem)) { rc = pmem_clear_poison(pmem, pmem_off, len); write_pmem(pmem_addr, page, page_off, len); } + dev_access_disable(); return rc; } -- 2.25.1