aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyril Bur <cyril.bur@au1.ibm.com>2016-01-14 18:08:30 +1100
committerStewart Smith <stewart@linux.vnet.ibm.com>2016-01-15 14:48:28 +1100
commitc80260e5ef3c780f2b6006fb4e50aaae2089d56f (patch)
tree8dcaf0e62a7cef50a2c01a27c4473e77b13fc230
parent343efe30a3139d030e89ec071b432c8fc1e8b1b6 (diff)
downloadskiboot-c80260e5ef3c780f2b6006fb4e50aaae2089d56f.zip
skiboot-c80260e5ef3c780f2b6006fb4e50aaae2089d56f.tar.gz
skiboot-c80260e5ef3c780f2b6006fb4e50aaae2089d56f.tar.bz2
external/gard: Fix displaying 'cleared' gard records
When a garded component is replaced hostboot detects this and updates the gard partition. What hostboot does is set the record_id field to 0xFFFFFFFF but leaves the rest of the flash untouched, this has caused issues with the gard tool the thinking was that an entire record of all 0xFF bytes would signal not a valid record. This patch add rectifies this issue and `gard list` will no longer show any record with an id of 0xFFFFFFFF. Equivalent to 91cebdcd557dfc2dfc8050a34edb11a43facaf74 in master Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
-rw-r--r--external/gard/gard.c36
1 files changed, 33 insertions, 3 deletions
diff --git a/external/gard/gard.c b/external/gard/gard.c
index 01488e3..869ada0 100644
--- a/external/gard/gard.c
+++ b/external/gard/gard.c
@@ -40,6 +40,8 @@
#include "gard.h"
+#define CLEARED_RECORD_ID 0xFFFFFFFF
+
#define FDT_ACTIVE_FLASH_PATH "/proc/device-tree/chosen/ibm,system-flash"
#define SYSFS_MTD_PATH "/sys/class/mtd/"
#define FLASH_GARD_PART "GUARD"
@@ -359,6 +361,11 @@ static int get_dev_mtd(const char *fdt_flash_path, char **r_path)
return done ? rc : -1;
}
+static bool is_valid_id(uint32_t record_id)
+{
+ return record_id != CLEARED_RECORD_ID;
+}
+
static int do_iterate(struct gard_ctx *ctx,
int (*func)(struct gard_ctx *ctx, int pos,
struct gard_record *gard, void *priv),
@@ -405,13 +412,36 @@ static int get_largest_pos(struct gard_ctx *ctx)
return largest;
}
+static int count_valid_records_i(struct gard_ctx *ctx, int pos, struct gard_record *gard, void *priv)
+{
+ if (!gard || !priv)
+ return -1;
+
+ if (is_valid_id(be32toh(gard->record_id)))
+ (*(int *)priv)++;
+
+ return 0;
+}
+
+static int count_valid_records(struct gard_ctx *ctx)
+{
+ int rc, count = 0;
+
+ rc = do_iterate(ctx, &count_valid_records_i, &count);
+ if (rc)
+ return 0;
+
+ return count;
+}
+
static int do_list_i(struct gard_ctx *ctx, int pos, struct gard_record *gard, void *priv)
{
if (!gard)
return -1;
- printf("| %08x | %08x | %-15s |\n", be32toh(gard->record_id),
- be32toh(gard->errlog_eid), path_type_to_str(gard->target_id.type_size >> PATH_TYPE_SHIFT));
+ if (is_valid_id(be32toh(gard->record_id)))
+ printf("| %08x | %08x | %-15s |\n", be32toh(gard->record_id), be32toh(gard->errlog_eid),
+ path_type_to_str(gard->target_id.type_size >> PATH_TYPE_SHIFT));
return 0;
}
@@ -421,7 +451,7 @@ static int do_list(struct gard_ctx *ctx, int argc, char **argv)
int rc;
/* No entries */
- if (get_largest_pos(ctx) == -1) {
+ if (count_valid_records(ctx) == 0) {
printf("No GARD entries to display\n");
rc = 0;
} else {