update targets

This commit is contained in:
2026-04-18 19:46:45 +02:00
parent 5dd763fd8a
commit 40d40bc57b
7 changed files with 269 additions and 36 deletions

View File

@ -64,8 +64,6 @@ my $ssh = Net::OpenSSH->new(
$ssh->error and die 'SSH connection failed: ' . $ssh->error; $ssh->error and die 'SSH connection failed: ' . $ssh->error;
say 'Connected to mars.cs.tu-dortmund.de'; say 'Connected to mars.cs.tu-dortmund.de';
# TODO: Abort if old experiments are still on the server => meaning they're not archived
# Pull changes # Pull changes
# remote( $ssh, 'git', '-C', $remote_root, 'pull' ); # TODO: Requires auth # remote( $ssh, 'git', '-C', $remote_root, 'pull' ); # TODO: Requires auth
@ -111,18 +109,7 @@ foreach (@experiments) {
or die "Failed to create database: " . $dbh->errstr; or die "Failed to create database: " . $dbh->errstr;
} }
# Kill old screen session (don't check success as a session might not exist) # Launch remote runner
# say "Killing previous screen session with name $screen_name";
# $ssh->system( "screen", "-XS", $screen_name, "quit" );
# Start new screen session
# my $invoke_runner =
# "cd " . shell_quote($remote_root) . " && perl " . shell_quote($remote_runner);
# say
# "Starting new screen session with name $screen_name and command $invoke_runner";
# remote( $ssh, "screen", "-dmS", $screen_name, "sh", "-lc",
# "exec $invoke_runner" );
remote( $ssh, remote( $ssh,
"nohup sh -c " "nohup sh -c "
. shell_quote("cd $remote_root && perl $remote_runner") . " >" . shell_quote("cd $remote_root && perl $remote_runner") . " >"

View File

@ -1,6 +1,8 @@
#ifndef _include_fail_h #ifndef _include_fail_h
#define _include_fail_h #define _include_fail_h
#include <stdint.h>
#define INLINE __attribute__((always_inline)) inline #define INLINE __attribute__((always_inline)) inline
#define NOINLINE __attribute__((noinline)) #define NOINLINE __attribute__((noinline))
@ -44,6 +46,15 @@
#define RET(val) return val; #define RET(val) return val;
#endif #endif
typedef uint16_t enc_t;
typedef uint8_t plain_t;
typedef int8_t sign_t;
#define check(vc, A, B) (((vc - B) % A) == 0)
#define encode(v, A, B) ((((plain_t)v) * ((sign_t)A)) + ((sign_t)B))
#define decode(vc, A, B) ((vc - B) / A)
#define equals(vc1, vc2, B1, B2) ((vc1 - vc2) == (B1 - B2))
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif

View File

@ -1,16 +1,30 @@
#include "../lib.h" #include "../lib.h"
extern "C" EXPORT("wasm_module") int wasm_module(void) { #define REPLICA_COUNT 1
fail_start_trace();
static plain_t sum_out[REPLICA_COUNT];
#define X sum_out[0]
template <const unsigned int N> static INLINE void sum(void) {
int sum = 0; int sum = 0;
for (int i = 0; i < 100; ++i) { for (int i = 0; i < 100; ++i) {
sum += 1; sum += 1;
} }
sum_out[N] = sum;
}
extern "C" EXPORT("wasm_module") int wasm_module(void) {
X = 0;
fail_start_trace();
sum<0>();
fail_stop_trace(); fail_stop_trace();
if (sum == 100) { if (X == 100) {
fail_marker_positive(); fail_marker_positive();
return 0; return 0;
} else { } else {

View File

@ -0,0 +1,58 @@
#include "../lib.h"
#define REPLICA_COUNT 3
static plain_t vote_res;
static plain_t sum_out[REPLICA_COUNT];
#define XC sum_out[0]
#define YC sum_out[1]
#define ZC sum_out[2]
// The prints here can't happen because they're disabled under test ¯\_(ツ)_/¯
static void naive_vote(void) {
if (XC == YC || XC == ZC) {
vote_res = XC;
} else if (YC == ZC) {
vote_res = YC;
} else {
HOST_PRINT("all replicas differ.\n");
fail_marker_detected();
}
}
template <const unsigned int N> static INLINE void sum(void) {
int sum = 0;
for (int i = 0; i < 100; ++i) {
sum += 1;
}
sum_out[N] = sum;
}
extern "C" EXPORT("wasm_module") int wasm_module(void) {
XC = 0;
YC = 0;
ZC = 0;
sum<0>();
sum<1>();
sum<2>();
fail_start_trace();
naive_vote();
fail_stop_trace();
if (vote_res == 100) {
HOST_PRINT("vote success.\n");
fail_marker_positive();
return 0;
} else {
HOST_PRINT("undetected error.\n");
fail_marker_negative();
return 1;
}
}

View File

@ -1,19 +1,5 @@
#include <stdint.h>
#include "../lib.h" #include "../lib.h"
typedef uint16_t enc_t;
typedef uint8_t plain_t;
typedef int8_t sign_t;
#define REPLICA_COUNT 3
#define check(vc, A, B) (((vc - B) % A) == 0)
#define encode(v, A, B) ((((plain_t)v) * ((sign_t)A)) + ((sign_t)B))
#define decode(vc, A, B) ((vc - B) / A)
#define equals(vc1, vc2, B1, B2) ((vc1 - vc2) == (B1 - B2))
#define THE_A 110 #define THE_A 110
// CONSTANT Replica results signatures // CONSTANT Replica results signatures
@ -28,13 +14,15 @@ typedef int8_t sign_t;
#define SIG_s_YZ (SIG_Y - SIG_Z) #define SIG_s_YZ (SIG_Y - SIG_Z)
#define SIG_s_XZ (SIG_X - SIG_Z) #define SIG_s_XZ (SIG_X - SIG_Z)
#define XC sum_out[0] #define REPLICA_COUNT 3
#define YC sum_out[1]
#define ZC sum_out[2]
static enc_t cored_res; static enc_t cored_res;
static enc_t sum_out[REPLICA_COUNT]; static enc_t sum_out[REPLICA_COUNT];
#define XC sum_out[0]
#define YC sum_out[1]
#define ZC sum_out[2]
// The prints here can't happen because they're disabled under test ¯\_(ツ)_/¯ // The prints here can't happen because they're disabled under test ¯\_(ツ)_/¯
static INLINE enc_t apply(enc_t vc, sign_t bdyn) { static INLINE enc_t apply(enc_t vc, sign_t bdyn) {
@ -81,12 +69,12 @@ extern "C" EXPORT("wasm_module") int wasm_module(void) {
YC = 0; YC = 0;
ZC = 0; ZC = 0;
fail_start_trace();
sum<0, SIG_X>(); sum<0, SIG_X>();
sum<1, SIG_Y>(); sum<1, SIG_Y>();
sum<2, SIG_Z>(); sum<2, SIG_Z>();
fail_start_trace();
sign_t static_sig = cored_vote(); sign_t static_sig = cored_vote();
fail_stop_trace(); fail_stop_trace();

View File

@ -0,0 +1,58 @@
#include "../lib.h"
#define REPLICA_COUNT 3
static plain_t vote_res;
static plain_t sum_out[REPLICA_COUNT];
#define XC sum_out[0]
#define YC sum_out[1]
#define ZC sum_out[2]
// The prints here can't happen because they're disabled under test ¯\_(ツ)_/¯
static void naive_vote(void) {
if (XC == YC || XC == ZC) {
vote_res = XC;
} else if (YC == ZC) {
vote_res = YC;
} else {
HOST_PRINT("all replicas differ.\n");
fail_marker_detected();
}
}
template <const unsigned int N> static INLINE void sum(void) {
int sum = 0;
for (int i = 0; i < 100; ++i) {
sum += 1;
}
sum_out[N] = sum;
}
extern "C" EXPORT("wasm_module") int wasm_module(void) {
XC = 0;
YC = 0;
ZC = 0;
fail_start_trace();
sum<0>();
sum<1>();
sum<2>();
naive_vote();
fail_stop_trace();
if (vote_res == 100) {
HOST_PRINT("vote success.\n");
fail_marker_positive();
return 0;
} else {
HOST_PRINT("undetected error.\n");
fail_marker_negative();
return 1;
}
}

View File

@ -0,0 +1,117 @@
#include "../lib.h"
#define THE_A 110
// CONSTANT Replica results signatures
#define SIG_X 32
#define SIG_Y 23
#define SIG_Z 67
#define SIG_MAX SIG_Z
// CONSTANT Voter Result Signatures
#define SIG_s_XYZ ((SIG_X - SIG_Y) + (SIG_X - SIG_Z))
#define SIG_s_XY (SIG_X - SIG_Y)
#define SIG_s_YZ (SIG_Y - SIG_Z)
#define SIG_s_XZ (SIG_X - SIG_Z)
#define REPLICA_COUNT 3
static enc_t cored_res;
static enc_t sum_out[REPLICA_COUNT];
#define XC sum_out[0]
#define YC sum_out[1]
#define ZC sum_out[2]
// The prints here can't happen because they're disabled under test ¯\_(ツ)_/¯
static INLINE enc_t apply(enc_t vc, sign_t bdyn) {
if (bdyn > SIG_MAX) {
HOST_PRINT("signature overflow.\n");
fail_marker_detected();
}
return vc + bdyn;
}
static sign_t cored_vote(void) {
if (equals(XC, YC, SIG_X, SIG_Y)) {
if (equals(XC, ZC, SIG_X, SIG_Z)) {
cored_res = apply(XC, (XC - YC) + (XC - ZC));
return SIG_s_XYZ;
} else {
cored_res = apply(XC, (XC - YC));
return SIG_s_XY;
}
} else if (equals(YC, ZC, SIG_Y, SIG_Z)) {
cored_res = apply(YC, (YC - ZC));
return SIG_s_YZ;
} else if (equals(XC, ZC, SIG_X, SIG_Z)) {
cored_res = apply(XC, (XC - ZC));
return SIG_s_XZ;
} else {
HOST_PRINT("all replicas differ.\n");
fail_marker_detected();
return 0;
}
}
template <const unsigned int N, const sign_t S> static INLINE void sum(void) {
int sum = 0;
for (int i = 0; i < 100; ++i) {
sum += 1;
}
sum_out[N] = encode(sum, THE_A, S);
}
extern "C" EXPORT("wasm_module") int wasm_module(void) {
XC = 0;
YC = 0;
ZC = 0;
fail_start_trace();
sum<0, SIG_X>();
sum<1, SIG_Y>();
sum<2, SIG_Z>();
sign_t static_sig = cored_vote();
fail_stop_trace();
sign_t vote_result_sig;
switch (static_sig) {
case SIG_s_XYZ:
case SIG_s_XY:
case SIG_s_XZ:
vote_result_sig = SIG_X;
break;
case SIG_s_YZ:
vote_result_sig = SIG_Y;
break;
default:
HOST_PRINT("unknown static_sig.\n");
break;
}
// Inversely apply constant program flow signature.
cored_res -= static_sig;
/* Validate Vote result */
if (!check(cored_res, THE_A, vote_result_sig)) {
HOST_PRINT("voted result invalid.\n");
fail_marker_detected();
return 2;
}
plain_t res = decode(cored_res, THE_A, vote_result_sig);
if (res == 100) {
HOST_PRINT("cored success.\n");
fail_marker_positive();
return 0;
} else {
HOST_PRINT("undetected error.\n");
fail_marker_negative();
return 1;
}
}