diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6a3c042..57fbea0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -50,4 +50,5 @@ jobs: - name: Build SGX-Step sample applications run: | source /opt/intel/sgxsdk/environment + for d in $GITHUB_WORKSPACE/app/selftest/*/ ; do echo -e "\n**** $d ****\n" ; cd "$d" ; make ; ldd ./app ; done for d in $GITHUB_WORKSPACE/app/*/ ; do echo -e "\n**** $d ****\n" ; cd "$d" ; make ; ldd ./app ; done diff --git a/README.md b/README.md index 1baee85..c938a2a 100644 --- a/README.md +++ b/README.md @@ -242,7 +242,7 @@ the example applications in the "app" directory. First, check the APIC and interrupt-descriptor table setup: ```bash -$ cd app/idt +$ cd app/selftest/idt $ make run # fires interrupts in an infinite loop to stress-test stability; exit with CTRL-C ``` @@ -282,7 +282,7 @@ access rights on specific code or data pages of interest. **Note (timer interval).** The exact timer interval value depends on CPU frequency, and hence remains inherently platform-specific (see also -[app/apic](app/apic) for detailed microbenchmarks assessing the accuracy of +[app/selftest/apic](app/selftest/apic) for detailed microbenchmarks assessing the accuracy of various APIC timer modes). Configure a suitable value in `/app/bench/main.c`. We established precise timer intervals for our evaluation platforms (see table below) by tweaking and observing the NOP microbenchmark enclave instruction diff --git a/app/selftest/README.md b/app/selftest/README.md new file mode 100644 index 0000000..6fdafbb --- /dev/null +++ b/app/selftest/README.md @@ -0,0 +1,31 @@ +# SGX-Step "Selftest" Applications + +This directory contains bare-metal applications designed to test various functionalities provided by `libsgxstep` without the need for SGX enclaves. + +## Directory Overview + +| Directory | Description | +|------------|-----------------------------------------------------------------------------------------------------------| +| `apic` | Microbenchmarks for timer interrupts via various Advanced Programmable Interrupt Controller (APIC) modes. | +| `apic-ipi` | Microbenchmarks for APIC inter-processor interrupts. | +| `cpl` | Changing the Current Privilege Level (CPL) through calland interrupt GDT/IDT gates. | +| `idt` | Custom handlers for software and timer interrupts via the Interrupt Descriptor Table (IDT). | +| `idt_isr_map` | Stresstest to demonstrate custom IDT handlers can be called across processes. | + +## Usage + +To run the selftest applications: + +1. Navigate to the desired directory. +2. Compile the application: + ```bash + make + ``` +3. Run the application with: + ```bash + sudo ./app + ``` + +Reference output is available in the respective README files within each subdirectory. + +**Note:** Any crashes during execution may indicate that your machine is not set up correctly for using SGX-Step. diff --git a/app/apic-ipi/.gitignore b/app/selftest/apic-ipi/.gitignore similarity index 100% rename from app/apic-ipi/.gitignore rename to app/selftest/apic-ipi/.gitignore diff --git a/app/apic-ipi/Makefile b/app/selftest/apic-ipi/Makefile similarity index 98% rename from app/apic-ipi/Makefile rename to app/selftest/apic-ipi/Makefile index 06394f7..1877f64 100644 --- a/app/apic-ipi/Makefile +++ b/app/selftest/apic-ipi/Makefile @@ -1,4 +1,4 @@ -LIBSGXSTEP_DIR = ../.. +LIBSGXSTEP_DIR = ../../.. LIBSGXSTEP = $(LIBSGXSTEP_DIR)/libsgxstep -include $(LIBSGXSTEP)/Makefile.config diff --git a/app/apic-ipi/README.md b/app/selftest/apic-ipi/README.md similarity index 100% rename from app/apic-ipi/README.md rename to app/selftest/apic-ipi/README.md diff --git a/app/apic-ipi/apic-ipi-hist.png b/app/selftest/apic-ipi/apic-ipi-hist.png similarity index 100% rename from app/apic-ipi/apic-ipi-hist.png rename to app/selftest/apic-ipi/apic-ipi-hist.png diff --git a/app/apic-ipi/apic-ipi-inst-hist.png b/app/selftest/apic-ipi/apic-ipi-inst-hist.png similarity index 100% rename from app/apic-ipi/apic-ipi-inst-hist.png rename to app/selftest/apic-ipi/apic-ipi-inst-hist.png diff --git a/app/apic-ipi/asm.S b/app/selftest/apic-ipi/asm.S similarity index 100% rename from app/apic-ipi/asm.S rename to app/selftest/apic-ipi/asm.S diff --git a/app/apic-ipi/main.c b/app/selftest/apic-ipi/main.c similarity index 100% rename from app/apic-ipi/main.c rename to app/selftest/apic-ipi/main.c diff --git a/app/apic-ipi/parse.py b/app/selftest/apic-ipi/parse.py similarity index 100% rename from app/apic-ipi/parse.py rename to app/selftest/apic-ipi/parse.py diff --git a/app/apic/.gitignore b/app/selftest/apic/.gitignore similarity index 100% rename from app/apic/.gitignore rename to app/selftest/apic/.gitignore diff --git a/app/apic/Makefile b/app/selftest/apic/Makefile similarity index 98% rename from app/apic/Makefile rename to app/selftest/apic/Makefile index 06394f7..1877f64 100644 --- a/app/apic/Makefile +++ b/app/selftest/apic/Makefile @@ -1,4 +1,4 @@ -LIBSGXSTEP_DIR = ../.. +LIBSGXSTEP_DIR = ../../.. LIBSGXSTEP = $(LIBSGXSTEP_DIR)/libsgxstep -include $(LIBSGXSTEP)/Makefile.config diff --git a/app/apic/README.md b/app/selftest/apic/README.md similarity index 100% rename from app/apic/README.md rename to app/selftest/apic/README.md diff --git a/app/apic/apic-hist.png b/app/selftest/apic/apic-hist.png similarity index 100% rename from app/apic/apic-hist.png rename to app/selftest/apic/apic-hist.png diff --git a/app/apic/asm.S b/app/selftest/apic/asm.S similarity index 100% rename from app/apic/asm.S rename to app/selftest/apic/asm.S diff --git a/app/apic/config.h b/app/selftest/apic/config.h similarity index 100% rename from app/apic/config.h rename to app/selftest/apic/config.h diff --git a/app/apic/irq_entry.S b/app/selftest/apic/irq_entry.S similarity index 100% rename from app/apic/irq_entry.S rename to app/selftest/apic/irq_entry.S diff --git a/app/apic/main.c b/app/selftest/apic/main.c similarity index 100% rename from app/apic/main.c rename to app/selftest/apic/main.c diff --git a/app/apic/parse.py b/app/selftest/apic/parse.py similarity index 100% rename from app/apic/parse.py rename to app/selftest/apic/parse.py diff --git a/app/cpl/.gitignore b/app/selftest/cpl/.gitignore similarity index 100% rename from app/cpl/.gitignore rename to app/selftest/cpl/.gitignore diff --git a/app/cpl/Makefile b/app/selftest/cpl/Makefile similarity index 98% rename from app/cpl/Makefile rename to app/selftest/cpl/Makefile index 458d44e..40d5be6 100644 --- a/app/cpl/Makefile +++ b/app/selftest/cpl/Makefile @@ -1,4 +1,4 @@ -LIBSGXSTEP_DIR = ../.. +LIBSGXSTEP_DIR = ../../.. LIBSGXSTEP = $(LIBSGXSTEP_DIR)/libsgxstep -include $(LIBSGXSTEP)/Makefile.config diff --git a/app/cpl/README.md b/app/selftest/cpl/README.md similarity index 100% rename from app/cpl/README.md rename to app/selftest/cpl/README.md diff --git a/app/cpl/asm.S b/app/selftest/cpl/asm.S similarity index 100% rename from app/cpl/asm.S rename to app/selftest/cpl/asm.S diff --git a/app/cpl/main.c b/app/selftest/cpl/main.c similarity index 100% rename from app/cpl/main.c rename to app/selftest/cpl/main.c diff --git a/app/idt/.gitignore b/app/selftest/idt/.gitignore similarity index 100% rename from app/idt/.gitignore rename to app/selftest/idt/.gitignore diff --git a/app/idt_isr_map/Makefile b/app/selftest/idt/Makefile similarity index 98% rename from app/idt_isr_map/Makefile rename to app/selftest/idt/Makefile index 45ba47a..2156a95 100644 --- a/app/idt_isr_map/Makefile +++ b/app/selftest/idt/Makefile @@ -1,4 +1,4 @@ -LIBSGXSTEP_DIR = ../.. +LIBSGXSTEP_DIR = ../../.. LIBSGXSTEP = $(LIBSGXSTEP_DIR)/libsgxstep -include $(LIBSGXSTEP)/Makefile.config diff --git a/app/idt/README.md b/app/selftest/idt/README.md similarity index 100% rename from app/idt/README.md rename to app/selftest/idt/README.md diff --git a/app/idt/main.c b/app/selftest/idt/main.c similarity index 99% rename from app/idt/main.c rename to app/selftest/idt/main.c index 5d14a9b..54fd5af 100644 --- a/app/idt/main.c +++ b/app/selftest/idt/main.c @@ -28,7 +28,7 @@ #define DO_APIC_SW_IRQ 1 #define DO_APIC_TMR_IRQ 1 #define DO_EXEC_PRIV 1 -#define NUM 100 +#define NUM 10 #define INFINITE_LOOP 1 #define NEMESIS_HIGH 1 diff --git a/app/idt_isr_map/.gitignore b/app/selftest/idt_isr_map/.gitignore similarity index 100% rename from app/idt_isr_map/.gitignore rename to app/selftest/idt_isr_map/.gitignore diff --git a/app/idt/Makefile b/app/selftest/idt_isr_map/Makefile similarity index 98% rename from app/idt/Makefile rename to app/selftest/idt_isr_map/Makefile index 45ba47a..2156a95 100644 --- a/app/idt/Makefile +++ b/app/selftest/idt_isr_map/Makefile @@ -1,4 +1,4 @@ -LIBSGXSTEP_DIR = ../.. +LIBSGXSTEP_DIR = ../../.. LIBSGXSTEP = $(LIBSGXSTEP_DIR)/libsgxstep -include $(LIBSGXSTEP)/Makefile.config diff --git a/app/idt_isr_map/README.md b/app/selftest/idt_isr_map/README.md similarity index 100% rename from app/idt_isr_map/README.md rename to app/selftest/idt_isr_map/README.md diff --git a/app/idt_isr_map/main.c b/app/selftest/idt_isr_map/main.c similarity index 100% rename from app/idt_isr_map/main.c rename to app/selftest/idt_isr_map/main.c diff --git a/libsgxstep/Makefile.config b/libsgxstep/Makefile.config index e9e5380..6edc668 100644 --- a/libsgxstep/Makefile.config +++ b/libsgxstep/Makefile.config @@ -23,4 +23,5 @@ ifndef LIBSGXSTEP_SILENT export LIBSGXSTEP_SILENT=0 endif +LDFLAGS += -z noexecstack CFLAGS += -DSGX_STEP_PLATFORM=$(SGX_STEP_PLATFORM) -DNO_SGX=$(NO_SGX) -DLIBSGXSTEP_SILENT=$(LIBSGXSTEP_SILENT)