Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp949518pxb; Fri, 22 Apr 2022 15:07:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwCH2ZuRoCnSrluIdjuHgAOu9KhaaVSNyuMiPfDueAgMs90mjOJRDvkFGzyJ2QHreye5h7N X-Received: by 2002:a17:902:f70f:b0:153:ebfe:21b3 with SMTP id h15-20020a170902f70f00b00153ebfe21b3mr6426072plo.119.1650665243852; Fri, 22 Apr 2022 15:07:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650665243; cv=none; d=google.com; s=arc-20160816; b=NaAhLWbmarI62qyWE0tftoqN0k+KKbP0oV/JXJicrkU4eYtD0UuB6+DuLcbBqvk/Xm h6CC4uc3mAKATsEtBzeR86RwV2J5QVL2vQ/hV1SvzxYfEo3dragVdNrf/OmmgvYZQMJ9 7C/buHkHAHw/cndO3m0pgi+mceEziXqmhzKZ5TkL9fhjbBDmO7sErO0uqnnZGdcn1ItJ Qg39pwMZNTvtcUozYOiDiw51N89wwfLGxlBI/R+z9DEPbfhkbO3ninobWSbEhCJBgskE kwTQtr2eWO/FpWFbhOcHpCZ7gWQekkKw7UTDtKcP1Pl5BDemNnsykf2NNnY7SvrEO0bn zeJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=v3QhvNBqoY192z9W9b4yBtZOVMAy++LYGfOQqq4SxdU=; b=Tj0thjJMN8UFpXxLkVjZ/daVFhIoilfRhadWgqzVUErn0uhBw2B9PaFf5uGrThZXN8 DhAUvZ87/QLmxmt3WtXYsHYa7bB11IDmSttna5jcHoLm8Zjt73U7zkRNZYrqnUVbVcdi 5r/hNbRfrmqijZhtEZj9R3xfuLRDRAxyinTpLDf5K0OGz3MEn+7Q21A91IzZ5VObec19 giTj0Pp1IExUfCFs6BT+4QTdrfoHGGJqCBO8satnn5doGOnygtfQhYhVQ237bmkOH8RA 3IJyoxDT0x8R3Fd9NI+dSBJK1HYCY/m+39Kz1QUZKt9QJxGpWZMXYqvaY4Kuw6foIX4V L6Yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=U6qi3nPg; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id f7-20020a170902860700b00156ae419651si8818006plo.401.2022.04.22.15.07.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 15:07:23 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=U6qi3nPg; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 75FC02784FB; Fri, 22 Apr 2022 13:13:51 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355910AbiDSRLJ (ORCPT + 99 others); Tue, 19 Apr 2022 13:11:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355657AbiDSRJ4 (ORCPT ); Tue, 19 Apr 2022 13:09:56 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95728EA5 for ; Tue, 19 Apr 2022 10:07:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1650388032; x=1681924032; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8HY8BDua6BN4XkwHxR01tuvztdYTdoms4hurcP8Ocpo=; b=U6qi3nPgQlvWwHsJBPyCKGZ8EofngQ1XOE7OJmb7mH2+kzbVocAl6DmN rT9+sYjxZhaMldriTek4uZoqm6szYSe/O0i79U3mWa6FZuJCSzZdqgnij TF7tEXAAGWSvzFgFefCqFY8XxQzicIc8prhsWvuwFnMCCA9cKLuB1zL/m 9wHEnZcx6CkgCfM+6Sy1G3/YNXDvYjpp7MftpQ6OP/2Yxz4/WrcTb3gSc 3W1VBHTvnX+ZXRMMB9KuktVABofp+AviJrJTT2lBVA2M6oBta7fGVRCUC knzrc6Qlhvq/vrO//Cir670VKGO+Tp41tUKp4m24p98aNz8+3Qfkkis+e Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10322"; a="350267610" X-IronPort-AV: E=Sophos;i="5.90,273,1643702400"; d="scan'208";a="350267610" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Apr 2022 10:07:12 -0700 X-IronPort-AV: E=Sophos;i="5.90,273,1643702400"; d="scan'208";a="510207192" Received: from ajacosta-mobl1.amr.corp.intel.com (HELO localhost) ([10.212.11.4]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Apr 2022 10:07:11 -0700 From: ira.weiny@intel.com To: Dave Hansen , "H. Peter Anvin" , Dan Williams Cc: Ira Weiny , Fenghua Yu , Rick Edgecombe , "Shankar, Ravi V" , linux-kernel@vger.kernel.org Subject: [PATCH V10 26/44] memremap_pages: Introduce pgmap_protection_available() Date: Tue, 19 Apr 2022 10:06:31 -0700 Message-Id: <20220419170649.1022246-27-ira.weiny@intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220419170649.1022246-1-ira.weiny@intel.com> References: <20220419170649.1022246-1-ira.weiny@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=unavailable 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 From: Ira Weiny PMEM will flag additional dev_pagemap protection through (struct dev_pagemap)->flags. However, it is more efficient to know if that protection is available prior to requesting it and failing the mapping. Define pgmap_protection_available() to check if protection is available prior to being requested. The name of pgmap_protection_available() was specifically chosen to isolate the implementation of the protection from higher level users. Signed-off-by: Ira Weiny --- Changes for V10 Move code from mm.h to memremap.h Upstream separated memremap.h functionality from mm.h dc90f0846df4 ("mm: don't include in ") Changes for V9 Clean up commit message From Dan Williams make call stack static inline throughout this call and pks_available() such that callers calls cpu_feature_enabled() directly Changes for V8 Split this out to it's own patch. s/pgmap_protection_enabled/pgmap_protection_available --- include/linux/memremap.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/linux/memremap.h b/include/linux/memremap.h index 8af304f6b504..7980d0db8617 100644 --- a/include/linux/memremap.h +++ b/include/linux/memremap.h @@ -6,6 +6,7 @@ #include #include #include +#include struct resource; struct device; @@ -214,4 +215,20 @@ static inline void put_dev_pagemap(struct dev_pagemap *pgmap) percpu_ref_put(&pgmap->ref); } +#ifdef CONFIG_DEVMAP_ACCESS_PROTECTION + +static inline bool pgmap_protection_available(void) +{ + return pks_available(); +} + +#else + +static inline bool pgmap_protection_available(void) +{ + return false; +} + +#endif /* CONFIG_DEVMAP_ACCESS_PROTECTION */ + #endif /* _LINUX_MEMREMAP_H_ */ -- 2.35.1