Skip to content

Commit

Permalink
Merge pull request #15 from mlq/feature/pstate-turbo-check
Browse files Browse the repository at this point in the history
Add option to enable/disable pstate and turbo during compilation
  • Loading branch information
jovanbulck authored Jan 10, 2020
2 parents 8e33510 + f52f4ef commit 615396c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
11 changes: 9 additions & 2 deletions libsgxstep/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ CC = gcc
AS = gcc
AR = ar
ARFLAGS = -rcs
CFLAGS += -DHAS_PSTATE -DHAS_TURBO

ifneq "$(WITH_PSTATE)" "0"
CPPFLAGS += -DHAS_PSTATE
endif

ifneq "$(WITH_TURBO)" "0"
CPPFLAGS += -DHAS_TURBO
endif

ifeq ($(M32), 1)
ASFLAGS = -m32 -DM32=1
Expand All @@ -25,7 +32,7 @@ $(OUTPUT): $(OBJECTS)

%.o : %.c
echo "$(INDENT)[CC] " $<
$(CC) $(CFLAGS) $(INCLUDE) -c $<
$(CC) $(CPPFLAGS) $(CFLAGS) $(INCLUDE) -c $<

%.o : %.S
echo "$(INDENT)[AS] " $<
Expand Down
8 changes: 6 additions & 2 deletions libsgxstep/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,14 @@ int disable_turbo(void)

int turbo_enabled( void )
{
#ifdef HAS_TURBO
int result;
file_read_int( "/sys/devices/system/cpu/intel_pstate/no_turbo", &result);

file_read_int( "/sys/devices/system/cpu/intel_pstate/no_turbo", &result);
return (result == 0)? 1 : 0;
#else
return 0;
#endif
}

int restore_system_state(void)
Expand Down

0 comments on commit 615396c

Please sign in to comment.