Subrata Banik has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/86164?usp=email )
Change subject: soc/intel: Add check to pmc_/gpe0_different_values ......................................................................
soc/intel: Add check to pmc_/gpe0_different_values
The pmc_/gpe0_different_values function previously only checked if the dw0, dw1, and dw2 values were different from each other. This commit adds a check to ensure that the values are not all zero, as this can represent an invalid configuration.
This prevents potential issues arising from a zeroed configuration by ensuring the assertion only passes if the values are different and at least one of them is non-zero.
TEST=Built and booted normally. No assertion failure observed.
Change-Id: Ie66d6dbcf49d5400b3fc3e4da113a569fe52dd51 Signed-off-by: Subrata Banik subratabanik@google.com --- M src/soc/intel/alderlake/pmutil.c M src/soc/intel/apollolake/pmutil.c M src/soc/intel/cannonlake/pmutil.c M src/soc/intel/elkhartlake/pmutil.c M src/soc/intel/jasperlake/pmutil.c M src/soc/intel/meteorlake/pmutil.c M src/soc/intel/pantherlake/pmutil.c M src/soc/intel/skylake/pmutil.c M src/soc/intel/tigerlake/pmutil.c 9 files changed, 68 insertions(+), 14 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/64/86164/1
diff --git a/src/soc/intel/alderlake/pmutil.c b/src/soc/intel/alderlake/pmutil.c index 60d6e10..3dc25af 100644 --- a/src/soc/intel/alderlake/pmutil.c +++ b/src/soc/intel/alderlake/pmutil.c @@ -156,9 +156,15 @@
static void pmc_gpe0_different_values(const struct soc_intel_alderlake_config *config) { + bool all_zero = (config->pmc_gpe0_dw0 == 0) && + (config->pmc_gpe0_dw1 == 0) && + (config->pmc_gpe0_dw2 == 0); + + /* Check if all values are different AND not all zero */ bool result = (config->pmc_gpe0_dw0 != config->pmc_gpe0_dw1) && (config->pmc_gpe0_dw0 != config->pmc_gpe0_dw2) && - (config->pmc_gpe0_dw1 != config->pmc_gpe0_dw2); + (config->pmc_gpe0_dw1 != config->pmc_gpe0_dw2) && + !all_zero;
assert(result); } diff --git a/src/soc/intel/apollolake/pmutil.c b/src/soc/intel/apollolake/pmutil.c index 5366ca8..9ed39f5 100644 --- a/src/soc/intel/apollolake/pmutil.c +++ b/src/soc/intel/apollolake/pmutil.c @@ -140,9 +140,15 @@
static void gpe0_different_values(const struct soc_intel_apollolake_config *config) { + bool all_zero = (config->gpe0_dw1 == 0) && + (config->gpe0_dw2 == 0) && + (config->gpe0_dw3 == 0); + + /* Check if all values are different AND not all zero */ bool result = (config->gpe0_dw1 != config->gpe0_dw2) && (config->gpe0_dw1 != config->gpe0_dw3) && - (config->gpe0_dw2 != config->gpe0_dw3); + (config->gpe0_dw2 != config->gpe0_dw3) && + !all_zero;
assert(result); } diff --git a/src/soc/intel/cannonlake/pmutil.c b/src/soc/intel/cannonlake/pmutil.c index 63eed16..43595a3 100644 --- a/src/soc/intel/cannonlake/pmutil.c +++ b/src/soc/intel/cannonlake/pmutil.c @@ -150,9 +150,15 @@
static void gpe0_different_values(const struct soc_intel_cannonlake_config *config) { + bool all_zero = (config->gpe0_dw0 == 0) && + (config->gpe0_dw1 == 0) && + (config->gpe0_dw2 == 0); + + /* Check if all values are different AND not all zero */ bool result = (config->gpe0_dw0 != config->gpe0_dw1) && (config->gpe0_dw0 != config->gpe0_dw2) && - (config->gpe0_dw1 != config->gpe0_dw2); + (config->gpe0_dw1 != config->gpe0_dw2) && + !all_zero;
assert(result); } diff --git a/src/soc/intel/elkhartlake/pmutil.c b/src/soc/intel/elkhartlake/pmutil.c index a862bdd..ec0a249 100644 --- a/src/soc/intel/elkhartlake/pmutil.c +++ b/src/soc/intel/elkhartlake/pmutil.c @@ -147,11 +147,17 @@ return (uint32_t *)(soc_read_pmc_base() + ETR); }
-static void pmc_gpe0_different_values(const struct soc_intel_elkhartlake_config *config) +static void pmc_gpe0_different_values(const struct soc_intel_alderlake_config *config) { + bool all_zero = (config->pmc_gpe0_dw0 == 0) && + (config->pmc_gpe0_dw1 == 0) && + (config->pmc_gpe0_dw2 == 0); + + /* Check if all values are different AND not all zero */ bool result = (config->pmc_gpe0_dw0 != config->pmc_gpe0_dw1) && (config->pmc_gpe0_dw0 != config->pmc_gpe0_dw2) && - (config->pmc_gpe0_dw1 != config->pmc_gpe0_dw2); + (config->pmc_gpe0_dw1 != config->pmc_gpe0_dw2) && + !all_zero;
assert(result); } diff --git a/src/soc/intel/jasperlake/pmutil.c b/src/soc/intel/jasperlake/pmutil.c index 569eac7..fb8b173 100644 --- a/src/soc/intel/jasperlake/pmutil.c +++ b/src/soc/intel/jasperlake/pmutil.c @@ -147,11 +147,17 @@ return (uint32_t *)(soc_read_pmc_base() + ETR); }
-static void pmc_gpe0_different_values(const struct soc_intel_jasperlake_config *config) +static void pmc_gpe0_different_values(const struct soc_intel_alderlake_config *config) { + bool all_zero = (config->pmc_gpe0_dw0 == 0) && + (config->pmc_gpe0_dw1 == 0) && + (config->pmc_gpe0_dw2 == 0); + + /* Check if all values are different AND not all zero */ bool result = (config->pmc_gpe0_dw0 != config->pmc_gpe0_dw1) && (config->pmc_gpe0_dw0 != config->pmc_gpe0_dw2) && - (config->pmc_gpe0_dw1 != config->pmc_gpe0_dw2); + (config->pmc_gpe0_dw1 != config->pmc_gpe0_dw2) && + !all_zero;
assert(result); } diff --git a/src/soc/intel/meteorlake/pmutil.c b/src/soc/intel/meteorlake/pmutil.c index 154c3be..93a84dc 100644 --- a/src/soc/intel/meteorlake/pmutil.c +++ b/src/soc/intel/meteorlake/pmutil.c @@ -150,11 +150,17 @@ return (uint32_t *)(soc_read_pmc_base() + ETR); }
-static void pmc_gpe0_different_values(const struct soc_intel_meteorlake_config *config) +static void pmc_gpe0_different_values(const struct soc_intel_alderlake_config *config) { + bool all_zero = (config->pmc_gpe0_dw0 == 0) && + (config->pmc_gpe0_dw1 == 0) && + (config->pmc_gpe0_dw2 == 0); + + /* Check if all values are different AND not all zero */ bool result = (config->pmc_gpe0_dw0 != config->pmc_gpe0_dw1) && (config->pmc_gpe0_dw0 != config->pmc_gpe0_dw2) && - (config->pmc_gpe0_dw1 != config->pmc_gpe0_dw2); + (config->pmc_gpe0_dw1 != config->pmc_gpe0_dw2) && + !all_zero;
assert(result); } diff --git a/src/soc/intel/pantherlake/pmutil.c b/src/soc/intel/pantherlake/pmutil.c index 306d834..2fce050 100644 --- a/src/soc/intel/pantherlake/pmutil.c +++ b/src/soc/intel/pantherlake/pmutil.c @@ -145,11 +145,17 @@ return (uint32_t *)(soc_read_pmc_base() + ETR); }
-static void pmc_gpe0_different_values(const struct soc_intel_pantherlake_config *config) +static void pmc_gpe0_different_values(const struct soc_intel_alderlake_config *config) { + bool all_zero = (config->pmc_gpe0_dw0 == 0) && + (config->pmc_gpe0_dw1 == 0) && + (config->pmc_gpe0_dw2 == 0); + + /* Check if all values are different AND not all zero */ bool result = (config->pmc_gpe0_dw0 != config->pmc_gpe0_dw1) && (config->pmc_gpe0_dw0 != config->pmc_gpe0_dw2) && - (config->pmc_gpe0_dw1 != config->pmc_gpe0_dw2); + (config->pmc_gpe0_dw1 != config->pmc_gpe0_dw2) && + !all_zero;
assert(result); } diff --git a/src/soc/intel/skylake/pmutil.c b/src/soc/intel/skylake/pmutil.c index ed1ab8b..212cbe5 100644 --- a/src/soc/intel/skylake/pmutil.c +++ b/src/soc/intel/skylake/pmutil.c @@ -156,9 +156,15 @@
static void gpe0_different_values(const struct soc_intel_skylake_config *config) { + bool all_zero = (config->gpe0_dw0 == 0) && + (config->gpe0_dw1 == 0) && + (config->gpe0_dw2 == 0); + + /* Check if all values are different AND not all zero */ bool result = (config->gpe0_dw0 != config->gpe0_dw1) && (config->gpe0_dw0 != config->gpe0_dw2) && - (config->gpe0_dw1 != config->gpe0_dw2); + (config->gpe0_dw1 != config->gpe0_dw2) && + !all_zero;
assert(result); } diff --git a/src/soc/intel/tigerlake/pmutil.c b/src/soc/intel/tigerlake/pmutil.c index 7903264..151870b 100644 --- a/src/soc/intel/tigerlake/pmutil.c +++ b/src/soc/intel/tigerlake/pmutil.c @@ -153,11 +153,17 @@ return (uint32_t *)(soc_read_pmc_base() + ETR); }
-static void pmc_gpe0_different_values(const struct soc_intel_tigerlake_config *config) +static void pmc_gpe0_different_values(const struct soc_intel_alderlake_config *config) { + bool all_zero = (config->pmc_gpe0_dw0 == 0) && + (config->pmc_gpe0_dw1 == 0) && + (config->pmc_gpe0_dw2 == 0); + + /* Check if all values are different AND not all zero */ bool result = (config->pmc_gpe0_dw0 != config->pmc_gpe0_dw1) && (config->pmc_gpe0_dw0 != config->pmc_gpe0_dw2) && - (config->pmc_gpe0_dw1 != config->pmc_gpe0_dw2); + (config->pmc_gpe0_dw1 != config->pmc_gpe0_dw2) && + !all_zero;
assert(result); }