Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2137434ybt; Sun, 28 Jun 2020 09:12:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAzmV+fu6iz97+soHQ1R721zzc4IhrIU5/w0sHql/0NlZUtrXPfRC5g88togW9FgMkBM6W X-Received: by 2002:a17:906:4f94:: with SMTP id o20mr10304267eju.113.1593360733766; Sun, 28 Jun 2020 09:12:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593360733; cv=none; d=google.com; s=arc-20160816; b=FDq2bfp6Kgwu5bovp9Ug0jWwz9nqAj8x5eh5hECoUQ7jWA09eRlQ5clPzneG6FcfE+ 1DsNJsKNJ8YFFZSPlHHEx8gHfw+tx2VdtkJXE7CGhL3hUeXN9zvL82tbcwH3QSfCVXGc 0NiNgQR1IoDtXSQt5Xf6TiNeZIqj1uXaekV0VRbph6e94/7RVs1J8Nu8JPveSAUlw5A5 AtLYGfHvdAar6v1dpy8ero558VF/h2A7wRTT+7B0shj6Sc+OkJ50T9uictB+01iT7ocb c/ZGFcJtyruURP1SE2lt6crE/TkXc6PW+EuHJY+YbbFv0pPnGxuewi+wSSrfRYBsw9hP cBpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=yBEjE2svm1fqCbBeDe5MSyX+FejWXeNqDrYH+R2Sb9k=; b=NOSn9bWRUyHXeVY+MDnamIoBTLnm5W1rPGUfkH3wmVR7UVMDrK+FTXRh7HxdWw1rLZ 5D9WGbotg2Y0y3v2Ru1WZbNUDMjx3S4wBc0wToe7UVzUterhvodV8k7keW5MUn/tJmYj N7/GnXmKZ/og3N4iOfnyegran7Jd/kblANeiZt3F43S/Ns8oM83UeXbiyzlXgk7vSbmg YvwM3FNyxZBicvZx380gQHBAaFjaDWUKHdN+YeeqE/m0L0lr1/W59bYGyeP0jQ3adpr/ 55BAyf9+ENyZgqeZbwihQOrCeleBEAwrVUqwmad1+mkuhjBgbITWz1YGy0h5jFequ/UC HLbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=aRA4km5O; 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 e23si6848837edy.264.2020.06.28.09.11.50; Sun, 28 Jun 2020 09:12:13 -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; dkim=pass header.i=@kernel.org header.s=default header.b=aRA4km5O; 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 S1726395AbgF1QIf (ORCPT + 99 others); Sun, 28 Jun 2020 12:08:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:37190 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726002AbgF1QIf (ORCPT ); Sun, 28 Jun 2020 12:08:35 -0400 Received: from localhost.localdomain (unknown [89.208.247.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A1BCC20771; Sun, 28 Jun 2020 16:08:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593360515; bh=JmkxcNePUGahgp6O8ZRxtWIgYYelQDYOd98hMhE4jz0=; h=From:To:Cc:Subject:Date:From; b=aRA4km5ODQzgSQKGiSPi0I/FFP+UA1Hj/Hi5IXsHyvsJ1hQUq/9a4QfwyuWa8eDRO IqjMjaOiiIBuS2rUuBdPLxpLU7xiDggEKdR+nHrccyWJJJh6M5/lacuXgtRJlojU0/ 6jlQYW44Ek86IOJmxBXlEpGiiNmvIb1UwBwvgYEE= From: guoren@kernel.org To: greentime.hu@sifive.com, mhiramat@kernel.org, guoren@kernel.org Cc: palmerdabbelt@google.com, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, paul.walmsley@sifive.com, anup@brainfault.org, linux-csky@vger.kernel.org, zong.li@sifive.com, Guo Ren Subject: [PATCH V2] riscv: Fixup compile error BUILD_BUG_ON failed Date: Sun, 28 Jun 2020 16:07:37 +0000 Message-Id: <1593360457-23827-1-git-send-email-guoren@kernel.org> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org 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 Cc: Masami Hiramatsu Cc: Zong Li --- Changelog V2: - Use __always_inline as same as fix_to_virt - Use const "const unsigned int" for 2th param Signed-off-by: Guo Ren --- 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 d4a64df..3179a4e 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