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

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