From 257eccc7ec0ddb3172ae8120a949ca66eda7d211 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 dd78e7f184f..8b8e5e6002c 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 73b9078c8c6..b44c638cbf6 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 e6b9b7f2b20..36b1d69b374 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) {