secvar/secboot_tpm: correctly reset the control index on secboot format
secvar/secboot_tpm: correctly reset the control index on secboot format

When the SECBOOT partition is formatted, the bank hash stored in the
control TPM NV index must be updated to match, or else we will immediately
fail to load the freshly formatted data at the .load_bank() step.

However, while the secboot_format() function does calculate and update the
bank hash, it only writes the new hash for bank 0. It does not update the
value for bank 1, or set the current active bank. This works as expected if
the active bank bit happens to be set to 0. On the other hand, if the active
bit is set to 1, the freshly formatted bank 1 will be compared against the
unchanged bank hash in bank 1 at the load step, therefore causing an error.

This patch fixes this issue by also setting the active bit to 0 to match
the freshly calculated hash.

Signed-off-by: Eric Richter <1231eba1c884d483f37f1ec746d19a1008480910@linux.ibm.com>
Tested-by: Nick Child <47354f8ad04d636edc050e4b8e3c4d452258c667@ibm.com>
Reviewed-by: Daniel Axtens <cf1af486034ab0119a20f38a060e40da25f4cea3@axtens.net>
Signed-off-by: Cédric Le Goater <2d8cace2254d4e43578d21933db015d84bcc468a@kaod.org>

shenki/skiboot,qemu/skiboot,shenki/skiboot,qemu/skiboot,qemu/skiboot,legoater/skiboot,open-power/skiboot,legoater/skiboot,open-power/skiboot,shenki/skiboot,open-power/skiboot,open-power/skiboot,qemu/skiboot,shenki/skiboot,open-power/skiboot,legoater/skiboot,qemu/skiboot,shenki/skiboot,legoater/skiboot,legoater/skiboot