This source file includes following definitions.
- convert_error
   1 
   2 
   3 
   4 
   5 
   6 
   7 
   8 
   9 
  10 
  11 #ifndef _ZCRYPT_ERROR_H_
  12 #define _ZCRYPT_ERROR_H_
  13 
  14 #include <linux/atomic.h>
  15 #include "zcrypt_debug.h"
  16 #include "zcrypt_api.h"
  17 #include "zcrypt_msgtype6.h"
  18 
  19 
  20 
  21 
  22 
  23 
  24 
  25 
  26 
  27 
  28 
  29 
  30 
  31 
  32 
  33 struct error_hdr {
  34         unsigned char reserved1;        
  35         unsigned char type;             
  36         unsigned char reserved2[2];     
  37         unsigned char reply_code;       
  38         unsigned char reserved3[3];     
  39 };
  40 
  41 #define TYPE82_RSP_CODE 0x82
  42 #define TYPE88_RSP_CODE 0x88
  43 
  44 #define REP82_ERROR_MACHINE_FAILURE         0x10
  45 #define REP82_ERROR_PREEMPT_FAILURE         0x12
  46 #define REP82_ERROR_CHECKPT_FAILURE         0x14
  47 #define REP82_ERROR_MESSAGE_TYPE            0x20
  48 #define REP82_ERROR_INVALID_COMM_CD         0x21 
  49 #define REP82_ERROR_INVALID_MSG_LEN         0x23
  50 #define REP82_ERROR_RESERVD_FIELD           0x24 
  51 #define REP82_ERROR_FORMAT_FIELD            0x29
  52 #define REP82_ERROR_INVALID_COMMAND         0x30
  53 #define REP82_ERROR_MALFORMED_MSG           0x40
  54 #define REP82_ERROR_INVALID_SPECIAL_CMD     0x41
  55 #define REP82_ERROR_INVALID_DOMAIN_PRECHECK 0x42
  56 #define REP82_ERROR_RESERVED_FIELDO         0x50 
  57 #define REP82_ERROR_WORD_ALIGNMENT          0x60
  58 #define REP82_ERROR_MESSAGE_LENGTH          0x80
  59 #define REP82_ERROR_OPERAND_INVALID         0x82
  60 #define REP82_ERROR_OPERAND_SIZE            0x84
  61 #define REP82_ERROR_EVEN_MOD_IN_OPND        0x85
  62 #define REP82_ERROR_RESERVED_FIELD          0x88
  63 #define REP82_ERROR_INVALID_DOMAIN_PENDING  0x8A
  64 #define REP82_ERROR_FILTERED_BY_HYPERVISOR  0x8B
  65 #define REP82_ERROR_TRANSPORT_FAIL          0x90
  66 #define REP82_ERROR_PACKET_TRUNCATED        0xA0
  67 #define REP82_ERROR_ZERO_BUFFER_LEN         0xB0
  68 
  69 #define REP88_ERROR_MODULE_FAILURE          0x10
  70 
  71 #define REP88_ERROR_MESSAGE_TYPE            0x20
  72 #define REP88_ERROR_MESSAGE_MALFORMD        0x22
  73 #define REP88_ERROR_MESSAGE_LENGTH          0x23
  74 #define REP88_ERROR_RESERVED_FIELD          0x24
  75 #define REP88_ERROR_KEY_TYPE                0x34
  76 #define REP88_ERROR_INVALID_KEY     0x82 
  77 #define REP88_ERROR_OPERAND                 0x84 
  78 #define REP88_ERROR_OPERAND_EVEN_MOD        0x85 
  79 
  80 static inline int convert_error(struct zcrypt_queue *zq,
  81                                 struct ap_message *reply)
  82 {
  83         struct error_hdr *ehdr = reply->message;
  84         int card = AP_QID_CARD(zq->queue->qid);
  85         int queue = AP_QID_QUEUE(zq->queue->qid);
  86 
  87         switch (ehdr->reply_code) {
  88         case REP82_ERROR_OPERAND_INVALID:
  89         case REP82_ERROR_OPERAND_SIZE:
  90         case REP82_ERROR_EVEN_MOD_IN_OPND:
  91         case REP88_ERROR_MESSAGE_MALFORMD:
  92         case REP82_ERROR_INVALID_DOMAIN_PRECHECK:
  93         case REP82_ERROR_INVALID_DOMAIN_PENDING:
  94         case REP82_ERROR_INVALID_SPECIAL_CMD:
  95         case REP82_ERROR_FILTERED_BY_HYPERVISOR:
  96         
  97         
  98         
  99                 
 100                 ZCRYPT_DBF(DBF_WARN,
 101                            "device=%02x.%04x reply=0x%02x => rc=EINVAL\n",
 102                            card, queue, ehdr->reply_code);
 103                 return -EINVAL;
 104         case REP82_ERROR_MESSAGE_TYPE:
 105         
 106                 
 107 
 108 
 109 
 110 
 111                 atomic_set(&zcrypt_rescan_req, 1);
 112                 zq->online = 0;
 113                 pr_err("Cryptographic device %02x.%04x failed and was set offline\n",
 114                        card, queue);
 115                 ZCRYPT_DBF(DBF_ERR,
 116                            "device=%02x.%04x reply=0x%02x => online=0 rc=EAGAIN\n",
 117                            card, queue, ehdr->reply_code);
 118                 return -EAGAIN;
 119         case REP82_ERROR_TRANSPORT_FAIL:
 120                 
 121                 atomic_set(&zcrypt_rescan_req, 1);
 122                 zq->online = 0;
 123                 pr_err("Cryptographic device %02x.%04x failed and was set offline\n",
 124                        card, queue);
 125                 
 126                 if (ehdr->type == TYPE86_RSP_CODE) {
 127                         struct {
 128                                 struct type86_hdr hdr;
 129                                 struct type86_fmt2_ext fmt2;
 130                         } __packed * head = reply->message;
 131                         unsigned int apfs = *((u32 *)head->fmt2.apfs);
 132 
 133                         ZCRYPT_DBF(DBF_ERR,
 134                                    "device=%02x.%04x reply=0x%02x apfs=0x%x => online=0 rc=EAGAIN\n",
 135                                    card, queue, apfs, ehdr->reply_code);
 136                 } else
 137                         ZCRYPT_DBF(DBF_ERR,
 138                                    "device=%02x.%04x reply=0x%02x => online=0 rc=EAGAIN\n",
 139                                    card, queue, ehdr->reply_code);
 140                 return -EAGAIN;
 141         case REP82_ERROR_MACHINE_FAILURE:
 142         
 143                 
 144                 atomic_set(&zcrypt_rescan_req, 1);
 145                 zq->online = 0;
 146                 pr_err("Cryptographic device %02x.%04x failed and was set offline\n",
 147                        card, queue);
 148                 ZCRYPT_DBF(DBF_ERR,
 149                            "device=%02x.%04x reply=0x%02x => online=0 rc=EAGAIN\n",
 150                            card, queue, ehdr->reply_code);
 151                 return -EAGAIN;
 152         default:
 153                 zq->online = 0;
 154                 pr_err("Cryptographic device %02x.%04x failed and was set offline\n",
 155                        card, queue);
 156                 ZCRYPT_DBF(DBF_ERR,
 157                            "device=%02x.%04x reply=0x%02x => online=0 rc=EAGAIN\n",
 158                            card, queue, ehdr->reply_code);
 159                 return -EAGAIN; 
 160         }
 161 }
 162 
 163 #endif