Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2146523ybt; Sun, 28 Jun 2020 09:28:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyXM/ngINKAIyx0hoM48z4Vo5XCoa8/iHCaS1yJlbUz9u51KaKWJvPfC09Dc08opyzy3VcX X-Received: by 2002:a17:906:824c:: with SMTP id f12mr10465634ejx.443.1593361680629; Sun, 28 Jun 2020 09:28:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593361680; cv=none; d=google.com; s=arc-20160816; b=PngwTodChcs6/XyX0pfJOotfpK5yXGvA3UqYGgqNsBI2idCGtkk1TDERA7z5xNLjgY IFzpdXf8t/roEeJ45a/sj2CeQKZX3KanmnIZAKRevYvVyrCwMhm31lVi+qFYFmBMUfgi e7BVvr+ReyqiJfzfmIxwTeRoVkj6C713gDLDadohKJLaNLOluRZ8dZDmNeKoc+CauSJN lcwMQXjeDa6XqNTiulYJ/tWc9cG3665q1W5zapPYQz/QgdsIoyUQa0xj4gVKbp/NRZSz k6j4OCLrJZ+j4LLaUV+JDopgBDYcgqMwDJfP9m/ZLSNSuDGe3WDej2+FCixrX33UJDIs Ljww== 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:subject:cc:to:from:date :dkim-signature; bh=UJQJdQLtPZRdjJC2yg2HBjmYhculxa0Wy4TBo5d7UMc=; b=lIMRLQsrc30sL50CXi+RaGmzrv4LFEfGwtXIzGdEtIOexPBscXKKByiUixYv0khESF xjDlyT39rdmHiaApjQ1X4Ch2yhUoLyRs6RUkjNo39K3ZFzqdKIvxKcFGd30788mI2T2n YNAbRdEEZnRW+Cm63chIVXyVASBhHEcikSUHG/s9kwt1mZTpd30iWOIQSTCvt5RbbQZA c7L6JgRDZKrbWlFXkTTTwEmy82nGBv3YGtey0mZqPaTr5wBLJ6BXIUCSzS64vcGwu6ht 8ACrI1oPtF+tt1elnH4/s5gT4xYXVUNtAtIygw6ubGlVGDMdVK0goBB6ydRoF+HZ+aON gZbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Y3OerUbS; 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 cw13si4641639edb.135.2020.06.28.09.27.37; Sun, 28 Jun 2020 09:28:00 -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=Y3OerUbS; 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 S1726539AbgF1QZa (ORCPT + 99 others); Sun, 28 Jun 2020 12:25:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:38968 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726104AbgF1QZ3 (ORCPT ); Sun, 28 Jun 2020 12:25:29 -0400 Received: from devnote2 (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BA64420771; Sun, 28 Jun 2020 16:25:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593361529; bh=4MsHQYCfwDNcgoFMDxuBklP42iO6H/Lxo4tZHOVpT+g=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Y3OerUbSLeNsgby2H3gQ4ClZuu9Zc3iA1DveyUjBNkbUmzJjyjMVL6Vb326AxTmc+ d1F44707pI8ZM34pAusrVj+gcJP9Yco0Ubr0359g2vTm8O/xdQkr6AzJo1+9hh6/GA b87a/tUXaPeXFae/mUxAQbck2dPswuPgYMtjP/74= Date: Mon, 29 Jun 2020 01:25:24 +0900 From: Masami Hiramatsu To: guoren@kernel.org Cc: greentime.hu@sifive.com, 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: Re: [PATCH V2] riscv: Fixup compile error BUILD_BUG_ON failed Message-Id: <20200629012524.c941a5f18aa7f312d325f714@kernel.org> In-Reply-To: <1593360457-23827-1-git-send-email-guoren@kernel.org> References: <1593360457-23827-1-git-send-email-guoren@kernel.org> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) 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 On Sun, 28 Jun 2020 16:07:37 +0000 guoren@kernel.org wrote: > 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". Looks good to me :) Reviewed-by: Masami Hiramatsu Thanks! > > 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 > -- Masami Hiramatsu