Author: tsoome
Date: Sun Oct 27 08:35:29 2019
New Revision: 354127
URL: https://svnweb.freebsd.org/changeset/base/354127

Log:
  loader: zio_checksum_verify should check byteswap
  
  We do have both native and byteswap checksum callbacks in place but the
  selection is not wired.
  
  MFC after:    1 week

Modified:
  head/sys/cddl/boot/zfs/zfsimpl.h
  head/sys/cddl/boot/zfs/zfssubr.c

Modified: head/sys/cddl/boot/zfs/zfsimpl.h
==============================================================================
--- head/sys/cddl/boot/zfs/zfsimpl.h    Sun Oct 27 05:32:08 2019        
(r354126)
+++ head/sys/cddl/boot/zfs/zfsimpl.h    Sun Oct 27 08:35:29 2019        
(r354127)
@@ -442,6 +442,13 @@ _NOTE(CONSTCOND) } while (0)
        ZIO_SET_CHECKSUM(&(bp)->blk_cksum, 0, 0, 0, 0); \
 }
 
+#if BYTE_ORDER == _BIG_ENDIAN
+#define        ZFS_HOST_BYTEORDER      (0ULL)
+#else
+#define        ZFS_HOST_BYTEORDER      (1ULL)
+#endif
+
+#define        BP_SHOULD_BYTESWAP(bp)  (BP_GET_BYTEORDER(bp) != 
ZFS_HOST_BYTEORDER)
 #define        BPE_NUM_WORDS 14
 #define        BPE_PAYLOAD_SIZE (BPE_NUM_WORDS * sizeof (uint64_t))
 #define        BPE_IS_PAYLOADWORD(bp, wp) \

Modified: head/sys/cddl/boot/zfs/zfssubr.c
==============================================================================
--- head/sys/cddl/boot/zfs/zfssubr.c    Sun Oct 27 05:32:08 2019        
(r354126)
+++ head/sys/cddl/boot/zfs/zfssubr.c    Sun Oct 27 08:35:29 2019        
(r354127)
@@ -318,8 +318,9 @@ zio_checksum_verify(const spa_t *spa, const blkptr_t *
                        byteswap_uint64_array(&expected_cksum,
                            sizeof (zio_cksum_t));
        } else {
+               byteswap = BP_SHOULD_BYTESWAP(bp);
                expected_cksum = bp->blk_cksum;
-               ci->ci_func[0](data, size, ctx, &actual_cksum);
+               ci->ci_func[byteswap](data, size, ctx, &actual_cksum);
        }
 
        if (!ZIO_CHECKSUM_EQUAL(actual_cksum, expected_cksum)) {
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to