Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1349018ybh; Mon, 13 Jul 2020 16:40:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMPdzawv+LjmqttJvbbvNPeGZF7gK7VIBWvXSXokpADEirNefSm2z7408aQyuCfm4i/kDV X-Received: by 2002:aa7:c2d7:: with SMTP id m23mr1779248edp.216.1594683629667; Mon, 13 Jul 2020 16:40:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594683629; cv=none; d=google.com; s=arc-20160816; b=EukAFcImYkk966lTol6sv+jW7tVV2sh2XSQIhUVofSVWtWNXBcZg14oG/wnMYGelZZ M7/VXi8lj9rq+mPV3YBU4nMqdXHB2CTjxPEEA3WpdTmC4g1oaiSM20CKW3xpvMEyHMls Az0w02c5u7LkaK6TRQf/IY4AWVcHsq0vfIXN+eZF5P2gjaIgBhIKNwP9UcQvUN8mFq2d pT7AJ3Jg5txvHKkNufESIzfAVpmkZQT/3pCI5dpghBgL5w+2rGt+hdp+6WNd4heZvfe0 96TxzIiotV6HFo44sSkpqwoXB2H84SKzrrPMqJHczbI8gWj1iEJL0kxXbmwommi6pyER OZrg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=K2NaSMSXGbu7bumRRClJ5tfc0MymQ4m4T2u72wQM6Yw=; b=LchsEcZ+IdvIEvaJn/GbEDjC8S4qJMe5PyOsR0obcIrgnrRp/npHy12IkRMz3zBFgg mbUomQFZCiR3o3Sm/6R7az740lK0DXiF3vbo28X7tqfrA3sm4jO01Rj7xoloA/5aIzpV S6tCDeHm8K8qmc0x9tnlGDxQAlZvxbxW0Rww3H2gZrXCyMQ2Jw0eUELsqcknStf0ncME EVV3cD/y3YXT6KtHnYWDxOM8YX3VbB0u0DVT7ciy+lmLMh9NNlMhaUg7T7S62vRaw8OB qNgv34x/OCAVCtHjbKoLgPtjcTI4krBgDr2/GoKdByxXa+RoMxhWcu0EZQSSfE7OKWFz CaMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cjZuzlbH; 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 e20si10157606edr.227.2020.07.13.16.40.07; Mon, 13 Jul 2020 16:40:29 -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=cjZuzlbH; 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 S1726794AbgGMXj4 (ORCPT + 99 others); Mon, 13 Jul 2020 19:39:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:51578 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726339AbgGMXjz (ORCPT ); Mon, 13 Jul 2020 19:39:55 -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 8FD182145D; Mon, 13 Jul 2020 23:39:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594683595; bh=meE7GtQd/R43Bd1jHY5qo5MQzOE71pNp6nUVwgD3B2E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cjZuzlbHOnTnuGHBXazLp16Olqij0hpIbnN39jFDf1MWkOv0r71f0C69tpacKTuDY FXRfnfe9US0IokhOWwEMr1r6QvLXB3aJf6r95Hh/6msSoS3VpdFyxeCtpeYBuxQjLv tDJC0oRIG5bzSuGp35OA3dlH6vovUtgkuJUKi5Ck= From: guoren@kernel.org To: palmerdabbelt@google.com, paul.walmsley@sifive.com, mhiramat@kernel.org, oleg@redhat.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, bjorn.topel@gmail.com, Guo Ren , Palmer Dabbelt Subject: [PATCH v3 2/7] riscv: Fixup compile error BUILD_BUG_ON failed Date: Mon, 13 Jul 2020 23:39:17 +0000 Message-Id: <1594683562-68149-3-git-send-email-guoren@kernel.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1594683562-68149-1-git-send-email-guoren@kernel.org> References: <1594683562-68149-1-git-send-email-guoren@kernel.org> 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 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