Skip to content

Instantly share code, notes, and snippets.

View aghosn's full-sized avatar

ghosn adrien aghosn

View GitHub Profile
# Questions about the rules
## Syntax
* `σ[ι↦(ρ, τ)]` means objectID l to object of type τ in region ρ, right?
## Freeze
Destroy a region and freeze all objects that were in it.
x ∉ σ
@aghosn
aghosn / kvm.go
Created March 18, 2020 16:43
a small hacky kvm example in go
package main
// #include <linux/kvm.h>
// #include <stdio.h>
// #include <err.h>
//
// static int myhandler(void* r) {
// struct kvm_run* run = (struct kvm_run*) r;
// switch (run->exit_reason) {
// case KVM_EXIT_HLT:
package a;
import java.util.Vector;
public class Main {
public static void main(String[] args) {
try {
Vector<Object> v = new Vector<Object>();
while(true) {
byte b[] = new byte[1048576];
-load("//third_party/linux_sgx:sgx_sdk.bzl", "sgx_enclave")
+load("//third_party/linux_sgx:sgx_sdk.bzl", "sgx_enclave", "sgx_enclave_configuration")
+sgx_enclave_configuration(
+ name = "demo_enclave_configuration",
+ heap_max_size = "0x6400000",
+)
sgx_enclave(
name = "demo_enclave",
#include <stdio.h>
#include <stdlib.h>
int my_errno = 0;
typedef int thread_condattr_t;
typedef int clid_t ;
typedef int thread_attr_t;
int pthread_condattr_setclock(thread_condattr_t* attr, clid_t clock_id) {
#ifndef __CPU_FEATURES_H__
#define __CPU_FEATURES_H__
typedef struct {
char fCX8;
char fCMOV;
char fFXSR;
char fHT;
char fMMX;
char fAMD3DNOWPREFETCH;
@aghosn
aghosn / cpu_features.c
Created August 21, 2019 17:51
port of cpu_features
#include "cpu_features.h"
#if defined(__x86_64__) || defined(_WIN64)
#ifndef _WIN64
#include <cpuid.h>
unsigned int get_cpuid_max (unsigned int ext, unsigned int *sig) {
return __get_cpuid_max(ext, sig);
}
@aghosn
aghosn / patch.diff
Created August 16, 2019 18:33
substrateVM patch
diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxImageHeapProvider.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxImageHeapProvider.java
index e6a1fa25aee..e94be2cae16 100644
--- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxImageHeapProvider.java
+++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxImageHeapProvider.java
@@ -78,8 +78,10 @@ import com.oracle.svm.core.posix.headers.UnistdNoTransitions;
import jdk.vm.ci.code.MemoryBarriers;
-@AutomaticFeature
-@Platforms(InternalPlatform.LINUX_AND_JNI.class)
@aghosn
aghosn / dump.md
Last active August 8, 2019 19:58
Description of linux sgx relocation issue

See => for a relevant entries.

$ readelf -l enclave

Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  PHDR           0x0000000000000040 0x0000000000000040 0x0000000000000040
                 0x0000000000000188 0x0000000000000188  R E    0x8