On Fri, Dec 6, 2019 at 5:35 PM Philippe Mathieu-Daudé <address@hidden
On 12/6/19 3:27 PM, Peter Maydell wrote:
> On Mon, 2 Dec 2019 at 21:10, Niek Linnenbank <address@hidden> wrote:
>> The Security Identifier device in Allwinner H3 System on Chip
>> gives applications a per-board unique identifier. This commit
>> adds support for the Allwinner H3 Security Identifier using
>> randomized data as input.
> If this is a fixed value in hardware, I'm not sure that
> having the QEMU model pick a random value is the best
> choice. If we just set it to a fixed value in QEMU, is
> that going to cause problems?
> (Generally it's nice for QEMU to be deterministic, so it
> behaves the same way every time you run it. Also if it's
> always the same we don't need to bother migrating the
> ID value.)
Agreed. Since the identifier is 128-bit, I'd use DEFINE_PROP_UUID() or,
to be even safer, DEFINE_PROP_UUID_NODEFAULT().
See how the ipmi-bmc-sim device checks its guid field and fails if unset.
Thank you both for clarifying this. OK, I'll update this patch such that the identifier is fixed,
using the functions Philippe suggested.
The reason I originally chose to make it randomized is that U-Boot mainline reads out the
SID data in order to create a MAC address for the ethernet device. So when a user runs multiple
QEMU machines inside a virtualized network, they will get the same MACs if the SID isnt unique.
However this problem can also be solved very easy with U-Boot itself by just overriding the ethaddr environment variable.
For your interest, in the U-Boot source you can see this behaviour in the file
arch/arm/mach-sunxi/cpu_info.c:139 in sunxi_get_sid(), sun8i_efuse_read() where it reads the SID
and in board/sunxi/board.c:782 in setup_environment() where it uses the SID to create the MAC address.