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

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