From 55657f5f22591fe4abe63060cbbbfda22e22aae5 Mon Sep 17 00:00:00 2001 From: "harshal.patil" Date: Fri, 27 Mar 2026 20:30:10 +0530 Subject: [PATCH] fix(cpu_region_protect): Fix incorrect definition of ALIGN_UP macro --- components/esp_hw_support/port/esp32c5/cpu_region_protect.c | 2 +- components/esp_hw_support/port/esp32c61/cpu_region_protect.c | 2 +- components/esp_hw_support/port/esp32p4/cpu_region_protect.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/esp_hw_support/port/esp32c5/cpu_region_protect.c b/components/esp_hw_support/port/esp32c5/cpu_region_protect.c index 5d2ccd14bff..d4e7dbe5b7f 100644 --- a/components/esp_hw_support/port/esp32c5/cpu_region_protect.c +++ b/components/esp_hw_support/port/esp32c5/cpu_region_protect.c @@ -29,7 +29,7 @@ #define ALIGN_UP_TO_MMU_PAGE_SIZE(addr) (((addr) + (SOC_MMU_PAGE_SIZE) - 1) & ~((SOC_MMU_PAGE_SIZE) - 1)) #define ALIGN_DOWN_TO_MMU_PAGE_SIZE(addr) ((addr) & ~((SOC_MMU_PAGE_SIZE) - 1)) -#define ALIGN_UP(addr, align) ((addr) & ~((align) - 1)) +#define ALIGN_UP(addr, align) (((addr) + (align) - 1) & ~((align) - 1)) static void esp_cpu_configure_invalid_regions(void) { diff --git a/components/esp_hw_support/port/esp32c61/cpu_region_protect.c b/components/esp_hw_support/port/esp32c61/cpu_region_protect.c index 080a56a24fb..0369f214071 100644 --- a/components/esp_hw_support/port/esp32c61/cpu_region_protect.c +++ b/components/esp_hw_support/port/esp32c61/cpu_region_protect.c @@ -30,7 +30,7 @@ #define ALIGN_UP_TO_MMU_PAGE_SIZE(addr) (((addr) + (SOC_MMU_PAGE_SIZE) - 1) & ~((SOC_MMU_PAGE_SIZE) - 1)) #define ALIGN_DOWN_TO_MMU_PAGE_SIZE(addr) ((addr) & ~((SOC_MMU_PAGE_SIZE) - 1)) -#define ALIGN_UP(addr, align) ((addr) & ~((align) - 1)) +#define ALIGN_UP(addr, align) (((addr) + (align) - 1) & ~((align) - 1)) static void esp_cpu_configure_invalid_regions(void) { diff --git a/components/esp_hw_support/port/esp32p4/cpu_region_protect.c b/components/esp_hw_support/port/esp32p4/cpu_region_protect.c index ab7cebf2a02..e2cbbb4b008 100644 --- a/components/esp_hw_support/port/esp32p4/cpu_region_protect.c +++ b/components/esp_hw_support/port/esp32p4/cpu_region_protect.c @@ -36,7 +36,7 @@ #define ALIGN_UP_TO_MMU_PAGE_SIZE(addr) (((addr) + (SOC_MMU_PAGE_SIZE) - 1) & ~((SOC_MMU_PAGE_SIZE) - 1)) #define ALIGN_DOWN_TO_MMU_PAGE_SIZE(addr) ((addr) & ~((SOC_MMU_PAGE_SIZE) - 1)) -#define ALIGN_UP(addr, align) ((addr) & ~((align) - 1)) +#define ALIGN_UP(addr, align) (((addr) + (align) - 1) & ~((align) - 1)) static void esp_cpu_configure_invalid_regions(void) {