diff options
author | Cyril Bur <cyril.bur@au1.ibm.com> | 2016-01-07 14:33:59 +1100 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2016-01-15 14:46:24 +1100 |
commit | 91cebdcd557dfc2dfc8050a34edb11a43facaf74 (patch) | |
tree | 8ac77625f3886a9cbeefa3f0b69cade98465c8e6 | |
parent | 09d10f9c6146f67d0b3f897a6249990b69f686b9 (diff) | |
download | skiboot-91cebdcd557dfc2dfc8050a34edb11a43facaf74.zip skiboot-91cebdcd557dfc2dfc8050a34edb11a43facaf74.tar.gz skiboot-91cebdcd557dfc2dfc8050a34edb11a43facaf74.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.
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
Reviewed-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
-rw-r--r-- | external/gard/gard.c | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/external/gard/gard.c b/external/gard/gard.c index 0b7a68b..53f31d9 100644 --- a/external/gard/gard.c +++ b/external/gard/gard.c @@ -41,6 +41,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" @@ -226,6 +228,11 @@ static const char *path_type_to_str(enum path_type t) return "Unknown"; } +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), @@ -272,13 +279,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; } @@ -288,7 +318,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 { |