git: 839b6e33089b - stable/13 - bhyve nvme: Fix Active Firmware Info

From: Corvin Köhne <corvink_at_FreeBSD.org>
Date: Mon, 14 Nov 2022 08:25:58 UTC
The branch stable/13 has been updated by corvink:

URL: https://cgit.FreeBSD.org/src/commit/?id=839b6e33089bee5873cf3fcd402260aa4d405f49

commit 839b6e33089bee5873cf3fcd402260aa4d405f49
Author:     WanpengQian <wanpengqian@gmail.com>
AuthorDate: 2022-08-14 15:28:05 +0000
Commit:     Corvin Köhne <corvink@FreeBSD.org>
CommitDate: 2022-11-14 08:23:03 +0000

    bhyve nvme: Fix Active Firmware Info
    
    Summary:
    Currently Active Firmware Info is not initialized.
    
    Fix is to initialize the Active Firmware Info to Slot 1.
    
    Test Plan: Within FreeBSD/Linux guests, show the Firmware Logpage to confirm.
    
    Reviewed By:    chuck
    MFC after:      2 weeks
    Differential Revision: https://reviews.freebsd.org/D32658
    
    (cherry picked from commit 3cae10048d27f805d7fc909b123ddee34be0268e)
---
 usr.sbin/bhyve/pci_nvme.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/usr.sbin/bhyve/pci_nvme.c b/usr.sbin/bhyve/pci_nvme.c
index 98410b92039c..15d6ae777cc6 100644
--- a/usr.sbin/bhyve/pci_nvme.c
+++ b/usr.sbin/bhyve/pci_nvme.c
@@ -695,6 +695,11 @@ pci_nvme_init_logpages(struct pci_nvme_softc *sc)
 	sc->health_log.temperature = NVME_TEMPERATURE;
 	sc->health_log.available_spare = 100;
 	sc->health_log.available_spare_threshold = 10;
+
+	/* Set Active Firmware Info to slot 1 */
+	sc->fw_log.afi = (1 << NVME_FIRMWARE_PAGE_AFI_SLOT_SHIFT);
+	memcpy(&sc->fw_log.revision[0], sc->ctrldata.fr,
+	    sizeof(sc->fw_log.revision[0]));
 }
 
 static void