Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp719478img; Wed, 20 Mar 2019 09:25:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqzxWYpjb8Y7vTUQFgRbMdFzufQZE37uIU9/7hYu+fEfSFteW2qXYKNJigH51ukxrmYfXaED X-Received: by 2002:a63:bd51:: with SMTP id d17mr8155172pgp.117.1553099116398; Wed, 20 Mar 2019 09:25:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553099116; cv=none; d=google.com; s=arc-20160816; b=HzUM/KXg+RNQc2zcadckcxylN/sT/+yowP664Ez3PPxd4HmGOx/SoT14GXTm9k0M4W h30gSrnzRhKTCbHvYTICqFSxJqcitW8kCeuAV3cGbGKyLxTH8E8MGI5FNAlsIjppvwMP 19MAFiCen9eGhvC9/7aBd60+dNSomSffm7OJKIA7+bm7a2pNAx1qQXIEl27DBl/vmLNK IxlTJ4jw4tAdXqmpdZwPt3ngpYaAe4d85biHGHgf9ROMxyGUkolm6caZGCbNJaPdwR/I WBU5e1DBMUl/pEMpAclB0eatzvHCb+n9DToPJndhWpMDaRsDft/JLSGi1SbAw/Za5shF s5RA== 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; bh=MFhmtSDJRyvMmgHAXEsuzT7qcFT0Xk5KpRpt/Ta0LNU=; b=nu62aSOdG+IwzNgUse1ILmvcXtXm3p9udq/xPQMaXYopYFl6vPfsYz0qvjkvGQM6PE ol39SEfJzhs6TvKzY9YjGZHYHRY3UWJMfYAe3t8jFdzAmwZ6oWoj5eC8CGgRVam8q6Ad ud8WyC9Czz0w73T0gyo/IT19vijjYWeYvxkX7lVFpDVblTA1JGipWWHVagGDDSeqGPBy bQKVTOH9rtZCKd4SjmbOywQssKUVquqJNNzoqcy50/UbG7uOuLHlIT/w3sr4dlqAdZf1 17bHmE/Ev8BIpOKlODfq1JERgb3jImPxWpXNIFmGI3564mKTbkkDeTy7Unt0XBNgljH2 4grA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id s5si2036857pgi.181.2019.03.20.09.25.00; Wed, 20 Mar 2019 09:25:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727688AbfCTQXg (ORCPT + 99 others); Wed, 20 Mar 2019 12:23:36 -0400 Received: from mga07.intel.com ([134.134.136.100]:50574 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726295AbfCTQXg (ORCPT ); Wed, 20 Mar 2019 12:23:36 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Mar 2019 09:23:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,249,1549958400"; d="scan'208";a="135715071" Received: from sorenthe-mobl1.ger.corp.intel.com (HELO localhost) ([10.249.254.203]) by orsmga003.jf.intel.com with ESMTP; 20 Mar 2019 09:23:25 -0700 From: Jarkko Sakkinen To: linux-kernel@vger.kernel.org, x86@kernel.org, linux-sgx@vger.kernel.org Cc: akpm@linux-foundation.org, dave.hansen@intel.com, sean.j.christopherson@intel.com, nhorman@redhat.com, npmccallum@redhat.com, serge.ayoun@intel.com, shay.katz-zamir@intel.com, haitao.huang@intel.com, andriy.shevchenko@linux.intel.com, tglx@linutronix.de, kai.svahn@intel.com, bp@alien8.de, josh@joshtriplett.org, luto@kernel.org, kai.huang@intel.com, rientjes@google.com, Jarkko Sakkinen Subject: [PATCH v19,RESEND 11/27] x86/sgx: Add definitions for SGX's CPUID leaf and variable sub-leafs Date: Wed, 20 Mar 2019 18:21:03 +0200 Message-Id: <20190320162119.4469-12-jarkko.sakkinen@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190320162119.4469-1-jarkko.sakkinen@linux.intel.com> References: <20190320162119.4469-1-jarkko.sakkinen@linux.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 SGX defines its own CPUID leaf, 0x12, along with a variable number of sub-leafs. Sub-leafs 0 and 1 are always available if SGX is supported and enumerate various SGX features, e.g. instruction sets and enclave capabilities. Sub-leafs 2+ are variable, both in their existence and in what they enumerate. Bits 3:0 of EAX report the sub-leaf type, with the remaining bits in EAX, EBX, ECX and EDX being type-specific. Currently, the only known sub-leaf type enumerates an EPC section. An EPC section is simply a range of EPC memory available to software. The "list" of varaible SGX sub-leafs is NULL-terminated, i.e. software is expected to query CPUID until an invalid sub-leaf is encountered. Signed-off-by: Jarkko Sakkinen Co-developed-by: Sean Christopherson Signed-off-by: Sean Christopherson --- arch/x86/kernel/cpu/sgx/arch.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/arch/x86/kernel/cpu/sgx/arch.h b/arch/x86/kernel/cpu/sgx/arch.h index 7a2f293db32c..e966cdd68040 100644 --- a/arch/x86/kernel/cpu/sgx/arch.h +++ b/arch/x86/kernel/cpu/sgx/arch.h @@ -10,6 +10,21 @@ #include +#define SGX_CPUID 0x12 +#define SGX_CPUID_FIRST_VARIABLE_SUB_LEAF 2 + +/** + * enum sgx_sub_leaf_types - SGX CPUID variable sub-leaf types + * %SGX_CPUID_SUB_LEAF_INVALID: Indicates this sub-leaf is invalid. + * %SGX_CPUID_SUB_LEAF_EPC_SECTION: Sub-leaf enumerates an EPC section. + * %SGX_CPUID_SUB_LEAF_TYPE_MASK: Mask for bits containing the type. + */ +enum sgx_sub_leaf_types { + SGX_CPUID_SUB_LEAF_INVALID = 0x0, + SGX_CPUID_SUB_LEAF_EPC_SECTION = 0x1, + SGX_CPUID_SUB_LEAF_TYPE_MASK = GENMASK(3, 0), +}; + /** * enum sgx_encls_leaves - ENCLS leaf functions * %SGX_ECREATE: Create an enclave. -- 2.19.1