From 00d257f61e235be4b812285ec8b2d83e14836fcf Mon Sep 17 00:00:00 2001 From: "iliya.saroukha" <iliya.saroukhanian@etu.hesge.ch> Date: Mon, 9 Dec 2024 21:14:47 +0100 Subject: [PATCH] chore: removing unpriv test dir --- proto/unprivileged/.gitignore | 2 -- proto/unprivileged/Makefile | 17 ------------- proto/unprivileged/unprivileged.c | 42 ------------------------------- 3 files changed, 61 deletions(-) delete mode 100644 proto/unprivileged/.gitignore delete mode 100644 proto/unprivileged/Makefile delete mode 100644 proto/unprivileged/unprivileged.c diff --git a/proto/unprivileged/.gitignore b/proto/unprivileged/.gitignore deleted file mode 100644 index 4a91bb6..0000000 --- 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 8a88d96..0000000 --- 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 61b7606..0000000 --- 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; -} -- GitLab