Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf arm-spe: Unaligned pointer work around

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 <irogers@google.com>
Reviewed-by: James Clark <james.clark@arm.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20240514052402.3031871-1-irogers@google.com

authored by

Ian Rogers and committed by
Namhyung Kim
cbd446b4 678be1ca

+5 -18
+5 -18
tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c
··· 10 10 #include <byteswap.h> 11 11 #include <linux/bitops.h> 12 12 #include <stdarg.h> 13 + #include <linux/kernel.h> 14 + #include <asm-generic/unaligned.h> 13 15 14 16 #include "arm-spe-pkt-decoder.h" 15 - 16 - #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ 17 - #define le16_to_cpu bswap_16 18 - #define le32_to_cpu bswap_32 19 - #define le64_to_cpu bswap_64 20 - #define memcpy_le64(d, s, n) do { \ 21 - memcpy((d), (s), (n)); \ 22 - *(d) = le64_to_cpu(*(d)); \ 23 - } while (0) 24 - #else 25 - #define le16_to_cpu 26 - #define le32_to_cpu 27 - #define le64_to_cpu 28 - #define memcpy_le64 memcpy 29 - #endif 30 17 31 18 static const char * const arm_spe_packet_name[] = { 32 19 [ARM_SPE_PAD] = "PAD", ··· 57 70 58 71 switch (payload_len) { 59 72 case 1: packet->payload = *(uint8_t *)buf; break; 60 - case 2: packet->payload = le16_to_cpu(*(uint16_t *)buf); break; 61 - case 4: packet->payload = le32_to_cpu(*(uint32_t *)buf); break; 62 - case 8: packet->payload = le64_to_cpu(*(uint64_t *)buf); break; 73 + case 2: packet->payload = get_unaligned_le16(buf); break; 74 + case 4: packet->payload = get_unaligned_le32(buf); break; 75 + case 8: packet->payload = get_unaligned_le64(buf); break; 63 76 default: return ARM_SPE_BAD_PACKET; 64 77 } 65 78