Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3063023rdh; Mon, 27 Nov 2023 05:54:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IEMhOVXwjaejfCiH6x92yMg0ytNj8leJc281XK4SMG7bg/5zrJNDBwH6TulvU6RDQbKh3iV X-Received: by 2002:a05:6e02:1e04:b0:35c:8410:84ee with SMTP id g4-20020a056e021e0400b0035c841084eemr7895409ila.24.1701093283034; Mon, 27 Nov 2023 05:54:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701093283; cv=none; d=google.com; s=arc-20160816; b=cKpYFSPe0sGCrPEkdKJ5CmXcxIklZNjWxx0XI4E7+QYKTDkjkypZJazDu31oMAB/1C 0QI62zMvq119cPJE3yePf4Ty+GOFXtzs5u9eSbfXpUmkikbSN98UwYqmAMRwPIA1ONHW 0BXsBAmD7ICIZgrsPI/DuhfQVbWQicaxY0U5SPt72h4jGvZZOl87kWmQQFs6sC/+NrF2 RQqUoGduk37VmNEgRMcFa9WuAMO1o7T3DlAP7Y9DY8xXew+mqNO1Rpev2uWBG3ieAFVQ E+WgdgV0Bv/xDIFlWeYOhHx742bGyH5aZSmDsebRjXEmwaRVrhzhNFyorOlNKLPetO4i lM4A== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=OESyYZVxbmArs5V4zMGrIL0/uPgjACK9BAVI1aKMbU0=; fh=SIgps5XdV0XNwjZfT2uAI7g3mrspDldK9Qs8qQAfoa4=; b=umHH1zdlv6simvMW1SeaVnT0NYlxNpawWdolOgZQR5CYPH2N4jTwXdQ4UjNkq3kU2p ZRsxwMd4wpFa0gCeir5rTcrwLhDUT77YnV7UcO3slKayfihRx2NnsGX27BOqUlpc1fDO D7qsB2Ol80ElM5suKj+Om5/AT9slSUMBUG5DF5MGT7k0ykY9MhEt76sn/h18CbuODOMI alr7RVqc5HjGjLb60cOKTv/akoUcvJEctiGOXbdUwTppbHOZe8cpAq7KVNkIH6LOBi5k iUhuioKPDW+OIamXwzUwJy5Edr37V5+wVxgshCAhtR2p+VjSqa6PUtdcVxjVjNFdEaLr oiGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GYUOOnwv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id s20-20020a656914000000b005b935872b48si9626337pgq.537.2023.11.27.05.54.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 05:54:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GYUOOnwv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id E8ECE8094D5E; Mon, 27 Nov 2023 05:54:35 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233392AbjK0NyG (ORCPT + 99 others); Mon, 27 Nov 2023 08:54:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233300AbjK0Nx5 (ORCPT ); Mon, 27 Nov 2023 08:53:57 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5063F136 for ; Mon, 27 Nov 2023 05:54:03 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1D003C433CA; Mon, 27 Nov 2023 13:53:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701093242; bh=BJTb9S/48BMXgKg9JdebJFjIf4uCQaHDkO4DGbu+/d0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GYUOOnwvQwsNlxSNuewCevm+q5XiHdJpOfdaSmMN+SXiZXPA0yXdYnswPHthV9OJ4 JWBFYOgT8yMoFGbfKTKWNFudYzy/VhLwKXMNYuJOs2xiqW2i0GHesk4ftCGA42hC+s sGcLQk4JU8qlQcd5e7qtQlNs3N4pxxBRldmtfsJnCtJipJS04rFhshaGrH9uCSMvol subLIaiFHSNXNaFX9EnViMCbyRJ81TfNSB2wgpxqA4X5lQC2bUe8z6DCxj6/ixLGNc ukeLgFfVWLMw8KXT/voig76MqTg3d+3Z/jaLvW0Wu/VwtvF+hMIVB2M/TuDhKFPyWf jrOWe0WQcF8bw== From: "Masami Hiramatsu (Google)" To: Alexei Starovoitov , Steven Rostedt , Florent Revest Cc: linux-trace-kernel@vger.kernel.org, LKML , Martin KaFai Lau , bpf , Sven Schnelle , Alexei Starovoitov , Jiri Olsa , Arnaldo Carvalho de Melo , Daniel Borkmann , Alan Maguire , Mark Rutland , Peter Zijlstra , Thomas Gleixner , Guo Ren Subject: [PATCH v3 05/33] fgraph: Use BUILD_BUG_ON() to make sure we have structures divisible by long Date: Mon, 27 Nov 2023 22:53:56 +0900 Message-Id: <170109323585.343914.8827157689000519661.stgit@devnote2> X-Mailer: git-send-email 2.34.1 In-Reply-To: <170109317214.343914.4784420430328654397.stgit@devnote2> References: <170109317214.343914.4784420430328654397.stgit@devnote2> User-Agent: StGit/0.19 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 27 Nov 2023 05:54:36 -0800 (PST) From: Steven Rostedt (VMware) Instead of using "ALIGN()", use BUILD_BUG_ON() as the structures should always be divisible by sizeof(long). Link: http://lkml.kernel.org/r/20190524111144.GI2589@hirez.programming.kicks-ass.net Suggested-by: Peter Zijlstra Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Masami Hiramatsu (Google) --- kernel/trace/fgraph.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c index 30edeb6d4aa9..837daf929d2a 100644 --- a/kernel/trace/fgraph.c +++ b/kernel/trace/fgraph.c @@ -26,10 +26,9 @@ #endif #define FGRAPH_RET_SIZE sizeof(struct ftrace_ret_stack) -#define FGRAPH_RET_INDEX (ALIGN(FGRAPH_RET_SIZE, sizeof(long)) / sizeof(long)) +#define FGRAPH_RET_INDEX (FGRAPH_RET_SIZE / sizeof(long)) #define SHADOW_STACK_SIZE (PAGE_SIZE) -#define SHADOW_STACK_INDEX \ - (ALIGN(SHADOW_STACK_SIZE, sizeof(long)) / sizeof(long)) +#define SHADOW_STACK_INDEX (SHADOW_STACK_SIZE / sizeof(long)) /* Leave on a buffer at the end */ #define SHADOW_STACK_MAX_INDEX (SHADOW_STACK_INDEX - FGRAPH_RET_INDEX) @@ -91,6 +90,8 @@ ftrace_push_return_trace(unsigned long ret, unsigned long func, if (!current->ret_stack) return -EBUSY; + BUILD_BUG_ON(SHADOW_STACK_SIZE % sizeof(long)); + /* * We must make sure the ret_stack is tested before we read * anything else. @@ -325,6 +326,8 @@ ftrace_graph_get_ret_stack(struct task_struct *task, int idx) { int index = task->curr_ret_stack; + BUILD_BUG_ON(FGRAPH_RET_SIZE % sizeof(long)); + index -= FGRAPH_RET_INDEX * (idx + 1); if (index < 0) return NULL;