-
Notifications
You must be signed in to change notification settings - Fork 550
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implements most of libsgx_capable for Linux (previously only availabl…
…e in the Windows SDK) (#107) * Adds libsgx_capable, which is currently only available in the Windows version of the Intel SGX SDK. The Linux implementation of this library adds the following functions: sgx_status_t sgx_is_capable (int *sgx_capable); sgx_status_t sgx_cap_get_status (sgx_device_status_t *sgx_device_status); sgx_status_t sgx_cap_enable_device (sgx_device_status_t *sgx_device_status); And adds the following error code (also from the Windows version of the Intel SGX SDK): SGX_ERROR_NO_PRIVILEGE Generates both a static and dynamic build of libsgx_capable. This is incorporated into the SDK package, not the PSW package, since software installers need to check for Intel SGX capability on systems where the PSW may not already be installed. This means that installers will either have to statically link, or distribute the .so with their installation package. ---------------------- Developer Certificate of Origin Version 1.1 Copyright (C) 2004, 2006 The Linux Foundation and its contributors. 660 York Street, Suite 102, San Francisco, CA 94110 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Developer's Certificate of Origin 1.1 By making a contribution to this project, I certify that: (a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or (b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or (c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it. (d) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved. Signed-off-by: John P Mechalas <[email protected]>
- Loading branch information
Showing
8 changed files
with
552 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* Copyright 2011-2017 Intel Corporation | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* | ||
* 1. Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* 3. Neither the name of the copyright holder nor the names of its | ||
* contributors may be used to endorse or promote products derived from | ||
* this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED | ||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#ifndef _SGX_CAPABLE_H_ | ||
#define _SGX_CAPABLE_H_ | ||
|
||
#include "sgx_error.h" | ||
#include "sgx_defs.h" | ||
|
||
#if defined(_MSC_VER) | ||
#include <Windows.h> | ||
#endif | ||
|
||
typedef enum _sgx_device_status_t { | ||
SGX_ENABLED, | ||
SGX_DISABLED_REBOOT_REQUIRED, /* A reboot is required to finish enabling SGX */ | ||
SGX_DISABLED_LEGACY_OS, /* SGX is disabled and a Software Control Interface is not available to enable it */ | ||
SGX_DISABLED, /* SGX is not enabled on this platform. More details are unavailable. */ | ||
SGX_DISABLED_SCI_AVAILABLE, /* SGX is disabled, but a Software Control Interface is available to enable it */ | ||
SGX_DISABLED_MANUAL_ENABLE, /* SGX is disabled, but can be enabled manually in the BIOS setup */ | ||
SGX_DISABLED_HYPERV_ENABLED, /* Detected an unsupported version of Windows* 10 with Hyper-V enabled */ | ||
SGX_DISABLED_UNSUPPORTED_CPU, /* SGX is not supported by this CPU */ | ||
} sgx_device_status_t; | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/* | ||
* Function to check if the client platform is SGX enabled. | ||
* | ||
* @param sgx_capable[out] The SGX capable status of the client platform. | ||
* 1 - Platform is SGX enabled or the Software Control Interface is available to configure SGX | ||
* 0 - SGX not available | ||
* @return If the function succeeds, return SGX_SUCCESS, any other value indicates an error. | ||
*/ | ||
sgx_status_t sgx_is_capable(int* sgx_capable); | ||
|
||
/* | ||
* Function used to enable SGX device through EFI. | ||
* | ||
* @param sgx_device_status[out] The status of SGX device. | ||
* @return If the function succeeds, return SGX_SUCCESS, any other value indicates an error. | ||
*/ | ||
sgx_status_t sgx_cap_enable_device(sgx_device_status_t* sgx_device_status); | ||
|
||
/* | ||
* Function used to query SGX device status. | ||
* | ||
* @param sgx_device_status[out] The status of SGX device. | ||
* @return If the function succeeds, return SGX_SUCCESS, any other value indicates an error. | ||
*/ | ||
sgx_status_t SGXAPI sgx_cap_get_status(sgx_device_status_t* sgx_device_status); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# | ||
# Copyright (C) 2011-2017 Intel Corporation. All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions | ||
# are met: | ||
# | ||
# * Redistributions of source code must retain the above copyright | ||
# notice, this list of conditions and the following disclaimer. | ||
# * Redistributions in binary form must reproduce the above copyright | ||
# notice, this list of conditions and the following disclaimer in | ||
# the documentation and/or other materials provided with the | ||
# distribution. | ||
# * Neither the name of Intel Corporation nor the names of its | ||
# contributors may be used to endorse or promote products derived | ||
# from this software without specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
# | ||
# | ||
|
||
include ../../../buildenv.mk | ||
|
||
CXXFLAGS += -fPIC -Werror -g | ||
CXXFLAGS += $(ADDED_INC) | ||
|
||
CFLAGS += -fPIC -Werror -g | ||
CFLAGS += $(ADDED_INC) | ||
|
||
INC += -I$(COMMON_DIR)/inc \ | ||
-I$(COMMON_DIR)/inc/internal \ | ||
-I$(COMMON_DIR)/inc/internal/linux | ||
|
||
LIB += -L$(BUILD_DIR) | ||
|
||
LIBCAPABLE := libsgx_capable.so | ||
LIBCAPABLE_STATIC := libsgx_capable.a | ||
|
||
OBJ := sgx_capable.o | ||
|
||
.PHONY: all | ||
all: $(LIBCAPABLE) $(LIBCAPABLE_STATIC) | $(BUILD_DIR) | ||
@$(CP) $(LIBCAPABLE) $| | ||
@$(CP) $(LIBCAPABLE_STATIC) $| | ||
|
||
$(LIBCAPABLE): $(OBJ) | ||
$(CXX) $(CXXFLAGS) -shared -Wl,-soname=$@ $(LIB) -o $@ $(OBJ) $(LDFLAGS) | ||
|
||
$(LIBCAPABLE_STATIC): $(OBJ) | ||
$(AR) r $@ $? | ||
|
||
%.o: %.cpp | ||
$(CXX) -c $(CXXFLAGS) $(INC) $< -o $@ | ||
|
||
$(BUILD_DIR): | ||
@$(MKDIR) $@ | ||
|
||
.PHONY: clean | ||
clean:: | ||
@$(RM) *.o $(LIBCAPABLE) $(BUILD_DIR)/$(LIBCAPABLE) | ||
@$(RM) $(LIBCAPABLE_STATIC) $(BUILD_DIR)/$(LIBCAPABLE_STATIC) |
Oops, something went wrong.