From nobody Fri Oct 11 07:42:48 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 4XPzB0616Dz5YRl7; Fri, 11 Oct 2024 07:42:48 +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 4XPzB05DD2z4ngd; Fri, 11 Oct 2024 07:42:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728632568; 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=MHJykXbyCQSylXutRA7oF9RJktruKronxqusmNB00w0=; b=p4Obtykn/EMAkDtvXBWo6ldKvrW+5TOMe+4ZDflV76SeKlMoT5ASRADrHmVtldkFfO6upa vmSIp0Ez+PY5QWqBamqpdg8IyuQkU4j5ARbB21f/wy+Wqo150vDkfvBmnaBPjUtPLps73I poJXm7xggNrdq+M//Ix2hPoYdr0T9x01V/TAUEVrM//Dqj6Y3DcAvRfsurdA0WDwTuxsKE 1krPO2s8LN7HwMNNpTMx+jilCNEwABWIRwi2pHg7v6tGosvoyxhwm6b5A/YQeyRngLUDop rG6HvuFgFCHt3AUCavFjGN96IRPsHEC7UJg0sFLRUZqLsoNB+SDoPsBEZ6LyJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728632568; 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=MHJykXbyCQSylXutRA7oF9RJktruKronxqusmNB00w0=; b=TIY9vWw/mokRuVSWURLRT+zp2HjIX3vT6jOchCtPNhHdIuyQMmsKNiuArp1tKdAbOQgdyC suIQo8kcER3MVwZeOVmXtilzNOag7xDF/D4w72Kkytl8b730b0Lm3gA9fjy++I95hqmKY7 IPYlij6xiXwR8OpMIvs917SMlzO1SfyrqUN3BqVTF+m87jzmXz7Ra9SaKEPmZYWTTL+snW sOfUZ5qna/7vFHUK4mZnX8IN3v2I9be5v0Rx++Yua+YEYCkjk72RKQ+wuOzVF+h7x+wgrZ q+wBJIJJmuxkEkL96oF0ZhuMuSqGARuxdj+gHMm74wbyuhBLBA5ux89cPBJVKA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1728632568; a=rsa-sha256; cv=none; b=WRM1RUVXfE8naDY8L4Iz8Z0hY9ctD+E6wZ70TLJso4FRI4TBMhBDaF8kxZRvJ/6SCWBhsP WCULQduaWrLLYPGE/ELsajIHl2SLghg1F2aatYK2vStq2GIVZ15tq9hsGu8yPvptQcje5/ zIoOtI4gOi/7AUPbpHHIaLmaraP2uv6hh2Y9jh6Q7TCA7EcBv1fpvbGkq15m640nv0+P46 OXaoMiRpYeQcmrxJpz7TZLBZpchYwkKJ7ppTsjSGqMAJFBhhHVv6av4csGcLl2dRxmBRQA EsnPLTELpOXYn9Q1W9ppuIN3g13o5MVfWLmCh5WmVEAkpqXvIGU4+ksfGGHVUw== 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 4XPzB04qLdzZ68; Fri, 11 Oct 2024 07:42:48 +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 49B7gmHm056784; Fri, 11 Oct 2024 07:42:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49B7gmwu056781; Fri, 11 Oct 2024 07:42:48 GMT (envelope-from git) Date: Fri, 11 Oct 2024 07:42:48 GMT Message-Id: <202410110742.49B7gmwu056781@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: 7174b9817cdd - stable/13 - 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/13 X-Git-Reftype: branch X-Git-Commit: 7174b9817cddb72abb9f0d8cec8689b498de1d97 Auto-Submitted: auto-generated The branch stable/13 has been updated by royger: URL: https://cgit.FreeBSD.org/src/commit/?id=7174b9817cddb72abb9f0d8cec8689b498de1d97 commit 7174b9817cddb72abb9f0d8cec8689b498de1d97 Author: Roger Pau Monné AuthorDate: 2023-11-02 17:23:25 +0000 Commit: Roger Pau Monné CommitDate: 2024-10-11 07:40:16 +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 c68c9331233b..df6c13dd8507 100644 --- a/sys/dev/xen/grant_table/grant_table.c +++ b/sys/dev/xen/grant_table/grant_table.c @@ -631,20 +631,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)