]>
Commit | Line | Data |
---|---|---|
7705c750 DH |
1 | /* |
2 | * s390x crypto helpers | |
3 | * | |
4 | * Copyright (c) 2017 Red Hat Inc | |
5 | * | |
6 | * Authors: | |
7 | * David Hildenbrand <david@redhat.com> | |
8 | * | |
9 | * This work is licensed under the terms of the GNU GPL, version 2 or later. | |
10 | * See the COPYING file in the top-level directory. | |
11 | */ | |
12 | ||
13 | #include "qemu/osdep.h" | |
14 | #include "qemu/main-loop.h" | |
15 | #include "internal.h" | |
1e36aee6 | 16 | #include "tcg_s390x.h" |
7705c750 DH |
17 | #include "exec/helper-proto.h" |
18 | #include "exec/exec-all.h" | |
19 | #include "exec/cpu_ldst.h" | |
20 | ||
21 | uint32_t HELPER(msa)(CPUS390XState *env, uint32_t r1, uint32_t r2, uint32_t r3, | |
22 | uint32_t type) | |
23 | { | |
24 | const uintptr_t ra = GETPC(); | |
25 | const uint8_t mod = env->regs[0] & 0x80ULL; | |
26 | const uint8_t fc = env->regs[0] & 0x7fULL; | |
7705c750 DH |
27 | uint8_t subfunc[16] = { 0 }; |
28 | uint64_t param_addr; | |
29 | int i; | |
30 | ||
31 | switch (type) { | |
32 | case S390_FEAT_TYPE_KMAC: | |
33 | case S390_FEAT_TYPE_KIMD: | |
34 | case S390_FEAT_TYPE_KLMD: | |
35 | case S390_FEAT_TYPE_PCKMO: | |
36 | case S390_FEAT_TYPE_PCC: | |
37 | if (mod) { | |
1e36aee6 | 38 | tcg_s390_program_interrupt(env, PGM_SPECIFICATION, ra); |
7705c750 DH |
39 | } |
40 | break; | |
41 | } | |
42 | ||
43 | s390_get_feat_block(type, subfunc); | |
44 | if (!test_be_bit(fc, subfunc)) { | |
1e36aee6 | 45 | tcg_s390_program_interrupt(env, PGM_SPECIFICATION, ra); |
7705c750 DH |
46 | } |
47 | ||
48 | switch (fc) { | |
49 | case 0: /* query subfunction */ | |
50 | for (i = 0; i < 16; i++) { | |
51 | param_addr = wrap_address(env, env->regs[1] + i); | |
52 | cpu_stb_data_ra(env, param_addr, subfunc[i], ra); | |
53 | } | |
54 | break; | |
55 | default: | |
56 | /* we don't implement any other subfunction yet */ | |
57 | g_assert_not_reached(); | |
58 | } | |
59 | ||
60 | return 0; | |
61 | } |