[PATCH v5 18/34] cxlflash: Fix AFU version access/storage and add check

Matthew R. Ochs mrochs at linux.vnet.ibm.com
Fri Oct 2 11:18:32 AEST 2015


> On Oct 1, 2015, at 7:56 PM, Daniel Axtens <dja at axtens.net> wrote:
> 
> "Matthew R. Ochs" <mrochs at linux.vnet.ibm.com> writes:
> 
>> The AFU version is stored as a non-terminated string of bytes within
>> a 64-bit little-endian register. Presently the value is read directly
>> (no MMIO accessor) and is stored in a buffer that is not big enough
>> to contain a NULL terminator. Additionally the version obtained is not
>> evaluated against a known value to prevent usage with unsupported AFUs.
>> All of these deficiencies can lead to a variety of problems.
>> 
>> +	if ((afu->interface_version + 1) == 0) {
>> +		pr_err("Back level AFU, please upgrade. AFU version %s "
>> +		       "interface version 0x%llx\n", afu->version,
>> +		       afu->interface_version);
>> +		rc = -EINVAL;
>> +		goto err1;
> 
> I'm confused by this if statement. If afu->interface_version + 1 == 0,
> and interface_version is a 64bit unsigned int, that would mean that
> afu->interface_version was 0xFFFF FFFF FFFF FFFF.
> 
> Are you trying to check against all Fs? Is that value significant in the
> hardware?

Correct, downlevel (unsupported) AFUs don't implement the interface_version
register and thus will return -1 at that offset.




More information about the Linuxppc-dev mailing list