Stable Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] arm64: cpufeature: Fix truncating a feature value
@ 2019-10-10 11:08 Suzuki K Poulose
  2019-10-10 11:12 ` Suzuki K Poulose
  0 siblings, 1 reply; 9+ messages in thread
From: Suzuki K Poulose @ 2019-10-10 11:08 UTC (permalink / raw)
  To: stable
  Cc: suzuki.poulose, linux-arm-kernel, will, mark.rutland, catalin.marinas

A signed feature value is truncated to turn to an unsigned value
causing bad state in the system wide infrastructure. This affects
the discovery of FP/ASIMD support on arm64. Fix this by making sure
we cast it properly.

Fixes: 4f0a606bce5ec ("arm64: cpufeature: Track unsigned fields")
Cc: stable@vger.kernel.org # v4.4
Cc: Will Deacon <will@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 arch/arm64/include/asm/cpufeature.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h
index 0a66f8241f18..9eb0d8072dd9 100644
--- a/arch/arm64/include/asm/cpufeature.h
+++ b/arch/arm64/include/asm/cpufeature.h
@@ -151,8 +151,8 @@ static inline u64 arm64_ftr_mask(struct arm64_ftr_bits *ftrp)
 static inline s64 arm64_ftr_value(struct arm64_ftr_bits *ftrp, u64 val)
 {
 	return ftrp->sign ?
-		cpuid_feature_extract_field_width(val, ftrp->shift, ftrp->width) :
-		cpuid_feature_extract_unsigned_field_width(val, ftrp->shift, ftrp->width);
+		(s64)cpuid_feature_extract_field_width(val, ftrp->shift, ftrp->width) :
+		(s64)cpuid_feature_extract_unsigned_field_width(val, ftrp->shift, ftrp->width);
 }
 
 static inline bool id_aa64mmfr0_mixed_endian_el0(u64 mmfr0)
-- 
2.21.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] arm64: cpufeature: Fix truncating a feature value
  2019-10-10 11:08 [PATCH] arm64: cpufeature: Fix truncating a feature value Suzuki K Poulose
@ 2019-10-10 11:12 ` Suzuki K Poulose
  2019-10-10 12:29   ` Greg KH
  0 siblings, 1 reply; 9+ messages in thread
From: Suzuki K Poulose @ 2019-10-10 11:12 UTC (permalink / raw)
  To: stable; +Cc: mark.rutland, catalin.marinas, will, linux-arm-kernel

All,

On 10/10/2019 12:08, Suzuki K Poulose wrote:
> A signed feature value is truncated to turn to an unsigned value
> causing bad state in the system wide infrastructure. This affects
> the discovery of FP/ASIMD support on arm64. Fix this by making sure
> we cast it properly.
> 
> Fixes: 4f0a606bce5ec ("arm64: cpufeature: Track unsigned fields")
> Cc: stable@vger.kernel.org # v4.4

Please note that this patch is only applicable for stable 4.4 tree.
I should have removed the Fixes tag.

Cheers
Suzuki

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] arm64: cpufeature: Fix truncating a feature value
  2019-10-10 11:12 ` Suzuki K Poulose
@ 2019-10-10 12:29   ` Greg KH
  2019-10-10 12:46     ` Suzuki K Poulose
  2019-10-10 13:19     ` Suzuki K Poulose
  0 siblings, 2 replies; 9+ messages in thread
From: Greg KH @ 2019-10-10 12:29 UTC (permalink / raw)
  To: Suzuki K Poulose
  Cc: stable, mark.rutland, catalin.marinas, will, linux-arm-kernel

On Thu, Oct 10, 2019 at 12:12:01PM +0100, Suzuki K Poulose wrote:
> All,
> 
> On 10/10/2019 12:08, Suzuki K Poulose wrote:
> > A signed feature value is truncated to turn to an unsigned value
> > causing bad state in the system wide infrastructure. This affects
> > the discovery of FP/ASIMD support on arm64. Fix this by making sure
> > we cast it properly.
> > 
> > Fixes: 4f0a606bce5ec ("arm64: cpufeature: Track unsigned fields")
> > Cc: stable@vger.kernel.org # v4.4
> 
> Please note that this patch is only applicable for stable 4.4 tree.
> I should have removed the Fixes tag.

Why is it only for 4.4?  That needs to be documented really really
really well in the changelog as to why this is a one-off patch, and why
we can't just take the relevant patches that are in Linus's tree
instead.

Please fix up and resend.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] arm64: cpufeature: Fix truncating a feature value
  2019-10-10 12:29   ` Greg KH
