Blame SOURCES/0015-EP11-Default-unknown-CPs-to-ON.patch

971d89
From 65cb0f2b0204183617b5d6e8e475f85faa8b789d Mon Sep 17 00:00:00 2001
971d89
From: Ingo Franzki <ifranzki@linux.ibm.com>
971d89
Date: Mon, 14 Feb 2022 16:35:34 +0100
971d89
Subject: [PATCH 15/34] EP11: Default unknown CPs to ON
971d89
971d89
Newer EP11 cards know additional control points that older cards do not
971d89
know. When building the combined minimum control point setting, treat
971d89
unknown control points as ON, to not disable mechanisms just because an
971d89
older card does not know a control point.
971d89
971d89
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
971d89
---
971d89
 usr/lib/ep11_stdll/ep11_specific.c | 21 +++++++++++++++++----
971d89
 1 file changed, 17 insertions(+), 4 deletions(-)
971d89
971d89
diff --git a/usr/lib/ep11_stdll/ep11_specific.c b/usr/lib/ep11_stdll/ep11_specific.c
971d89
index 147ce7b2..e3451163 100644
971d89
--- a/usr/lib/ep11_stdll/ep11_specific.c
971d89
+++ b/usr/lib/ep11_stdll/ep11_specific.c
971d89
@@ -10904,13 +10904,18 @@ static CK_RV control_point_handler(uint_32 adapter, uint_32 domain,
971d89
 #ifdef DEBUG
971d89
     TRACE_DEBUG("Control points from adapter %02X.%04X\n", adapter, domain);
971d89
     TRACE_DEBUG_DUMP("    ", cp, cp_len);
971d89
+    TRACE_DEBUG("Max control point index: %lu\n", max_cp_index);
971d89
 #endif
971d89
 
971d89
     if (data->first) {
971d89
         data->first_adapter = adapter;
971d89
         data->first_domain = domain;
971d89
-        memcpy(data->first_cp, cp, cp_len);
971d89
-        memcpy(data->combined_cp, cp, cp_len);
971d89
+        /* Apply CP bits 0 to max_cp_index-1 only */
971d89
+        for (i = 0; i < max_cp_index; i++) {
971d89
+            data->combined_cp[CP_BYTE_NO(i)] &=
971d89
+                                    (cp[CP_BYTE_NO(i)] | ~CP_BIT_MASK(i));
971d89
+        }
971d89
+        memcpy(data->first_cp, data->combined_cp, sizeof(data->first_cp));
971d89
         data->max_cp_index = max_cp_index;
971d89
         data->first = 0;
971d89
     } else {
971d89
@@ -10927,8 +10932,10 @@ static CK_RV control_point_handler(uint_32 adapter, uint_32 domain,
971d89
                        data->first_domain);
971d89
         }
971d89
 
971d89
-        for (i = 0; i < cp_len; i++) {
971d89
-            data->combined_cp[i] &= cp[i];
971d89
+        for (i = 0; i < max_cp_index; i++) {
971d89
+            /* Apply CP bits 0 to max_cp_index-1 only */
971d89
+            data->combined_cp[CP_BYTE_NO(i)] &=
971d89
+                                    (cp[CP_BYTE_NO(i)] | ~CP_BIT_MASK(i));
971d89
         }
971d89
 
971d89
         if (max_cp_index != data->max_cp_index) {
971d89
@@ -10973,6 +10980,11 @@ static CK_RV get_control_points(STDLL_TokData_t * tokdata,
971d89
     ep11_private_data_t *ep11_data = tokdata->private_data;
971d89
 
971d89
     memset(&data, 0, sizeof(data));
971d89
+    /*
971d89
+     * Turn all CPs ON by default, so that newer control points that are unknown
971d89
+     * to older cards default to ON. CPs being OFF disable functionality.
971d89
+     */
971d89
+    memset(data.combined_cp, 0xff, sizeof(data.combined_cp));
971d89
     data.first = 1;
971d89
     rc = handle_all_ep11_cards(&ep11_data->target_list, control_point_handler,
971d89
                                &data);
971d89
@@ -10987,6 +10999,7 @@ static CK_RV get_control_points(STDLL_TokData_t * tokdata,
971d89
     TRACE_DEBUG("Combined control points from all cards (%lu CPs):\n",
971d89
                 data.max_cp_index);
971d89
     TRACE_DEBUG_DUMP("    ", cp, *cp_len);
971d89
+    TRACE_DEBUG("Max control point index: %lu\n", data.max_cp_index);
971d89
     print_control_points(cp, *cp_len, data.max_cp_index);
971d89
 #endif
971d89
 
971d89
-- 
971d89
2.16.2.windows.1
971d89