vpnor: gracefully handle missing HBB partition

The first thing the virtual pnor enabled mboxd does is look for the host
boot-loader partition. Not finding the same would result in an exception
that was not handled, and hence mboxd would core. Commit this exception
instead; mboxd still won't be able to load the host bootloader if HBB is
missing.

Change-Id: I9cd4fe74238267ed9d6635d84298da38ac3c36cc
Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
diff --git a/mboxd_pnor_partition_table.cpp b/mboxd_pnor_partition_table.cpp
index e2125da..4837aa3 100644
--- a/mboxd_pnor_partition_table.cpp
+++ b/mboxd_pnor_partition_table.cpp
@@ -4,6 +4,8 @@
 #include "mboxd_flash.h"
 #include "pnor_partition_table.hpp"
 #include "config.h"
+#include "xyz/openbmc_project/Common/error.hpp"
+#include <phosphor-logging/elog-errors.hpp>
 #include <experimental/filesystem>
 
 struct vpnor_partition_table
@@ -92,16 +94,25 @@
 
     size_t tocOffset = 0;
     uint32_t tocSize = blTable.size() * eraseSize;
-    // Copy TOC
-    copy_flash(&local, tocOffset,
-               static_cast<uint8_t*>(context->mem) + tocStart,
-               tocSize);
-    const pnor_partition& partition = blTable.partition(blPartitionName);
-    size_t hbbOffset = partition.data.base * eraseSize;
-    uint32_t hbbSize = partition.data.actual;
-    // Copy HBB
-    copy_flash(&local, hbbOffset,
-               static_cast<uint8_t*>(context->mem) + hbbOffset, hbbSize);
+    using namespace phosphor::logging;
+    using namespace sdbusplus::xyz::openbmc_project::Common::Error;
+    try
+    {
+        // Copy TOC
+        copy_flash(&local, tocOffset,
+                   static_cast<uint8_t*>(context->mem) + tocStart,
+                   tocSize);
+        const pnor_partition& partition = blTable.partition(blPartitionName);
+        size_t hbbOffset = partition.data.base * eraseSize;
+        uint32_t hbbSize = partition.data.actual;
+        // Copy HBB
+        copy_flash(&local, hbbOffset,
+                   static_cast<uint8_t*>(context->mem) + hbbOffset, hbbSize);
+    }
+    catch (InternalFailure& e)
+    {
+        commit<InternalFailure>();
+    }
 }
 
 void destroy_vpnor(struct mbox_context *context)