Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2804955ybt; Fri, 3 Jul 2020 20:37:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+U1QIOx0eIA8dOMVQ4ZM7n6tvqP2sfgZwR1JZbpVQwjtgpJQ1Zjt7qxrh8qE3a1kO5ZI9 X-Received: by 2002:a17:906:4145:: with SMTP id l5mr34377158ejk.334.1593833861149; Fri, 03 Jul 2020 20:37:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593833861; cv=none; d=google.com; s=arc-20160816; b=QvmO1Ru8Ns3yOxhLzbwnRxuwRPLE5B0im02+4Mn8Cy5uqU/LPgD2angJLYmUegO3Vv LtYSOIiZ4/U+71zlcfbUydaX12ZBFlJJYslH/tdWZwrvX52EGI5nal69o9aDNE8TtHYP /Ci/2sqjqOcecceWvuWH73m7GFUK68VU2jydxtYzQnixU7JINne6D5P8LhT1Bh5ipqEx ehNQmQfZfIMvV/wU0fd1oX7xwizDKSu/5sXregW1hOE/08vqA9H8nSoccW5w7Blg4YNl xf7aSl81kKGSQS4yPUJyyXIRa5+OMZW9YOEIUZ8TZIZpRX5AwGJm0T2VqeEArJ72uYs8 UCdA== 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=x4kkRT6J8+YeL/uQX402DQOTnF4AOxdj3Yq82igO5u4=; b=yE+ZoJLW76eRbVt0915/UvteAe6xXAeETgSINp8wHV6Ijs/HcMdR+9tGu0pTNx2I6O 7rO+STVkVZFoq3lLBqXOwLDs4mU8dHvC/TOE/rw0K7EiDrTtkEJThpb59wLUc93v7l07 EzKPSFrAckJaFXRuB4Cx2J2IKk7QlZV/Ml2AKQmWZ8zNfm/jtFfFv2+/Al7kcai3JRy8 5iwiGW5tt/q9AoEZhtSGazTnyv9h+T1MqUhNN6BIL5BzYXS1QCvWwG0ShA7LqgtNDdGO z4s4s8n3ZFjTVeTs4Sqc6h+pkrQeTVSNpva4eS+nGKEZ4wNdBW2gxv0KqnLnsomwDAId HH5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ekniUIMB; 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 h18si8669928ejd.91.2020.07.03.20.37.18; Fri, 03 Jul 2020 20:37:41 -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=ekniUIMB; 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 S1727098AbgGDDe4 (ORCPT + 99 others); Fri, 3 Jul 2020 23:34:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:48404 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726501AbgGDDez (ORCPT ); Fri, 3 Jul 2020 23:34:55 -0400 Received: from localhost.localdomain (89.208.247.74.16clouds.com [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 6401D20899; Sat, 4 Jul 2020 03:34:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593833694; bh=DwnW4KHO8DYEljlqVPhBYinwJJ3evXr/9FwF+yD4CN8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ekniUIMB/mW40lSgqx4piqYh4sT4fOnQFgYmOx1uFIxDzFsxtt8CEWi8yoUo8sqls 0GdPVbA8Bcm2F7y4YbicLcWGl/PjwiX4PexX+R1OyGGQo0SO3A9XK11Fs6iolmCb5r QyyppUSWMTR3hpKbXiYkmP2GVAjiynauB4km0lIQ= From: guoren@kernel.org To: palmerdabbelt@google.com, paul.walmsley@sifive.com, anup@brainfault.org, greentime.hu@sifive.com, zong.li@sifive.com, me@packi.ch, bjorn.topel@gmail.com, atish.patra@wdc.com Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, guoren@kernel.org, Guo Ren Subject: [PATCH V1 3/5] riscv: Fixup compile error BUILD_BUG_ON failed Date: Sat, 4 Jul 2020 03:34:17 +0000 Message-Id: <1593833659-26224-4-git-send-email-guoren@kernel.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1593833659-26224-1-git-send-email-guoren@kernel.org> References: <1593833659-26224-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 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