From 97924e4521dbc1002f7b13302fd350c00da36b27 Mon Sep 17 00:00:00 2001 From: Dan Handley Date: Tue, 27 Feb 2018 13:00:43 +0000 Subject: [PATCH 1/3] Suppress spurious deprecated declaration warnings Some generic compatibility functions emit deprecated declaration warnings even when platforms do not use the deprecated functions directly. This can be confusing. Suppress these warnings by using: `#pragma GCC diagnostic ignored "-Wdeprecated-declarations"` Also emit a runtime warning if the weak plat/common implemntation of plat_get_syscnt_freq2() is used, as this implies the platform has not migrated from plat_get_syscnt_freq(). The deprecated declaration warnings only help detect when platforms are calling deprecated functions, not when they are defining deprecated functions. Fixes ARM-software/tf-issues#550 Change-Id: Id14a92279c2634c1e76db8ef210da8affdbb2a5d Signed-off-by: Dan Handley --- bl31/bl31_context_mgmt.c | 24 ++++++++++++++++++++++-- plat/common/aarch64/plat_common.c | 8 ++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/bl31/bl31_context_mgmt.c b/bl31/bl31_context_mgmt.c index 123e623c5..7d2c89385 100644 --- a/bl31/bl31_context_mgmt.c +++ b/bl31/bl31_context_mgmt.c @@ -79,7 +79,13 @@ void *cm_get_context_by_mpidr(uint64_t mpidr, uint32_t security_state) { assert(sec_state_is_valid(security_state)); + /* + * Suppress deprecated declaration warning in compatibility function + */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" return cm_get_context_by_index(platform_get_core_pos(mpidr), security_state); +#pragma GCC diagnostic pop } /******************************************************************************* @@ -90,8 +96,14 @@ void cm_set_context_by_mpidr(uint64_t mpidr, void *context, uint32_t security_st { assert(sec_state_is_valid(security_state)); + /* + * Suppress deprecated declaration warning in compatibility function + */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" cm_set_context_by_index(platform_get_core_pos(mpidr), context, security_state); +#pragma GCC diagnostic pop } /******************************************************************************* @@ -104,7 +116,15 @@ void cm_init_context(uint64_t mpidr, const entry_point_info_t *ep) if ((mpidr & MPIDR_AFFINITY_MASK) == (read_mpidr_el1() & MPIDR_AFFINITY_MASK)) cm_init_my_context(ep); - else + else { + /* + * Suppress deprecated declaration warning in compatibility + * function + */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" cm_init_context_by_index(platform_get_core_pos(mpidr), ep); +#pragma GCC diagnostic pop + } } -#endif +#endif /* ERROR_DEPRECATED */ diff --git a/plat/common/aarch64/plat_common.c b/plat/common/aarch64/plat_common.c index 080d35698..ddd29f29b 100644 --- a/plat/common/aarch64/plat_common.c +++ b/plat/common/aarch64/plat_common.c @@ -65,7 +65,15 @@ unsigned int platform_core_pos_helper(unsigned long mpidr) #if !ERROR_DEPRECATED unsigned int plat_get_syscnt_freq2(void) { + WARN("plat_get_syscnt_freq() is deprecated\n"); + WARN("Please define plat_get_syscnt_freq2()\n"); + /* + * Suppress deprecated declaration warning in compatibility function + */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" unsigned long long freq = plat_get_syscnt_freq(); +#pragma GCC diagnostic pop assert(freq >> 32 == 0); From bc1a03c7a6db40a1ab86192675aa47d17afb7f4c Mon Sep 17 00:00:00 2001 From: Dan Handley Date: Tue, 27 Feb 2018 16:03:58 +0000 Subject: [PATCH 2/3] Improve MULTI_CONSOLE_API deprecation warnings For platforms that have not migrated to MULTI_CONSOLE_API == 1, there are a lot of confusing deprecated declaration warnings relating to use of console_init() and console_uninit(). Some of these relate to use by the generic code, not the platform code. These functions are not really deprecated but *removed* when MULTI_CONSOLE_API == 1. This patch consolidates these warnings into a single preprocessor warning. The __deprecated attribute is removed from the console_init() and console_uninit() declarations. For preprocessor warnings like this to not cause fatal build errors, this patch adds -Wno-error=cpp to the build flags when ERROR_DEPRECATED == 0. This option (and -Wno-error=deprecated-declarations) is now added to CPPFLAGS instead of TF_CFLAGS to ensure the build flags are used in the assembler as well as the compiler. This patch also disentangles the MULTI_CONSOLE_API and ERROR_DEPRECATED build flags by defaulting MULTI_CONSOLE_API to 0 instead of ERROR_DEPRECATED. This allows platforms that have not migrated to MULTI_CONSOLE_API to use ERROR_DEPRECATED == 1 to emit a more meaningful build error. Finally, this patch bans use of MULTI_CONSOLE_API == 1 and AARCH32, since the AArch32 console implementation does not support MULTI_CONSOLE_API == 1. Change-Id: If762165ddcb90c28aa7a4951aba70cb15c2b709c Signed-off-by: Dan Handley --- Makefile | 10 ++++++++-- drivers/console/aarch64/deprecated_console.S | 3 ++- include/drivers/console.h | 8 ++++---- make_helpers/defaults.mk | 8 ++++---- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index db15930e8..69f29e6c0 100644 --- a/Makefile +++ b/Makefile @@ -374,6 +374,12 @@ ifeq ($(HW_ASSISTED_COHERENCY)-$(USE_COHERENT_MEM),1-1) $(error USE_COHERENT_MEM cannot be enabled with HW_ASSISTED_COHERENCY) endif +ifneq ($(MULTI_CONSOLE_API), 0) + ifeq (${ARCH},aarch32) + $(error "Error: MULTI_CONSOLE_API is not supported for AArch32") + endif +endif + ################################################################################ # Process platform overrideable behaviour ################################################################################ @@ -588,9 +594,9 @@ all: msg_start msg_start: @echo "Building ${PLAT}" -# Check if deprecated declarations should be treated as error or not. +# Check if deprecated declarations and cpp warnings should be treated as error or not. ifeq (${ERROR_DEPRECATED},0) - TF_CFLAGS += -Wno-error=deprecated-declarations + CPPFLAGS += -Wno-error=deprecated-declarations -Wno-error=cpp endif # Expand build macros for the different images diff --git a/drivers/console/aarch64/deprecated_console.S b/drivers/console/aarch64/deprecated_console.S index c83e2467b..d6ecc4df2 100644 --- a/drivers/console/aarch64/deprecated_console.S +++ b/drivers/console/aarch64/deprecated_console.S @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -9,6 +9,7 @@ * This is the common console core code for the deprecated single-console API. * New platforms should set MULTI_CONSOLE_API=1 and not use this file. */ +#warning "Using deprecated console implementation. Please migrate to MULTI_CONSOLE_API" .globl console_init .globl console_uninit diff --git a/include/drivers/console.h b/include/drivers/console.h index 0629f5717..f8ec83d2f 100644 --- a/include/drivers/console.h +++ b/include/drivers/console.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2017, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -63,10 +63,10 @@ int console_getc(void); int console_flush(void); #if !MULTI_CONSOLE_API -/* DEPRECATED on AArch64 -- use console__register() instead! */ +/* REMOVED on AArch64 -- use console__register() instead! */ int console_init(uintptr_t base_addr, - unsigned int uart_clk, unsigned int baud_rate) __deprecated; -void console_uninit(void) __deprecated; + unsigned int uart_clk, unsigned int baud_rate); +void console_uninit(void); #endif #endif /* __ASSEMBLY__ */ diff --git a/make_helpers/defaults.mk b/make_helpers/defaults.mk index a80a4915a..751f8343c 100644 --- a/make_helpers/defaults.mk +++ b/make_helpers/defaults.mk @@ -1,5 +1,5 @@ # -# Copyright (c) 2016-2017, ARM Limited and Contributors. All rights reserved. +# Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause # @@ -98,9 +98,9 @@ KEY_ALG := rsa # Flag to enable new version of image loading LOAD_IMAGE_V2 := 0 -# Use the new console API that allows registering more than one console instance -# at once. Use = instead of := to dynamically default to ERROR_DEPRECATED. -MULTI_CONSOLE_API = $(ERROR_DEPRECATED) +# Enable use of the console API allowing multiple consoles to be registered +# at the same time. +MULTI_CONSOLE_API := 0 # NS timer register save and restore NS_TIMER_SWITCH := 0 From dcf01a0a8dddde79b8315c30395f40f9afa85af4 Mon Sep 17 00:00:00 2001 From: Dan Handley Date: Thu, 1 Mar 2018 16:00:15 +0000 Subject: [PATCH 3/3] Emit warnings when using deprecated GIC init Emit runtime warnings when intializing the GIC drivers using the deprecated method of defining integer interrupt arrays in the GIC driver data structures; interrupt_prop_t arrays should be used instead. This helps platforms detect that they have migration work to do. Previously, no warning was emitted in this case. This affects both the GICv2 and GICv3 drivers. Also use the __deprecated attribute to emit a build time warning if these deprecated fields are used. These warnings are suppressed in the GIC driver compatibility functions but will be visible if platforms use them. Change-Id: I6b6b8f6c3b4920c448b6dcb82fc18442cfdf6c7a Signed-off-by: Dan Handley --- drivers/arm/gic/v2/gicv2_main.c | 27 +++++++++++++++++++++++++++ drivers/arm/gic/v3/gicv3_main.c | 28 ++++++++++++++++++++++++++++ include/drivers/arm/gicv2.h | 4 ++-- include/drivers/arm/gicv3.h | 8 ++++---- 4 files changed, 61 insertions(+), 6 deletions(-) diff --git a/drivers/arm/gic/v2/gicv2_main.c b/drivers/arm/gic/v2/gicv2_main.c index c65f972d0..7e2c7a7b0 100644 --- a/drivers/arm/gic/v2/gicv2_main.c +++ b/drivers/arm/gic/v2/gicv2_main.c @@ -85,10 +85,17 @@ void gicv2_pcpu_distif_init(void) driver_data->interrupt_props_num); #if !ERROR_DEPRECATED } else { + /* + * Suppress deprecated declaration warnings in compatibility + * function + */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" assert(driver_data->g0_interrupt_array); gicv2_secure_ppi_sgi_setup(driver_data->gicd_base, driver_data->g0_interrupt_num, driver_data->g0_interrupt_array); +#pragma GCC diagnostic pop } #endif @@ -128,12 +135,20 @@ void gicv2_distif_init(void) driver_data->interrupt_props_num); #if !ERROR_DEPRECATED } else { + /* + * Suppress deprecated declaration warnings in compatibility + * function + */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + assert(driver_data->g0_interrupt_array); /* Configure the G0 SPIs */ gicv2_secure_spis_configure(driver_data->gicd_base, driver_data->g0_interrupt_num, driver_data->g0_interrupt_array); +#pragma GCC diagnostic pop } #endif @@ -156,6 +171,13 @@ void gicv2_driver_init(const gicv2_driver_data_t *plat_driver_data) /* Interrupt properties array size must be 0 */ assert(plat_driver_data->interrupt_props_num == 0); + /* + * Suppress deprecated declaration warnings in compatibility + * function + */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + /* The platform should provide a list of secure interrupts */ assert(plat_driver_data->g0_interrupt_array); @@ -166,6 +188,11 @@ void gicv2_driver_init(const gicv2_driver_data_t *plat_driver_data) assert(plat_driver_data->g0_interrupt_array ? plat_driver_data->g0_interrupt_num : plat_driver_data->g0_interrupt_num == 0); +#pragma GCC diagnostic pop + + WARN("Using deprecated integer interrupt array in " + "gicv2_driver_data_t\n"); + WARN("Please migrate to using an interrupt_prop_t array\n"); } #else assert(plat_driver_data->interrupt_props != NULL); diff --git a/drivers/arm/gic/v3/gicv3_main.c b/drivers/arm/gic/v3/gicv3_main.c index 45a2e5bca..f4a3ef81f 100644 --- a/drivers/arm/gic/v3/gicv3_main.c +++ b/drivers/arm/gic/v3/gicv3_main.c @@ -72,6 +72,13 @@ void gicv3_driver_init(const gicv3_driver_data_t *plat_driver_data) /* Interrupt properties array size must be 0 */ assert(plat_driver_data->interrupt_props_num == 0); + /* + * Suppress deprecated declaration warnings in compatibility + * function + */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + /* * The platform should provide a list of at least one type of * interrupt. @@ -89,6 +96,11 @@ void gicv3_driver_init(const gicv3_driver_data_t *plat_driver_data) assert(plat_driver_data->g1s_interrupt_array ? plat_driver_data->g1s_interrupt_num : plat_driver_data->g1s_interrupt_num == 0); +#pragma GCC diagnostic pop + + WARN("Using deprecated integer interrupt arrays in " + "gicv3_driver_data_t\n"); + WARN("Please migrate to using interrupt_prop_t arrays\n"); } #else assert(plat_driver_data->interrupt_props != NULL); @@ -189,6 +201,13 @@ void gicv3_distif_init(void) gicv3_driver_data->interrupt_props_num); #if !ERROR_DEPRECATED } else { + /* + * Suppress deprecated declaration warnings in compatibility + * function + */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + assert(gicv3_driver_data->g1s_interrupt_array || gicv3_driver_data->g0_interrupt_array); @@ -209,6 +228,7 @@ void gicv3_distif_init(void) INTR_GROUP0); bitmap |= CTLR_ENABLE_G0_BIT; } +#pragma GCC diagnostic pop } #endif @@ -253,6 +273,13 @@ void gicv3_rdistif_init(unsigned int proc_num) gicv3_driver_data->interrupt_props_num); #if !ERROR_DEPRECATED } else { + /* + * Suppress deprecated declaration warnings in compatibility + * function + */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + assert(gicv3_driver_data->g1s_interrupt_array || gicv3_driver_data->g0_interrupt_array); @@ -273,6 +300,7 @@ void gicv3_rdistif_init(unsigned int proc_num) INTR_GROUP0); bitmap |= CTLR_ENABLE_G0_BIT; } +#pragma GCC diagnostic pop } #endif diff --git a/include/drivers/arm/gicv2.h b/include/drivers/arm/gicv2.h index 6e8322e1b..39c73027e 100644 --- a/include/drivers/arm/gicv2.h +++ b/include/drivers/arm/gicv2.h @@ -155,8 +155,8 @@ typedef struct gicv2_driver_data { uintptr_t gicd_base; uintptr_t gicc_base; #if !ERROR_DEPRECATED - unsigned int g0_interrupt_num; - const unsigned int *g0_interrupt_array; + unsigned int g0_interrupt_num __deprecated; + const unsigned int *g0_interrupt_array __deprecated; #endif unsigned int *target_masks; unsigned int target_masks_num; diff --git a/include/drivers/arm/gicv3.h b/include/drivers/arm/gicv3.h index 5f265c6e4..37c92e4f8 100644 --- a/include/drivers/arm/gicv3.h +++ b/include/drivers/arm/gicv3.h @@ -310,10 +310,10 @@ typedef struct gicv3_driver_data { uintptr_t gicd_base; uintptr_t gicr_base; #if !ERROR_DEPRECATED - unsigned int g0_interrupt_num; - unsigned int g1s_interrupt_num; - const unsigned int *g0_interrupt_array; - const unsigned int *g1s_interrupt_array; + unsigned int g0_interrupt_num __deprecated; + unsigned int g1s_interrupt_num __deprecated; + const unsigned int *g0_interrupt_array __deprecated; + const unsigned int *g1s_interrupt_array __deprecated; #endif const interrupt_prop_t *interrupt_props; unsigned int interrupt_props_num;