lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 16 Sep 2011 16:35:34 +0200
From:	Stephane Eranian <eranian@...gle.com>
To:	Peter Zijlstra <peterz@...radead.org>
Cc:	David Ahern <dsahern@...il.com>, linux-kernel@...r.kernel.org,
	acme@...hat.com, mingo@...e.hu
Subject: Re: [PATCH] perf: make perf.data more self-descriptive (v4)

On Mon, Sep 12, 2011 at 4:43 PM, Peter Zijlstra <peterz@...radead.org> wrote:
> On Mon, 2011-09-12 at 16:40 +0200, Stephane Eranian wrote:
>> I don't think this should be the test to detect endianess.
>
> You should be able to tell the endianness from the PERF_MAGIC string, it
> stores the string as a u64, so depending on endianness it reads back as
> either: PERFFILE or ELIFFREP or whatever the bswap64 result is.
>

I believe in big endian, if you do od -c perf.data | head -1, you also see:

0000000   P   E   R   F   F   I   L   E   h  \0  \0  \0  \0  \0  \0  \0

static const char *__perf_magic = "PERFFILE";
#define PERF_MAGIC      (*(u64 *)__perf_magic)

u64 hm = PERF_MAGIC;

The layout in memory is the same for both little-endian and
big-endian. Thus the layout on the file is the same.

When you look at the memory as u64, then things are different:
In little-endian, hm=0x454c494646524550
in big-endian,   hm=0x5045524646494c45

In big-endian, the MSB 0x50 ('P') ends up at the lowest memory address.
In little-endian, the LSB 0x50 ('P') ends up at the lowest memory address.

Thus, I suspect we need to write in the file a different MAGIC for big vs.
little endian.

David, can you confirm this?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