Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp3375019pxb; Tue, 20 Apr 2021 07:03:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxOfqOacVBvJOs0Bp/jlRLZzqMLjnV+DjqKhCB5aRz+T0lAxV8ItEu+cVTvEZdyqF/xX4wc X-Received: by 2002:a17:90b:1118:: with SMTP id gi24mr5081050pjb.30.1618927386447; Tue, 20 Apr 2021 07:03:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618927386; cv=none; d=google.com; s=arc-20160816; b=WQSFQGPxNFATbw4Vetj/VCsHkqmSFbgt2w7ogzhXD1Ly1pxikF59LdcZDivxC/XZxS vQJNrSfTtqp18ZODr4bIaJhZlSBQijF9UxFdQFL77WawRsRRKPEOWIRE8CuExmcVzyDo 7YGpv87XH+iWj25Q2/lksgCNPSHt2Dup4YHxxDBixY14tKf461j4mGgFCdy1SEWNtBH8 UqtfIjhBYXrkSH+27WjqxQcZT8N3YMFEGPIisQJnKVSKNupQ3zx1Xhk1ZJAMIyBVeZNX xJxEiC1bh9cPCSchrlCyVVbBQlVqoh/z1vGmOIwUXBBXc6uOVJ+jt3hUrIJhWGmzXuC/ fUpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:cc:to:subject:from:message-id; bh=0i/mI9LxwA78vEqmhg0C2/LwcuOr9sLjNoC2gy1I/gU=; b=qbQnhGbSs29QlO4Q6ieBXqzry63pVWpl2XwIKtrRrvImm0+QM/CRXGh77UzM0QoD3h 29cCLP0F0mtIlQ/qryEfopNHA3xFPPEhxI6aCansK1IN0MqVWqPfRvE5krMh68glRa+G rr1GeUVX7QhxKY119giHB1/reHwAto090lGJaBLPeikyVbuAg3sbKQ/EZlwpKEljPYgG 5ScfLTIA7MIN82cH3dWUX4NW9svsiXAUrdk9qapsEhwINxtn+eZRZq43cwEF+P6cy7/T za30BilVyf5bK1pue0VcIsvHAzmuyD6XoDQ5FPCWDYevJFPo+r0W3u8DFUAKaCLH9Okg DjVA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s14si3080943pjf.94.2021.04.20.07.02.52; Tue, 20 Apr 2021 07:03:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232504AbhDTOCn (ORCPT + 99 others); Tue, 20 Apr 2021 10:02:43 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:2862 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231758AbhDTOCk (ORCPT ); Tue, 20 Apr 2021 10:02:40 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 4FPljn6cbjz9v0Dy; Tue, 20 Apr 2021 16:02:05 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id w5X7gkbZO2QL; Tue, 20 Apr 2021 16:02:05 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 4FPljn5sLLz9v0Dw; Tue, 20 Apr 2021 16:02:05 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 334188B807; Tue, 20 Apr 2021 16:02:07 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id VkjBHKdmV6jb; Tue, 20 Apr 2021 16:02:07 +0200 (CEST) Received: from po16121vm.idsi0.si.c-s.fr (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id D40178B7ED; Tue, 20 Apr 2021 16:02:06 +0200 (CEST) Received: by po16121vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 42F8F67A48; Tue, 20 Apr 2021 14:02:06 +0000 (UTC) Message-Id: <22cadf29620664b600b82026d2a72b8b23351777.1618927318.git.christophe.leroy@csgroup.eu> From: Christophe Leroy Subject: [PATCH v2 1/2] powerpc/inst: ppc_inst_as_u64() becomes ppc_inst_as_ulong() To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , naveen.n.rao@linux.vnet.ibm.com Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Tue, 20 Apr 2021 14:02:06 +0000 (UTC) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to simplify use on PPC32, change ppc_inst_as_u64() into ppc_inst_as_ulong() that returns the 32 bits instruction on PPC32. Will be used when porting OPTPROBES to PPC32. Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/inst.h | 13 +++++++------ arch/powerpc/kernel/optprobes.c | 2 +- arch/powerpc/lib/code-patching.c | 2 +- arch/powerpc/xmon/xmon.c | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/arch/powerpc/include/asm/inst.h b/arch/powerpc/include/asm/inst.h index 19e18af2fac9..9646c63f7420 100644 --- a/arch/powerpc/include/asm/inst.h +++ b/arch/powerpc/include/asm/inst.h @@ -147,13 +147,14 @@ static inline struct ppc_inst *ppc_inst_next(void *location, struct ppc_inst *va return location + ppc_inst_len(tmp); } -static inline u64 ppc_inst_as_u64(struct ppc_inst x) +static inline unsigned long ppc_inst_as_ulong(struct ppc_inst x) { -#ifdef CONFIG_CPU_LITTLE_ENDIAN - return (u64)ppc_inst_suffix(x) << 32 | ppc_inst_val(x); -#else - return (u64)ppc_inst_val(x) << 32 | ppc_inst_suffix(x); -#endif + if (IS_ENABLED(CONFIG_PPC32)) + return ppc_inst_val(x); + else if (IS_ENABLED(CONFIG_CPU_LITTLE_ENDIAN)) + return (u64)ppc_inst_suffix(x) << 32 | ppc_inst_val(x); + else + return (u64)ppc_inst_val(x) << 32 | ppc_inst_suffix(x); } #define PPC_INST_STR_LEN sizeof("00000000 00000000") diff --git a/arch/powerpc/kernel/optprobes.c b/arch/powerpc/kernel/optprobes.c index 7f7cdbeacd1a..58fdb9f66e0f 100644 --- a/arch/powerpc/kernel/optprobes.c +++ b/arch/powerpc/kernel/optprobes.c @@ -264,7 +264,7 @@ int arch_prepare_optimized_kprobe(struct optimized_kprobe *op, struct kprobe *p) * 3. load instruction to be emulated into relevant register, and */ temp = ppc_inst_read((struct ppc_inst *)p->ainsn.insn); - patch_imm64_load_insns(ppc_inst_as_u64(temp), 4, buff + TMPL_INSN_IDX); + patch_imm64_load_insns(ppc_inst_as_ulong(temp), 4, buff + TMPL_INSN_IDX); /* * 4. branch back from trampoline diff --git a/arch/powerpc/lib/code-patching.c b/arch/powerpc/lib/code-patching.c index 65aec4d6d9ba..870b30d9be2f 100644 --- a/arch/powerpc/lib/code-patching.c +++ b/arch/powerpc/lib/code-patching.c @@ -26,7 +26,7 @@ static int __patch_instruction(struct ppc_inst *exec_addr, struct ppc_inst instr __put_kernel_nofault(patch_addr, &val, u32, failed); } else { - u64 val = ppc_inst_as_u64(instr); + u64 val = ppc_inst_as_ulong(instr); __put_kernel_nofault(patch_addr, &val, u64, failed); } diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c index a619b9ed8458..ff2b92bfeedc 100644 --- a/arch/powerpc/xmon/xmon.c +++ b/arch/powerpc/xmon/xmon.c @@ -2953,7 +2953,7 @@ generic_inst_dump(unsigned long adr, long count, int praddr, if (!ppc_inst_prefixed(inst)) dump_func(ppc_inst_val(inst), adr); else - dump_func(ppc_inst_as_u64(inst), adr); + dump_func(ppc_inst_as_ulong(inst), adr); printf("\n"); } return adr - first_adr; -- 2.25.0