Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp103476ybg; Sun, 31 May 2020 18:20:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzrIe9ZAcKA6NLI4naxm3yIzGZeuOlTqFySPZUzfsCp+8rsnFZLWFZnEUeAQslPslkxLhnP X-Received: by 2002:a17:906:fc20:: with SMTP id ov32mr10478922ejb.531.1590974401766; Sun, 31 May 2020 18:20:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590974401; cv=none; d=google.com; s=arc-20160816; b=shMD7YZW9vTO6N6oHlK3YeIbzVtmbgtMpoFxp9LCryrTKiObNHh/v0gqJHahNXT0L0 jFzJEtjUA2MMiucEoS3rgLlLPmwYIhq+JnKAVIhbgPzoqCNTVoArz2PGKsYRTHzUfdQq zcQKKJSuRqijLwOyC5lUaqi+NWzGdmYz02UWdNQqc0lmziprjHZCJTj3+uc0JvszVwxc fUQZOFtdmeKbHSDZSQMlNpb8RR9r5+Wfz413vV6kWti3pszSWorDT1m7zBmZzJ0sgld8 1eKrROG4tQpU53xIBEwT3rYZtU6xn92pbFCGfU2LVTOwCQqwL5HmwmY02uGFl0j6uYFA 990w== 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=xbCwaOnvnuHIejD14UD1Z+ZYOcR7tC11Eo9kpP1pKw0=; b=l+xFl07KfBIHv/GqTMuOEaOuTnfhXpwHTV1kIP+hBK8rjOYBRHBTZjXzYKpcU9LZzQ t9JVmcx027FC00x0kFFv7LX5fwDzuZMyC56gdlEylX6EnpCqTspwaudGiLfBW7/KSebN x5SSSdEZaRn356B+eGgwn30TWsNcApqm1WtDTRNXzvxBbt7ZYsg8Fa8hNl3w5r/1hWS8 2W8pHCQMdM/Lzv6zIasrZNfhyJ6LkbrYKVY4FS7hnLJ2vjyH/sRXTWVabyqnpYPeTvtX /bP3MBLWNRbCYyxCh2EM0dyz/owpPGtm2b1Z4AHypO4KTiB3hWHeTZIzuhNjHcTyAbs5 PmIQ== 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 u21si5745600edq.299.2020.05.31.18.19.38; Sun, 31 May 2020 18:20:01 -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 S1727842AbgFABR1 (ORCPT + 99 others); Sun, 31 May 2020 21:17:27 -0400 Received: from mga17.intel.com ([192.55.52.151]:30442 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726555AbgFABR1 (ORCPT ); Sun, 31 May 2020 21:17:27 -0400 IronPort-SDR: BiTCngnFycXeaMm5GfQp1gKZVYARuUAO3majZ11V9ImEOwmLcrf7musSRZtsaNvNvCEde3171a DyKeT9dcFETQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 May 2020 18:17:27 -0700 IronPort-SDR: nQUSIBqWfdNxz9HRxdxZzxLcafWopyFk1A8NXCjVPym7gWgu4EHs7HfTqUxRfl67mT9Qb2xnLk B4dqL7VrdZiQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,459,1583222400"; d="scan'208";a="268156930" Received: from hbetts-mobl.ger.corp.intel.com (HELO localhost) ([10.252.59.178]) by orsmga003.jf.intel.com with ESMTP; 31 May 2020 18:17:14 -0700 From: Jarkko Sakkinen To: linux-kernel@vger.kernel.org, x86@kernel.org, linux-sgx@vger.kernel.org Cc: Sean Christopherson , Jethro Beekman , Jarkko Sakkinen , akpm@linux-foundation.org, andriy.shevchenko@linux.intel.com, asapek@google.com, bp@alien8.de, 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 v31 02/21] x86/cpufeatures: x86/msr: Add Intel SGX Launch Control hardware bits Date: Mon, 1 Jun 2020 04:16:26 +0300 Message-Id: <20200601011645.794040-3-jarkko.sakkinen@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200601011645.794040-1-jarkko.sakkinen@linux.intel.com> References: <20200601011645.794040-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 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 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 fc4422f747d5..c2f8962e8468 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 a277d33006c0..4b2e9c25cde3 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -575,6 +575,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) @@ -595,6 +596,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