All of lore.kernel.org
 help / color / mirror / Atom feed
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: Thu, 24 Sep 2026 18:58:59 +0100	[thread overview]
Message-ID: <86mrt64jks.wl-maz@kernel.org> (raw)
In-Reply-To: <6975605e-6635-f3c6-39ee-8faaae6d9856@hisilicon.com>

On Tue, 22 Sep 2026 11:16:36 +0100,
Zhou Wang <wangzhou1@hisilicon.com> wrote:
> 
> On 2026/9/21 21:22, Marc Zyngier wrote:
> > 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?
> 
> I mean we do not use ptimer at least in current Linux kernel, however, for system
> which has ECV_CNTPOFF capability, we have to handle related logic here.
> 
> So we can detect if ptimer is been used, if it is been used, then we run into the
> related codes.

But where is the actual cost? Is it the saving of these registers?
Something else?

> 
> I am not familiar with the nested cases, so just not change related logic.
> 
> > 
> >>
> >> 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
> 
> Do you mean that in non-nested case, we can make offset always be 0, so
> related logic in __activate_traps/__deactivate_traps can be skipped?
>

The *trapping* of the physical timer/counter will be skipped.

	M.

-- 
Without deviation from the norm, progress is not possible.

  reply	other threads:[~2026-09-24 17:59 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
2026-09-22 10:16   ` Zhou Wang
2026-09-24 17:58     ` Marc Zyngier [this message]
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=86mrt64jks.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.