Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp5341887rwn; Mon, 12 Sep 2022 07:44:16 -0700 (PDT) X-Google-Smtp-Source: AA6agR718pyphXo/RSlRIk90ioQ6C0wMC6zxs4K7GErtaEuFYeUFZarTuSau2aEFzUrlbt9a1Sv2 X-Received: by 2002:a17:902:dac4:b0:178:3037:680a with SMTP id q4-20020a170902dac400b001783037680amr5847046plx.37.1662993855900; Mon, 12 Sep 2022 07:44:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662993855; cv=none; d=google.com; s=arc-20160816; b=kWz8ip7kVEZgB3THaEvoNpdICmECqFdrQyaXVisYewv/Pg/jhaBvX/n4dTqcUrYLbR q7aNPJlDGhgOarrkpfVlvcVwR1vjFA4Or3rOkAznBg5PXFYVzfcEnH4XKy9b3IGxesNO JPsSe9MrRDCX0PLwkbh9QNNqi6/VgJbpd7y00mGHn65Q8xxf0QHDHtL9ZjgmJq7860Mr DA7SU3ZknZkrYwqKYeQzQxnSO1v94c+0gzeRubE6zP8HF0w9/6L1g5W7WgVOLRkxcoV5 JFRj1NRqDLg+hjnMOBqOAGMqLPk0uOjRu2sB+NVrtySweWgdZk8BmzsIUIjQt/N8X7Zn i/+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=60L4KlKfMOqnCfk/k65qx9B8UjK5837ivA1rkmKzT5I=; b=K+Kw+3sa/GTwu/FRI9iq7OujGtCGd1oxBxh/jX+NU0Geu6yokEanpwKqXeTeup7j5v 4LEm0FxWOLJe6HqGZEnuPC5awrZtuCbhPHpWG1QJ2bUtKWrQ8I9TByM0NokumZndh8jd Y2+oXlFNsoOXRVydhY+PZIdlVpavfjOb3s0gWfedgXf/ytuspldWeysPRQ2VhDGu85a7 fX+WycP9xH0uhID9JP8hYmTxLZvjfgelxsQD0g+IxUMWIq9ZpuFnwMxbgrD6IunjxPps G+YPmUfiwt+9BWjH3dTH7RwlInQLFc67CGolTB7dXSSAe0K7ShsNa1Kaf6SZuYxXWFIz Jk0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hxBYwAm3; 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 f17-20020a056a00239100b005373f74e4e3si8632737pfc.369.2022.09.12.07.44.04; Mon, 12 Sep 2022 07:44:15 -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=hxBYwAm3; 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 S230148AbiILOfI (ORCPT + 99 others); Mon, 12 Sep 2022 10:35:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229607AbiILOfF (ORCPT ); Mon, 12 Sep 2022 10:35:05 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 388E3167EC; Mon, 12 Sep 2022 07:35:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662993303; x=1694529303; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=lTQhPuGOrEhsApa+ZuBWBhTU3YqEpPMJQ+ugZRCuVU0=; b=hxBYwAm33bKAz7NeCmAAVr/l60jOdSBlR0Bgk7nqk4hS9VFysIJRQqpb 7AJUuS3Cd35r5jaWSDT/vu1W499G02lqWBtaRZ0fkA/sriv0yEGaulauj AN15XzJIg54Ab6ch8KKsnQJrK/4r6z5BUQ5ykfFz6i1eP/I8wYHxw3XjA VNR4Je5rqBaz4exgVTU5TqeN368I0ttBdFM5fSBerkUQp1a1LA89B/yTj 0QHF+c5/G0VXeymqnIYEVe2f6sDHbgWiPb+1vP4WVWkx44l7lIvD7Dh3+ DLYf5JG4Eags27wkQyOTRehuHBGmsMGY5u5AUGHk46vaJvldexoupdJQi A==; X-IronPort-AV: E=McAfee;i="6500,9779,10468"; a="384175166" X-IronPort-AV: E=Sophos;i="5.93,310,1654585200"; d="scan'208";a="384175166" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2022 07:34:38 -0700 X-IronPort-AV: E=Sophos;i="5.93,310,1654585200"; d="scan'208";a="646480527" Received: from jmwalsh-mobl.amr.corp.intel.com (HELO [10.213.220.208]) ([10.213.220.208]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2022 07:34:35 -0700 Message-ID: <28d7a4bf-591f-3afa-b9ea-526a14abc587@intel.com> Date: Mon, 12 Sep 2022 07:34:33 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH] x86/intel: Clear SGX bit if both SGX driver and KVM SGX are not enabled Content-Language: en-US To: Reinette Chatre , Jarkko Sakkinen , Kai Huang Cc: linux-sgx@vger.kernel.org, dave.hansen@linux.intel.com, seanjc@google.com, linux-kernel@vger.kernel.org References: <20220909080853.547058-1-kai.huang@intel.com> From: Dave Hansen In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,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 9/12/22 07:31, Reinette Chatre wrote: > > On 9/12/2022 3:47 AM, Jarkko Sakkinen wrote: >> On Fri, Sep 09, 2022 at 08:08:53PM +1200, Kai Huang wrote: >>> Currently on platform which has SGX enabled, if CONFIG_X86_SGX is not >>> enabled, the X86_FEATURE_SGX is not cleared, resulting in /proc/cpuinfo >>> shows "sgx" feature. This is not desired. >>> >>> Clear SGX feature bit if both SGX driver and KVM SGX are not enabled in >>> init_ia32_feat_ctl(). >>> >>> Signed-off-by: Kai Huang >> Is it a pattern that flags are cleared when they are disabled by the >> kernel? I don't know the answer for this. There's no good pattern. But, one guideline is that the X86_FEATURE_*'s are for the *kernel*. They are *not* for userspace. The fact that the features are exposed to userspace in cpuinfo is unfortunate, but it doesn't change our guideline. So, if this patch is done only for the benefit of userspace, I don't think we should apply it.