[PATCH 1/2] uefirtmisc: add UEFI runtime service QueryCapsuleCapabilities interface test.

IvanHu ivan.hu at canonical.com
Tue Jan 29 15:12:00 UTC 2013


>> +static int querycapsulecapabilities_test(fwts_framework *fw, uint32_t
>> multitesttime, uint32_t flag)
>> +{
>> +    long ioret;
>> +    uint64_t status;
>> +    uint32_t i;
>> +
>> +    struct efi_querycapsulecapabilities querycapsulecapabilities;
>> +    EFI_RESET_TYPE resettype;
>> +    EFI_CAPSULE_HEADER *pcapsuleheaderarray[2];
>> +    EFI_CAPSULE_HEADER capsuleheader;
>> +    uint64_t maxcapsulesize;
>> +    uint64_t capsulecount;
>> +
>> +    pcapsuleheaderarray[0] = &capsuleheader;
>> +    pcapsuleheaderarray[1] = NULL;
>> +    pcapsuleheaderarray[0]->CapsuleGuid = gEfiCapsuleHeaderGuid;
>> +    pcapsuleheaderarray[0]->CapsuleImageSize =
>> sizeof(EFI_CAPSULE_HEADER);
>> +    pcapsuleheaderarray[0]->HeaderSize = sizeof(EFI_CAPSULE_HEADER);
>> +    pcapsuleheaderarray[0]->Flags = flag;
>> +    querycapsulecapabilities.status = &status;
>> +    querycapsulecapabilities.CapsuleHeaderArray = pcapsuleheaderarray;
>> +    capsulecount = 1;
>> +    querycapsulecapabilities.CapsuleCount = capsulecount;
>> +    querycapsulecapabilities.MaximumCapsuleSize = &maxcapsulesize;
>> +    querycapsulecapabilities.ResetType = &resettype;
>
> capsuleheader is being declared on the stack so it's picking up all
> sorts of possible (garbage) values.  What about the other fields in this
> struct, should they be zero/NULL or what?    As it stands, this test
> will be passing different values into the ioctl() depending on how the
> data appears on the stack, so it's not repeatable in a stable way.
>

Hi Colin,

Thanks for providing your comment.
Actually, the typedef of EFI_CAPSULE_HEADER:
typedef struct {
	EFI_GUID CapsuleGuid;
	uint32_t HeaderSize;
	uint32_t Flags;
	uint32_t CapsuleImageSize;
} __attribute__ ((packed)) EFI_CAPSULE_HEADER;
And the value of capsuleheader fields are given by these line:
pcapsuleheaderarray[0] = &capsuleheader;
pcapsuleheaderarray[0]->CapsuleGuid = gEfiCapsuleHeaderGuid;
pcapsuleheaderarray[0]->CapsuleImageSize = sizeof(EFI_CAPSULE_HEADER);
pcapsuleheaderarray[0]->HeaderSize = sizeof(EFI_CAPSULE_HEADER);
pcapsuleheaderarray[0]->Flags = flag;

I may not totally understand what you are trying to tell me.
Could you please provide me further information? Thanks!

Cheers,
Ivan




More information about the fwts-devel mailing list