Skip to content

Commit a0c0741

Browse files
authored
Auto-enable Vector Crypto superset extensions (Zvkn, Zvknc, Zvkng, Zvks, Zvksc, Zvksg) (#1096)
Add remaining vector crypto extensions and automatically enable superset extensions when all of the appropriate subset extensions are enabled.
1 parent d8c3006 commit a0c0741

File tree

3 files changed

+59
-1
lines changed

3 files changed

+59
-1
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,15 @@ For booting operating system images, see the information under the
101101
- Zvbc extension for vector carryless multiplication, v1.0
102102
- Zvkb extension for vector cryptography bit-manipulation, v1.0
103103
- Zvkg extension for vector GCM/GMAC, v1.0
104+
- Zvkn extension for vector crytography NIST Algorithm Suite
105+
- Zvknc extension for vector crytography NIST Algorithm Suite with carryless multiply
104106
- Zvkned extension for vector cryptography NIST Suite: Vector AES Block Cipher, v1.0
107+
- Zvkng extension for vector crytography NIST Algorithm Suite with GCM
105108
- Zvknha and Zvknhb extensions for vector cryptography NIST Suite: Vector SHA-2 Secure Hash, v1.0
109+
- Zvks extension for vector crytography ShangMi Algorithm Suite
110+
- Zvksc extension for vector crytography ShangMi Algorithm Suite with carryless multiplication
106111
- Zvksed extension for vector cryptography ShangMi Suite: SM4 Block Cipher, v1.0
112+
- Zvksg extension for vector crytography ShangMi Algorithm Suite with GCM
107113
- Zvksh extension for vector cryptography ShangMi Suite: SM3 Secure Hash, v1.0
108114
- Zvkt extension for vector data independent execution latency, v1.0 (no impact on model)
109115
- Machine, Supervisor, and User modes

model/riscv_extensions.sail

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,46 @@ enum clause extension = Ext_Zvkt
287287
mapping clause extensionName = Ext_Zvkt <-> "zvkt"
288288
function clause hartSupports(Ext_Zvkt) = config extensions.Zvkt.supported
289289
function clause currentlyEnabled(Ext_Zvkt) = hartSupports(Ext_Zvkt)
290+
// The following extensions are superset/shorthand extensions. They cannot be
291+
// directly configured in the config file and are automatically supported when
292+
// all their required subset extensions are supported.
293+
enum clause extension = Ext_Zvkn
294+
mapping clause extensionName = Ext_Zvkn <-> "zvkn"
295+
function clause hartSupports(Ext_Zvkn) =
296+
hartSupports(Ext_Zvkned) &
297+
hartSupports(Ext_Zvknhb) &
298+
hartSupports(Ext_Zvkb) &
299+
hartSupports(Ext_Zvkt)
300+
function clause currentlyEnabled(Ext_Zvkn) = hartSupports(Ext_Zvkn)
301+
// NIST Algorithm Suite with carryless multiply
302+
enum clause extension = Ext_Zvknc
303+
mapping clause extensionName = Ext_Zvknc <-> "zvknc"
304+
function clause hartSupports(Ext_Zvknc) = hartSupports(Ext_Zvkn) & hartSupports(Ext_Zvbc)
305+
function clause currentlyEnabled(Ext_Zvknc) = hartSupports(Ext_Zvknc)
306+
// NIST Algorithm Suite with GCM
307+
enum clause extension = Ext_Zvkng
308+
mapping clause extensionName = Ext_Zvkng <-> "zvkng"
309+
function clause hartSupports(Ext_Zvkng) = hartSupports(Ext_Zvkn) & hartSupports(Ext_Zvkg)
310+
function clause currentlyEnabled(Ext_Zvkng) = hartSupports(Ext_Zvkng)
311+
// ShangMi Algorithm Suite
312+
enum clause extension = Ext_Zvks
313+
mapping clause extensionName = Ext_Zvks <-> "zvks"
314+
function clause hartSupports(Ext_Zvks) =
315+
hartSupports(Ext_Zvksed) &
316+
hartSupports(Ext_Zvksh) &
317+
hartSupports(Ext_Zvkb) &
318+
hartSupports(Ext_Zvkt)
319+
function clause currentlyEnabled(Ext_Zvks) = hartSupports(Ext_Zvks)
320+
// ShangMi Algorithm Suite with carryless multiplication
321+
enum clause extension = Ext_Zvksc
322+
mapping clause extensionName = Ext_Zvksc <-> "zvksc"
323+
function clause hartSupports(Ext_Zvksc) = hartSupports(Ext_Zvks) & hartSupports(Ext_Zvbc)
324+
function clause currentlyEnabled(Ext_Zvksc) = hartSupports(Ext_Zvksc)
325+
// ShangMi Algorithm Suite with GCM
326+
enum clause extension = Ext_Zvksg
327+
mapping clause extensionName = Ext_Zvksg <-> "zvksg"
328+
function clause hartSupports(Ext_Zvksg) = hartSupports(Ext_Zvks) & hartSupports(Ext_Zvkg)
329+
function clause currentlyEnabled(Ext_Zvksg) = hartSupports(Ext_Zvksg)
290330

291331
// Count Overflow and Mode-Based Filtering
292332
enum clause extension = Ext_Sscofpmf
@@ -405,10 +445,16 @@ let extensions_ordered_for_isa_string = [
405445
Ext_Zvbc,
406446
Ext_Zvkb,
407447
Ext_Zvkg,
448+
Ext_Zvkn,
449+
Ext_Zvknc,
408450
Ext_Zvkned,
451+
Ext_Zvkng,
409452
Ext_Zvknha,
410453
Ext_Zvknhb,
454+
Ext_Zvks,
455+
Ext_Zvksc,
411456
Ext_Zvksed,
457+
Ext_Zvksg,
412458
Ext_Zvksh,
413459
Ext_Zvkt,
414460

model/riscv_termination.sail

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,14 @@ termination_measure virtual_memory_supported(_) = 3
9191

9292
function hartSupports_measure(ext : extension) -> int =
9393
match ext {
94-
Ext_C => 2,
9594
Ext_D => 1,
95+
Ext_Zvkn => 1,
96+
Ext_Zvks => 1,
97+
Ext_C => 2,
98+
Ext_Zvknc => 2,
99+
Ext_Zvkng => 2,
100+
Ext_Zvksc => 2,
101+
Ext_Zvksg => 2,
96102
_ => 0,
97103
}
98104

0 commit comments

Comments
 (0)