Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3979438ybg; Mon, 28 Oct 2019 23:51:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqwHi1IfdfwxxWK25vA8IIWn+7dVXiTTt4HWS7UORWa5bKftwkhtLwwjsCbgmJscx0VqpTeP X-Received: by 2002:aa7:ccda:: with SMTP id y26mr23790326edt.130.1572331874307; Mon, 28 Oct 2019 23:51:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572331874; cv=none; d=google.com; s=arc-20160816; b=A53Yl+zTNijZde7PAzMlqsyUP910WOnr/Os1n2kM2ymNvr9g6Xj0YD9bdtebMSOBKy yZmDXd/2UVIPL56SfBaHLpVOm08Bwws5BqP6dHOmRKmfTHllHsCivACdr+HwjZKe1Xzq dFl6tmMzZyivdJorjJYWINdP3JveYdYdPpnEwYSNTceCTm1+TBZ71Br8I8qsmsjvoojD Oarm0MuDSjb1tdY/QmDLD5CbJd7XaXaSU1n93mvZ68/+1ngYtEY8LorbcAbyt3qGEXMT OBSOeJmHvIu53gRqVBH3EkWdX7z7x/qStVVsVqFGBSkGg22/OSgz5kZ6c/C1nKBDTi4u TuQA== 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=OVh2Rk0QDpRLC2+oz+BkkfgZwlddW/MTfwfujej4MqE=; b=RFCb45sP0ITS6Gz7sr+dNJ9WBH3g5KhAUHOWmHehrbuXni/QQooY37j5m/MojGqrWW mEyYj5vM2SuDB2KbOlVGcVD1fPuHAw6DX675IUpW7PwIIGbtz47stG2HUuhzt/h9mgHO BuPa2VAB9kGHNPew6hz3a2uYtOnWtvk6ZZesTUzf5tVk+cKSFglhRDfbv/Jiw04dtVMQ eyealx2+h+2jGdYLPfkl0zXKYiXACQKyTe5NcIy7MKQgIkvIvnMyKe12YeL+WeR85jRj IoNV1M2iAey6glrpWLKZo6EA9lhYhEksOiYjBv2gyWqWjDhcqqLG4qn6XZZjF5YuP4FK cJUw== 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 f18si7850466ejx.45.2019.10.28.23.50.51; Mon, 28 Oct 2019 23:51:14 -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 S2388893AbfJ1VEK (ORCPT + 99 others); Mon, 28 Oct 2019 17:04:10 -0400 Received: from mga05.intel.com ([192.55.52.43]:7327 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388873AbfJ1VEJ (ORCPT ); Mon, 28 Oct 2019 17:04:09 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Oct 2019 14:04:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,241,1569308400"; d="scan'208";a="205281284" Received: from shrehore-mobl1.ti.intel.com (HELO localhost) ([10.251.82.5]) by FMSMGA003.fm.intel.com with ESMTP; 28 Oct 2019 14:04:00 -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, cedric.xing@intel.com, puiterwijk@redhat.com, Jarkko Sakkinen Subject: [PATCH v23 03/24] x86/cpufeatures: x86/msr: Intel SGX Launch Control hardware bits Date: Mon, 28 Oct 2019 23:03:03 +0200 Message-Id: <20191028210324.12475-4-jarkko.sakkinen@linux.intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191028210324.12475-1-jarkko.sakkinen@linux.intel.com> References: <20191028210324.12475-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 FEATURE_CONTROL_SGX_LE_WR bit of the feature control MSR, which informs whether the formentioned 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 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 0872fec45534..71ccc14511f9 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -358,6 +358,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 975a957a791a..7dadfcfe6afd 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -551,6 +551,7 @@ #define FEATURE_CONTROL_LOCKED (1<<0) #define FEATURE_CONTROL_VMXON_ENABLED_INSIDE_SMX (1<<1) #define FEATURE_CONTROL_VMXON_ENABLED_OUTSIDE_SMX (1<<2) +#define FEATURE_CONTROL_SGX_LE_WR (1<<17) #define FEATURE_CONTROL_SGX_ENABLE (1<<18) #define FEATURE_CONTROL_LMCE (1<<20) @@ -564,6 +565,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.20.1