Files
graphene/Scripts/Makefile.rules
T
Michał Kowalczyk 3d31f2d18d Introduce one, central manifest, zero-config children and constant MRENCLAVE
This is the next part of the great loader rework, with a lot of breaking changes:

- Complete removal of the "trusted children" thing - now children
  processes can be spawned arbitrarily and from arbitrary mountpoint
  types, without any additional configuration needed.

- There's a new, required option in the manifest: `libos.entrypoint` - it
  specifies the URI to the entry binary in the first process. There's no
  need anymore to name the manifest and the first binary identically.

- On SGX, the main binary is not measured in MRENCLAVE anymore - only
  PAL, LibOS and the manifest are measured. This is enough to bind
  MRENCLAVE to a specific entrypoint user executable if wanted - it
  just has to be mounted as a trusted file.

- All Graphene SGX enclaves have now exactly the same MRENCLAVE. This is
  a hash of a "Graphene stub", which can "fork" into one of two states
  in runtime: initial process or child. The initial process creates a
  new "Graphene namespace" with a clean state, it can also be attested
  remotely (contrary to child processes). The initial process can spawn
  children processes by spawning a Graphene stub and directing it to
  start in the child mode. It then attests it locally, and if
  successful, establishes an encrypted pipe, "connects" to its own
  namespace and treats as trusted (including sending protected files
  key).

- Now, there's only one, central manifest describing the initial state
  of a Graphene instance which can be spawned from it (previously, each
  process required a separate manifest which could have different
  configuration - which wasn't actually supported and didn't make sense
  design-wise). One downside of central manifests is that all processes
  require the same enclave configuration (e.g. size), but that was
  already the case so far because of broken checkpointing code. Also,
  this is only a temporary problem, which will cease to exist after the
  introduction of EDMM.

