[SLOF] [PATCH v3 10/17] Add support for a TPM menu to control the state of the TPM

Stefan Berger stefanb at linux.vnet.ibm.com
Tue Dec 22 01:39:05 AEDT 2015


On 12/15/2015 07:34 AM, Thomas Huth wrote:
> On 30/11/15 23:01, Stefan Berger wrote:
>> diff --git a/board-qemu/slof/vtpm-sml.fs b/board-qemu/slof/vtpm-sml.fs
>> index 193b567..3e17c82 100644
>> --- a/board-qemu/slof/vtpm-sml.fs
>> +++ b/board-qemu/slof/vtpm-sml.fs
>> @@ -120,6 +120,200 @@ log-base LOG-SIZE tpm-set-log-parameters
> ...
>> +\ wait for keyboard input
>> +: menu-key-get
>> +    0 0 DO
>> +       key? IF
>> +           key
>> +           UNLOOP EXIT
>> +       THEN
>> +       100 MS
>> +    LOOP
>> +    1b
>> +;
> Is that some kind of timeout that you've tried to do with the "100 MS"
> and 1b at the end here? If so, that should have a proper comment. Then I
> somewhat doubt that it is working as expected: Since you're looping with
> "0 0" that means the loop is running almost forever - and since you're
> delaying 256 ms inbetween (yes, we're hex), the loop will likely never
> end while the user is sitting in front of the screen.
> So if you really want to time-out here, I think you have to rework the
> code. If you wanted to do an endless loop instead ... well then please
> do not use "DO ... LOOP" and something like BEGIN ... WHILE ... REPEAT
> or BEGIN ... UNTIL instead.

It was meant to get a key from the keyboard. So I replaced the code now 
as follows:

\ wait for keyboard input
: menu-key-get
     BEGIN key? 0=
       WHILE 64 MS
     REPEAT
     key
;

>> +\ Send a code to the C-driver to change the state of the vTPM
>> +: process-opcode ( verbose? opcode -- )
>> +    tpm-process-opcode
>> +    dup 0<> IF
>> +        ." VTPM: Error code from tpm-process-opcode: " . cr
>> +    ELSE
>> +        drop
>> +    THEN
>> +;
>> +
>> +1  CONSTANT PPI_OP_ENABLE
>> +2  CONSTANT PPI_OP_DISABLE
>> +3  CONSTANT PPI_OP_ACTIVATE
>> +4  CONSTANT PPI_OP_DEACTIVATE
>> +5  CONSTANT PPI_OP_CLEAR
>> +8  CONSTANT PPI_OP_SETOWNERINSTALL_TRUE
>> +9  CONSTANT PPI_OP_SETOWNERINSTALL_FALSE
>> +
>> +\ if there's a vtpm available, display the menu
>> +\ wait for keyboard input and have the C-driver
>> +\ process opcodes we derive from the chosen menu
>> +\ item
>> +: vtpm-menu
>> +    tpm-is-working IF
>> +        \ vtpm-empty-keybuffer
>> +        menu-show
>> +        0 0  DO
> Endless loop? Please use BEGIN ... REPEAT / UNTIL instead.

Will do.

>
>> +            CASE menu-key-get
> I'd prefer "menu-key-get CASE" instead.

Fixed.

Thanks for the review.

    Stefan



More information about the SLOF mailing list