From: Marc Zyngier <marc.zyngier@arm.com>
To: Suzuki K Poulose <Suzuki.Poulose@arm.com>,
Christoffer Dall <christoffer.dall@linaro.org>
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Radim Krčmář" <rkrcmar@redhat.com>,
kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu,
linux-arm-kernel@lists.infradead.org,
"Eric Auger" <eric.auger@redhat.com>,
"Jintack Lim" <jintack@cs.columbia.edu>
Subject: Re: [PATCH 2/3] KVM: arm64: Access CNTHCTL_EL2 bit fields correctly on VHE systems
Date: Mon, 16 Jan 2017 13:30:42 +0000 [thread overview]
Message-ID: <61f7dbf1-e20d-e9e4-950c-6a224619cf31@arm.com> (raw)
In-Reply-To: <e0d1473f-0cf9-a801-585b-4385bc5b35ab@arm.com>
On 13/01/17 14:56, Suzuki K Poulose wrote:
> On 13/01/17 13:30, Marc Zyngier wrote:
>> [+ Suzuki, who wrote the whole cpus_have_const_cap thing]
>>
[...]
>> But maybe we should have have some stronger guarantees that we'll
>> always get things inlined, and that the "const" side is enforced:
>
> Agreed.
>
>>
>> diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h
>> index b4989df..4710469 100644
>> --- a/arch/arm64/include/asm/cpufeature.h
>> +++ b/arch/arm64/include/asm/cpufeature.h
>> @@ -105,10 +105,11 @@ static inline bool cpu_have_feature(unsigned int num)
>> }
>>
>> /* System capability check for constant caps */
>> -static inline bool cpus_have_const_cap(int num)
>> +static __always_inline bool cpus_have_const_cap(int num)
>
> I think we should have the above change and make it inline always.
>
>> {
>> - if (num >= ARM64_NCAPS)
>> - return false;
>> + BUILD_BUG_ON(!__builtin_constant_p(num));
>
> This is not needed, as the compilation would fail if num is not a constant with
> static key code.
>
>> + BUILD_BUG_ON(num >= ARM64_NCAPS);
>> +
>
> Also, I think it would be good to return false for caps > the ARM64_NCAPS, in sync
> with the non-const version.
But what's the semantic? It means we're accessing a capability that
doesn't exist, which looks like a major bug in my book. Is there any
valid use case for this?
Thanks,
M.
--
Jazz is not dead. It just smells funny...
next prev parent reply other threads:[~2017-01-16 13:30 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-13 11:31 [PATCH 0/3] KVM/ARM updates for 4.10-rc4 Marc Zyngier
2017-01-13 11:31 ` [PATCH 1/3] KVM: arm/arm64: Fix occasional warning from the timer work function Marc Zyngier
2017-01-13 11:31 ` [PATCH 2/3] KVM: arm64: Access CNTHCTL_EL2 bit fields correctly on VHE systems Marc Zyngier
2017-01-13 12:36 ` Christoffer Dall
2017-01-13 13:30 ` Marc Zyngier
2017-01-13 13:46 ` Christoffer Dall
2017-01-13 13:57 ` Marc Zyngier
2017-01-13 14:14 ` Christoffer Dall
2017-01-13 14:42 ` Mark Rutland
2017-01-13 14:55 ` Mark Rutland
2017-01-13 14:56 ` Suzuki K Poulose
2017-01-13 19:04 ` Jintack Lim
2017-01-16 13:30 ` Marc Zyngier [this message]
2017-01-16 14:11 ` Marc Zyngier
2017-01-16 14:19 ` Suzuki K Poulose
2017-01-13 14:46 ` Mark Rutland
2017-01-13 14:57 ` Marc Zyngier
2017-01-13 11:31 ` [PATCH 3/3] KVM: arm/arm64: vgic: Fix deadlock on error handling Marc Zyngier
2017-01-17 16:49 ` [PATCH 0/3] KVM/ARM updates for 4.10-rc4 Radim Krčmář
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=61f7dbf1-e20d-e9e4-950c-6a224619cf31@arm.com \
--to=marc.zyngier@arm.com \
--cc=Suzuki.Poulose@arm.com \
--cc=christoffer.dall@linaro.org \
--cc=eric.auger@redhat.com \
--cc=jintack@cs.columbia.edu \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@redhat.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