mirror of
https://github.com/corda/corda.git
synced 2025-06-17 22:58:19 +00:00
Initial release of Intel SGX for Linux.
This release is used in conjunction with the linux-sgx-driver Intial release: https://github.com/01org/linux-sgx-driver commit-id: 0e865ce5e6b297a787bcdc12d98bada8174be6d7 Intel-id: 33399 Signed-off-by: Angie Chinchilla <angie.v.chinchilla@intel.com>
This commit is contained in:
42
sdk/simulation/assembly/linux/Makefile
Normal file
42
sdk/simulation/assembly/linux/Makefile
Normal file
@ -0,0 +1,42 @@
|
||||
#
|
||||
# Copyright (C) 2011-2016 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
|
||||
|
||||
ASFLAGS += -Werror $(CFLAGS)
|
||||
CPPFLAGS += -Werror -I$(COMMON_DIR)/inc/internal
|
||||
|
||||
.PHONY: all
|
||||
all: lowlib.o sgxsim.o
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@$(RM) *.o
|
100
sdk/simulation/assembly/linux/gnu_tls.h
Normal file
100
sdk/simulation/assembly/linux/gnu_tls.h
Normal file
@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright (C) 2011-2016 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.
|
||||
*
|
||||
*/
|
||||
#ifndef GNU_TLS_H__
|
||||
#define GNU_TLS_H__
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
|
||||
/* Type for the dtv. */
|
||||
typedef union
|
||||
{
|
||||
size_t counter;
|
||||
struct
|
||||
{
|
||||
void *val;
|
||||
int is_static;
|
||||
} pointer;
|
||||
} dtv_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void *tcb; /* Pointer to the TCB. Not necessarily the
|
||||
thread descriptor used by libpthread. */
|
||||
dtv_t *dtv;
|
||||
void *self; /* Pointer to the thread descriptor. */
|
||||
|
||||
/* We are not interested in the other fields. */
|
||||
} tcbhead_t;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
||||
#if defined(__amd64) || defined(__amd64__) || defined (__x86_64)
|
||||
/* x86_64 uses %fs as the thread register */
|
||||
#define GET_DTV() \
|
||||
({ dtv_t* __dtv; \
|
||||
asm ("mov %%fs:%c1, %0" : "=r"(__dtv) \
|
||||
: "i" (offsetof (tcbhead_t, dtv))); \
|
||||
__dtv; })
|
||||
|
||||
#define GET_FS_GS_0() \
|
||||
({ uintptr_t __orig; \
|
||||
asm volatile ("mov %%fs:0x0, %0" : "=r"(__orig)); \
|
||||
__orig; })
|
||||
|
||||
#define SET_FS_GS_0(val) \
|
||||
({ asm volatile ("mov %0, %%fs:0x0" : :"r"(val));})
|
||||
|
||||
#elif defined(__i386) || defined(__i386__)
|
||||
/* IA32 uses %gs as the thread register */
|
||||
#define GET_DTV() \
|
||||
({ dtv_t* __dtv; \
|
||||
asm ("mov %%gs:%c1, %0" : "=r"(__dtv) \
|
||||
: "i" (offsetof (tcbhead_t, dtv))); \
|
||||
__dtv; })
|
||||
|
||||
#define GET_FS_GS_0() \
|
||||
({ uintptr_t __orig; \
|
||||
asm volatile ("mov %%gs:0x0, %0" : "=r"(__orig)); \
|
||||
__orig; })
|
||||
|
||||
#define SET_FS_GS_0(val) \
|
||||
({ asm volatile ("mov %0, %%gs:0x0" : :"r"(val));})
|
||||
|
||||
#endif
|
||||
|
||||
#define read_dtv_val(dtv) (dtv->pointer.val)
|
||||
#define set_dtv_val(dtv, v) \
|
||||
do { dtv->pointer.val = (void*)(size_t)v; } while (0)
|
||||
|
||||
|
||||
#endif /* !GNU_TLS_H__ */
|
65
sdk/simulation/assembly/linux/lowlib.S
Normal file
65
sdk/simulation/assembly/linux/lowlib.S
Normal file
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (C) 2011-2016 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 "linux/linux-regs.h"
|
||||
|
||||
.file "lowlib.S"
|
||||
|
||||
.text
|
||||
|
||||
DECLARE_LOCAL_FUNC get_bp
|
||||
mov %xbp, %xax
|
||||
ret
|
||||
|
||||
#define reg_xax (0 * SE_WORDSIZE)
|
||||
#define reg_xbx (1 * SE_WORDSIZE)
|
||||
#define reg_xcx (2 * SE_WORDSIZE)
|
||||
#define reg_xdx (3 * SE_WORDSIZE)
|
||||
#define reg_xsi (4 * SE_WORDSIZE)
|
||||
#define reg_xdi (5 * SE_WORDSIZE)
|
||||
#define reg_xbp (6 * SE_WORDSIZE)
|
||||
#define reg_xsp (7 * SE_WORDSIZE)
|
||||
#define reg_xip (8 * SE_WORDSIZE)
|
||||
|
||||
DECLARE_LOCAL_FUNC load_regs
|
||||
mov naked_arg0, %xdx
|
||||
mov reg_xax(%xdx), %xax
|
||||
mov reg_xbx(%xdx), %xbx
|
||||
mov reg_xcx(%xdx), %xcx
|
||||
mov reg_xsi(%xdx), %xsi
|
||||
mov reg_xdi(%xdx), %xdi
|
||||
mov reg_xbp(%xdx), %xbp
|
||||
mov reg_xsp(%xdx), %xsp
|
||||
mov reg_xax(%xdx), %xax
|
||||
push reg_xip(%xdx)
|
||||
mov reg_xdx(%xdx), %xdx
|
||||
ret
|
43
sdk/simulation/assembly/linux/sgxsim.S
Normal file
43
sdk/simulation/assembly/linux/sgxsim.S
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (C) 2011-2016 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 "sw_emu.h"
|
||||
|
||||
.file "sgxsim.S"
|
||||
|
||||
.text
|
||||
|
||||
/* DoECREATE_SW, DoEADD_SW, DoEINIT_SW, DoEREMOVE, ... */
|
||||
DoSW ECREATE
|
||||
DoSW EADD
|
||||
DoSW EINIT
|
||||
DoSW EREMOVE
|
121
sdk/simulation/assembly/linux/sw_emu.h
Normal file
121
sdk/simulation/assembly/linux/sw_emu.h
Normal file
@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Copyright (C) 2011-2016 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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* File: sw_emu.h
|
||||
* Description:
|
||||
* This file defined macros which hide hardware differences.
|
||||
*/
|
||||
|
||||
#ifndef _SW_EMU_H_
|
||||
#define _SW_EMU_H_
|
||||
|
||||
#include "linux/linux-regs.h"
|
||||
|
||||
/*******************************************************************/
|
||||
|
||||
#define SE0func _SE0
|
||||
.type SE0func, @function
|
||||
.protected SE0func
|
||||
|
||||
#if defined LINUX64
|
||||
|
||||
.macro SE0_SW leafcode
|
||||
movabsq $\leafcode, %rax
|
||||
|
||||
pushq %rax
|
||||
pushq %rbx
|
||||
pushq %rcx
|
||||
pushq %rdx
|
||||
pushq %rsi
|
||||
pushq %rdi
|
||||
|
||||
/* 64bit ABI: parameter passing with registers */
|
||||
popq %r9
|
||||
popq %r8
|
||||
popq %rcx
|
||||
popq %rdx
|
||||
popq %rsi
|
||||
popq %rdi
|
||||
|
||||
call SE0func
|
||||
.endm
|
||||
|
||||
#elif defined LINUX32
|
||||
|
||||
.macro SE0_SW leafcode
|
||||
movl $\leafcode, %eax
|
||||
|
||||
pushl %edi
|
||||
pushl %esi
|
||||
pushl %edx
|
||||
pushl %ecx
|
||||
pushl %ebx
|
||||
pushl %eax
|
||||
|
||||
call SE0func
|
||||
add $(SE_WORDSIZE * 6), %esp
|
||||
.endm
|
||||
|
||||
#endif
|
||||
|
||||
/*******************************************************************/
|
||||
|
||||
.macro ECREATE_SW
|
||||
SE0_SW SE_ECREATE
|
||||
.endm
|
||||
|
||||
.macro EADD_SW
|
||||
SE0_SW SE_EADD
|
||||
.endm
|
||||
|
||||
.macro EINIT_SW
|
||||
SE0_SW SE_EINIT
|
||||
.endm
|
||||
|
||||
.macro EREMOVE_SW
|
||||
SE0_SW SE_EREMOVE
|
||||
.endm
|
||||
|
||||
/*******************************************************************/
|
||||
|
||||
/* This macro is used to generate simulation functions like:
|
||||
* DoECREATE_SW, DoEADD_SW, ...
|
||||
*/
|
||||
.macro DoSW inst
|
||||
DECLARE_LOCAL_FUNC Do\()\inst\()_SW
|
||||
SE_PROLOG
|
||||
\inst\()_SW
|
||||
SE_EPILOG
|
||||
.endm
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user