]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
scsi: devinfo: warn on undefined blist flags
authorMartin Wilck <mwilck@suse.com>
Tue, 17 Apr 2018 23:35:09 +0000 (01:35 +0200)
committerMartin K. Petersen <martin.petersen@oracle.com>
Fri, 20 Apr 2018 23:14:35 +0000 (19:14 -0400)
Warn if a device (or the user) sets blist flags which are unknown
or have been removed. This should enable us to reuse freed blist
bits in later releases.

Signed-off-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/Makefile
drivers/scsi/scsi_devinfo.c
include/scsi/scsi_devinfo.h

index f31145d6d4722df71a77f9b807e3e13de8de6884..eb30e558fc360dd2fbe257589b4641828313b0a5 100644 (file)
@@ -190,7 +190,7 @@ $(obj)/53c700.o $(MODVERDIR)/$(obj)/53c700.ver: $(obj)/53c700_d.h
 $(obj)/scsi_sysfs.o: $(obj)/scsi_devinfo_tbl.c
 
 quiet_cmd_bflags = GEN     $@
-       cmd_bflags = sed -n 's/.*BLIST_\([A-Z0-9_]*\) *.*/BLIST_FLAG_NAME(\1),/p' $< > $@
+       cmd_bflags = sed -n 's/.*define *BLIST_\([A-Z0-9_]*\) *.*/BLIST_FLAG_NAME(\1),/p' $< > $@
 
 $(obj)/scsi_devinfo_tbl.c: include/scsi/scsi_devinfo.h
        $(call if_changed,bflags)
index bd04a33e4360f3636e4f66597d8e40b6619a64b2..9603f3ef18aa76da265acb43b661851089a7ff99 100644 (file)
@@ -370,6 +370,12 @@ int scsi_dev_info_list_add_keyed(int compatible, char *vendor, char *model,
                }
                flags = (__force blist_flags_t)val;
        }
+       if (flags & __BLIST_UNUSED_MASK) {
+               pr_err("scsi_devinfo (%s:%s): unsupported flags 0x%llx",
+                      vendor, model, flags & __BLIST_UNUSED_MASK);
+               kfree(devinfo);
+               return -EINVAL;
+       }
        devinfo->flags = flags;
        devinfo->compatible = compatible;
 
index e206d299f1370c3585006738f87986099b752629..3434e143feff3183fc362d6e4c2eab399e867ce6 100644 (file)
 #define BLIST_LARGELUN         ((__force blist_flags_t)(1ULL << 9))
 /* override additional length field */
 #define BLIST_INQUIRY_36       ((__force blist_flags_t)(1ULL << 10))
+#define __BLIST_UNUSED_11      ((__force blist_flags_t)(1ULL << 11))
 /* do not do automatic start on add */
 #define BLIST_NOSTARTONADD     ((__force blist_flags_t)(1ULL << 12))
+#define __BLIST_UNUSED_13      ((__force blist_flags_t)(1ULL << 13))
+#define __BLIST_UNUSED_14      ((__force blist_flags_t)(1ULL << 14))
+#define __BLIST_UNUSED_15      ((__force blist_flags_t)(1ULL << 15))
+#define __BLIST_UNUSED_16      ((__force blist_flags_t)(1ULL << 16))
 /* try REPORT_LUNS even for SCSI-2 devs (if HBA supports more than 8 LUNs) */
 #define BLIST_REPORTLUN2       ((__force blist_flags_t)(1ULL << 17))
 /* don't try REPORT_LUNS scan (SCSI-3 devs) */
 #define BLIST_RETRY_HWERROR    ((__force blist_flags_t)(1ULL << 22))
 /* maximum 512 sector cdb length */
 #define BLIST_MAX_512          ((__force blist_flags_t)(1ULL << 23))
+#define __BLIST_UNUSED_24      ((__force blist_flags_t)(1ULL << 24))
 /* Disable T10 PI (DIF) */
 #define BLIST_NO_DIF           ((__force blist_flags_t)(1ULL << 25))
 /* Ignore SBC-3 VPD pages */
 #define BLIST_SKIP_VPD_PAGES   ((__force blist_flags_t)(1ULL << 26))
+#define __BLIST_UNUSED_27      ((__force blist_flags_t)(1ULL << 27))
 /* Attempt to read VPD pages */
 #define BLIST_TRY_VPD_PAGES    ((__force blist_flags_t)(1ULL << 28))
 /* don't try to issue RSOC */
 /* Use UNMAP limit for WRITE SAME */
 #define BLIST_UNMAP_LIMIT_WS   ((__force blist_flags_t)(1ULL << 31))
 
+#define __BLIST_LAST_USED BLIST_UNMAP_LIMIT_WS
+
+#define __BLIST_HIGH_UNUSED (~(__BLIST_LAST_USED | \
+                              (__force blist_flags_t) \
+                              ((__force __u64)__BLIST_LAST_USED - 1ULL)))
+#define __BLIST_UNUSED_MASK (__BLIST_UNUSED_11 | \
+                            __BLIST_UNUSED_13 | \
+                            __BLIST_UNUSED_14 | \
+                            __BLIST_UNUSED_15 | \
+                            __BLIST_UNUSED_16 | \
+                            __BLIST_UNUSED_24 | \
+                            __BLIST_UNUSED_27 | \
+                            __BLIST_HIGH_UNUSED)
+
 #endif