Re: [PATCH v6 10/12] crypto: x86/aes - Prepare for a new AES implementation

From: Eric Biggers
Date: Thu May 11 2023 - 17:40:01 EST


On Thu, May 11, 2023 at 12:05:17PM -0700, Chang S. Bae wrote:
> +
> +struct aes_xts_ctx {
> + struct crypto_aes_ctx tweak_ctx AES_ALIGN_ATTR;
> + struct crypto_aes_ctx crypt_ctx AES_ALIGN_ATTR;
> +};
> +
> +static inline struct crypto_aes_ctx *aes_ctx(void *raw_ctx)
> +{
> + unsigned long addr = (unsigned long)raw_ctx;
> + unsigned long align = AES_ALIGN;
> +
> + if (align <= crypto_tfm_ctx_alignment())
> + align = 1;
> +
> + return (struct crypto_aes_ctx *)ALIGN(addr, align);
> +}

It seems you took my suggestion to fix the definition of struct aes_xts_ctx, but
you didn't make the corresponding change to the runtime alignment code. There
should be a helper function aes_xts_ctx() that is used like:

struct aes_xts_ctx *ctx = aes_xts_ctx(tfm);

It would do the runtime alignment. Then, aes_ctx() should be removed.

- Eric