@ 2019-10-10 12:46     ` Suzuki K Poulose
  2019-10-10 13:16       ` Greg KH
  2019-10-10 13:19     ` Suzuki K Poulose
  1 sibling, 1 reply; 9+ messages in thread
From: Suzuki K Poulose @ 2019-10-10 12:46 UTC (permalink / raw)
  To: Greg KH; +Cc: stable, mark.rutland, catalin.marinas, will, linux-arm-kernel



On 10/10/2019 13:29, Greg KH wrote:
> On Thu, Oct 10, 2019 at 12:12:01PM +0100, Suzuki K Poulose wrote:
>> All,
>>
>> On 10/10/2019 12:08, Suzuki K Poulose wrote:
>>> A signed feature value is truncated to turn to an unsigned value
>>> causing bad state in the system wide infrastructure. This affects
>>> the discovery of FP/ASIMD support on arm64. Fix this by making sure
>>> we cast it properly.
>>>
>>> Fixes: 4f0a606bce5ec ("arm64: cpufeature: Track unsigned fields")
>>> Cc: stable@vger.kernel.org # v4.4
>>
>> Please note that this patch is only applicable for stable 4.4 tree.
>> I should have removed the Fixes tag.
> 
> Why is it only for 4.4?  That needs to be documented really really

This was fixed later in v4.6 onwards with commit 28c5dcb22f90113dea
("arm64: Rename cpuid_feature field extract routines") rather inadvertently.

> really well in the changelog as to why this is a one-off patch, and why
> we can't just take the relevant patches that are in Linus's tree
> instead.
> 
> Please fix up and resend.

I can resend the patch with the above information included if you like.

Cheers
Suzuki

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] arm64: cpufeature: Fix truncating a feature value
  2019-10-10 12:46     ` Suzuki K Poulose
