From nobody Mon Oct 16 23:05:17 2023 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 4S8Xl22Mqfz4xvK2; Mon, 16 Oct 2023 23:05:18 +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 4S8Xl20dWcz4dg9; Mon, 16 Oct 2023 23:05:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1697497518; 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=M53nAVU2qwADAEVOz6PBUaA5aHUJ7F4m6IcvsbYmoAM=; b=JEnFCiIcCdRpLsFb7XlnxlGXdCLXnz46aAO3s2NuyH/Jupss2eWyDLFpZPFALyu1Fw7tix tLnjvErEERTRhPwdfGl3Q+xDIedszLOYq63ie31SxnE878+O310E3Bu70kN8cNNM+op6vr ZYiGGiDBKPpUOGeUFfRrA3oWMfnDV2nS7oeV8y7FzM3060CY894iM3goDQcXhsqY6cKUif ANCuGbgEv5Jivet57wgmPH/0aDGWT2bJV37obcR7UzqMdxIE3em+vB2AkWpn17CDXVFqC6 T57/qHqI27Azhh+rO/Q0WKxTk18dTuZm3mgxaB/7oB/3GJ2saa6EZqAtc46C7Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1697497518; a=rsa-sha256; cv=none; b=fQayEqs3tC41J/1cvyweMO89c/x1J7LgBu0muqI4S4t4WcvfvpT5Cnx/kYetfPUZeg6fFi Xx5P/WNEigAq9fNbxZxz2IcZnZ6mCrArKctaT1GMttJRK26MSKYHxmhNxmnGT7fuZPNz7O jJc84eXqwIwUfoQr0z5NJB6D+4WdXnBX2HXK8C2jn1pDZYb8JnCZuHrjAIZ5nOmYxaqIpN zO5H0AC0pkkeAZaF3/pd+j2VQQj89gqMOwK4AMtj9GH2V4hu8eWwZG5NtF7Gd4jrCGheYY Vt/jQo6X6zTFGcRqR/G3iJ+8FiHdymQ9EOUbIBr4isrikFnqu2/TPTaYVRD3lw== 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=1697497518; 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=M53nAVU2qwADAEVOz6PBUaA5aHUJ7F4m6IcvsbYmoAM=; b=hUjaPttxvF0zhofa8F18vrYr6tvTIp6K9F1IaecoKUdfrG96XQOSsyBVTjZRuYDERg+l8+ 8Hm+qo9VaagjXKhBKXn4QeDZXkkFtZvJgBya+rqPIfC0eod+F3pgFMW/WiilApFc/2bj+g 8TfSZfBo2wMiXW5gblXT+XkRvNpNqPQzrdiGtD5zvvKaxkV5KoAWvy6L9bjDqkCs1Kmcdk 4FeZxkmERYqTbLOVvxrkzUR36cvX51ruw3t+mBSiSkm1ItUUh0ugt5l973AbxoUXHfQvTx jsAOzylnbBPhp8+1Uul32O6TCBDWNiLphi+iHlFrcS9soSP9NP+EDFUwpyqe+Q== 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 4S8Xl16qklz10B9; Mon, 16 Oct 2023 23:05:17 +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 39GN5HSk046861; Mon, 16 Oct 2023 23:05:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 39GN5HTf046858; Mon, 16 Oct 2023 23:05:17 GMT (envelope-from git) Date: Mon, 16 Oct 2023 23:05:17 GMT Message-Id: <202310162305.39GN5HTf046858@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 9851b24ed4fa - releng/14.0 - x86: Properly align interrupt vectors for MSI 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: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/releng/14.0 X-Git-Reftype: branch X-Git-Commit: 9851b24ed4fa571ae3b931f834d21b9f800db9e9 Auto-Submitted: auto-generated The branch releng/14.0 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=9851b24ed4fa571ae3b931f834d21b9f800db9e9 commit 9851b24ed4fa571ae3b931f834d21b9f800db9e9 Author: John Hay AuthorDate: 2023-09-28 21:08:08 +0000 Commit: John Baldwin CommitDate: 2023-10-16 23:04:33 +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 (cherry picked from commit d33a4ae8ba5343f555842e6e32321f9cd64dfd09) (cherry picked from commit d73b4f06403af6c1a384c8c59ba9eb138c861ee1) Approved by: re (karels) --- 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; }