Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp4623084pxb; Wed, 20 Apr 2022 07:06:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxAMdvuTewD3WSlElweXnoWV9AlEt4wGZwMR/6D1TVbIEwPfyuR5ztuYn6Yf4UaIwdsDXun X-Received: by 2002:a1f:5c8e:0:b0:348:d8f9:df34 with SMTP id q136-20020a1f5c8e000000b00348d8f9df34mr6115878vkb.10.1650463599079; Wed, 20 Apr 2022 07:06:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650463599; cv=none; d=google.com; s=arc-20160816; b=B23XnqxDDCdSeovYV+fCX4tP6MjZhSCLypAThkIaj767HBo+RENLju4C9bvPW76Ama gtPsODcW9m8scpqf2Q4ZsRNcxVrFlcnNUD4Df6OgcO7PnFQVbPIDRY+5UBPjR6sghE+7 fp6opQQCXtiBRwFn59pmDa6R2X2bhiJYSEQo3sx5CKB+gY8AvtC1FjJkXdLV4ign1ndC BE76Nt+Xqa/lfMgfPZrd8Cgcho1/FIIB7PedFNm0EJpI7RFyqtho9bW3o2PjV21Rqt/k d8TJXVY643KM1II+kJ2/gqiqj3S+GJvkBn1QtgAX30wN7IujusGDoVHk9oMMj35efgnP Brtw== 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=16KRpwNgZI5Tn6v5CctsFLFRPO7eoMbrM9HmNPZ50kk=; b=E1ddFEcbBqMyS0fOhoalbRTLQh3a1sg6qj3sP22JgrQ9X6nW8w1/M+rq6VwMrB0iVF zci+TV3QymJ3KND9F9OdaUDee5ZDv5YV7qzWstpVvXjKWelMWwtt+b2GqILT5U2JLAue 2BbQhfqBBOlg9s8v62eWbMSZyuL6hvsuyYA5jTXXAxA+dqXNJ9JIbt6DGqso0qlSnofZ FdC26doROQFCKsfQobAW5s62CwDfdr1qTn+ky1lXuMG9iA70g4hRCCEX+XdOcShhIiUi efE8EGWGxDUucj7pM46WjHwlf4+1KC5qYW67YBkyUFtkteUWccJU54jHOt41HcP8Nytl 8pVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=c1wRbMFo; 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 x20-20020ab05ad4000000b0034c07a93b21si214288uae.188.2022.04.20.07.06.17; Wed, 20 Apr 2022 07:06:38 -0700 (PDT) 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=c1wRbMFo; 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 S237205AbiDSRKL (ORCPT + 99 others); Tue, 19 Apr 2022 13:10:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355576AbiDSRJr (ORCPT ); Tue, 19 Apr 2022 13:09:47 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8880125CE for ; Tue, 19 Apr 2022 10:07:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1650388020; x=1681924020; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3treoGF538ZRvO/T0g44eU89daYldwoSNScF2DK9tso=; b=c1wRbMFoUjauiQnLKrGko9zbVflt8LQ8772CGPWBWJZYRTnnV78Mj2uH ZlzGbZk68lBZtYIGIdiYaa23OVvjdXJ8W0Cx3nI5XOBa0yKVsLpM4zoAc S0hXENvWA5sVVwM2zlih+pzLgPtUC20fc2FTK5U7vciGnWbwdwkmzeY6S AafPy5/QHNAQ7jVpoUaTE+OWOUuVKDLnovUORjBCpkq8m2/ynxaHkpC0S 2JmyrpxTeQCcZZABWmJCL2tvPqUrfaaxErIqMVt2Q+l0xBf87Y2xHuHA4 iqgbQCnAOm+n+IwxcUESMuaqIUDdgCLXVEZuIIS7908AzL95bYqjk2uhK g==; X-IronPort-AV: E=McAfee;i="6400,9594,10322"; a="263280356" X-IronPort-AV: E=Sophos;i="5.90,273,1643702400"; d="scan'208";a="263280356" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Apr 2022 10:06:55 -0700 X-IronPort-AV: E=Sophos;i="5.90,273,1643702400"; d="scan'208";a="666579647" Received: from ajacosta-mobl1.amr.corp.intel.com (HELO localhost) ([10.212.11.4]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Apr 2022 10:06:54 -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 05/44] mm/pkeys: Add Kconfig options for PKS Date: Tue, 19 Apr 2022 10:06:10 -0700 Message-Id: <20220419170649.1022246-6-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=-5.0 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 From: Ira Weiny Consumers wishing to implement additional protections on memory pages can use PKS. However, PKS is only available on some architectures. For this reason PKS code, both in the core and in the consumers, is dead code without PKS being both available and used. Add Kconfig options to allow for the elimination of unneeded code by detecting architecture PKS support (ARCH_HAS_SUPERVISOR_PKEYS) and requiring an indication of consumer need (ARCH_ENABLE_SUPERVISOR_PKEYS). In this patch ARCH_ENABLE_SUPERVISOR_PKEYS remains off until the first kernel consumer sets it. Cc: "Moger, Babu" Signed-off-by: Ira Weiny --- Changes for V9 Dave Hansen Don't exclude AMD, cpu supported bits will properly turn the feature off. Clarify commit message Depend on CPU_SUP_INTEL Changes for V8 Split this out to a single change patch --- arch/x86/Kconfig | 1 + mm/Kconfig | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index b0142e01002e..c53deda2ea25 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1879,6 +1879,7 @@ config X86_INTEL_MEMORY_PROTECTION_KEYS depends on X86_64 && (CPU_SUP_INTEL || CPU_SUP_AMD) select ARCH_USES_HIGH_VMA_FLAGS select ARCH_HAS_PKEYS + select ARCH_HAS_SUPERVISOR_PKEYS help Memory Protection Keys provides a mechanism for enforcing page-based protections, but without requiring modification of the diff --git a/mm/Kconfig b/mm/Kconfig index 034d87953600..29c272974aa9 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -821,6 +821,10 @@ config ARCH_USES_HIGH_VMA_FLAGS bool config ARCH_HAS_PKEYS bool +config ARCH_HAS_SUPERVISOR_PKEYS + bool +config ARCH_ENABLE_SUPERVISOR_PKEYS + bool config PERCPU_STATS bool "Collect percpu memory statistics" -- 2.35.1