From 5b549d16679bc064a1f258a22cffec336e216d54 Mon Sep 17 00:00:00 2001 From: Niklas Eiling Date: Mon, 23 Oct 2023 16:51:34 +0200 Subject: [PATCH] fix readHostBar throwing errors when BAR is correct Signed-off-by: Niklas Eiling --- common/lib/kernel/pci.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/common/lib/kernel/pci.cpp b/common/lib/kernel/pci.cpp index 19a532864..f76e51938 100644 --- a/common/lib/kernel/pci.cpp +++ b/common/lib/kernel/pci.cpp @@ -367,11 +367,12 @@ uint32_t Device::readHostBar(unsigned barNum) const { if (std::sscanf(line.c_str(), "%llx %llx %llx", &start, &end, &flags) != 3) throw SystemError("Failed to parse BAR line"); - if (end > start) + if (end <= start) { throw SystemError("Invalid BAR: start={}, end={}", start, end); + } log->debug("Host BAR: start={:#x}, end={:#x}, size={:#x}, flags={:#x}", start, - end, end - start, flags); + end, end - start + 1, flags); return start; }