Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp632280ybe; Wed, 11 Sep 2019 02:13:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqyMVQgQ8QsV8LGDfdt9oPtnxzYqEy3Kr5E95qLXEarelR392HO3j3rnTXe1H4XOiHeew4Vu X-Received: by 2002:a17:906:7494:: with SMTP id e20mr29021697ejl.166.1568193200896; Wed, 11 Sep 2019 02:13:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568193200; cv=none; d=google.com; s=arc-20160816; b=pW74ciXxzOlPANJJWbEKB3na5OYL0+Scw9FzC/iY+lD9UQP5sfGXdFU9JTK4n77qT3 8RY+isT1FYHgU68SxIFIVnHpG9DHWIajrg6xAuNknDdV6mpwccKomXFJ55nKmAh3oLAa La7qFMqNXfD1wO3FAPH+vNqI4U0Q2WJvM7bsXhkbJ96hf9S5LdPiiveXvk+RenoLiN/e Ut5m+5KDntPHNDek/LpCA88DKt9xPlX+YFqwiql0Ail408Z05ZSfw771Nn6J2KaeJU2W M0avrT6OADjQrE5r1AESeK/xRB4+ztytSziTjSPxfgkMVbiFj9y6j9kfLgCk6P3qHpYo 3qsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=fVXJdEiyG3g7I0Ee9AcvktkAQsh4s+Etlf6fhn1BiQk=; b=fyzVyfAhjUxgIhvugKhtK+eB01c2YhgpLs+UcmEqiXBZavbR3qM2oaV1n8e2Y4/W4Z 5eofTDyv9rFvixV4Mf8n8SOhxfjGRIjZzGtQqW8m0ZXu1FaWUwX5HcBtiEZ+43LuQwyR CaHUS1qcEu2rkW+a0ymG7XO4DNQJ01QKfC75jIaYQAkoomran6dPUG5L6UhjhKrmq1fl POAHaPJD6W+KhsuZ39jb/ELIXO6P5rcU6NPZyyX0G6G2GEiMo6BCgLnqKJ9+ZAQBGqft TZL7HFA8jU3KA5xF/bOGuT6/NMyvBzH1eAM4s7zs0p5VI/9h0bEIuhiM4eRNJIDeRETJ 8AoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=SloJf08G; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h4si12206162edd.189.2019.09.11.02.12.57; Wed, 11 Sep 2019 02:13:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=SloJf08G; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727329AbfIKJIs (ORCPT + 99 others); Wed, 11 Sep 2019 05:08:48 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:37280 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726765AbfIKJIr (ORCPT ); Wed, 11 Sep 2019 05:08:47 -0400 Received: by mail-wm1-f67.google.com with SMTP id r195so2563248wme.2 for ; Wed, 11 Sep 2019 02:08:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=fVXJdEiyG3g7I0Ee9AcvktkAQsh4s+Etlf6fhn1BiQk=; b=SloJf08GFdByA5YtqiSMgVWUoDfKLosEALLv1z+JHxPfMHmzqQEPufdARHBVpooccQ PKa46XI6UoUWJ0FlKtMQMmqrGAi3Ahdh7o9BvXGcV3cAyUT6cjldNAt5XNWaSJ/V3zaN WsYE2nbdiPV18nUGV7BdAUREhqyvAbdiNJKGKcMr9vpGVX4RM89zF/7kSYnFpKil8o6g xUh73eh/yqXmbe7W/PCTK5wNZTTUMq5ygAIVemM23Odt5cTRXw2E2TKBq1V5dtQP462D 9pWAQZQdm+7c2dOGYvb96qJpTkDthZTfJV5MnQ01O6TducJB4vSY63I9obEi7PMlvwxv ZQVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=fVXJdEiyG3g7I0Ee9AcvktkAQsh4s+Etlf6fhn1BiQk=; b=sWiCLSziuxY0SNLUy3mY8lfD6vlTRoFLTU4XsSQBxRO0LUoSjsjQRYc1SOio/kxcz2 4c0cO7K1JIakhSgaLtZUBOBvMDaw1p2K//Py+x5PjjInqJQh1TZswWGNc8QyjKjZMa8n JRm56VRCgNdSY+WFTSxl3VE5jNXFZpFgitCUnr9wKlX2kNVTtxOsAk+VJmCIhwEJQRY0 UFCjImRPuBtE55fgtNzYJKcPhdNhL7l4aEzl9u1cqRQTBRModox7VF4ZpxGILkqXf9mr IuzVjupXHt1j5pWpbYrcMjlcvSc7ONEDCWymhXZsvbkFVe+OazajOvCuTcEf6puvJBLk Lgfw== X-Gm-Message-State: APjAAAW1E5FiUjyogvZvi3ik1XCjpP5Y/N3z67jOAqN2b3bxub+XvcT4 C8atIVjaM2YT4GLVpyNJODlniEFChLCLZ3OMokp7wQ== X-Received: by 2002:a1c:c90e:: with SMTP id f14mr2849955wmb.54.1568192924093; Wed, 11 Sep 2019 02:08:44 -0700 (PDT) MIME-Version: 1.0 References: <20190724224954.229540-1-nums@google.com> <20190724224954.229540-2-nums@google.com> In-Reply-To: <20190724224954.229540-2-nums@google.com> From: Ian Rogers Date: Wed, 11 Sep 2019 02:08:32 -0700 Message-ID: Subject: Re: [RFC][PATCH 1/2] Fix event.c misaligned address error To: Numfor Mbiziwo-Tiapo Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Song Liu , mbd@fb.com, LKML , Stephane Eranian Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org An idea here is that, if this breaks backward compatibility, we introduce an aligned variant and work to deprecate the unaligned variant. I will look into making a patch set. Thanks, Ian On Wed, Jul 24, 2019 at 3:50 PM Numfor Mbiziwo-Tiapo wrote: > > The ubsan (undefined behavior sanitizer) build of perf throws an > error when the synthesize "Synthesize cpu map" function from > perf test is run. > > This can be reproduced by running (from the tip directory): > make -C tools/perf USE_CLANG=1 EXTRA_CFLAGS="-fsanitize=undefined" > > (see cover letter for why perf may not build) > > then running: tools/perf/perf test 44 -v > > This bug occurs because the cpu_map_data__synthesize function in > event.c calls synthesize_mask, casting the 'data' variable > (of type cpu_map_data*) to a cpu_map_mask*. Since struct > cpu_map_data is 2 byte aligned and struct cpu_map_mask is 8 byte > aligned this causes memory alignment issues. > > This is fixed by adding 6 bytes of padding to the struct cpu_map_data, > however, this will break compatibility between perf data files - a file > written by an old perf wouldn't work with a perf with this patch due > to event data alignment changing. > > Comments? > > Not-Quite-Signed-off-by: Numfor Mbiziwo-Tiapo > --- > tools/perf/util/event.h | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h > index eb95f3384958..82eaf06c2604 100644 > --- a/tools/perf/util/event.h > +++ b/tools/perf/util/event.h > @@ -433,6 +433,7 @@ struct cpu_map_mask { > > struct cpu_map_data { > u16 type; > + u8 pad[6]; > char data[]; > }; > > -- > 2.22.0.657.g960e92d24f-goog >