diff --git a/proto/unprivileged/.gitignore b/proto/unprivileged/.gitignore deleted file mode 100644 index 4a91bb69396f4c789feaa9f773af086f0924fa8e..0000000000000000000000000000000000000000 --- a/proto/unprivileged/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.o -unprivileged diff --git a/proto/unprivileged/Makefile b/proto/unprivileged/Makefile deleted file mode 100644 index 8a88d9660d02ff339fe5cf9085b01341031636f1..0000000000000000000000000000000000000000 --- a/proto/unprivileged/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -CC := gcc -CFLAGS := -g -pedantic -Wall -Wextra -LDFLAGS := -fsanitize=address,leak,undefined -TARGET := unprivileged - -all: $(TARGET) - -$(TARGET): unprivileged.o - $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) - -%.o: %.c - $(CC) $(CFLAGS) -c $< - -.PHONY: clean - -clean: - rm -f *.o $(TARGET) diff --git a/proto/unprivileged/unprivileged.c b/proto/unprivileged/unprivileged.c deleted file mode 100644 index 61b760660a0b3a157643325985e87c07296c9883..0000000000000000000000000000000000000000 --- a/proto/unprivileged/unprivileged.c +++ /dev/null @@ -1,42 +0,0 @@ -#include <stdbool.h> -#include <stdio.h> -#include <stdlib.h> - -/*asm ( assembler template*/ -/* : output operands (optional)*/ -/* : input operands (optional)*/ -/* : clobbered registers list (optional)*/ -/* );*/ - -static void enable_vmx(void) { - unsigned long cr4; - - __asm__ volatile("mov %%cr4, %0" : "=r"(cr4)::"memory"); - cr4 |= (1 << 13); - __asm__ volatile("mov %0, %%cr4" ::"r"(cr4) : "memory"); -} - -static bool vmx_supported(void) { - int ecx; - - __asm__ volatile("mov $1, %rax"); - __asm__ volatile("cpuid"); - __asm__ volatile("mov %%ecx , %0\n\t" : "=r"(ecx)); - - return (ecx >> 5) & 1; -} - -int main(void) { - if (!vmx_supported()) { - printf("VMX isn't supported!\n"); - exit(EXIT_FAILURE); - } - - printf("VMX is supported!\n"); - - enable_vmx(); - - printf("VMX has been enabled\n"); - - return 0; -}