From nobody Tue May 21 08:19: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=1662352412; cv=none; d=zohomail.com; s=zohoarc; b=ZE94/3LhvrP4TYbIsdI2D2vjOL3R3LVF1Asq7f0eEab82MA6eMfGNruvAy3JUBmYnFHzLoUsHS5rPbUX/dBsu/HwaSxK2wDm48tE5GmdtXC7HvW1EMImg0Y7GohPKYFOwZp3UuXtfB5ZHOfveZDP9hc8gsRULqrEtl7Fa4fzRjo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662352412; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=JEqOjE7qgfPHaAK0g036/FP/i4rSlui0iDxhlSDYI4Y=; b=Y8+wp/jhq1HDAI4GqTCMFduFLHqb1BehBsS+upaSiLLRnsX7L6IDKGWHGTLhJjdGEbhTWQH+12Hmc+dHpyNY0twwa5cpPwWnKlxQKe1DTXl0vS0dVBtxkfn6+V5xfQli8SH7AAZN9qYUn0FCobvQ24Kt1AxG+F4F2r+hNUI9Mw4= 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 1662352412922664.9024728404995; Sun, 4 Sep 2022 21:33:32 -0700 (PDT) Received: from localhost ([::1]:50256 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oV3nf-0004OZ-E2 for importer@patchew.org; Mon, 05 Sep 2022 00:33:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47008) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oV3kA-0003Oq-PN for qemu-devel@nongnu.org; Mon, 05 Sep 2022 00:29:55 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]:45648) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oV3k6-0004NL-PD for qemu-devel@nongnu.org; Mon, 05 Sep 2022 00:29:53 -0400 Received: by mail-pf1-x430.google.com with SMTP id z187so7498921pfb.12 for ; Sun, 04 Sep 2022 21:29:49 -0700 (PDT) Received: from localhost.localdomain ([49.206.11.92]) by smtp.gmail.com with ESMTPSA id a20-20020aa795b4000000b0053812f35a41sm6526113pfk.194.2022.09.04.21.29.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 21:29:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=JEqOjE7qgfPHaAK0g036/FP/i4rSlui0iDxhlSDYI4Y=; b=H4C2A2NE8s7LXsa2Ku/O9E8Z3Cs/qk7bs7cif2qNhRm9JXRvtZ/rzY1dRbHTJTWLCL c5PKoyyCWYnHdo4IdEnUXYRrscju+vK2Whm6noZ/m1Fl93W8bLEjIS8h3m25AGsvL3wp BsTjDzb715RpJvv8LkQwYF03vhvs3xWp9LPRxKkbzRrfoM22AdbyW53t3Rj8FPGOjsFU ZVhfSNM8czywd7W8TJfdrWkiOjy9AwCuh3fcTelVgfluQbg8G3mtnkKys+6sLOk73k2x 0emXGa5UhNGrWlf0AXA82xnfnE8C4OILEyxHzPvF8MIk4gXQL08/o1bipFlttqIdgDHS H3Jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=JEqOjE7qgfPHaAK0g036/FP/i4rSlui0iDxhlSDYI4Y=; b=NKIS+9E3xceaCLFa1hfPsnxorB7ziqRDETzpc5DJoJvKqa85tN4lQpzOyIic5Ko1l6 b1dRRnoCRzwg0lyGjWV+QxVaNY5pGDog3c4XnKXBSc+Z3GeVbuJdlHTdwWTj76zcMwzg p4XclGG6SwiS+NuKc+f0i0xNuk37E5AJTfGQRsntZYSosWRGiVyE/MXPVzkZjY0C8nZz K80v6wY94DST1glQX7oUKAyY5OkDyrE8GlaxoM4+a7Dm+MBJg7mccJWivmPyDBZgPwGc LI2828catuDGbc4eVpMda75UtHe9YgoOhfkJybvhEvyP51kYxoIzanzQ2/TuykVaQM2w jHjw== X-Gm-Message-State: ACgBeo34eTDcf/T8OXb26MWGlXOctZk486AmbocgNy6PmTfkl0EGB9ps yyFHBObL5RfB7tJ8+GJwB9sbWU+ncqw+Kw== X-Google-Smtp-Source: AA6agR5xIFvtRd0tnQjOPqbtKxZQWtaokSfzznmhMDUnRwy3NiEHtibWLUvbcIcVi7pxNbX9apEHbw== X-Received: by 2002:a05:6a00:1501:b0:52e:67e9:56d7 with SMTP id q1-20020a056a00150100b0052e67e956d7mr48288348pfu.48.1662352187904; Sun, 04 Sep 2022 21:29:47 -0700 (PDT) From: Sunil V L To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Cc: Palmer Dabbelt , Alistair Francis , Bin Meng , Anup Patel , Atish Kumar Patra , Sunil V L Subject: [PATCH] hw/riscv: virt: Enable booting S-mode firmware from pflash Date: Mon, 5 Sep 2022 09:59:40 +0530 Message-Id: <20220905042940.146913-1-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.25.1 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::430; envelope-from=sunilvl@ventanamicro.com; helo=mail-pf1-x430.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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" X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1662352414291100001 Content-Type: text/plain; charset="utf-8" To boot S-mode firmware payload like EDK2 from persistent flash storage, qemu needs to pass the flash address as the next_addr in fw_dynamic_info to the opensbi. Update the kernel_entry with the flash address when no kernel is specified via QEMU command line so that opensbi can jump to the flash address. This assumes flash drive unit 1 is used to keep dynamic payload similar to other architectures. Signed-off-by: Sunil V L --- hw/riscv/virt.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index ff8c0df5cd..1ee855fded 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -1284,6 +1284,18 @@ static void virt_machine_done(Notifier *notifier, vo= id *data) start_addr =3D virt_memmap[VIRT_FLASH].base; } =20 + if (drive_get(IF_PFLASH, 0, 1)) { + /* + * Assume second pflash unit (unit=3D1) to hold the S-mode firmware + * like EDK2. Set kernel_entry to flash address if kernel argument + * is not set and pflash unit 1 is configured. + */ + if (!kernel_entry) { + kernel_entry =3D virt_memmap[VIRT_FLASH].base + + virt_memmap[VIRT_FLASH].size / 2; + } + } + /* * Init fw_cfg. Must be done before riscv_load_fdt, otherwise the dev= ice * tree cannot be altered and we get FDT_ERR_NOSPACE. --=20 2.25.1