Received: by 2002:ab2:7a09:0:b0:1f8:46dc:890e with SMTP id k9csp95921lqo; Wed, 15 May 2024 08:38:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX4P1ShD0V0yp79AMVvjoIvOaGFy2XXQINWvTR8xab1X4VuIaLk3a9+Y8ggnnV2n0sd88JtXpJ4hcIau3OseJZDc4CNdoe+sTSOSEKFMw== X-Google-Smtp-Source: AGHT+IEkX/Kb0QX4aN9MUn3DOAhCjgJ/9lvtc3JwEurMhpPiUYDm04zgccUXdRXMPKqucetvvq5U X-Received: by 2002:a05:6102:32cb:b0:47c:abf:385 with SMTP id ada2fe7eead31-48077db3e21mr17731023137.4.1715787518739; Wed, 15 May 2024 08:38:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715787518; cv=pass; d=google.com; s=arc-20160816; b=Ce5Rfp7wvMqY/Xerorp3RTIiqaHsN/PJxPhHBA8/52HDoQgz5zlY1YpiEEGnIoExIj bU0sy+6EEJJFlMNxLfSW2GEm75QXHHRnTe7zFGp3yqPtRfraITOu6HbaZMMykLgR2Jp1 ONY73B6dBEKkA51pDMynCBcyrQDXIek5fumLmolh/67tQtORPqVK26CmmfhqhApXFsJk L5uCHcFebZEWjv8/nWCRSagKhonRavHyVj6zC0WuNJdax92mZf7YanCWI/P/sewaLdAt xUN9N5XZxWKWBhQhqHcVfnxFk3OeBO3keM/Y6hkRMwWGki0r3DQATgn8Rnaqm4QHBd/l xVlA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:cc:content-language :references:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=ZsYHlHaUskJz26ZNOq4uzgHKA+LtNVSGskB0bHWzxXI=; fh=dckI+2wnqak7AxlNfUmueVXgTGWN60N6lY9n65nrXrw=; b=chN+8D0ddtTgX6Pjr/EiK4MVROFy7J+p9YAF9kHf1pUcnKe8rn+9X5st/P2X7jGIFy xdYKuuAJFkfmv5u5YhN0q+Gh0ursVDeTPQPOzJWqb/QEhiNsVp11gRUuwfSnBPSHmPiA O3JJ8vm2/QlZaYOkZZW4kEzDB3wG0zln++YpO6/6HaIX5iqOgRGI8vr2zMnG9QFkPVIk Ks3q1xgL+ig9wbBGAB8tS8u30cMBiwgCo9ih50o8LHonOH1pnKtCB48oqsDyZxcyYZO3 unceT6hAnk3BJpPw4HzUnfzrvGAFhv06UtnScPeLqRMw1KTrXHMxn7w9hA1e297G7/c5 crAg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-180080-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-180080-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id ada2fe7eead31-4806cc94a66si2241460137.674.2024.05.15.08.38.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 08:38:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-180080-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-180080-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-180080-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 48B291C21427 for ; Wed, 15 May 2024 15:38:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 935B0156226; Wed, 15 May 2024 15:38:31 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3C907155749; Wed, 15 May 2024 15:38:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715787511; cv=none; b=QtPLwbaEJUN9OYLOrCYfWvcX9vTNsz1u1MHvQTgEiJ4dCb2lW/HdzX0HTHC4rN7J5fpUYN/KWQWcfenNk7XXZkGKGjcVnVdwyHQPc73vm7wgyhld4rORM3UHR8bbxX0sl0yxtJGIWk56NsD9ksg/knX2SWMjiFi9MQxx/LPo9aE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715787511; c=relaxed/simple; bh=LEUHsrTdwa6alzDTTaOO55XhQjMYEv4S83zzoa18X5c=; h=Message-ID:Date:MIME-Version:Subject:To:References:Cc:From: In-Reply-To:Content-Type; b=mg02pdkGhgdR26+VxCtx9DKNk2n0SReO+Fw0S30HIK5p9FOaS6v/dux9ZjaDx9HfYTi2Ei4nGtjV2WwW6VURI8a4rURCgdsQugP6w4+fScA/dHzQK1z5Ppj77tO03ZMBTmjqpDOa3nyou2XPG5sdwvz+FVR5fBZiwlzJx63ttdo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1438B1042; Wed, 15 May 2024 08:38:53 -0700 (PDT) Received: from [10.57.35.76] (unknown [10.57.35.76]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 232AB3F7A6; Wed, 15 May 2024 08:38:25 -0700 (PDT) Message-ID: <89e6a60e-5dfc-431a-aeb5-d4f1e9fdc4b0@arm.com> Date: Wed, 15 May 2024 17:38:28 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1] perf arm-spe: Unaligned pointer work around To: Ian Rogers References: <20240514052402.3031871-1-irogers@google.com> Content-Language: en-US Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org From: James Clark In-Reply-To: <20240514052402.3031871-1-irogers@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 14/05/2024 07:24, Ian Rogers wrote: > 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 > --- Reviewed-by: James Clark > .../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/tools/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__ == __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) = 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[] = { > [ARM_SPE_PAD] = "PAD", > [ARM_SPE_END] = "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 = *(uint8_t *)buf; break; > - case 2: packet->payload = le16_to_cpu(*(uint16_t *)buf); break; > - case 4: packet->payload = le32_to_cpu(*(uint32_t *)buf); break; > - case 8: packet->payload = le64_to_cpu(*(uint64_t *)buf); break; > + case 2: packet->payload = get_unaligned_le16(buf); break; > + case 4: packet->payload = get_unaligned_le32(buf); break; > + case 8: packet->payload = get_unaligned_le64(buf); break; > default: return ARM_SPE_BAD_PACKET; > } >