From nobody Thu Apr 25 00:37:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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 ARC-Seal: i=1; a=rsa-sha256; t=1685103121; cv=none; d=zohomail.com; s=zohoarc; b=GRQLT60pqUVIV5kXbj/iMC1BmaQMOJJwiZY4MNJCI+CbhRstAsg4tfznwnRasnDXUuh64fLy8HQ35l2sYKhBSPQY+5xiFIc6Vldg4o/airyqB2kEHHBA7A3nMdOmjUXboMASHDN5pLkc+vrwHxJe+r+i1tmx8eb4p3WpLTZKdBs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685103121; 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=sohObpPsTDyvbd/i6NEgtcjSRxEYuJVX4NYM6c82H20=; b=YSloLzynVEAChCDBe+P64iBrRuRftfVUJ/8Eqgn1lNjRoMb9hAZ5ML9Mv13Jyf5qlxTBAgtC7wPWunrWpbwGFG4VMK7FOYJ4QkF++LARcMLG2/fAOX4GBDJynaciALZ3jClX/dF6O7n/JPQxeksU7BZeoK3i0C0tS5JCQl3Ly44= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685103121852700.2676433054428; Fri, 26 May 2023 05:12:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2WHP-0004rO-0T; Fri, 26 May 2023 08:10:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2WH3-0004oT-DW for qemu-devel@nongnu.org; Fri, 26 May 2023 08:10:27 -0400 Received: from mail-ot1-x333.google.com ([2607:f8b0:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q2WH1-0005Cr-Ah for qemu-devel@nongnu.org; Fri, 26 May 2023 08:10:25 -0400 Received: by mail-ot1-x333.google.com with SMTP id 46e09a7af769-6af89b0f3e5so805677a34.0 for ; Fri, 26 May 2023 05:10:21 -0700 (PDT) Received: from sunil-laptop.dc1.ventanamicro.com ([106.51.186.3]) by smtp.gmail.com with ESMTPSA id g10-20020a9d618a000000b006abb3b660a9sm1611602otk.54.2023.05.26.05.10.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 May 2023 05:10:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1685103021; x=1687695021; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sohObpPsTDyvbd/i6NEgtcjSRxEYuJVX4NYM6c82H20=; b=mpQp8UrxChZiYUryS2UoO5md5/prxMX/+NZhcBvlYFlR3ny0orR2ZtQgMROJswHrLK dWZ9+sm02tAj5l6d4Uf0b3qdSrN3yUKFxiOCSs3JkIK3uYRz9FO9X1B2ZQQ5atEnW6rx YCHGYEf9ci8p0ZQtJhUhOZh3Xlor7uQS88aG5u8rWBgic/xn/BEZA3prLRP18wVOFmb0 UCcF7y1Qo/zbhNSZBKVjYv3NXtP1tOcfMH8M0nynYkNNZl8W81w4RFNL5pG4rFsxBnaR AUJsdSXqGhrrNJVLeh4aJr8+XNdTpPfUsT+n37XVzQnBKWu44qpvWG/P1SB7qeAOUvOV FXSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685103021; x=1687695021; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sohObpPsTDyvbd/i6NEgtcjSRxEYuJVX4NYM6c82H20=; b=PXGSbr4eDGPGAhwc0PILS4kSMCC01sEKZUUbvlgSRZobqXUvu54Z7zhd44En/akvK3 j7pTOQdCkuMT81ZjSlEBYJMKPF4o6FPPhs6YmmRnJtypR6SxDFdpTtRYm3h31j29pFz4 /BHOiCCjYUbKVPJn+Xv2iXndaQEXPbbEaFASmfBsc327GabUuMGhMfXXX727YWeyMEHH AFeBkSf5lrDKmGrdjR8mQf1AQQijlhpJQgR/kBYVhXX2NzAUDWqovYFglfUZh9eWEuIj 3Wr0k6nM9rQNhpUNlK2Zb5JWQYO+ssN1dVBreJW1DHLstpRIqITQvmsn/X6nAsNStZPc 7yyQ== X-Gm-Message-State: AC+VfDwontXPbsXz32gBgNgNiAEnHxHF6kPbzQbhs6/SKsa1Ixf20Ddu rkEr4Q3taUmMVMHAvkRginy6eQ== X-Google-Smtp-Source: ACHHUZ5p33ZqcLML8qWVSGuaVYEudlltc0/qkqEYVLPVmjtxpyJMuRAI6CyxV/1N/VuI1DGaob+ePQ== X-Received: by 2002:a05:6830:1544:b0:6ab:1d86:e4a5 with SMTP id l4-20020a056830154400b006ab1d86e4a5mr570482otp.25.1685103021208; Fri, 26 May 2023 05:10:21 -0700 (PDT) From: Sunil V L To: qemu-riscv@nongnu.org Cc: qemu-devel@nongnu.org, Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Andrea Bolognani , Sunil V L , Heinrich Schuchardt Subject: [PATCH v5 1/3] hw/riscv: virt: Assume M-mode FW in pflash0 only when "-bios none" Date: Fri, 26 May 2023 17:40:04 +0530 Message-Id: <20230526121006.76388-2-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230526121006.76388-1-sunilvl@ventanamicro.com> References: <20230526121006.76388-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=2607:f8b0:4864:20::333; envelope-from=sunilvl@ventanamicro.com; helo=mail-ot1-x333.google.com X-Spam_score_int: -5 X-Spam_score: -0.6 X-Spam_bar: / X-Spam_report: (-0.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SORBS_WEB=1.5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1685103123087100002 Content-Type: text/plain; charset="utf-8" Currently, virt machine supports two pflash instances each with 32MB size. However, the first pflash is always assumed to contain M-mode firmware and reset vector is set to this if enabled. Hence, for S-mode payloads like EDK2, only one pflash instance is available for use. This means both code and NV variables of EDK2 will need to use the same pflash. The OS distros keep the EDK2 FW code as readonly. When non-volatile variables also need to share the same pflash, it is not possible to keep it as readonly since variables need write access. To resolve this issue, the code and NV variables need to be separated. But in that case we need an extra flash. Hence, modify the convention such that pflash0 will contain the M-mode FW only when "-bios none" option is used. Otherwise, pflash0 will contain the S-mode payload FW. This enables both pflash instances available for EDK2 use. Example usage: 1) pflash0 containing M-mode FW qemu-system-riscv64 -bios none -pflash -machine virt or qemu-system-riscv64 -bios none \ -drive file=3D,if=3Dpflash,format=3Draw,unit=3D0 -machine virt 2) pflash0 containing S-mode payload like EDK2 qemu-system-riscv64 -pflash -pflash -machine = virt or qemu-system-riscv64 -bios \ -pflash \ -pflash \ -machine virt or qemu-system-riscv64 -bios \ -drive file=3D,if=3Dpflash,format=3Draw,unit=3D0,readonly=3D= on \ -drive file=3D,if=3Dpflash,format=3Draw,unit=3D1 \ -machine virt Signed-off-by: Sunil V L Reported-by: Heinrich Schuchardt Tested-by: Andrea Bolognani Reviewed-by: Alistair Francis --- hw/riscv/virt.c | 51 ++++++++++++++++++------------------------------- 1 file changed, 19 insertions(+), 32 deletions(-) diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index 4e3efbee16..1187a60d6e 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -1245,7 +1245,7 @@ static void virt_machine_done(Notifier *notifier, voi= d *data) target_ulong firmware_end_addr, kernel_start_addr; const char *firmware_name =3D riscv_default_firmware_name(&s->soc[0]); uint32_t fdt_load_addr; - uint64_t kernel_entry; + uint64_t kernel_entry =3D 0; =20 /* * Only direct boot kernel is currently supported for KVM VM, @@ -1266,42 +1266,29 @@ static void virt_machine_done(Notifier *notifier, v= oid *data) firmware_end_addr =3D riscv_find_and_load_firmware(machine, firmware_n= ame, start_addr, NULL); =20 - if (drive_get(IF_PFLASH, 0, 1)) { - /* - * S-mode FW like EDK2 will be kept in second plash (unit 1). - * When both kernel, initrd and pflash options are provided in the - * command line, the kernel and initrd will be copied to the fw_cfg - * table and opensbi will jump to the flash address which is the - * entry point of S-mode FW. It is the job of the S-mode FW to load - * the kernel and initrd using fw_cfg table. - * - * If only pflash is given but not -kernel, then it is the job of - * of the S-mode firmware to locate and load the kernel. - * In either case, the next_addr for opensbi will be the flash add= ress. - */ - riscv_setup_firmware_boot(machine); - kernel_entry =3D virt_memmap[VIRT_FLASH].base + - virt_memmap[VIRT_FLASH].size / 2; - } else if (machine->kernel_filename) { + if (drive_get(IF_PFLASH, 0, 0)) { + if (machine->firmware && !strcmp(machine->firmware, "none")) { + /* + * Pflash was supplied but bios is none, let's overwrite the + * address we jump to after reset to the base of the flash. + */ + start_addr =3D virt_memmap[VIRT_FLASH].base; + } else { + /* + * Pflash was supplied but bios is not none. In this case, + * base of the flash would contain S-mode payload. + */ + riscv_setup_firmware_boot(machine); + kernel_entry =3D virt_memmap[VIRT_FLASH].base; + } + } + + if (machine->kernel_filename && !kernel_entry) { kernel_start_addr =3D riscv_calc_kernel_start_addr(&s->soc[0], firmware_end_addr= ); =20 kernel_entry =3D riscv_load_kernel(machine, &s->soc[0], kernel_start_addr, true, NULL); - } else { - /* - * If dynamic firmware is used, it doesn't know where is the next m= ode - * if kernel argument is not set. - */ - kernel_entry =3D 0; - } - - if (drive_get(IF_PFLASH, 0, 0)) { - /* - * Pflash was supplied, let's overwrite the address we jump to aft= er - * reset to the base of the flash. - */ - start_addr =3D virt_memmap[VIRT_FLASH].base; } =20 fdt_load_addr =3D riscv_compute_fdt_addr(memmap[VIRT_DRAM].base, --=20 2.34.1 From nobody Thu Apr 25 00:37:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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 ARC-Seal: i=1; a=rsa-sha256; t=1685103121; cv=none; d=zohomail.com; s=zohoarc; b=Vh6yScM7yeVJXhP2xtyVkS+jQ5aaazrC7kYN4n9SxTaZOVBjo7RGuhLbz0pH0u7J5z7nKh/rTVxl699Urg2HXCJJBqpRBfm4pJCfYSOAR6YRUDZuX+1pyAqDUV9IukLqFR+kkDIXrI7d673LpYpbBVkvOSWBI8/+3MI3BEJcinE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685103121; 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=oIbZJJsOcm3S8IEVd1te65HPg1fVUwZXpCiyeQi07lA=; b=LRIXmjDqAf+6qBfznWYlS0ggFfknSxmIbZP6NAhT9ezLUT+G4IM5X/X2c4JxWW1qTjVHgGakPsCkflnE0+GI5y+MIKP2bugd2TwrfrpDDZfnkRmZs5pkZ0AcGo9YO9/Qw9xE5pfI9Lx98qEkcit/cSzlhFaC3xEI0de569ifSCs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685103121817209.5761172586731; Fri, 26 May 2023 05:12:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2WHP-0004rQ-Bz; Fri, 26 May 2023 08:10:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2WHB-0004oj-VW for qemu-devel@nongnu.org; Fri, 26 May 2023 08:10:34 -0400 Received: from mail-oa1-x34.google.com ([2001:4860:4864:20::34]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q2WH7-0005Hl-7l for qemu-devel@nongnu.org; Fri, 26 May 2023 08:10:33 -0400 Received: by mail-oa1-x34.google.com with SMTP id 586e51a60fabf-19f22575d89so23314fac.0 for ; Fri, 26 May 2023 05:10:26 -0700 (PDT) Received: from sunil-laptop.dc1.ventanamicro.com ([106.51.186.3]) by smtp.gmail.com with ESMTPSA id g10-20020a9d618a000000b006abb3b660a9sm1611602otk.54.2023.05.26.05.10.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 May 2023 05:10:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1685103025; x=1687695025; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oIbZJJsOcm3S8IEVd1te65HPg1fVUwZXpCiyeQi07lA=; b=mQkYLwqxmn/+up7zWPEW78xfkz7JUifMhUmMmQDJsU+5bpfL8htIQOlfJXkdLE2sCE 6KYP+MJPs5Wb94/Eup5qNld43/xgmVQGkNFq4EPaBEgLSLeyEhfYjKVDcdPYADuWHacK S57de4IoQtRJTfm3JMyRIz9R1cMIqFM6kCWeFvXQDTxsEyhaCIV/BU0VfOTzsIqUzJjv CHZXgvb3p++pjuh+tkws+loxJFgEe0pJD2VMKYRUI4ZFz++UkRl/4fmF48+Bx228H3u1 kYVNMc1Opo8e1Hi+Igm6sdqrKgCteCW9bcoSUi9SFQho+7hr3cfZfGCbAY0P9OpCkfdh GiOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685103025; x=1687695025; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oIbZJJsOcm3S8IEVd1te65HPg1fVUwZXpCiyeQi07lA=; b=UacoXAB6KOYBd/lr71u3V97Mj5YjP4YGGP04VbtgyFFv+XYleAEZCkgxfHH44SDPJs kPtZeVmP53bVdietf5nU+VMNrsAGbVolXJa+KEgXy6cjm+t5S38ChksO775r8vZYeRR4 V6VRaeLKHxP0isYX1F6Umb7PmAV6i9Q2piG0orgSPl/wrUjUFhDAcTuIhjzGANr4NL0X zBrEHouA58qQm85D7AC6rj27VIxwaYl/pWE4obAoizq4H80RolJ/+s8SUzzmEIpt0RHO V7qptErEv+kN6eu5Dd06R+P+v2HOxLHebOnKmpk27wUI1sIXxxPDpLcJYIROFQTZWVDX wrEA== X-Gm-Message-State: AC+VfDxR8ubJrrorQYI831nSZ4oOnHuP3rVHuBRHPqpzJSZRpScvk7Ix UArcTl1Io85JWQfCZr4UptDKQg== X-Google-Smtp-Source: ACHHUZ5D5YNR4vtXDWgJU5o4l0xKuwWuAPxtr5i9kRX76op/nc8XOe0mw8FCWwekvKWCoSx9NdfJ1Q== X-Received: by 2002:a05:6870:1728:b0:192:8632:aca9 with SMTP id h40-20020a056870172800b001928632aca9mr817720oae.23.1685103025499; Fri, 26 May 2023 05:10:25 -0700 (PDT) From: Sunil V L To: qemu-riscv@nongnu.org Cc: qemu-devel@nongnu.org, Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Andrea Bolognani , Sunil V L Subject: [PATCH v5 2/3] riscv/virt: Support using pflash via -blockdev option Date: Fri, 26 May 2023 17:40:05 +0530 Message-Id: <20230526121006.76388-3-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230526121006.76388-1-sunilvl@ventanamicro.com> References: <20230526121006.76388-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=2001:4860:4864:20::34; envelope-from=sunilvl@ventanamicro.com; helo=mail-oa1-x34.google.com X-Spam_score_int: -5 X-Spam_score: -0.6 X-Spam_bar: / X-Spam_report: (-0.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SORBS_WEB=1.5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1685103123076100001 Content-Type: text/plain; charset="utf-8" Currently, pflash devices can be configured only via -pflash or -drive options. This is the legacy way and the better way is to use -blockdev as in other architectures. libvirt also has moved to use -blockdev method. To support -blockdev option, pflash devices need to be created in instance_init itself. So, update the code to move the virt_flash_create() to instance_init. Also, use standard interfaces to detect whether pflash0 is configured or not. Signed-off-by: Sunil V L Reported-by: Andrea Bolognani Tested-by: Andrea Bolognani Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/riscv/virt.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index 1187a60d6e..b450248a21 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -1246,6 +1246,7 @@ static void virt_machine_done(Notifier *notifier, voi= d *data) const char *firmware_name =3D riscv_default_firmware_name(&s->soc[0]); uint32_t fdt_load_addr; uint64_t kernel_entry =3D 0; + BlockBackend *pflash_blk0; =20 /* * Only direct boot kernel is currently supported for KVM VM, @@ -1265,8 +1266,8 @@ static void virt_machine_done(Notifier *notifier, voi= d *data) =20 firmware_end_addr =3D riscv_find_and_load_firmware(machine, firmware_n= ame, start_addr, NULL); - - if (drive_get(IF_PFLASH, 0, 0)) { + pflash_blk0 =3D pflash_cfi01_get_blk(s->flash[0]); + if (pflash_blk0) { if (machine->firmware && !strcmp(machine->firmware, "none")) { /* * Pflash was supplied but bios is none, let's overwrite the @@ -1497,8 +1498,6 @@ static void virt_machine_init(MachineState *machine) sysbus_create_simple("goldfish_rtc", memmap[VIRT_RTC].base, qdev_get_gpio_in(DEVICE(mmio_irqchip), RTC_IRQ)); =20 - virt_flash_create(s); - for (i =3D 0; i < ARRAY_SIZE(s->flash); i++) { /* Map legacy -drive if=3Dpflash to machine properties */ pflash_cfi01_legacy_drive(s->flash[i], @@ -1525,6 +1524,8 @@ static void virt_machine_instance_init(Object *obj) { RISCVVirtState *s =3D RISCV_VIRT_MACHINE(obj); =20 + virt_flash_create(s); + s->oem_id =3D g_strndup(ACPI_BUILD_APPNAME6, 6); s->oem_table_id =3D g_strndup(ACPI_BUILD_APPNAME8, 8); s->acpi =3D ON_OFF_AUTO_AUTO; --=20 2.34.1 From nobody Thu Apr 25 00:37:21 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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 ARC-Seal: i=1; a=rsa-sha256; t=1685103121; cv=none; d=zohomail.com; s=zohoarc; b=P99frzuc90GsUHaqmk8pX1CTX9Xv8zuwW7GtLdLs1kgbIO2HnF8KiQEOrOOqnrlofLWYiy0PrpBsjlssjFKr7P35PA+/iJny9pDhEm3zgCbyLeboYIFaKk2PfOYHgpEj3iE1WEFldy+JBw0inr7orrEMJNNzEQBEYiIyYiG0eyo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685103121; 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=0SMtqwocGY/rL4SvD4PKQMdaIYi1C6Pm17aeP+9/5u4=; b=GAQ3gkDVjGQZOPOreDMDm67TXAGe8Vh7f5zyk+xNstV5gq3OkuqPm+j65w5Mxn2ttUHayDpoPG564k3VoNfgeNgFaIMMKMReK1GUfmIPWYJ8HyvTgVt8FOaOI8GDGQj00E4LtvfTwJq0dKzoZ+gTLrT7SJtG5fddT6dpM4gmrbQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 168510312184690.80177345356606; Fri, 26 May 2023 05:12:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2WHQ-0004sv-Pq; Fri, 26 May 2023 08:10:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2WHF-0004pX-Tp for qemu-devel@nongnu.org; Fri, 26 May 2023 08:10:40 -0400 Received: from mail-oa1-x36.google.com ([2001:4860:4864:20::36]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q2WHA-0005Kx-8x for qemu-devel@nongnu.org; Fri, 26 May 2023 08:10:35 -0400 Received: by mail-oa1-x36.google.com with SMTP id 586e51a60fabf-19f22575d89so23361fac.0 for ; Fri, 26 May 2023 05:10:30 -0700 (PDT) Received: from sunil-laptop.dc1.ventanamicro.com ([106.51.186.3]) by smtp.gmail.com with ESMTPSA id g10-20020a9d618a000000b006abb3b660a9sm1611602otk.54.2023.05.26.05.10.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 May 2023 05:10:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1685103029; x=1687695029; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0SMtqwocGY/rL4SvD4PKQMdaIYi1C6Pm17aeP+9/5u4=; b=kJI/zhw4NUdxMHIej6vzNVEPf7gRRvyFg5H7JxTMiK11j9iaJjxW07pQvwa4XT42cF cJyCmWeoMlBzekmRpZgG5z2aWNzZXkipSltwwb69cm2utZLiv4SmM+d7+boKCy15xWha RvYJBOhKfQBuZ96RemwDRRVe68cxqCMizaF3u9gDi727ycDklNQoasfIwTcWBlenEagY z6YIMi09pTPxdx/wdQ+Du/BeieO5FTtaiLSXc48vDSygwUXuDSdagBDG9NfLOFoUGGeG NCprqWwj8SNBJscbE0Mts+687y9dSifZrpiGe5321yJJHfs8tB6kq1DoAw++mtxVAuRi wF4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685103029; x=1687695029; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0SMtqwocGY/rL4SvD4PKQMdaIYi1C6Pm17aeP+9/5u4=; b=LJl5O7qWye4TWSNfNPNtEi/Xk+xbjBNoeq1pEclSWg1cMnW8sUYB3qdCIvj+KXHA6S ovsfX86tImgILll8MZk6oSa/z+9rKGRMJ63HMFRbcKD6QVG93DPrybBtkR/5A/vLc4Lf vZc2AzMDrRhS7hdvJeCr8/Y9bQ6HoiN8erajlznTFsWW5UGNv2JIz+q3GV25Ot95mo5m 5Uu/dQHc2PQLDt+Y/TiF2g1zRWVV15eT5evoKZs2FqtihIn2BcmmzwtWK65uZRCzhELk 0GhjE8WR6LtgyrdQKZXCqxiWHXEhRDEFO70zZaSN3o8ggBRrpJy4ceyP5PIurnWH6lDP moZA== X-Gm-Message-State: AC+VfDx941Jv5KXBg0d/DEDoUrS96ZfJiKubwAJo75j+GjWcBZi9QaVZ LdOaMk00Bc0bP5o0BiJbxyluDw== X-Google-Smtp-Source: ACHHUZ7cpCdW7aitKNZrqYZkeGvRAytiuaGmC5jOv6o3OxV0mZ2UzCqSLER136w/q58uVqINqnUa4w== X-Received: by 2002:a05:6808:45:b0:398:1eae:f773 with SMTP id v5-20020a056808004500b003981eaef773mr736904oic.41.1685103029702; Fri, 26 May 2023 05:10:29 -0700 (PDT) From: Sunil V L To: qemu-riscv@nongnu.org Cc: qemu-devel@nongnu.org, Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Andrea Bolognani , Sunil V L Subject: [PATCH v5 3/3] docs/system: riscv: Add pflash usage details Date: Fri, 26 May 2023 17:40:06 +0530 Message-Id: <20230526121006.76388-4-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230526121006.76388-1-sunilvl@ventanamicro.com> References: <20230526121006.76388-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=2001:4860:4864:20::36; envelope-from=sunilvl@ventanamicro.com; helo=mail-oa1-x36.google.com X-Spam_score_int: -5 X-Spam_score: -0.6 X-Spam_bar: / X-Spam_report: (-0.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SORBS_WEB=1.5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1685103123130100006 Content-Type: text/plain; charset="utf-8" pflash devices can be used in virt machine for different purposes like for ROM code or S-mode FW payload. Add a section in the documentation on how to use pflash devices for different purposes. Signed-off-by: Sunil V L Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Andrea Bolognani --- docs/system/riscv/virt.rst | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/docs/system/riscv/virt.rst b/docs/system/riscv/virt.rst index 4b16e41d7f..3e873c67f3 100644 --- a/docs/system/riscv/virt.rst +++ b/docs/system/riscv/virt.rst @@ -53,6 +53,35 @@ with the default OpenSBI firmware image as the -bios. It= also supports the recommended RISC-V bootflow: U-Boot SPL (M-mode) loads OpenSBI fw_dyna= mic firmware and U-Boot proper (S-mode), using the standard -bios functionalit= y. =20 +Using flash devices +------------------- + +The first flash device (pflash0) can contain either ROM code +or S-mode payload firmware code. If the pflash0 contains the +ROM code, -bios should be set to none. If -bios is not set to +none, pflash0 is assumed to contain S-mode payload code. + +Firmware images used for pflash should be of size 32 MiB. + +To boot as ROM code: + +.. code-block:: bash + + $ qemu-system-riscv64 -bios none \ + -blockdev node-name=3Dpflash0,driver=3Dfile,read-only=3Don,filename= =3D \ + -M virt,pflash0=3Dpflash0 \ + ... other args .... + +To boot as read-only S-mode payload: + +.. code-block:: bash + + $ qemu-system-riscv64 \ + -blockdev node-name=3Dpflash0,driver=3Dfile,read-only=3Don,filename= =3D \ + -blockdev node-name=3Dpflash1,driver=3Dfile,filename=3D \ + -M virt,pflash0=3Dpflash0,pflash1=3Dpflash1 \ + ... other args .... + Machine-specific options ------------------------ =20 --=20 2.34.1