From nobody Wed Apr 17 08:13:48 2024 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VKDFT2M53z5J6jh; Wed, 17 Apr 2024 08:13:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VKDFS6zBFz4BNh; Wed, 17 Apr 2024 08:13:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713341629; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=y8LIVBmcKK/ww1LNrGGvQ3qA5dCPeLTLQzyFqmZtLQo=; b=ouuI7Wxy+zfyBVGfoKCfDZJJxADfivQyYW68MWc6IZkCun3VcEzpEc5btjggS3UActSw4M 5x/aUGw9CWERTtFIzVJheJSjuq45uq4aRiFv2FKsJa0ORFaqJdKBx6DTIiyRToZmhg1eGX 4ByUJk+dplS8dAlS6I+NeRZG9TMX/KlbFLZS4JUsMznyOPOMli14H8rhWr2NmZ0VDEr5U+ UV/e/P+X5C+po9htQu9YA9xQRoCaYsi6y3EFdZciNeGvcnrT9+tLDRDh2dti5Dmfxsx4Od O6511x58fTOE+MhPQ2v9Nb3lR+5/0FClVtdrdf6ssuyEXgDvt6WJmklnFmuSZA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1713341629; a=rsa-sha256; cv=none; b=XStOyetUHpk4XjjeT1Yo7MtSreuGZjOaxUfCPJjGkqoLVX8Ed6lNEHrJ0dc5pnvJFKGFUF ikjxOBwTg5eukv+VwJEAzVpZEAuYYiVYv96RZ2jdzqajkRXOjzWIpuC+MWAeeorUfZ0Fer ZulXnmBcvt0Y/7kIrdQklH7jaFzarHOoc9SVuSrF6mcoqaE+KbNSz6vJK2JJjYk8TQpiho sHZk0r5WH85ZFo3FArTt7ZuHGbHmlgFaC8dzagLVid8qmVgQh3quj++WxjwYjGfJbbR5GU Ctd3FiT3DrlfxUNRw77GbiInx+ZQ0QIwyiINTCqwuqIQFfSmhToetp/t79ZXSQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713341629; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=y8LIVBmcKK/ww1LNrGGvQ3qA5dCPeLTLQzyFqmZtLQo=; b=IcZMo6f4Yw0s/MY4gGelEugH5Jp2Hj6SEtXedonKl+7e+t/WLCfkScxqeMMpqCnYoaQGOO UDNmA0f92UtY5KB7l/jMTNGorHlj9+DnxFwcEeYN8E/Z2iKw5xGQvSD+OCDHt90405bGQb 5sGgHyVffBMQTOYJMjDlhEFB/XN0gK+KMO4TqCb4lPp1pIVn7pYttZvLYMgY07LAncpyaL gydlMkdEhVU8hSQAxf7sKT6ms+kVBK9gumyPBQAXrleOJjiDA7gzQVjPfvpgGfv/v4NYMT 0xVlnR6KGxyfL6YBDCHAm4C5H7r16vspBXpHt/WjMCY0VkXKwVHkp3ehfSaT9Q== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VKDFS6X3TzJk3; Wed, 17 Apr 2024 08:13:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 43H8DmcH062644; Wed, 17 Apr 2024 08:13:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43H8Dmq1062641; Wed, 17 Apr 2024 08:13:48 GMT (envelope-from git) Date: Wed, 17 Apr 2024 08:13:48 GMT Message-Id: <202404170813.43H8Dmq1062641@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 02dc74cc21af - stable/13 - pciconf(8): dump AMD IOMMU Base Capability List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 02dc74cc21af0928021fb53de1c804d068de1449 Auto-Submitted: auto-generated The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=02dc74cc21af0928021fb53de1c804d068de1449 commit 02dc74cc21af0928021fb53de1c804d068de1449 Author: Konstantin Belousov AuthorDate: 2024-04-09 22:13:59 +0000 Commit: Konstantin Belousov CommitDate: 2024-04-17 08:13:18 +0000 pciconf(8): dump AMD IOMMU Base Capability (cherry picked from commit 1e6db7be692198acfa7f02dea83aa9aa1dfce273) --- usr.sbin/pciconf/cap.c | 115 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) diff --git a/usr.sbin/pciconf/cap.c b/usr.sbin/pciconf/cap.c index 7b403b90eee6..72b63db31d70 100644 --- a/usr.sbin/pciconf/cap.c +++ b/usr.sbin/pciconf/cap.c @@ -376,6 +376,118 @@ cap_subvendor(int fd, struct pci_conf *p, uint8_t ptr) printf("PCI Bridge subvendor=0x%04x subdevice=0x%04x", ssvid, ssid); } +static const char * +cap_secdev_amdiommu_decode_vasize(uint32_t misc0) +{ + switch (misc0 & PCIM_AMDIOMMU_MISC0_VASIZE_MASK) { + case PCIM_AMDIOMMU_MISC0_VASIZE_32: + return ("32bit"); + case PCIM_AMDIOMMU_MISC0_VASIZE_40: + return ("40bit"); + case PCIM_AMDIOMMU_MISC0_VASIZE_48: + return ("48bit"); + case PCIM_AMDIOMMU_MISC0_VASIZE_64: + return ("64bit"); + default: + return ("unknown"); + } +} + +static const char * +cap_secdev_amdiommu_decode_pasize(uint32_t misc0) +{ + switch (misc0 & PCIM_AMDIOMMU_MISC0_PASIZE_MASK) { + case PCIM_AMDIOMMU_MISC0_PASIZE_40: + return ("40bit"); + case PCIM_AMDIOMMU_MISC0_PASIZE_48: + return ("48bit"); + case PCIM_AMDIOMMU_MISC0_PASIZE_52: + return ("52bit"); + default: + return ("unknown"); + } +} + +static const char * +cap_secdev_amdiommu_decode_gvasize(uint32_t misc0) +{ + switch (misc0 & PCIM_AMDIOMMU_MISC0_GVASIZE_MASK) { + case PCIM_AMDIOMMU_MISC0_GVASIZE_48: + return ("48bit"); + case PCIM_AMDIOMMU_MISC0_GVASIZE_57: + return ("57bit"); + default: + return ("unknown"); + } +} + +static void +cap_secdev(int fd, struct pci_conf *p, uint8_t ptr) +{ + uint32_t cap_h; + uint32_t cap_type, cap_rev; + uint32_t base_low, base_high; + uint32_t range; + uint32_t misc0, misc1; + const char *delim; + + cap_h = read_config(fd, &p->pc_sel, ptr + PCIR_AMDIOMMU_CAP_HEADER, 4); + cap_type = cap_h & PCIM_AMDIOMMU_CAP_TYPE_MASK; + cap_rev = cap_h & PCIM_AMDIOMMU_CAP_REV_MASK; + if (cap_type != PCIM_AMDIOMMU_CAP_TYPE_VAL || + cap_rev != PCIM_AMDIOMMU_CAP_REV_VAL) { + printf("Secure Device Type=0x%1x Rev=0x%02x\n", + cap_type >> 16, cap_rev >> 19); + return; + } + base_low = read_config(fd, &p->pc_sel, ptr + PCIR_AMDIOMMU_BASE_LOW, + 4); + base_high = read_config(fd, &p->pc_sel, ptr + PCIR_AMDIOMMU_BASE_HIGH, + 4); + printf("AMD IOMMU Base Capability Base=%#018jx/%sabled", + (uintmax_t)(base_low & PCIM_AMDIOMMU_BASE_LOW_ADDRM) + + ((uintmax_t)base_high << 32), + (base_low & PCIM_AMDIOMMU_BASE_LOW_EN) != 0 ? "En" : "Dis"); + + delim = "\n\t\t"; +#define PRINTCAP(bit, name) \ + if ((cap_h & PCIM_AMDIOMMU_CAP_ ##bit) != 0) { \ + printf("%s%s", delim, #name); \ + delim = ","; \ + } + PRINTCAP(CAPEXT, CapExt); + PRINTCAP(EFR, EFRSup); + PRINTCAP(NPCACHE, NpCache); + PRINTCAP(HTTUN, HtTunnel); + PRINTCAP(IOTLB, IotlbSup); +#undef PRINTCAP + + range = read_config(fd, &p->pc_sel, ptr + PCIR_AMDIOMMU_RANGE, 4); + printf("\n\t\tUnitId=%d", range & PCIM_AMDIOMMU_RANGE_UNITID_MASK); + if ((range & PCIM_AMDIOMMU_RANGE_RNGVALID) != 0) { + printf(" BusNum=%#06x FirstDev=%#06x LastDev=%#06x", + (range & PCIM_AMDIOMMU_RANGE_BUSNUM_MASK) >> 8, + (range & PCIM_AMDIOMMU_RANGE_FIRSTDEV_MASK) >> 16, + (range & PCIM_AMDIOMMU_RANGE_LASTDEV_MASK) >> 24); + } + + misc0 = read_config(fd, &p->pc_sel, ptr + PCIR_AMDIOMMU_MISC0, 4); + printf("\n\t\tMsiNum=%d MsiNumPPR=%d HtAtsResv=%d", + misc0 & PCIM_AMDIOMMU_MISC0_MSINUM_MASK, + (misc0 & PCIM_AMDIOMMU_MISC0_MSINUMPPR_MASK) >> 27, + (misc0 & PCIM_AMDIOMMU_MISC0_HTATSRESV) != 0); + if ((cap_h & PCIM_AMDIOMMU_CAP_CAPEXT) != 0) { + misc1 = read_config(fd, &p->pc_sel, + ptr + PCIR_AMDIOMMU_MISC1, 4); + printf(" MsiNumGA=%d", + misc1 & PCIM_AMDIOMMU_MISC1_MSINUMGA_MASK); + } + printf("\n\t\tVAsize=%s PAsize=%s GVAsize=%s", + cap_secdev_amdiommu_decode_vasize(misc0), + cap_secdev_amdiommu_decode_pasize(misc0), + cap_secdev_amdiommu_decode_gvasize(misc0)); +} + #define MAX_PAYLOAD(field) (128 << (field)) static const char * @@ -809,6 +921,9 @@ list_caps(int fd, struct pci_conf *p, int level) case PCIY_SUBVENDOR: cap_subvendor(fd, p, ptr); break; + case PCIY_SECDEV: + cap_secdev(fd, p, ptr); + break; case PCIY_EXPRESS: express = 1; cap_express(fd, p, ptr);