From nobody Fri Oct 11 07:36:31 2024 X-Original-To: dev-commits-src-all@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 4XPz2m119Pz5YR81; Fri, 11 Oct 2024 07:36:32 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XPz2l6WDJz4mLp; Fri, 11 Oct 2024 07:36:31 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728632191; 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=go5QZ29X7jeTluPmLINmhh7qhij/QOEtVKC/OEaZBlc=; b=TuvBglhNH5/OIR8zJAx7/AO7ENASuL3a+BNeT3CMKVFNRFum7KTpi3gZWxFcx3AKOZF4kF vXvPvSRyseNyLYzP3tDb1XM7Jeic/5XshlzqQINgaB5kedPf2OOn5RPnqVu847qAqPKl0V LA0XBtOOg7dxLH4z9Q/fyREesKi927/w3VIM6XbibhNCpRflFrAzMTUCzBzecgZdZsKuc+ f57J3NbUKhlZMRBQtE2vUdawM358o84+/hD/yFsys7wTZw3lVoS1y1YbZyrb39o58nYRB3 Ji0Hc7gdqwCo/EtWkCjADCQ/9X6ine5NeF4BgXcoqmF9FJ3sHZndwdoRWCci8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728632191; 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=go5QZ29X7jeTluPmLINmhh7qhij/QOEtVKC/OEaZBlc=; b=w0SjR028aU2avr9CoVc/EEMU66so3jq9kEvU7vclCjt+zfrX3sV5zez534M4e1H/rAo3x8 WrZMcvu265+zeuWAEo+QHitSgVov7+HeqQ2oPj9yngCfviub9VpdgFvcGWDcKkGQ5qUYn9 ttpwnOqJKjjH5ZW1gihpKH7nuBL4CjTsO5aYbUx2+XM/MqXMgAWFOPBbzFvVNI+kPWsb/5 MP05yaDhfBbW1Qc4L3oFPiGak+3S3XSR3yg3ndib7l5Pp5H/RL3z8CG4ld8wNgyVQGdr1i 2CuxdU/cAv6Wq3jaG0gr0/jN+X+nZ7eHH7MyQlj2i24v4fkr4MYY6KXkAPlTXQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1728632191; a=rsa-sha256; cv=none; b=kRiCs2pKQi36Wazdo1wGxVsGaL7EBngAiQnZUCl5cWtPWSKWT0uNn1tyHZiNSt/7TSIkiW D84ZtAf8uzFJFiJVfhiLVhjOiBQ9wxcc5rnhLSb+Mg0UBKawhS0gOy4J/uHx6U6Vo5JQkH WIxxincMcme03k5jM+DN2oS94bNH9A25bWwSwtojLsCSK7LN8qBc+wkBS1wTI18kUq2bl3 9eXF4LJzmdEz2Q4WeFOFPWz+Ws9AbaFpoukYgfmf+Sjfnbey7eHB2VDvgxtF+sE1run5BZ lcpg7WtM0aFnj50UMJuwKL+frvYZhxkXg34Ryu79xkeXOGuiwSNqlGwSxjvUXg== 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 4XPz2l66ybzYPJ; Fri, 11 Oct 2024 07:36:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 49B7aVQ6040706; Fri, 11 Oct 2024 07:36:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49B7aV0w040703; Fri, 11 Oct 2024 07:36:31 GMT (envelope-from git) Date: Fri, 11 Oct 2024 07:36:31 GMT Message-Id: <202410110736.49B7aV0w040703@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Roger Pau =?utf-8?Q?Monn=C3=A9?= Subject: git: 329a3b0844e6 - stable/14 - xen: fix initialization of grant table frame array List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: royger X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 329a3b0844e6671a3119a3f4da98e826c1c6199e Auto-Submitted: auto-generated The branch stable/14 has been updated by royger: URL: https://cgit.FreeBSD.org/src/commit/?id=329a3b0844e6671a3119a3f4da98e826c1c6199e commit 329a3b0844e6671a3119a3f4da98e826c1c6199e Author: Roger Pau Monné AuthorDate: 2023-11-02 17:23:25 +0000 Commit: Roger Pau Monné CommitDate: 2024-10-11 07:06:13 +0000 xen: fix initialization of grant table frame array The current sizing of the array used to store grant table frames is broken, as the calculation: max_nr_glist_frames = (boot_max_nr_grant_frames * GREFS_PER_GRANT_FRAME / (PAGE_SIZE / sizeof(grant_ref_t))); Is plain bogus, for once grant_ref_t is the type of the grant reference, but not the entry used to store such references in the grant frames. But even if the above calculation is switched to use grant_entry_v1_t, it would end up as: max_nr_glist_frames = (boot_max_nr_grant_frames * (PAGE_SIZE / sizeof(grant_entry_v1_t)) / (PAGE_SIZE / sizeof(grant_entry_v1_t))); Which is pointless (note GREFS_PER_GRANT_FRAME has been expanded to (PAGE_SIZE / sizeof(grant_entry_v1_t))). Just use boot_max_nr_grant_frames directly to size the grant table frames array. Fixes: 30d1eefe3937 ("Import OS interfaces to Xen services.") Sponsored by: Citrix Systems R&D (cherry picked from commit 1a12f0aea81b57d0dd2374047b8f4c97a037a8df) --- sys/dev/xen/grant_table/grant_table.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/sys/dev/xen/grant_table/grant_table.c b/sys/dev/xen/grant_table/grant_table.c index 13ca966c1f90..1cf9fe5e339a 100644 --- a/sys/dev/xen/grant_table/grant_table.c +++ b/sys/dev/xen/grant_table/grant_table.c @@ -610,20 +610,12 @@ static int granttable_attach(device_t dev) { int i; - unsigned int max_nr_glist_frames; unsigned int nr_init_grefs; nr_grant_frames = 1; boot_max_nr_grant_frames = __max_nr_grant_frames(); - /* Determine the maximum number of frames required for the - * grant reference free list on the current hypervisor. - */ - max_nr_glist_frames = (boot_max_nr_grant_frames * - GREFS_PER_GRANT_FRAME / - (PAGE_SIZE / sizeof(grant_ref_t))); - - gnttab_list = malloc(max_nr_glist_frames * sizeof(grant_ref_t *), + gnttab_list = malloc(boot_max_nr_grant_frames * sizeof(grant_ref_t *), M_DEVBUF, M_NOWAIT); if (gnttab_list == NULL)