summaryrefslogtreecommitdiffstats
path: root/libpore
diff options
context:
space:
mode:
authorCyril Bur <cyril.bur@au1.ibm.com>2017-11-17 11:29:15 +1100
committerStewart Smith <stewart@linux.vnet.ibm.com>2017-11-20 20:35:24 -0600
commit65f9abea8e8cfd7f711a5c54217b5505826ff497 (patch)
tree73d90554d4c981d13a54105f88df609b2c338e24 /libpore
parentc2e404aedd52da91fdf605e24b9d1ae7894974c5 (diff)
downloadtalos-skiboot-65f9abea8e8cfd7f711a5c54217b5505826ff497.tar.gz
talos-skiboot-65f9abea8e8cfd7f711a5c54217b5505826ff497.zip
libpore: Fix incorrect mtspr instruction generation
>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 Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'libpore')
-rw-r--r--libpore/p9_stop_api.C10
1 files changed, 4 insertions, 6 deletions
diff --git a/libpore/p9_stop_api.C b/libpore/p9_stop_api.C
index 26a14bbf..33a3bf39 100644
--- a/libpore/p9_stop_api.C
+++ b/libpore/p9_stop_api.C
@@ -255,12 +255,10 @@ static uint32_t getOrisInstruction( const uint16_t i_Rs, const uint16_t i_Ra,
*/
static uint32_t getMtsprInstruction( const uint16_t i_Rs, const uint16_t i_Spr )
{
- uint32_t mtsprInstOpcode = 0;
- uint32_t temp = (( i_Spr & 0x03FF ) << 11);
- mtsprInstOpcode = (uint8_t)i_Rs << 21;
- mtsprInstOpcode = ( temp & 0x0000F800 ) << 5;
- mtsprInstOpcode |= ( temp & 0x001F0000 ) >> 5;
- mtsprInstOpcode |= MTSPR_BASE_OPCODE;
+ uint32_t mtsprInstOpcode = MTSPR_BASE_OPCODE;
+ uint32_t temp = ((i_Spr & 0x1F) << 5) | ((i_Spr & 0x8F) >> 5);
+
+ mtsprInstOpcode |= ((i_Rs & 0x1F) << 21) | ((temp & 0x03FF) << 11);
return SWIZZLE_4_BYTE(mtsprInstOpcode);
}
OpenPOWER on IntegriCloud