From patchwork Mon Dec 14 12:49:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Bin X-Patchwork-Id: 7844161 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3D3A29F3CD for ; Mon, 14 Dec 2015 12:50:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5D8A02037F for ; Mon, 14 Dec 2015 12:50:54 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7E86D20375 for ; Mon, 14 Dec 2015 12:50:53 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1a8SYz-0008Eg-T8; Mon, 14 Dec 2015 12:49:13 +0000 Received: from szxga03-in.huawei.com ([119.145.14.66]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1a8SYm-0007zR-0Y for linux-arm-kernel@lists.infradead.org; Mon, 14 Dec 2015 12:49:01 +0000 Received: from 172.24.1.51 (EHLO szxeml428-hub.china.huawei.com) ([172.24.1.51]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id BST15242; Mon, 14 Dec 2015 20:48:06 +0800 (CST) Received: from localhost.localdomain (10.175.100.166) by szxeml428-hub.china.huawei.com (10.82.67.183) with Microsoft SMTP Server id 14.3.235.1; Mon, 14 Dec 2015 20:47:57 +0800 From: Li Bin To: , , , , Subject: [RFC PATCH 1/3] livepatch: allow arch specific implementation Date: Mon, 14 Dec 2015 20:49:36 +0800 Message-ID: <1450097378-3780-2-git-send-email-huawei.libin@huawei.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1450097378-3780-1-git-send-email-huawei.libin@huawei.com> References: <1450097378-3780-1-git-send-email-huawei.libin@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.100.166] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020204.566EBA88.017B, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: da94af144c789ca825bf327c4cee8992 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151214_044900_904591_7B5577CB X-CRM114-Status: GOOD ( 10.45 ) X-Spam-Score: -4.2 (----) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: live-patching@vger.kernel.org, huawei.libin@huawei.com, rostedt@goodmis.org, linux-arm-kernel@lists.infradead.org, guohanjun@huawei.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Allow klp_enable_func/klp_disable_func be specific implementation for different arch. Signed-off-by: Li Bin --- kernel/livepatch/core.c | 45 +++++++++++++++++++++++++++++---------------- 1 files changed, 29 insertions(+), 16 deletions(-) diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c index db545cb..0a8cf96 100644 --- a/kernel/livepatch/core.c +++ b/kernel/livepatch/core.c @@ -350,15 +350,10 @@ unlock: rcu_read_unlock(); } -static void klp_disable_func(struct klp_func *func) +void __weak arch_klp_disable_func(struct klp_func *func) { struct klp_ops *ops; - if (WARN_ON(func->state != KLP_ENABLED)) - return; - if (WARN_ON(!func->old_addr)) - return; - ops = klp_find_ops(func->old_addr); if (WARN_ON(!ops)) return; @@ -373,21 +368,23 @@ static void klp_disable_func(struct klp_func *func) } else { list_del_rcu(&func->stack_node); } +} +static void klp_disable_func(struct klp_func *func) +{ + if (WARN_ON(func->state != KLP_ENABLED)) + return; + if (WARN_ON(!func->old_addr)) + return; + arch_klp_disable_func(func); func->state = KLP_DISABLED; } -static int klp_enable_func(struct klp_func *func) +int __weak arch_klp_enable_func(struct klp_func *func) { struct klp_ops *ops; int ret; - if (WARN_ON(!func->old_addr)) - return -EINVAL; - - if (WARN_ON(func->state != KLP_DISABLED)) - return -EINVAL; - ops = klp_find_ops(func->old_addr); if (!ops) { ops = kzalloc(sizeof(*ops), GFP_KERNEL); @@ -424,10 +421,7 @@ static int klp_enable_func(struct klp_func *func) list_add_rcu(&func->stack_node, &ops->func_stack); } - func->state = KLP_ENABLED; - return 0; - err: list_del_rcu(&func->stack_node); list_del(&ops->node); @@ -435,6 +429,25 @@ err: return ret; } +static int klp_enable_func(struct klp_func *func) +{ + int ret; + + if (WARN_ON(!func->old_addr)) + return -EINVAL; + + if (WARN_ON(func->state != KLP_DISABLED)) + return -EINVAL; + + ret = arch_klp_enable_func(func); + if (ret) + return ret; + + func->state = KLP_ENABLED; + + return 0; +} + static void klp_disable_object(struct klp_object *obj) { struct klp_func *func;