ubi: Rewrite freePriority

freePriority is called by RedundancyPriority::priority() to ensure that
there are no duplicate priority values. Originally, freePriority would
call priority() whenever it updated a priority value, but this would call
freePriority again. This can cause the priorities stored on flash to not
match the D-Bus values. The priorities on flash are used to determine
which version to boot from so that leads to unexpected behavior.

Example is if A has priority 1 and B has priority 2, and the priority of
B is changed to 1, this triggers the new value of 1 to be stored on
flash, then A is bumped to 2, but then B that originally had 2 is bumped
to 3, so that at the end of the operation, B has priority 3 on flash but
the correct 1 in D-Bus.

The solution is to prevent freePriority from calling itself, by sorting
all versions by priority in ascending order, so that if a version is
bumped, then only the remaining versions need to be checked. Then
locally update the priority values on flash and on D-Bus for each
changed one.

Tested: Changed priorities multipled times and verified the mismatch is not
        seen anymore.

Change-Id: I704ee98f356a1a77f431b83e4b9d787b2671aeb2
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
2 files changed
tree: a5b4f6b4f130ab4093010f378c9ad00a7b9da95b
  1. m4/
  2. org/
  3. static/
  4. test/
  5. ubi/
  6. .clang-format
  7. .gitignore
  8. activation.cpp
  9. activation.hpp
  10. bootstrap.sh
  11. configure.ac
  12. generate-tar
  13. generate-ubi
  14. image_verify.cpp
  15. image_verify.hpp
  16. item_updater.cpp
  17. item_updater.hpp
  18. item_updater_main.cpp
  19. LICENSE
  20. MAINTAINERS
  21. Makefile.am
  22. msl_verify.cpp
  23. msl_verify.hpp
  24. msl_verify_main.cpp
  25. op-pnor-msl.service
  26. openpower-pnor-update@.service
  27. org.open_power.Software.Host.Updater.service
  28. README.md
  29. utils.cpp
  30. utils.hpp
  31. version.cpp
  32. version.hpp
README.md

openpower-pnor-code-mgmt

OpenPower PNOR (Processor NOR) Code Management provides a set of host software management applications for OpenPower systems. The host firmware is stored on the PNOR chip. More information can be found at Software Architecture or Host Code Update

To Build

To build this package, do the following steps:

    1. ./bootstrap.sh
    2. ./configure ${CONFIGURE_FLAGS}
    3. make

To clean the repository run `./bootstrap.sh clean`.