From: Alessandro Zucchelli <alessandro.zucchelli@bugseng.com>
To: Julien Grall <julien@xen.org>
Cc: Jan Beulich <jbeulich@suse.com>,
consulting@bugseng.com, Tamas K Lengyel <tamas@tklengyel.com>,
Alexandru Isaila <aisaila@bitdefender.com>,
Petre Pircalabu <ppircalabu@bitdefender.com>,
xen-devel@lists.xenproject.org, sstabellini@kernel.org,
bertrand.marquis@arm.com, michal.orzel@amd.com,
volodymyr_babchuk@epam.com
Subject: Re: [XEN PATCH] xen/mem_access: address violations of MISRA C: 2012 Rule 8.4
Date: Wed, 08 May 2024 16:02:32 +0200 [thread overview]
Message-ID: <5b84019c4e0111b3cc5e369b999fbfab@bugseng.com> (raw)
In-Reply-To: <47033435-c621-40f6-b5a9-a385f323f382@xen.org>
On 2024-05-03 11:32, Julien Grall wrote:
> Hi,
>
> On 03/05/2024 08:09, Alessandro Zucchelli wrote:
>> On 2024-04-29 17:58, Jan Beulich wrote:
>>> On 29.04.2024 17:45, Alessandro Zucchelli wrote:
>>>> Change #ifdef CONFIG_MEM_ACCESS by OR-ing defined(CONFIG_ARM),
>>>> allowing asm/mem_access.h to be included in all ARM build
>>>> configurations.
>>>> This is to address the violation of MISRA C: 2012 Rule 8.4 which
>>>> states:
>>>> "A compatible declaration shall be visible when an object or
>>>> function
>>>> with external linkage is defined". Functions p2m_mem_access_check
>>>> and p2m_mem_access_check_and_get_page when CONFIG_MEM_ACCESS is not
>>>> defined in ARM builds don't have visible declarations in the file
>>>> containing their definitions.
>>>>
>>>> Signed-off-by: Alessandro Zucchelli
>>>> <alessandro.zucchelli@bugseng.com>
>>>> ---
>>>> xen/include/xen/mem_access.h | 2 +-
>>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/xen/include/xen/mem_access.h
>>>> b/xen/include/xen/mem_access.h
>>>> index 87d93b31f6..ec0630677d 100644
>>>> --- a/xen/include/xen/mem_access.h
>>>> +++ b/xen/include/xen/mem_access.h
>>>> @@ -33,7 +33,7 @@
>>>> */
>>>> struct vm_event_st;
>>>>
>>>> -#ifdef CONFIG_MEM_ACCESS
>>>> +#if defined(CONFIG_MEM_ACCESS) || defined(CONFIG_ARM)
>>>> #include <asm/mem_access.h>
>>>> #endif
>>>
>>> This doesn't look quite right. If Arm supports mem-access, why would
>>> it
>>> not set MEM_ACCESS=y? Whereas if it's only stubs that Arm supplies,
>>> then
>>> those would better move here, thus eliminating the need for a
>>> per-arch
>>> stub header (see what was e.g. done for numa.h). This way RISC-V and
>>> PPC
>>> (and whatever is to come) would then be taken care of as well.
>>>
>> ARM does support mem-access, so I don't think this is akin to the
>> changes done to handle numa.h.
>> ARM also allows users to set MEM_ACCESS=n (e.g.
>> xen/arch/arm/configs/tiny64_defconfig) and builds just fine; however,
>> the implementation file mem_access.c is compiled unconditionally in
>> ARM's makefile, hence why the violation was spotted.
>> This is a bit unusual, so I was also hoping to get some feedback from
>> mem-access maintainers as to why this discrepancy from x86 exists. I
>> probably should have also included some ARM maintainers as well, so
>> I'm going to loop them in now.
>>
>> An alternative option I think is to make the compilation of arm's
>> mem_access.c conditional on CONFIG_MEM_ACCESS (as for x86/mm and
>> common).
>
> I can't think of a reason to have mem_access.c unconditional compiled
> in. So I think it should be conditional like on x86.
Hi,
attempting to build ARM with a configuration where MEM_ACCESS=n and
mem_access.c is conditioned on CONFIG_MEM_ACCESS results in a fail as
there are other pieces of code that call some mem_access.c functions
(p2m_mem_access_check_and_get_page, p2m_mem_access_check).
In a Matrix chat Julien was suggesting adding stubs for the functions
for this use case.
--
Alessandro Zucchelli, B.Sc.
Software Engineer, BUGSENG (https://bugseng.com)
next prev parent reply other threads:[~2024-05-08 14:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-29 15:45 [XEN PATCH] xen/mem_access: address violations of MISRA C: 2012 Rule 8.4 Alessandro Zucchelli
2024-04-29 15:58 ` Jan Beulich
2024-05-03 7:09 ` Alessandro Zucchelli
2024-05-03 9:32 ` Julien Grall
2024-05-08 14:02 ` Alessandro Zucchelli [this message]
2024-05-08 16:01 ` Tamas K Lengyel
2024-05-08 16:26 ` Julien Grall
2024-05-08 17:00 ` Tamas K Lengyel
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=5b84019c4e0111b3cc5e369b999fbfab@bugseng.com \
--to=alessandro.zucchelli@bugseng.com \
--cc=aisaila@bitdefender.com \
--cc=bertrand.marquis@arm.com \
--cc=consulting@bugseng.com \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=michal.orzel@amd.com \
--cc=ppircalabu@bitdefender.com \
--cc=sstabellini@kernel.org \
--cc=tamas@tklengyel.com \
--cc=volodymyr_babchuk@epam.com \
--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.