From: Andre Przywara <andre.przywara@arm.com>
To: Mark Rutland <mark.rutland@arm.com>,
linux-arm-kernel@lists.infradead.org
Cc: alexandru.elisei@arm.com, maz@kernel.org
Subject: Re: [boot-wrapper PATCH 3/5] GICv3: initialize without RMW
Date: Tue, 24 Aug 2021 17:50:43 +0100 [thread overview]
Message-ID: <32fc73f9-7eef-d6e2-1f5c-491e330e5b70@arm.com> (raw)
In-Reply-To: <20210824134900.34849-4-mark.rutland@arm.com>
On 8/24/21 2:48 PM, Mark Rutland wrote:
> There's no need to perform an RMW sequence to initialize ICC_SRE_EL3, as
> there are no bits that we need to preserve, and generally we should
> reset registers to specific values such that RESx bits aren't configured
> to UNKNOWN values that could be problematic in future architecture
> versions.
>
> Instead, let's initialize ICC_SRE_EL3 with a constant value. Since the
> `DIB` and `DFB` fields are RAO/WI in some configurations and we have no
> reason to initialize these to 0, we always initialize these to 1, in
> addition to `SRE` and `SRE_Enable`.
Indeed, actually the architectural reset value is 0 (bypass enabled),
and we seem to be just saved by the fact that the model implements them
as RAO/WI. So forcing a value is the right thing to do.
> Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> Cc: Marc Zyngier <maz@kernel.org>
> Cc: Alexandru Elisei <alexandru.elisei@arm.com>
> Cc: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Cheers,
Andre
> ---
> arch/aarch32/include/asm/gic-v3.h | 7 -------
> arch/aarch64/include/asm/gic-v3.h | 7 -------
> common/gic-v3.c | 8 +++-----
> 3 files changed, 3 insertions(+), 19 deletions(-)
>
> diff --git a/arch/aarch32/include/asm/gic-v3.h b/arch/aarch32/include/asm/gic-v3.h
> index ec9a327..65f38de 100644
> --- a/arch/aarch32/include/asm/gic-v3.h
> +++ b/arch/aarch32/include/asm/gic-v3.h
> @@ -9,13 +9,6 @@
> #ifndef __ASM_AARCH32_GICV3_H
> #define __ASM_AARCH32_GICV3_H
>
> -static inline uint32_t gic_read_icc_sre(void)
> -{
> - uint32_t val;
> - asm volatile ("mrc p15, 6, %0, c12, c12, 5" : "=r" (val));
> - return val;
> -}
> -
> static inline void gic_write_icc_sre(uint32_t val)
> {
> asm volatile ("mcr p15, 6, %0, c12, c12, 5" : : "r" (val));
> diff --git a/arch/aarch64/include/asm/gic-v3.h b/arch/aarch64/include/asm/gic-v3.h
> index e743c02..5b32380 100644
> --- a/arch/aarch64/include/asm/gic-v3.h
> +++ b/arch/aarch64/include/asm/gic-v3.h
> @@ -15,13 +15,6 @@
> #define ICC_CTLR_EL3 "S3_6_C12_C12_4"
> #define ICC_PMR_EL1 "S3_0_C4_C6_0"
>
> -static inline uint32_t gic_read_icc_sre(void)
> -{
> - uint32_t val;
> - asm volatile ("mrs %0, " ICC_SRE_EL3 : "=r" (val));
> - return val;
> -}
> -
> static inline void gic_write_icc_sre(uint32_t val)
> {
> asm volatile ("msr " ICC_SRE_EL3 ", %0" : : "r" (val));
> diff --git a/common/gic-v3.c b/common/gic-v3.c
> index 62f9676..6207007 100644
> --- a/common/gic-v3.c
> +++ b/common/gic-v3.c
> @@ -42,6 +42,8 @@
> #define GICR_TYPER_Last (1 << 4)
>
> #define ICC_SRE_SRE (1 << 0)
> +#define ICC_SRE_DFB (1 << 1)
> +#define ICC_SRE_DIB (1 << 2)
> #define ICC_SRE_Enable (1 << 3)
>
> void gic_secure_init_primary(void)
> @@ -101,8 +103,6 @@ void gic_secure_init_primary(void)
>
> void gic_secure_init(void)
> {
> - uint32_t sre;
> -
> /*
> * If GICv3 is not available, skip initialisation. The OS will probably
> * fail with a warning, but this should be easier to debug than a
> @@ -114,9 +114,7 @@ void gic_secure_init(void)
> if (this_cpu_logical_id() == 0)
> gic_secure_init_primary();
>
> - sre = gic_read_icc_sre();
> - sre |= ICC_SRE_Enable | ICC_SRE_SRE;
> - gic_write_icc_sre(sre);
> + gic_write_icc_sre(ICC_SRE_Enable | ICC_SRE_DIB | ICC_SRE_DFB | ICC_SRE_SRE);
> isb();
>
> gic_write_icc_ctlr(0);
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2021-08-24 16:52 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-24 13:48 [boot-wrapper PATCH 0/5] Misc cleanups Mark Rutland
2021-08-24 13:48 ` [boot-wrapper PATCH 1/5] Remove unused Set/Way cache helpers Mark Rutland
2021-08-24 16:49 ` Andre Przywara
2021-08-24 13:48 ` [boot-wrapper PATCH 2/5] aarch32: simplify _switch_monitor Mark Rutland
2021-08-24 16:50 ` Andre Przywara
2021-08-24 13:48 ` [boot-wrapper PATCH 3/5] GICv3: initialize without RMW Mark Rutland
2021-08-24 16:50 ` Andre Przywara [this message]
2021-08-24 13:48 ` [boot-wrapper PATCH 4/5] Rename kernel *_RESET values to *_KERNEL Mark Rutland
2021-08-24 16:50 ` Andre Przywara
2021-08-24 13:49 ` [boot-wrapper PATCH 5/5] Rename `CNTFRQ` -> `COUNTER_FREQ` Mark Rutland
2021-08-24 16:51 ` Andre Przywara
2021-08-25 9:46 ` [boot-wrapper PATCH 0/5] Misc cleanups Marc Zyngier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=32fc73f9-7eef-d6e2-1f5c-491e330e5b70@arm.com \
--to=andre.przywara@arm.com \
--cc=alexandru.elisei@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=maz@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).