lszcrypt: Fix wrong state showing up for removed AP queue within SE guest

When a queue is removed from a SE guest which was in a state other
than "usable" (for example "unbound") the state displayed by lszcrypt
switches to "usable" until the queue device is finally removed by the
AP bus scan running every 30s.

This intermediate state is caused by reading 0x00000000 on the
underlying /sys/devices/cardxx/xx.yyyy/ap_functions. lszcrypt only
extracts the BS bits from this value and maps these both bits to
string output
  0: "usable"
  1: "bound"
  2: "unbound"
  3: "illicit"
totally ignoring the fact that there is no AP function at all.

Now the code checks for a valid ap_functions value first, before
actually extracting and displaying the SE state. In case the
ap_functions reads as 0x00000000 lszcrypt now displays the string
"invalid".

Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Reviewed-by: Holger Dengler <dengler@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Harald Freudenberger
2024-10-11 14:28:50 +02:00
committed by Jan Höppner
parent b7ac46b98b
commit 300f8d23b5

View File

@@ -693,21 +693,25 @@ static void read_subdev_rec_verbose(struct util_rec *rec, const char *grp_dev,
util_rec_set(rec, "sestat", "error");
return;
}
switch (EXTRACT_BS_BITS(facility)) {
case 0:
util_rec_set(rec, "sestat", "usable");
break;
case 1:
util_rec_set(rec, "sestat", "bound");
break;
case 2:
util_rec_set(rec, "sestat", "unbound");
break;
case 3:
util_rec_set(rec, "sestat", "illicit");
break;
default:
util_rec_set(rec, "sestat", "-");
if (facility) {
switch (EXTRACT_BS_BITS(facility)) {
case 0:
util_rec_set(rec, "sestat", "usable");
break;
case 1:
util_rec_set(rec, "sestat", "bound");
break;
case 2:
util_rec_set(rec, "sestat", "unbound");
break;
case 3:
util_rec_set(rec, "sestat", "illicit");
break;
default:
util_rec_set(rec, "sestat", "-");
}
} else {
util_rec_set(rec, "sestat", "invalid");
}
}
}