mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 18:40:43 +03:00
Drop lying to the compiler in the fletcher4 code
This is probably the uncontroversial part of #13631, which fixes a real problem people are having. There's still things to improve in our code after this is merged, but it should stop the breakage that people have reported, where we lie about a type always being aligned and then pass in stack objects with no alignment requirement and hope for the best. Of course, our SIMD code was written with unaligned accesses, so it doesn't care if we drop this...but some auto-vectorized code that gcc emits sure does, since we told it it can assume they're aligned. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de> Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu> Signed-off-by: Rich Ercolani <rincebrain@gmail.com> Closes #14649
This commit is contained in:
@@ -301,21 +301,18 @@ fletcher_2_byteswap(const void *buf, uint64_t size,
|
||||
(void) fletcher_2_incremental_byteswap((void *) buf, size, zcp);
|
||||
}
|
||||
|
||||
ZFS_NO_SANITIZE_UNDEFINED
|
||||
static void
|
||||
fletcher_4_scalar_init(fletcher_4_ctx_t *ctx)
|
||||
{
|
||||
ZIO_SET_CHECKSUM(&ctx->scalar, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
ZFS_NO_SANITIZE_UNDEFINED
|
||||
static void
|
||||
fletcher_4_scalar_fini(fletcher_4_ctx_t *ctx, zio_cksum_t *zcp)
|
||||
{
|
||||
memcpy(zcp, &ctx->scalar, sizeof (zio_cksum_t));
|
||||
}
|
||||
|
||||
ZFS_NO_SANITIZE_UNDEFINED
|
||||
static void
|
||||
fletcher_4_scalar_native(fletcher_4_ctx_t *ctx, const void *buf,
|
||||
uint64_t size)
|
||||
@@ -339,7 +336,6 @@ fletcher_4_scalar_native(fletcher_4_ctx_t *ctx, const void *buf,
|
||||
ZIO_SET_CHECKSUM(&ctx->scalar, a, b, c, d);
|
||||
}
|
||||
|
||||
ZFS_NO_SANITIZE_UNDEFINED
|
||||
static void
|
||||
fletcher_4_scalar_byteswap(fletcher_4_ctx_t *ctx, const void *buf,
|
||||
uint64_t size)
|
||||
|
||||
@@ -48,14 +48,12 @@
|
||||
#include <sys/string.h>
|
||||
#include <zfs_fletcher.h>
|
||||
|
||||
ZFS_NO_SANITIZE_UNDEFINED
|
||||
static void
|
||||
fletcher_4_aarch64_neon_init(fletcher_4_ctx_t *ctx)
|
||||
{
|
||||
memset(ctx->aarch64_neon, 0, 4 * sizeof (zfs_fletcher_aarch64_neon_t));
|
||||
}
|
||||
|
||||
ZFS_NO_SANITIZE_UNDEFINED
|
||||
static void
|
||||
fletcher_4_aarch64_neon_fini(fletcher_4_ctx_t *ctx, zio_cksum_t *zcp)
|
||||
{
|
||||
|
||||
@@ -35,14 +35,12 @@
|
||||
#define __asm __asm__ __volatile__
|
||||
#endif
|
||||
|
||||
ZFS_NO_SANITIZE_UNDEFINED
|
||||
static void
|
||||
fletcher_4_avx512f_init(fletcher_4_ctx_t *ctx)
|
||||
{
|
||||
memset(ctx->avx512, 0, 4 * sizeof (zfs_fletcher_avx512_t));
|
||||
}
|
||||
|
||||
ZFS_NO_SANITIZE_UNDEFINED
|
||||
static void
|
||||
fletcher_4_avx512f_fini(fletcher_4_ctx_t *ctx, zio_cksum_t *zcp)
|
||||
{
|
||||
|
||||
@@ -47,14 +47,12 @@
|
||||
#include <sys/simd.h>
|
||||
#include <zfs_fletcher.h>
|
||||
|
||||
ZFS_NO_SANITIZE_UNDEFINED
|
||||
static void
|
||||
fletcher_4_avx2_init(fletcher_4_ctx_t *ctx)
|
||||
{
|
||||
memset(ctx->avx, 0, 4 * sizeof (zfs_fletcher_avx_t));
|
||||
}
|
||||
|
||||
ZFS_NO_SANITIZE_UNDEFINED
|
||||
static void
|
||||
fletcher_4_avx2_fini(fletcher_4_ctx_t *ctx, zio_cksum_t *zcp)
|
||||
{
|
||||
|
||||
@@ -49,14 +49,12 @@
|
||||
#include <sys/byteorder.h>
|
||||
#include <zfs_fletcher.h>
|
||||
|
||||
ZFS_NO_SANITIZE_UNDEFINED
|
||||
static void
|
||||
fletcher_4_sse2_init(fletcher_4_ctx_t *ctx)
|
||||
{
|
||||
memset(ctx->sse, 0, 4 * sizeof (zfs_fletcher_sse_t));
|
||||
}
|
||||
|
||||
ZFS_NO_SANITIZE_UNDEFINED
|
||||
static void
|
||||
fletcher_4_sse2_fini(fletcher_4_ctx_t *ctx, zio_cksum_t *zcp)
|
||||
{
|
||||
|
||||
@@ -47,14 +47,12 @@
|
||||
#include <sys/string.h>
|
||||
#include <zfs_fletcher.h>
|
||||
|
||||
ZFS_NO_SANITIZE_UNDEFINED
|
||||
static void
|
||||
fletcher_4_superscalar_init(fletcher_4_ctx_t *ctx)
|
||||
{
|
||||
memset(ctx->superscalar, 0, 4 * sizeof (zfs_fletcher_superscalar_t));
|
||||
}
|
||||
|
||||
ZFS_NO_SANITIZE_UNDEFINED
|
||||
static void
|
||||
fletcher_4_superscalar_fini(fletcher_4_ctx_t *ctx, zio_cksum_t *zcp)
|
||||
{
|
||||
@@ -70,7 +68,6 @@ fletcher_4_superscalar_fini(fletcher_4_ctx_t *ctx, zio_cksum_t *zcp)
|
||||
ZIO_SET_CHECKSUM(zcp, A, B, C, D);
|
||||
}
|
||||
|
||||
ZFS_NO_SANITIZE_UNDEFINED
|
||||
static void
|
||||
fletcher_4_superscalar_native(fletcher_4_ctx_t *ctx,
|
||||
const void *buf, uint64_t size)
|
||||
@@ -110,7 +107,6 @@ fletcher_4_superscalar_native(fletcher_4_ctx_t *ctx,
|
||||
ctx->superscalar[3].v[1] = d2;
|
||||
}
|
||||
|
||||
ZFS_NO_SANITIZE_UNDEFINED
|
||||
static void
|
||||
fletcher_4_superscalar_byteswap(fletcher_4_ctx_t *ctx,
|
||||
const void *buf, uint64_t size)
|
||||
|
||||
@@ -47,14 +47,12 @@
|
||||
#include <sys/string.h>
|
||||
#include <zfs_fletcher.h>
|
||||
|
||||
ZFS_NO_SANITIZE_UNDEFINED
|
||||
static void
|
||||
fletcher_4_superscalar4_init(fletcher_4_ctx_t *ctx)
|
||||
{
|
||||
memset(ctx->superscalar, 0, 4 * sizeof (zfs_fletcher_superscalar_t));
|
||||
}
|
||||
|
||||
ZFS_NO_SANITIZE_UNDEFINED
|
||||
static void
|
||||
fletcher_4_superscalar4_fini(fletcher_4_ctx_t *ctx, zio_cksum_t *zcp)
|
||||
{
|
||||
@@ -84,7 +82,6 @@ fletcher_4_superscalar4_fini(fletcher_4_ctx_t *ctx, zio_cksum_t *zcp)
|
||||
ZIO_SET_CHECKSUM(zcp, A, B, C, D);
|
||||
}
|
||||
|
||||
ZFS_NO_SANITIZE_UNDEFINED
|
||||
static void
|
||||
fletcher_4_superscalar4_native(fletcher_4_ctx_t *ctx,
|
||||
const void *buf, uint64_t size)
|
||||
@@ -150,7 +147,6 @@ fletcher_4_superscalar4_native(fletcher_4_ctx_t *ctx,
|
||||
ctx->superscalar[3].v[3] = d4;
|
||||
}
|
||||
|
||||
ZFS_NO_SANITIZE_UNDEFINED
|
||||
static void
|
||||
fletcher_4_superscalar4_byteswap(fletcher_4_ctx_t *ctx,
|
||||
const void *buf, uint64_t size)
|
||||
|
||||
Reference in New Issue
Block a user