Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp2690861imd; Fri, 2 Nov 2018 16:16:38 -0700 (PDT) X-Google-Smtp-Source: AJdET5dlwtqH+C6ue4j6sSAuQx2VMmHOmSYxOZy2ew7Qaew7LhbCo5TsY8nqposRKEf+3scWGX8G X-Received: by 2002:a65:5a05:: with SMTP id y5-v6mr12472382pgs.161.1541200598515; Fri, 02 Nov 2018 16:16:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541200598; cv=none; d=google.com; s=arc-20160816; b=RWT0XIGfywAxgsi62Q4Huk4c1asD4VlymnvPNB8F93ZicoN9g58q879XYPFujXQGRs QcAzmMdxEiU6m1fkcxSgCsrTCYho5U4R4Yrfui7hwe0IiAWUiPg9lXRF/oAeYgTgQhao QO0p55Cwxz3lLzF0mrITPUFImqE/PGTpJqbGk1TGvMAj2GQqBpNSlmjBr9FLYHBoyR8Z m223p117q4CTMXZSM8lpz2gTXHxfnJBsoAd5L1Z2ndNmhqBSudq8L9aVSLky7dwJhc7t khvPjedsqah1AnPkh6asDcCGRyDFOv7wOy9MLf1X1Vcf48j35VpiodI/i3Fs4FeBH3UY cmnQ== 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=+HWVhKGl9TR5UnQRqfjTWPYeoQReQ9WV8YLuckqH2cA=; b=Tn31wyIytDaeQhNr9gUuDf0dFkb7wXELWPeA0XCVS+VxwbQMBGGBGrIztmJqsYnU6Q Zg3i0Grlv2uyJHbh9dlCMZzwp5jqn8P/ToH2RJDgA/FfPckP5JqbUJIBSc8MTWhDkukX Aqkk0Gvl5AdI7DvKmyDc9/G2ST7AiCixo7ApVGC/ksigm1RNnZN4J89pLF20Bwms5QOk AOHA42UTc5d0BYClW2CM1uZ5vT7wCG4OpXcdJjYDjyeh2A70Tgl5SR41emik+8jSIbDS 2Z5sbZaNJXU0SxxdP/MOtgcK9SzEFpxjnhKsRgp4Vr8UNQRzx5T2dKHJqeHUlfawYred Z2ew== 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 t191si13224767pgd.579.2018.11.02.16.16.24; Fri, 02 Nov 2018 16:16:38 -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 S1728642AbeKCIYg (ORCPT + 99 others); Sat, 3 Nov 2018 04:24:36 -0400 Received: from mga04.intel.com ([192.55.52.120]:54435 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726705AbeKCIYg (ORCPT ); Sat, 3 Nov 2018 04:24:36 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Nov 2018 16:15:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,457,1534834800"; d="scan'208";a="270987874" Received: from btyborox-mobl.ger.corp.intel.com (HELO localhost) ([10.249.254.138]) by orsmga005.jf.intel.com with ESMTP; 02 Nov 2018 16:15:21 -0700 From: Jarkko Sakkinen To: x86@kernel.org, platform-driver-x86@vger.kernel.org, linux-sgx@vger.kernel.org Cc: 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, mark.shanahan@intel.com, andriy.shevchenko@linux.intel.com, Jarkko Sakkinen , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , linux-kernel@vger.kernel.org (open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)) Subject: [PATCH v15 08/23] x86/sgx: Define SGX1 and SGX2 ENCLS leafs Date: Sat, 3 Nov 2018 01:11:07 +0200 Message-Id: <20181102231320.29164-9-jarkko.sakkinen@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181102231320.29164-1-jarkko.sakkinen@linux.intel.com> References: <20181102231320.29164-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 ENCLS, a.k.a. Enclave System instruction, is an umbrella instruction for a variety of privileged SGX functions. The ENCLS function to be executed is specified in EAX, a la GETSEC of SMX/TXT fame. Leafs may use additional registers for function-specific operands. ENCLS also introduces its own set of error codes that (some) leafs use to return pass/fail information to software. Leafs that return an error code also modify RFLAGS. And finally, ENCLS generates ENCLS-specific #GPs and #PFs. ENCLS leafs functions are organized under SGX sub-features, e.g. SGX1 defines the base ENCLS function set and SGX2 adds ENCLS functions to enable dynamic EPC management. At this time, only the SGX1 and SGX2 function sets are supported by Linux; the other published sets relate to VMM EPC oversubscription, which is far out on the horizon. Define the ENCLS leafs in a dedicated file as more architecturally defined SGX constants and data structures will be introduced in short order. Co-developed-by: Sean Christopherson Signed-off-by: Sean Christopherson Signed-off-by: Jarkko Sakkinen --- arch/x86/include/asm/sgx_arch.h | 54 +++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 arch/x86/include/asm/sgx_arch.h diff --git a/arch/x86/include/asm/sgx_arch.h b/arch/x86/include/asm/sgx_arch.h new file mode 100644 index 000000000000..e068db46835e --- /dev/null +++ b/arch/x86/include/asm/sgx_arch.h @@ -0,0 +1,54 @@ +/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */ +/** + * Copyright(c) 2016-18 Intel Corporation. + * + * Contains data structures defined by the SGX architecture. Data structures + * defined by the Linux software stack should not be placed here. + */ +#ifndef _ASM_X86_SGX_ARCH_H +#define _ASM_X86_SGX_ARCH_H + +/** + * enum sgx_encls_leaves - ENCLS leaf functions + * %SGX_ECREATE: Create an enclave. + * %SGX_EADD: Add a page to an uninitialized enclave. + * %SGX_EINIT: Initialize an enclave, i.e. launch an enclave. + * %SGX_EREMOVE: Remove a page from an enclave. + * %SGX_EDBGRD: Read a word from an enclve (peek). + * %SGX_EDBGWR: Write a word to an enclave (poke). + * %SGX_EEXTEND: Measure 256 bytes of an added enclave page. + * %SGX_ELDB: Load a swapped page in blocked state. + * %SGX_ELDU: Load a swapped page in unblocked state. + * %SGX_EBLOCK: Change page state to blocked i.e. entering hardware + * threads cannot access it and create new TLB entries. + * %SGX_EPA: Create a Version Array (VA) page used to store isvsvn + * number for a swapped EPC page. + * %SGX_EWB: Swap an enclave page to the regular memory. Checks that + * all threads have exited that were in the previous + * shoot-down sequence. + * %SGX_ETRACK: Start a new shoot down sequence. Used to together with + * EBLOCK to make sure that a page is safe to swap. + * %SGX_EAUG: Add a page to an initialized enclave. + * %SGX_EMODPR: Restrict an EPC page's permissions. + * %SGX_EMODT: Modify the page type of an EPC page. + */ +enum sgx_encls_leaves { + SGX_ECREATE = 0x00, + SGX_EADD = 0x01, + SGX_EINIT = 0x02, + SGX_EREMOVE = 0x03, + SGX_EDGBRD = 0x04, + SGX_EDGBWR = 0x05, + SGX_EEXTEND = 0x06, + SGX_ELDB = 0x07, + SGX_ELDU = 0x08, + SGX_EBLOCK = 0x09, + SGX_EPA = 0x0A, + SGX_EWB = 0x0B, + SGX_ETRACK = 0x0C, + SGX_EAUG = 0x0D, + SGX_EMODPR = 0x0E, + SGX_EMODT = 0x0F, +}; + +#endif /* _ASM_X86_SGX_ARCH_H */ -- 2.19.1