@ 2019-10-10 13:16       ` Greg KH
  0 siblings, 0 replies; 9+ messages in thread
From: Greg KH @ 2019-10-10 13:16 UTC (permalink / raw)
  To: Suzuki K Poulose
  Cc: stable, mark.rutland, catalin.marinas, will, linux-arm-kernel

On Thu, Oct 10, 2019 at 01:46:21PM +0100, Suzuki K Poulose wrote:
> 
> 
> On 10/10/2019 13:29, Greg KH wrote:
> > On Thu, Oct 10, 2019 at 12:12:01PM +0100, Suzuki K Poulose wrote:
> > > All,
> > > 
> > > On 10/10/2019 12:08, Suzuki K Poulose wrote:
> > > > A signed feature value is truncated to turn to an unsigned value
> > > > causing bad state in the system wide infrastructure. This affects
> > > > the discovery of FP/ASIMD support on arm64. Fix this by making sure
> > > > we cast it properly.
> > > > 
> > > > Fixes: 4f0a606bce5ec ("arm64: cpufeature: Track unsigned fields")
> > > > Cc: stable@vger.kernel.org # v4.4
> > > 
> > > Please note that this patch is only applicable for stable 4.4 tree.
> > > I should have removed the Fixes tag.
> > 
> > Why is it only for 4.4?  That needs to be documented really really
> 
> This was fixed later in v4.6 onwards with commit 28c5dcb22f90113dea
> ("arm64: Rename cpuid_feature field extract routines") rather inadvertently.
> 
> > really well in the changelog as to why this is a one-off patch, and why
> > we can't just take the relevant patches that are in Linus's tree
> > instead.
> > 
> > Please fix up and resend.
> 
> I can resend the patch with the above information included if you like.

As I said, please do, I can not take it otherwise.

greg k-h

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH] arm64: cpufeature: Fix truncating a feature value
  2019-10-10 12:29   ` Greg KH
  2019-10-10 12:46     ` Suzuki K Poulose
@ 2019-10-10 13:19     ` Suzuki K Poulose
  2019-10-11  4:55       ` Greg KH
  1 sibling, 1 reply; 9+ messages in thread
From: Suzuki K Poulose @ 2019-10-10 13:19 UTC (permalink / raw)
  To: stable
  Cc: suzuki.poulose, linux-arm-kernel, will, mark.rutland, catalin.marinas

A signed feature value is truncated to turn to an unsigned value
causing bad state in the system wide infrastructure. This affects
the discovery of FP/ASIMD support on arm64. Fix this by making sure
we cast it properly.

This was inadvertently fixed upstream in v4.6 onwards with the following :
commit 28c5dcb22f90113dea ("arm64: Rename cpuid_feature field extract routines")

Cc: stable@vger.kernel.org # v4.4
Cc: Will Deacon <will@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 arch/arm64/include/asm/cpufeature.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h
index 0a66f8241f18..9eb0d8072dd9 100644
--- a/arch/arm64/include/asm/cpufeature.h
+++ b/arch/arm64/include/asm/cpufeature.h
@@ -151,8 +151,8 @@ static inline u64 arm64_ftr_mask(struct arm64_ftr_bits *ftrp)
 static inline s64 arm64_ftr_value(struct arm64_ftr_bits *ftrp, u64 val)
 {
 	return ftrp->sign ?
-		cpuid_feature_extract_field_width(val, ftrp->shift, ftrp->width) :
-		cpuid_feature_extract_unsigned_field_width(val, ftrp->shift, ftrp->width);
+		(s64)cpuid_feature_extract_field_width(val, ftrp->shift, ftrp->width) :
+		(s64)cpuid_feature_extract_unsigned_field_width(val, ftrp->shift, ftrp->width);
 }
 
 static inline bool id_aa64mmfr0_mixed_endian_el0(u64 mmfr0)
-- 
2.21.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] arm64: cpufeature: Fix truncating a feature value
  2019-10-10 13:19     ` Suzuki K Poulose
@ 2019-10-11  4:55       ` Greg KH
  2019-10-11 10:31         ` Suzuki K Poulose
  0 siblings, 1 reply; 9+ messages in thread
From: Greg KH @ 2019-10-11  4:55 UTC (permalink / raw)
  To: Suzuki K Poulose
  Cc: stable, linux-arm-kernel, will, mark.rutland, catalin.marinas

On Thu, Oct 10, 2019 at 02:19:43PM +0100, Suzuki K Poulose wrote:
> A signed feature value is truncated to turn to an unsigned value
> causing bad state in the system wide infrastructure. This affects
> the discovery of FP/ASIMD support on arm64. Fix this by making sure
> we cast it properly.
> 
> This was inadvertently fixed upstream in v4.6 onwards with the following :
> commit 28c5dcb22f90113dea ("arm64: Rename cpuid_feature field extract routines")

What prevents us from just taking that commit instead?  You did not
document that here at all, which I thought I asked for.

Also, you only need 12 digits for a sha1, 28c5dcb22f90 ("arm64: Rename
cpuid_feature field extract routines") would be just fine :)

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] arm64: cpufeature: Fix truncating a feature value
  2019-10-11  4:55       ` Greg KH
@ 2019-10-11 10:31         ` Suzuki K Poulose
  2019-10-11 12:13           ` Greg KH
  0 siblings, 1 reply; 9+ messages in thread
From: Suzuki K Poulose @ 2019-10-11 10:31 UTC (permalink / raw)
  To: Greg KH; +Cc: stable, linux-arm-kernel, will, mark.rutland, catalin.marinas

Hi Greg,

On 11/10/2019 05:55, Greg KH wrote:
> On Thu, Oct 10, 2019 at 02:19:43PM +0100, Suzuki K Poulose wrote:
>> A signed feature value is truncated to turn to an unsigned value
>> causing bad state in the system wide infrastructure. This affects
>> the discovery of FP/ASIMD support on arm64. Fix this by making sure
>> we cast it properly.
>>
>> This was inadvertently fixed upstream in v4.6 onwards with the following :
>> commit 28c5dcb22f90113dea ("arm64: Rename cpuid_feature field extract routines")
> 
> What prevents us from just taking that commit instead?  You did not
> document that here at all, which I thought I asked for.

Sorry, I missed that part. So, that change introduces helpers to
extract feature fields based on the sign. And it also depends on

commit ff96f7bc7bf6 ("arm64: capabilities: Handle sign of the feature bit")

which introduces "sign" bit for the "capability" list and modifies
the generic capability->matches() helpers to use the hint to switch to the
appropriate helpers.

I could backport parts of the commit 28c5dcb22f90 dropping the bits
that affect the changes mentioned above.

> 
> Also, you only need 12 digits for a sha1, 28c5dcb22f90 ("arm64: Rename
> cpuid_feature field extract routines") would be just fine :)

Yea, I understand. Its simply a pain to count the numbers, so I make sure
to pickup something that looks larger than the 12 ;-). I will try to stick
to that :-)

Cheers
Suzuki


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] arm64: cpufeature: Fix truncating a feature value
  2019-10-11 10:31         ` Suzuki K Poulose
