]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
s390/ap/zcrypt: Rearrange fields within AP and zcrypt structs
authorHarald Freudenberger <freude@linux.ibm.com>
Mon, 27 Apr 2026 16:09:39 +0000 (18:09 +0200)
committerAlexander Gordeev <agordeev@linux.ibm.com>
Wed, 3 Jun 2026 13:32:43 +0000 (15:32 +0200)
Rearrange some fields within AP and zcrypt structs to reduce
memory consumption and unused holes with the help of pahole
analysis of the code.

Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Reviewed-by: Holger Dengler <dengler@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
drivers/s390/crypto/ap_bus.h
drivers/s390/crypto/zcrypt_api.h
drivers/s390/crypto/zcrypt_ccamisc.h
drivers/s390/crypto/zcrypt_ep11misc.h

index ca5e142c9b249a4478928d04de281a54386d1885..b2e57e5d6c3f028825cbf141a7cf0b583766c912 100644 (file)
@@ -134,8 +134,6 @@ struct ap_message;
 
 struct ap_driver {
        struct device_driver driver;
-       struct ap_device_id *ids;
-       unsigned int flags;
 
        int (*probe)(struct ap_device *);
        void (*remove)(struct ap_device *);
@@ -156,6 +154,9 @@ struct ap_driver {
         */
        void (*on_scan_complete)(struct ap_config_info *new_config_info,
                                 struct ap_config_info *old_config_info);
+
+       struct ap_device_id *ids;
+       unsigned int flags;
 };
 
 #define to_ap_drv(x) container_of_const((x), struct ap_driver, driver)
@@ -173,11 +174,11 @@ struct ap_device {
 struct ap_card {
        struct ap_device ap_dev;
        struct ap_tapq_hwinfo hwinfo;   /* TAPQ GR2 content */
-       int id;                         /* AP card number. */
+       atomic64_t total_request_count; /* # requests ever for this AP device.*/
        unsigned int maxmsgsize;        /* AP msg limit for this card */
+       int id;                         /* AP card number. */
        bool config;                    /* configured state */
        bool chkstop;                   /* checkstop state */
-       atomic64_t total_request_count; /* # requests ever for this AP device.*/
 };
 
 #define TAPQ_CARD_HWINFO_MASK 0xFFFF0000FFFF0F0FUL
@@ -190,16 +191,14 @@ struct ap_queue {
        struct hlist_node hnode;        /* Node for the ap_queues hashtable */
        struct ap_card *card;           /* Ptr to assoc. AP card. */
        spinlock_t lock;                /* Per device lock. */
+       u64 total_request_count;        /* # requests ever for this AP device.*/
        enum ap_dev_state dev_state;    /* queue device state */
-       bool config;                    /* configured state */
-       bool chkstop;                   /* checkstop state */
        ap_qid_t qid;                   /* AP queue id. */
        unsigned int se_bstate;         /* SE bind state (BS) */
        unsigned int assoc_idx;         /* SE association index */
        int queue_count;                /* # messages currently on AP queue. */
        int pendingq_count;             /* # requests on pendingq list. */
        int requestq_count;             /* # requests on requestq list. */
-       u64 total_request_count;        /* # requests ever for this AP device.*/
        int request_timeout;            /* Request timeout in jiffies. */
        struct timer_list timeout;      /* Timer for request timeouts. */
        struct list_head pendingq;      /* List of message sent to AP queue. */
@@ -208,6 +207,8 @@ struct ap_queue {
        enum ap_sm_state sm_state;      /* ap queue state machine state */
        int rapq_fbit;                  /* fbit arg for next rapq invocation */
        int last_err_rc;                /* last error state response code */
+       bool config;                    /* configured state */
+       bool chkstop;                   /* checkstop state */
 };
 
 #define to_ap_queue(x) container_of((x), struct ap_queue, ap_dev.device)
@@ -225,12 +226,12 @@ struct ap_message {
        void *msg;                      /* Pointer to message buffer. */
        size_t len;                     /* actual msg len in msg buffer */
        size_t bufsize;                 /* allocated msg buffer size */
-       u16 flags;                      /* Flags, see AP_MSG_FLAG_xxx */
-       int rc;                         /* Return code for this message */
-       struct ap_response_type response;
        /* receive is called from tasklet context */
        void (*receive)(struct ap_queue *, struct ap_message *,
                        struct ap_message *);
+       struct ap_response_type response;
+       int rc;                         /* Return code for this message */
+       u16 flags;                      /* Flags, see AP_MSG_FLAG_xxx */
 };
 
 #define AP_MSG_FLAG_SPECIAL  0x0001    /* flag msg as 'special' with NQAP */
index 6ef8850a42df1fc4a43078af02b899e934d48801..9f8df809bb85090b0955a6f2b5eb279b8558420c 100644 (file)
@@ -104,33 +104,28 @@ struct zcrypt_card {
        struct list_head list;          /* Device list. */
        struct list_head zqueues;       /* List of zcrypt queues */
        struct kref refcount;           /* device refcounting */
-       struct ap_card *card;           /* The "real" ap card device. */
        int online;                     /* User online/offline */
-
-       int user_space_type;            /* User space device id. */
+       struct ap_card *card;           /* The "real" ap card device. */
        char *type_string;              /* User space device name. */
+       int user_space_type;            /* User space device id. */
        int min_mod_size;               /* Min number of bits. */
        int max_mod_size;               /* Max number of bits. */
        int max_exp_bit_length;
        const int *speed_rating;        /* Speed idx of crypto ops. */
        atomic_t load;                  /* Utilization of the crypto device */
-
        int request_count;              /* # current requests. */
 };
 
 struct zcrypt_queue {
        struct list_head list;          /* Device list. */
        struct kref refcount;           /* device refcounting */
+       int online;                     /* User online/offline */
        struct zcrypt_card *zcard;
        struct zcrypt_ops *ops;         /* Crypto operations. */
        struct ap_queue *queue;         /* The "real" ap queue device. */
-       int online;                     /* User online/offline */
-
+       struct ap_message reply;        /* Per-device reply structure. */
        atomic_t load;                  /* Utilization of the crypto device */
-
        int request_count;              /* # current requests. */
-
-       struct ap_message reply;        /* Per-device reply structure. */
 };
 
 /* transport layer rescanning */
index 06507363947b4a88bf270d99b20dd38615287923..07bbb1c2002273c890c29f115631bec1a4878ec0 100644 (file)
@@ -235,7 +235,16 @@ int cca_findcard2(u32 *apqns, u32 *nr_apqns, u16 cardnr, u16 domain,
 
 /* struct to hold info for each CCA queue */
 struct cca_info {
-       int  hwtype;            /* one of the defined AP_DEVICE_TYPE_* */
+       u8   new_asym_mkvp[16]; /* verify pattern of new asym master key */
+       u8   cur_asym_mkvp[16]; /* verify pattern of current asym master key */
+       u8   old_asym_mkvp[16]; /* verify pattern of old asym master key */
+       u8   new_aes_mkvp[8];   /* truncated sha256 of new aes master key */
+       u8   cur_aes_mkvp[8];   /* truncated sha256 of current aes master key */
+       u8   old_aes_mkvp[8];   /* truncated sha256 of old aes master key */
+       u8   new_apka_mkvp[8];  /* truncated sha256 of new apka master key */
+       u8   cur_apka_mkvp[8];  /* truncated sha256 of current apka mk */
+       u8   old_apka_mkvp[8];  /* truncated sha256 of old apka mk */
+       char serial[9];         /* serial number (8 ascii numbers + 0x00) */
        char new_aes_mk_state;  /* '1' empty, '2' partially full, '3' full */
        char cur_aes_mk_state;  /* '1' invalid, '2' valid */
        char old_aes_mk_state;  /* '1' invalid, '2' valid */
@@ -245,16 +254,7 @@ struct cca_info {
        char new_asym_mk_state; /* '1' empty, '2' partially full, '3' full */
        char cur_asym_mk_state; /* '1' invalid, '2' valid */
        char old_asym_mk_state; /* '1' invalid, '2' valid */
-       u8   new_aes_mkvp[8];   /* truncated sha256 of new aes master key */
-       u8   cur_aes_mkvp[8];   /* truncated sha256 of current aes master key */
-       u8   old_aes_mkvp[8];   /* truncated sha256 of old aes master key */
-       u8   new_apka_mkvp[8];  /* truncated sha256 of new apka master key */
-       u8   cur_apka_mkvp[8];  /* truncated sha256 of current apka mk */
-       u8   old_apka_mkvp[8];  /* truncated sha256 of old apka mk */
-       u8   new_asym_mkvp[16]; /* verify pattern of new asym master key */
-       u8   cur_asym_mkvp[16]; /* verify pattern of current asym master key */
-       u8   old_asym_mkvp[16]; /* verify pattern of old asym master key */
-       char serial[9];         /* serial number (8 ascii numbers + 0x00) */
+       int  hwtype;            /* one of the defined AP_DEVICE_TYPE_* */
 };
 
 /*
index b5e6fd861815b3ba0c12e82ebefefb221cfbcec0..05006817b6c0d3e47ebcf13a3a68a93f25f9bbf1 100644 (file)
@@ -86,19 +86,19 @@ int ep11_check_aes_key(debug_info_t *dbg, int dbflvl,
 
 /* EP11 card info struct */
 struct ep11_card_info {
+       u64  op_mode;       /* card operational mode(s) */
+       char serial[16];    /* serial number string (16 ascii, no 0x00 !) */
        u32  API_ord_nr;    /* API ordinal number */
        u16  FW_version;    /* Firmware major and minor version */
-       char serial[16];    /* serial number string (16 ascii, no 0x00 !) */
-       u64  op_mode;       /* card operational mode(s) */
 };
 
 /* EP11 domain info struct */
 struct ep11_domain_info {
-       char cur_wk_state;  /* '0' invalid, '1' valid */
-       char new_wk_state;  /* '0' empty, '1' uncommitted, '2' committed */
+       u64  op_mode;       /* domain operational mode(s) */
        u8   cur_wkvp[32];  /* current wrapping key verification pattern */
        u8   new_wkvp[32];  /* new wrapping key verification pattern */
-       u64  op_mode;       /* domain operational mode(s) */
+       char cur_wk_state;  /* '0' invalid, '1' valid */
+       char new_wk_state;  /* '0' empty, '1' uncommitted, '2' committed */
 };
 
 /*