Fix alignment issues on MIPS: align the pointers properly.
All the 5520 GEOM_ELI tests passed successfully on MIPS64EB. Sponsored by: DARPA, AFRL Sponsored by: HEIF5 Differential Revision: https://reviews.freebsd.org/D7905
This commit is contained in:
parent
2668ec0761
commit
ae8b1f90fe
@ -666,7 +666,7 @@ static void
|
||||
eli_init(struct gctl_req *req)
|
||||
{
|
||||
struct g_eli_metadata md;
|
||||
unsigned char sector[sizeof(struct g_eli_metadata)];
|
||||
unsigned char sector[sizeof(struct g_eli_metadata)] __aligned(4);
|
||||
unsigned char key[G_ELI_USERKEYLEN];
|
||||
char backfile[MAXPATHLEN];
|
||||
const char *str, *prov;
|
||||
|
@ -289,6 +289,7 @@ eli_metadata_encode_v1v2v3v4v5v6v7(struct g_eli_metadata *md, u_char **datap)
|
||||
static __inline void
|
||||
eli_metadata_encode(struct g_eli_metadata *md, u_char *data)
|
||||
{
|
||||
uint32_t hash[4];
|
||||
MD5_CTX ctx;
|
||||
u_char *p;
|
||||
|
||||
@ -320,12 +321,14 @@ eli_metadata_encode(struct g_eli_metadata *md, u_char *data)
|
||||
}
|
||||
MD5Init(&ctx);
|
||||
MD5Update(&ctx, data, p - data);
|
||||
MD5Final(md->md_hash, &ctx);
|
||||
MD5Final((void *)hash, &ctx);
|
||||
bcopy(hash, md->md_hash, sizeof(md->md_hash));
|
||||
bcopy(md->md_hash, p, sizeof(md->md_hash));
|
||||
}
|
||||
static __inline int
|
||||
eli_metadata_decode_v0(const u_char *data, struct g_eli_metadata *md)
|
||||
{
|
||||
uint32_t hash[4];
|
||||
MD5_CTX ctx;
|
||||
const u_char *p;
|
||||
|
||||
@ -341,7 +344,8 @@ eli_metadata_decode_v0(const u_char *data, struct g_eli_metadata *md)
|
||||
bcopy(p, md->md_mkeys, sizeof(md->md_mkeys)); p += sizeof(md->md_mkeys);
|
||||
MD5Init(&ctx);
|
||||
MD5Update(&ctx, data, p - data);
|
||||
MD5Final(md->md_hash, &ctx);
|
||||
MD5Final((void *)hash, &ctx);
|
||||
bcopy(hash, md->md_hash, sizeof(md->md_hash));
|
||||
if (bcmp(md->md_hash, p, 16) != 0)
|
||||
return (EINVAL);
|
||||
return (0);
|
||||
@ -350,6 +354,7 @@ eli_metadata_decode_v0(const u_char *data, struct g_eli_metadata *md)
|
||||
static __inline int
|
||||
eli_metadata_decode_v1v2v3v4v5v6v7(const u_char *data, struct g_eli_metadata *md)
|
||||
{
|
||||
uint32_t hash[4];
|
||||
MD5_CTX ctx;
|
||||
const u_char *p;
|
||||
|
||||
@ -366,7 +371,8 @@ eli_metadata_decode_v1v2v3v4v5v6v7(const u_char *data, struct g_eli_metadata *md
|
||||
bcopy(p, md->md_mkeys, sizeof(md->md_mkeys)); p += sizeof(md->md_mkeys);
|
||||
MD5Init(&ctx);
|
||||
MD5Update(&ctx, data, p - data);
|
||||
MD5Final(md->md_hash, &ctx);
|
||||
MD5Final((void *)hash, &ctx);
|
||||
bcopy(hash, md->md_hash, sizeof(md->md_hash));
|
||||
if (bcmp(md->md_hash, p, 16) != 0)
|
||||
return (EINVAL);
|
||||
return (0);
|
||||
|
@ -444,6 +444,7 @@ g_eli_auth_run(struct g_eli_worker *wr, struct bio *bp)
|
||||
size += sizeof(*crde) * nsec;
|
||||
size += sizeof(*crda) * nsec;
|
||||
size += G_ELI_AUTH_SECKEYLEN * nsec;
|
||||
size += sizeof(uintptr_t); /* Space for alignment. */
|
||||
data = malloc(size, M_ELI, M_WAITOK);
|
||||
bp->bio_driver2 = data;
|
||||
p = data + encr_secsize * nsec;
|
||||
@ -451,6 +452,10 @@ g_eli_auth_run(struct g_eli_worker *wr, struct bio *bp)
|
||||
bp->bio_inbed = 0;
|
||||
bp->bio_children = nsec;
|
||||
|
||||
#if defined(__mips_n64) || defined(__mips_o64)
|
||||
p = (char *)roundup((uintptr_t)p, sizeof(uintptr_t));
|
||||
#endif
|
||||
|
||||
for (i = 1; i <= nsec; i++, dstoff += encr_secsize) {
|
||||
crp = (struct cryptop *)p; p += sizeof(*crp);
|
||||
crde = (struct cryptodesc *)p; p += sizeof(*crde);
|
||||
|
@ -6,6 +6,7 @@ SYSDIR?=${.CURDIR}/../..
|
||||
SUBDIR= geom_bde \
|
||||
geom_cache \
|
||||
geom_concat \
|
||||
geom_eli \
|
||||
geom_gate \
|
||||
geom_journal \
|
||||
geom_label \
|
||||
@ -29,9 +30,4 @@ SUBDIR= geom_bde \
|
||||
SUBDIR+= geom_ccd
|
||||
.endif
|
||||
|
||||
# Alignment issues in g_eli_auth_run() on MIPS64 causes kernel panic
|
||||
.if ${MACHINE_ARCH} != "mips64" && ${MACHINE_ARCH} != "mips64el"
|
||||
SUBDIR+= geom_eli
|
||||
.endif
|
||||
|
||||
.include <bsd.subdir.mk>
|
||||
|
Loading…
Reference in New Issue
Block a user