From nobody Thu Sep 28 21:18:37 2023 X-Original-To: dev-commits-src-main@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 4RxRDG12MLz4vcRq; Thu, 28 Sep 2023 21:18:38 +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 4RxRDG0WJBz3Gcy; Thu, 28 Sep 2023 21:18:38 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1695935918; 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=Tuw7ZJCNjYJRaYEPM1kJ5SqPkizWzmQoADi73t1hoEM=; b=CC5+RRuwOzFOESKaSR1bYc8y0H9gDTyN/xSDYWzURrZrwQkD3BjAnIeHxF2nkAxUbjPhiG bQgRgIyIwZx4a/9hIovaDYGGRnxU/zd28wWBTZarQp73XYZ5jCsiLnoZWr//tb+DQWNZuB MxXQJ3jk+C0OzC5GG8Idx+B9GeTKnM9vbmasb3hId89g0jnxLraC+jaPon5FbIyld9FlHs MS3P8lJuzwJNjg5A/2RNpAX17rrFvflN2kzHoWTjDQUCGpyIM5q8p9LJ2K8d/cxhrc+fSd Lti3TGLbh0bUDStHweuSn5BdOzuF6DzIpAO1r1JcsOTH0pPMpnC6vO0Zk3BEPg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1695935918; a=rsa-sha256; cv=none; b=doBtdZHCGp5gSOTrNufg8atzvRSyQCiEN1XvMD28ySJdQZQsPxLA/GUFZfNf1/Hd0LvtAF YYYHb3ieXR9JpP4c/dvs7y4w9y1YccBKAwDQIbhftXctjxXaKwz7Ck4U5dUw/J0GLmB15e a+I3dAwqUvDJbVU4w5bePlXT/iegf76ABiAO/FOmO4YxjwaZZ/EQOFcbRSRbG5PQWbRbzF iwTVbljRAQHnYfIOz6ctl3ShQZ2XR639ZyaVpBesBphWmoHzSd80dCeQZafXreY1rmAW5H NbRjPtEhscYZaVDKkIbuq7UYRCxj2oiuS6O7OC57aUag1JUqnSDMnvNSBv5+0Q== 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=1695935918; 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=Tuw7ZJCNjYJRaYEPM1kJ5SqPkizWzmQoADi73t1hoEM=; b=Yi6Z666iVUohOrnNsrBNo3KxOE9sDL8MpyIlb3fbwYoR0mSWrO1kR07KyeR4jONB47QWEY Gu/zRhYlUHdiAKxsgftvUyK796lgDLVfIsIeoPwlI8xbiH5YrQnXpgtfn5UrYrMOA9XeGv K7benCu6fX8NhOtIC72q/mFY0ANwbMBfQH6x2ecb67+iaUs0xRb6dUAgo5f/01l87i2ZqW Oft4lv1Raa/Hkg9vMTUwPPjdr5gKTjHN7U3Mx4TAyjFZv6YdMQpGat0Q6aMZIYFG63tHiZ OZcQhvHpD5twzulBv/AhWrJZBO8qBh2kwAFHvJRM0A4YIvxD4pMtsI6gIISUGQ== 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 4RxRDF6jP5zdgG; Thu, 28 Sep 2023 21:18:37 +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 38SLIbHl056935; Thu, 28 Sep 2023 21:18:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 38SLIbFA056932; Thu, 28 Sep 2023 21:18:37 GMT (envelope-from git) Date: Thu, 28 Sep 2023 21:18:37 GMT Message-Id: <202309282118.38SLIbFA056932@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: d33a4ae8ba53 - main - x86: Properly align interrupt vectors for MSI List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d33a4ae8ba5343f555842e6e32321f9cd64dfd09 Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=d33a4ae8ba5343f555842e6e32321f9cd64dfd09 commit d33a4ae8ba5343f555842e6e32321f9cd64dfd09 Author: John Hay AuthorDate: 2023-09-28 21:08:08 +0000 Commit: John Baldwin CommitDate: 2023-09-28 21:08:08 +0000 x86: Properly align interrupt vectors for MSI MSI (not MSI-X) interrupt vectors must be allocated in groups that are powers of 2, and the block of IDT vectors must be aligned to the size of the request. The code in native_apic_alloc_vectors() does an alignment check in the loop: if ((vector & (align - 1)) != 0) continue; first = vector; But it adds APIC_IO_INTS to the value it returns: return (first + APIC_IO_INTS); The problem is that APIC_IO_INTS is not a multiple of 32. It is 48: As a result, a request for 32 vectors (the max supported by MSI), was not always aligned. To fix, check the alignment of 'vector + APIC_IO_INTS' in the loop. PR: 274074 Reviewed by: jhb --- sys/x86/x86/local_apic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/x86/x86/local_apic.c b/sys/x86/x86/local_apic.c index 17b0223f834b..b382368cc626 100644 --- a/sys/x86/x86/local_apic.c +++ b/sys/x86/x86/local_apic.c @@ -1582,7 +1582,7 @@ apic_alloc_vectors(u_int apic_id, u_int *irqs, u_int count, u_int align) /* Start a new run if run == 0 and vector is aligned. */ if (run == 0) { - if ((vector & (align - 1)) != 0) + if (((vector + APIC_IO_INTS) & (align - 1)) != 0) continue; first = vector; }