From: Marc Zyngier <maz@kernel.org>
To: James Clark <james.clark@arm.com>
Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org,
kvmarm@lists.linux.dev, suzuki.poulose@arm.com, acme@kernel.org,
oliver.upton@linux.dev, broonie@kernel.org,
James Morse <james.morse@arm.com>,
Zenghui Yu <yuzenghui@huawei.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>, Mike Leach <mike.leach@linaro.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Anshuman Khandual <anshuman.khandual@arm.com>,
Miguel Luis <miguel.luis@oracle.com>,
Joey Gouly <joey.gouly@arm.com>, Ard Biesheuvel <ardb@kernel.org>,
Quentin Perret <qperret@google.com>,
Javier Martinez Canillas <javierm@redhat.com>,
Mark Rutland <mark.rutland@arm.com>,
Arnd Bergmann <arnd@arndb.de>,
Vincent Donnefort <vdonnefort@google.com>,
Ryan Roberts <ryan.roberts@arm.com>,
Fuad Tabba <tabba@google.com>,
Jing Zhang <jingzhangos@google.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v6 5/8] arm64: KVM: Add iflag for FEAT_TRF
Date: Mon, 26 Feb 2024 18:03:57 +0000 [thread overview]
Message-ID: <86a5nn2jci.wl-maz@kernel.org> (raw)
In-Reply-To: <8b9c1cce-401c-5084-ee2f-68beb03ad7a0@arm.com>
On Mon, 26 Feb 2024 15:41:02 +0000,
James Clark <james.clark@arm.com> wrote:
>
>
>
> On 26/02/2024 13:35, Marc Zyngier wrote:
> > On Mon, 26 Feb 2024 11:30:33 +0000,
> > James Clark <james.clark@arm.com> wrote:
[...]
> >> diff --git a/arch/arm64/kvm/debug.c b/arch/arm64/kvm/debug.c
> >> index ce8886122ed3..49a13e72ddd2 100644
> >> --- a/arch/arm64/kvm/debug.c
> >> +++ b/arch/arm64/kvm/debug.c
> >> @@ -332,14 +332,30 @@ void kvm_arch_vcpu_load_debug_state_flags(struct kvm_vcpu *vcpu)
> >> !(read_sysreg_s(SYS_PMBIDR_EL1) & BIT(PMBIDR_EL1_P_SHIFT)))
> >> vcpu_set_flag(vcpu, DEBUG_STATE_SAVE_SPE);
> >>
> >> - /* Check if we have TRBE implemented and available at the host */
> >> - if (cpuid_feature_extract_unsigned_field(dfr0, ID_AA64DFR0_EL1_TraceBuffer_SHIFT) &&
> >> - !(read_sysreg_s(SYS_TRBIDR_EL1) & TRBIDR_EL1_P))
> >> - vcpu_set_flag(vcpu, DEBUG_STATE_SAVE_TRBE);
> >> + /*
> >> + * Set SAVE_TRFCR flag if FEAT_TRF (TraceFilt) exists. This flag
> >> + * signifies that the exclude_host/exclude_guest settings of any active
> >> + * host Perf session on a core running a VCPU can be written into
> >> + * TRFCR_EL1 on guest switch.
> >> + */
> >> + if (cpuid_feature_extract_unsigned_field(dfr0, ID_AA64DFR0_EL1_TraceFilt_SHIFT)) {
> >> + vcpu_set_flag(vcpu, DEBUG_STATE_SAVE_TRFCR);
> >
> > Can we avoid doing this unconditionally? It only makes sense to save
> > the trace crud if it is going to be changed, right?
> >
>
> Do you mean to see if kvm_guest_trfcr was non-zero (and would have to be
> changed) at VCPU load? I assumed that it could be modified between load
> and switch. That would mean there is no way to do it conditionally.
What's the problem? If you change the value behind the vcpu's back,
you get what you deserve: garbage.
I'm baffled that you consider that randomly changing a value without
proper synchronisation (such as with an IPI) is a valid approach.
Please look at what is being done for the PMU in the same context.
> I also assumed that's the reason SPE and TRBE were implemented like
> this, with the feat check at load and the enabled check at switch. It
> doesn't feel like TRFCR is any different to those two.
Well, that' doesn't make it right. Having just looked at the debug
stuff, I'm ashamed to have let that stuff in.
> Or do you mean to only set DEBUG_STATE_SAVE_TRFCR on switch if tracing
> was enabled?
I don't think there should be any flag. The discriminant should be:
- does the HW support TRF?
- is the in-guest tracing enabled?
If both are true, and that this requires a change of configuration,
*then* you perform the change. Same thing on exit. No flag. And a
static key for TRF support, which should really be valid on all CPUs.
M.
--
Without deviation from the norm, progress is not possible.
WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <maz@kernel.org>
To: James Clark <james.clark@arm.com>
Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org,
kvmarm@lists.linux.dev, suzuki.poulose@arm.com, acme@kernel.org,
oliver.upton@linux.dev, broonie@kernel.org,
James Morse <james.morse@arm.com>,
Zenghui Yu <yuzenghui@huawei.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>, Mike Leach <mike.leach@linaro.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Anshuman Khandual <anshuman.khandual@arm.com>,
Miguel Luis <miguel.luis@oracle.com>,
Joey Gouly <joey.gouly@arm.com>, Ard Biesheuvel <ardb@kernel.org>,
Quentin Perret <qperret@google.com>,
Javier Martinez Canillas <javierm@redhat.com>,
Mark Rutland <mark.rutland@arm.com>,
Arnd Bergmann <arnd@arndb.de>,
Vincent Donnefort <vdonnefort@google.com>,
Ryan Roberts <ryan.roberts@arm.com>,
Fuad Tabba <tabba@google.com>,
Jing Zhang <jingzhangos@google.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v6 5/8] arm64: KVM: Add iflag for FEAT_TRF
Date: Mon, 26 Feb 2024 18:03:57 +0000 [thread overview]
Message-ID: <86a5nn2jci.wl-maz@kernel.org> (raw)
In-Reply-To: <8b9c1cce-401c-5084-ee2f-68beb03ad7a0@arm.com>
On Mon, 26 Feb 2024 15:41:02 +0000,
James Clark <james.clark@arm.com> wrote:
>
>
>
> On 26/02/2024 13:35, Marc Zyngier wrote:
> > On Mon, 26 Feb 2024 11:30:33 +0000,
> > James Clark <james.clark@arm.com> wrote:
[...]
> >> diff --git a/arch/arm64/kvm/debug.c b/arch/arm64/kvm/debug.c
> >> index ce8886122ed3..49a13e72ddd2 100644
> >> --- a/arch/arm64/kvm/debug.c
> >> +++ b/arch/arm64/kvm/debug.c
> >> @@ -332,14 +332,30 @@ void kvm_arch_vcpu_load_debug_state_flags(struct kvm_vcpu *vcpu)
> >> !(read_sysreg_s(SYS_PMBIDR_EL1) & BIT(PMBIDR_EL1_P_SHIFT)))
> >> vcpu_set_flag(vcpu, DEBUG_STATE_SAVE_SPE);
> >>
> >> - /* Check if we have TRBE implemented and available at the host */
> >> - if (cpuid_feature_extract_unsigned_field(dfr0, ID_AA64DFR0_EL1_TraceBuffer_SHIFT) &&
> >> - !(read_sysreg_s(SYS_TRBIDR_EL1) & TRBIDR_EL1_P))
> >> - vcpu_set_flag(vcpu, DEBUG_STATE_SAVE_TRBE);
> >> + /*
> >> + * Set SAVE_TRFCR flag if FEAT_TRF (TraceFilt) exists. This flag
> >> + * signifies that the exclude_host/exclude_guest settings of any active
> >> + * host Perf session on a core running a VCPU can be written into
> >> + * TRFCR_EL1 on guest switch.
> >> + */
> >> + if (cpuid_feature_extract_unsigned_field(dfr0, ID_AA64DFR0_EL1_TraceFilt_SHIFT)) {
> >> + vcpu_set_flag(vcpu, DEBUG_STATE_SAVE_TRFCR);
> >
> > Can we avoid doing this unconditionally? It only makes sense to save
> > the trace crud if it is going to be changed, right?
> >
>
> Do you mean to see if kvm_guest_trfcr was non-zero (and would have to be
> changed) at VCPU load? I assumed that it could be modified between load
> and switch. That would mean there is no way to do it conditionally.
What's the problem? If you change the value behind the vcpu's back,
you get what you deserve: garbage.
I'm baffled that you consider that randomly changing a value without
proper synchronisation (such as with an IPI) is a valid approach.
Please look at what is being done for the PMU in the same context.
> I also assumed that's the reason SPE and TRBE were implemented like
> this, with the feat check at load and the enabled check at switch. It
> doesn't feel like TRFCR is any different to those two.
Well, that' doesn't make it right. Having just looked at the debug
stuff, I'm ashamed to have let that stuff in.
> Or do you mean to only set DEBUG_STATE_SAVE_TRFCR on switch if tracing
> was enabled?
I don't think there should be any flag. The discriminant should be:
- does the HW support TRF?
- is the in-guest tracing enabled?
If both are true, and that this requires a change of configuration,
*then* you perform the change. Same thing on exit. No flag. And a
static key for TRF support, which should really be valid on all CPUs.
M.
--
Without deviation from the norm, progress is not possible.
_______________________________________________
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:[~2024-02-26 18:04 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-26 11:30 [PATCH v6 0/8] kvm/coresight: Support exclude guest and exclude host James Clark
2024-02-26 11:30 ` James Clark
2024-02-26 11:30 ` [PATCH v6 1/8] arm64: KVM: Fix renamed function in comment James Clark
2024-02-26 11:30 ` James Clark
2024-02-26 11:30 ` [PATCH v6 2/8] arm64/sysreg: Add a comment that the sysreg file should be sorted James Clark
2024-02-26 11:30 ` James Clark
2024-02-26 13:19 ` Mark Brown
2024-02-26 13:19 ` Mark Brown
2024-02-26 11:30 ` [PATCH v6 3/8] tools: arm64: Update sysreg.h header files James Clark
2024-02-26 11:30 ` James Clark
2024-02-26 11:30 ` [PATCH v6 4/8] arm64/sysreg/tools: Move TRFCR definitions to sysreg James Clark
2024-02-26 11:30 ` James Clark
2024-02-26 13:21 ` Mark Brown
2024-02-26 13:21 ` Mark Brown
2024-02-26 11:30 ` [PATCH v6 5/8] arm64: KVM: Add iflag for FEAT_TRF James Clark
2024-02-26 11:30 ` James Clark
2024-02-26 13:35 ` Marc Zyngier
2024-02-26 13:35 ` Marc Zyngier
2024-02-26 15:41 ` James Clark
2024-02-26 15:41 ` James Clark
2024-02-26 18:03 ` Marc Zyngier [this message]
2024-02-26 18:03 ` Marc Zyngier
2024-02-26 11:30 ` [PATCH v6 6/8] arm64: KVM: Add interface to set guest value for TRFCR register James Clark
2024-02-26 11:30 ` James Clark
2024-02-26 15:01 ` Marc Zyngier
2024-02-26 15:01 ` Marc Zyngier
2024-02-26 11:30 ` [PATCH v6 7/8] arm64: KVM: Write TRFCR value on guest switch with nVHE James Clark
2024-02-26 11:30 ` James Clark
2024-02-26 17:50 ` Marc Zyngier
2024-02-26 17:50 ` Marc Zyngier
2024-02-26 18:26 ` Marc Zyngier
2024-02-26 18:26 ` Marc Zyngier
2024-02-26 11:30 ` [PATCH v6 8/8] coresight: Pass guest TRFCR value to KVM James Clark
2024-02-26 11:30 ` James Clark
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=86a5nn2jci.wl-maz@kernel.org \
--to=maz@kernel.org \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=anshuman.khandual@arm.com \
--cc=ardb@kernel.org \
--cc=arnd@arndb.de \
--cc=broonie@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=coresight@lists.linaro.org \
--cc=james.clark@arm.com \
--cc=james.morse@arm.com \
--cc=javierm@redhat.com \
--cc=jingzhangos@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=mark.rutland@arm.com \
--cc=miguel.luis@oracle.com \
--cc=mike.leach@linaro.org \
--cc=oliver.upton@linux.dev \
--cc=qperret@google.com \
--cc=ryan.roberts@arm.com \
--cc=suzuki.poulose@arm.com \
--cc=tabba@google.com \
--cc=vdonnefort@google.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.