Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10678475ybi; Thu, 25 Jul 2019 03:30:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqzhRxDmEegRUocJs35PWBK5MT4Vf9qSSJRCDsI4xVsk+aNAYzK89Hm+G0Vo3Lm3mOYS5yH/ X-Received: by 2002:a62:fb15:: with SMTP id x21mr7861322pfm.233.1564050646276; Thu, 25 Jul 2019 03:30:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564050646; cv=none; d=google.com; s=arc-20160816; b=MiQM2QK/sAtESWCQwlWnYjbyPU4ScNqr+U1lUJ7LakwaPlmEVoAzVOlh/E3TkF6O5R h+iqSJUR03E8BoqyC9IFuwH7KCCRFf/p/R6WEdote+kgA4IjsQ0tGinEXFPBQMHDIjNt S6VAo6vxqknpU4A1+bHI3tvINr0DfKkWvu7sNpX9NNrV6IRlthDQwnftUaSItmziUiVs XvwwNke3vo64izZYGyxN0cjrwcwP8sQp3ONKDLsTHaQ82y3dmlLcAQekLi+cmfoZ7c2i /qT947o6pehgd3aZf9I+CukiaU4E58LxygzhsmmcC/jkddlcZlng+k7PnRNbYP0w1kpm tSDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=GB4nZVYWkx54T499tGW7LQ9xBxxyD8tkNT6QDgPsIdw=; b=tz0ncff8FfSywYuUbV+0piAZ3LUrnC+Hyu49Uc7AJF+0nLfscfDv9/sC9lPph/UJg4 B0QoGYdlvI74BCqgXbkPa2XPh++amXctXlqnd6cmpR+bJSFsOFk1kc/HE/DWow1bqkfZ XltS2P/vVTgLIrBpj0zaswlUWnFa4g0yB++7nBZ2RiGE9dBy+ed9+1hzykyR3Xat7PSe 0CPl8bOk1gQNpl3YruZfTYamMkZy0W6XgedaY89rFGja6e/mEL6zgiH5UkENF6HdfsVi jgVGx/cHCLALJD2jkUN5131de1DEfp1tCwQnz+gY+PN4//KKa4PvuPe++juaB4ck1TGr /XOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=qJwrufS3; 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 59si16446746plc.425.2019.07.25.03.30.26; Thu, 25 Jul 2019 03:30:46 -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=qJwrufS3; 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 S1729590AbfGXWuC (ORCPT + 99 others); Wed, 24 Jul 2019 18:50:02 -0400 Received: from mail-pf1-f202.google.com ([209.85.210.202]:42738 "EHLO mail-pf1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726001AbfGXWuB (ORCPT ); Wed, 24 Jul 2019 18:50:01 -0400 Received: by mail-pf1-f202.google.com with SMTP id 21so29491564pfu.9 for ; Wed, 24 Jul 2019 15:50:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=GB4nZVYWkx54T499tGW7LQ9xBxxyD8tkNT6QDgPsIdw=; b=qJwrufS35GNRyXEA4GiCT7sI3nbMEajGqcx0nM/PxQz7F3h0qKEUCBhoLp4B071vIK 2ylNHen6c05PBxL+ThTJ6jeRLn9ELGca6EDaex1JP+RdJ+zC5gIWwydP5yN44RGO5c9r nULwodbf7xHJkbKr66uawpzSWLNXZwjObpsEtTJROUkT067SD4gfuPHRhIliSPDHeacA a1QeKOk1Yk+xDzPIXEHNvVOz1hxv5qN60VK1YtvlGG+yHyubKG32WB7ESu0yiky/a1Ua EHwuvOIEIIgMwTNCX6FpjdMj1C/n8tcYYp9keT7AmwMeXfuBGzVErEIwE2b//fcNerx7 wYjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=GB4nZVYWkx54T499tGW7LQ9xBxxyD8tkNT6QDgPsIdw=; b=U/K6+GWkg9a71F97Lcd/D3a2oJZ4BbqZ+2tCz+x6iMaLxZdTSJm/XdhrN4lOV1JaUx hKSfcnfg+oWwa+r+44nbgY8mXDkvaF8MiVfJLJa8RJzTar5Dgz5Xmezaa3cNgiliBDQY j61yJOSUABxv+9U9xqDP+DyBtm6VTiU3pa0FzCI/gBuBSOw1FSrr+afZycSs54fl7BTg HfW6KsN5Hy9sNdNQihg9AJVLGhUBpaTx6RA3oLyI3QYm63+3MTquvnODq3+UkcgZ2mbD 5HvJ7rfxbQizx6FVKMvyOVmtLOWE8/dZlSYMNoH/Lsv1G1cTlr0TH58q6MDnyDywRyE4 ueIg== X-Gm-Message-State: APjAAAVEHLAQJJmPSgOr3YOxbfoxGGLcNfE09f0oSRr/U4R8yGorhuiq 4qG/E8MBXkRP6/eCndCMiYOrZKK5 X-Received: by 2002:a63:cb4f:: with SMTP id m15mr7868403pgi.100.1564008600166; Wed, 24 Jul 2019 15:50:00 -0700 (PDT) Date: Wed, 24 Jul 2019 15:49:53 -0700 In-Reply-To: <20190724224954.229540-1-nums@google.com> Message-Id: <20190724224954.229540-2-nums@google.com> Mime-Version: 1.0 References: <20190724224954.229540-1-nums@google.com> X-Mailer: git-send-email 2.22.0.657.g960e92d24f-goog Subject: [RFC][PATCH 1/2] Fix event.c misaligned address error From: Numfor Mbiziwo-Tiapo To: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, alexander.shishkin@linux.intel.com, jolsa@redhat.com, namhyung@kernel.org, songliubraving@fb.com, mbd@fb.com Cc: linux-kernel@vger.kernel.org, irogers@google.com, eranian@google.com, Numfor Mbiziwo-Tiapo 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 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