From 82dbc15a05125a812c140a3c8cff81c366482229 Mon Sep 17 00:00:00 2001 From: "Jason M. Bills" Date: Mon, 7 Dec 2020 13:45:20 -0800 Subject: Update to internal 0.26 Signed-off-by: Jason M. Bills --- .../0001-Add-more-error-types.patch | 459 --------------------- ...-condition-of-software-version-service-wa.patch | 4 +- ...rmware-activation-to-launch-fwupd.sh-thro.patch | 97 +++-- ...ID-of-software-image-updater-object-on-DB.patch | 4 +- ...ding-StandBySpare-for-firmware-activation.patch | 10 +- .../0007-PFR-images-support.patch | 163 ++++---- .../0008-PFR-image-HASH-verification.patch | 74 ++-- ..._updater-update-the-bmc_active-objectPath.patch | 44 +- ...pplyOptions-D-bus-property-under-Software.patch | 6 +- ...-Add-error-reporting-to-pfr_image_manager.patch | 13 +- ...Fix-for-RedudancyPriority-in-item_updater.patch | 10 +- .../0014-PFR-image-verification.patch | 116 ++++++ ...image-by-ID-and-inhibit-removal-of-bmc_ac.patch | 153 +++++++ .../0016-Process-PLDM-image-type.patch | 224 ++++++++++ 14 files changed, 715 insertions(+), 662 deletions(-) delete mode 100644 meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0001-Add-more-error-types.patch create mode 100644 meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0014-PFR-image-verification.patch create mode 100644 meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0015-Fix-delete-image-by-ID-and-inhibit-removal-of-bmc_ac.patch create mode 100644 meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0016-Process-PLDM-image-type.patch (limited to 'meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager') diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0001-Add-more-error-types.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0001-Add-more-error-types.patch deleted file mode 100644 index d43256bf4..000000000 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0001-Add-more-error-types.patch +++ /dev/null @@ -1,459 +0,0 @@ -From e710df3123c382fc735c451a048f7c51250c1a92 Mon Sep 17 00:00:00 2001 -From: James Feist -Date: Thu, 11 Jun 2020 13:14:11 -0700 -Subject: [PATCH 1/2] Add more error types - -This adds ImageFailure and Busy error types -to updates status in bmcweb. - -elog-errors.hpp is a generated file. - -Tested: Could create errors - -Signed-off-by: James Feist ---- - elog-errors.hpp | 269 ++++++++++++------ - .../Software/Image.errors.yaml | 5 + - .../Software/Image.metadata.yaml | 11 + - 3 files changed, 204 insertions(+), 81 deletions(-) - -diff --git a/elog-errors.hpp b/elog-errors.hpp -index 2888f0d..38016e1 100644 ---- a/elog-errors.hpp -+++ b/elog-errors.hpp -@@ -2,12 +2,12 @@ - // See elog-gen.py for more details - #pragma once - --#include --#include --#include - #include - #include - #include -+#include -+#include -+#include - - namespace sdbusplus - { -@@ -21,7 +21,7 @@ namespace Image - { - namespace Error - { --struct UnTarFailure; -+ struct InternalFailure; - } // namespace Error - } // namespace Image - } // namespace Software -@@ -41,7 +41,7 @@ namespace Image - { - namespace Error - { --struct InternalFailure; -+ struct UnTarFailure; - } // namespace Error - } // namespace Image - } // namespace Software -@@ -61,7 +61,7 @@ namespace Image - { - namespace Error - { --struct ManifestFileFailure; -+ struct BusyFailure; - } // namespace Error - } // namespace Image - } // namespace Software -@@ -69,6 +69,47 @@ struct ManifestFileFailure; - } // namespace xyz - } // namespace sdbusplus - -+namespace sdbusplus -+{ -+namespace xyz -+{ -+namespace openbmc_project -+{ -+namespace Software -+{ -+namespace Image -+{ -+namespace Error -+{ -+ struct ImageFailure; -+} // namespace Error -+} // namespace Image -+} // namespace Software -+} // namespace openbmc_project -+} // namespace xyz -+} // namespace sdbusplus -+ -+namespace sdbusplus -+{ -+namespace xyz -+{ -+namespace openbmc_project -+{ -+namespace Software -+{ -+namespace Image -+{ -+namespace Error -+{ -+ struct ManifestFileFailure; -+} // namespace Error -+} // namespace Image -+} // namespace Software -+} // namespace openbmc_project -+} // namespace xyz -+} // namespace sdbusplus -+ -+ - namespace phosphor - { - -@@ -88,38 +129,25 @@ namespace _UnTarFailure - - struct PATH - { -- static constexpr auto str = "PATH=%s"; -+ /* -+ * We can't use -fsanitize=undefined if we declare a -+ * 'static constexpr auto str' member, so don't. Instead, open-code the -+ * mako template lookups. -+ */ - static constexpr auto str_short = "PATH"; -- using type = std::tuple, const char*>; -- explicit constexpr PATH(const char* a) : _entry(entry(str, a)){}; -+ using type = std::tuple,const char*>; -+ explicit constexpr PATH(const char* a) : _entry(entry("PATH=%s", a)) {}; - type _entry; - }; - --} // namespace _UnTarFailure -+} // namespace _UnTarFailure - --struct UnTarFailure : public sdbusplus::exception_t -+struct UnTarFailure - { -- static constexpr auto errName = -- "xyz.openbmc_project.Software.Image.UnTarFailure"; -- static constexpr auto errDesc = "An error occurred during untar."; - static constexpr auto L = level::ERR; - using PATH = _UnTarFailure::PATH; - using metadata_types = std::tuple; - -- const char* name() const noexcept -- { -- return errName; -- } -- -- const char* description() const noexcept -- { -- return errDesc; -- } -- -- const char* what() const noexcept -- { -- return errName; -- } - }; - - } // namespace Image -@@ -127,16 +155,17 @@ struct UnTarFailure : public sdbusplus::exception_t - } // namespace openbmc_project - } // namespace xyz - -+ - namespace details - { - - template <> --struct map_exception_type< -- sdbusplus::xyz::openbmc_project::Software::Image::Error::UnTarFailure> -+struct map_exception_type - { - using type = xyz::openbmc_project::Software::Image::UnTarFailure; - }; --} // namespace details -+ -+} - - namespace xyz - { -@@ -151,38 +180,25 @@ namespace _ManifestFileFailure - - struct PATH - { -- static constexpr auto str = "PATH=%s"; -+ /* -+ * We can't use -fsanitize=undefined if we declare a -+ * 'static constexpr auto str' member, so don't. Instead, open-code the -+ * mako template lookups. -+ */ - static constexpr auto str_short = "PATH"; -- using type = std::tuple, const char*>; -- explicit constexpr PATH(const char* a) : _entry(entry(str, a)){}; -+ using type = std::tuple,const char*>; -+ explicit constexpr PATH(const char* a) : _entry(entry("PATH=%s", a)) {}; - type _entry; - }; - --} // namespace _ManifestFileFailure -+} // namespace _ManifestFileFailure - --struct ManifestFileFailure : public sdbusplus::exception_t -+struct ManifestFileFailure - { -- static constexpr auto errName = -- "xyz.openbmc_project.Software.Image.ManifestFileFailure"; -- static constexpr auto errDesc = "An error when reading the Manifest file."; - static constexpr auto L = level::ERR; - using PATH = _ManifestFileFailure::PATH; - using metadata_types = std::tuple; - -- const char* name() const noexcept -- { -- return errName; -- } -- -- const char* description() const noexcept -- { -- return errDesc; -- } -- -- const char* what() const noexcept -- { -- return errName; -- } - }; - - } // namespace Image -@@ -190,16 +206,17 @@ struct ManifestFileFailure : public sdbusplus::exception_t - } // namespace openbmc_project - } // namespace xyz - -+ - namespace details - { - - template <> --struct map_exception_type -+struct map_exception_type - { - using type = xyz::openbmc_project::Software::Image::ManifestFileFailure; - }; --} // namespace details -+ -+} - - namespace xyz - { -@@ -214,39 +231,76 @@ namespace _InternalFailure - - struct FAIL - { -- static constexpr auto str = "FAIL=%s"; -+ /* -+ * We can't use -fsanitize=undefined if we declare a -+ * 'static constexpr auto str' member, so don't. Instead, open-code the -+ * mako template lookups. -+ */ - static constexpr auto str_short = "FAIL"; -- using type = std::tuple, const char*>; -- explicit constexpr FAIL(const char* a) : _entry(entry(str, a)){}; -+ using type = std::tuple,const char*>; -+ explicit constexpr FAIL(const char* a) : _entry(entry("FAIL=%s", a)) {}; - type _entry; - }; - --} // namespace _InternalFailure -+} // namespace _InternalFailure - --struct InternalFailure : public sdbusplus::exception_t -+struct InternalFailure - { -- static constexpr auto errName = -- "xyz.openbmc_project.Software.Image.InternalFailure"; -- static constexpr auto errDesc = -- "The operation failed internally during processing the image."; - static constexpr auto L = level::ERR; - using FAIL = _InternalFailure::FAIL; - using metadata_types = std::tuple; - -- const char* name() const noexcept -- { -- return errName; -- } -+}; -+ -+} // namespace Image -+} // namespace Software -+} // namespace openbmc_project -+} // namespace xyz -+ -+ -+namespace details -+{ -+ -+template <> -+struct map_exception_type -+{ -+ using type = xyz::openbmc_project::Software::Image::InternalFailure; -+}; -+ -+} - -- const char* description() const noexcept -- { -- return errDesc; -- } -+namespace xyz -+{ -+namespace openbmc_project -+{ -+namespace Software -+{ -+namespace Image -+{ -+namespace _ImageFailure -+{ -+ -+struct PATH -+{ -+ /* -+ * We can't use -fsanitize=undefined if we declare a -+ * 'static constexpr auto str' member, so don't. Instead, open-code the -+ * mako template lookups. -+ */ -+ static constexpr auto str_short = "PATH"; -+ using type = std::tuple,const char*>; -+ explicit constexpr PATH(const char* a) : _entry(entry("PATH=%s", a)) {}; -+ type _entry; -+}; -+ -+} // namespace _ImageFailure -+ -+struct ImageFailure -+{ -+ static constexpr auto L = level::ERR; -+ using PATH = _ImageFailure::PATH; -+ using metadata_types = std::tuple; - -- const char* what() const noexcept -- { -- return errName; -- } - }; - - } // namespace Image -@@ -254,16 +308,69 @@ struct InternalFailure : public sdbusplus::exception_t - } // namespace openbmc_project - } // namespace xyz - -+ - namespace details - { - - template <> --struct map_exception_type< -- sdbusplus::xyz::openbmc_project::Software::Image::Error::InternalFailure> -+struct map_exception_type - { -- using type = xyz::openbmc_project::Software::Image::InternalFailure; -+ using type = xyz::openbmc_project::Software::Image::ImageFailure; - }; --} // namespace details -+ -+} -+ -+namespace xyz -+{ -+namespace openbmc_project -+{ -+namespace Software -+{ -+namespace Image -+{ -+namespace _BusyFailure -+{ -+ -+struct PATH -+{ -+ /* -+ * We can't use -fsanitize=undefined if we declare a -+ * 'static constexpr auto str' member, so don't. Instead, open-code the -+ * mako template lookups. -+ */ -+ static constexpr auto str_short = "PATH"; -+ using type = std::tuple,const char*>; -+ explicit constexpr PATH(const char* a) : _entry(entry("PATH=%s", a)) {}; -+ type _entry; -+}; -+ -+} // namespace _BusyFailure -+ -+struct BusyFailure -+{ -+ static constexpr auto L = level::ERR; -+ using PATH = _BusyFailure::PATH; -+ using metadata_types = std::tuple; -+ -+}; -+ -+} // namespace Image -+} // namespace Software -+} // namespace openbmc_project -+} // namespace xyz -+ -+ -+namespace details -+{ -+ -+template <> -+struct map_exception_type -+{ -+ using type = xyz::openbmc_project::Software::Image::BusyFailure; -+}; -+ -+} -+ - - } // namespace logging - -diff --git a/xyz/openbmc_project/Software/Image.errors.yaml b/xyz/openbmc_project/Software/Image.errors.yaml -index 67d6c20..2b8f7ee 100644 ---- a/xyz/openbmc_project/Software/Image.errors.yaml -+++ b/xyz/openbmc_project/Software/Image.errors.yaml -@@ -4,3 +4,8 @@ - description: An error when reading the Manifest file. - - name: InternalFailure - description: The operation failed internally during processing the image. -+- name: ImageFailure -+ description: An error occured processing the image. -+- name: BusyFailure -+ description: The device is busy during the update. -+ -diff --git a/xyz/openbmc_project/Software/Image.metadata.yaml b/xyz/openbmc_project/Software/Image.metadata.yaml -index 5e749c9..65d4e1c 100644 ---- a/xyz/openbmc_project/Software/Image.metadata.yaml -+++ b/xyz/openbmc_project/Software/Image.metadata.yaml -@@ -13,3 +13,14 @@ - meta: - - str: "FAIL=%s" - type: string -+- name: ImageFailure -+ level: ERR -+ meta: -+ - str: "PATH=%s" -+ type: string -+- name: BusyFailure -+ level: ERR -+ meta: -+ - str: "PATH=%s" -+ type: string -+ --- -2.17.1 - diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0004-Changed-the-condition-of-software-version-service-wa.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0004-Changed-the-condition-of-software-version-service-wa.patch index 3fc3907ba..bcf692f5e 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0004-Changed-the-condition-of-software-version-service-wa.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0004-Changed-the-condition-of-software-version-service-wa.patch @@ -17,7 +17,7 @@ diff --git a/watch.cpp b/watch.cpp index e46b8aa..eee1bc3 100644 --- a/watch.cpp +++ b/watch.cpp -@@ -45,7 +45,7 @@ Watch::Watch(sd_event* loop, std::function imageCallback) : +@@ -46,7 +46,7 @@ Watch::Watch(sd_event* loop, std::function imageCallback) : std::strerror(error)); } @@ -26,7 +26,7 @@ index e46b8aa..eee1bc3 100644 if (-1 == wd) { auto error = errno; -@@ -96,7 +96,8 @@ int Watch::callback(sd_event_source* s, int fd, uint32_t revents, +@@ -97,7 +97,8 @@ int Watch::callback(sd_event_source* /* s */, int fd, uint32_t revents, while (offset < bytes) { auto event = reinterpret_cast(&buffer[offset]); diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0005-Modified-firmware-activation-to-launch-fwupd.sh-thro.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0005-Modified-firmware-activation-to-launch-fwupd.sh-thro.patch index 355261e8f..85ef5afcf 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0005-Modified-firmware-activation-to-launch-fwupd.sh-thro.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0005-Modified-firmware-activation-to-launch-fwupd.sh-thro.patch @@ -10,22 +10,24 @@ Subject: [PATCH 1/1] Modified firmware activation to launch fwupd.sh through Signed-off-by: Jennifer Lee Signed-off-by: James Feist + --- - activation.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ - configure.ac | 7 +++++++ - static/flash.cpp | 41 +++++++++++++++++++++++++++++++++++++++-- - ubi/flash.cpp | 9 +++------ - 4 files changed, 92 insertions(+), 8 deletions(-) + activation.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++ + meson.build | 1 + + meson_options.txt | 3 +++ + static/flash.cpp | 41 +++++++++++++++++++++++++++++++++++++++-- + ubi/flash.cpp | 9 +++------ + 5 files changed, 91 insertions(+), 8 deletions(-) diff --git a/activation.cpp b/activation.cpp -index ab76420..91e3a10 100644 +index 291ce7c..f76018d 100644 --- a/activation.cpp +++ b/activation.cpp -@@ -200,6 +200,49 @@ auto Activation::activation(Activations value) -> Activations - softwareServer::Activation::Activations::Active); - } - } -+#elif defined(FWUPD_SCRIPT) +@@ -88,7 +88,50 @@ auto Activation::activation(Activations value) -> Activations + + if (value == softwareServer::Activation::Activations::Activating) + { ++#ifdef FWUPD_SCRIPT + if (!activationProgress) + { + // Enable systemd signals @@ -58,7 +60,7 @@ index ab76420..91e3a10 100644 + redundancyPriority = + std::make_unique(bus, path, *this, 0); + } -+ + + // Remove version object from image manager + Activation::deleteImageManagerObject(); + @@ -68,35 +70,60 @@ index ab76420..91e3a10 100644 + return softwareServer::Activation::activation( + softwareServer::Activation::Activations::Active); + } - #else // !UBIFS_LAYOUT ++#else // !FWUPD_SCRIPT + #ifdef HOST_BIOS_UPGRADE + auto purpose = parent.versions.find(versionId)->second->purpose(); + if (purpose == VersionPurpose::Host) +@@ -111,7 +154,6 @@ auto Activation::activation(Activations value) -> Activations + return softwareServer::Activation::activation(value); + } + #endif +- + auto versionStr = parent.versions.find(versionId)->second->version(); + + if (!minimum_ship_level::verify(versionStr)) +@@ -175,6 +217,7 @@ auto Activation::activation(Activations value) -> Activations + return softwareServer::Activation::activation( + softwareServer::Activation::Activations::Active); + #endif ++#endif // FWUPD_SCRIPT + } + else + { +diff --git a/meson.build b/meson.build +index 62b9aeb..08d6f71 100644 +--- a/meson.build ++++ b/meson.build +@@ -54,6 +54,7 @@ conf.set('MMC_LAYOUT', get_option('bmc-layout').contains('mmc')) + # Configurable features + conf.set('HOST_BIOS_UPGRADE', get_option('host-bios-upgrade').enabled()) + conf.set('WANT_SIGNATURE_VERIFY', get_option('verify-signature').enabled()) ++conf.set('FWUPD_SCRIPT', get_option('fwupd-script').enabled()) - #ifdef WANT_SIGNATURE_VERIFY -diff --git a/configure.ac b/configure.ac -index 5fba420..3b5fdab 100755 ---- a/configure.ac -+++ b/configure.ac -@@ -194,6 +194,13 @@ AS_IF([test "x$enable_host_bios_upgrade" == "xyes"], \ - [AC_DEFINE([HOST_BIOS_UPGRADE],[],[Enable host bios upgrade support.])]) - AM_CONDITIONAL([HOST_BIOS_UPGRADE], [test "x$enable_host_bios_upgrade" == "xyes"]) + # Configurable variables + conf.set('ACTIVE_BMC_MAX_ALLOWED', get_option('active-bmc-max-allowed')) +diff --git a/meson_options.txt b/meson_options.txt +index c9b7b33..4f7e62a 100644 +--- a/meson_options.txt ++++ b/meson_options.txt +@@ -22,6 +22,9 @@ option('oe-sdk', type: 'feature', description: 'Enable OE SDK') + option('verify-signature', type: 'feature', + description: 'Enable image signature validation.') -+# setup fwupd script support -+AC_ARG_ENABLE([fwupd_script], -+ AS_HELP_STRING([--enable-fwupd_script], [Enable fwupd script support.])) -+AS_IF([test "x$enable_fwupd_script" == "xyes"], \ -+ [AC_DEFINE([FWUPD_SCRIPT],[],[Enable fwupd script support.])]) -+AM_CONDITIONAL([FWUPD_SCRIPT], [test "x$enable_fwupd_script" == "xyes"]) ++option('fwupd-script', type: 'feature', ++ description: 'Enable fwupd script support.') + - # Check for header files. - AC_CHECK_HEADER(systemd/sd-bus.h, ,[AC_MSG_ERROR([Could not find systemd/sd-bus.h...systemd development package required])]) - AC_CHECK_HEADER(sdbusplus/server.hpp, ,[AC_MSG_ERROR([Could not find sdbusplus/server.hpp...openbmc/sdbusplus package required])]) + # Variables + option( + 'active-bmc-max-allowed', type: 'integer', diff --git a/static/flash.cpp b/static/flash.cpp -index 82c2393..1bf29d5 100644 +index 9bb2bba..c4ff002 100644 --- a/static/flash.cpp +++ b/static/flash.cpp -@@ -20,9 +20,11 @@ namespace updater - { +@@ -22,9 +22,11 @@ namespace updater - namespace fs = std::experimental::filesystem; + namespace fs = std::filesystem; + using namespace phosphor::software::image; +namespace softwareServer = sdbusplus::xyz::openbmc_project::Software::server; void Activation::flashWrite() @@ -105,7 +132,7 @@ index 82c2393..1bf29d5 100644 // For static layout code update, just put images in /run/initramfs. // It expects user to trigger a reboot and an updater script will program // the image to flash during reboot. -@@ -33,11 +35,46 @@ void Activation::flashWrite() +@@ -36,11 +38,46 @@ void Activation::flashWrite() fs::copy_file(uploadDir / versionId / bmcImage, toPath / bmcImage, fs::copy_options::overwrite_existing); } diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0006-Modify-the-ID-of-software-image-updater-object-on-DB.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0006-Modify-the-ID-of-software-image-updater-object-on-DB.patch index 2d2ac2673..1f2a86fb9 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0006-Modify-the-ID-of-software-image-updater-object-on-DB.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0006-Modify-the-ID-of-software-image-updater-object-on-DB.patch @@ -26,8 +26,8 @@ index 5b2ff49..e3d26e3 100644 +#include #include - #include -@@ -129,6 +130,11 @@ int Manager::processImage(const std::string& tarFilePath) + #include +@@ -174,6 +175,11 @@ int Manager::processImage(const std::string& tarFilePath) // Compute id auto id = Version::getId(version); diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0007-Adding-StandBySpare-for-firmware-activation.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0007-Adding-StandBySpare-for-firmware-activation.patch index b63226cce..6039be44b 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0007-Adding-StandBySpare-for-firmware-activation.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0007-Adding-StandBySpare-for-firmware-activation.patch @@ -31,9 +31,9 @@ diff --git a/activation.cpp b/activation.cpp index 2966b2f..a098784 100644 --- a/activation.cpp +++ b/activation.cpp -@@ -80,12 +80,16 @@ auto Activation::activation(Activations value) -> Activations +@@ -81,12 +81,16 @@ void Activation::unsubscribeFromSystemdSignals() + auto Activation::activation(Activations value) -> Activations { - if ((value != softwareServer::Activation::Activations::Active) && - (value != softwareServer::Activation::Activations::Activating)) + (value != softwareServer::Activation::Activations::Activating) && @@ -48,9 +48,9 @@ index 2966b2f..a098784 100644 + value == + softwareServer::Activation::Activations::ActivatingAsStandbySpare) { - #ifdef UBIFS_LAYOUT - if (rwVolumeCreated == false && roVolumeCreated == false) -@@ -256,6 +260,20 @@ auto Activation::requestedActivation(RequestedActivations value) + #ifdef FWUPD_SCRIPT + if (!activationProgress) +@@ -309,6 +313,20 @@ auto Activation::requestedActivation(RequestedActivations value) softwareServer::Activation::Activations::Activating); } } diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0007-PFR-images-support.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0007-PFR-images-support.patch index 92b3ced38..49bdc138f 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0007-PFR-images-support.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0007-PFR-images-support.patch @@ -10,65 +10,23 @@ Testing: tested PFR image uploads and updates Signed-off-by: Vikram Bodireddy + --- - Makefile.am | 18 +++- activation.cpp | 2 +- - configure.ac | 7 ++ - item_updater.cpp | 6 +- + item_updater.cpp | 7 +- + meson.build | 7 +- + meson_options.txt | 3 + pfr_image_manager.cpp | 217 ++++++++++++++++++++++++++++++++++++++++++ pfr_image_manager.hpp | 75 +++++++++++++++ - 6 files changed, 320 insertions(+), 5 deletions(-) + 6 files changed, 306 insertions(+), 5 deletions(-) create mode 100644 pfr_image_manager.cpp create mode 100644 pfr_image_manager.hpp -diff --git a/Makefile.am b/Makefile.am -index 6c3ec16..59ebecc 100755 ---- a/Makefile.am -+++ b/Makefile.am -@@ -6,13 +6,20 @@ noinst_HEADERS = \ - watch.hpp \ - version.hpp \ - images.hpp \ -- image_manager.hpp \ - item_updater.hpp \ - activation.hpp \ - flash.hpp \ - item_updater_helper.hpp \ - utils.hpp - -+if PFR_UPDATE -+noinst_HEADERS += \ -+ pfr_image_manager.hpp -+else -+noinst_HEADERS += \ -+ image_manager.hpp -+endif -+ - bin_PROGRAMS = \ - phosphor-version-software-manager \ - phosphor-download-manager \ -@@ -24,8 +31,15 @@ dist_bin_SCRIPTS = \ - phosphor_version_software_manager_SOURCES = \ - image_manager_main.cpp \ - watch.cpp \ -- version.cpp \ -+ version.cpp -+ -+if PFR_UPDATE -+phosphor_version_software_manager_SOURCES += \ -+ pfr_image_manager.cpp -+else -+phosphor_version_software_manager_SOURCES += \ - image_manager.cpp -+endif - - BUILT_SOURCES = \ - xyz/openbmc_project/Software/Image/error.cpp \ diff --git a/activation.cpp b/activation.cpp -index cea1e50..7ff4196 100644 +index bad17b8..3363230 100644 --- a/activation.cpp +++ b/activation.cpp -@@ -197,7 +197,7 @@ auto Activation::activation(Activations value) -> Activations +@@ -119,7 +119,7 @@ auto Activation::activation(Activations value) -> Activations } else if (activationProgress->progress() == 100) { @@ -77,31 +35,13 @@ index cea1e50..7ff4196 100644 if (!redundancyPriority) { redundancyPriority = -diff --git a/configure.ac b/configure.ac -index 720e704..e527682 100755 ---- a/configure.ac -+++ b/configure.ac -@@ -191,6 +191,13 @@ AS_IF([test "x$enable_fwupd_script" == "xyes"], \ - [AC_DEFINE([FWUPD_SCRIPT],[],[Enable fwupd script support.])]) - AM_CONDITIONAL([FWUPD_SCRIPT], [test "x$enable_fwupd_script" == "xyes"]) - -+# setup pfr image update support -+AC_ARG_ENABLE([pfr_update], -+ AS_HELP_STRING([--enable-pfr_update], [Enable pfr image update support.])) -+AS_IF([test "x$enable_pfr_update" == "xyes"], \ -+ [AC_DEFINE([PFR_UPDATE],[],[Enable pfr image update support.])]) -+AM_CONDITIONAL([PFR_UPDATE], [test "x$enable_pfr_update" == "xyes"]) -+ - # Check for header files. - AC_CHECK_HEADER(systemd/sd-bus.h, ,[AC_MSG_ERROR([Could not find systemd/sd-bus.h...systemd development package required])]) - AC_CHECK_HEADER(sdbusplus/server.hpp, ,[AC_MSG_ERROR([Could not find sdbusplus/server.hpp...openbmc/sdbusplus package required])]) diff --git a/item_updater.cpp b/item_updater.cpp -index 21fb6e0..fd76a7f 100644 +index df8595c..694975f 100644 --- a/item_updater.cpp +++ b/item_updater.cpp @@ -64,10 +64,10 @@ void ItemUpdater::createActivation(sdbusplus::message::message& msg) auto value = SVersion::convertVersionPurposeFromString( - variant_ns::get(property.second)); + std::get(property.second)); if (value == VersionPurpose::BMC || -#ifdef HOST_BIOS_UPGRADE +#if defined(HOST_BIOS_UPGRADE) || defined(PFR_UPDATE) @@ -112,29 +52,84 @@ index 21fb6e0..fd76a7f 100644 { purpose = value; } -@@ -356,6 +357,7 @@ void ItemUpdater::deleteAll() +@@ -399,6 +399,7 @@ void ItemUpdater::deleteAll() ItemUpdater::ActivationStatus ItemUpdater::validateSquashFSImage(const std::string& filePath) { +#ifndef PFR_UPDATE - bool invalid = false; + bool valid = true; - for (auto& bmcImage : bmcImages) -@@ -375,7 +377,7 @@ ItemUpdater::ActivationStatus - { - return ItemUpdater::ActivationStatus::invalid; + // Record the images which are being updated +@@ -416,7 +417,7 @@ ItemUpdater::ActivationStatus + return ItemUpdater::ActivationStatus::invalid; + } } - +#endif return ItemUpdater::ActivationStatus::ready; } +@@ -690,8 +691,8 @@ void ItemUpdater::freeSpace(Activation& caller) + // Failed activations don't have priority, assign them a large value + // for sorting purposes. + auto priority = 999; +- if ((iter.second.get()->activation() == +- server::Activation::Activations::Active)&& ++ if ((iter.second.get()->activation() == ++ server::Activation::Activations::Active) && + iter.second->redundancyPriority.get()) + { + priority = iter.second->redundancyPriority.get()->priority(); +diff --git a/meson.build b/meson.build +index 08d6f71..c61d59f 100644 +--- a/meson.build ++++ b/meson.build +@@ -55,6 +55,7 @@ conf.set('MMC_LAYOUT', get_option('bmc-layout').contains('mmc')) + conf.set('HOST_BIOS_UPGRADE', get_option('host-bios-upgrade').enabled()) + conf.set('WANT_SIGNATURE_VERIFY', get_option('verify-signature').enabled()) + conf.set('FWUPD_SCRIPT', get_option('fwupd-script').enabled()) ++conf.set('PFR_UPDATE', get_option('pfr-update').enabled()) + + # Configurable variables + conf.set('ACTIVE_BMC_MAX_ALLOWED', get_option('active-bmc-max-allowed')) +@@ -195,12 +196,16 @@ executable( + install: true + ) + ++image_manager_source = files('image_manager.cpp') ++if get_option('pfr-update').enabled() ++ image_manager_source = files('pfr_image_manager.cpp') ++endif + executable( + 'phosphor-version-software-manager', + image_error_cpp, + image_error_hpp, +- 'image_manager.cpp', + 'image_manager_main.cpp', ++ image_manager_source, + 'version.cpp', + 'watch.cpp', + dependencies: [deps, ssl], +diff --git a/meson_options.txt b/meson_options.txt +index 4f7e62a..1593502 100644 +--- a/meson_options.txt ++++ b/meson_options.txt +@@ -25,6 +25,9 @@ option('verify-signature', type: 'feature', + option('fwupd-script', type: 'feature', + description: 'Enable fwupd script support.') + ++option('pfr-update', type: 'feature', ++ description: 'Enable fwupd script support.') ++ + # Variables + option( + 'active-bmc-max-allowed', type: 'integer', diff --git a/pfr_image_manager.cpp b/pfr_image_manager.cpp new file mode 100644 index 0000000..242a6ca --- /dev/null +++ b/pfr_image_manager.cpp -@@ -0,0 +1,217 @@ +@@ -0,0 +1,218 @@ +#include "config.h" + +#include "pfr_image_manager.hpp" @@ -149,15 +144,16 @@ index 0000000..242a6ca +#include +#include + ++#include ++#include ++ +#include +#include -+#include +#include +#include +#include +#include +#include -+#include + +namespace phosphor +{ @@ -357,7 +353,7 @@ new file mode 100644 index 0000000..c6ee6a4 --- /dev/null +++ b/pfr_image_manager.hpp -@@ -0,0 +1,75 @@ +@@ -0,0 +1,76 @@ +#pragma once +#include "version.hpp" + @@ -370,7 +366,8 @@ index 0000000..c6ee6a4 +namespace manager +{ + -+enum pfrImgPCType { ++enum pfrImgPCType ++{ + pfrCPLDUpdateCap = 0x00, + pfrPCHPFM = 0x01, + pfrPCHUpdateCap = 0x02, @@ -379,7 +376,8 @@ index 0000000..c6ee6a4 +}; + +/* PFR image block 0 - As defined in HAS */ -+struct pfrImgBlock0 { ++struct pfrImgBlock0 ++{ + uint8_t tag[4]; + uint8_t pcLength[4]; + uint8_t pcType[4]; @@ -387,7 +385,7 @@ index 0000000..c6ee6a4 + uint8_t hash256[32]; + uint8_t hash384[48]; + uint8_t reserved2[32]; -+}__attribute__((packed)); ++} __attribute__((packed)); + +/** @class Manager + * @brief Contains a map of Version dbus objects. @@ -427,7 +425,6 @@ index 0000000..c6ee6a4 + + /** @brief Persistent sdbusplus DBus bus connection. */ + sdbusplus::bus::bus& bus; -+ +}; + +} // namespace manager diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0008-PFR-image-HASH-verification.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0008-PFR-image-HASH-verification.patch index c65f8318c..72eb0beba 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0008-PFR-image-HASH-verification.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0008-PFR-image-HASH-verification.patch @@ -59,18 +59,15 @@ index 242a6ca..1a41cbe 100644 #include #include #include -@@ -15,9 +17,9 @@ - #include - #include - #include --#include +@@ -20,6 +22,7 @@ + #include #include #include +#include #include #include - #include -@@ -33,12 +35,21 @@ using namespace sdbusplus::xyz::openbmc_project::Software::Image::Error; + +@@ -34,12 +37,21 @@ using namespace sdbusplus::xyz::openbmc_project::Software::Image::Error; namespace Software = phosphor::logging::xyz::openbmc_project::Software; static constexpr const uint32_t pfmPos = 2054; @@ -96,7 +93,7 @@ index 242a6ca..1a41cbe 100644 if (std::filesystem::exists(imgPath)) { -@@ -55,17 +66,101 @@ static int getPFRImgInfo(const std::filesystem::path imgPath, uint8_t& imgType, +@@ -56,17 +68,101 @@ static int getPFRImgInfo(const std::filesystem::path imgPath, uint8_t& imgType, imgFile.read(reinterpret_cast(&block0Data), sizeof(block0Data)); @@ -200,7 +197,7 @@ index 242a6ca..1a41cbe 100644 } catch (std::exception& e) { -@@ -79,20 +174,21 @@ static int getPFRImgInfo(const std::filesystem::path imgPath, uint8_t& imgType, +@@ -80,20 +176,21 @@ static int getPFRImgInfo(const std::filesystem::path imgPath, uint8_t& imgType, int Manager::processImage(const std::string& imgFilePath) { @@ -225,7 +222,7 @@ index 242a6ca..1a41cbe 100644 return -1; } -@@ -103,31 +198,6 @@ int Manager::processImage(const std::string& imgFilePath) +@@ -104,31 +201,6 @@ int Manager::processImage(const std::string& imgFilePath) return -1; } @@ -257,7 +254,7 @@ index 242a6ca..1a41cbe 100644 sdbusplus::xyz::openbmc_project::Software::server::Version::VersionPurpose purpose = Version::VersionPurpose::Unknown; try -@@ -169,6 +239,7 @@ int Manager::processImage(const std::string& imgFilePath) +@@ -170,6 +242,7 @@ int Manager::processImage(const std::string& imgFilePath) std::filesystem::create_directory(imageDirPath); std::filesystem::path newFileName = imageDirPath / "image-runtime"; @@ -265,7 +262,7 @@ index 242a6ca..1a41cbe 100644 std::filesystem::rename(imgFilePath, newFileName); // Create Version object -@@ -212,6 +283,14 @@ void Manager::erase(std::string entryId) +@@ -213,6 +286,14 @@ void Manager::erase(std::string entryId) this->versions.erase(entryId); } @@ -284,7 +281,7 @@ diff --git a/pfr_image_manager.hpp b/pfr_image_manager.hpp index c6ee6a4..5b7b2c3 100644 --- a/pfr_image_manager.hpp +++ b/pfr_image_manager.hpp -@@ -1,6 +1,13 @@ +@@ -1,8 +1,16 @@ #pragma once #include "version.hpp" @@ -294,38 +291,26 @@ index c6ee6a4..5b7b2c3 100644 +#include +#include + -+#include #include ++#include ++ namespace phosphor -@@ -10,7 +17,8 @@ namespace software - namespace manager { - --enum pfrImgPCType { -+enum pfrImgPCType -+{ - pfrCPLDUpdateCap = 0x00, - pfrPCHPFM = 0x01, - pfrPCHUpdateCap = 0x02, -@@ -19,15 +27,94 @@ enum pfrImgPCType { - }; - + namespace software +@@ -22,7 +30,7 @@ enum pfrImgPCType /* PFR image block 0 - As defined in HAS */ --struct pfrImgBlock0 { + struct pfrImgBlock0 + { - uint8_t tag[4]; -+struct pfrImgBlock0 -+{ + uint32_t tag; uint8_t pcLength[4]; uint8_t pcType[4]; uint8_t reserved1[4]; - uint8_t hash256[32]; - uint8_t hash384[48]; +@@ -31,6 +39,82 @@ struct pfrImgBlock0 uint8_t reserved2[32]; --}__attribute__((packed)); -+} __attribute__((packed)); -+ + } __attribute__((packed)); + +/** @struct CustomFd + * + * RAII wrapper for file descriptor. @@ -343,8 +328,7 @@ index c6ee6a4..5b7b2c3 100644 + * @param[in] fd - File descriptor + */ + CustomFd(int fd) : fd(fd) -+ { -+ } ++ {} + + ~CustomFd() + { @@ -390,8 +374,7 @@ index c6ee6a4..5b7b2c3 100644 + * @param[in] length - length of the map + */ + CustomMap(void* addr, size_t length) : addr(addr), length(length) -+ { -+ } ++ {} + + ~CustomMap() + { @@ -403,10 +386,11 @@ index c6ee6a4..5b7b2c3 100644 + return addr; + } +}; - ++ /** @class Manager * @brief Contains a map of Version dbus objects. -@@ -61,13 +148,28 @@ class Manager + * @details The software image manager class that contains the Version dbus +@@ -63,6 +147,22 @@ class Manager void erase(std::string entryId); private: @@ -429,13 +413,3 @@ index c6ee6a4..5b7b2c3 100644 /** @brief Persistent map of Version dbus objects and their * version id */ std::map> versions; - - /** @brief Persistent sdbusplus DBus bus connection. */ - sdbusplus::bus::bus& bus; -- - }; - - } // namespace manager --- -2.17.1 - diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0008-item_updater-update-the-bmc_active-objectPath.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0008-item_updater-update-the-bmc_active-objectPath.patch index bac756a18..e0ff79795 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0008-item_updater-update-the-bmc_active-objectPath.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0008-item_updater-update-the-bmc_active-objectPath.patch @@ -6,25 +6,45 @@ Subject: [PATCH] item_updater: update the bmc_active objectPath Update the Software object path to bmc_active instead of random Id. Signed-off-by: Chalapathi + --- - item_updater.cpp | 4 +--- - 1 file changed, 1 insertion(+), 3 deletions(-) + item_updater.cpp | 7 ++----- + 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/item_updater.cpp b/item_updater.cpp -index 7fe69e4..3ce1dbf 100644 +index e6dd298..c3a846d 100644 --- a/item_updater.cpp +++ b/item_updater.cpp -@@ -175,9 +175,7 @@ void ItemUpdater::processBMCImage() +@@ -175,7 +175,8 @@ void ItemUpdater::processBMCImage() if (0 == iter.path().native().compare(0, BMC_RO_PREFIX_LEN, BMC_ROFS_PREFIX)) { -- // The versionId is extracted from the path -- // for example /media/ro-2a1022fe. -- auto id = iter.path().native().substr(BMC_RO_PREFIX_LEN); +- // Get the version to calculate the id + std::string id = "bmc_active"; - auto osRelease = iter.path() / OS_RELEASE_FILE; ++ // upstream changed this to relative_path ... is that right? + fs::path releaseFile(OS_RELEASE_FILE); + auto osRelease = iter.path() / releaseFile.relative_path(); if (!fs::is_regular_file(osRelease)) - { --- -2.17.1 - +@@ -189,7 +190,6 @@ void ItemUpdater::processBMCImage() + // volumes created by the UBI layout for example have the id in + // the mount directory name. The worst that can happen is that + // erase() is called with an non-existent id and returns. +- auto id = iter.path().native().substr(BMC_RO_PREFIX_LEN); + ItemUpdater::erase(id); + + continue; +@@ -203,14 +203,11 @@ void ItemUpdater::processBMCImage() + + // Try to delete the version, same as above if the + // OS_RELEASE_FILE does not exist. +- auto id = iter.path().native().substr(BMC_RO_PREFIX_LEN); + ItemUpdater::erase(id); + + continue; + } + +- auto id = VersionClass::getId(version); +- + // Check if the id has already been added. This can happen if the + // BMC partitions / devices were manually flashed with the same + // image. diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0009-Add-ApplyOptions-D-bus-property-under-Software.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0009-Add-ApplyOptions-D-bus-property-under-Software.patch index 3fa6a9a79..f150c1027 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0009-Add-ApplyOptions-D-bus-property-under-Software.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0009-Add-ApplyOptions-D-bus-property-under-Software.patch @@ -27,9 +27,9 @@ index 3f0530f..5c1a779 100644 #include +#include - namespace phosphor - { -@@ -21,7 +22,8 @@ using ItemUpdaterInherit = sdbusplus::server::object::object< + #include + #include +@@ -24,7 +25,8 @@ using ItemUpdaterInherit = sdbusplus::server::object::object< sdbusplus::xyz::openbmc_project::Common::server::FactoryReset, sdbusplus::xyz::openbmc_project::Control::server::FieldMode, sdbusplus::xyz::openbmc_project::Association::server::Definitions, diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0010-Add-error-reporting-to-pfr_image_manager.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0010-Add-error-reporting-to-pfr_image_manager.patch index 9c3ab4dd2..e72398efd 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0010-Add-error-reporting-to-pfr_image_manager.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0010-Add-error-reporting-to-pfr_image_manager.patch @@ -133,7 +133,7 @@ index 1a41cbe..fe1e6f9 100644 static constexpr const uint32_t pfmPos = 2054; static constexpr const uint32_t block0Magic = 0xB6EAFD19; -@@ -74,6 +78,8 @@ int Manager::verifyPFRImage(const std::filesystem::path imgPath, +@@ -76,6 +80,8 @@ int Manager::verifyPFRImage(const std::filesystem::path imgPath, phosphor::logging::log( "Image magic number match failed", phosphor::logging::entry("IMAGEMAGIC=0x%x", imgMagic)); @@ -142,34 +142,37 @@ index 1a41cbe..fe1e6f9 100644 return -1; } -@@ -108,6 +114,8 @@ int Manager::verifyPFRImage(const std::filesystem::path imgPath, +@@ -110,6 +116,9 @@ int Manager::verifyPFRImage(const std::filesystem::path imgPath, phosphor::logging::log( "Unknown image type"); + phosphor::logging::report( ++ ImageFail::FAIL("Unknown image type"), + ImageFail::PATH(imgPath.c_str())); return -1; } -@@ -151,6 +159,8 @@ int Manager::verifyPFRImage(const std::filesystem::path imgPath, +@@ -153,6 +162,9 @@ int Manager::verifyPFRImage(const std::filesystem::path imgPath, "PRIORITY=%i", LOG_ERR, "REDFISH_MESSAGE_ID=%s", redfishMsgID.c_str(), "REDFISH_MESSAGE_ARGS=%s", "Image HASH check fail", NULL); + phosphor::logging::report( ++ ImageFail::FAIL("Security violation: hash mismatch"), + ImageFail::PATH(imgPath.c_str())); return -1; } -@@ -165,6 +175,8 @@ int Manager::verifyPFRImage(const std::filesystem::path imgPath, +@@ -167,6 +179,9 @@ int Manager::verifyPFRImage(const std::filesystem::path imgPath, catch (std::exception& e) { phosphor::logging::log(e.what()); + phosphor::logging::report( ++ ImageFail::FAIL("Unhandled exception"), + ImageFail::PATH(imgPath.c_str())); return -1; } } -@@ -180,6 +192,12 @@ int Manager::processImage(const std::string& imgFilePath) +@@ -182,6 +197,12 @@ int Manager::processImage(const std::string& imgFilePath) if (!std::filesystem::exists(imgPath)) return -1; diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0011-Fix-for-RedudancyPriority-in-item_updater.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0011-Fix-for-RedudancyPriority-in-item_updater.patch index 4c8f82aa3..156e6fe7c 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0011-Fix-for-RedudancyPriority-in-item_updater.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0011-Fix-for-RedudancyPriority-in-item_updater.patch @@ -1,4 +1,4 @@ -From 0babf82f51561ac92a9b0dd56991d8de01930129 Mon Sep 17 00:00:00 2001 +From f6022e25d0b47af502522913773e589fcdd1568e Mon Sep 17 00:00:00 2001 From: Vikram Bodireddy Date: Sun, 5 Jul 2020 00:54:57 +0530 Subject: [PATCH] Fix for RedudancyPriority in item_updater @@ -13,15 +13,16 @@ item_updater. Tested: Tested for coredumps during Seamless firmware update. Signed-off-by: Vikram Bodireddy + --- item_updater.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/item_updater.cpp b/item_updater.cpp -index af01e39..8d7bb82 100644 +index c3a846d..b299b4d 100644 --- a/item_updater.cpp +++ b/item_updater.cpp -@@ -655,8 +655,9 @@ void ItemUpdater::freeSpace(Activation& caller) +@@ -690,8 +690,9 @@ void ItemUpdater::freeSpace(Activation& caller) // Failed activations don't have priority, assign them a large value // for sorting purposes. auto priority = 999; @@ -33,6 +34,3 @@ index af01e39..8d7bb82 100644 { priority = iter.second->redundancyPriority.get()->priority(); } --- -2.17.1 - diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0014-PFR-image-verification.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0014-PFR-image-verification.patch new file mode 100644 index 000000000..dfc7f2e58 --- /dev/null +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0014-PFR-image-verification.patch @@ -0,0 +1,116 @@ +From 9d82d53b50769506926dd99273f197a268d68fa3 Mon Sep 17 00:00:00 2001 +From: Chalapathi Venkataramashetty +Date: Thu, 30 Jul 2020 09:50:40 +0000 +Subject: [PATCH] PFR-image-verification + +Add support verify the complete fw image by using mtd-util repo's +pfr_authenticate function. + +Tested. +1. Upload the corrupted image. +POST: https:///redfish/v1/UpdateService/ + with binary file +Response: +{ + "error": { + "@Message.ExtendedInfo": [ + { + "@odata.type": "/redfish/v1/$metadata#Message.v1_0_0.Message", + "Message": "Invalid file uploaded to /redfish/v1/UpdateService: + Invalid image format.", + "MessageArgs": [ + "/redfish/v1/UpdateService", + "Invalid image format" + ], + "MessageId": "OpenBMC.0.1.0.InvalidUpload", + "Resolution": "None.", + "Severity": "Warning" + } + ], + "code": "OpenBMC.0.1.0.InvalidUpload", + "message": "Invalid file uploaded to /redfish/v1/UpdateService: + Invalid image format." + } +} + +2. Upload the correct image. +POST: https:///redfish/v1/UpdateService/ + with binary file + +Image verified and firmware updated. +{ + "@odata.id": "/redfish/v1/TaskService/Tasks/0", + "@odata.type": "#Task.v1_4_3.Task", + "Id": "0", + "TaskState": "Running", + "TaskStatus": "OK" +} + +Command: +GET: https:///redfish/v1/Systems/system/LogServices/EventLog/ + Entries + +Response: +{ + "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/ + Entries/1596082187", + "@odata.type": "#LogEntry.v1_4_0.LogEntry", + "Created": "2020-07-30T04:09:47+00:00", + "EntryType": "Event", + "Id": "1596082187", + "Message": "BMC firmware update to version 00.72 completed + successfully.", + "MessageArgs": [ + "BMC", + "00.72" + ], + "MessageId": "OpenBMC.0.1.FirmwareUpdateCompleted", + "Name": "System Event Log Entry", + "Severity": "OK" + }, + +Signed-off-by: Chalapathi Venkataramashetty +--- + pfr_image_manager.cpp | 17 +++++++++++++++++ + 1 file changed, 17 insertions(+) + +diff --git a/pfr_image_manager.cpp b/pfr_image_manager.cpp +index eeed4fe..16231fa 100644 +--- a/pfr_image_manager.cpp ++++ b/pfr_image_manager.cpp +@@ -15,6 +15,7 @@ + #include + #include + ++#include + #include + #include + +@@ -122,6 +123,24 @@ int Manager::verifyPFRImage(const std::filesystem::path imgPath, + return -1; + } + ++ // Verify the complete image ++ std::string mtdUtilfile = "/usr/bin/mtd-util"; ++ std::vector mtdUtilCmd = {"p", "a"}; ++ mtdUtilCmd.push_back(imgPath); ++ ++ boost::process::child execProg(mtdUtilfile, mtdUtilCmd); ++ execProg.wait(); ++ if (execProg.exit_code()) ++ { ++ phosphor::logging::log( ++ "Image authentication failed"); ++ phosphor::logging::report( ++ ImageFail::FAIL( ++ "Security violation: image authentication failure"), ++ ImageFail::PATH(imgPath.c_str())); ++ return -1; ++ } ++ + imgFile.seekg(pfmPos, + std::ios::beg); // Version is at 0x806 in the PFM + imgFile.read(reinterpret_cast(&verData), sizeof(verData)); +-- +2.17.1 + diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0015-Fix-delete-image-by-ID-and-inhibit-removal-of-bmc_ac.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0015-Fix-delete-image-by-ID-and-inhibit-removal-of-bmc_ac.patch new file mode 100644 index 000000000..54efbee8c --- /dev/null +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0015-Fix-delete-image-by-ID-and-inhibit-removal-of-bmc_ac.patch @@ -0,0 +1,153 @@ +From f2dd5e13a0774d8683542798dd96979f9d7a6691 Mon Sep 17 00:00:00 2001 +From: Vernon Mauery +Date: Tue, 29 Sep 2020 13:38:35 -0700 +Subject: [PATCH] Fix delete image by ID and inhibit removal of bmc_active + +Delete image by ID was broken because when hitting the delete dbus +interface, it recalculated the ID from the parent version, which then +does not match because of the random number addition that was added to +the ID when the parent interface was created. This saves away the parent +interface ID and recalls it rather than recalculating it. + +Also, there was a logic error in deleting images that would delete the +active BMC image. This fixes up that error. + +Tested: run multiple back-to back updates and see that when the fwupd + script calls delete on the seamless images, the interfaces are + deleted and that the bmc_active interface is not deleted. + +Signed-off-by: Vernon Mauery +--- + item_updater.cpp | 17 +++++++++++------ + pfr_image_manager.cpp | 2 +- + version.cpp | 2 +- + version.hpp | 19 +++++++++++++++---- + 4 files changed, 28 insertions(+), 12 deletions(-) + +diff --git a/item_updater.cpp b/item_updater.cpp +index db255d6..90970d3 100644 +--- a/item_updater.cpp ++++ b/item_updater.cpp +@@ -133,7 +133,7 @@ void ItemUpdater::createActivation(sdbusplus::message::message& msg) + activationState, associations))); + + auto versionPtr = std::make_unique( +- bus, path, version, purpose, filePath, ++ bus, path, versionId, version, purpose, filePath, + std::bind(&ItemUpdater::erase, this, std::placeholders::_1)); + versionPtr->deleteObject = + std::make_unique(bus, path, +@@ -247,7 +247,7 @@ void ItemUpdater::processBMCImage() + + // Create Version instance for this version. + auto versionPtr = std::make_unique( +- bus, path, version, purpose, "", ++ bus, path, id, version, purpose, "", + std::bind(&ItemUpdater::erase, this, std::placeholders::_1)); + auto isVersionFunctional = versionPtr->isFunctional(); + if (!isVersionFunctional) +@@ -322,11 +322,11 @@ void ItemUpdater::erase(std::string entryId) + auto it = versions.find(entryId); + if (it != versions.end()) + { +- if (it->second->isFunctional() && ACTIVE_BMC_MAX_ALLOWED > 1) ++ if (it->second->isFunctional()) + { +- log("Error: Version is currently running on the BMC. " +- "Unable to remove.", +- entry("VERSIONID=%s", entryId.c_str())); ++ log("Error: Version is currently running on the BMC. " ++ "Unable to remove.", ++ entry("VERSIONID=%s", entryId.c_str())); + return; + } + } +@@ -669,6 +669,11 @@ void ItemUpdater::freeSpace(Activation& caller) + std::size_t count = 0; + for (const auto& iter : activations) + { ++ if (versions.find(iter.second->versionId)->second->isFunctional()) ++ { ++ // don't bother with function versions ++ continue; ++ } + if ((iter.second.get()->activation() == + server::Activation::Activations::Active) || + (iter.second.get()->activation() == +diff --git a/pfr_image_manager.cpp b/pfr_image_manager.cpp +index 145237e..0c6c3d8 100644 +--- a/pfr_image_manager.cpp ++++ b/pfr_image_manager.cpp +@@ -308,7 +308,7 @@ int Manager::processImage(const std::string& imgFilePath) + std::string objPath = std::string{SOFTWARE_OBJPATH} + '/' + id; + + auto versionPtr = std::make_unique( +- bus, objPath, ver, purpose, imageDirPath.string(), ++ bus, objPath, id, ver, purpose, imageDirPath.string(), + std::bind(&Manager::erase, this, std::placeholders::_1)); + versionPtr->deleteObject = + std::make_unique(bus, objPath, +diff --git a/version.cpp b/version.cpp +index 18f3f4f..e6fd481 100644 +--- a/version.cpp ++++ b/version.cpp +@@ -182,7 +182,7 @@ void Delete::delete_() + { + if (parent.eraseCallback) + { +- parent.eraseCallback(parent.getId(parent.version())); ++ parent.eraseCallback(parent.getExtId()); + } + } + +diff --git a/version.hpp b/version.hpp +index 9cf76da..ae70ea8 100644 +--- a/version.hpp ++++ b/version.hpp +@@ -74,14 +74,15 @@ class Version : public VersionInherit + * @param[in] callback - The eraseFunc callback + */ + Version(sdbusplus::bus::bus& bus, const std::string& objPath, +- const std::string& versionString, VersionPurpose versionPurpose, +- const std::string& filePath, eraseFunc callback) : ++ const std::string& extId, const std::string& versionString, ++ VersionPurpose versionPurpose, const std::string& filePath, ++ eraseFunc callback) : + VersionInherit(bus, (objPath).c_str(), true), +- eraseCallback(callback), versionStr(versionString) ++ eraseCallback(callback), extId(extId), versionStr(versionString) + { + // Set properties. + purpose(versionPurpose); +- version(versionString); ++ version(extId); + path(filePath); + // Emit deferred signal. + emit_object_added(); +@@ -134,6 +135,15 @@ class Version : public VersionInherit + */ + bool isFunctional(); + ++ /* @brief Return the extended ID of this version object ++ * ++ * @ return - returns the extended ID string ++ */ ++ std::string getExtId() ++ { ++ return extId; ++ } ++ + /** @brief Persistent Delete D-Bus object */ + std::unique_ptr deleteObject; + +@@ -143,6 +153,7 @@ class Version : public VersionInherit + private: + /** @brief This Version's version string */ + const std::string versionStr; ++ const std::string extId; + }; + + } // namespace manager +-- +2.17.1 + diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0016-Process-PLDM-image-type.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0016-Process-PLDM-image-type.patch new file mode 100644 index 000000000..c353a09b2 --- /dev/null +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0016-Process-PLDM-image-type.patch @@ -0,0 +1,224 @@ +From aaebe1c3db71b7addbd3f1d1b2b5f83d7cba14e3 Mon Sep 17 00:00:00 2001 +From: Ayushi Smriti +Date: Mon, 9 Nov 2020 23:04:58 +0530 +Subject: [PATCH] Process PLDM image type + +This change is to check whether the image uploaded is of PLDM image +type based on the PackageHeaderIdentifier check which is a 16 bytes +uuid field in the pldm package header. + +Also, determine image purpose and version. +Purpose is set to pldm enum type and for version, PackageVersionString +is concluded based on PackageVersionStringLength value. + +Tested: +- On uploading a pldm image through Redfish. Uuid is identified and +matched correctly. +- Purpose and version is given to the image as expected and activation +intf got added. + - verified same with busctl cmd on xyz.openbmc_project.Software.Version + and xyz.openbmc_project.Software.BMC.Updater +- Verified the regular PFR update procedure works + - received expected redfish response from postman + - verified fwupd.sh script is reached + +Signed-off-by: Ayushi Smriti +--- + item_updater.cpp | 1 + + pfr_image_manager.cpp | 95 +++++++++++++++++++++++++++++++++++++++++-- + pfr_image_manager.hpp | 6 +-- + pldm.hpp | 21 ++++++++++ + 4 files changed, 117 insertions(+), 6 deletions(-) + create mode 100644 pldm.hpp + +diff --git a/item_updater.cpp b/item_updater.cpp +index db255d6..2ed2a3c 100644 +--- a/item_updater.cpp ++++ b/item_updater.cpp +@@ -67,6 +67,7 @@ void ItemUpdater::createActivation(sdbusplus::message::message& msg) + #if defined(HOST_BIOS_UPGRADE) || defined(PFR_UPDATE) + value == VersionPurpose::Host || + #endif ++ value == VersionPurpose::PLDM || + value == VersionPurpose::Other) + { + purpose = value; +diff --git a/pfr_image_manager.cpp b/pfr_image_manager.cpp +index 178367f..c923494 100644 +--- a/pfr_image_manager.cpp ++++ b/pfr_image_manager.cpp +@@ -3,6 +3,7 @@ + #include "pfr_image_manager.hpp" + + #include "dbus_helpers.hpp" ++#include "pldm.hpp" + #include "version.hpp" + #include "watch.hpp" + +@@ -44,9 +45,10 @@ using BusyFail = Software::Image::BusyFailure; + static constexpr const uint32_t pfmPos = 2054; + static constexpr const uint32_t block0Magic = 0xB6EAFD19; + static constexpr const uint32_t lengthBlk0Blk1 = 1024; ++static constexpr const uint32_t pldmMagic = 0xF018878C; + +-int Manager::verifyPFRImage(const std::filesystem::path imgPath, +- std::string& version, std::string& purposeString) ++int Manager::verifyImage(const std::filesystem::path imgPath, ++ std::string& version, std::string& purposeString) + { + uint8_t imgType = 0; + uint32_t imgMagic = 0; +@@ -76,6 +78,93 @@ int Manager::verifyPFRImage(const std::filesystem::path imgPath, + + imgMagic = block0Data.tag; + ++ if (htobe32(imgMagic) == pldmMagic) ++ { ++ if (!version.empty()) ++ { ++ version.clear(); ++ } ++ ++ imgFile.seekg(0, std::ios_base::end); ++ ++ const size_t length = imgFile.tellg(); ++ constexpr size_t readBytes = 36; ++ ++ if (length < readBytes) ++ { ++ phosphor::logging::log( ++ "Insufficient file length to read the required " ++ "bytes"); ++ return -1; ++ } ++ ++ imgFile.seekg(0, std::ios::beg); ++ ++ std::array buffer = {}; ++ ++ imgFile.read( ++ buffer.data(), ++ buffer.size()); // read 36 bytes of PLDM Package Header ++ ++ if (!imgFile.good()) ++ { ++ phosphor::logging::log( ++ "Image file read is not successful"); ++ return -1; ++ } ++ ++ if (!std::equal(buffer.begin(), ++ buffer.begin() + pldm::headerIdLen, ++ pldm::pldmPkgHeaderId ++ .begin())) // comparing 16 bytes of ++ // PackageHeaderIdentifier field ++ { ++ std::string redfishMsgID = ++ "OpenBMC.0.1.FirmwareUpdateFailed"; ++ sd_journal_send( ++ "MESSAGE=%s", "Firmware image verification failed", ++ "PRIORITY=%i", LOG_ERR, "REDFISH_MESSAGE_ID=%s", ++ redfishMsgID.c_str(), "REDFISH_MESSAGE_ARGS=%s", ++ "PLDM Image package header identifier check fail", ++ NULL); ++ ++ return -1; ++ } ++ ++ phosphor::logging::log( ++ "Package header identifier matched"); ++ purposeString = ++ "xyz.openbmc_project.Software.Version.VersionPurpose.PLDM"; ++ ++ const uint8_t pkgVerStrLen = static_cast( ++ buffer[35]); // PackageVersionStringLen byte ++ ++ imgFile.seekg(readBytes, ++ std::ios::beg); // point to the begin of ++ // PackageVersionString field ++ // i.e. 36th pos ++ ++ std::array ver = {}; ++ imgFile.read(ver.data(), ++ pkgVerStrLen); // read PackageVersionString bytes ++ ++ if (!imgFile.good()) ++ { ++ phosphor::logging::log( ++ "Image file read is not successful"); ++ return -1; ++ } ++ ++ version.assign(ver.data(), pkgVerStrLen); ++ phosphor::logging::log( ++ "Package version string value", ++ phosphor::logging::entry("IMAGE_VERSION=%s", ++ version.c_str())); ++ ++ imgFile.close(); ++ return 0; ++ } ++ + if (imgMagic != block0Magic) + { + phosphor::logging::log( +@@ -226,7 +315,7 @@ int Manager::processImage(const std::string& imgFilePath) + std::string ver; + std::string purposeString; + +- if (0 != verifyPFRImage(imgFilePath, ver, purposeString)) ++ if (0 != verifyImage(imgFilePath, ver, purposeString)) + { + phosphor::logging::log( + "Error verifying uploaded image"); +diff --git a/pfr_image_manager.hpp b/pfr_image_manager.hpp +index 3591f1a..2facfe6 100644 +--- a/pfr_image_manager.hpp ++++ b/pfr_image_manager.hpp +@@ -156,13 +156,13 @@ class Manager + CustomMap mapFile(const std::filesystem::path& path, size_t size); + + /** +- * @brief Verify the PFR image and return version and purpose ++ * @brief Verify the uploaded image type and return version and purpose + * @param[in] - file path + * @param[out] - version + * @param[out] - purpose + */ +- int verifyPFRImage(const std::filesystem::path imgPath, +- std::string& version, std::string& purposeString); ++ int verifyImage(const std::filesystem::path imgPath, std::string& version, ++ std::string& purposeString); + /** @brief Persistent map of Version dbus objects and their + * version id */ + std::map> versions; +diff --git a/pldm.hpp b/pldm.hpp +new file mode 100644 +index 0000000..edbd6ae +--- /dev/null ++++ b/pldm.hpp +@@ -0,0 +1,21 @@ ++namespace pldm ++{ ++ ++struct PldmPkgHeader ++{ ++ uint8_t uuid[16]; // PackageHeaderIdentifier ++ uint8_t formatRev; // PackageHeaderFormatRevision ++ uint16_t headerSize; // PackageHeaderSize ++ uint8_t timestamp[13]; // PackageReleaseDateTime ++ uint16_t bitmapLen; // ComponentBitmapBitLength ++ uint8_t verStringType; // PackageVersionStringType ++ uint8_t verStringLen; // PackageVersionStringLength ++} __attribute__((packed)); ++ ++constexpr size_t headerIdLen = 16; ++ ++const std::array pldmPkgHeaderId = { ++ 0xF0, 0x18, 0x87, 0x8C, 0xCB, 0x7D, 0x49, 0x43, ++ 0x98, 0x00, 0xA0, 0x2F, 0x05, 0x9A, 0xCA, 0x02}; // 16 bytes package header ++ // identifier uuid ++} // namespace pldm +-- +2.17.1 + -- cgit v1.2.3