From patchwork Tue Jan 3 16:48:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 638723 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1352257pvb; Tue, 3 Jan 2023 08:49:27 -0800 (PST) X-Google-Smtp-Source: AMrXdXvZL7Ggr7RDC4prbwc7ERPeBj+hiE74UTXp+Dmzxfy+h21MAVlcvWu776Yoh/9p0vDSdZwn X-Received: by 2002:ac8:7948:0:b0:3a6:8f0d:53a6 with SMTP id r8-20020ac87948000000b003a68f0d53a6mr70279850qtt.40.1672764567363; Tue, 03 Jan 2023 08:49:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672764567; cv=none; d=google.com; s=arc-20160816; b=gy24W43OJMwe3qPX/Rpv46pHFI6Yot1smht8WFrCxdGzi0PXFeug7GjAtcTnifp0/d 1Mi6nA43Dj1DUJtYEwnwVZI3KjQ3m5qLvicoCPQvYKV4G/cxYV0c38C7QcaB0apeDiBp NkFBXk7v0tLsIuFH4qIQOlCc2X3Drf9Jj3Gsbo6dzZzrjMqVk9QqbmvYPd8QnVvHzQim ZsZ5Xqpw2+pP0flxSmmYDm3+/y6GsZpzvPq3FcyWE+eSYBa3Kt3r9UZ+/fg6iScVhsVm a/nsv/IFBznRvBFFUTbSn1MTiDVYGPXcJv9CQiLoDRqSG3NoFLC+paPt7pLXig+FoVOl y/FQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=1+/2U4c2jz7FuN+HYbjdpm7LXcWK38fV7wkmohQlrig=; b=Zq3e92IjzqL2JUqZdhDNph1BlqO2KzS1Ti9D8c8zIkBlbX9Bh80jFvXUoao0DNxSeC AZlibwdbphKMHhusxOyNn/6zgxgjwac4cgbpz8S47R/wLSLW9+7dhHY+FJMnrkklkyA/ FS1iO4L4p0c0kGmUsnvJv5nGRhri8LJN/CDxGA2HtGOPwWVEuwbLRlMJdv4TSYVET704 bcQus/O0uOsqFjCMklLt/a6c6mHsiplg+M+9BzaNzHgH/LgHMv1sU1UGIRBLH7uxBMSy UjYzVEF7lFqWGd357C+IVjisLFvxP+eF+5/29NbG4+fVOZ5E/qxKJJ0w1iCaaZ08ROW0 D8Dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="U8/A/WiB"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id p8-20020ac87408000000b003a97e804cfesi15470645qtq.528.2023.01.03.08.49.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jan 2023 08:49:27 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="U8/A/WiB"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pCkSm-0005Eu-UX; Tue, 03 Jan 2023 11:48:33 -0500 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 1pCkSk-00059s-Er for qemu-devel@nongnu.org; Tue, 03 Jan 2023 11:48:30 -0500 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pCkSi-0006pv-Rn for qemu-devel@nongnu.org; Tue, 03 Jan 2023 11:48:30 -0500 Received: by mail-wm1-x32f.google.com with SMTP id fm16-20020a05600c0c1000b003d96fb976efso21633914wmb.3 for ; Tue, 03 Jan 2023 08:48:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=1+/2U4c2jz7FuN+HYbjdpm7LXcWK38fV7wkmohQlrig=; b=U8/A/WiBNcwAMmtUYN/tbaPrqiXOjmIuT7aOtXT/d37m4hbUvw6xcbbc1ew+BUosI8 yQ02Wpmlo7ALxaLKstUprg2iAQKazPUBKkhT3QI0ZTwwOaFakvzhM5Ve2Nx6g2kgFIZN vA/A9TSWhy7y7AQfP2aIAOcAIAM7wlU23Rq86OBdFObv6NnwoUD6Y1HeepFfkO5p/LE5 RVR+8QxsCwbzh9il4VMUt5vliJTpFh4vcDy45Y+cZ7TbC7fiitKSv3HGmG/KYdbOLEi8 kPBotmR6U7+8Z+J00WHQCFE0hAL8Gix+0g2ukUjbYJYLx+CpuKNkivkwkeB1fxlNGSJY D22Q== 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:message-id :reply-to; bh=1+/2U4c2jz7FuN+HYbjdpm7LXcWK38fV7wkmohQlrig=; b=TwQ40RFG3HDryTOC1sAxdP1Fk2Fr9Drrs6WheQojJOalUd3PRFz/HyehNpAse2DysY k6Keq9fhMC3iRXavu1mobgiq3tB201kmCYsXtIc9Y0BauCVBGZ3rdNUVO3PqFXK6NOem gJO4JakeT6jTN8cCNVrzCDDzyipe53IZe2TL3tELFZpFgO3IyiIghzE6QB0OQOYHfC4n r/iy4jXqT+qP/GHNcWmP4dQm0XGPYpJBG7Oyndn7m3cLDE/z+Z3xBDGVabYoNIOoJrJU sdtmA2WJW7i38R+6W3LmYnArfU+twH9BzTvy6wlno0J7HuKf4sUo16hNAG2H7Nl2J9Kh j2jA== X-Gm-Message-State: AFqh2koufI1TtdNNkPkdC0F7w4wx6MPln1wwlH3VekXdaT3w81FHcg7b CDVzEkfiOSPXQxo7rLqt2dqWwt9v/aPKV4wF X-Received: by 2002:a05:600c:2112:b0:3d3:396e:5e36 with SMTP id u18-20020a05600c211200b003d3396e5e36mr31119224wml.0.1672764506851; Tue, 03 Jan 2023 08:48:26 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id f6-20020a05600c154600b003d98a7aa12csm31924742wmg.16.2023.01.03.08.48.26 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 03 Jan 2023 08:48:26 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Marcel Apfelbaum , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?q?aud=C3=A9?= Subject: [PATCH] hw/pci: Display correct size for unmapped BARs in HMP 'info pci' Date: Tue, 3 Jan 2023 17:48:25 +0100 Message-Id: <20230103164825.95329-1-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=philmd@linaro.org; helo=mail-wm1-x32f.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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org When a BAR is not mapped, the displayed size is shifted by 1 byte: (qemu) info pci ... Bus 0, device 11, function 0: Ethernet controller: PCI device 1022:2000 PCI subsystem 0000:0000 IRQ 10, pin A BAR0: I/O at 0xffffffffffffffff [0x001e]. BAR1: 32 bit memory at 0xffffffffffffffff [0x0000001e]. <=== BAR6: 32 bit memory at 0xffffffffffffffff [0x0003fffe]. <=== id "" Bus 0, device 18, function 0: VGA controller: PCI device 1013:00b8 PCI subsystem 1af4:1100 BAR0: 32 bit prefetchable memory at 0x10000000 [0x11ffffff]. BAR1: 32 bit memory at 0x12050000 [0x12050fff]. BAR6: 32 bit memory at 0xffffffffffffffff [0x0000fffe]. <=== id "" Only substract this byte when the BAR is mapped to display the correct size: (qemu) info pci ... Bus 0, device 11, function 0: Ethernet controller: PCI device 1022:2000 PCI subsystem 0000:0000 IRQ 10, pin A BAR0: I/O at 0xffffffffffffffff [0x001f]. BAR1: 32 bit memory at 0xffffffffffffffff [0x0000001f]. <=== BAR6: 32 bit memory at 0xffffffffffffffff [0x0003ffff]. <=== id "" Bus 0, device 18, function 0: VGA controller: PCI device 1013:00b8 PCI subsystem 1af4:1100 BAR0: 32 bit prefetchable memory at 0x10000000 [0x11ffffff]. BAR1: 32 bit memory at 0x12050000 [0x12050fff]. BAR6: 32 bit memory at 0xffffffffffffffff [0x0000ffff]. <=== id "" Fixes: 0ac32c8375 ("PCI interrupt support - 'info pci' monitor command") Signed-off-by: Philippe Mathieu-Daudé --- hw/pci/pci-hmp-cmds.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/pci/pci-hmp-cmds.c b/hw/pci/pci-hmp-cmds.c index fb7591d6ab..8cfa5f9cd1 100644 --- a/hw/pci/pci-hmp-cmds.c +++ b/hw/pci/pci-hmp-cmds.c @@ -75,22 +75,24 @@ static void hmp_info_pci_device(Monitor *mon, const PciDeviceInfo *dev) for (region = dev->regions; region; region = region->next) { uint64_t addr, size; + bool mapped; addr = region->value->address; size = region->value->size; + mapped = addr != -1; monitor_printf(mon, " BAR%" PRId64 ": ", region->value->bar); if (!strcmp(region->value->type, "io")) { monitor_printf(mon, "I/O at 0x%04" PRIx64 " [0x%04" PRIx64 "].\n", - addr, addr + size - 1); + addr, addr + size + (mapped ? -1 : 0)); } else { monitor_printf(mon, "%d bit%s memory at 0x%08" PRIx64 " [0x%08" PRIx64 "].\n", region->value->mem_type_64 ? 64 : 32, region->value->prefetch ? " prefetchable" : "", - addr, addr + size - 1); + addr, addr + size + (mapped ? -1 : 0)); } }