From nobody Sat May 18 16:46:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 169935308184064.30219929235079; Tue, 7 Nov 2023 02:31:21 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.628721.980473 (Exim 4.92) (envelope-from ) id 1r0JM9-0003kB-Kd; Tue, 07 Nov 2023 10:30:49 +0000 Received: by outflank-mailman (output) from mailman id 628721.980473; Tue, 07 Nov 2023 10:30:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r0JM9-0003k4-I2; Tue, 07 Nov 2023 10:30:49 +0000 Received: by outflank-mailman (input) for mailman id 628721; Tue, 07 Nov 2023 10:30:49 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r0JM9-0003jy-6Y for xen-devel@lists.xenproject.org; Tue, 07 Nov 2023 10:30:49 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id b6d84437-7d58-11ee-98da-6d05b1d4d9a1; Tue, 07 Nov 2023 11:30:47 +0100 (CET) Received: from nico.bugseng.com (unknown [147.123.100.131]) by support.bugseng.com (Postfix) with ESMTPSA id 5D3484EE0C81; Tue, 7 Nov 2023 11:30:45 +0100 (CET) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: b6d84437-7d58-11ee-98da-6d05b1d4d9a1 From: Nicola Vetrini To: xen-devel@lists.xenproject.org Cc: sstabellini@kernel.org, michal.orzel@amd.com, xenia.ragiadakou@amd.com, ayan.kumar.halder@amd.com, consulting@bugseng.com, jbeulich@suse.com, andrew.cooper3@citrix.com, roger.pau@citrix.com, Nicola Vetrini , George Dunlap , Julien Grall , Wei Liu , Bertrand Marquis , Volodymyr Babchuk Subject: [XEN PATCH][for-4.19 v2] xen: replace occurrences of SAF-1-safe with asmlinkage attribute Date: Tue, 7 Nov 2023 11:30:42 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1699353082405100001 Content-Type: text/plain; charset="utf-8" The comment-based justifications for MISRA C:2012 Rule 8.4 are replaced by the asmlinkage pseudo-attribute, for the sake of uniformity. Add missing 'xen/compiler.h' #include-s where needed. The text in docs/misra/deviations.rst and docs/misra/safe.json is modified to reflect this change. Signed-off-by: Nicola Vetrini Acked-by: Julien Grall --- Changes in v2: - Edit safe.json. - Remove mention of SAF-1-safe in deviations.rst. --- docs/misra/deviations.rst | 5 ++--- docs/misra/safe.json | 2 +- xen/arch/arm/cpuerrata.c | 7 +++---- xen/arch/arm/setup.c | 5 ++--- xen/arch/arm/smpboot.c | 3 +-- xen/arch/arm/traps.c | 21 +++++++-------------- xen/arch/x86/boot/cmdline.c | 5 +++-- xen/arch/x86/boot/reloc.c | 7 ++++--- xen/arch/x86/extable.c | 3 +-- xen/arch/x86/setup.c | 3 +-- xen/arch/x86/traps.c | 27 +++++++++------------------ xen/common/efi/boot.c | 5 ++--- 12 files changed, 36 insertions(+), 57 deletions(-) diff --git a/docs/misra/deviations.rst b/docs/misra/deviations.rst index d468da2f5ce9..0fa0475db0eb 100644 --- a/docs/misra/deviations.rst +++ b/docs/misra/deviations.rst @@ -134,9 +134,8 @@ Deviations related to MISRA C:2012 Rules: - Tagged as `safe` for ECLAIR. =20 * - R8.4 - - Functions and variables used only by asm modules are either marked = with - the `asmlinkage` macro or with a SAF-1-safe textual deviation - (see safe.json). + - Functions and variables used only to interface with asm modules sho= uld + be marked with the `asmlinkage` macro. - Tagged as `safe` for ECLAIR. =20 * - R8.6 diff --git a/docs/misra/safe.json b/docs/misra/safe.json index 39c5c056c7d4..eaff0312e20c 100644 --- a/docs/misra/safe.json +++ b/docs/misra/safe.json @@ -16,7 +16,7 @@ "eclair": "MC3R1.R8.4" }, "name": "Rule 8.4: asm-only definition", - "text": "Functions and variables used only by asm modules do n= ot need to have a visible declaration prior to their definition." + "text": "Not used anymore." }, { "id": "SAF-2-safe", diff --git a/xen/arch/arm/cpuerrata.c b/xen/arch/arm/cpuerrata.c index 9137958fb682..a28fa6ac78cc 100644 --- a/xen/arch/arm/cpuerrata.c +++ b/xen/arch/arm/cpuerrata.c @@ -370,10 +370,9 @@ custom_param("spec-ctrl", parse_spec_ctrl); =20 /* Arm64 only for now as for Arm32 the workaround is currently handled in = C. */ #ifdef CONFIG_ARM_64 -/* SAF-1-safe */ -void __init arm_enable_wa2_handling(const struct alt_instr *alt, - const uint32_t *origptr, - uint32_t *updptr, int nr_inst) +void asmlinkage __init arm_enable_wa2_handling(const struct alt_instr *alt, + const uint32_t *origptr, + uint32_t *updptr, int nr_in= st) { BUG_ON(nr_inst !=3D 1); =20 diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index 3f3a45719ccb..bedbce3c0d37 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -1077,9 +1077,8 @@ static bool __init is_dom0less_mode(void) size_t __read_mostly dcache_line_bytes; =20 /* C entry point for boot CPU */ -/* SAF-1-safe */ -void __init start_xen(unsigned long boot_phys_offset, - unsigned long fdt_paddr) +void asmlinkage __init start_xen(unsigned long boot_phys_offset, + unsigned long fdt_paddr) { size_t fdt_size; const char *cmdline; diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c index ec76de3cac12..a32f610b47d9 100644 --- a/xen/arch/arm/smpboot.c +++ b/xen/arch/arm/smpboot.c @@ -303,8 +303,7 @@ smp_prepare_cpus(void) } =20 /* Boot the current CPU */ -/* SAF-1-safe */ -void start_secondary(void) +void asmlinkage start_secondary(void) { unsigned int cpuid =3D init_data.cpuid; =20 diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 5aa14d470791..63d3bc7bd67b 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -161,8 +161,7 @@ void init_traps(void) isb(); } =20 -/* SAF-1-safe */ -void __div0(void) +void asmlinkage __div0(void) { printk("Division by zero in hypervisor.\n"); BUG(); @@ -1955,8 +1954,7 @@ static inline bool needs_ssbd_flip(struct vcpu *v) * Actions that needs to be done after entering the hypervisor from the * guest and before the interrupts are unmasked. */ -/* SAF-1-safe */ -void enter_hypervisor_from_guest_preirq(void) +void asmlinkage enter_hypervisor_from_guest_preirq(void) { struct vcpu *v =3D current; =20 @@ -1970,8 +1968,7 @@ void enter_hypervisor_from_guest_preirq(void) * guest and before we handle any request. Depending on the exception trap, * this may be called with interrupts unmasked. */ -/* SAF-1-safe */ -void enter_hypervisor_from_guest(void) +void asmlinkage enter_hypervisor_from_guest(void) { struct vcpu *v =3D current; =20 @@ -1999,8 +1996,7 @@ void enter_hypervisor_from_guest(void) vgic_sync_from_lrs(v); } =20 -/* SAF-1-safe */ -void do_trap_guest_sync(struct cpu_user_regs *regs) +void asmlinkage do_trap_guest_sync(struct cpu_user_regs *regs) { const union hsr hsr =3D { .bits =3D regs->hsr }; =20 @@ -2195,14 +2191,12 @@ void do_trap_guest_serror(struct cpu_user_regs *reg= s) __do_trap_serror(regs, true); } =20 -/* SAF-1-safe */ -void do_trap_irq(struct cpu_user_regs *regs) +void asmlinkage do_trap_irq(struct cpu_user_regs *regs) { gic_interrupt(regs, 0); } =20 -/* SAF-1-safe */ -void do_trap_fiq(struct cpu_user_regs *regs) +void asmlinkage do_trap_fiq(struct cpu_user_regs *regs) { gic_interrupt(regs, 1); } @@ -2275,8 +2269,7 @@ static bool check_for_vcpu_work(void) * * The function will return with IRQ masked. */ -/* SAF-1-safe */ -void leave_hypervisor_to_guest(void) +void asmlinkage leave_hypervisor_to_guest(void) { local_irq_disable(); =20 diff --git a/xen/arch/x86/boot/cmdline.c b/xen/arch/x86/boot/cmdline.c index f9eee756aaed..93c6b68ed909 100644 --- a/xen/arch/x86/boot/cmdline.c +++ b/xen/arch/x86/boot/cmdline.c @@ -31,6 +31,7 @@ asm ( ); =20 #include +#include #include "defs.h" #include "video.h" =20 @@ -340,8 +341,8 @@ static void vga_parse(const char *cmdline, early_boot_o= pts_t *ebo) } #endif =20 -/* SAF-1-safe */ -void __stdcall cmdline_parse_early(const char *cmdline, early_boot_opts_t = *ebo) +void asmlinkage __stdcall cmdline_parse_early(const char *cmdline, + early_boot_opts_t *ebo) { if ( !cmdline ) return; diff --git a/xen/arch/x86/boot/reloc.c b/xen/arch/x86/boot/reloc.c index 609b02cb73dc..668918db879a 100644 --- a/xen/arch/x86/boot/reloc.c +++ b/xen/arch/x86/boot/reloc.c @@ -33,6 +33,8 @@ asm ( #include "../../../include/xen/kconfig.h" #include =20 +#include + #ifdef CONFIG_VIDEO # include "video.h" =20 @@ -347,9 +349,8 @@ static multiboot_info_t *mbi2_reloc(uint32_t mbi_in, ui= nt32_t video_out) return mbi_out; } =20 -/* SAF-1-safe */ -void *__stdcall reloc(uint32_t magic, uint32_t in, uint32_t trampoline, - uint32_t video_info) +void *asmlinkage __stdcall reloc(uint32_t magic, uint32_t in, + uint32_t trampoline, uint32_t video_info) { alloc =3D trampoline; =20 diff --git a/xen/arch/x86/extable.c b/xen/arch/x86/extable.c index 74b14246e9d8..51245221ec03 100644 --- a/xen/arch/x86/extable.c +++ b/xen/arch/x86/extable.c @@ -194,8 +194,7 @@ static int __init cf_check stub_selftest(void) __initcall(stub_selftest); #endif =20 -/* SAF-1-safe */ -unsigned long search_pre_exception_table(struct cpu_user_regs *regs) +unsigned asmlinkage long search_pre_exception_table(struct cpu_user_regs *= regs) { unsigned long addr =3D regs->rip; unsigned long fixup =3D search_one_extable( diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index d70ad1e44a60..958ebeeef0c3 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -970,8 +970,7 @@ static struct domain *__init create_dom0(const module_t= *image, /* How much of the directmap is prebuilt at compile time. */ #define PREBUILT_MAP_LIMIT (1 << L2_PAGETABLE_SHIFT) =20 -/* SAF-1-safe */ -void __init noreturn __start_xen(unsigned long mbi_p) +void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) { const char *memmap_type =3D NULL; char *cmdline, *kextra, *loader; diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index 6393467b06fd..2c2e19fe8964 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -833,8 +833,7 @@ void fatal_trap(const struct cpu_user_regs *regs, bool = show_remote) (regs->eflags & X86_EFLAGS_IF) ? "" : " IN INTERRUPT CONTEXT"); } =20 -/* SAF-1-safe */ -void do_unhandled_trap(struct cpu_user_regs *regs) +void asmlinkage do_unhandled_trap(struct cpu_user_regs *regs) { unsigned int trapnr =3D regs->entry_vector; =20 @@ -921,8 +920,7 @@ static bool extable_fixup(struct cpu_user_regs *regs, b= ool print) return true; } =20 -/* SAF-1-safe */ -void do_trap(struct cpu_user_regs *regs) +void asmlinkage do_trap(struct cpu_user_regs *regs) { unsigned int trapnr =3D regs->entry_vector; =20 @@ -1154,8 +1152,7 @@ void cpuid_hypervisor_leaves(const struct vcpu *v, ui= nt32_t leaf, } } =20 -/* SAF-1-safe */ -void do_invalid_op(struct cpu_user_regs *regs) +void asmlinkage do_invalid_op(struct cpu_user_regs *regs) { u8 bug_insn[2]; const void *eip =3D (const void *)regs->rip; @@ -1200,8 +1197,7 @@ void do_invalid_op(struct cpu_user_regs *regs) panic("FATAL TRAP: vector =3D %d (invalid opcode)\n", X86_EXC_UD); } =20 -/* SAF-1-safe */ -void do_int3(struct cpu_user_regs *regs) +void asmlinkage do_int3(struct cpu_user_regs *regs) { struct vcpu *curr =3D current; =20 @@ -1568,8 +1564,7 @@ static int fixup_page_fault(unsigned long addr, struc= t cpu_user_regs *regs) return 0; } =20 -/* SAF-1-safe */ -void do_page_fault(struct cpu_user_regs *regs) +void asmlinkage do_page_fault(struct cpu_user_regs *regs) { unsigned long addr; unsigned int error_code; @@ -1646,8 +1641,7 @@ void do_page_fault(struct cpu_user_regs *regs) * during early boot (an issue was seen once, but was most likely a hardwa= re * problem). */ -/* SAF-1-safe */ -void __init do_early_page_fault(struct cpu_user_regs *regs) +void asmlinkage __init do_early_page_fault(struct cpu_user_regs *regs) { static unsigned int __initdata stuck; static unsigned long __initdata prev_eip, prev_cr2; @@ -1847,8 +1841,7 @@ void trigger_nmi_continuation(void) apic_wait_icr_idle(); } =20 -/* SAF-1-safe */ -void do_device_not_available(struct cpu_user_regs *regs) +void asmlinkage do_device_not_available(struct cpu_user_regs *regs) { #ifdef CONFIG_PV struct vcpu *curr =3D current; @@ -1884,8 +1877,7 @@ void do_device_not_available(struct cpu_user_regs *re= gs) #endif } =20 -/* SAF-1-safe */ -void do_debug(struct cpu_user_regs *regs) +void asmlinkage do_debug(struct cpu_user_regs *regs) { unsigned long dr6; struct vcpu *v =3D current; @@ -2010,8 +2002,7 @@ void do_debug(struct cpu_user_regs *regs) pv_inject_hw_exception(X86_EXC_DB, X86_EVENT_NO_EC); } =20 -/* SAF-1-safe */ -void do_entry_CP(struct cpu_user_regs *regs) +void asmlinkage do_entry_CP(struct cpu_user_regs *regs) { static const char errors[][10] =3D { [1] =3D "near ret", diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index e5e86f22b2b2..bc58dfce2f6c 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -1254,9 +1254,8 @@ static void __init efi_exit_boot(EFI_HANDLE ImageHand= le, EFI_SYSTEM_TABLE *Syste efi_fw_vendor =3D (void *)efi_fw_vendor + DIRECTMAP_VIRT_START; } =20 -/* SAF-1-safe */ -void EFIAPI __init noreturn efi_start(EFI_HANDLE ImageHandle, - EFI_SYSTEM_TABLE *SystemTable) +void asmlinkage EFIAPI __init noreturn efi_start(EFI_HANDLE ImageHandle, + EFI_SYSTEM_TABLE *SystemT= able) { static EFI_GUID __initdata loaded_image_guid =3D LOADED_IMAGE_PROTOCOL; static EFI_GUID __initdata shim_lock_guid =3D SHIM_LOCK_PROTOCOL_GUID; --=20 2.34.1