Skip to content

Commit f2dcbf1

Browse files
committed
[litmus] Introduce EXS, EIS and EOS variants to litmus
1 parent 50e29ce commit f2dcbf1

File tree

7 files changed

+107
-1
lines changed

7 files changed

+107
-1
lines changed

litmus/libdir/_aarch64/_exs.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/****************************************************************************/
2+
/* the diy toolsuite */
3+
/* */
4+
/* Jade Alglave, University College London, UK. */
5+
/* Luc Maranget, INRIA Paris-Rocquencourt, France. */
6+
/* */
7+
/* Copyright 2015-present Institut National de Recherche en Informatique et */
8+
/* en Automatique and the authors. All rights reserved. */
9+
/* */
10+
/* This software is governed by the CeCILL-B license under French law and */
11+
/* abiding by the rules of distribution of free software. You can use, */
12+
/* modify and/ or redistribute the software under the terms of the CeCILL-B */
13+
/* license as circulated by CEA, CNRS and INRIA at the following URL */
14+
/* "http://www.cecill.info". We also give a copy in LICENSE.txt. */
15+
/****************************************************************************/
16+
#include "exs.h"
17+
18+
int check_exs(const char *tname) {
19+
uint64_t mmfr0;
20+
asm volatile("mrs %0, ID_AA64MMFR0_EL1" : "=r" (mmfr0));
21+
int exs = (mmfr0 >> 44) & 0xf;
22+
if (exs == 0) {
23+
printf("Test %s, ExS not supported on this system\n", tname);
24+
return 0;
25+
}
26+
return 1;
27+
}
28+
29+
void init_exs(int need_eis, int need_eos) {
30+
uint64_t sctlr;
31+
asm volatile("mrs %0, SCTLR_EL1" : "=r" (sctlr));
32+
sctlr &= ~SCTLR_EL1_EIS;
33+
sctlr &= ~SCTLR_EL1_EOS;
34+
if (need_eis) sctlr |= SCTLR_EL1_EIS;
35+
if (need_eos) sctlr |= SCTLR_EL1_EOS;
36+
asm volatile("msr SCTLR_EL1, %0" :: "r" (sctlr));
37+
asm volatile("isb");
38+
}

litmus/libdir/_aarch64/_exs.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/****************************************************************************/
2+
/* the diy toolsuite */
3+
/* */
4+
/* Jade Alglave, University College London, UK. */
5+
/* Luc Maranget, INRIA Paris-Rocquencourt, France. */
6+
/* */
7+
/* Copyright 2015-present Institut National de Recherche en Informatique et */
8+
/* en Automatique and the authors. All rights reserved. */
9+
/* */
10+
/* This software is governed by the CeCILL-B license under French law and */
11+
/* abiding by the rules of distribution of free software. You can use, */
12+
/* modify and/ or redistribute the software under the terms of the CeCILL-B */
13+
/* license as circulated by CEA, CNRS and INRIA at the following URL */
14+
/* "http://www.cecill.info". We also give a copy in LICENSE.txt. */
15+
/****************************************************************************/
16+
#ifndef _LITMUS_EXS_H
17+
#define _LITMUS_EXS_H 1
18+
19+
int check_exs(const char *tname);
20+
void init_exs(int need_eis, int need_eos);
21+
22+
#endif

litmus/libdir/_instance.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@ static void set_role(global_t *g,thread_ctx_t *c,int part) {
180180
c->role = d->ind[c->role] ;
181181
}
182182
#ifdef KVM
183+
#ifdef EXS
184+
init_exs(EIS, EOS);
185+
#endif
183186
set_feature(c->role) ;
184187
#ifdef HAVE_FAULT_HANDLER
185188
whoami[c->id].instance = inst ;

