Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp690845ybt; Mon, 6 Jul 2020 20:39:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUqOpIKH/cRm+tSa5mQAf3DR7d2EGR7ZLwdcC5lLYETxZmb0D4c2tlVevv4wbOhI+Iu9HW X-Received: by 2002:a50:ee87:: with SMTP id f7mr60888331edr.355.1594093181525; Mon, 06 Jul 2020 20:39:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594093181; cv=none; d=google.com; s=arc-20160816; b=K2Q8Q9uP/yUCusYgPz/0IiO8mkL8h15Z5+2i6qFsxU5j8Ya3wGajtrc1Wb+uzZUOGt D0IusH+GcbOzRPOaeusNGzbMYS62Ds7KRcUF4KEbGXZ2pBvjMUwIKjtn+IJRJ9AXcG+n dRsenQvfFFDjhuLmL/W++QF66DGYeWxQn1NfdiyEcYoKnRnkGhaPjS351vKXsYgv55eh TqpCQLLszsBnEeBdSOxZZOd3bDqYAD4PnD4ZuyZ5bdIOXUPZSiMAmtLNeW5DN38XGFUw mQitY209DDHkqqv+WQSOgDzNDb/CnuthMk+Wqf36aUgQYOFS0rDb2TuXj6e45WThXeJn In1A== 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 :ironport-sdr:ironport-sdr; bh=JGDm7dhc2V3QsThQKoUGrAQlM4oo0M16MNY/+iRs3IM=; b=Fm+4wq4T5J3mTbIOx8RHcqzGEnkU1eN8172yJEzxddC66eNFxVTMiZ5dBmKkwwNsVD jVVYnxdAikT/xEagDISY2hdeX/FoFA0LekRXSpivspvGLf6pxFzzPo0hRL243axlCrW0 GrwL0mAITeLqsZrirkLAHQNWG40LI9HfQClBU8rr57s3pFvKib1u0abjpQs6X1ktrb4E g6ZAaRklSm8b23W5H2RmKsukYt/+vaBjCkRkUnIQMLahfSWTIt/dmN79S/m3wqQhg9kc wha0XMiHqxt684CcoHiBhGavOvIadaI8Eyg0KUxgCZRWo7yyrmHlaUMdoCOTpcTYDXq6 vrkg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id oq5si13380806ejb.110.2020.07.06.20.39.17; Mon, 06 Jul 2020 20:39:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1728224AbgGGDi0 (ORCPT + 99 others); Mon, 6 Jul 2020 23:38:26 -0400 Received: from mga05.intel.com ([192.55.52.43]:51716 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727871AbgGGDiZ (ORCPT ); Mon, 6 Jul 2020 23:38:25 -0400 IronPort-SDR: DGwDBL7wDYHPWeoltRn8VYAQyUqmTIVMYbrUHkeHns5g/dGIfDriaYNL+crHLbzA5LmKfldDZ2 JbUnQntzBB5A== X-IronPort-AV: E=McAfee;i="6000,8403,9674"; a="232394687" X-IronPort-AV: E=Sophos;i="5.75,321,1589266800"; d="scan'208";a="232394687" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2020 20:38:25 -0700 IronPort-SDR: jmGptrlNDI66DjBNA4P8MA0fdMsxVL0D6NnH5kn0f2VkWsSH6e+fOYbITqtD+ed/PZd/CqRF/W fktHPLci+lSg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,321,1589266800"; d="scan'208";a="427314193" Received: from apiccion-mobl1.ger.corp.intel.com (HELO localhost) ([10.249.45.178]) by orsmga004.jf.intel.com with ESMTP; 06 Jul 2020 20:38:14 -0700 From: Jarkko Sakkinen To: x86@kernel.org, linux-sgx@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Sean Christopherson , Borislav Petkov , Jethro Beekman , Jarkko Sakkinen , akpm@linux-foundation.org, andriy.shevchenko@linux.intel.com, asapek@google.com, cedric.xing@intel.com, chenalexchen@google.com, conradparker@google.com, cyhanish@google.com, dave.hansen@intel.com, haitao.huang@intel.com, josh@joshtriplett.org, kai.huang@intel.com, kai.svahn@intel.com, kmoy@google.com, ludloff@google.com, luto@kernel.org, nhorman@redhat.com, npmccallum@redhat.com, puiterwijk@redhat.com, rientjes@google.com, tglx@linutronix.de, yaozhangx@google.com Subject: [PATCH v35 02/24] x86/cpufeatures: x86/msr: Add Intel SGX Launch Control hardware bits Date: Tue, 7 Jul 2020 06:37:25 +0300 Message-Id: <20200707033747.142828-3-jarkko.sakkinen@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200707033747.142828-1-jarkko.sakkinen@linux.intel.com> References: <20200707033747.142828-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 From: Sean Christopherson Add X86_FEATURE_SGX_LC, which informs whether or not the CPU supports SGX Launch Control. Add MSR_IA32_SGXLEPUBKEYHASH{0, 1, 2, 3}, which when combined contain a SHA256 hash of a 3072-bit RSA public key. SGX backed software packages, so called enclaves, are always signed. All enclaves signed with the public key are unconditionally allowed to initialize. [1] Add FEAT_CTL_SGX_LC_ENABLED, which informs whether the aformentioned MSRs are writable or not. If the bit is off, the public key MSRs are read-only for the OS. If the MSRs are read-only, the platform must provide a launch enclave (LE). LE can create cryptographic tokens for other enclaves that they can pass together with their signature to the ENCLS(EINIT) opcode, which is used to initialize enclaves. Linux is unlikely to support the locked configuration because it takes away the control of the launch decisions from the kernel. [1] Intel SDM: 38.1.4 Intel SGX Launch Control Configuration Reviewed-by: Borislav Petkov Acked-by: Jethro Beekman Signed-off-by: Sean Christopherson Co-developed-by: Jarkko Sakkinen Signed-off-by: Jarkko Sakkinen --- arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/include/asm/msr-index.h | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index 545ac3e0e269..0a4541e4f076 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -352,6 +352,7 @@ #define X86_FEATURE_CLDEMOTE (16*32+25) /* CLDEMOTE instruction */ #define X86_FEATURE_MOVDIRI (16*32+27) /* MOVDIRI instruction */ #define X86_FEATURE_MOVDIR64B (16*32+28) /* MOVDIR64B instruction */ +#define X86_FEATURE_SGX_LC (16*32+30) /* Software Guard Extensions Launch Control */ /* AMD-defined CPU features, CPUID level 0x80000007 (EBX), word 17 */ #define X86_FEATURE_OVERFLOW_RECOV (17*32+ 0) /* MCA overflow recovery support */ diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h index 18e08da19f16..3d7c89a8533f 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -582,6 +582,7 @@ #define FEAT_CTL_LOCKED BIT(0) #define FEAT_CTL_VMX_ENABLED_INSIDE_SMX BIT(1) #define FEAT_CTL_VMX_ENABLED_OUTSIDE_SMX BIT(2) +#define FEAT_CTL_SGX_LC_ENABLED BIT(17) #define FEAT_CTL_SGX_ENABLED BIT(18) #define FEAT_CTL_LMCE_ENABLED BIT(20) @@ -602,6 +603,12 @@ #define MSR_IA32_UCODE_WRITE 0x00000079 #define MSR_IA32_UCODE_REV 0x0000008b +/* Intel SGX Launch Enclave Public Key Hash MSRs */ +#define MSR_IA32_SGXLEPUBKEYHASH0 0x0000008C +#define MSR_IA32_SGXLEPUBKEYHASH1 0x0000008D +#define MSR_IA32_SGXLEPUBKEYHASH2 0x0000008E +#define MSR_IA32_SGXLEPUBKEYHASH3 0x0000008F + #define MSR_IA32_SMM_MONITOR_CTL 0x0000009b #define MSR_IA32_SMBASE 0x0000009e -- 2.25.1