1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26#ifndef _ZCRYPT_ERROR_H_
27#define _ZCRYPT_ERROR_H_
28
29#include <linux/atomic.h>
30#include "zcrypt_debug.h"
31#include "zcrypt_api.h"
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47struct error_hdr {
48 unsigned char reserved1;
49 unsigned char type;
50 unsigned char reserved2[2];
51 unsigned char reply_code;
52 unsigned char reserved3[3];
53};
54
55#define TYPE82_RSP_CODE 0x82
56#define TYPE88_RSP_CODE 0x88
57
58#define REP82_ERROR_MACHINE_FAILURE 0x10
59#define REP82_ERROR_PREEMPT_FAILURE 0x12
60#define REP82_ERROR_CHECKPT_FAILURE 0x14
61#define REP82_ERROR_MESSAGE_TYPE 0x20
62#define REP82_ERROR_INVALID_COMM_CD 0x21
63#define REP82_ERROR_INVALID_MSG_LEN 0x23
64#define REP82_ERROR_RESERVD_FIELD 0x24
65#define REP82_ERROR_FORMAT_FIELD 0x29
66#define REP82_ERROR_INVALID_COMMAND 0x30
67#define REP82_ERROR_MALFORMED_MSG 0x40
68#define REP82_ERROR_RESERVED_FIELDO 0x50
69#define REP82_ERROR_WORD_ALIGNMENT 0x60
70#define REP82_ERROR_MESSAGE_LENGTH 0x80
71#define REP82_ERROR_OPERAND_INVALID 0x82
72#define REP82_ERROR_OPERAND_SIZE 0x84
73#define REP82_ERROR_EVEN_MOD_IN_OPND 0x85
74#define REP82_ERROR_RESERVED_FIELD 0x88
75#define REP82_ERROR_TRANSPORT_FAIL 0x90
76#define REP82_ERROR_PACKET_TRUNCATED 0xA0
77#define REP82_ERROR_ZERO_BUFFER_LEN 0xB0
78
79#define REP88_ERROR_MODULE_FAILURE 0x10
80
81#define REP88_ERROR_MESSAGE_TYPE 0x20
82#define REP88_ERROR_MESSAGE_MALFORMD 0x22
83#define REP88_ERROR_MESSAGE_LENGTH 0x23
84#define REP88_ERROR_RESERVED_FIELD 0x24
85#define REP88_ERROR_KEY_TYPE 0x34
86#define REP88_ERROR_INVALID_KEY 0x82
87#define REP88_ERROR_OPERAND 0x84
88#define REP88_ERROR_OPERAND_EVEN_MOD 0x85
89
90static inline int convert_error(struct zcrypt_device *zdev,
91 struct ap_message *reply)
92{
93 struct error_hdr *ehdr = reply->message;
94
95 switch (ehdr->reply_code) {
96 case REP82_ERROR_OPERAND_INVALID:
97 case REP82_ERROR_OPERAND_SIZE:
98 case REP82_ERROR_EVEN_MOD_IN_OPND:
99 case REP88_ERROR_MESSAGE_MALFORMD:
100
101
102
103
104 return -EINVAL;
105 case REP82_ERROR_MESSAGE_TYPE:
106
107
108
109
110
111
112 WARN_ON(1);
113 atomic_set(&zcrypt_rescan_req, 1);
114 zdev->online = 0;
115 ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%drc%d",
116 zdev->ap_dev->qid,
117 zdev->online, ehdr->reply_code);
118 return -EAGAIN;
119 case REP82_ERROR_TRANSPORT_FAIL:
120 case REP82_ERROR_MACHINE_FAILURE:
121
122
123 atomic_set(&zcrypt_rescan_req, 1);
124 zdev->online = 0;
125 ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%drc%d",
126 zdev->ap_dev->qid,
127 zdev->online, ehdr->reply_code);
128 return -EAGAIN;
129 default:
130 zdev->online = 0;
131 ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%drc%d",
132 zdev->ap_dev->qid,
133 zdev->online, ehdr->reply_code);
134 return -EAGAIN;
135 }
136}
137
138#endif
139