summaryrefslogtreecommitdiff
path: root/usr/src/uts
diff options
context:
space:
mode:
authorJerry Jelinek <jerry.jelinek@joyent.com>2020-09-08 11:35:00 +0000
committerJerry Jelinek <jerry.jelinek@joyent.com>2020-09-08 11:35:00 +0000
commit59a0703a940438d24a8cd9911a57711b8028c496 (patch)
tree816119c979bf679b1cef812f7c2f36f2d743800a /usr/src/uts
parent538446bd297154cf5d4db74adf78dfa23d05df0c (diff)
parent93d26c05275be2c44aedd16705237484fc0a0990 (diff)
downloadillumos-joyent-59a0703a940438d24a8cd9911a57711b8028c496.tar.gz
[illumos-gate merge]
commit 93d26c05275be2c44aedd16705237484fc0a0990 13015 fruaccess: comparison between pointer and zero character constant commit ba12489a763ade223e478c59fdc4cb752fcba568 13011 tsalarm: '*' in boolean context, suggest '&&' instead commit 09e6639baaf32231365cb9895bf1e0ea006a2a60 12885 efcode: smatch and build errors commit e4af2f17fac5babc25d094f1bf22dd06515f66c7 13104 zfs: offset_t is signed and can not be > MAXOFFSET_T commit 7aaede4825001926ae223b8c47ef9e4d0d6021ba 12974 libc: left shift of negative value commit 712669c9fa9278704a4ccefe1d96acaf29397d36 13103 zfs: zvol_strategy() warn: unsigned 'off' is never less than zero commit e075c017fe4c71cde62297bcc90d3411c0f4ad1d 12512 dispadmin.1m manpage is missing \fB \fR around FX commit 9b0881404678e5235132f9320785c3f5ce6e71f6 13087 zfs: zfs_ereport_post() and zfs_ereport_start() return values are ignored commit 5365b8a5984eca60a3cedc7f9f738e51fb056bec 12936 bhyve vlapic needs ability to bypass isrvec_stk
Diffstat (limited to 'usr/src/uts')
-rw-r--r--usr/src/uts/common/fs/zfs/arc.c7
-rw-r--r--usr/src/uts/common/fs/zfs/spa.c3
-rw-r--r--usr/src/uts/common/fs/zfs/spa_config.c3
-rw-r--r--usr/src/uts/common/fs/zfs/vdev.c7
-rw-r--r--usr/src/uts/common/fs/zfs/vdev_indirect.c6
-rw-r--r--usr/src/uts/common/fs/zfs/vdev_raidz.c2
-rw-r--r--usr/src/uts/common/fs/zfs/zfs_fm.c2
-rw-r--r--usr/src/uts/common/fs/zfs/zfs_vnops.c2
-rw-r--r--usr/src/uts/common/fs/zfs/zio.c10
-rw-r--r--usr/src/uts/common/fs/zfs/zvol.c2
-rw-r--r--usr/src/uts/i86pc/io/vmm/io/vlapic.c210
-rw-r--r--usr/src/uts/i86pc/io/vmm/io/vlapic_priv.h38
-rw-r--r--usr/src/uts/sun4v/ontario/io/tsalarm.c2
13 files changed, 187 insertions, 107 deletions
diff --git a/usr/src/uts/common/fs/zfs/arc.c b/usr/src/uts/common/fs/zfs/arc.c
index 9e04e5e00d..939282b378 100644
--- a/usr/src/uts/common/fs/zfs/arc.c
+++ b/usr/src/uts/common/fs/zfs/arc.c
@@ -2538,7 +2538,7 @@ arc_untransform(arc_buf_t *buf, spa_t *spa, const zbookmark_phys_t *zb,
*/
ret = SET_ERROR(EIO);
spa_log_error(spa, zb);
- zfs_ereport_post(FM_EREPORT_ZFS_AUTHENTICATION,
+ (void) zfs_ereport_post(FM_EREPORT_ZFS_AUTHENTICATION,
spa, NULL, zb, NULL, 0, 0);
}
@@ -5801,7 +5801,8 @@ arc_read_done(zio_t *zio)
error = SET_ERROR(EIO);
if ((zio->io_flags & ZIO_FLAG_SPECULATIVE) == 0) {
spa_log_error(zio->io_spa, &acb->acb_zb);
- zfs_ereport_post(FM_EREPORT_ZFS_AUTHENTICATION,
+ (void) zfs_ereport_post(
+ FM_EREPORT_ZFS_AUTHENTICATION,
zio->io_spa, NULL, &acb->acb_zb, zio, 0, 0);
}
}
@@ -6058,7 +6059,7 @@ top:
rc = SET_ERROR(EIO);
if ((zio_flags & ZIO_FLAG_SPECULATIVE) == 0) {
spa_log_error(spa, zb);
- zfs_ereport_post(
+ (void) zfs_ereport_post(
FM_EREPORT_ZFS_AUTHENTICATION,
spa, NULL, zb, NULL, 0, 0);
}
diff --git a/usr/src/uts/common/fs/zfs/spa.c b/usr/src/uts/common/fs/zfs/spa.c
index fc08eebbc0..a040fbfea5 100644
--- a/usr/src/uts/common/fs/zfs/spa.c
+++ b/usr/src/uts/common/fs/zfs/spa.c
@@ -2408,7 +2408,8 @@ spa_load(spa_t *spa, spa_load_state_t state, spa_import_type_t type)
spa->spa_loaded_ts.tv_nsec = 0;
}
if (error != EBADF) {
- zfs_ereport_post(ereport, spa, NULL, NULL, NULL, 0, 0);
+ (void) zfs_ereport_post(ereport, spa,
+ NULL, NULL, NULL, 0, 0);
}
}
spa->spa_load_state = error ? SPA_LOAD_ERROR : SPA_LOAD_NONE;
diff --git a/usr/src/uts/common/fs/zfs/spa_config.c b/usr/src/uts/common/fs/zfs/spa_config.c
index 4719696ca4..ae814208fd 100644
--- a/usr/src/uts/common/fs/zfs/spa_config.c
+++ b/usr/src/uts/common/fs/zfs/spa_config.c
@@ -280,7 +280,8 @@ spa_write_cachefile(spa_t *target, boolean_t removing, boolean_t postsysevent)
* resource issues are resolved.
*/
if (target->spa_ccw_fail_time == 0) {
- zfs_ereport_post(FM_EREPORT_ZFS_CONFIG_CACHE_WRITE,
+ (void) zfs_ereport_post(
+ FM_EREPORT_ZFS_CONFIG_CACHE_WRITE,
target, NULL, NULL, NULL, 0, 0);
}
target->spa_ccw_fail_time = gethrtime();
diff --git a/usr/src/uts/common/fs/zfs/vdev.c b/usr/src/uts/common/fs/zfs/vdev.c
index e82b309537..254af68099 100644
--- a/usr/src/uts/common/fs/zfs/vdev.c
+++ b/usr/src/uts/common/fs/zfs/vdev.c
@@ -1365,7 +1365,7 @@ vdev_probe_done(zio_t *zio)
} else {
ASSERT(zio->io_error != 0);
vdev_dbgmsg(vd, "failed probe");
- zfs_ereport_post(FM_EREPORT_ZFS_PROBE_FAILURE,
+ (void) zfs_ereport_post(FM_EREPORT_ZFS_PROBE_FAILURE,
spa, vd, NULL, NULL, 0, 0);
zio->io_error = SET_ERROR(ENXIO);
}
@@ -1717,7 +1717,8 @@ vdev_open(vdev_t *vd)
*/
if (ashift > vd->vdev_top->vdev_ashift &&
vd->vdev_ops->vdev_op_leaf) {
- zfs_ereport_post(FM_EREPORT_ZFS_DEVICE_BAD_ASHIFT,
+ (void) zfs_ereport_post(
+ FM_EREPORT_ZFS_DEVICE_BAD_ASHIFT,
spa, vd, NULL, NULL, 0, 0);
}
@@ -4408,7 +4409,7 @@ vdev_set_state(vdev_t *vd, boolean_t isopen, vdev_state_t state, vdev_aux_t aux)
class = FM_EREPORT_ZFS_DEVICE_UNKNOWN;
}
- zfs_ereport_post(class, spa, vd, NULL, NULL,
+ (void) zfs_ereport_post(class, spa, vd, NULL, NULL,
save_state, 0);
}
diff --git a/usr/src/uts/common/fs/zfs/vdev_indirect.c b/usr/src/uts/common/fs/zfs/vdev_indirect.c
index effea61bc6..6c636dd4d2 100644
--- a/usr/src/uts/common/fs/zfs/vdev_indirect.c
+++ b/usr/src/uts/common/fs/zfs/vdev_indirect.c
@@ -1382,8 +1382,8 @@ vdev_indirect_checksum_error(zio_t *zio,
void *bad_buf = abd_borrow_buf_copy(ic->ic_data, is->is_size);
abd_t *good_abd = is->is_good_child->ic_data;
void *good_buf = abd_borrow_buf_copy(good_abd, is->is_size);
- zfs_ereport_post_checksum(zio->io_spa, vd, &zio->io_bookmark, zio,
- is->is_target_offset, is->is_size, good_buf, bad_buf, &zbc);
+ (void) zfs_ereport_post_checksum(zio->io_spa, vd, &zio->io_bookmark,
+ zio, is->is_target_offset, is->is_size, good_buf, bad_buf, &zbc);
abd_return_buf(ic->ic_data, bad_buf, is->is_size);
abd_return_buf(good_abd, good_buf, is->is_size);
}
@@ -1459,7 +1459,7 @@ vdev_indirect_all_checksum_errors(zio_t *zio)
vd->vdev_stat.vs_checksum_errors++;
mutex_exit(&vd->vdev_stat_lock);
- zfs_ereport_post_checksum(zio->io_spa, vd,
+ (void) zfs_ereport_post_checksum(zio->io_spa, vd,
&zio->io_bookmark, zio, is->is_target_offset,
is->is_size, NULL, NULL, NULL);
}
diff --git a/usr/src/uts/common/fs/zfs/vdev_raidz.c b/usr/src/uts/common/fs/zfs/vdev_raidz.c
index e4db03ce89..381c2ff84f 100644
--- a/usr/src/uts/common/fs/zfs/vdev_raidz.c
+++ b/usr/src/uts/common/fs/zfs/vdev_raidz.c
@@ -1968,7 +1968,7 @@ raidz_checksum_error(zio_t *zio, raidz_col_t *rc, abd_t *bad_data)
zbc.zbc_has_cksum = 0;
zbc.zbc_injected = rm->rm_ecksuminjected;
- zfs_ereport_post_checksum(zio->io_spa, vd,
+ (void) zfs_ereport_post_checksum(zio->io_spa, vd,
&zio->io_bookmark, zio, rc->rc_offset, rc->rc_size,
rc->rc_abd, bad_data, &zbc);
}
diff --git a/usr/src/uts/common/fs/zfs/zfs_fm.c b/usr/src/uts/common/fs/zfs/zfs_fm.c
index dd854c12e1..2118fd549e 100644
--- a/usr/src/uts/common/fs/zfs/zfs_fm.c
+++ b/usr/src/uts/common/fs/zfs/zfs_fm.c
@@ -735,7 +735,7 @@ zfs_ereport_start_checksum(spa_t *spa, vdev_t *vd, const zbookmark_phys_t *zb,
report->zcr_length = length;
#ifdef _KERNEL
- zfs_ereport_start(&report->zcr_ereport, &report->zcr_detector,
+ (void) zfs_ereport_start(&report->zcr_ereport, &report->zcr_detector,
FM_EREPORT_ZFS_CHECKSUM, spa, vd, zb, zio, offset, length);
if (report->zcr_ereport == NULL) {
diff --git a/usr/src/uts/common/fs/zfs/zfs_vnops.c b/usr/src/uts/common/fs/zfs/zfs_vnops.c
index 99011b83b4..c016b5c1ea 100644
--- a/usr/src/uts/common/fs/zfs/zfs_vnops.c
+++ b/usr/src/uts/common/fs/zfs/zfs_vnops.c
@@ -4839,7 +4839,7 @@ zfs_seek(vnode_t *vp, offset_t ooff, offset_t *noffp,
{
if (vp->v_type == VDIR)
return (0);
- return ((*noffp < 0 || *noffp > MAXOFFSET_T) ? EINVAL : 0);
+ return ((*noffp < 0) ? EINVAL : 0);
}
/*
diff --git a/usr/src/uts/common/fs/zfs/zio.c b/usr/src/uts/common/fs/zfs/zio.c
index 5215a58bf2..9981263343 100644
--- a/usr/src/uts/common/fs/zfs/zio.c
+++ b/usr/src/uts/common/fs/zfs/zio.c
@@ -483,7 +483,7 @@ error:
zio->io_error = SET_ERROR(EIO);
if ((zio->io_flags & ZIO_FLAG_SPECULATIVE) == 0) {
spa_log_error(spa, &zio->io_bookmark);
- zfs_ereport_post(FM_EREPORT_ZFS_AUTHENTICATION,
+ (void) zfs_ereport_post(FM_EREPORT_ZFS_AUTHENTICATION,
spa, NULL, &zio->io_bookmark, zio, 0, 0);
}
} else {
@@ -1995,7 +1995,7 @@ zio_suspend(spa_t *spa, zio_t *zio, zio_suspend_reason_t reason)
"failure and has been suspended; `zpool clear` will be required "
"before the pool can be written to.", spa_name(spa));
- zfs_ereport_post(FM_EREPORT_ZFS_IO_FAILURE, spa, NULL,
+ (void) zfs_ereport_post(FM_EREPORT_ZFS_IO_FAILURE, spa, NULL,
NULL, NULL, 0, 0);
mutex_enter(&spa->spa_suspend_lock);
@@ -4265,7 +4265,7 @@ zio_done(zio_t *zio)
zio->io_vd->vdev_stat.vs_slow_ios++;
mutex_exit(&zio->io_vd->vdev_stat_lock);
- zfs_ereport_post(FM_EREPORT_ZFS_DELAY,
+ (void) zfs_ereport_post(FM_EREPORT_ZFS_DELAY,
zio->io_spa, zio->io_vd, &zio->io_bookmark,
zio, 0, 0);
}
@@ -4280,7 +4280,7 @@ zio_done(zio_t *zio)
* device is currently unavailable.
*/
if (zio->io_error != ECKSUM && vd != NULL && !vdev_is_dead(vd))
- zfs_ereport_post(FM_EREPORT_ZFS_IO, spa, vd,
+ (void) zfs_ereport_post(FM_EREPORT_ZFS_IO, spa, vd,
&zio->io_bookmark, zio, 0, 0);
if ((zio->io_error == EIO || !(zio->io_flags &
@@ -4291,7 +4291,7 @@ zio_done(zio_t *zio)
* error and generate a logical data ereport.
*/
spa_log_error(spa, &zio->io_bookmark);
- zfs_ereport_post(FM_EREPORT_ZFS_DATA, spa, NULL,
+ (void) zfs_ereport_post(FM_EREPORT_ZFS_DATA, spa, NULL,
&zio->io_bookmark, zio, 0, 0);
}
}
diff --git a/usr/src/uts/common/fs/zfs/zvol.c b/usr/src/uts/common/fs/zfs/zvol.c
index 2e684a5ff0..19130289e7 100644
--- a/usr/src/uts/common/fs/zfs/zvol.c
+++ b/usr/src/uts/common/fs/zfs/zvol.c
@@ -1232,7 +1232,7 @@ zvol_strategy(buf_t *bp)
addr = bp->b_un.b_addr;
resid = bp->b_bcount;
- if (resid > 0 && (off < 0 || off >= volsize)) {
+ if (resid > 0 && off >= volsize) {
bioerror(bp, EIO);
biodone(bp);
return (0);
diff --git a/usr/src/uts/i86pc/io/vmm/io/vlapic.c b/usr/src/uts/i86pc/io/vmm/io/vlapic.c
index c1825f4264..1288f69321 100644
--- a/usr/src/uts/i86pc/io/vmm/io/vlapic.c
+++ b/usr/src/uts/i86pc/io/vmm/io/vlapic.c
@@ -96,6 +96,12 @@ __FBSDID("$FreeBSD$");
static void vlapic_set_error(struct vlapic *, uint32_t, bool);
static void vlapic_tmr_reset(struct vlapic *);
+#ifdef __ISRVEC_DEBUG
+static void vlapic_isrstk_accept(struct vlapic *, int);
+static void vlapic_isrstk_eoi(struct vlapic *, int);
+static void vlapic_isrstk_verify(const struct vlapic *);
+#endif /* __ISRVEC_DEBUG */
+
static __inline uint32_t
vlapic_get_id(struct vlapic *vlapic)
{
@@ -495,21 +501,33 @@ vlapic_fire_lvt(struct vlapic *vlapic, u_int lvt)
return (1);
}
-#if 1
-static void
-dump_isrvec_stk(struct vlapic *vlapic)
+static uint_t
+vlapic_active_isr(struct vlapic *vlapic)
{
int i;
- uint32_t *isrptr;
+ uint32_t *isrp;
- isrptr = &vlapic->apic_page->isr0;
- for (i = 0; i < 8; i++)
- printf("ISR%d 0x%08x\n", i, isrptr[i * 4]);
+ isrp = &vlapic->apic_page->isr7;
- for (i = 0; i <= vlapic->isrvec_stk_top; i++)
- printf("isrvec_stk[%d] = %d\n", i, vlapic->isrvec_stk[i]);
+ for (i = 7; i >= 0; i--, isrp -= 4) {
+ uint32_t reg = *isrp;
+
+ if (reg != 0) {
+ uint_t vec = (i * 32) + bsrl(reg);
+
+ if (vec < 16) {
+ /*
+ * Truncate the illegal low vectors to value of
+ * 0, indicating that no active ISR was found.
+ */
+ return (0);
+ }
+ return (vec);
+ }
+ }
+
+ return (0);
}
-#endif
/*
* Algorithm adopted from section "Interrupt, Task and Processor Priority"
@@ -520,55 +538,11 @@ vlapic_update_ppr(struct vlapic *vlapic)
{
int isrvec, tpr, ppr;
- /*
- * Note that the value on the stack at index 0 is always 0.
- *
- * This is a placeholder for the value of ISRV when none of the
- * bits is set in the ISRx registers.
- */
- isrvec = vlapic->isrvec_stk[vlapic->isrvec_stk_top];
+ isrvec = vlapic_active_isr(vlapic);
tpr = vlapic->apic_page->tpr;
-#if 1
- {
- int i, lastprio, curprio, vector, idx;
- uint32_t *isrptr;
-
- if (vlapic->isrvec_stk_top == 0 && isrvec != 0)
- panic("isrvec_stk is corrupted: %d", isrvec);
-
- /*
- * Make sure that the priority of the nested interrupts is
- * always increasing.
- */
- lastprio = -1;
- for (i = 1; i <= vlapic->isrvec_stk_top; i++) {
- curprio = PRIO(vlapic->isrvec_stk[i]);
- if (curprio <= lastprio) {
- dump_isrvec_stk(vlapic);
- panic("isrvec_stk does not satisfy invariant");
- }
- lastprio = curprio;
- }
-
- /*
- * Make sure that each bit set in the ISRx registers has a
- * corresponding entry on the isrvec stack.
- */
- i = 1;
- isrptr = &vlapic->apic_page->isr0;
- for (vector = 0; vector < 256; vector++) {
- idx = (vector / 32) * 4;
- if (isrptr[idx] & (1 << (vector % 32))) {
- if (i > vlapic->isrvec_stk_top ||
- vlapic->isrvec_stk[i] != vector) {
- dump_isrvec_stk(vlapic);
- panic("ISR and isrvec_stk out of sync");
- }
- i++;
- }
- }
- }
+#ifdef __ISRVEC_DEBUG
+ vlapic_isrstk_verify(vlapic);
#endif
if (PRIO(tpr) >= PRIO(isrvec))
@@ -593,25 +567,25 @@ vlapic_process_eoi(struct vlapic *vlapic)
{
struct LAPIC *lapic = vlapic->apic_page;
uint32_t *isrptr, *tmrptr;
- int i, idx, bitpos, vector;
+ int i;
+ uint_t idx, bitpos, vector;
isrptr = &lapic->isr0;
tmrptr = &lapic->tmr0;
for (i = 7; i >= 0; i--) {
idx = i * 4;
- bitpos = fls(isrptr[idx]);
- if (bitpos-- != 0) {
- if (vlapic->isrvec_stk_top <= 0) {
- panic("invalid vlapic isrvec_stk_top %d",
- vlapic->isrvec_stk_top);
- }
- isrptr[idx] &= ~(1 << bitpos);
+ if (isrptr[idx] != 0) {
+ bitpos = bsrl(isrptr[idx]);
vector = i * 32 + bitpos;
+
+ isrptr[idx] &= ~(1 << bitpos);
VCPU_CTR1(vlapic->vm, vlapic->vcpuid, "EOI vector %d",
vector);
VLAPIC_CTR_ISR(vlapic, "vlapic_process_eoi");
- vlapic->isrvec_stk_top--;
+#ifdef __ISRVEC_DEBUG
+ vlapic_isrstk_eoi(vlapic, vector);
+#endif
vlapic_update_ppr(vlapic);
if ((tmrptr[idx] & (1 << bitpos)) != 0) {
vioapic_process_eoi(vlapic->vm, vlapic->vcpuid,
@@ -1143,7 +1117,7 @@ vlapic_intr_accepted(struct vlapic *vlapic, int vector)
{
struct LAPIC *lapic = vlapic->apic_page;
uint32_t *irrptr, *isrptr;
- int idx, stk_top;
+ int idx;
if (vlapic->ops.intr_accepted)
return ((*vlapic->ops.intr_accepted)(vlapic, vector));
@@ -1162,16 +1136,9 @@ vlapic_intr_accepted(struct vlapic *vlapic, int vector)
isrptr[idx] |= 1 << (vector % 32);
VLAPIC_CTR_ISR(vlapic, "vlapic_intr_accepted");
- /*
- * Update the PPR
- */
- vlapic->isrvec_stk_top++;
-
- stk_top = vlapic->isrvec_stk_top;
- if (stk_top >= ISRVEC_STK_SIZE)
- panic("isrvec_stk_top overflow %d", stk_top);
-
- vlapic->isrvec_stk[stk_top] = vector;
+#ifdef __ISRVEC_DEBUG
+ vlapic_isrstk_accept(vlapic, vector);
+#endif
}
void
@@ -1708,3 +1675,92 @@ vlapic_localize_resources(struct vlapic *vlapic)
vmm_glue_callout_localize(&vlapic->callout);
}
#endif /* __FreeBSD */
+
+#ifdef __ISRVEC_DEBUG
+static void
+vlapic_isrstk_eoi(struct vlapic *vlapic, int vector)
+{
+ if (vlapic->isrvec_stk_top <= 0) {
+ panic("invalid vlapic isrvec_stk_top %d",
+ vlapic->isrvec_stk_top);
+ }
+ vlapic->isrvec_stk_top--;
+}
+
+static void
+vlapic_isrstk_accept(struct vlapic *vlapic, int vector)
+{
+ int stk_top;
+
+ vlapic->isrvec_stk_top++;
+
+ stk_top = vlapic->isrvec_stk_top;
+ if (stk_top >= ISRVEC_STK_SIZE)
+ panic("isrvec_stk_top overflow %d", stk_top);
+
+ vlapic->isrvec_stk[stk_top] = vector;
+}
+
+static void
+vlapic_isrstk_dump(const struct vlapic *vlapic)
+{
+ int i;
+ uint32_t *isrptr;
+
+ isrptr = &vlapic->apic_page->isr0;
+ for (i = 0; i < 8; i++)
+ printf("ISR%d 0x%08x\n", i, isrptr[i * 4]);
+
+ for (i = 0; i <= vlapic->isrvec_stk_top; i++)
+ printf("isrvec_stk[%d] = %d\n", i, vlapic->isrvec_stk[i]);
+}
+
+static void
+vlapic_isrstk_verify(const struct vlapic *vlapic)
+{
+ int i, lastprio, curprio, vector, idx;
+ uint32_t *isrptr;
+
+ /*
+ * Note: The value at index 0 in isrvec_stk is always 0.
+ *
+ * It is a placeholder for the value of ISR vector when no bits are set
+ * in the ISRx registers.
+ */
+ if (vlapic->isrvec_stk_top == 0 && vlapic->isrvec_stk[0] != 0) {
+ panic("isrvec_stk is corrupted: %d", vlapic->isrvec_stk[0]);
+ }
+
+ /*
+ * Make sure that the priority of the nested interrupts is
+ * always increasing.
+ */
+ lastprio = -1;
+ for (i = 1; i <= vlapic->isrvec_stk_top; i++) {
+ curprio = PRIO(vlapic->isrvec_stk[i]);
+ if (curprio <= lastprio) {
+ vlapic_isrstk_dump(vlapic);
+ panic("isrvec_stk does not satisfy invariant");
+ }
+ lastprio = curprio;
+ }
+
+ /*
+ * Make sure that each bit set in the ISRx registers has a
+ * corresponding entry on the isrvec stack.
+ */
+ i = 1;
+ isrptr = &vlapic->apic_page->isr0;
+ for (vector = 0; vector < 256; vector++) {
+ idx = (vector / 32) * 4;
+ if (isrptr[idx] & (1 << (vector % 32))) {
+ if (i > vlapic->isrvec_stk_top ||
+ vlapic->isrvec_stk[i] != vector) {
+ vlapic_isrstk_dump(vlapic);
+ panic("ISR and isrvec_stk out of sync");
+ }
+ i++;
+ }
+ }
+}
+#endif
diff --git a/usr/src/uts/i86pc/io/vmm/io/vlapic_priv.h b/usr/src/uts/i86pc/io/vmm/io/vlapic_priv.h
index 5795d48d52..8a0d594de3 100644
--- a/usr/src/uts/i86pc/io/vmm/io/vlapic_priv.h
+++ b/usr/src/uts/i86pc/io/vmm/io/vlapic_priv.h
@@ -27,6 +27,18 @@
*
* $FreeBSD$
*/
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ *
+ * Copyright 2020 Oxide Computer Company
+ */
#ifndef _VLAPIC_PRIV_H_
#define _VLAPIC_PRIV_H_
@@ -140,6 +152,10 @@ enum boot_state {
#define VLAPIC_TMR_CNT 8
+#ifdef DEBUG
+#define __ISRVEC_DEBUG
+#endif
+
struct vlapic;
struct vlapic_ops {
@@ -166,15 +182,6 @@ struct vlapic {
struct bintime timer_period_bt; /* timer period */
struct mtx timer_mtx;
- /*
- * The 'isrvec_stk' is a stack of vectors injected by the local apic.
- * A vector is popped from the stack when the processor does an EOI.
- * The vector on the top of the stack is used to compute the
- * Processor Priority in conjunction with the TPR.
- */
- uint8_t isrvec_stk[ISRVEC_STK_SIZE];
- int isrvec_stk_top;
-
uint64_t msr_apicbase;
enum boot_state boot_state;
@@ -199,6 +206,19 @@ struct vlapic {
*/
uint32_t tmr_vec_deassert[VLAPIC_TMR_CNT];
uint32_t tmr_vec_assert[VLAPIC_TMR_CNT];
+
+#ifdef __ISRVEC_DEBUG
+ /*
+ * The 'isrvec_stk' is a stack of vectors injected by the local APIC.
+ * It is used as a debugging method to double-check the behavior of the
+ * emulation. Vectors are pushed to the stack when they are accepted
+ * for injection and popped from the stack when the processor performs
+ * an EOI. The vector on the top of the stack is used to verify the
+ * computed Processor Priority.
+ */
+ uint8_t isrvec_stk[ISRVEC_STK_SIZE];
+ int isrvec_stk_top;
+#endif
};
void vlapic_init(struct vlapic *vlapic);
diff --git a/usr/src/uts/sun4v/ontario/io/tsalarm.c b/usr/src/uts/sun4v/ontario/io/tsalarm.c
index 7fb9577028..6f80db8e88 100644
--- a/usr/src/uts/sun4v/ontario/io/tsalarm.c
+++ b/usr/src/uts/sun4v/ontario/io/tsalarm.c
@@ -544,7 +544,7 @@ FAIL:
if (rv != 0) {
if (softc->flags & TSAL_OPENED)
(void) ldi_close(softc->lh, FREAD|FWRITE, credp);
- if (softc->flags * TSAL_IDENTED)
+ if (softc->flags & TSAL_IDENTED)
(void) ldi_ident_release(softc->li);
softc->flags &= ~(TSAL_OPENED | TSAL_IDENTED);
if (softc->req_ptr != NULL)