[Skiboot] [PATCH v2] libpore: Fix incorrect mtspr instruction generation

Stewart Smith stewart at linux.vnet.ibm.com
Wed Nov 22 07:36:58 AEDT 2017

Cyril Bur <cyril.bur at au1.ibm.com> writes:
> From coverity defect 173758:
> CID 173758 (#1 of 1): Unused value (UNUSED_VALUE)
> assigned_value: Assigning value from (uint8_t)i_Rs << 21 to
> mtsprInstOpcode here, but that stored value is overwritten before it can
> be used.
> This causes the generated mtspr to always move from register r0 as
> opposed to the function parameter i_Rs.
> Luckily the only call to getMtsprInstruction is:
> getMtsprInstruction( 0, (uint16_t)i_regId );
> the first parameter is the register so in an incredible stroke of luck,
> the requirement is to generate a mtspr from r0.
> Therefore no bug exists today, this is still a fairly important fix
> because if anyone uses getMtsprInstruction() with a non zero first
> parameter, it will cause them endless headache.
> Fixes: CID 173758
> ---
>  libpore/p9_stop_api.C | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)

So, I'll at least take this patch until we get something from upstream
that does a similar/same thing.

Merged to master as of 65f9abea8e8cfd7f711a5c54217b5505826ff497

Stewart Smith
OPAL Architect, IBM.

More information about the Skiboot mailing list