From patchwork Wed Oct 4 15:13:58 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: 13408891 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 DA20CE7C4D6 for ; Wed, 4 Oct 2023 15:14:41 +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=8+KdRg0Vfjd1OLTt0yCcOWo/qLIYKr5JgyOmfPVFbK0=; b=vp+dSxKgpzVB3V p2Jp4su4T+kxKKeCtquAqZNY8Vrjdfr/dtTw79BSMRF6APEF/pWY76fvaSAfpIbDbpUz2TrFF1RTv bcDs49nJMTeKcbTtfnn+bct0q6vwWzzZl1SnY2Y1WiuQqXCisoTNXaOF9fdiNWKLLXWiCXGjFCtXy IlUE4qMuNWYvQm55n4NYBuf9DpbbMeeaBov34vUNOsF5oDjo7+YDRxx6Qi8ow//MwzR5F2D2CupIC Dt6l9z7SoqYbnxffVzF3wZzpX/gu/xJSmcq5ciRDMKxGck2vFHc++25ZlCeN50w5po0kzxHgzQTnn Mid1giU87PTjP8pnj1Yg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qo3a0-000JYv-1Q; Wed, 04 Oct 2023 15:14:28 +0000 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qo3Zx-000JXl-1o for linux-riscv@lists.infradead.org; Wed, 04 Oct 2023 15:14:26 +0000 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-405d70d19bcso4000335e9.0 for ; Wed, 04 Oct 2023 08:14:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1696432464; x=1697037264; 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=v7cbbMj+E5ZBlob6bJSyN7OfL5gwM5MZRfPIQhkQ9FM=; b=Ln6oFJ68DZXy6nNtakfKkd7xFe59+CVgePRpR8rgCJmZNSrtt3hPpP4yp6ZHlYWu4t EnUfSg3sDWfvxz4XPH8WN9XQNGtvreYifgCyD0oppU9jz97jujO1rvCSecmPQXFIuWyx towtXxowLm5T3zKYdf2Xq0xqx3iC3Fyfqjnu+0dXOO40HV6h1Os71EArLozz/wFucbfn LZSO9X+6Co1ZLFFYyOQP7A0arZH44KwFZLu2XC/AYOXieYYmH3JGgcSB+rfUD1ubWHOS J36ZBSJfIGsqL8gSAcJXig8qFkDPIB22SoNJtoaQOgstjog7t2Euwou+lZ9r+IB0qxjC i2Gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696432464; x=1697037264; 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=v7cbbMj+E5ZBlob6bJSyN7OfL5gwM5MZRfPIQhkQ9FM=; b=UendlYrKC9o1P1ypuTAfVhA9P3VKtWeJb9KAU+DM94xEvghtrWC01S1QrXw4czkmGQ aH09qD/xrAsp0twpjD1WjMdKHJT7pMTAeKPQEAYJ3uTEENineS7FozwuJXV74SBe8A9A dd9q3hQNXccklDARlgY0tBdkNRNaWfJVyQMnwTIIRcBe2rqhosWAWDVEi9nNWvDYKBk5 gCVk4Y2iPiK24eV7cAliU4Y21JWhGeRuLnzNWGzEk6rNTomRPHH9U8KjxxqWtwnL0mbs h00W539epMEG/i3+ZxbFT3QdP9cg8nGUDIAekjIlAcWKvwIr0RsBG7h0cm4lFtxtZdHf M9aQ== X-Gm-Message-State: AOJu0YztSpqRIxpkpyc8bwGON/bbA3bwm4Apn13Z0HngMVFtaFl+fsCf eY1Q4+dlWSWrrlj8LBvmhv2YbA== X-Google-Smtp-Source: AGHT+IFUYTV7FQFGtTHrMfR1VYTiBZo398LRCCrHvZm7ekynuy7D8ReYeOuSobKwivtHrDzV0o76mg== X-Received: by 2002:a05:600c:510b:b0:404:75cc:62e6 with SMTP id o11-20020a05600c510b00b0040475cc62e6mr2495282wms.3.1696432464039; Wed, 04 Oct 2023 08:14:24 -0700 (PDT) Received: from carbon-x1.. ([2a01:e0a:999:a3a0:9474:8d75:5115:42cb]) by smtp.gmail.com with ESMTPSA id i2-20020a05600c290200b00402f7b50517sm1768764wmd.40.2023.10.04.08.14.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 08:14:23 -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 , Conor Dooley Subject: [PATCH v2 1/8] riscv: remove unused functions in traps_misaligned.c Date: Wed, 4 Oct 2023 17:13:58 +0200 Message-ID: <20231004151405.521596-2-cleger@rivosinc.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231004151405.521596-1-cleger@rivosinc.com> References: <20231004151405.521596-1-cleger@rivosinc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231004_081425_598885_2FC3B3B5 X-CRM114-Status: UNSURE ( 9.07 ) 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) {