I am starting a new thread for these issues because I now understand 
what is going on. The original thread was this one:

http://sourceforge.net/p/tboot/mailman/message/34455904/

We have identified 2 issues with the LZ compressed log code feature 
introduced here:

http://hg.code.sf.net/p/tboot/code/rev/9040e000ccc4
http://hg.code.sf.net/p/tboot/code/rev/78713e04bdd9

Issue #1

Calls to  LZ_Compress can be extremely slow. On all the systems we have 
we are seeing times on the order of around 1 minute to as bad as 4 
minutes or more on the first zip to occur. This is why we thought we saw 
hangs - they turned out to be temporary ones and eventually the system 
would resume from S3.

The author of the LZ code actually states that it is very very slow:

https://github.com/NordicSemiconductor/puck-central-ios/blob/master/PuckCentral/lz.c#L22

I assume this particular implementation was chosen because it is BSD 
(lzlib is GPL)? I also assume LZ_CompressFast was not used because of 
the very large buffer it needs? At any rate, I don't think this is an 
acceptable delay in S3 resume.

Issue #2

The new log compressing logic is susceptible to buffer overruns after a 
sequence of S3 sleeps and resumes. This is because there is no 
terminating condition in the logic. This condition needs to be tested 
before copying more zipped blobs and text into the log buffer:

if (g_log->curr_pos + count > g_log->max_size) {
     g_log->zip_size = LZ_Compress(&g_log->buf[g_log->zip_pos], out,
                           g_log->curr_pos - g_log->zip_pos);

     /* This is the new condition that needs to be tested for here */
     if (g_log->zip_pos + g_log->zip_size + count > g_log->max_size) {
         /* Not sure what the right thing to do here is. Reset logging
            pointers, disable further mem logging, etc... */
     }
     ...
}

I have shown in code that I do reach that condition and logging beyond 
that condition results in a buffer overrun.

Thanks

-- 
Ross Philipson

------------------------------------------------------------------------------
_______________________________________________
tboot-devel mailing list
tboot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tboot-devel

Reply via email to