From patchwork Tue Jan 30 22:28:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 13538190 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B0F19C46CD2 for ; Tue, 30 Jan 2024 22:28:46 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.673701.1048145 (Exim 4.92) (envelope-from ) id 1rUwag-0005HO-8z; Tue, 30 Jan 2024 22:28:26 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 673701.1048145; Tue, 30 Jan 2024 22:28:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rUwag-0005HH-4H; Tue, 30 Jan 2024 22:28:26 +0000 Received: by outflank-mailman (input) for mailman id 673701; Tue, 30 Jan 2024 22:28:24 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rUwae-00052C-QC for xen-devel@lists.xenproject.org; Tue, 30 Jan 2024 22:28:24 +0000 Received: from esa4.hc3370-68.iphmx.com (esa4.hc3370-68.iphmx.com [216.71.155.144]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id df8d247e-bfbe-11ee-98f5-efadbce2ee36; Tue, 30 Jan 2024 23:28:22 +0100 (CET) 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: df8d247e-bfbe-11ee-98f5-efadbce2ee36 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1706653702; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=bxThfDoIJYYf/WUb/HpXil0IxNtiXP9us+MkCQrsKWI=; b=Gj/8xa+eF4W9Fw0GbdC4FPLqEg1a+GLBoLxTeEXD+sxQ+nC0wNI3DL61 gwwmfWyHfD4+2Xv/y43OpPbCSccFUbZ4eCa6zYkGjAfkciD34FsV3gldr 7yK5EbBe8RIPdezUYgsv1FyXvaaqpeSh0RV43vzOPuVBPn9vi+ly0qDG+ 8=; X-CSE-ConnectionGUID: 8bC+uzs5RFebPMbp/NHfJw== X-CSE-MsgGUID: faFS1O21T0m4er0q9ijryQ== Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 4.0 X-MesageID: 132570056 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.159.70 X-Policy: $RELAYED X-ThreatScanner-Verdict: Negative IronPort-Data: A9a23:WNFBra7SyXPCNSrfcZmO/AxRtJ3HchMFZxGqfqrLsTDasY5as4F+v jQcUWyBOPyOYzP0cotybIy+oU0BsZaGxoJkSgE6pC5hHi5G8cbLO4+Ufxz6V8+wwm8vb2o8t plDNYOQRCwQZiWBzvt4GuG59RGQ7YnRG/ykTraCY3gtLeNdYH9JoQp5nOIkiZJfj9G8Agec0 fv/uMSaM1K+s9JOGjt8B5mr9lU34ZwehBtC5gZiPakQ5AeE/5UoJMl3yZ+ZfiOQrrZ8RoZWd 86bpJml82XQ+QsaC9/Nut4XpWVTH9Y+lSDX4pZnc/DKbipq/0Te4Y5iXBYoUm9Fii3hojxE4 I4lWapc6+seFvakdOw1C3G0GszlVEFM0OevzXOX6aR/w6BaGpdFLjoH4EweZOUlFuhL7W5mp fYzay0fdU25qe+8+JexUq5KpsoBM5y+VG8fkikIITDxCP8nRd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UID: 9a23:lrEi82uJzxAJL1w9XFVUGc6G6It1eFae0WXLfnWWBGxRbbeNDnmw9oF7xp8= X-Talos-MUID: 9a23:byE9KgoiuEcu6S05KKwezz9rGvwxxP73NBgIzZgc49DVNC5qKg7I2Q== X-IronPort-AV: E=Sophos;i="6.05,230,1701147600"; d="scan'208";a="132570056" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Wei Liu , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bertrand Marquis , Michal Orzel , Bob Eshleman , Alistair Francis , Connor Davis , Shawn Anastasio Subject: [PATCH] xen/*/asm-offset: Fix bad copy&paste from x86 Date: Tue, 30 Jan 2024 22:28:08 +0000 Message-ID: <20240130222808.106006-1-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 All architectures have copy&pasted bad logic from x86. OFFSET() having a trailing semi-colon within the macro expansion can be a problematic pattern. It's benign in this case, but fix it anyway. Perform style fixes for the other macros, and tame the mess of BLANK() position to be consistent (one BLANK() after each block) so the intermediate form is legible too. No functional change. Signed-off-by: Andrew Cooper Acked-by: Shawn Anastasio Reviewed-by: Jan Beulich Acked-by: Julien Grall --- CC: Jan Beulich CC: Roger Pau Monné CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall CC: Volodymyr Babchuk CC: Bertrand Marquis CC: Michal Orzel CC: Bob Eshleman CC: Alistair Francis CC: Connor Davis CC: Shawn Anastasio Why does PPC have a local copy of ilog2() here? Especially as it's not used, and there's a perfectly good one in --- xen/arch/arm/arm32/asm-offsets.c | 13 +++++++------ xen/arch/arm/arm64/asm-offsets.c | 12 +++++++----- xen/arch/ppc/ppc64/asm-offsets.c | 11 +++++++---- xen/arch/riscv/riscv64/asm-offsets.c | 8 ++++---- xen/arch/x86/x86_64/asm-offsets.c | 7 ++++--- 5 files changed, 29 insertions(+), 22 deletions(-) diff --git a/xen/arch/arm/arm32/asm-offsets.c b/xen/arch/arm/arm32/asm-offsets.c index 05c692bb2822..f19523d741af 100644 --- a/xen/arch/arm/arm32/asm-offsets.c +++ b/xen/arch/arm/arm32/asm-offsets.c @@ -15,11 +15,11 @@ #define DEFINE(_sym, _val) \ asm volatile ("\n.ascii\"==>#define " #_sym " %0 /* " #_val " */<==\"" \ - : : "i" (_val) ) + :: "i" (_val)) #define BLANK() \ - asm volatile ( "\n.ascii\"==><==\"" : : ) + asm volatile ("\n.ascii\"==><==\"") #define OFFSET(_sym, _str, _mem) \ - DEFINE(_sym, offsetof(_str, _mem)); + DEFINE(_sym, offsetof(_str, _mem)) void __dummy__(void) { @@ -62,18 +62,19 @@ void __dummy__(void) BLANK(); DEFINE(CPUINFO_sizeof, sizeof(struct cpu_info)); + BLANK(); OFFSET(VCPU_arch_saved_context, struct vcpu, arch.saved_context); - BLANK(); + DEFINE(PROCINFO_sizeof, sizeof(struct proc_info_list)); OFFSET(PROCINFO_cpu_val, struct proc_info_list, cpu_val); OFFSET(PROCINFO_cpu_mask, struct proc_info_list, cpu_mask); OFFSET(PROCINFO_cpu_init, struct proc_info_list, cpu_init); - BLANK(); - OFFSET(INITINFO_stack, struct init_info, stack); + OFFSET(INITINFO_stack, struct init_info, stack); + BLANK(); } /* diff --git a/xen/arch/arm/arm64/asm-offsets.c b/xen/arch/arm/arm64/asm-offsets.c index 7adb67a1b81a..8112b9243d39 100644 --- a/xen/arch/arm/arm64/asm-offsets.c +++ b/xen/arch/arm/arm64/asm-offsets.c @@ -15,11 +15,11 @@ #define DEFINE(_sym, _val) \ asm volatile ("\n.ascii\"==>#define " #_sym " %0 /* " #_val " */<==\"" \ - : : "i" (_val) ) + :: "i" (_val)) #define BLANK() \ - asm volatile ( "\n.ascii\"==><==\"" : : ) + asm volatile ("\n.ascii\"==><==\"") #define OFFSET(_sym, _str, _mem) \ - DEFINE(_sym, offsetof(_str, _mem)); + DEFINE(_sym, offsetof(_str, _mem)) void __dummy__(void) { @@ -48,13 +48,14 @@ void __dummy__(void) DEFINE(CPUINFO_sizeof, sizeof(struct cpu_info)); OFFSET(CPUINFO_flags, struct cpu_info, flags); + BLANK(); OFFSET(VCPU_arch_saved_context, struct vcpu, arch.saved_context); - BLANK(); - OFFSET(INITINFO_stack, struct init_info, stack); + OFFSET(INITINFO_stack, struct init_info, stack); BLANK(); + OFFSET(SMCCC_RES_a0, struct arm_smccc_res, a0); OFFSET(SMCCC_RES_a2, struct arm_smccc_res, a2); OFFSET(ARM_SMCCC_1_2_REGS_X0_OFFS, struct arm_smccc_1_2_regs, a0); @@ -66,6 +67,7 @@ void __dummy__(void) OFFSET(ARM_SMCCC_1_2_REGS_X12_OFFS, struct arm_smccc_1_2_regs, a12); OFFSET(ARM_SMCCC_1_2_REGS_X14_OFFS, struct arm_smccc_1_2_regs, a14); OFFSET(ARM_SMCCC_1_2_REGS_X16_OFFS, struct arm_smccc_1_2_regs, a16); + BLANK(); } /* diff --git a/xen/arch/ppc/ppc64/asm-offsets.c b/xen/arch/ppc/ppc64/asm-offsets.c index 634d7260e3a4..24065578cbdb 100644 --- a/xen/arch/ppc/ppc64/asm-offsets.c +++ b/xen/arch/ppc/ppc64/asm-offsets.c @@ -9,12 +9,12 @@ #include #define DEFINE(_sym, _val) \ - asm volatile ( "\n.ascii\"==>#define " #_sym " %0 /* " #_val " */<==\"" \ - : : "i" (_val) ) + asm volatile ("\n.ascii\"==>#define " #_sym " %0 /* " #_val " */<==\"" \ + : : "i" (_val)) #define BLANK() \ - asm volatile ( "\n.ascii\"==><==\"" : : ) + asm volatile ("\n.ascii\"==><==\"") #define OFFSET(_sym, _str, _mem) \ - DEFINE(_sym, offsetof(_str, _mem)); + DEFINE(_sym, offsetof(_str, _mem)) /* base-2 logarithm */ #define __L2(_x) (((_x) & 0x00000002) ? 1 : 0) @@ -29,6 +29,7 @@ void __dummy__(void) DEFINE(GPR_WIDTH, sizeof(unsigned long)); DEFINE(FPR_WIDTH, sizeof(double)); + BLANK(); OFFSET(UREGS_gprs, struct cpu_user_regs, gprs); OFFSET(UREGS_r0, struct cpu_user_regs, gprs[0]); @@ -48,9 +49,11 @@ void __dummy__(void) OFFSET(UREGS_fpscr, struct cpu_user_regs, fpscr); OFFSET(UREGS_entry_vector, struct cpu_user_regs, entry_vector); DEFINE(UREGS_sizeof, sizeof(struct cpu_user_regs)); + BLANK(); OFFSET(OPAL_base, struct opal, base); OFFSET(OPAL_entry, struct opal, entry); + BLANK(); } /* diff --git a/xen/arch/riscv/riscv64/asm-offsets.c b/xen/arch/riscv/riscv64/asm-offsets.c index d632b75c2acb..ed74b11bf654 100644 --- a/xen/arch/riscv/riscv64/asm-offsets.c +++ b/xen/arch/riscv/riscv64/asm-offsets.c @@ -5,15 +5,14 @@ #define DEFINE(_sym, _val) \ asm volatile ("\n.ascii\"==>#define " #_sym " %0 /* " #_val " */<==\"" \ - : : "i" (_val) ) + :: "i" (_val)) #define BLANK() \ - asm volatile ( "\n.ascii\"==><==\"" : : ) + asm volatile ("\n.ascii\"==><==\"") #define OFFSET(_sym, _str, _mem) \ - DEFINE(_sym, offsetof(_str, _mem)); + DEFINE(_sym, offsetof(_str, _mem)) void asm_offsets(void) { - BLANK(); DEFINE(CPU_USER_REGS_SIZE, sizeof(struct cpu_user_regs)); OFFSET(CPU_USER_REGS_ZERO, struct cpu_user_regs, zero); OFFSET(CPU_USER_REGS_RA, struct cpu_user_regs, ra); @@ -50,4 +49,5 @@ void asm_offsets(void) OFFSET(CPU_USER_REGS_SEPC, struct cpu_user_regs, sepc); OFFSET(CPU_USER_REGS_SSTATUS, struct cpu_user_regs, sstatus); OFFSET(CPU_USER_REGS_PREGS, struct cpu_user_regs, pregs); + BLANK(); } diff --git a/xen/arch/x86/x86_64/asm-offsets.c b/xen/arch/x86/x86_64/asm-offsets.c index f9546ec60b60..a4931c4f7eb2 100644 --- a/xen/arch/x86/x86_64/asm-offsets.c +++ b/xen/arch/x86/x86_64/asm-offsets.c @@ -18,11 +18,11 @@ #define DEFINE(_sym, _val) \ asm volatile ("\n.ascii\"==>#define " #_sym " %0 /* " #_val " */<==\"" \ - : : "i" (_val) ) + :: "i" (_val)) #define BLANK() \ - asm volatile ( "\n.ascii\"==><==\"" : : ) + asm volatile ("\n.ascii\"==><==\"") #define OFFSET(_sym, _str, _mem) \ - DEFINE(_sym, offsetof(_str, _mem)); + DEFINE(_sym, offsetof(_str, _mem)) void __dummy__(void) { @@ -180,4 +180,5 @@ void __dummy__(void) BLANK(); OFFSET(DOMAIN_vm_assist, struct domain, vm_assist); + BLANK(); }