On Mon, Jun 05, 2006 at 10:11:17AM -0600, Jordan Crouse ([EMAIL PROTECTED]) 
wrote:
> On 03/06/06 14:53 +0400, Evgeniy Polyakov wrote:
>  
> > > +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.
> 
> I'll turn AWRITE and AREAD into macros - I would rather abstract the
> ioread/iowrite functionality away so we can easily maintain it.

Why do you want to have those ugly macros?
Quite good you do not use macros around mutexes.

> > Do not use __pa, use virt_to_phys() although it is the same for i386.
> 
> Sometimes its easy to get lazy when you're only playing with x86.. :)

But it does not mean it should be done.

> > > + 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?
>  
> I struggle with this - on one hand, it is more correct to fail, but on
> the other hand, catastrophic failure means that something horrible happened
> to the silicon block (like overheating).  Since the AES block is in the 
> northbridge, and the northbridge is integrated with the CPU, well - lets put
> it this way - if the AES block stops working, then you probably have 
> more concerns then decrypting a block of data.
> 
> Regardless, I'll stick a stupidly huge number counter here, and fail if it 
> hits zero.

No need to create "stupidly huge number counter".
Setup reasonable counter and fail gracefully there.
If chip is overheated, busyloop definitely will not cool it down
and will not allow to do anything to recover.

> > > +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.
> 
> Is there any way to differentiate if a crypto API call was made in an
> atomic context or not?  The problem here, is that I only have one engine,
> so I need to protect it from multiple processes accessing it at the 
> same time.  I can get rid of the sleep in an atomic context, but we expect
> to have both atomic and process contexts heavily accessing the engine at
> the same time, we really run the risk of having the atomic contexts fail 
> more often then they should due to a process holding the mutex.

You can detect sleeping context by checking tfm->crt_flags & 
CRYPTO_TFM_REQ_MAY_SLEEP,
which is not the best way to do actually, since it might not be set by every
sleeping users.

It can be easily accessed from hardware interrupt context.

> 
> Jordan

-- 
        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