From: Nicola Vetrini <nicola.vetrini@bugseng.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: sstabellini@kernel.org, michal.orzel@amd.com,
xenia.ragiadakou@amd.com, ayan.kumar.halder@amd.com,
consulting@bugseng.com, andrew.cooper3@citrix.com,
roger.pau@citrix.com, Julien Grall <julien@xen.org>,
Bertrand Marquis <bertrand.marquis@arm.com>,
Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>,
George Dunlap <george.dunlap@citrix.com>, Wei Liu <wl@xen.org>,
xen-devel@lists.xenproject.org
Subject: Re: [XEN PATCH v2 1/7] xen: add declarations for variables where needed
Date: Mon, 16 Oct 2023 19:05:40 +0200 [thread overview]
Message-ID: <f89fc0b2814cc4b84abc431c0355b348@bugseng.com> (raw)
In-Reply-To: <2023f16b-46fb-2a19-9620-7872b3029b5f@suse.com>
On 16/10/2023 16:50, Jan Beulich wrote:
> On 09.10.2023 08:54, Nicola Vetrini wrote:
>> Some variables with external linkage used in C code do not have
>> a visible declaration where they are defined. Providing such
>> declaration also resolves violations of MISRA C:2012 Rule 8.4.
>>
>> Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
>
> This is a mix of different approaches to the same underlying issue. I
> think respectively splitting would have helped.
>
>> --- a/xen/arch/x86/include/asm/compat.h
>> +++ b/xen/arch/x86/include/asm/compat.h
>> @@ -13,6 +13,7 @@ typedef unsigned long full_ptr_t;
>>
>> struct domain;
>> #ifdef CONFIG_PV32
>> +extern unsigned long cr4_pv32_mask;
>
> Why is this needed? Didn't we say declarations aren't needed when the
> only consumer is assembly code? (I also wonder how this header is any
> more "appropriate" - see the changelog entry - than about any other
> one.)
>
It was pointed out to me [1] that compat.h might be more appropriate
than setup.h
(probably because the asm code referencing it is under x86_64/compat).
Further, while it's true that this variable is used in asm, it's also
used in x86/setup.c, hence
the need for a declaration.
>> --- a/xen/arch/x86/include/asm/setup.h
>> +++ b/xen/arch/x86/include/asm/setup.h
>> @@ -13,6 +13,7 @@ extern char __2M_rwdata_start[], __2M_rwdata_end[];
>> extern unsigned long xenheap_initial_phys_start;
>> extern uint64_t boot_tsc_stamp;
>>
>> +extern char cpu0_stack[STACK_SIZE];
>
> Same question here.
>
This one is a bit more nuanced (I wouldn't oppose deviating this), but
there is indeed one use.
>> --- a/xen/common/symbols.c
>> +++ b/xen/common/symbols.c
>> @@ -21,23 +21,6 @@
>> #include <xen/guest_access.h>
>> #include <xen/errno.h>
>>
>> -#ifdef SYMBOLS_ORIGIN
>> -extern const unsigned int symbols_offsets[];
>> -#define symbols_address(n) (SYMBOLS_ORIGIN + symbols_offsets[n])
>> -#else
>> -extern const unsigned long symbols_addresses[];
>> -#define symbols_address(n) symbols_addresses[n]
>> -#endif
>> -extern const unsigned int symbols_num_syms;
>> -extern const u8 symbols_names[];
>> -
>> -extern const struct symbol_offset symbols_sorted_offsets[];
>> -
>> -extern const u8 symbols_token_table[];
>> -extern const u16 symbols_token_index[];
>> -
>> -extern const unsigned int symbols_markers[];
>> -
>> /* expand a compressed symbol data into the resulting uncompressed
>> string,
>> given the offset to where the symbol is in the compressed stream
>> */
>> static unsigned int symbols_expand_symbol(unsigned int off, char
>> *result)
>> --- a/xen/include/xen/symbols.h
>> +++ b/xen/include/xen/symbols.h
>> @@ -33,4 +33,22 @@ struct symbol_offset {
>> uint32_t stream; /* .. in the compressed stream.*/
>> uint32_t addr; /* .. and in the fixed size address array. */
>> };
>> +
>> +#ifdef SYMBOLS_ORIGIN
>> +extern const unsigned int symbols_offsets[];
>> +#define symbols_address(n) (SYMBOLS_ORIGIN + symbols_offsets[n])
>> +#else
>> +extern const unsigned long symbols_addresses[];
>> +#define symbols_address(n) symbols_addresses[n]
>> +#endif
>> +extern const unsigned int symbols_num_syms;
>> +extern const u8 symbols_names[];
>> +
>> +extern const struct symbol_offset symbols_sorted_offsets[];
>> +
>> +extern const u8 symbols_token_table[];
>> +extern const u16 symbols_token_index[];
>> +
>> +extern const unsigned int symbols_markers[];
>> +
>> #endif /*_XEN_SYMBOLS_H*/
>
> This change is even less clear to me: The producer is assembly code,
> and the consumer already had appropriate declarations. Why would we
> want to increase the scope of their visibility?
>
> Jan
The missing decls are about common/symbols-dummy.c. Xen can choose that
this file does
not need to conform (to this guideline or any guideline), in which case
this change can be dropped.
[1] https://lore.kernel.org/xen-devel/ZRqkbeVUZbjizjNv@MacBookPdeRoger/
--
Nicola Vetrini, BSc
Software Engineer, BUGSENG srl (https://bugseng.com)
next prev parent reply other threads:[~2023-10-16 17:06 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-09 6:54 [XEN PATCH][for-4.19 v2 0/7] Fix or deviate various instances of missing declarations Nicola Vetrini
2023-10-09 6:54 ` [XEN PATCH v2 1/7] xen: add declarations for variables where needed Nicola Vetrini
2023-10-10 1:32 ` Stefano Stabellini
2023-10-16 14:50 ` Jan Beulich
2023-10-16 17:05 ` Nicola Vetrini [this message]
2023-10-17 6:46 ` Jan Beulich
2023-10-18 7:47 ` Nicola Vetrini
2023-10-09 6:54 ` [XEN PATCH v2 2/7] x86: add deviations for variables only used in asm code Nicola Vetrini
2023-10-16 14:58 ` Jan Beulich
2023-10-18 14:28 ` Nicola Vetrini
2023-10-18 14:56 ` Jan Beulich
2023-10-18 15:24 ` Nicola Vetrini
2023-10-09 6:54 ` [XEN PATCH v2 3/7] x86: add deviation comments for asm-only functions Nicola Vetrini
2023-10-16 15:00 ` Jan Beulich
2023-10-16 22:34 ` Stefano Stabellini
2023-10-17 6:54 ` Jan Beulich
2023-10-19 0:07 ` Stefano Stabellini
2023-10-19 6:55 ` Jan Beulich
2023-10-19 8:04 ` Nicola Vetrini
2023-10-19 8:57 ` Jan Beulich
2023-10-17 15:26 ` Nicola Vetrini
2023-10-09 6:54 ` [XEN PATCH][for-next v2 4/7] x86/grant: switch included header to make declarations visible Nicola Vetrini
2023-10-09 6:54 ` [XEN PATCH][for-next v2 5/7] x86/vm_event: add missing include for hvm_vm_event_do_resume Nicola Vetrini
2023-10-09 19:25 ` Tamas K Lengyel
2023-10-09 6:54 ` [XEN PATCH][for-4.19 v2 6/7] xen/console: make function static inline Nicola Vetrini
2023-10-16 14:52 ` Jan Beulich
2023-10-17 15:24 ` Nicola Vetrini
2023-10-17 16:26 ` Jan Beulich
2023-10-17 16:36 ` Nicola Vetrini
2023-10-09 6:54 ` [XEN PATCH][for-next v2 7/7] x86/mem_access: make function static Nicola Vetrini
2023-10-09 19:25 ` Tamas K Lengyel
2023-10-16 14:29 ` Jan Beulich
2023-10-17 9:45 ` 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=f89fc0b2814cc4b84abc431c0355b348@bugseng.com \
--to=nicola.vetrini@bugseng.com \
--cc=Volodymyr_Babchuk@epam.com \
--cc=andrew.cooper3@citrix.com \
--cc=ayan.kumar.halder@amd.com \
--cc=bertrand.marquis@arm.com \
--cc=consulting@bugseng.com \
--cc=george.dunlap@citrix.com \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=michal.orzel@amd.com \
--cc=roger.pau@citrix.com \
--cc=sstabellini@kernel.org \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.org \
--cc=xenia.ragiadakou@amd.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 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.