From patchwork Tue Sep 26 15:03:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= X-Patchwork-Id: 13399308 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 14890E7E648 for ; Tue, 26 Sep 2023 15:04:08 +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=lHFyMDqIFfMpEhX0jRdhThq+/KF5BFM/fywmQQQrIHY=; b=Rb1iXdV/SKCVts dL6XuBNHgwO0Vcg+KEohkAAtRmQoHRbJ7BTFFHuf/rILL1uPQPBrJU4wOVczMXKVr9cL0eSBrNLC8 T7EyZO2wICBQWTA8ixrprpcqzaKpt5ECQqKYNLhHmEdBQXyrxqG6r4ElY4/RUrh5Ez9bW9uuNIjGC ZWugqlTL6Q9wDNUcEIPr9P6MKZ7MEiPndDtSaPNrdYrgoxQUjDxSA9xKeP4NZ9Rz9Lf1yJ59J8ltK I2jvo71eFk9nBDHC98hQf3/YE185CmSXseM02h3sQZIyYu29aFiNytOeqDOErS22FI2nzgbBtXVbc ED26Fg0kFVA38GU+jiWA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1ql9bX-00GbNs-0S; Tue, 26 Sep 2023 15:04:03 +0000 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1ql9bQ-00GbJZ-1P for linux-riscv@lists.infradead.org; Tue, 26 Sep 2023 15:03:59 +0000 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-3232bb059d3so775976f8f.1 for ; Tue, 26 Sep 2023 08:03:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1695740632; x=1696345432; darn=lists.infradead.org; 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=XQDAxN5g1vMcAJWLoIEgGtbs3vH3NsC3JS3eiLLd1tc=; b=v1J9p0rcq9E76GiPKCMTNdaKvf6uyz68OXT1bGFzV6jon8MaBUaXw57Liq5TUx7enA YBLNMzlARFJrw1mla5uUs4cJ8P8G7Vbnit55IuMXgp67EC6C8gGgjWa5Kn29yiOwh0O+ N0PAggsxQhSYv258LX5945zxjoqpID+4LpXfXS99PLe4+ejnhlq9c83vhl7xfFxYQevp m5NaxIm9EIP/Y9WoqtXSYYPNdwVzkzqGRhh/Ufy9JAHrxKNoF6pxulKVTvLEHhTzTNRT /+x3fY2CNsDp/sbpxBWFNWOefRSYPm1EPKy1/vMe+xVq08PhqS0wyx342upuEdAnZ9qo 6EcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695740632; x=1696345432; 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=XQDAxN5g1vMcAJWLoIEgGtbs3vH3NsC3JS3eiLLd1tc=; b=uc8+c/dV7dG9N7iAeWUxeDVhASZtpXBdIrfoY5n4zLl8+ms3t72VvQWHtcoovyl8aD akeHGdOnsy5GmoGjh0z7HH7o/xvjqMlYX2ab+HUS4NGUXQ7UNli0VkmvQx3UK15Hd2w3 +c6sBRXH0vrjO2Pwoak2uoNSiCt9WTwXSJ2LHP/eElDvqNUcERwSyLjwDdj8Vyrchn7h V5d0OcCcEonYJghDDhYU9L62i/bnA96SQURjPm5etN9hEgDw3FT0gQeast3auk8oYrOx thbnGwy9I8yGZLKi0wkXC1vFyKfhAfyV8yfEWLWXJ840Diye+bmoObwgUAf0eHV73R1W PavA== X-Gm-Message-State: AOJu0YxRC46zpkVddvePO/CtVTd+nXktYlg2D9VzfxuCmkGAc2T1SY5C mKCpg90y1UpJqDLuusgsEdTyIA== X-Google-Smtp-Source: AGHT+IH9PRCXtJEPxMLZQ5j5Z5+cpNGCxbKpqseY8qd18eONWrD2LaNnzT+g47bz5kOVc9HeGDcZ5g== X-Received: by 2002:adf:a456:0:b0:323:2df9:618f with SMTP id e22-20020adfa456000000b003232df9618fmr3634053wra.0.1695740632703; Tue, 26 Sep 2023 08:03:52 -0700 (PDT) Received: from carbon-x1.. ([2a01:e0a:999:a3a0:2b3d:6c70:9dbf:5ede]) by smtp.gmail.com with ESMTPSA id x11-20020a5d650b000000b00318147fd2d3sm14926060wru.41.2023.09.26.08.03.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 08:03:52 -0700 (PDT) From: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= To: Paul Walmsley , Palmer Dabbelt , Albert Ou Cc: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= , Atish Patra , Andrew Jones , Evan Green , =?utf-8?q?Bj=C3=B6rn_Topel?= , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Ron Minnich , Daniel Maslowski Subject: [PATCH 1/7] riscv: remove unused functions in traps_misaligned.c Date: Tue, 26 Sep 2023 17:03:10 +0200 Message-Id: <20230926150316.1129648-2-cleger@rivosinc.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230926150316.1129648-1-cleger@rivosinc.com> References: <20230926150316.1129648-1-cleger@rivosinc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230926_080356_494405_294A1CF8 X-CRM114-Status: UNSURE ( 9.40 ) 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 Replace macros by the only two function calls that are done from this file, store_u8() and load_u8(). Signed-off-by: Clément Léger --- arch/riscv/kernel/traps_misaligned.c | 46 +++++----------------------- 1 file changed, 7 insertions(+), 39 deletions(-) diff --git a/arch/riscv/kernel/traps_misaligned.c b/arch/riscv/kernel/traps_misaligned.c index 378f5b151443..e7bfb33089c1 100644 --- a/arch/riscv/kernel/traps_misaligned.c +++ b/arch/riscv/kernel/traps_misaligned.c @@ -151,51 +151,19 @@ #define PRECISION_S 0 #define PRECISION_D 1 -#define DECLARE_UNPRIVILEGED_LOAD_FUNCTION(type, insn) \ -static inline type load_##type(const type *addr) \ -{ \ - type val; \ - asm (#insn " %0, %1" \ - : "=&r" (val) : "m" (*addr)); \ - return val; \ -} +static inline u8 load_u8(const u8 *addr) +{ + u8 val; -#define DECLARE_UNPRIVILEGED_STORE_FUNCTION(type, insn) \ -static inline void store_##type(type *addr, type val) \ -{ \ - asm volatile (#insn " %0, %1\n" \ - : : "r" (val), "m" (*addr)); \ -} + asm volatile("lbu %0, %1" : "=&r" (val) : "m" (*addr)); -DECLARE_UNPRIVILEGED_LOAD_FUNCTION(u8, lbu) -DECLARE_UNPRIVILEGED_LOAD_FUNCTION(u16, lhu) -DECLARE_UNPRIVILEGED_LOAD_FUNCTION(s8, lb) -DECLARE_UNPRIVILEGED_LOAD_FUNCTION(s16, lh) -DECLARE_UNPRIVILEGED_LOAD_FUNCTION(s32, lw) -DECLARE_UNPRIVILEGED_STORE_FUNCTION(u8, sb) -DECLARE_UNPRIVILEGED_STORE_FUNCTION(u16, sh) -DECLARE_UNPRIVILEGED_STORE_FUNCTION(u32, sw) -#if defined(CONFIG_64BIT) -DECLARE_UNPRIVILEGED_LOAD_FUNCTION(u32, lwu) -DECLARE_UNPRIVILEGED_LOAD_FUNCTION(u64, ld) -DECLARE_UNPRIVILEGED_STORE_FUNCTION(u64, sd) -DECLARE_UNPRIVILEGED_LOAD_FUNCTION(ulong, ld) -#else -DECLARE_UNPRIVILEGED_LOAD_FUNCTION(u32, lw) -DECLARE_UNPRIVILEGED_LOAD_FUNCTION(ulong, lw) - -static inline u64 load_u64(const u64 *addr) -{ - return load_u32((u32 *)addr) - + ((u64)load_u32((u32 *)addr + 1) << 32); + return val; } -static inline void store_u64(u64 *addr, u64 val) +static inline void store_u8(u8 *addr, u8 val) { - store_u32((u32 *)addr, val); - store_u32((u32 *)addr + 1, val >> 32); + asm volatile ("sb %0, %1\n" : : "r" (val), "m" (*addr)); } -#endif static inline ulong get_insn(ulong mepc) {