From: Nicola Vetrini <nicola.vetrini@bugseng.com>
To: Julien Grall <julien@xen.org>
Cc: xen-devel@lists.xenproject.org, consulting@bugseng.com,
Stefano Stabellini <sstabellini@kernel.org>,
Bertrand Marquis <bertrand.marquis@arm.com>,
Michal Orzel <michal.orzel@amd.com>,
Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
Subject: Re: [XEN PATCH 5/7] xen/arm: traps: add ASSERT_UNREACHABLE() where needed
Date: Mon, 11 Dec 2023 18:36:33 +0100 [thread overview]
Message-ID: <920a835236ff8cf922e515c5082770b7@bugseng.com> (raw)
In-Reply-To: <95690c3a-92c5-4e05-856b-088133b87650@xen.org>
On 2023-12-11 17:05, Julien Grall wrote:
> On 11/12/2023 15:59, Julien Grall wrote:
>> Hi Nicola,
>>
>> On 11/12/2023 14:54, Nicola Vetrini wrote:
>>> On 2023-12-11 13:32, Julien Grall wrote:
>>>> Hi,
>>>>
>>>> On 11/12/2023 10:30, Nicola Vetrini wrote:
>>>>> The branches of the switch after a call to 'do_unexpected_trap'
>>>>> cannot return, but there is one path that may return, hence
>>>>> only some clauses are marked with ASSERT_UNREACHABLE().
>>>> I don't understand why this is necessary. The code should never be
>>>> reachable because do_unexpected_trap() is a noreturn().
>>>>
>>>> Cheers,
>>>
>>> It was meant as a safeguard against mistakes.
>>
>> I am confused about which mistakes you are trying to prevent. Are you
>> saying you are not trusting the noreturn attribute?
>>
>> And if so, are you intending to add ASSERT_UNREACHABLE() after every
>> single call to noreturn functions?
>
> Replying to myself. What's confusing the most is that in [1], you
> decided to not add the ASSERT_UNREACHABLE(). Yet the problem is
> similar.
>
> I'd also like to point out that by removing the "break", then if the
> 'noreturn' function turns out to return, then in prod build you would
> fallthrough to the next case. And who knows what's going to happen...
>
> All of this really adds some confusion...
>
I should have checked before responding: do_trap_hyp_sync is not afaik
noreturn. Specifically, do_trap_brk may return. If I worked under the
wrong assumption, then certainly the ASSERT_UNREACHABLE-s should be
dropped.
>>
>>> There are MISRA rules that deal with this aspect (e.g., a noreturn
>>> function should not return), but they are not in Amendment 2, which
>>> is what Xen is following.
>> Do you mind providing a bit more details about the rules you are
>> talking about? At least the numbers would be helpful.
>
> [1]
> https://lore.kernel.org/xen-devel/c0a8a12e39d688e101936d221af0f8eeefabe352.1702283415.git.nicola.vetrini@bugseng.com/
>
> Cheers,
Sure. Here are the rules concerned with _Noreturn:
R17.9: A function declared with a _Noreturn function specifier shall not
return to its caller
R17.10: A function declared with a _Noreturn function specifier shall
have void return type
R17.11: A function that never returns should be declared with a
_Noreturn function specifier
--
Nicola Vetrini, BSc
Software Engineer, BUGSENG srl (https://bugseng.com)
next prev parent reply other threads:[~2023-12-11 17:36 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-11 10:30 [XEN PATCH 0/7] address violations of MISRA C:2012 Rule 2.1 Nicola Vetrini
2023-12-11 10:30 ` [XEN PATCH 1/7] xen/shutdown: address " Nicola Vetrini
2023-12-12 1:39 ` Stefano Stabellini
2023-12-12 9:45 ` Jan Beulich
2023-12-12 9:53 ` Nicola Vetrini
2023-12-12 10:30 ` Jan Beulich
2023-12-11 10:30 ` [XEN PATCH 2/7] x86/mm: " Nicola Vetrini
2023-12-12 1:42 ` Stefano Stabellini
2023-12-12 9:12 ` Nicola Vetrini
2023-12-12 9:53 ` Jan Beulich
2023-12-13 14:44 ` Nicola Vetrini
2023-12-14 7:57 ` Jan Beulich
2023-12-14 8:52 ` Nicola Vetrini
2023-12-11 10:30 ` [XEN PATCH 3/7] xen/arm: " Nicola Vetrini
2023-12-11 12:29 ` Julien Grall
2023-12-11 13:06 ` Michal Orzel
2023-12-11 14:14 ` Julien Grall
2023-12-11 14:52 ` Nicola Vetrini
2023-12-11 10:30 ` [XEN PATCH 4/7] xen/sched: " Nicola Vetrini
2023-12-11 13:30 ` George Dunlap
2023-12-12 1:43 ` Stefano Stabellini
2023-12-11 10:30 ` [XEN PATCH 5/7] xen/arm: traps: add ASSERT_UNREACHABLE() where needed Nicola Vetrini
2023-12-11 12:32 ` Julien Grall
2023-12-11 14:54 ` Nicola Vetrini
2023-12-11 15:59 ` Julien Grall
2023-12-11 16:05 ` Julien Grall
2023-12-11 17:36 ` Nicola Vetrini [this message]
2023-12-12 1:36 ` Stefano Stabellini
2023-12-12 9:23 ` Julien Grall
2023-12-12 15:49 ` Julien Grall
2023-12-13 14:02 ` Nicola Vetrini
2023-12-14 9:42 ` Julien Grall
2023-12-14 22:32 ` Stefano Stabellini
2023-12-15 11:03 ` Nicola Vetrini
2023-12-15 14:08 ` Nicola Vetrini
2023-12-15 18:18 ` Julien Grall
2023-12-15 21:02 ` Stefano Stabellini
2023-12-11 10:30 ` [XEN PATCH 6/7] x86/platform: removed break to address MISRA C:2012 Rule 2.1 Nicola Vetrini
2023-12-12 1:44 ` Stefano Stabellini
2023-12-12 10:13 ` Jan Beulich
2023-12-12 22:38 ` Stefano Stabellini
2023-12-13 10:43 ` Nicola Vetrini
2023-12-11 10:30 ` [XEN PATCH 7/7] x86/xstate: move BUILD_BUG_ON " Nicola Vetrini
2023-12-12 1:46 ` Stefano Stabellini
2023-12-12 10:04 ` Jan Beulich
2023-12-12 10:07 ` Jan Beulich
2023-12-12 13:38 ` Nicola Vetrini
2023-12-12 14:01 ` Jan Beulich
2023-12-12 14:05 ` Nicola Vetrini
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=920a835236ff8cf922e515c5082770b7@bugseng.com \
--to=nicola.vetrini@bugseng.com \
--cc=Volodymyr_Babchuk@epam.com \
--cc=bertrand.marquis@arm.com \
--cc=consulting@bugseng.com \
--cc=julien@xen.org \
--cc=michal.orzel@amd.com \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.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 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.