Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3674472pxt; Tue, 10 Aug 2021 08:48:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGokvcTelNs7Wjy37tAp8UBlRv7eaf09mpSvsZAxm6YQxG+fvNkjUtT6ZY1b7gFdhvGFYX X-Received: by 2002:a17:906:a08a:: with SMTP id q10mr27807516ejy.100.1628610531282; Tue, 10 Aug 2021 08:48:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628610531; cv=none; d=google.com; s=arc-20160816; b=u0A10rkfv0EErXHdlkr09EObs4iagj93Z210Y7AbLoy48aMG0ToQalpwjBs5N32+9/ diKTISSN3IdEgOLXTsv6uu4kanDQqMHgUhKNNICOvmA9R/10TgEbtiHD/5Cmh1PT1jDf 1VMgiWg66Ysf+MvlSWrbGC/K2LQxnJAS09FDXIDA2FFIq5n9epeofAX3DUQoSQ+FnZR/ thYza///va5PvRCGu40wfVPFkfDaNz0jVKkb/Ecal19IH+TVzLG7KeecjMrwdkMtNB9Q Az1f9v7PUBVY7GeZFhR4n9EqbrH1IJeODPBVq87igrB1QKnPzThPG6VbjOFGTxG694i/ xPwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=uFfiXbECg11RtRPnwNIQofPMvYdxyzL37Vw0MH27wzw=; b=TBNUXBezdnaTjpCMWflnT1nn42htf8MJ/Zvfhw7OY1sjGXg1U4ztF7QO2hB9y6OSGV QhwCgLM3Oo8d9tdi9+Ie0beL/gLY+KGEHVNMYyEDq6SIGWblhzh1qx6AFpA3WFByu3bq y50m+o/F4V99C80YfXvktmBZUqXnM4WLjKedes84TASQkclLhriUFNjnbC0aKI+NJGqU NAS1CyQVz7IXN3IsGI5RD2PuRJaafBeoUVF3xxeJsRRizW2PhG6GvDFQt67Nl5u+RYNV KSpuUF6xU7pINyhO3Qp/K2XBdNh6Xv1EywU7EaY4Yx7CIV3bz1ZndqRT+aECTxqOBTEz 4Yfw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s18si285181ejh.110.2021.08.10.08.48.25; Tue, 10 Aug 2021 08:48:51 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238807AbhHJJSX (ORCPT + 99 others); Tue, 10 Aug 2021 05:18:23 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:13410 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234408AbhHJJSV (ORCPT ); Tue, 10 Aug 2021 05:18:21 -0400 Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4GkS233QGfzdZYH; Tue, 10 Aug 2021 17:14:19 +0800 (CST) Received: from dggema757-chm.china.huawei.com (10.1.198.199) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Tue, 10 Aug 2021 17:17:57 +0800 Received: from localhost.localdomain (10.67.165.2) by dggema757-chm.china.huawei.com (10.1.198.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Tue, 10 Aug 2021 17:17:57 +0800 From: Qi Liu To: , , , , , , CC: , , , , , , Subject: [PATCH v3 1/2] arm64: assembler: Make save_all_base_regs and restore_all_base_regs common macros Date: Tue, 10 Aug 2021 13:53:29 +0800 Message-ID: <20210810055330.18924-2-liuqi115@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210810055330.18924-1-liuqi115@huawei.com> References: <20210810055330.18924-1-liuqi115@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggema757-chm.china.huawei.com (10.1.198.199) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move save_all_base_regs and restore_all_base_regs to , as these two macros can be reused in optprobe. Signed-off-by: Qi Liu --- arch/arm64/include/asm/assembler.h | 52 +++++++++++++++++++ arch/arm64/kernel/probes/kprobes_trampoline.S | 52 ------------------- 2 files changed, 52 insertions(+), 52 deletions(-) diff --git a/arch/arm64/include/asm/assembler.h b/arch/arm64/include/asm/assembler.h index 89faca0e740d..cd912810fc80 100644 --- a/arch/arm64/include/asm/assembler.h +++ b/arch/arm64/include/asm/assembler.h @@ -515,6 +515,58 @@ alternative_endif .pushsection "_kprobe_blacklist", "aw"; \ .quad x; \ .popsection; + + .macro save_all_base_regs + stp x0, x1, [sp, #S_X0] + stp x2, x3, [sp, #S_X2] + stp x4, x5, [sp, #S_X4] + stp x6, x7, [sp, #S_X6] + stp x8, x9, [sp, #S_X8] + stp x10, x11, [sp, #S_X10] + stp x12, x13, [sp, #S_X12] + stp x14, x15, [sp, #S_X14] + stp x16, x17, [sp, #S_X16] + stp x18, x19, [sp, #S_X18] + stp x20, x21, [sp, #S_X20] + stp x22, x23, [sp, #S_X22] + stp x24, x25, [sp, #S_X24] + stp x26, x27, [sp, #S_X26] + stp x28, x29, [sp, #S_X28] + add x0, sp, #PT_REGS_SIZE + stp lr, x0, [sp, #S_LR] + /* + * Construct a useful saved PSTATE + */ + mrs x0, nzcv + mrs x1, daif + orr x0, x0, x1 + mrs x1, CurrentEL + orr x0, x0, x1 + mrs x1, SPSel + orr x0, x0, x1 + stp xzr, x0, [sp, #S_PC] + .endm + + .macro restore_all_base_regs + ldr x0, [sp, #S_PSTATE] + and x0, x0, #(PSR_N_BIT | PSR_Z_BIT | PSR_C_BIT | PSR_V_BIT) + msr nzcv, x0 + ldp x0, x1, [sp, #S_X0] + ldp x2, x3, [sp, #S_X2] + ldp x4, x5, [sp, #S_X4] + ldp x6, x7, [sp, #S_X6] + ldp x8, x9, [sp, #S_X8] + ldp x10, x11, [sp, #S_X10] + ldp x12, x13, [sp, #S_X12] + ldp x14, x15, [sp, #S_X14] + ldp x16, x17, [sp, #S_X16] + ldp x18, x19, [sp, #S_X18] + ldp x20, x21, [sp, #S_X20] + ldp x22, x23, [sp, #S_X22] + ldp x24, x25, [sp, #S_X24] + ldp x26, x27, [sp, #S_X26] + ldp x28, x29, [sp, #S_X28] + .endm #else #define NOKPROBE(x) #endif diff --git a/arch/arm64/kernel/probes/kprobes_trampoline.S b/arch/arm64/kernel/probes/kprobes_trampoline.S index 288a84e253cc..2463d5d0e004 100644 --- a/arch/arm64/kernel/probes/kprobes_trampoline.S +++ b/arch/arm64/kernel/probes/kprobes_trampoline.S @@ -9,58 +9,6 @@ .text - .macro save_all_base_regs - stp x0, x1, [sp, #S_X0] - stp x2, x3, [sp, #S_X2] - stp x4, x5, [sp, #S_X4] - stp x6, x7, [sp, #S_X6] - stp x8, x9, [sp, #S_X8] - stp x10, x11, [sp, #S_X10] - stp x12, x13, [sp, #S_X12] - stp x14, x15, [sp, #S_X14] - stp x16, x17, [sp, #S_X16] - stp x18, x19, [sp, #S_X18] - stp x20, x21, [sp, #S_X20] - stp x22, x23, [sp, #S_X22] - stp x24, x25, [sp, #S_X24] - stp x26, x27, [sp, #S_X26] - stp x28, x29, [sp, #S_X28] - add x0, sp, #PT_REGS_SIZE - stp lr, x0, [sp, #S_LR] - /* - * Construct a useful saved PSTATE - */ - mrs x0, nzcv - mrs x1, daif - orr x0, x0, x1 - mrs x1, CurrentEL - orr x0, x0, x1 - mrs x1, SPSel - orr x0, x0, x1 - stp xzr, x0, [sp, #S_PC] - .endm - - .macro restore_all_base_regs - ldr x0, [sp, #S_PSTATE] - and x0, x0, #(PSR_N_BIT | PSR_Z_BIT | PSR_C_BIT | PSR_V_BIT) - msr nzcv, x0 - ldp x0, x1, [sp, #S_X0] - ldp x2, x3, [sp, #S_X2] - ldp x4, x5, [sp, #S_X4] - ldp x6, x7, [sp, #S_X6] - ldp x8, x9, [sp, #S_X8] - ldp x10, x11, [sp, #S_X10] - ldp x12, x13, [sp, #S_X12] - ldp x14, x15, [sp, #S_X14] - ldp x16, x17, [sp, #S_X16] - ldp x18, x19, [sp, #S_X18] - ldp x20, x21, [sp, #S_X20] - ldp x22, x23, [sp, #S_X22] - ldp x24, x25, [sp, #S_X24] - ldp x26, x27, [sp, #S_X26] - ldp x28, x29, [sp, #S_X28] - .endm - SYM_CODE_START(kretprobe_trampoline) sub sp, sp, #PT_REGS_SIZE -- 2.17.1