Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp64330pxk; Tue, 15 Sep 2020 17:57:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwkeAdntMqYslRm05otC3sHt7eQ2vfM5z/G2mIcFKEpK5Wrsv/HEenoHBWDXYs1Ecp7QYFG X-Received: by 2002:a17:906:4cc7:: with SMTP id q7mr23178068ejt.437.1600217875224; Tue, 15 Sep 2020 17:57:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600217875; cv=none; d=google.com; s=arc-20160816; b=tRDO2CyFwoYvTfpvAr8gCxdNI4XWLjADmUWuJoU6t7AN+CZ+5RBOO09h9dELO9rw9d N4wbsAPORpz5NM9iXkyth0hA+vDFH64GeE4yVivjkhEYhStbI91le3MIye6xUYb2wC85 nIDAWesugXSP4Lx1N0ifrcdcUGNzfTA7XZtIoDlMKJR3AKAg5wIIEiFJwr9UzfC4hUDo Pj9MhPagIgY8yDBMRP8oS+Wgd3LqBs97O5hyn1KMzTOLJrY7EGlAgf58exxn8a82PEdk KuBk+R4y5hinrgyC0mMXWr5CxcNaMFF63yyDV1puKUrLN4GM5SbZRVXo3fInBMal7VOx oleA== 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 :dkim-signature; bh=Dw0RXYIryfkngJ4OEuc3gpztJP0jIMz1MlJhMluSPdE=; b=AxrZ9Yror1lE1vuFe53q0Sl83cRLTzmeBnptFPXkFwmFRq8YOWJpRZJC8mPKxF7bAM w+u6ImvMLdMDw9KsPGBXcp56jGQpNke76pI62ICtGEUpQU2BBekQtDy1poTPmhBzRV7e rJGvjdKA2ikA4Nc+UhYnbwubdYdq8hK0ulFrOsS7S/mQHmsCYOCM1TD743FwbU+tsVJX nkOHHzniTabAFLBLhcj0nAhuz1E9bGezPuXqQ5GCEIwy07p8uy1rwg7zA1479R/nGkEM V7qSZMn0nnks/tLS/adgLlx0FtSHUr4uAvQIYuY/Wrrcy3ClwleSbarhsM8FxDECTWnk kcYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@kapsi.fi header.s=20161220 header.b=OhtFJ70B; 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 y16si11257097edm.444.2020.09.15.17.57.32; Tue, 15 Sep 2020 17:57:55 -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; dkim=fail header.i=@kapsi.fi header.s=20161220 header.b=OhtFJ70B; 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 S1726373AbgIPAyV (ORCPT + 99 others); Tue, 15 Sep 2020 20:54:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726302AbgIOLbo (ORCPT ); Tue, 15 Sep 2020 07:31:44 -0400 Received: from mail.kapsi.fi (mail.kapsi.fi [IPv6:2001:67c:1be8::25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 053D6C061353; Tue, 15 Sep 2020 04:28:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kapsi.fi; s=20161220; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Dw0RXYIryfkngJ4OEuc3gpztJP0jIMz1MlJhMluSPdE=; b=OhtFJ70BLiCUJMMBYxd+LQvX2w 3rn+vs4G5gHH+62KgwUHUDuv5FzdoHTOQAfyXq9XwswRk0J29z3Tciku20kk/0sGYeD7gyhVNbAj2 Wdl66I2ncMEp2GEYGyu71mSUOPToFhOtmWMksGgl/bzGGLSJDWnIFTXuhXVZZ+eN3GcCe8jM9dm83 dksViErq0MgSfaJviGEnc+5FSFmQ/p+8qhI1SYDBgXKElVXfF7sOV3OqUPudSYrf6ATQH4roUsDjY 9WXZKlieXY2iQJWXKjhCvYDitt/NcgLtC+kbZWw/v26BAMSpT8CN4EyUBtcqoiMB4YfXBe0n8VTtT a5CHiIwA==; Received: from 83-245-197-237.elisa-laajakaista.fi ([83.245.197.237] helo=localhost) by mail.kapsi.fi with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1kI98g-0000hc-Jm; Tue, 15 Sep 2020 14:28:46 +0300 From: Jarkko Sakkinen To: x86@kernel.org, linux-sgx@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Sean Christopherson , Borislav Petkov , Jethro Beekman , Darren Kenny , 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 v38 02/24] x86/cpufeatures: x86/msr: Add Intel SGX Launch Control hardware bits Date: Tue, 15 Sep 2020 14:28:20 +0300 Message-Id: <20200915112842.897265-3-jarkko.sakkinen@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200915112842.897265-1-jarkko.sakkinen@linux.intel.com> References: <20200915112842.897265-1-jarkko.sakkinen@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 83.245.197.237 X-SA-Exim-Mail-From: jjs@kapsi.fi X-SA-Exim-Scanned: No (on mail.kapsi.fi); SAEximRunCond expanded to false 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 Reviewed-by: Darren Kenny 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 159b635159c0..398e4f19c3d7 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -354,6 +354,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 c0b04f020162..e574b4bb5aad 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -602,6 +602,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) @@ -622,6 +623,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