Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4060541rdb; Thu, 14 Sep 2023 10:29:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHipuRiFQUorlXhoanu4tunanjYx1XzsnwV3CwCg0vVa+nikn61zNN2fewnyfJaxjxpy2ni X-Received: by 2002:a17:90b:4b4f:b0:274:6a79:17c1 with SMTP id mi15-20020a17090b4b4f00b002746a7917c1mr2499918pjb.15.1694712583170; Thu, 14 Sep 2023 10:29:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694712583; cv=none; d=google.com; s=arc-20160816; b=hNEiAp/DJWGUpf8+/GNI6mvicwBlMIpRLMPFA3hkB5H8Jc4Z/A0sSGtSLgxkx7nb9v oNx3lwYO+nF+lXL2x/dVXUjgY6ilzQZXxOd5bivhuxblao5uUs73FGzv4z4G81ExM9s3 RYvNKhVdzfjDI65HudQmDvVHN3TwJCdIiXeaYtp2CXFhfOz9pFFWgDknHWP164BOiU4m AGA/fj130wlLrn8j/YC3DBqOzrU35HS/IFqWnFjqoFGuMlj41MFSRTa623w9Na44GQ2Z dY9GTmyFnFAJYash9EHAC+pWyrIFs0rDhtwi227qfJ4Sb/LZawYiKMBlvh7EOvHzWzDm d1CQ== 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 :references:in-reply-to:message-id:subject:cc:to:from:date; bh=/D6pViBa38waQZ5w1dZ35FII4noctuESyjcVuPMxnsU=; fh=YyVXi/xTzNsktJCX8n+bNXIvJTNrwtFLOFeQ9mxoAuY=; b=hhqgT0DhZ+acLJP2AK9n3K+VGDRGZKlAfJhTlpQ704FPgLtbf/6a4qE5Y2gVQZZpZ6 b7pSx6B7ycYZwByr4OaFW+WnXnHXQt2r8oOLubLP69zqQXNEFwtPm7HD+uw8NfGK99fb wElkxh+s1o5a4HOoB+8PYgqrnjSyd2b5oN4im1o9HDwLuQEVmTCKn5pnXvJbUExY24hF X7CIursMszZS7zloo4Y/p28GmCJbzkS3aWfR1QMTNbBPF9686mKXiIn3HkrOEaJ5zQfQ 9sZs4i9SKDgofVqsz4SfKXuiyXEkqNEu5icY8t7xVy7OZW1N7P5/8t0/N6xD71cJ5kVw oIWA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id w20-20020a17090aea1400b0026b2fdb4f82si1965961pjy.29.2023.09.14.10.29.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 10:29:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 2C3C382B64C8; Thu, 14 Sep 2023 10:29:40 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237398AbjINR3k (ORCPT + 99 others); Thu, 14 Sep 2023 13:29:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235055AbjINR3j (ORCPT ); Thu, 14 Sep 2023 13:29:39 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7D161FF0; Thu, 14 Sep 2023 10:29:35 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BCF80C433C7; Thu, 14 Sep 2023 17:29:34 +0000 (UTC) Date: Thu, 14 Sep 2023 13:29:56 -0400 From: Steven Rostedt To: =?UTF-8?B?Q2zDqW1lbnQgTMOpZ2Vy?= Cc: Masami Hiramatsu , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, Beau Belgrave Subject: Re: [PATCH] tracing/user_events: align uaddr on unsigned long alignment Message-ID: <20230914132956.569dad45@gandalf.local.home> In-Reply-To: <20230914131700.0ba3ee80@gandalf.local.home> References: <20230914131102.179100-1-cleger@rivosinc.com> <20230914131700.0ba3ee80@gandalf.local.home> X-Mailer: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 (agentk.vger.email [0.0.0.0]); Thu, 14 Sep 2023 10:29:40 -0700 (PDT) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email On Thu, 14 Sep 2023 13:17:00 -0400 Steven Rostedt wrote: > Now lets look at big endian layout: > > uaddr = 0xbeef0004 > enabler = 1; > > memory at 0xbeef0000: 00 00 00 00 00 00 00 02 > ^ > addr: 0xbeef0004 > > (enabler is set ) > > bitoffset = uaddr & (sizeof(unsigned long) - 1); bitoffset = 4 > bit_offset *= 8; bitoffset = 32 > uaddr &= ~(sizeof(unsigned long) - 1); uaddr = 0xbeef0000 > > ptr = kaddr + (uaddr & ~PAGE_MASK); > > clear_bit(1 + 32, ptr); > > memory at 0xbeef0000: 00 00 00 00 00 00 00 02 > ^ > bit 33 of 0xbeef0000 > > I don't think that's what you expected! I believe the above can be fixed with: bit_offset = uaddr & (sizeof(unsigned long) - 1); if (bit_offset) { #ifdef CONFIG_CPU_BIG_ENDIAN bit_offest = 0; #else bit_offset *= BITS_PER_BYTE; #endif uaddr &= ~(sizeof(unsigned long) - 1); } -- Steve