Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4266209pxf; Tue, 6 Apr 2021 11:55:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxCm31GYLvWkMfc6dsWz9EYyZo5sH8REJY6JaRHK5+KjCa7ZevpDudLZBsc9aTfSJq+AGG X-Received: by 2002:a92:c26e:: with SMTP id h14mr20269119ild.33.1617735323653; Tue, 06 Apr 2021 11:55:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617735323; cv=none; d=google.com; s=arc-20160816; b=T2CRZr+bkNkJRq3d4Lhp9soDJjtI0lDYafigkDeiO5a0kEXEyZR6addw0tnbwcAUvl yQV4rdTxlgJI8lEk9SaiwdPUJ05YAXv1aoqKILJ9gCzATemFIUZG6SuxdKPVYaJSWnTi 7Wu0ZHclfWcTZvy9oPexRD2PEKQivPsdpCkmStq6vfKTDBJTTZPvrAvQ91ttqSa2MD1G XhqfAbuQ6gYzzAya8HGlReNJwgTIXSXW+1ZfZsZHtISLqICh9/AAJQe8EBsIHIxTooyo B11wSRVF6BSoy8NyRK5s7ZbuQRTz5R4sk854KmfB6U2cgmvQJB/F0v27u8zDQhDzEl6X qTwQ== 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=esThI7aTVi3gI4Q7NVnUaTNUSlZ1vvMMu8EJOUdBzGY=; b=fiU0u9dEO7IjzCyO91njCnmVM3PiuylwTm5uz6Q4I8IWS0S0xqMzCtBRVqHGiTuE1X MtfnMWcHxPYGuG46mc0npyWU3f//6RklwvxcMZdjBEKTSQYvgIR6ipW9DvwTto7C1r4g tq1me4SeTYojyIdYEA7ToPu0n/XOGnLfYW+jyIdHUEGdmrDJz/O08MIzDPyZM+VtF6hl l2GjLu1CwD5j2Yyw7z44wxSu6/fkh3pImSPbsGOq3VSugbtMGZKoO8scItV7Cfob7eHu iWN4EKVw3gnCnrpFkorO7EAx8QSfn0maRN6Iz5NTmNCgLVA7pZvXoIwMZXIvjBOhOA1l 229A== 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 k7si17907283ilu.15.2021.04.06.11.55.10; Tue, 06 Apr 2021 11:55:23 -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 S233062AbhDFJia (ORCPT + 99 others); Tue, 6 Apr 2021 05:38:30 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:4471 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230071AbhDFJi2 (ORCPT ); Tue, 6 Apr 2021 05:38:28 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 4FF2Ws20CTz9txTJ; Tue, 6 Apr 2021 11:38:17 +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 03pPQZ_PdaOp; Tue, 6 Apr 2021 11:38:17 +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 4FF2Ws0tTZz9txTH; Tue, 6 Apr 2021 11:38:17 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 31CB78B79E; Tue, 6 Apr 2021 11:38:18 +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 KsXH1uIQ6ZeQ; Tue, 6 Apr 2021 11:38:18 +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 B9B068B796; Tue, 6 Apr 2021 11:38:17 +0200 (CEST) Received: by po16121vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 76C066766B; Tue, 6 Apr 2021 09:38:17 +0000 (UTC) Message-Id: From: Christophe Leroy Subject: [PATCH v1 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, 6 Apr 2021 09:38:17 +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 cc73c1267572..8ea0b503f32f 100644 --- a/arch/powerpc/include/asm/inst.h +++ b/arch/powerpc/include/asm/inst.h @@ -113,13 +113,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 3fe37495f63d..ff10a357d41d 100644 --- a/arch/powerpc/xmon/xmon.c +++ b/arch/powerpc/xmon/xmon.c @@ -2980,7 +2980,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