Merge remote-tracking branch 'remotes/jasowang/tags/net-pull-request' into staging
[qemu.git] / target / s390x / crypto_helper.c
blob5c79790187c4ed9bdce45676643a243f267ec6ab
1 /*
2 * s390x crypto helpers
4 * Copyright (c) 2017 Red Hat Inc
6 * Authors:
7 * David Hildenbrand <david@redhat.com>
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.
13 #include "qemu/osdep.h"
14 #include "qemu/main-loop.h"
15 #include "internal.h"
16 #include "exec/helper-proto.h"
17 #include "exec/exec-all.h"
18 #include "exec/cpu_ldst.h"
20 uint32_t HELPER(msa)(CPUS390XState *env, uint32_t r1, uint32_t r2, uint32_t r3,
21 uint32_t type)
23 const uintptr_t ra = GETPC();
24 const uint8_t mod = env->regs[0] & 0x80ULL;
25 const uint8_t fc = env->regs[0] & 0x7fULL;
26 uint8_t subfunc[16] = { 0 };
27 uint64_t param_addr;
28 int i;
30 switch (type) {
31 case S390_FEAT_TYPE_KMAC:
32 case S390_FEAT_TYPE_KIMD:
33 case S390_FEAT_TYPE_KLMD:
34 case S390_FEAT_TYPE_PCKMO:
35 case S390_FEAT_TYPE_PCC:
36 if (mod) {
37 s390_program_interrupt(env, PGM_SPECIFICATION, 4, ra);
38 return 0;
40 break;
43 s390_get_feat_block(type, subfunc);
44 if (!test_be_bit(fc, subfunc)) {
45 s390_program_interrupt(env, PGM_SPECIFICATION, 4, ra);
46 return 0;
49 switch (fc) {
50 case 0: /* query subfunction */
51 for (i = 0; i < 16; i++) {
52 param_addr = wrap_address(env, env->regs[1] + i);
53 cpu_stb_data_ra(env, param_addr, subfunc[i], ra);
55 break;
56 default:
57 /* we don't implement any other subfunction yet */
58 g_assert_not_reached();
61 return 0;