Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1017460imu; Fri, 9 Nov 2018 09:35:52 -0800 (PST) X-Google-Smtp-Source: AJdET5ffXoq/vHIs7O1riqZlJX5ttB852gaA4vm/CWz72ZArd/mgBaSIxObxWZSTIJFONTpUTvfZ X-Received: by 2002:a63:ae4d:: with SMTP id e13-v6mr8299302pgp.315.1541784952446; Fri, 09 Nov 2018 09:35:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541784952; cv=none; d=google.com; s=arc-20160816; b=JRJMKhIMmr2KVKmdW3hN4IIIkmMrr9+dntsnIZObKW2BxoqyV0c1hN/OdljugRAvyX lMHgKbyJDaNhPblWDMwDvTZ1Nzf96S2OG0gvq2c+JcWmaQ50RzhOJfdSDUt6gfQkCUWF 2NGEZ76iJsZb4gMkdP4Fn+nQES9OqCHMNpytO5lyuKQKosLkIQNng74Jlty5EIOdlEWC NHLvhg3ajhW4iyDsPeC+768rKTleddDjH449E5bFuJuyZotJhLzvEnJmYKQOrkjMY1Lw eylx+3widUAPMwYmOPbqmohvJmUcnIvbKN8sWBoHPPcMf0vX6ZwgUhG+sj6OrayYep7j VsOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:subject:from:references :in-reply-to:message-id; bh=UpWS41IpScLAiK4mHLNSzWfvzz5jujCc3BfYgAA2E+Y=; b=TwG/eIshyWotL1Spj6HWNdC7Jj/1Psw24IP0/VNmA2md3Qkg8kdykGgJMzy+SwiY3w bp1bvbGJurFvMqrmWTQLsByYmzLRKCZX53DfCmjAo6TI+xnV7iFZvayOvfKD1E6HLc4B nK5qIgmJUnQEjGk7zDBYjf7A/AJKMDwDs1VCCXSd38M8tWfvpiL0WwWYbTapjU2tbkfp Kb1wIQqCcJWFOgx7WDoAMcO9dw1MVdK6PAZ8TpxExSRTC5UD5/QNrflsttF3QXxQCX0m V4wp5WiftIldVWVy1cize8uGkNzS4I/75QlUPtrmeKYcRKDnbn9BdYwRremx7c8B01cX 4LAw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i33-v6si1916439pld.185.2018.11.09.09.35.27; Fri, 09 Nov 2018 09:35:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728713AbeKJDOx (ORCPT + 99 others); Fri, 9 Nov 2018 22:14:53 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:6034 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727995AbeKJDOw (ORCPT ); Fri, 9 Nov 2018 22:14:52 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 42s6gX2Nnzz9v0XP; Fri, 9 Nov 2018 18:33:12 +0100 (CET) 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 XmPTcMUazS7J; Fri, 9 Nov 2018 18:33:12 +0100 (CET) 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 42s6gX1wtdz9v0XL; Fri, 9 Nov 2018 18:33:12 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 1FA2B8B899; Fri, 9 Nov 2018 18:33:18 +0100 (CET) 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 WWxjoJ6FwuIm; Fri, 9 Nov 2018 18:33:18 +0100 (CET) Received: from po14163vm.idsi0.si.c-s.fr (po15451.idsi0.si.c-s.fr [172.25.231.2]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 039C98B887; Fri, 9 Nov 2018 18:33:18 +0100 (CET) Received: by po14163vm.idsi0.si.c-s.fr (Postfix, from userid 0) id F112A69A2A; Fri, 9 Nov 2018 17:33:17 +0000 (UTC) Message-Id: <7d51b0a71491e9260da34935bd28b04366831ef4.1541784640.git.christophe.leroy@c-s.fr> In-Reply-To: References: From: Christophe Leroy Subject: [PATCH 2/9] powerpc: add modify_instruction() and modify_instruction_site() To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Fri, 9 Nov 2018 17:33:17 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add two helpers to avoid hardcoding of instructions modifications. Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/code-patching.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arch/powerpc/include/asm/code-patching.h b/arch/powerpc/include/asm/code-patching.h index 0eeed21e4898..2074b40f3fb5 100644 --- a/arch/powerpc/include/asm/code-patching.h +++ b/arch/powerpc/include/asm/code-patching.h @@ -49,6 +49,17 @@ static inline int patch_branch_site(s32 *site, unsigned long target, int flags) return patch_branch((unsigned int *)patch_site_addr(site), target, flags); } +static inline int modify_instruction(unsigned int *addr, unsigned int clr, + unsigned int set) +{ + return patch_instruction(addr, (*addr & ~clr) | set); +} + +static inline int modify_instruction_site(s32 *site, unsigned int clr, unsigned int set) +{ + return modify_instruction((unsigned int *)patch_site_addr(site), clr, set); +} + int instr_is_relative_branch(unsigned int instr); int instr_is_relative_link_branch(unsigned int instr); int instr_is_branch_to_addr(const unsigned int *instr, unsigned long addr); -- 2.13.3