- `sgx.static_address` was renamed to `sgx.nonpie_binary` and now has to
  be inserted manually by users (`sgx_sign` tools doesn't know about the
  binaries run inside, which can be even provided or generated in
  runtime by the user's workload).

- Caveat: the memory gap for non-PIE executables was removed because it
  requires adding a new option to the manifest to be cleanly
  implemented. This is left for some future loader rework PR.
2021-01-12 19:53:24 +01:00

168 lines
5.2 KiB
Makefile

#
# All Makefiles must follow the following conventions:
#
# - Compilation and linking steps must be done via the 'cmd' function:
# e.g., use '$(call cmd,ld_so_o)' to create a shared library using LD
#
# - File-specific build flags must be specified via variables of the format 'FLAG-filename':
# e.g., use 'LDFLAGS-libsysdb.so=...' to specify libsysdb.so-specific linker flags
#
ifeq ("$(origin V)", "command line")
BUILD_VERBOSE = $(V)
endif
ifndef BUILD_VERBOSE
BUILD_VERBOSE = 0
endif
ifeq ($(BUILD_VERBOSE),1)
quiet =
Q =
else
quiet = quiet_
Q = @
endif
export Q quiet BUILD_VERBOSE
squote := '
escsq = $(subst $(squote),'\$(squote)',$1)
echo-cmd = $(if $($(quiet)cmd_$(1)), echo ' $(call escsq,$($(quiet)cmd_$(1)))';)
cmd = @$(echo-cmd) $(cmd_$(1))
quiet_cmd_generated_offsets_s = [ $@ ]
cmd_generated_offsets_s = $(CC) $(CFLAGS) $(defs) -S $< -o $@
generated-offsets.s: generated-offsets.c $(filter-out asm-offsets.h,$(headers))
$(call cmd,generated_offsets_s)
CLEAN_FILES += generated-offsets.s
# Convert inline assembly into preprocessor directives.
# The source line is something like:
# .ascii "GENERATED_INTEGER SHIM_TCB_OFFSET $8 "
# (see the DEFINE macro Pal/include/pal/generated-offsets-build.h)
#
# Because of clang compatibility, we need to:
# - generate the numbers with prefix ($) and strip it here, as clang doesn't support "%p"
# in inline assembly
# - recognize both tab and space [ \t] after ".ascii"
quiet_cmd_asm_offsets_h = [ $@ ]
cmd_asm_offsets_h = \
(set -e; \
echo "/* DO NOT MODIFY. THIS FILE WAS AUTO-GENERATED. */"; \
echo "\#ifndef _ASM_OFFSETS_H_"; \
echo "\#define _ASM_OFFSETS_H_"; \
echo ""; \
awk '/\.ascii[ \t]"GENERATED_INTEGER/{print "\#ifndef " $$3 "\n\#define " $$3 " " substr($$4,2) "\n\#endif"}' $^; \
echo ""; \
echo "\#endif") > $@
asm-offsets.h: generated-offsets.s
$(call cmd,asm_offsets_h)
CLEAN_FILES += asm-offsets.h
quiet_cmd_generated_offsets_py = [ $@ ]
cmd_generated_offsets_py = \
(set -e; \
echo "\# DO NOT MODIFY. THIS FILE WAS AUTO-GENERATED."; \
echo ""; \
awk '/\.ascii[ \t]"GENERATED_INTEGER/{print $$3 " = " substr($$4,2)}' $^) > $@
generated_offsets.py: generated-offsets.s
$(call cmd,generated_offsets_py)
CLEAN_FILES += generated_offsets.py generated_offsets.pyc
quiet_cmd_ln_sfr = [ $@ ]
cmd_ln_sfr = ln -sfr $(abspath $<) $@
cc-option = $(shell set -e; \
if ($(CC) -Werror $(1) -c -x c /dev/null -o /dev/null) >/dev/null 2>&1; \
then echo "$(1)"; \
fi)
# .c
quiet_cmd_cc_o_c = [ $@ ]
cmd_cc_o_c = $(CC) -MD -MP $(CFLAGS) $(CFLAGS-$@) -c -o $@ $<
quiet_cmd_cpp_i_c = [ $@ ]
cmd_cpp_i_c = $(CC) -MD -MP -MF $@.d $(CFLAGS) $(CFLAGS-$@) -E -o $@ $<
quiet_cmd_cc_s_c = [ $@ ]
cmd_cc_s_c = $(CC) -MD -MP -MF $@.d $(CFLAGS) $(CFLAGS-$@) -S -o $@ $<
# .S
quiet_cmd_as_o_S = [ $@ ]
cmd_as_o_S = $(CC) -MD -MP $(ASFLAGS) $(ASFLAGS-$@) -c -o $@ $<
quiet_cmd_cpp_s_S = [ $@ ]
cmd_cpp_s_S = $(CC) -MD -MP -MF $@.d $(ASFLAGS) $(ASFLAGS-$@) -E -o $@ $<
# LD
quiet_cmd_ld_so_o = [ $@ ]
cmd_ld_so_o = $(LD) $(LDFLAGS) $(LDFLAGS-$@) -o $@ $(filter-out pal-symbols %.map %.map.template %.lds,$^) -soname $(notdir $@)
# AR
quiet_cmd_ar_so_o = [ $@ ]
cmd_ar_so_o = $(AR) $(ARFLAGS)$(ARFLAGS-$@) $@ $^
quiet_cmd_ar_a_o = [ $@ ]
cmd_ar_a_o = $(AR) $(ARFLAGS)$(ARFLAGS-$@) $@ $^
# LD only
quiet_cmd_ld = [ $@ ]
cmd_ld = $(LD) $(LDFLAGS) $(LDFLAGS-$@) -o $@ $(filter-out pal-symbols %.map %.map.template %.lds,$^)
# OBJCOPY
quiet_cmd_objcopy = [ $@ ]
cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS-$@) $< $@
# check_no_reloc
# This depends on the output of readelf command.
quiet_cmd_check_no_reloc = [ check_no_reloc $^ ]
cmd_check_no_reloc = LC_ALL=C readelf -r $^ | grep -q 'There are no relocations in this file.'
# single .c => executable
quiet_cmd_csingle = [ $@ ]
cmd_csingle = $(CC) -MD -MP $(CFLAGS) $(CFLAGS-$@) -o $@ $< $(LDLIBS) $(LDLIBS-$@)
# single .cpp => executable
quiet_cmd_cxxsingle = [ $@ ]
cmd_cxxsingle = $(CXX) -MD -MP $(CXXFLAGS) $(CXXFLAGS-$@) -o $@ $< $(LDLIBS) $(LDLIBS-$@)
# multiple .o => executable
quiet_cmd_cmulti = [ $@ ]
cmd_cmulti = $(CC) -MD -MP $(CFLAGS) $(CFLAGS-$@) -o $@ $^ $(LDLIBS) $(LDLIBS-$@)
# sgx sign
quiet_cmd_sgx_sign = [ $*.{sig, manifest.sgx} ]
cmd_sgx_sign = $(SGX_SIGN) -output $*.manifest.sgx -manifest $< > .output.sgx_sign.$*
# sgx token
quiet_cmd_sgx_get_token = [ Token: $(basename $*) ]
cmd_sgx_get_token = $(SGX_GET_TOKEN) -output $@ -sig $^ > .output.sgx_get_token.$(basename $*)
# sgx manifest dependency
quiet_cmd_sgx_sign_depend = [ $@ ]
cmd_sgx_sign_depend = $(SGX_SIGN) -depend -output $@ -manifest $<
# manifest ($(2) - entrypoint, $(3) - replace rules)
quiet_cmd_manifest = [ $@ ]
cmd_manifest = \
$(if $(2),sed $(3) -e 's:\$$(ENTRYPOINT):$(2):g' $< > $@,cp -f $< $@)
# pal map
PAL_SYMBOL_FILE := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/../Pal/src/pal-symbols
PAL_SYMBOLS = $(shell sed -e 's|$$|;|g' $(PAL_SYMBOL_FILE))
quiet_cmd_pal_map = [ $@ ]
cmd_pal_map = \
(echo "/* DO NOT MODIFY. THIS FILE WAS AUTO-GENERATED. */"; \
sed -e 's|\$$(PAL_SYMBOLS)|$(PAL_SYMBOLS)|g' $<) > $@
pal.map: pal.map.template $(PAL_SYMBOL_FILE)
$(call cmd,pal_map)