litmus/objUtil.ml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,12 @@ module Make(O:Config)(Tar:Tar.S) =
254254
let fnames = cpy fnames "outs" ".h" in
255255
fnames
256256
| Mode.PreSi|Mode.Kvm ->
257+
let fnames =
258+
if O.mode = Mode.Kvm && O.sysarch = `AArch64 then
259+
let sub = dir_of_sysarch O.sysarch in
260+
let fnames = cpy ~sub:sub fnames "exs" ".c" in
261+
cpy ~sub:sub fnames "exs" ".h"
262+
else fnames in
257263
fnames in
258264
let fnames =
259265
match O.affinity with

litmus/preSi.ml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ module Make
8080
if Cfg.variant Variant_litmus.ConstPacField && not (Cfg.variant Variant_litmus.Pac) then
8181
Warn.user_error "\"const-pac-field\" variant require \"pac\" variant"
8282

83+
let () =
84+
if (Cfg.variant Variant_litmus.EIS || Cfg.variant Variant_litmus.EOS)
85+
&& not (Cfg.variant Variant_litmus.ExS) then
86+
Warn.user_error "\"eis\"/\"eos\" variants require \"exs\" variant"
87+
8388
module Insert =
8489
ObjUtil.Insert
8590
(struct
@@ -222,8 +227,17 @@ module Make
222227
if do_stats then O.o "#define STATS 1" ;
223228
if Cfg.is_kvm then begin
224229
O.o "#define KVM 1" ;
230+
if Cfg.variant Variant_litmus.ExS then begin
231+
let eis = if Cfg.variant Variant_litmus.EIS then 1 else 0 in
232+
let eos = if Cfg.variant Variant_litmus.EOS then 1 else 0 in
233+
O.o "#define EXS 1" ;
234+
O.f "#define EIS %d" eis ;
235+
O.f "#define EOS %d" eos
236+
end ;
225237
O.o "#include <libcflat.h>" ;
226238
O.o "#include \"kvm-headers.h\"" ;
239+
if Cfg.variant Variant_litmus.ExS then
240+
O.o "#include \"exs.h\"" ;
227241
O.o "#include \"utils.h\"" ;
228242
if not Cfg.stdio then begin
229243
O.o "#include \"litmus_io.h\"" ;
@@ -2312,6 +2326,10 @@ module Make
23122326
dump_cond_def env test ;
23132327
dump_parameters env test ;
23142328
dump_hash_def doc.Name.name env test ;
2329+
if Cfg.is_kvm && Cfg.variant Variant_litmus.ExS then begin
2330+
Insert.insert O.o "_exs.c" ;
2331+
O.o ""
2332+
end ;
23152333
dump_set_feature test db ;
23162334
dump_test_code env test procs_user ;
23172335
dump_instance_def procs_user test ;
@@ -2329,6 +2347,8 @@ module Make
23292347
end ;
23302348
if Cfg.variant Variant_litmus.ConstPacField then
23312349
O.fi "if (!check_const_pac_field_variant(%S)) return 0;" doc.Name.name;
2350+
if Cfg.is_kvm && Cfg.variant Variant_litmus.ExS then
2351+
O.fi "if (!check_exs(%S)) return 0;" doc.Name.name ;
23322352
if Cfg.is_kvm then begin
23332353
match db with
23342354
| None ->

litmus/variant_litmus.ml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ type t =
2020
| S128 (* 128 bit signed ints*)
2121
| Mixed (* Ignored *)
2222
| Vmsa (* Checked *)
23+
| ExS (* Enhanced Exception Synchronization *)
24+
| EIS (* Exception entry event behavior *)
25+
| EOS (* Exception return event behavior *)
2326
| Telechat (* Telechat idiosyncrasies *)
2427
| SVE (* Do nothing *)
2528
| SME (* Do nothing *)
@@ -37,6 +40,9 @@ let (mode_variants, arch_variants) : t list * t list =
3740
| S128 -> S128
3841
| Mixed -> Mixed
3942
| Vmsa -> Vmsa
43+
| ExS -> ExS
44+
| EIS -> EIS
45+
| EOS -> EOS
4046
| Telechat -> Telechat
4147
| SVE -> SVE
4248
| SME -> SME
@@ -50,7 +56,9 @@ let (mode_variants, arch_variants) : t list * t list =
5056
let base_modes =
5157
List.map f [NoInit; S128; Telechat]
5258
and archs =
53-
List.map f [SVE; SME; Self; Mixed; Vmsa; Pac; FPac; ConstPacField; MemTag;]
59+
List.map f
60+
[SVE; SME; Self; Mixed; Vmsa; ExS; EIS; EOS; Pac; FPac; ConstPacField;
61+
MemTag;]
5462
and mte_precisions =
5563
List.map (fun precision -> f (MTEPrecision precision)) Precision.all
5664
and fault_modes =
@@ -71,6 +79,9 @@ let parse s = match Misc.lowercase s with
7179
| "self" -> Some Self
7280
| "mixed" -> Some Mixed
7381
| "vmsa"|"kvm" -> Some Vmsa
82+
| "exs" -> Some ExS
83+
| "eis" -> Some EIS
84+
| "eos" -> Some EOS
7485
| "telechat" -> Some Telechat
7586
| "sve" -> Some SVE
7687
| "sme" -> Some SME
@@ -104,6 +115,9 @@ let pp = function
104115
| Mixed -> "mixed"
105116
| S128 -> "s128"
106117
| Vmsa -> "vmsa"
118+
| ExS -> "exs"
119+
| EIS -> "eis"
120+
| EOS -> "eos"
107121
| Telechat -> "telechat"
108122
| FaultHandling p -> Fault.Handling.pp p
109123
| SVE -> "sve"

litmus/variant_litmus.mli

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ type t =
2020
| S128 (* 128 bit signed ints*)
2121
| Mixed (* Ignored *)
2222
| Vmsa (* Checked *)
23+
| ExS (* Enhanced Exception Synchronization *)
24+
| EIS (* Exception entry event behavior *)
25+
| EOS (* Exception return event behavior *)
2326
| Telechat (* Telechat idiosyncrasies *)
2427
| SVE (* Do nothing *)
2528
| SME (* Do nothing *)

0 commit comments

Comments
 (0)