From patchwork Tue Nov 15 20:08:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jamie Iles X-Patchwork-Id: 13044121 X-Patchwork-Delegate: palmer@dabbelt.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 50F39C4332F for ; Tue, 15 Nov 2022 20:08:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=6tezbKsRj+mvpKPV5i+ErMgFiXooeL2yPUlKPyQ5xNE=; b=H+iOC1AWCYiapd v566sBdXlPIlVUbZ7Wd2cyDgH0fQ+MgTzEWG/1AgR+c0hXx+e4MirLCUuUXICEEq6dnoBFVYbjlk1 WZS9u1zqtmA6ohLwBtVN4SM07Tcluzh4VK/sV307kfFQFX62CpZzy82J77OKuSkGCY5uzvOoZv7WB cjmtUUK+1BKSJbNQFfCAQYc+KrSiF2+jVwAtxIaHynqcydxZZu3LzQl50tRHmRAbz83K/jOEsasQL SWGzh596V5Ygw9yDBXT0bVvsG3L46kOLulothRE+ztuJM1nkD/tNzxn7iBMKsqDKQkOtutQUOnlqm SNzg565rabRp8T9yYAHQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ov2Eg-00EUQ6-MM; Tue, 15 Nov 2022 20:08:46 +0000 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ov2Ed-00EUOY-2X for linux-riscv@lists.infradead.org; Tue, 15 Nov 2022 20:08:44 +0000 Received: by mail-wr1-x42f.google.com with SMTP id cl5so26257840wrb.9 for ; Tue, 15 Nov 2022 12:08:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jamieiles.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xT3AgcfoR7jBMGz0aexOpadgy9URzXtZx9NcMwal4RA=; b=XgynjtRyypL0z1WzJGfSms2XvdPpZEkuiQKWXOAKP0M6L8Wxk0cIGukWZ6Z1gRND6S B6Dbh8b4RbrvdE226TZj6h6ndjPoQsUiE8YCHuSwamhBMyTWZ81/hugt9X7QdPsJnJQU v/DFZoJCP63Vc6wt7x5X0Z+YSIaJbOEwTyHaOFv4OFRQA9w/7KIunotGilwjdjAr+RWQ VWdaQNrQM6+D+q1ukQ+qulEpDsZoUEyk9jcoGU3ZoZCK0lSI2jjSNLaNs6tCsLsfva2V bRYVcuS9KQtkbuvtAvQKAHvllvriEZAmRyoJ9bL6ZZiTVHsfAqkY4rEZkGeChPLTm4OJ D5Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xT3AgcfoR7jBMGz0aexOpadgy9URzXtZx9NcMwal4RA=; b=7+JfANMPCiWFzxVTRSNCmj7cSIpeIFCaZzn9xNJnVwBy/lTkiTKSharW0Sskef0kd4 vGNWx3mkYEAz2Qvfq9Re2xsO4j24u52yC9N7YEkVVYNviWj5nFo6BpVtXuIEui9YQmsp OH3As9Zdj55bHQ2v1Fl3kjGujox6YrJTj9H+i2jzK8ER+wB8E7u5bSiBqxRoaga5EI7G wHn8uVIi9pqhoqBnJ7p5tUqCjmMOVtqtnrMla12P0pyWyE89dhgczd6kYzZ7RUvHs5RB 48+WUg95rWe+vTEiKt0OxAVaPW5+UTwrsKwtgiDzLM+beMprIxIOdrk6DRSo38amXkJb qZ8w== X-Gm-Message-State: ANoB5pk9Ov1R6AkgNGnf2oqVRjEAq2yDeyOR8xkv6pOlodBYoH1rV1Of v7JKI2rxf0ESAd7DtHf+BP363Ne8CBFF+A== X-Google-Smtp-Source: AA0mqf76fwnEh67K//rSYihWI7bhurJCzPdW6lVsR3x37KupV8U/PG+mh8wTj1idCkVwbh81EibIvw== X-Received: by 2002:a5d:5481:0:b0:235:a4a5:8e91 with SMTP id h1-20020a5d5481000000b00235a4a58e91mr12211234wrv.404.1668542918962; Tue, 15 Nov 2022 12:08:38 -0800 (PST) Received: from localhost ([5.181.106.148]) by smtp.gmail.com with ESMTPSA id r8-20020a056000014800b002206203ed3dsm13425989wrx.29.2022.11.15.12.08.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Nov 2022 12:08:38 -0800 (PST) From: Jamie Iles To: linux-riscv@lists.infradead.org Cc: Jamie Iles , Andrew Jones Subject: [PATCH v2 1/4] RISC-V: use REG_S/REG_L for mcount Date: Tue, 15 Nov 2022 20:08:29 +0000 Message-Id: <20221115200832.706370-2-jamie@jamieiles.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221115200832.706370-1-jamie@jamieiles.com> References: <20221115200832.706370-1-jamie@jamieiles.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221115_120843_132053_60009AAD X-CRM114-Status: UNSURE ( 8.14 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org In preparation for rv32i ftrace support, convert mcount routines to use native sized loads/stores. Reviewed-by: Andrew Jones Signed-off-by: Jamie Iles --- arch/riscv/kernel/mcount.S | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/arch/riscv/kernel/mcount.S b/arch/riscv/kernel/mcount.S index 6d462681c9c0..9cf0904afd6d 100644 --- a/arch/riscv/kernel/mcount.S +++ b/arch/riscv/kernel/mcount.S @@ -15,8 +15,8 @@ .macro SAVE_ABI_STATE addi sp, sp, -16 - sd s0, 0(sp) - sd ra, 8(sp) + REG_S s0, 0(sp) + REG_S ra, 8(sp) addi s0, sp, 16 .endm @@ -26,22 +26,22 @@ */ .macro SAVE_RET_ABI_STATE addi sp, sp, -32 - sd s0, 16(sp) - sd ra, 24(sp) - sd a0, 8(sp) + REG_S s0, 16(sp) + REG_S ra, 24(sp) + REG_S a0, 8(sp) addi s0, sp, 32 .endm .macro RESTORE_ABI_STATE - ld ra, 8(sp) - ld s0, 0(sp) + REG_L ra, 8(sp) + REG_L s0, 0(sp) addi sp, sp, 16 .endm .macro RESTORE_RET_ABI_STATE - ld ra, 24(sp) - ld s0, 16(sp) - ld a0, 8(sp) + REG_L ra, 24(sp) + REG_L s0, 16(sp) + REG_L a0, 8(sp) addi sp, sp, 32 .endm @@ -82,16 +82,16 @@ ENTRY(MCOUNT_NAME) la t4, ftrace_stub #ifdef CONFIG_FUNCTION_GRAPH_TRACER la t0, ftrace_graph_return - ld t1, 0(t0) + REG_L t1, 0(t0) bne t1, t4, do_ftrace_graph_caller la t3, ftrace_graph_entry - ld t2, 0(t3) + REG_L t2, 0(t3) la t6, ftrace_graph_entry_stub bne t2, t6, do_ftrace_graph_caller #endif la t3, ftrace_trace_function - ld t5, 0(t3) + REG_L t5, 0(t3) bne t5, t4, do_trace ret @@ -104,7 +104,7 @@ do_ftrace_graph_caller: addi a0, s0, -8 mv a1, ra #ifdef HAVE_FUNCTION_GRAPH_FP_TEST - ld a2, -16(s0) + REG_L a2, -16(s0) #endif SAVE_ABI_STATE call prepare_ftrace_return @@ -117,7 +117,7 @@ do_ftrace_graph_caller: * (*ftrace_trace_function)(ra_to_caller, ra_to_caller_of_caller) */ do_trace: - ld a1, -8(s0) + REG_L a1, -8(s0) mv a0, ra SAVE_ABI_STATE From patchwork Tue Nov 15 20:08:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jamie Iles X-Patchwork-Id: 13044122 X-Patchwork-Delegate: palmer@dabbelt.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 44025C43217 for ; Tue, 15 Nov 2022 20:08:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xXOvQ5y41xE0phypKxsl4v7zl2IDcJ23y8D1Rq6UU0E=; b=kWs/rn+7MWAoM/ Ao/hCWCUCR989riI0PSXXF3FSTPLKYeKo5uB0aaRKdcYg4O+bA7aJinuzwr/rmSh+ksUGhOoWpRbP SAR5GYLdr7j2viHpU5D3aX+44B/zVzi4gXRbT0d4w2qUqdAMmHcHCjdpAAlqp3npNR0wRWvDu4WNi s+AP9eiFrLQNdJR1+Wa8n/9rhoDqp9SQZONIm/Ab/kEUO7YBvvz6GAHpmAIRdhprTu7CEW08LcahG N4JiUH5EQbq0wpj7mR562J6Sd2Y2y9Avis2RjdaAyfCy84b9EOl8y8aTV5JeU4mIptnIJQq1CLzNK HiQbfsrDxpwwE3thENNQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ov2Ei-00EUR1-1v; Tue, 15 Nov 2022 20:08:48 +0000 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ov2Ee-00EUOZ-IL for linux-riscv@lists.infradead.org; Tue, 15 Nov 2022 20:08:45 +0000 Received: by mail-wm1-x32e.google.com with SMTP id p13-20020a05600c468d00b003cf8859ed1bso11136547wmo.1 for ; Tue, 15 Nov 2022 12:08:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jamieiles.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yEZxthwoJR8ikYAsnBg3VLqlA9l37WC0aRUXRJ9MycY=; b=E/41ajyIsOe0G+QsfA9ycZGH87iAWHxa/4RU5sx8vv+ZrErlBCPB78YxdftABytze0 AVgPne1/d/DZaNFu1BH9zS9DQfzYk5rTuLQL/6yTbl7N7Frx5al+ctZCYpPSr8X/6uiX aB6I9qHMKchHQAuK4BMHSOTZlPXm8xB1O31i1vWfziBvMMpKtp0ZANFdElMGh/8ZYP8+ m6suY3BuqjfIHWmxCwd8IK5x4+2dUcQ4oJfHQ6zrxHvef+crh665Z3kmTqU6okKlxS4r Cy7KPvGh9m6KDZVFWWiRKw46aYhT0d7by6tslzBPpHng3ZZFq3ZJkRm4P0jSseMcjuEH /N/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yEZxthwoJR8ikYAsnBg3VLqlA9l37WC0aRUXRJ9MycY=; b=6YQEhhexIE7EKDbpRLu7jLB+3wgFhnscjbXGOvxiRyriAXUWZfD6gKp8Jtjzh7Q2RX ojqhCWvn0DzfjNyR7ECW/LGxoktvoNn8S5hGX9S+YiYz+9hz1Mk40dhZ+V6aTFD6+SfF CIKxq6Z1p4oUqOgOaqo26M7egtDxt+zbGduUWb6qUAWfWmRgQBnKnJaUKbQ/ifSAjSu5 m1kyU/8kxf1SbAM7dUaCYgSzKliqulUw1LL+jyjGTLN7ON1WOaQK2V9M8GboVhY7B+CT ICjGxCuLNQVcaWeT5lbRLaGs72WErHm+wcNMewlcPTSxJ8yOwHV67fKVfisOoBdePcSA kLlQ== X-Gm-Message-State: ANoB5pmowoNYDsJK3ylCXspTGnYlpTYSUlPs1lysRpfOp0KSjfRXlbu6 xER1Ho+BjmSN1j2gQjOoKW7pE0l7wIn9gg== X-Google-Smtp-Source: AA0mqf4CEBd5alQ5WsJiLn7l/ukVLe/yTaKYz13oa9tuQh+Y4RelwsbOf2A18mZ5nDeEyWFfxXUmTg== X-Received: by 2002:a1c:4b0f:0:b0:3cf:758f:161f with SMTP id y15-20020a1c4b0f000000b003cf758f161fmr26745wma.54.1668542920465; Tue, 15 Nov 2022 12:08:40 -0800 (PST) Received: from localhost ([5.181.106.148]) by smtp.gmail.com with ESMTPSA id m29-20020a05600c3b1d00b003c6b7f5567csm3473999wms.0.2022.11.15.12.08.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Nov 2022 12:08:39 -0800 (PST) From: Jamie Iles To: linux-riscv@lists.infradead.org Cc: Jamie Iles Subject: [PATCH v2 2/4] RISC-V: reduce mcount save space on RV32 Date: Tue, 15 Nov 2022 20:08:30 +0000 Message-Id: <20221115200832.706370-3-jamie@jamieiles.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221115200832.706370-1-jamie@jamieiles.com> References: <20221115200832.706370-1-jamie@jamieiles.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221115_120844_620820_6A9EC12C X-CRM114-Status: UNSURE ( 8.91 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org For RV32 we can reduce the size of the ABI save+restore state by using SZREG so that register stores are packed rather than on an 8 byte boundary. Signed-off-by: Jamie Iles Reviewed-by: Andrew Jones --- arch/riscv/kernel/mcount.S | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/arch/riscv/kernel/mcount.S b/arch/riscv/kernel/mcount.S index 9cf0904afd6d..613bd07c6268 100644 --- a/arch/riscv/kernel/mcount.S +++ b/arch/riscv/kernel/mcount.S @@ -15,8 +15,8 @@ .macro SAVE_ABI_STATE addi sp, sp, -16 - REG_S s0, 0(sp) - REG_S ra, 8(sp) + REG_S s0, 0*SZREG(sp) + REG_S ra, 1*SZREG(sp) addi s0, sp, 16 .endm @@ -25,24 +25,24 @@ * register if a0 was not saved. */ .macro SAVE_RET_ABI_STATE - addi sp, sp, -32 - REG_S s0, 16(sp) - REG_S ra, 24(sp) - REG_S a0, 8(sp) - addi s0, sp, 32 + addi sp, sp, -4*SZREG + REG_S s0, 2*SZREG(sp) + REG_S ra, 3*SZREG(sp) + REG_S a0, 1*SZREG(sp) + addi s0, sp, 4*SZREG .endm .macro RESTORE_ABI_STATE - REG_L ra, 8(sp) - REG_L s0, 0(sp) + REG_L ra, 1*SZREG(sp) + REG_L s0, 0*SZREG(sp) addi sp, sp, 16 .endm .macro RESTORE_RET_ABI_STATE - REG_L ra, 24(sp) - REG_L s0, 16(sp) - REG_L a0, 8(sp) - addi sp, sp, 32 + REG_L ra, 3*SZREG(sp) + REG_L s0, 2*SZREG(sp) + REG_L a0, 1*SZREG(sp) + addi sp, sp, 4*SZREG .endm ENTRY(ftrace_stub) @@ -101,10 +101,10 @@ ENTRY(MCOUNT_NAME) * prepare_to_return(&ra_to_caller_of_caller, ra_to_caller) */ do_ftrace_graph_caller: - addi a0, s0, -8 + addi a0, s0, -SZREG mv a1, ra #ifdef HAVE_FUNCTION_GRAPH_FP_TEST - REG_L a2, -16(s0) + REG_L a2, -2*SZREG(s0) #endif SAVE_ABI_STATE call prepare_ftrace_return @@ -117,7 +117,7 @@ do_ftrace_graph_caller: * (*ftrace_trace_function)(ra_to_caller, ra_to_caller_of_caller) */ do_trace: - REG_L a1, -8(s0) + REG_L a1, -SZREG(s0) mv a0, ra SAVE_ABI_STATE From patchwork Tue Nov 15 20:08:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jamie Iles X-Patchwork-Id: 13044123 X-Patchwork-Delegate: palmer@dabbelt.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EFAA9C4332F for ; Tue, 15 Nov 2022 20:08:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/9nxe+li8GEIO8p3mv/iI1XQB7aJtW2wInq21zQF9XI=; b=gC9fx6/fIE6csM dR79qfUU1i2IPbq0wlNlhWE4CACcHMmloZ1/C0tnjKnilshhTHBZOUOQ6ZgGlOHd8Sv/sWSteWE7L yMwW3FPz/VNROAPeaVFJVbLyT9HLr7Riekpiz8DNn8k8K+GKYKjDR1MQjd0HFfjBcrVZaaDdO0AI7 wXZQdemZBSm6hXS47e99MSc6doIARN1ihHEH5g5wirpdgVdjuR4K9e3Nm6cyOxQlxQUR8B74Bdfv6 fRZaU1/pI/MoPTwI0jrnDsBGlfxRmwGOXYCV+VsZh8yDYxTnKZFP0U9gswEkrAv812hdlrFs4uVHT JzmlQQZ65aNzUKAIBvWA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ov2Ej-00EURN-J7; Tue, 15 Nov 2022 20:08:49 +0000 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ov2Eg-00EUP0-3t for linux-riscv@lists.infradead.org; Tue, 15 Nov 2022 20:08:47 +0000 Received: by mail-wm1-x330.google.com with SMTP id 5so10449507wmo.1 for ; Tue, 15 Nov 2022 12:08:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jamieiles.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lem3JFRGQXteyT/VGs+SUok868Rxk0mkNrpcdtQDPu4=; b=efeqNe7UBWvJ9srYeZdQOEOF5c67vebzOXKSmneU4d+msHmqlQ+YC5DNc1luVUTvPn N8tpJBX77jqBJlufu12OzvqnUBd1J362fnM+AhC7Ddd9Y8CMlt8BrXCiMbt/73GlFRhp /zs+boQXvMOL7OkV86x8xrx3G6FZ4tO5YlKGs4zd4IcWguO3IlX83Cn1bAbKSgarDabI YKNrXvmIQwSUi8SJn9gG8BSvziVY7Xc+VKM2N0cDdGQJLHHrwu2gH+P8oeC4TPnVALP3 dOZN74l23uMfRONFeSyTgjot+7FP0DYTcIubuzpQ7a6+nu2f4dJl2ryhbFsry3pivEMj kjiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lem3JFRGQXteyT/VGs+SUok868Rxk0mkNrpcdtQDPu4=; b=Mecc4lO42CSAU074MBrCPI2QC3NovgtezsQ0hzu8nxqMjttkAcgaueQnxPUL1x8zC8 68SnTN5kf6yL4xaGCbVLNJgbLeWIte2ihaZLGovDLbMupkYrJV7zLuL/oMOWlczp/zGW 8txwPCyk5sLZTC6z7Hd1NEhAhHpd2K0xradzkFw163q2+Wch7Y2YQWW6txkUFw1vMvUv ZqA682FrVQp0zvU0OujGeLJTajZ7+imkQKsPMnG32bOaOh8vlw9xCS1nTopGNg05ujB1 bBoPCqLA3l7D4QvrIv1YsVu0PVKIMSQHnpY8y5OlZ6AsrRJP+bILAZDXnRkBXVJt9fLY vEyQ== X-Gm-Message-State: ANoB5pku911OtzCvvX0ST93GPomRKytWpRA/nWmvnMrHhsP0CgrT/O7L gt3DoFBLpCy+bA+ZoTiir11W01lzmwJV8w== X-Google-Smtp-Source: AA0mqf6/Mmc4WS6QQ+6kUEAbx02G8YxbDsCrelEPePKWmDWQ6VheJGqxojM4hI832MsOFsZ+yfHMAQ== X-Received: by 2002:a05:600c:3788:b0:3cf:6c2f:950c with SMTP id o8-20020a05600c378800b003cf6c2f950cmr2702503wmr.146.1668542922585; Tue, 15 Nov 2022 12:08:42 -0800 (PST) Received: from localhost ([5.181.106.148]) by smtp.gmail.com with ESMTPSA id z8-20020adfec88000000b00236722ebe66sm13401745wrn.75.2022.11.15.12.08.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Nov 2022 12:08:41 -0800 (PST) From: Jamie Iles To: linux-riscv@lists.infradead.org Cc: Jamie Iles , Andrew Jones Subject: [PATCH v2 3/4] RISC-V: preserve a1 in mcount Date: Tue, 15 Nov 2022 20:08:31 +0000 Message-Id: <20221115200832.706370-4-jamie@jamieiles.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221115200832.706370-1-jamie@jamieiles.com> References: <20221115200832.706370-1-jamie@jamieiles.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221115_120846_172946_5B210AAD X-CRM114-Status: UNSURE ( 9.54 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org The RISC-V ELF psABI states that both a0 and a1 are used for return values so we should preserve them both in return_to_handler. This is especially important for RV32 for functions returning a 64-bit quantity otherwise the return value can be corrupted and undefined behaviour results. Reviewed-by: Andrew Jones Signed-off-by: Jamie Iles --- arch/riscv/kernel/mcount.S | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/riscv/kernel/mcount.S b/arch/riscv/kernel/mcount.S index 613bd07c6268..30102aadc4d7 100644 --- a/arch/riscv/kernel/mcount.S +++ b/arch/riscv/kernel/mcount.S @@ -29,6 +29,7 @@ REG_S s0, 2*SZREG(sp) REG_S ra, 3*SZREG(sp) REG_S a0, 1*SZREG(sp) + REG_S a1, 0*SZREG(sp) addi s0, sp, 4*SZREG .endm @@ -42,6 +43,7 @@ REG_L ra, 3*SZREG(sp) REG_L s0, 2*SZREG(sp) REG_L a0, 1*SZREG(sp) + REG_L a1, 0*SZREG(sp) addi sp, sp, 4*SZREG .endm @@ -71,9 +73,9 @@ ENTRY(return_to_handler) mv a0, t6 #endif call ftrace_return_to_handler - mv a1, a0 + mv a2, a0 RESTORE_RET_ABI_STATE - jalr a1 + jalr a2 ENDPROC(return_to_handler) #endif From patchwork Tue Nov 15 20:08:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jamie Iles X-Patchwork-Id: 13044124 X-Patchwork-Delegate: palmer@dabbelt.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 020A3C4332F for ; Tue, 15 Nov 2022 20:09:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wbrGyAMT823hg6AYii2/DPgjtn5wk6DhcFWfPECuZNI=; b=uMJRRuu/viaCnl VBij1x3zJ40KHKw1D8siE7aDIMbJeRp/5/zRkM2QFER9lwBSBtWfT+b1gyxDyqoKAiLCzKkpdNtad q+WTRnlbwUgAIIfNPO83Gm8dZfayb/hayvG94NidIjoS9bluFL3lUMcLhdOY9P9SyIEMWKMkmU8tZ NW//W7qmiyN5p8L5YddgjUSfULkF73buweonJFor8iVQ9r8Sz0waOpwhsjO/M5pjlvy35pHd66mjE Cm/mxesr/4qdDT40WyDbwZtJBrrn8JfV/6vgVzKhZ5d0fISZhrlSWjjuo39E3eUdh+p9WZ5GcMzJu ix1j+gA7UntwR8QYhXoA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ov2Er-00EUUA-WD; Tue, 15 Nov 2022 20:08:58 +0000 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ov2Ep-00EUQ7-Sm for linux-riscv@lists.infradead.org; Tue, 15 Nov 2022 20:08:57 +0000 Received: by mail-wr1-x42d.google.com with SMTP id a14so26281182wru.5 for ; Tue, 15 Nov 2022 12:08:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jamieiles.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4ZewNcWS1CBuE/TOZhf1B+A3aeLfdjLjA0yDv/ensoA=; b=Kx4IyUiyLrxrK99Z0EdEamaXI7fTY7abjWk5bbGDASfMbdOzQx0fAEtfFYInKdcRll 4VSiXGqgzHu6Aoz2zUOvYUtuyIrMVHBa37KCL0z4NLet7+J/YfMdC1AMNipXLGBVAygA OK283kwkWNS7PCrAkveBZUhc/saX3E5lSCLs3HWrlZRyUUnwoRWAHXHCI0hPzLUSsQ+L OaNMCTpjdYGuPG25iZCUedicpyA3Rdf6hincO77CIzbzXTMBc0qio+c7iLZNQaNVg40G xaqoz8Etq5V1OA7foUwFckPx6eJ+X1U0de0iSpgxLTlbJHhIOULez7CInhCkxWowoW7g tD4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4ZewNcWS1CBuE/TOZhf1B+A3aeLfdjLjA0yDv/ensoA=; b=OlOd3K7EbYboiUR+0mP3afQBNRzLpdDeX99FgFsJ54QQYxVRb2fe1FjbbQTG2PAsXH KfzwZIYWFQe18kB7rmWJkmQde5/2hG2uWQUK1G7R1i45sW32uJicpKqoiqgNSGNYuAzX pgyXa/UN8+80r7t4neRfD6AJhO0flG3JSRSKPJfYUYEMmzlcDUum6OfdzLntfe4eiohe hDc5yXoQXyHWz6Qyz2qqR3pLoOm33+4iDnJpFfRYw1cy45KaV/Z00R9wDWy1FXBYDw1Y +uhgVpRsTlk5L5Ha2Ng9ycAB6uBAczfQTb8siAy9uBdvJVFOsDs6P+lvg73mmIDVYByI vmVA== X-Gm-Message-State: ANoB5pmOG5WTaKptaoxIUBWO+voQwKAMEFBTStvIgqVJiTBoL37OjHSU 70WGaNTC6RzSy7rhgOgyCZn4srp6yWckkQ== X-Google-Smtp-Source: AA0mqf4o5KFdSk7TJdSynDPEf9pXWVngFsl1g1F+1O1hVglMn55dJQ9L1o8xYIIQ7bdnajpQm2ezsw== X-Received: by 2002:a5d:4844:0:b0:236:71ce:a49e with SMTP id n4-20020a5d4844000000b0023671cea49emr12096315wrs.257.1668542925413; Tue, 15 Nov 2022 12:08:45 -0800 (PST) Received: from localhost ([5.181.106.148]) by smtp.gmail.com with ESMTPSA id g9-20020a05600c310900b003a2f2bb72d5sm28534647wmo.45.2022.11.15.12.08.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Nov 2022 12:08:44 -0800 (PST) From: Jamie Iles To: linux-riscv@lists.infradead.org Cc: Jamie Iles Subject: [PATCH v2 4/4] RISC-V: enable dynamic ftrace for RV32I Date: Tue, 15 Nov 2022 20:08:32 +0000 Message-Id: <20221115200832.706370-5-jamie@jamieiles.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221115200832.706370-1-jamie@jamieiles.com> References: <20221115200832.706370-1-jamie@jamieiles.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221115_120855_944555_DC9F3A81 X-CRM114-Status: GOOD ( 10.40 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org The RISC-V mcount function is now capable of supporting RV32I so make it available in the kernel config. Signed-off-by: Jamie Iles --- arch/riscv/Kconfig | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 6b48a3ae9843..5ae4f7ce2a05 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -129,6 +129,11 @@ config RISCV select TRACE_IRQFLAGS_SUPPORT select UACCESS_MEMCPY if !MMU select ZONE_DMA32 if 64BIT + select HAVE_DYNAMIC_FTRACE if !XIP_KERNEL && MMU && $(cc-option,-fpatchable-function-entry=8) + select HAVE_DYNAMIC_FTRACE_WITH_REGS if HAVE_DYNAMIC_FTRACE + select HAVE_FTRACE_MCOUNT_RECORD if !XIP_KERNEL + select HAVE_FUNCTION_GRAPH_TRACER + select HAVE_FUNCTION_TRACER if !XIP_KERNEL config ARCH_MMAP_RND_BITS_MIN default 18 if 64BIT @@ -274,11 +279,6 @@ config ARCH_RV64I bool "RV64I" select 64BIT select ARCH_SUPPORTS_INT128 if CC_HAS_INT128 - select HAVE_DYNAMIC_FTRACE if !XIP_KERNEL && MMU && $(cc-option,-fpatchable-function-entry=8) - select HAVE_DYNAMIC_FTRACE_WITH_REGS if HAVE_DYNAMIC_FTRACE - select HAVE_FTRACE_MCOUNT_RECORD if !XIP_KERNEL - select HAVE_FUNCTION_GRAPH_TRACER - select HAVE_FUNCTION_TRACER if !XIP_KERNEL select SWIOTLB if MMU endchoice