Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp4150021pxm; Tue, 1 Mar 2022 12:20:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJzxCms13BtwPgOJOQ81bcH3aYyN+Jrbp6L+fwJ9tHofI5mqg+XcgOFFIOb5XOm8izpH2dCw X-Received: by 2002:a17:906:7056:b0:6d6:dd99:f2a4 with SMTP id r22-20020a170906705600b006d6dd99f2a4mr5423675ejj.43.1646166037650; Tue, 01 Mar 2022 12:20:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646166037; cv=none; d=google.com; s=arc-20160816; b=oMPgFWT7Xl/LNz1ikj8CL0MWmTb//qcb2wLJqj61IJApHKCpLgOj6WqLxG34L18NQa g6UXnco+GAgteEXBFST/j2h+ZtXL5LelK2tx5LXVPdAlnHb58AxfPTmv475RAoaCZBA2 YYnR+S8rM578wBDRg/2mO1O6eb//OttMCTUmk19UAH/tsDFfujWDNyD3yn6qI0jDsMxc pwbl3glz9MO5D9E48s75cJwwBIIpf9AJtf2B2hRBnSO/PnD3vKMfmIoq4M85UwR8kh2v XlESsX7DuOXRTJv9IERRREp3s2EVyIazk8wuOtuidXFVT1wNH6GGDnvFyj7SAdMr76QP 9LzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=M2W0cyNSRTSmN2XSdjAmjU6MCSSjm9ImIGsUBpEMHQ8=; b=eEPymJ7wfEXQpCwM1EDQnUfLIbTi8EdyjUx6V0KlomSaPI1D+hTWvNJQv/9INzxyRR e2NcKyN2VMeIqBa05r30frWOFItFyln+ampBKo7Rp6nEH/4HnEjnUoFPpbtydEWYwjXP FgDpfN6lJ0/GGIf0j8VlbrGYroKkJtbEsNu752URHtCp51NqfMsnZn6mb6EBu6v4WREv +iPuNkNEpKb2vgRl4vY/7yWmYt0GlZEaE4j4p4VwzqONiwa87bzczR08rScQkOR3BuAO Zpwt6sSAuD9LDXunroO9Zk/ERIK2xFCs6nrxdjOEdsIABYka86cu5e99rEad2Yt7lXUg 6gRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dvJt3Jmu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w7-20020aa7d287000000b00410d7181b8fsi8954586edq.518.2022.03.01.12.20.13; Tue, 01 Mar 2022 12:20:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dvJt3Jmu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236856AbiCASOf (ORCPT + 99 others); Tue, 1 Mar 2022 13:14:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235929AbiCASOd (ORCPT ); Tue, 1 Mar 2022 13:14:33 -0500 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B327A24BDA for ; Tue, 1 Mar 2022 10:13:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646158432; x=1677694432; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=eyJL07c9fgvnRU+ZPSiuOTMVvgv6cbmEG2Rg/8bgmzU=; b=dvJt3JmuexlpQCckiJaJytkxILOkEuKmFGjcREw3K5uD/mpq314Oj/R9 DOxZndLmKPNXrlzvw4nGlI1yguHXFfzTJ3tekXzZ0A8VermW04JF/UV/i 8lTQbdDMJuoUZa4Vvj9GQmm6N/CnRc2bMLyPkevOBSaxK3n3AgNjITaMp lv0CVYZxYsJLBDhayBLS715RrhTmWEHiUFGBYwvCC17xggp0IAAyY/cH/ 6sAiZGmuD0kz0qNYW/QpxSWBz86/yunVIM64WpMOD/uncMZitxoQqlNMF 5bnPVgdRceoJyu96OY42ge3za/MmHAkaXbVaJE3UpST77aGF9Zqbdp/p3 Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10273"; a="252937935" X-IronPort-AV: E=Sophos;i="5.90,146,1643702400"; d="scan'208";a="252937935" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Mar 2022 10:13:52 -0800 X-IronPort-AV: E=Sophos;i="5.90,146,1643702400"; d="scan'208";a="535003514" Received: from bklinvil-mobl.amr.corp.intel.com (HELO localhost) ([10.212.48.220]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Mar 2022 10:13:52 -0800 Date: Tue, 1 Mar 2022 10:13:51 -0800 From: Ira Weiny To: Dan Williams Cc: Dave Hansen , "H. Peter Anvin" , Fenghua Yu , Rick Edgecombe , Linux Kernel Mailing List Subject: Re: [PATCH V8 42/44] dax: Stray access protection for dax_direct_access() Message-ID: References: <20220127175505.851391-1-ira.weiny@intel.com> <20220127175505.851391-43-ira.weiny@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 03, 2022 at 09:19:58PM -0800, Dan Williams wrote: > On Thu, Jan 27, 2022 at 9:55 AM wrote: > > > > From: Ira Weiny > > > > dax_direct_access() provides a way to obtain the direct map address of > > PMEM memory. Coordinate PKS protection with dax_direct_access() of > > protected devmap pages. > > > > Introduce 3 new dax_operation calls .map_protected .mk_readwrite and > > .mk_noaccess. These 3 calls do not have to be implemented by the dax > > provider if no protection is implemented. > > > > Threads of execution can use dax_mk_{readwrite,noaccess}() to relax the > > protection of the dax device and allow direct use of the kaddr returned > > from dax_direct_access(). The dax_mk_{readwrite,noaccess}() calls only > > need to be used to guard actual access to the memory. Other uses of > > dax_direct_access() do not need to use these guards. > > > > For users who require a permanent address to the dax device such as the > > DM write cache. dax_map_protected() indicates that the dax device has > > additional protections and that user should create it's own permanent > > mapping of the memory. Update the DM write cache code to create this > > permanent mapping. > > > > Signed-off-by: Ira Weiny > [..] > > diff --git a/include/linux/dax.h b/include/linux/dax.h > > index 9fc5f99a0ae2..261af298f89f 100644 > > --- a/include/linux/dax.h > > +++ b/include/linux/dax.h > > @@ -30,6 +30,10 @@ struct dax_operations { > > sector_t, sector_t); > > /* zero_page_range: required operation. Zero page range */ > > int (*zero_page_range)(struct dax_device *, pgoff_t, size_t); > > + > > + bool (*map_protected)(struct dax_device *dax_dev); > > + void (*mk_readwrite)(struct dax_device *dax_dev); > > + void (*mk_noaccess)(struct dax_device *dax_dev); > > So the dax code just recently jettisoned -the >copy_{to,from}_iter() > ops and it would be shame to grow more ops. Given that the > implementation is pgmap generic I think all that is needed is way to > go from a daxdev to a pgmap and then use the pgmap helpers directly > rather than indirecting through the pmem driver just to get the pgmap. Ok done. dax_device now has knowledge of the pgmap which was pretty clean. Ira