@ 2019-10-11 12:13           ` Greg KH
  0 siblings, 0 replies; 9+ messages in thread
From: Greg KH @ 2019-10-11 12:13 UTC (permalink / raw)
  To: Suzuki K Poulose
  Cc: stable, linux-arm-kernel, will, mark.rutland, catalin.marinas

On Fri, Oct 11, 2019 at 11:31:30AM +0100, Suzuki K Poulose wrote:
> Hi Greg,
> 
> On 11/10/2019 05:55, Greg KH wrote:
> > On Thu, Oct 10, 2019 at 02:19:43PM +0100, Suzuki K Poulose wrote:
> > > A signed feature value is truncated to turn to an unsigned value
> > > causing bad state in the system wide infrastructure. This affects
> > > the discovery of FP/ASIMD support on arm64. Fix this by making sure
> > > we cast it properly.
> > > 
> > > This was inadvertently fixed upstream in v4.6 onwards with the following :
> > > commit 28c5dcb22f90113dea ("arm64: Rename cpuid_feature field extract routines")
> > 
> > What prevents us from just taking that commit instead?  You did not
> > document that here at all, which I thought I asked for.
> 
> Sorry, I missed that part. So, that change introduces helpers to
> extract feature fields based on the sign. And it also depends on
> 
> commit ff96f7bc7bf6 ("arm64: capabilities: Handle sign of the feature bit")
> 
> which introduces "sign" bit for the "capability" list and modifies
> the generic capability->matches() helpers to use the hint to switch to the
> appropriate helpers.

That's ok, does that cause any problems?  We always want the original
patch instead of a one-off patch as that way we do not diverge.

> I could backport parts of the commit 28c5dcb22f90 dropping the bits
> that affect the changes mentioned above.

Please do, that is always prefered as well, but do the first thing above
if at all possible.

> > 
> > Also, you only need 12 digits for a sha1, 28c5dcb22f90 ("arm64: Rename
> > cpuid_feature field extract routines") would be just fine :)
> 
> Yea, I understand. Its simply a pain to count the numbers, so I make sure
> to pickup something that looks larger than the 12 ;-). I will try to stick
> to that :-)

	git show -s --abbrev-commit --abbrev=12 --pretty=format:"%h (\"%s\")%n"
will give you the correct format.  I suggest making it a git alias :)

Or, use:
	[core]
	        abbrev = 12
in your .gitconfig file.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, back to index

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-10 11:08 [PATCH] arm64: cpufeature: Fix truncating a feature value Suzuki K Poulose
2019-10-10 11:12 ` Suzuki K Poulose
2019-10-10 12:29   ` Greg KH
2019-10-10 12:46     ` Suzuki K Poulose
2019-10-10 13:16       ` Greg KH
2019-10-10 13:19     ` Suzuki K Poulose
2019-10-11  4:55       ` Greg KH
2019-10-11 10:31         ` Suzuki K Poulose
2019-10-11 12:13           ` Greg KH

Stable Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/stable/0 stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ https://lore.kernel.org/stable \
		stable@vger.kernel.org
	public-inbox-index stable

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.stable


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git