Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1353234pxu; Thu, 17 Dec 2020 08:06:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJzMyloR1vIXB8alCwqWy31233r7itWCnurCncQFrQ6s+6fcOKf8kPBGE8kDMuh3JRniGKBe X-Received: by 2002:a17:906:b002:: with SMTP id v2mr6148526ejy.531.1608221170950; Thu, 17 Dec 2020 08:06:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608221170; cv=none; d=google.com; s=arc-20160816; b=RP6Yi7JIiZrOvff0bs6fbO44c2CbIlxchR/V4Fcp6A+Uvk/S9Ky/gBVCe5IDfJgWbc hLKWoCSg6dsx2V4SZ1CnArh15T3RvdN5OPBmbmoU2NTe3XgFjvroSryvRA5iVEHZWvus 6/Y509mVuxn6on72E3f8vk+KiYhzF4H4zw3m6PZQyuy2bv+mZIItr3bxgYZSmP2K1dH6 0/pM/dIUlS2BvTRR8JND9LAXhSKKBL0oX/G4MJKx5L8AlVzK4penbKNiBb4nd5eQz0iV OLuRmwrxAr02h9HBbypxMrnAePu+gUnbM1+97XBKLabggqJo6gHao3r2QWLHbCxqQrzE dRGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=K2NaSMSXGbu7bumRRClJ5tfc0MymQ4m4T2u72wQM6Yw=; b=DDj+OkHfgjmoZTBrPdliHn9OYf2Wfq9MoFc7qmCs0mG7NNLUe3YaZxqV/QE7B/s6A2 qSNHW76QTU93iYf77atoovnNrJk3DKzeG4ALA48TeO1XQbVNPRNL+mVc0a1HTPNDo74H RjzGaWNxWsxDnzjxn4s3M61bfc43eHgvxbMcqw91KSsXdp4M2Y5uxAJcbISF//OEQ6jS iHK7PkxAfQ5okBTqw0LwGBPa1j/JEBfpGUVJcsgE0BF01+cOPZs9oEhCBsUT4nj1FQhh BhpXs0BC1rwRf5PEHnmQf2MMyim9P44uNYb/eYthgIL1tWwIcngED5XxCnbRD8wOulFe b0sw== 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f7si2895130ejx.294.2020.12.17.08.05.48; Thu, 17 Dec 2020 08:06:10 -0800 (PST) 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728850AbgLQQEU (ORCPT + 99 others); Thu, 17 Dec 2020 11:04:20 -0500 Received: from mail.kernel.org ([198.145.29.99]:52906 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727660AbgLQQES (ORCPT ); Thu, 17 Dec 2020 11:04:18 -0500 From: guoren@kernel.org Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: palmerdabbelt@google.com, paul.walmsley@sifive.com, mhiramat@kernel.org, alankao@andestech.com, rostedt@goodmis.org, bjorn.topel@intel.com, pdp7pdp7@gmail.com Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, anup@brainfault.org, linux-csky@vger.kernel.org, greentime.hu@sifive.com, zong.li@sifive.com, guoren@kernel.org, me@packi.ch, Guo Ren , Palmer Dabbelt Subject: [PATCH v5 2/9] riscv: Fixup compile error BUILD_BUG_ON failed Date: Thu, 17 Dec 2020 16:01:38 +0000 Message-Id: <1608220905-1962-3-git-send-email-guoren@kernel.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1608220905-1962-1-git-send-email-guoren@kernel.org> References: <1608220905-1962-1-git-send-email-guoren@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Guo Ren Unfortunately, the current code couldn't be compiled: CC arch/riscv/kernel/patch.o In file included from ./include/linux/kernel.h:11, from ./include/linux/list.h:9, from ./include/linux/preempt.h:11, from ./include/linux/spinlock.h:51, from arch/riscv/kernel/patch.c:6: In function ‘fix_to_virt’, inlined from ‘patch_map’ at arch/riscv/kernel/patch.c:37:17: ./include/linux/compiler.h:392:38: error: call to ‘__compiletime_assert_205’ declared with attribute error: BUILD_BUG_ON failed: idx >= __end_of_fixed_addresses _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) ^ ./include/linux/compiler.h:373:4: note: in definition of macro ‘__compiletime_assert’ prefix ## suffix(); \ ^~~~~~ ./include/linux/compiler.h:392:2: note: in expansion of macro ‘_compiletime_assert’ _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) ^~~~~~~~~~~~~~~~~~~ ./include/linux/build_bug.h:39:37: note: in expansion of macro ‘compiletime_assert’ #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg) ^~~~~~~~~~~~~~~~~~ ./include/linux/build_bug.h:50:2: note: in expansion of macro ‘BUILD_BUG_ON_MSG’ BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition) ^~~~~~~~~~~~~~~~ ./include/asm-generic/fixmap.h:32:2: note: in expansion of macro ‘BUILD_BUG_ON’ BUILD_BUG_ON(idx >= __end_of_fixed_addresses); ^~~~~~~~~~~~ Because fix_to_virt(, idx) needs a const value, not a dynamic variable of reg-a0 or BUILD_BUG_ON failed with "idx >= __end_of_fixed_addresses". Signed-off-by: Guo Ren Reviewed-by: Masami Hiramatsu Reviewed-by: Pekka Enberg Cc: Paul Walmsley Cc: Palmer Dabbelt --- arch/riscv/kernel/patch.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/riscv/kernel/patch.c b/arch/riscv/kernel/patch.c index 3fe7a52..0b55287 100644 --- a/arch/riscv/kernel/patch.c +++ b/arch/riscv/kernel/patch.c @@ -20,7 +20,12 @@ struct patch_insn { }; #ifdef CONFIG_MMU -static void *patch_map(void *addr, int fixmap) +/* + * The fix_to_virt(, idx) needs a const value (not a dynamic variable of + * reg-a0) or BUILD_BUG_ON failed with "idx >= __end_of_fixed_addresses". + * So use '__always_inline' and 'const unsigned int fixmap' here. + */ +static __always_inline void *patch_map(void *addr, const unsigned int fixmap) { uintptr_t uintaddr = (uintptr_t) addr; struct page *page; @@ -37,7 +42,6 @@ static void *patch_map(void *addr, int fixmap) return (void *)set_fixmap_offset(fixmap, page_to_phys(page) + (uintaddr & ~PAGE_MASK)); } -NOKPROBE_SYMBOL(patch_map); static void patch_unmap(int fixmap) { -- 2.7.4