From nobody Fri Nov 14 01:00:12 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=wdc.com ARC-Seal: i=1; a=rsa-sha256; t=1583531221; cv=none; d=zohomail.com; s=zohoarc; b=UGZeP0Rxv3zYCMGB3TcB4OGUHM/dk1by8LItiGu8ZCBkeoKLQuq/OS4E+ct0GQYH6dqh4H8gRQ96Nf32weNu5UmnQ6FyuoLgwAPwuX8hhD6lzsjALXvg91lNTaT7Wa/qZOZ4u72xR2PHROX5A/5TgX6QWpTNldS0sT1XXbSPoYA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583531221; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Ag5cVC05Az6hBVESvtBsS004ZE2fHOqEO510FoOmg/8=; b=IiNVoKKqU4sNdyWFevdK+2flEM0KOZnua/9a5RGBjwuHaGMkJa4cP78/znWMUsdNb2/WNkttjtLniwfL9sas3RUqXZ4F7NY79ENhvZgVQ9jDGNxuZmgdHLTqQ/1ogTi55Dt+6qDThnRwl2V4hTihRxT7i8JLuboJQ38Dhfe7EZk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@wdc.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1583531221443778.0838744651987; Fri, 6 Mar 2020 13:47:01 -0800 (PST) Received: from localhost ([::1]:42632 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jAKo8-0003Rw-6a for importer@patchew.org; Fri, 06 Mar 2020 16:47:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35271) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jAKlR-0008WA-Oy for qemu-devel@nongnu.org; Fri, 06 Mar 2020 16:44:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jAKlQ-0002YW-Jf for qemu-devel@nongnu.org; Fri, 06 Mar 2020 16:44:13 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:5222) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jAKlQ-0002Wr-BD; Fri, 06 Mar 2020 16:44:12 -0500 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 07 Mar 2020 05:44:16 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2020 13:35:57 -0800 Received: from risc6-mainframe.sdcorp.global.sandisk.com (HELO risc6-mainframe.int.fusionio.com) ([10.196.158.235]) by uls-op-cesaip02.wdc.com with ESMTP; 06 Mar 2020 13:44:12 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1583531058; x=1615067058; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oUDyZha+UP2T6K4Wg1D/+zB6S5n/oFK58M6oTJnOjPI=; b=Di/ChBGOByJMOKF/Wc2OAHfUD28xGsLnr0HRtEZ2OK1OJJJs5CC5VIXC zWgkc4IX1kdPjEGD7ucd2sV4fpCGkuNvcu5n1L/FFf1vh7neYppCzvIQn MXDXkrXzLR46zKN0j68T6OSG2AupjhwzZiQBDXcppr2FhVqFUHMtNbusl 9W0F5frV6YRAT+CJrqCTvF/0xEAH5zVc2Npcaa6itCmcXYRUx7cioMlJt S5OEUtGnG5VrbE2XKqugryUJZ/yH4s+1R0YaU6NbtFwO+sxSXhxG4PY6Y t3yb8Vodt9DWYQq2glQ1A+SisqIlLs4KLd2anD6l3paiVxy9BKA/1aGUN w==; IronPort-SDR: 75X+OYJkTMlSbyAbOkK4fGalRgO55Qe7hts7huQfz2aSyGg/omWN8yBXSeS+0617Eu3mRBTfjb kGx0V/kQp+o6ltLBrmr7qE2UZ69Jcwk6eiJQ+2yZitbZGoSaXbTdeBC30UzdtFRjLhFrG8/g4w An5wPww1XRRZ4qs2mtgq13Oe6/YYLKkCVYCofxr4uoSBGS/CYfA4WfmlBOdJTn5+1toSgxHy18 W78/kCYubx/eQRhhkOwHZxm/MGzhg5Csxj17saQ8ZgNObWHl0PP/Cxmfyq5HEG5+vTnAFrJn2b tm4= X-IronPort-AV: E=Sophos;i="5.70,523,1574092800"; d="scan'208";a="233784294" IronPort-SDR: eHtLSfL1ruD7D79YqyC+O7apdxR/hcaHf/bpa6vAI2fISuoz1MoZ6zvza2IoXiFSTVZELDILTP V/ZxVRNQL66T03tD26ptv/QeBQ+2FuzvlTvx6PZ0TzX4GyLtmVQoM63KdYc7DGb7X8C9o9nyO3 AEb2TwYU9oVlqZkeIN736XRo6WsMSuUdjQOM7861NOU87NAbC1NBlhoTcLGwxmwBWoXxT/egou 0Aceo2fJywI1i6loIOV0xqFMd9ib6OzaS24iEyXwkCnc5gPmn4YipX344kEza0l6Os6cWstIWK Kp5zl45Zy6qZ+MIVrw1vGMYF IronPort-SDR: Nvy4I/rMYB8hPlDRenNn91bQ0srciovlVXPUOEYD+Lm9DQB6whh8gBc6W6DokYzT2bqS/tV6ds HFZOvlUV48h6wmYohRGkdMAhAzTeON0nW+GSlrEGCFhVYd3mdAYv34Y/Jlj1CDrU/hMFbd/gQr 25Vj/Z5P+tCeda6C/8Si19NCagpMTC7uJwSLeXECEGkwF+0djj8eDu7h7xQXW01sCOr7j74EL+ 19xRg9iIOQJ8d6oxLiCsuPbFYUTog0JuIiumwAf8eoXmwdZHJujZ85edo37pFJhT+FeIVaGAsC bF4= WDCIronportException: Internal From: Alistair Francis To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Subject: [PATCH v3 3/3] riscv/sifive_u: Add a serial property to the sifive_u machine Date: Fri, 6 Mar 2020 13:36:52 -0800 Message-Id: <6132e0b3554868acd16b45eb8ca365cae68a4712.1583530528.git.alistair.francis@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-Received-From: 68.232.143.124 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alistair.francis@wdc.com, palmer@dabbelt.com, alistair23@gmail.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Bin Meng At present the board serial number is hard-coded to 1, and passed to OTP model during initialization. Firmware (FSBL, U-Boot) uses the serial number to generate a unique MAC address for the on-chip ethernet controller. When multiple QEMU 'sifive_u' instances are created and connected to the same subnet, they all have the same MAC address hence it creates a unusable network. A new "serial" property is introduced to specify the board serial number. When not given, the default serial number 1 is used. Signed-off-by: Bin Meng Reviewed-by: Palmer Dabbelt Reviewed-by: Alistair Francis Message-Id: <1573916930-19068-1-git-send-email-bmeng.cn@gmail.com> [ Changed by AF: - Use the SoC's serial property to pass the info to the SoC - Fixup commit title - Rebase on file restructuring ] Signed-off-by: Alistair Francis --- hw/riscv/sifive_u.c | 20 ++++++++++++++++++++ include/hw/riscv/sifive_u.h | 1 + 2 files changed, 21 insertions(+) diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index dc572c761a..44cb72f09e 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -34,6 +34,7 @@ #include "qemu/log.h" #include "qemu/error-report.h" #include "qapi/error.h" +#include "qapi/visitor.h" #include "hw/boards.h" #include "hw/loader.h" #include "hw/sysbus.h" @@ -322,6 +323,8 @@ static void sifive_u_machine_init(MachineState *machine) object_initialize_child(OBJECT(machine), "soc", &s->soc, sizeof(s->soc), TYPE_RISCV_U_SOC, &error_abort, NULL); + object_property_set_uint(OBJECT(&s->soc), s->serial, "serial", + &error_abort); object_property_set_bool(OBJECT(&s->soc), true, "realized", &error_abort); =20 @@ -413,6 +416,18 @@ static void sifive_u_machine_set_start_in_flash(Object= *obj, bool value, Error * s->start_in_flash =3D value; } =20 +static void sifive_u_machine_get_serial(Object *obj, Visitor *v, const cha= r *name, + void *opaque, Error **errp) +{ + visit_type_uint32(v, name, (uint32_t *)opaque, errp); +} + +static void sifive_u_machine_set_serial(Object *obj, Visitor *v, const cha= r *name, + void *opaque, Error **errp) +{ + visit_type_uint32(v, name, (uint32_t *)opaque, errp); +} + static void sifive_u_machine_instance_init(Object *obj) { SiFiveUState *s =3D RISCV_U_MACHINE(obj); @@ -424,6 +439,11 @@ static void sifive_u_machine_instance_init(Object *obj) "Set on to tell QEMU's ROM to jump to = " \ "flash. Otherwise QEMU will jump to DR= AM", NULL); + + s->serial =3D OTP_SERIAL; + object_property_add(obj, "serial", "uint32", sifive_u_machine_get_seri= al, + sifive_u_machine_set_serial, NULL, &s->serial, NUL= L); + object_property_set_description(obj, "serial", "Board serial number", = NULL); } =20 =20 diff --git a/include/hw/riscv/sifive_u.h b/include/hw/riscv/sifive_u.h index a2baa1de5f..16c297ec5f 100644 --- a/include/hw/riscv/sifive_u.h +++ b/include/hw/riscv/sifive_u.h @@ -61,6 +61,7 @@ typedef struct SiFiveUState { int fdt_size; =20 bool start_in_flash; + uint32_t serial; } SiFiveUState; =20 enum { --=20 2.25.1