On Fri, Jun 02, 2006 at 11:23:41AM -0600, Jordan Crouse ([EMAIL PROTECTED]) 
wrote:
> Greetings - attached is a patch adding a crypto API driver for the hardware
> encryption engine on the AMD Geode LX processor, applied against latest
> GIT from Linus.  This is my first foray into the world of the Crypto API, 
> so comments are more then welcome.

Couple of them inside.

> Regards,
> Jordan
> 
> -- 
> Jordan Crouse
> Senior Linux Engineer
> Advanced Micro Devices, Inc.
> <www.amd.com>

...

> +static inline void AWRITE(unsigned long val, unsigned short reg) {
> +#ifdef DEBUG
> +     printk("[AES] W [%x]=%x\n", reg, val);
> +#endif
> +     iowrite32(val, _iobase + reg);
> +}
> +
> +static inline unsigned int AREAD(unsigned short reg) {
> +     unsigned int val = ioread32(_iobase + reg);
> +#ifdef DEBUG
> +     printk("[AES] R [%x]=%x\n", reg, val);
> +#endif
> +     return val;
> +}

Remove above functions and use ioread/iowrite directly.

> +/* Write a 128 bit field (either a writable key or IV) */
> +static inline void
> +_writefield(u32 offset, void *value)
> +{
> +     int i;
> +     for(i = 0; i < 4; i++)
> +             AWRITE(((u32 *) value)[i], offset + (i * 4));
> +}
> +
> +/* Read a 128 bit field (either a writable key or IV) */
> +static inline void
> +_readfield(u32 offset, void *value)
> +{
> +     int i;
> +     for(i = 0; i < 4; i++)
> +             ((u32 *) value)[i] = AREAD(offset + (i * 4));
> +}
> +
> +static void
> +_crypt(void *src, void *dst, int len, u32 flags)
> +{
> +     u32 status;
> +
> +     AWRITE(__pa(src), AES_SOURCEA_REG);
> +     AWRITE(__pa(dst), AES_DSTA_REG);

Do not use __pa, use virt_to_phys() although it is the same for i386.

> +     AWRITE(len,  AES_LENA_REG);
> +
> +     /* Start the operation */
> +     AWRITE(AES_CTRL_START | flags, AES_CTRLA_REG);
> +
> +     /* According to the silicon developers, the status will only
> +      * fail to clear on an catastrophic failure, so an infinite
> +      * loop is valid here
> +      */
> +
> +     do
> +             status = AREAD(AES_INTR_REG);
> +     while(!(status & AES_INTRA_PENDING));
> +
> +     /* Clear the event */
> +     AWRITE((status & 0xFF) | AES_INTRA_PENDING, AES_INTR_REG);
> +}

And how will system behave if that catastrophic failure happend?
Maybe it would be better to have counter and failure device shutdown in
case of error?

> +unsigned int
> +geode_aes_crypt(struct geode_aes_op *op)
> +{
> +     u32 flags = 0;
> +
> +     if (op->len == 0 || op->src == op->dst)
> +             return 0;
> +
> +     if (mutex_lock_interruptible(&emutex))
> +             return 0;

I.e. it can not be used in atomic context?
That will break a lot of setups.

...

> +             .cipher = {
> +                     .cia_min_keysize        =  AES_KEY_LENGTH,
> +                     .cia_max_keysize        =  AES_KEY_LENGTH,

I.e. it does not support different keys?
If so, it should be called geode-aes-128, imho.

-- 
        Evgeniy Polyakov
-
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to