From: Marc Zyngier <maz@kernel.org>
To: Zhou Wang <wangzhou1@hisilicon.com>
Cc: Oliver Upton <oupton@kernel.org>,
Fuad Tabba <fuad.tabba@linux.dev>,
Joey Gouly <joey.gouly@arm.com>,
Steffen Eiden <seiden@linux.ibm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Zenghui Yu <yuzenghui@huawei.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
Mark Rutland <mark.rutland@arm.com>, <kvmarm@lists.linux.dev>,
Nianyao Tang <tangnianyao@huawei.com>
Subject: Re: [RFC PATCH] KVM: arm64: Restrict CNTP_CVAL/CNTHP_CVAL save/reload when ptimer is used
Date: Mon, 21 Sep 2026 14:22:49 +0100 [thread overview]
Message-ID: <878q4u4u3a.wl-maz@kernel.org> (raw)
In-Reply-To: <20260921111840.3000905-1-wangzhou1@hisilicon.com>
On Mon, 21 Sep 2026 12:18:40 +0100,
Zhou Wang <wangzhou1@hisilicon.com> wrote:
>
> A guest's physical timer may be used in nested guest or directly used in
> VHE mode. We can check above cases to avoid useless CNTP_CVAL/CNTHP_CVAL save
> and reload.
Why useless? What cases?
>
> Use lazy detection to determine whether a non-nested VHE guest actually uses
> the physical timer.
>
> timer_set_traps() initially traps CNTP_CTL_EL0 writes for non-nested guests.
> On the first write that sets CNTP_CTL.ENABLE=1, the trap handler records
> ptimer_used and clears the trap in CNTHCTL_EL2, allowing the guest direct
> access thereafter.
I really don't want to go into these micro optimisation to paper over
the bad state of the architecture.
The options are:
- Don't use any offset (offsets always set to 0), and there will not
be any trap
- Use CNTPOFF, which will work just fine for an L1 guest, without
traps
- For nested guests, there is no solution that matches the
architecture (CNTPOFF doesn't nest), and you must trap.
So where is the cost in your case?
>
> A test result from KUT in HiSilicon HIP12 is:
>
> nopatch patch
> hvc 758 624
> mmio_read_user 3647 3479
> mmio_read_vgic 949 817
> eoi 29 29
> ipi 2534 2302
> lpi 2684 2442
> timer_10ms 2393 2168
I don't know what these numbers are. There is no unit, no indication
of how this is run (L1, L2, Ln...), no base kernel version...
Can you please explain what you are actually trying to do? Are you
saying that accessing the physical timer (two registers) is that
expensive?
Thanks,
M.
--
Jazz isn't dead. It just smells funny.
next prev parent reply other threads:[~2026-09-21 13:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-21 11:18 [RFC PATCH] KVM: arm64: Restrict CNTP_CVAL/CNTHP_CVAL save/reload when ptimer is used Zhou Wang
2026-09-21 11:41 ` sashiko-bot
2026-09-21 13:22 ` Marc Zyngier [this message]
2026-09-22 10:16 ` Zhou Wang
2026-09-24 17:58 ` Marc Zyngier
2026-09-28 8:30 ` Zhou Wang
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=878q4u4u3a.wl-maz@kernel.org \
--to=maz@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=fuad.tabba@linux.dev \
--cc=joey.gouly@arm.com \
--cc=kvmarm@lists.linux.dev \
--cc=mark.rutland@arm.com \
--cc=oupton@kernel.org \
--cc=seiden@linux.ibm.com \
--cc=suzuki.poulose@arm.com \
--cc=tangnianyao@huawei.com \
--cc=wangzhou1@hisilicon.com \
--cc=will@kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.