From 1bdf613b1d364b97fed62da60c52062732b5c8d2 Mon Sep 17 00:00:00 2001 From: Joel Kitching Date: Fri, 6 Dec 2019 17:21:45 +0800 Subject: vboot: remove VbExOverrideGptEntryPriority This function was added with the sole intended user being BCB support on the depthcharge side. Now that BCB is deprecated, we can remove it. BUG=b:124141368, chromium:956474 TEST=make clean && make runtests BRANCH=none Change-Id: I4a99c540951b5e160bf50bcb790091d1df6eefc3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1954975 Tested-by: Joel Kitching Reviewed-by: Julius Werner Commit-Queue: Joel Kitching Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1986996 Reviewed-by: Shelley Chen Commit-Queue: Shelley Chen Tested-by: Shelley Chen --- firmware/include/vboot_api.h | 13 ----- firmware/lib/cgptlib/cgptlib_internal.c | 6 --- firmware/stub/vboot_api_stub.c | 5 -- tests/cgptlib_test.c | 85 +-------------------------------- 4 files changed, 1 insertion(+), 108 deletions(-) diff --git a/firmware/include/vboot_api.h b/firmware/include/vboot_api.h index 455c3dcc..62fd32fe 100644 --- a/firmware/include/vboot_api.h +++ b/firmware/include/vboot_api.h @@ -765,19 +765,6 @@ enum vb_firmware_region { VB_REGION_COUNT, }; -/** - * Check if the firmware wants to override GPT entry priority. - * - * In case of kernel entry, check if there is an override of priority - * available. This is used to select a particular partition to boot in the - * current boot cycle. Rollback protection, image verification and all other - * checks in LoadKernel still remain the same. - * - * @param e Gpt Entry to check for priority override. - * @return 0 if no override, 1-15 for override priority. - */ -uint8_t VbExOverrideGptEntryPriority(const GptEntry *e); - /** * Return number of locales supported * diff --git a/firmware/lib/cgptlib/cgptlib_internal.c b/firmware/lib/cgptlib/cgptlib_internal.c index f4d1c1ec..7d214a91 100644 --- a/firmware/lib/cgptlib/cgptlib_internal.c +++ b/firmware/lib/cgptlib/cgptlib_internal.c @@ -396,12 +396,6 @@ int GetEntrySuccessful(const GptEntry *e) int GetEntryPriority(const GptEntry *e) { - int ret = VbExOverrideGptEntryPriority(e); - - /* Ensure that the override priority is valid. */ - if ((ret > 0) && (ret < 16)) - return ret; - return (e->attrs.fields.gpt_att & CGPT_ATTRIBUTE_PRIORITY_MASK) >> CGPT_ATTRIBUTE_PRIORITY_OFFSET; } diff --git a/firmware/stub/vboot_api_stub.c b/firmware/stub/vboot_api_stub.c index 54ba130d..d00229c2 100644 --- a/firmware/stub/vboot_api_stub.c +++ b/firmware/stub/vboot_api_stub.c @@ -141,11 +141,6 @@ vb2_error_t VbExLegacy(enum VbAltFwIndex_t altfw_num) return 1; } -uint8_t VbExOverrideGptEntryPriority(const GptEntry *e) -{ - return 0; -} - vb2_error_t VbExSetVendorData(const char *vendor_data_value) { return 0; diff --git a/tests/cgptlib_test.c b/tests/cgptlib_test.c index 821ffb13..ee7cb9da 100644 --- a/tests/cgptlib_test.c +++ b/tests/cgptlib_test.c @@ -52,18 +52,6 @@ static const Guid guid_rootfs = GPT_ENT_TYPE_CHROMEOS_ROOTFS; const char *progname = "CGPT-TEST"; const char *command = "TEST"; -static int override_priority = 0; -static int override_counter = 0; - -uint8_t VbExOverrideGptEntryPriority(const GptEntry *e) -{ - if (override_counter == 0) - return override_priority; - - override_counter--; - return 0; -} - /* * Copy a random-for-this-program-only Guid into the dest. The num parameter * completely determines the Guid. @@ -1187,31 +1175,12 @@ static int EntryAttributeGetSetTest(void) EXPECT(0xFFF0FFFFFFFFFFFFULL == e->attrs.whole); EXPECT(0 == GetEntryPriority(e)); - e->attrs.whole = 0x0000000000000000ULL; - SetEntryPriority(e, 15); - override_priority = 10; - EXPECT(0x000F000000000000ULL == e->attrs.whole); - EXPECT(10 == GetEntryPriority(e)); - e->attrs.whole = 0xFFFFFFFFFFFFFFFFULL; - SetEntryPriority(e, 0); - EXPECT(0xFFF0FFFFFFFFFFFFULL == e->attrs.whole); - EXPECT(10 == GetEntryPriority(e)); - override_priority = 0; - - e->attrs.whole = 0xFFFFFFFFFFFFFFFFULL; - EXPECT(1 == GetEntryLegacyBoot(e)); - EXPECT(1 == GetEntrySuccessful(e)); - EXPECT(15 == GetEntryPriority(e)); - EXPECT(15 == GetEntryTries(e)); - - override_priority = 10; e->attrs.whole = 0xFFFFFFFFFFFFFFFFULL; EXPECT(1 == GetEntryRequired(e)); EXPECT(1 == GetEntryLegacyBoot(e)); EXPECT(1 == GetEntrySuccessful(e)); - EXPECT(10 == GetEntryPriority(e)); + EXPECT(15 == GetEntryPriority(e)); EXPECT(15 == GetEntryTries(e)); - override_priority = 0; e->attrs.whole = 0x0123000000000004ULL; EXPECT(0 == GetEntryRequired(e)); @@ -1220,25 +1189,6 @@ static int EntryAttributeGetSetTest(void) EXPECT(2 == GetEntryTries(e)); EXPECT(3 == GetEntryPriority(e)); - override_priority = 10; - e->attrs.whole = 0x0123000000000004ULL; - EXPECT(0 == GetEntryRequired(e)); - EXPECT(1 == GetEntryLegacyBoot(e)); - EXPECT(1 == GetEntrySuccessful(e)); - EXPECT(2 == GetEntryTries(e)); - EXPECT(10 == GetEntryPriority(e)); - override_priority = 0; - - /* Invalid priority */ - override_priority = 100; - e->attrs.whole = 0x0123000000000004ULL; - EXPECT(0 == GetEntryRequired(e)); - EXPECT(1 == GetEntryLegacyBoot(e)); - EXPECT(1 == GetEntrySuccessful(e)); - EXPECT(2 == GetEntryTries(e)); - EXPECT(3 == GetEntryPriority(e)); - override_priority = 0; - return TEST_OK; } @@ -1472,38 +1422,6 @@ static int GptUpdateTest(void) return TEST_OK; } -static int GptOverridePriorityTest(void) -{ - GptData *gpt = GetEmptyGptData(); - GptEntry *e = (GptEntry *)(gpt->primary_entries); - uint64_t start, size; - - /* Tries=nonzero is attempted just like success, but tries=0 isn't */ - BuildTestGptData(gpt); - FillEntry(e + KERNEL_A, 1, 4, 1, 0); - FillEntry(e + KERNEL_B, 1, 3, 0, 2); - FillEntry(e + KERNEL_X, 1, 2, 0, 2); - RefreshCrc32(gpt); - GptInit(gpt); - gpt->modified = 0; /* Nothing modified yet */ - - override_counter = 1; - override_priority = 15; - - /* Kernel returned should be B instead of A */ - EXPECT(GPT_SUCCESS == GptNextKernelEntry(gpt, &start, &size)); - EXPECT(KERNEL_B == gpt->current_kernel); - - override_counter = 0; - override_priority = 0; - - /* Now, we should get A */ - EXPECT(GPT_SUCCESS == GptNextKernelEntry(gpt, &start, &size)); - EXPECT(KERNEL_A == gpt->current_kernel); - - return TEST_OK; -} - /* * Give an invalid kernel type, and expect GptUpdateKernelEntry() returns * GPT_ERROR_INVALID_UPDATE_TYPE. @@ -1711,7 +1629,6 @@ int main(int argc, char *argv[]) { TEST_CASE(GetNextPrioTest), }, { TEST_CASE(GetNextTriesTest), }, { TEST_CASE(GptUpdateTest), }, - { TEST_CASE(GptOverridePriorityTest), }, { TEST_CASE(UpdateInvalidKernelTypeTest), }, { TEST_CASE(DuplicateUniqueGuidTest), }, { TEST_CASE(TestCrc32TestVectors), }, -- cgit v1.2.1