linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Sebastian Ott <sebott@redhat.com>
Cc: Oliver Upton <oliver.upton@linux.dev>,
	Colton Lewis <coltonlewis@google.com>,
	Ricardo Koller <ricarkol@google.com>,
	Joey Gouly <joey.gouly@arm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Zenghui Yu <yuzenghui@huawei.com>, Shuah Khan <shuah@kernel.org>,
	linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH 3/3] KVM: arm64: selftests: arch_timer_edge_cases - workaround for AC03_CPU_14
Date: Sat, 10 May 2025 10:03:10 +0100	[thread overview]
Message-ID: <87jz6o6do1.wl-maz@kernel.org> (raw)
In-Reply-To: <20250509143312.34224-4-sebott@redhat.com>

On Fri, 09 May 2025 15:33:12 +0100,
Sebastian Ott <sebott@redhat.com> wrote:
> 
> arch_timer_edge_cases currently fails on ampere-one machines with
> the following assertion failure:
> 
> ==== Test Assertion Failure ====
>   arm64/arch_timer_edge_cases.c:169: timer_condition == istatus
>   pid=11236 tid=11236 errno=4 - Interrupted system call
>      1  0x0000000000404ce7: test_run at arch_timer_edge_cases.c:938
>      2  0x0000000000401ebb: main at arch_timer_edge_cases.c:1053
>      3  0x0000ffff9fa8625b: ?? ??:0
>      4  0x0000ffff9fa8633b: ?? ??:0
>      5  0x0000000000401fef: _start at ??:?
>   0x1 != 0x0 (timer_condition != istatus)
> 
> Meaning that the timer condition was met and an interrupt
> was presented but the timer status bit in the control register
> was not set.
> 
> This happens due to AC03_CPU_14 "Timer CVAL programming of a delta
> greater than 2^63 will result in incorrect behavior."
> 
> Work around this issue by reducing the value that is used to reset
> the counter and thus reduce the delta.
> 
> Link: https://lore.kernel.org/kvmarm/ac1de1d2-ef2b-d439-dc48-8615e121b07b@redhat.com
> Link: https://amperecomputing.com/assets/AmpereOne_Developer_ER_v0_80_20240823_28945022f4.pdf
> Signed-off-by: Sebastian Ott <sebott@redhat.com>
> ---
>  tools/testing/selftests/kvm/arm64/arch_timer_edge_cases.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/kvm/arm64/arch_timer_edge_cases.c b/tools/testing/selftests/kvm/arm64/arch_timer_edge_cases.c
> index a813b4c6c817..2f0397df0aa6 100644
> --- a/tools/testing/selftests/kvm/arm64/arch_timer_edge_cases.c
> +++ b/tools/testing/selftests/kvm/arm64/arch_timer_edge_cases.c
> @@ -31,7 +31,7 @@ static const int32_t TVAL_MIN = INT32_MIN;
>  static const uint32_t TIMEOUT_NO_IRQ_US = 50000;
>  
>  /* A nice counter value to use as the starting one for most tests. */
> -static const uint64_t DEF_CNT = (CVAL_MAX / 2);
> +static const uint64_t DEF_CNT = (CVAL_MAX / 4);

This is rather arbitrary, and only sidestep the issue: the core
problem is that CVAL_MAX is defined as ~0, and that we have no idea
what the *effective* counter width is.

So while this happen to sidestep the particular Ampere erratum (and
avoid failures on X1E), this is only papering over the problem. Which
is why I always had some reservations on this particular test -- it is
remarkably broken.

If anything, we should compute the expected width of the counter based
on the frequency and the architectural guarantees ("Roll-over time of
not less than 40 years."), just like the kernel driver does (see
arch_counter_get_width()).

I'm also not keen on hiding a HW bug by altering the test. What of
other guests that would fall into the same issue? If we think the
problem exposed by this test is serious enough, then we need to fully
trap and emulate the timers, X1E style. Performance would definitely
suffer, but that would be the correct thing to do.

So my proposal is to fix the test to be compliant with the intent of
the architecture instead of making bets and using semi-random values.
If that's good enough to make that test pass on A1, great.

Thanks,

	M.

-- 
Jazz isn't dead. It just smells funny.


      reply	other threads:[~2025-05-10  9:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-09 14:33 [PATCH 0/3] KVM: arm64: selftests: arch_timer_edge_cases fixes Sebastian Ott
2025-05-09 14:33 ` [PATCH 1/3] KVM: arm64: selftests: fix help text for arch_timer_edge_cases Sebastian Ott
2025-05-09 14:33 ` [PATCH 2/3] KVM: arm64: selftests: fix thread migration in arch_timer_edge_cases Sebastian Ott
2025-05-09 14:33 ` [PATCH 3/3] KVM: arm64: selftests: arch_timer_edge_cases - workaround for AC03_CPU_14 Sebastian Ott
2025-05-10  9:03   ` Marc Zyngier [this message]

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=87jz6o6do1.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=coltonlewis@google.com \
    --cc=joey.gouly@arm.com \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=oliver.upton@linux.dev \
    --cc=ricarkol@google.com \
    --cc=sebott@redhat.com \
    --cc=shuah@kernel.org \
    --cc=suzuki.poulose@arm.com \
    --cc=yuzenghui@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).