qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: "Alex Bennée" <alex.bennee@linaro.org>
Cc: qemu-devel@nongnu.org,
	"Leif Lindholm" <quic_llindhol@quicinc.com>,
	"Leif Lindholm" <leif.lindholm@oss.qualcomm.com>,
	"Marcin Juszkiewicz" <marcin.juszkiewicz@linaro.org>,
	"Radoslaw Biernacki" <rad@semihalf.com>,
	qemu-arm@nongnu.org, qemu-stable@nongnu.org,
	"Andrei Homescu" <ahomescu@google.com>,
	"Arve Hjønnevåg" <arve@google.com>,
	"Rémi Denis-Courmont" <remi.denis.courmont@huawei.com>
Subject: Re: [PATCH v2 3/5] target/arm: implement SEL2 physical and virtual timers
Date: Fri, 10 Jan 2025 12:57:25 +0000	[thread overview]
Message-ID: <CAFEAcA8r9OS9SO_26GmagYD1E-0e1OSmU8GiGXtogpOJ5c7vYQ@mail.gmail.com> (raw)
In-Reply-To: <20241218181511.3575613-4-alex.bennee@linaro.org>

On Wed, 18 Dec 2024 at 18:15, Alex Bennée <alex.bennee@linaro.org> wrote:
>
> When FEAT_SEL2 was implemented the SEL2 timers where missed. This
> shows up when building the latest Hafnium with SPMC_AT_EL=2. The
> actual implementation utilises the same logic as the rest of the
> timers so all we need to do is:
>
>   - define the timers and their access functions
>   - conditionally add the correct system registers
>   - create a new accessfn as the rules are subtly different to the
>     existing secure timer
>
> Fixes: e9152ee91c (target/arm: add ARMv8.4-SEL2 system registers)
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> Cc: qemu-stable@nongnu.org
> Cc: Andrei Homescu <ahomescu@google.com>
> Cc: Arve Hjønnevåg <arve@google.com>
> Cc: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
>
> ---
> v1
>   - add better comments to GTIMER descriptions
>   - also define new timers for sbsa-ref
>   - don't conditionally gate qemu_timer creation on the feature
>   - take cntvoff_el2 int account for SEC_VEL2 in gt_recalc/g_tval_[read|write]
> v2
>   - rename IRQ to ARCH_TIMER_S_EL2_VIRT_IRQ
>   - split machine enablement into separate patches
>   - return CP_ACCESS_TRAP_UNCATEGORIZED for UNDEF cases
> ---

> +static CPAccessResult gt_sel2timer_access(CPUARMState *env,
> +                                          const ARMCPRegInfo *ri,
> +                                          bool isread)
> +{
> +    /*
> +     * The AArch64 register view of the secure EL2 timers are mostly
> +     * accessible from EL3 and EL2 although can also be trapped to EL2
> +     * from EL1 depending on nested virt config.
> +     */
> +    switch (arm_current_el(env)) {
> +    case 0:
> +        return CP_ACCESS_TRAP;
> +    case 1:
> +        if (!arm_is_secure(env)) {
> +            return CP_ACCESS_TRAP_UNCATEGORIZED;
> +        } else if (arm_hcr_el2_eff(env) & HCR_NV) {
> +            return CP_ACCESS_TRAP_EL2;
> +        }
> +        return CP_ACCESS_TRAP;
> +    case 2:
> +        if (!arm_is_secure(env)) {
> +            return CP_ACCESS_TRAP_UNCATEGORIZED;
> +        }
> +        return CP_ACCESS_OK;
> +    case 3:
> +        if (env->cp15.scr_el3 & SCR_EEL2) {
> +            return CP_ACCESS_OK;
> +        } else {
> +            return CP_ACCESS_TRAP_UNCATEGORIZED;
> +        }
> +    default:
> +        g_assert_not_reached();
> +    }
> +}

This code is still using CP_ACCESS_TRAP in some codepaths, which
isn't correct. Either:
 * you want an UNDEF: that's CP_ACCESS_TRAP_UNCATEGORIZED
 * you want to trap to some specific EL: that's CP_ACCESS_TRAP_EL2
   or CP_ACCESS_TRAP_EL3 depending on where you need to trap to.

thanks
-- PMM


  parent reply	other threads:[~2025-01-10 12:57 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-18 18:15 [PATCH v2 0/5] target/arm: implement SEL2 physical and virtual timers Alex Bennée
2024-12-18 18:15 ` [PATCH v2 1/5] target/arm: document the architectural names of our GTIMERs Alex Bennée
2024-12-18 18:15 ` [PATCH v2 2/5] target/arm: ensure cntvoff_el2 also used for EL2 virt timer Alex Bennée
2024-12-18 18:15 ` [PATCH v2 3/5] target/arm: implement SEL2 physical and virtual timers Alex Bennée
2025-01-09 11:18   ` Philippe Mathieu-Daudé
2025-01-09 11:25     ` Daniel Wielandt
2025-01-10 12:57   ` Peter Maydell [this message]
2024-12-18 18:15 ` [PATCH v2 4/5] hw/arm: enable secure EL2 timers for virt machine Alex Bennée
2025-01-10 12:53   ` Peter Maydell
2025-01-22 11:20     ` Alex Bennée
2024-12-18 18:15 ` [PATCH v2 5/5] hw/arm: enable secure EL2 timers for sbsa machine Alex Bennée
2025-01-10 12:53   ` Peter Maydell
2025-01-09 10:40 ` [PATCH v2 0/5] target/arm: implement SEL2 physical and virtual timers Alex Bennée
2025-01-09 10:57   ` Peter Maydell

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=CAFEAcA8r9OS9SO_26GmagYD1E-0e1OSmU8GiGXtogpOJ5c7vYQ@mail.gmail.com \
    --to=peter.maydell@linaro.org \
    --cc=ahomescu@google.com \
    --cc=alex.bennee@linaro.org \
    --cc=arve@google.com \
    --cc=leif.lindholm@oss.qualcomm.com \
    --cc=marcin.juszkiewicz@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    --cc=quic_llindhol@quicinc.com \
    --cc=rad@semihalf.com \
    --cc=remi.denis.courmont@huawei.com \
    /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).