Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp2771733lqo; Tue, 14 May 2024 08:40:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWx7EJz+rA+uGQwOJo8UMgXe0ADF1792lEg70jU7WdcOOgHcaGKnpkjJkOSkB/51WvKKmgYc8SVY5eaI6o4HLxI+tm3zLYMe2REKYltgg== X-Google-Smtp-Source: AGHT+IHzP4xZNOX1+KQVaJ/Q3C0J0U2m/wghJlue0/N8FgQh/GiOkJEPEfIE4stLCyaWDIEZoWDP X-Received: by 2002:a17:903:28d:b0:1eb:7746:4237 with SMTP id d9443c01a7336-1ef43d127f9mr214147575ad.19.1715701237089; Tue, 14 May 2024 08:40:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715701237; cv=pass; d=google.com; s=arc-20160816; b=vxlxSj1fjyVc6lx6rp7s25cvW6hvP3/dSkY034VzeR/oSl8YbcutwTS+ahIgUseGBa drW85dmEBGkJEYtlqIZXF6bQt7JWUmyUHcz/9nxNdj2nwNWhrlQnBlSDvdrVkgb1zk5Z Yh07u92bImKtNnBKsi9OIYg/EJRo43znsPAHDvtjFWeuGHk0FoQ/wUNtBGI5RaurtQGp B3U6Pmq/EsjD58bwX7Vg88Xmgh5tzn8jAC5RNddRZ4azFPvNyiu7zOGbBPbeUbovbXgO adp3qrJPe12UHyuPM5TOHP9a1ZdxZ9/gR/+YNADBrXYuQNzl2dwlT30gNVXUg5wKcO42 bnzQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=NMCjVuovCRRhsqJzS9OSQQK8JqKttyF9yzBankV6qIQ=; fh=eMZ6m6S53ReXrKVfXlK5h7EebPnm/NxMuVIrfvRiXlI=; b=YZHYl1ZH0VO/ITmL+06KBV9Z4RwWwYA+lq+INWCU/FIHKnF/WpLMt1ym9AI+UA6otK PJbq4LKga/nJmLoRZnGs84dqWM6ZB/yMP3/ZJ7bkRzlQPWbHN5HDxkYOIu9dxB2vrtT1 iuwWdqxQAP/ygUQORYQ88xLQekmpgMqaGW2ptO5ZiH4Q4mxBqHyrQTxsqY/uRSk1Zqin PAljFRSdbZr25Tz2npPQEEY1T4gVNEz0knoK2BAZdYotupXPSy4DSBdMqDqYOFb/JL73 O2XZcjJjDECy4nbcwdkUzN4qXGB34qQLPeQ+TFBxTvUVmefO6HXtoc5gZn4R/DzlfH6t +w6w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=tb859D3h; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-178874-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178874-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1ef0b9d138csi118892155ad.121.2024.05.14.08.40.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 08:40:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-178874-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=tb859D3h; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-178874-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178874-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 2196D283498 for ; Tue, 14 May 2024 15:40:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 353F417F37A; Tue, 14 May 2024 15:39:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="tb859D3h" Received: from mail-qt1-f176.google.com (mail-qt1-f176.google.com [209.85.160.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E042817F36F for ; Tue, 14 May 2024 15:39:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715701174; cv=none; b=gLtid+DI4eQmqVhiQ5N0/WesPJENLTkBO0kuMTyj1I6dY8G2Q8YYjdhg9ZFbJk6i9kd/boXZxcfMa7x6zVB1jgxuXCd7DRHFSJzdaU5WyuTZw7PeM3NAuC2UsWoSHDBhV5sCTD4qPd27pfMSc3t8bTR3Jfm5Hvjw58efb3i5PgI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715701174; c=relaxed/simple; bh=wPQNzP+a91MdWa0iSqIQy+ouXi9GvhZ2QK7RwkKxXjM=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Content-Type; b=RU+OC4rDUwJKQFnJRib7KygKB12p9VEAPVii/ZK/MggbXp5nNWr4fv6xm5f7XbRX7e2nJlZNFdQ/Uzsm9beIj/Oa5PmNNRH5+dU0n6KNwQ4yp9EmKCwxA0sCYf8lmRVZeHioNkxEe93GoN5QpsnjTV5aar1YZUxMqStRw2q5Oeg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=tb859D3h; arc=none smtp.client-ip=209.85.160.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-qt1-f176.google.com with SMTP id d75a77b69052e-43df9ac3ebcso1393411cf.0 for ; Tue, 14 May 2024 08:39:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715701172; x=1716305972; darn=vger.kernel.org; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=NMCjVuovCRRhsqJzS9OSQQK8JqKttyF9yzBankV6qIQ=; b=tb859D3hPAsQabIEeAmjrE0A+xpNNSpjhtnfvoGYoeGhZoXFkEwKRdTWGjRnvbINCV qG90Ocr1bBBNzbJGtF9/nWt699Z7WVcS10PnlNcJVNcNUnse93kieyyoSYjhxy8AzJaI 6yxIffTe/6zTvPi82p5P4TmEhmw2U4/RrNS/0lRBqafuBzwMQ2gKzxgLdDsxhbUmXK5+ EExW5wZl1xss6Iu9bWBpxqLn2IXOpts9Cn2UJJkUzLVBNiUDAIqHs7/y9YNT7/GxFdZu T08nrkiz6mcCwjR1/37M2H82ZLjc7O+K5kp7yeb+UBM9/vl7zvvk1lEtrVSBj2pNjHgH 9ACQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715701172; x=1716305972; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NMCjVuovCRRhsqJzS9OSQQK8JqKttyF9yzBankV6qIQ=; b=imtJbzb9NXMH3FG119sBVa6aJqeZ6fDd5tSE+I50sSDOczNEAhBOi/tur7HMbmKdS0 JGznX8k/aV6FuLOn+PKtH1cPc+GdtkbNOHQhoaXorSVyEfm8yisabmUsNSjwLhxW7KRv lk0kneRsWO9hq8wcx53pBdeZIJSnCuSKyk4EhvV0g+Rd701cU4+9rxYu+RI6yvGXh1EB prydsSAhZZscedhb14BiUJ3PD0VVwlpGhvmCUc80hJrTCDj+CWz2IYI/RBBlX5/Ca99R dHK04Qqjhibvu+pnxT8hpVuIcUZqrqiao+T8s+RrAsR+vLk/05tsQNdYtrN8QVfnlWdF JomQ== X-Forwarded-Encrypted: i=1; AJvYcCWbhCHn3uwVS4GHAolYnD+gHIpyvTPFrSJqmqKcPRN1jRrPJHqTQj89gXwdjKVwPCcQGkUKPaseW9MtHbbrPmO51GVRKPYYiYqI2f/Z X-Gm-Message-State: AOJu0Yx1mOXbg0bus3vs5HHXyKFpENGGBxM9bIGnB9xnlWr/yGb8xMjR ffdApa1cL91vcQh3NMGL8qRONvm6f/ui/5UoaZ/iW76EQ9CI2tRCuNtKFg2SGfwXl4VCEmWcd0m eqFQpsWhR1UR0/iP6mqTnbn5Km1tr0uJjllUD X-Received: by 2002:a05:622a:1e0b:b0:43a:e258:8fed with SMTP id d75a77b69052e-43e095453ffmr7359681cf.18.1715701171651; Tue, 14 May 2024 08:39:31 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240514052402.3031871-1-irogers@google.com> In-Reply-To: <20240514052402.3031871-1-irogers@google.com> From: Ian Rogers Date: Tue, 14 May 2024 08:39:20 -0700 Message-ID: Subject: Re: [PATCH v1] perf arm-spe: Unaligned pointer work around To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Leo Yan , James Clark Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, May 13, 2024 at 10:24=E2=80=AFPM Ian Rogers wr= ote: > > Use get_unaligned_leXX instead of leXX_to_cpu to handle unaligned > pointers. Such pointers occur with libFuzzer testing. > > A similar change for intel-pt was done in: > https://lore.kernel.org/r/20231005190451.175568-6-adrian.hunter@intel.com > > Signed-off-by: Ian Rogers +Leo Yan +James Clark surprisingly missed by get_maintainer.pl. Thanks, Ian > --- > .../arm-spe-decoder/arm-spe-pkt-decoder.c | 23 ++++--------------- > 1 file changed, 5 insertions(+), 18 deletions(-) > > diff --git a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c b/tool= s/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c > index a454c6737563..7bf607d0f6d8 100644 > --- a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c > +++ b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c > @@ -10,24 +10,11 @@ > #include > #include > #include > +#include > +#include > > #include "arm-spe-pkt-decoder.h" > > -#if __BYTE_ORDER__ =3D=3D __ORDER_BIG_ENDIAN__ > -#define le16_to_cpu bswap_16 > -#define le32_to_cpu bswap_32 > -#define le64_to_cpu bswap_64 > -#define memcpy_le64(d, s, n) do { \ > - memcpy((d), (s), (n)); \ > - *(d) =3D le64_to_cpu(*(d)); \ > -} while (0) > -#else > -#define le16_to_cpu > -#define le32_to_cpu > -#define le64_to_cpu > -#define memcpy_le64 memcpy > -#endif > - > static const char * const arm_spe_packet_name[] =3D { > [ARM_SPE_PAD] =3D "PAD", > [ARM_SPE_END] =3D "END", > @@ -70,9 +57,9 @@ static int arm_spe_get_payload(const unsigned char *buf= , size_t len, > > switch (payload_len) { > case 1: packet->payload =3D *(uint8_t *)buf; break; > - case 2: packet->payload =3D le16_to_cpu(*(uint16_t *)buf); break; > - case 4: packet->payload =3D le32_to_cpu(*(uint32_t *)buf); break; > - case 8: packet->payload =3D le64_to_cpu(*(uint64_t *)buf); break; > + case 2: packet->payload =3D get_unaligned_le16(buf); break; > + case 4: packet->payload =3D get_unaligned_le32(buf); break; > + case 8: packet->payload =3D get_unaligned_le64(buf); break; > default: return ARM_SPE_BAD_PACKET; > } > > -- > 2.45.0.rc1.225.g2a3ae87e7f-goog >