restore OF flag

This commit is contained in:
Andreas Abel
2019-03-06 17:12:10 +01:00
parent def19c2349
commit fe6cc1c675
2 changed files with 35 additions and 11 deletions

View File

@@ -515,7 +515,8 @@ void measurement_template_Intel() {
".intel_syntax noprefix \n"
"push rax \n"
"lahf \n"
"push rax \n"
"seto al \n"
"push rax \n"
"push rcx \n"
"push rdx \n"
"push r15 \n"
@@ -545,7 +546,8 @@ void measurement_template_Intel() {
"pop rdx; lfence \n"
"pop rcx; lfence \n"
"pop rax; lfence \n"
"sahf; lfence \n"
"cmp al, -127; lfence \n"
"sahf; lfence \n"
"pop rax; \n"
"lfence \n"
".att_syntax noprefix ");
@@ -642,6 +644,7 @@ void measurement_template_AMD() {
".intel_syntax noprefix \n"
"push rax \n"
"lahf \n"
"seto al \n"
"push rax \n"
"push rcx \n"
"push rdx \n"
@@ -682,6 +685,7 @@ void measurement_template_AMD() {
"pop rdx; lfence \n"
"pop rcx; lfence \n"
"pop rax; lfence \n"
"cmp al, -127; lfence \n"
"sahf; lfence \n"
"pop rax; \n"
"lfence \n"
@@ -807,6 +811,7 @@ void measurement_FF_template_Intel() {
".intel_syntax noprefix \n"
"push rax \n"
"lahf \n"
"seto al \n"
"push rax \n"
"push rcx \n"
"push rdx \n"
@@ -836,6 +841,7 @@ void measurement_FF_template_Intel() {
"pop rdx; lfence \n"
"pop rcx; lfence \n"
"pop rax; lfence \n"
"cmp al, -127; lfence \n"
"sahf; lfence \n"
"pop rax; \n"
"lfence \n"
@@ -927,8 +933,9 @@ void measurement_FF_template_AMD() {
asm(".quad "STRINGIFY(MAGIC_BYTES_INIT));
asm volatile(
".intel_syntax noprefix \n"
"push rax \n"
"push rax \n"
"lahf \n"
"seto al \n"
"push rax \n"
"push rdx \n"
"push r15 \n"
@@ -951,6 +958,7 @@ void measurement_FF_template_AMD() {
"pop r15; lfence \n"
"pop rdx; lfence \n"
"pop rax; lfence \n"
"cmp al, -127; lfence \n"
"sahf; lfence \n"
"pop rax; \n"
"lfence \n"
@@ -1031,6 +1039,7 @@ void measurement_RDTSC_template() {
".intel_syntax noprefix \n"
"push rax \n"
"lahf \n"
"seto al \n"
"push rax \n"
"push rdx \n"
"push r15 \n"
@@ -1043,6 +1052,7 @@ void measurement_RDTSC_template() {
"pop r15; lfence \n"
"pop rdx; lfence \n"
"pop rax; lfence \n"
"cmp al, -127; lfence \n"
"sahf; lfence \n"
"pop rax; \n"
"lfence \n"

View File

@@ -63,11 +63,15 @@ static ssize_t unroll_count_show(struct kobject *kobj, struct kobj_attribute *at
return sprintf(buf, "%ld\n", unroll_count);
}
static ssize_t unroll_count_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) {
long old_unroll_count = unroll_count;
sscanf(buf, "%ld", &unroll_count);
vfree(runtime_code);
runtime_code = __vmalloc(PAGE_SIZE + (unroll_count)*PAGE_SIZE*2 + 10000, GFP_KERNEL, PAGE_KERNEL_EXEC);
if (!runtime_code) {
pr_debug("failed to allocate executable memory\n");
if (old_unroll_count != unroll_count) {
vfree(runtime_code);
runtime_code = __vmalloc(PAGE_SIZE + (unroll_count)*PAGE_SIZE*2 + 10000, GFP_KERNEL, PAGE_KERNEL_EXEC);
if (!runtime_code) {
pr_debug("failed to allocate executable memory\n");
}
}
return count;
}
@@ -86,10 +90,18 @@ static ssize_t n_measurements_show(struct kobject *kobj, struct kobj_attribute *
return sprintf(buf, "%ld\n", n_measurements);
}
static ssize_t n_measurements_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) {
long old_n_measurements = n_measurements;
sscanf(buf, "%ld", &n_measurements);
for (int i=0; i<MAX_PROGRAMMABLE_COUNTERS; i++) {
kfree(measurement_results[i]);
measurement_results[i] = kmalloc(n_measurements*sizeof(int64_t), GFP_KERNEL);
if (old_n_measurements != n_measurements) {
for (int i=0; i<MAX_PROGRAMMABLE_COUNTERS; i++) {
kfree(measurement_results[i]);
kfree(measurement_results_base[i]);
measurement_results[i] = kmalloc(n_measurements*sizeof(int64_t), GFP_KERNEL);
measurement_results_base[i] = kmalloc(n_measurements*sizeof(int64_t), GFP_KERNEL);
memset(measurement_results[i], 0, n_measurements*sizeof(int64_t));
memset(measurement_results_base[i], 0, n_measurements*sizeof(int64_t));
}
}
return count;
}
@@ -322,12 +334,14 @@ static int __init nb_init (void) {
}
for (int i=0; i<MAX_PROGRAMMABLE_COUNTERS; i++) {
measurement_results[i] = kmalloc(n_measurements*sizeof(int64_t), GFP_KERNEL);
measurement_results[i] = kmalloc(n_measurements*sizeof(int64_t), GFP_KERNEL);
measurement_results_base[i] = kmalloc(n_measurements*sizeof(int64_t), GFP_KERNEL);
if(!measurement_results[i] || !measurement_results_base[i]){
printk(KERN_ERR "Could not allocate memory for measurement_results\n");
return -1;
}
memset(measurement_results[i], 0, n_measurements*sizeof(int64_t));
memset(measurement_results_base[i], 0, n_measurements*sizeof(int64_t));
}
runtime_mem = kmalloc(2*1024*1024, GFP_KERNEL);