Page MenuHomeFreeBSD

vmm: Fix wrong assert in ivhd_dev_add_entry
ClosedPublic

Authored by khng on Aug 12 2021, 6:58 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Feb 18, 8:07 AM
Unknown Object (File)
Sat, Feb 1, 3:59 PM
Unknown Object (File)
Sat, Feb 1, 3:16 PM
Unknown Object (File)
Jan 25 2025, 11:00 PM
Unknown Object (File)
Jan 25 2025, 10:54 PM
Unknown Object (File)
Jan 25 2025, 7:37 PM
Unknown Object (File)
Jan 25 2025, 6:36 PM
Unknown Object (File)
Jan 24 2025, 7:04 PM
Subscribers

Details

Summary

The correct condition is to check the number of ivhd entries fit into
the array.

Reported by: bz
Sponsored by: The FreeBSD Foundation

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

khng requested review of this revision.Aug 12 2021, 6:58 AM

I changed the text to this but swapping the < to > makes things boot! Thanks so much for your quick response!

diff --git sys/amd64/vmm/amd/ivrs_drv.c sys/amd64/vmm/amd/ivrs_drv.c
index 68c31788e29d..790b429bd1c8 100644
--- sys/amd64/vmm/amd/ivrs_drv.c
+++ sys/amd64/vmm/amd/ivrs_drv.c
@@ -184,8 +184,9 @@ ivhd_dev_add_entry(struct amdvi_softc *softc, uint32_t start_id,
 {
        struct ivhd_dev_cfg *dev_cfg;
 
-       KASSERT(softc->dev_cfg_cap <= softc->dev_cfg_cnt,
-           ("Impossible case: number of dev_cfg exceeding capacity"));
+       KASSERT(softc->dev_cfg_cap >= softc->dev_cfg_cnt, ("Impossible case: "
+           "dev_cfg exceeding capacity: dev_cfg_cap %d >= dev_cfg_cnt %d",
+           softc->dev_cfg_cap, softc->dev_cfg_cnt));
        if (softc->dev_cfg_cap == softc->dev_cfg_cnt) {
                if (softc->dev_cfg_cap == 0)
                        softc->dev_cfg_cap = 1;
This revision is now accepted and ready to land.Aug 12 2021, 7:49 AM
This revision was automatically updated to reflect the committed changes.