summaryrefslogtreecommitdiff
path: root/usr/src/uts
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/uts')
-rw-r--r--usr/src/uts/common/io/blkdev/blkdev.c74
-rw-r--r--usr/src/uts/common/io/mlxcx/mlxcx_endint.h10
-rw-r--r--usr/src/uts/common/sys/blkdev.h7
-rw-r--r--usr/src/uts/common/sys/debug.h5
-rw-r--r--usr/src/uts/i86pc/vm/hat_i86.c8
5 files changed, 57 insertions, 47 deletions
diff --git a/usr/src/uts/common/io/blkdev/blkdev.c b/usr/src/uts/common/io/blkdev/blkdev.c
index 7e5e5716e2..2587d51799 100644
--- a/usr/src/uts/common/io/blkdev/blkdev.c
+++ b/usr/src/uts/common/io/blkdev/blkdev.c
@@ -207,7 +207,7 @@ struct bd_handle {
void *h_private;
bd_t *h_bd;
char *h_name;
- char h_addr[30]; /* enough for w%0.16x,%X */
+ char h_addr[50]; /* enough for w%0.32x,%X */
};
struct bd_xfer_impl {
@@ -651,6 +651,7 @@ bd_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
int rv;
char name[16];
char kcache[32];
+ char *node_type;
switch (cmd) {
case DDI_ATTACH:
@@ -823,11 +824,17 @@ bd_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
offsetof(struct bd_xfer_impl, i_linkage));
}
+ if (*(uint64_t *)drive.d_eui64 != 0 ||
+ *(uint64_t *)drive.d_guid != 0 ||
+ *((uint64_t *)drive.d_guid + 1) != 0)
+ node_type = DDI_NT_BLOCK_BLKDEV;
+ else if (drive.d_lun >= 0)
+ node_type = DDI_NT_BLOCK_CHAN;
+ else
+ node_type = DDI_NT_BLOCK;
+
rv = cmlb_attach(dip, &bd_tg_ops, DTYPE_DIRECT,
- bd->d_removable, bd->d_hotpluggable,
- /*LINTED: E_BAD_PTR_CAST_ALIGN*/
- *(uint64_t *)drive.d_eui64 != 0 ? DDI_NT_BLOCK_BLKDEV :
- drive.d_lun >= 0 ? DDI_NT_BLOCK_CHAN : DDI_NT_BLOCK,
+ bd->d_removable, bd->d_hotpluggable, node_type,
CMLB_FAKE_LABEL_ONE_PARTITION, bd->d_cmlbh, 0);
if (rv != 0) {
goto fail_cmlb_attach;
@@ -2325,8 +2332,9 @@ bd_free_handle(bd_handle_t hdl)
int
bd_attach_handle(dev_info_t *dip, bd_handle_t hdl)
{
- dev_info_t *child;
bd_drive_t drive = { 0 };
+ dev_info_t *child;
+ size_t len;
/*
* It's not an error if bd_attach_handle() is called on a handle that
@@ -2345,31 +2353,37 @@ bd_attach_handle(dev_info_t *dip, bd_handle_t hdl)
hdl->h_parent = dip;
hdl->h_name = "blkdev";
- /*LINTED: E_BAD_PTR_CAST_ALIGN*/
- if (*(uint64_t *)drive.d_eui64 != 0) {
- if (drive.d_lun >= 0) {
- (void) snprintf(hdl->h_addr, sizeof (hdl->h_addr),
- "w%02X%02X%02X%02X%02X%02X%02X%02X,%X",
- drive.d_eui64[0], drive.d_eui64[1],
- drive.d_eui64[2], drive.d_eui64[3],
- drive.d_eui64[4], drive.d_eui64[5],
- drive.d_eui64[6], drive.d_eui64[7], drive.d_lun);
- } else {
- (void) snprintf(hdl->h_addr, sizeof (hdl->h_addr),
- "w%02X%02X%02X%02X%02X%02X%02X%02X",
- drive.d_eui64[0], drive.d_eui64[1],
- drive.d_eui64[2], drive.d_eui64[3],
- drive.d_eui64[4], drive.d_eui64[5],
- drive.d_eui64[6], drive.d_eui64[7]);
- }
+ /*
+ * Prefer the GUID over the EUI64.
+ */
+ if (*(uint64_t *)drive.d_guid != 0 ||
+ *((uint64_t *)drive.d_guid + 1) != 0) {
+ len = snprintf(hdl->h_addr, sizeof (hdl->h_addr),
+ "w%02X%02X%02X%02X%02X%02X%02X%02X"
+ "%02X%02X%02X%02X%02X%02X%02X%02X",
+ drive.d_guid[0], drive.d_guid[1], drive.d_guid[2],
+ drive.d_guid[3], drive.d_guid[4], drive.d_guid[5],
+ drive.d_guid[6], drive.d_guid[7], drive.d_guid[8],
+ drive.d_guid[9], drive.d_guid[10], drive.d_guid[11],
+ drive.d_guid[12], drive.d_guid[13], drive.d_guid[14],
+ drive.d_guid[15]);
+ } else if (*(uint64_t *)drive.d_eui64 != 0) {
+ len = snprintf(hdl->h_addr, sizeof (hdl->h_addr),
+ "w%02X%02X%02X%02X%02X%02X%02X%02X",
+ drive.d_eui64[0], drive.d_eui64[1],
+ drive.d_eui64[2], drive.d_eui64[3],
+ drive.d_eui64[4], drive.d_eui64[5],
+ drive.d_eui64[6], drive.d_eui64[7]);
} else {
- if (drive.d_lun >= 0) {
- (void) snprintf(hdl->h_addr, sizeof (hdl->h_addr),
- "%X,%X", drive.d_target, drive.d_lun);
- } else {
- (void) snprintf(hdl->h_addr, sizeof (hdl->h_addr),
- "%X", drive.d_target);
- }
+ len = snprintf(hdl->h_addr, sizeof (hdl->h_addr),
+ "%X", drive.d_target);
+ }
+
+ VERIFY(len <= sizeof (hdl->h_addr));
+
+ if (drive.d_lun >= 0) {
+ (void) snprintf(hdl->h_addr + len, sizeof (hdl->h_addr) - len,
+ ",%X", drive.d_lun);
}
if (ndi_devi_alloc(dip, hdl->h_name, (pnode_t)DEVI_SID_NODEID,
diff --git a/usr/src/uts/common/io/mlxcx/mlxcx_endint.h b/usr/src/uts/common/io/mlxcx/mlxcx_endint.h
index 4ad69173c0..acc8f4216c 100644
--- a/usr/src/uts/common/io/mlxcx/mlxcx_endint.h
+++ b/usr/src/uts/common/io/mlxcx/mlxcx_endint.h
@@ -36,12 +36,10 @@
* gain a little bit of type safety when dealing with endian-swapped bitfields.
*/
-#pragma pack(1)
-typedef struct { uint16_t be_val; } uint16be_t;
-typedef struct { uint8_t be_val[3]; } uint24be_t;
-typedef struct { uint32_t be_val; } uint32be_t;
-typedef struct { uint64_t be_val; } uint64be_t;
-#pragma pack()
+typedef struct { uint16_t be_val; } __packed uint16be_t;
+typedef struct { uint8_t be_val[3]; } __packed uint24be_t;
+typedef struct { uint32_t be_val; } __packed uint32be_t;
+typedef struct { uint64_t be_val; } __packed uint64be_t;
static inline uint16_t
from_be16(uint16be_t v)
diff --git a/usr/src/uts/common/sys/blkdev.h b/usr/src/uts/common/sys/blkdev.h
index 6407f7b960..7418aaac4c 100644
--- a/usr/src/uts/common/sys/blkdev.h
+++ b/usr/src/uts/common/sys/blkdev.h
@@ -20,10 +20,9 @@
*/
/*
* Copyright 2012 DEY Storage Systems, Inc. All rights reserved.
- * Copyright 2016 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2019 Western Digital Corporation.
* Copyright 2020 Joyent, Inc.
+ * Copyright 2022 Tintri by DDN, Inc. All rights reserved.
*/
#ifndef _SYS_BLKDEV_H
@@ -120,8 +119,10 @@ struct bd_drive {
char *d_serial;
size_t d_revision_len;
char *d_revision;
+
uint8_t d_eui64[8];
- /* Added at the end to maintain binary compatibility */
+ uint8_t d_guid[16];
+
uint32_t d_qcount;
/*
diff --git a/usr/src/uts/common/sys/debug.h b/usr/src/uts/common/sys/debug.h
index 9c91905af2..0c1625455a 100644
--- a/usr/src/uts/common/sys/debug.h
+++ b/usr/src/uts/common/sys/debug.h
@@ -133,10 +133,7 @@ _NOTE(CONSTCOND) } while (0)
/*
* Compile-time assertion. The condition 'x' must be constant.
*/
-#define CTASSERT(x) _CTASSERT(x, __LINE__)
-#define _CTASSERT(x, y) __CTASSERT(x, y)
-#define __CTASSERT(x, y) \
- typedef char __compile_time_assertion__ ## y [(x) ? 1 : -1] __unused
+#define CTASSERT(x) _Static_assert(x, "compile-time assertion failed")
#if defined(_KERNEL) || defined(_FAKE_KERNEL)
diff --git a/usr/src/uts/i86pc/vm/hat_i86.c b/usr/src/uts/i86pc/vm/hat_i86.c
index e5676e5cff..cf7f97f972 100644
--- a/usr/src/uts/i86pc/vm/hat_i86.c
+++ b/usr/src/uts/i86pc/vm/hat_i86.c
@@ -1140,8 +1140,8 @@ hat_pcp_setup(struct cpu *cpu)
*/
hati_cpu_punchin(cpu, (uintptr_t)&kdi_idt, PROT_READ);
- CTASSERT(((uintptr_t)&kpti_tramp_start % MMU_PAGESIZE) == 0);
- CTASSERT(((uintptr_t)&kpti_tramp_end % MMU_PAGESIZE) == 0);
+ VERIFY0((uintptr_t)&kpti_tramp_start % MMU_PAGESIZE);
+ VERIFY0((uintptr_t)&kpti_tramp_end % MMU_PAGESIZE);
for (va = (uintptr_t)&kpti_tramp_start;
va < (uintptr_t)&kpti_tramp_end; va += MMU_PAGESIZE) {
hati_cpu_punchin(cpu, va, PROT_READ | PROT_EXEC);
@@ -1175,8 +1175,8 @@ hat_pcp_setup(struct cpu *cpu)
}
}
- CTASSERT(((uintptr_t)&kdi_isr_start % MMU_PAGESIZE) == 0);
- CTASSERT(((uintptr_t)&kdi_isr_end % MMU_PAGESIZE) == 0);
+ VERIFY0((uintptr_t)&kdi_isr_start % MMU_PAGESIZE);
+ VERIFY0((uintptr_t)&kdi_isr_end % MMU_PAGESIZE);
for (va = (uintptr_t)&kdi_isr_start;
va < (uintptr_t)&kdi_isr_end; va += MMU_PAGESIZE) {
hati_cpu_punchin(cpu, va, PROT_READ | PROT_EXEC);