mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Robin Murphy <robin.murphy@arm.com>
To: Will Deacon <will@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>,
	Anders Roxell <anders.roxell@linaro.org>,
	Kees Cook <keescook@chromium.org>,
	"Gustavo A. R. Silva" <gustavo@embeddedor.com>,
	catalin.marinas@arm.com, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 1/3] arm64: perf: Mark expected switch fall-through
Date: Fri, 26 Jul 2019 14:28:38 +0100	[thread overview]
Message-ID: <0dc7d97f-88bb-6416-d731-afbf0d3c6133@arm.com> (raw)
In-Reply-To: <20190726130523.ftmc2un7fwwcegrr@willie-the-truck>

On 26/07/2019 14:05, Will Deacon wrote:
> On Fri, Jul 26, 2019 at 01:38:24PM +0100, Robin Murphy wrote:
>> On 26/07/2019 13:27, Will Deacon wrote:
>>> On Fri, Jul 26, 2019 at 01:13:54PM +0100, Mark Rutland wrote:
>>>> On Fri, Jul 26, 2019 at 01:10:57PM +0100, Mark Rutland wrote:
>>>>> On Fri, Jul 26, 2019 at 01:27:16PM +0200, Anders Roxell wrote:
>>>>>> When fall-through warnings was enabled by default, commit d93512ef0f0e
>>>>>> ("Makefile: Globally enable fall-through warning"), the following
>>>>>> warnings was starting to show up:
>>>>>>
>>>>>> ../arch/arm64/kernel/hw_breakpoint.c: In function ‘hw_breakpoint_arch_parse’:
>>>>>> ../arch/arm64/kernel/hw_breakpoint.c:540:7: warning: this statement may fall
>>>>>>    through [-Wimplicit-fallthrough=]
>>>>>>       if (hw->ctrl.len == ARM_BREAKPOINT_LEN_1)
>>>>>>          ^
>>>>>> ../arch/arm64/kernel/hw_breakpoint.c:542:3: note: here
>>>>>>      case 2:
>>>>>>      ^~~~
>>>>>> ../arch/arm64/kernel/hw_breakpoint.c:544:7: warning: this statement may fall
>>>>>>    through [-Wimplicit-fallthrough=]
>>>>>>       if (hw->ctrl.len == ARM_BREAKPOINT_LEN_2)
>>>>>>          ^
>>>>>> ../arch/arm64/kernel/hw_breakpoint.c:546:3: note: here
>>>>>>      default:
>>>>>>      ^~~~~~~
>>>>>>
>>>>>> Rework so that the compiler doesn't warn about fall-through. Rework so
>>>>>> the code looks like the arm code. Since the comment in the function
>>>>>> indicates taht this is supposed to behave the same way as arm32 because
>>>>>
>>>>> Typo: s/taht/that/
>>>>>
>>>>>> it handles 32-bit tasks also.
>>>>>>
>>>>>> Cc: stable@vger.kernel.org # v3.16+
>>>>>> Fixes: 6ee33c2712fc ("ARM: hw_breakpoint: correct and simplify alignment fixup code")
>>>>>> Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
>>>>>
>>>>> The patch itself looks fine, but I don't think this needs a CC to
>>>>> stable, nor does it require that fixes tag, as there's no functional
>>>>> problem.
>>>>
>>>> Hmm... I now see I spoke too soon, and this is making the 1-byte
>>>> breakpoint work at a 3-byte offset.
>>>
>>> I still don't think it's quite right though, since it forbids a 2-byte
>>> watchpoint on a byte-aligned address.
>>
>> Plus, AFAICS, a 1-byte watchpoint on a 2-byte-aligned address.

[and of course, what I missed was that that's the case the fallthrough 
serves... yuck indeed]

>> Not that I know anything about this code, but it does start to look like it
>> might want rewriting without the offending switch statement anyway. At a
>> glance, it looks like the intended semantic might boil down to:
>>
>> 	if (hw->ctrl.len > offset)
>> 		return -EINVAL;
> 
> Given that it's compat code, I think it's worth staying as close to the
> arch/arm/ implementation as we can.

Right, I also misread the accompanying arch/arm/ patch and got the 
impression that 32-bit also had a problem such that any fix would happen 
in parallel - on closer inspection the current arch/arm/ code does 
actually seem to make sense, even if it is horribly subtle.

> Also, beware that the
> ARM_BREAKPOINT_LEN_* definitions are masks because of the BAS fields in
> the debug architecture.

Fun... Clearly it's a bit too Friday for me to be useful here, so 
apologies for the confusion :)

Robin.

      reply	other threads:[~2019-07-26 13:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-26 11:27 Anders Roxell
2019-07-26 12:10 ` Mark Rutland
2019-07-26 12:13   ` Mark Rutland
2019-07-26 12:27     ` Will Deacon
2019-07-26 12:38       ` Robin Murphy
2019-07-26 13:05         ` Will Deacon
2019-07-26 13:28           ` Robin Murphy [this message]

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=0dc7d97f-88bb-6416-d731-afbf0d3c6133@arm.com \
    --to=robin.murphy@arm.com \
    --cc=anders.roxell@linaro.org \
    --cc=catalin.marinas@arm.com \
    --cc=gustavo@embeddedor.com \
    --cc=keescook@chromium.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=stable@vger.kernel.org \
    --cc=will@kernel.org \
    /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

all inboxes | Powered by JetHome®