From nobody Mon Nov 06 10:17:47 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 4SP6jm0yB4z508lp; Mon, 6 Nov 2023 10:17: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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SP6jm0BBbz4Sbt; Mon, 6 Nov 2023 10:17:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699265868; 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=P0pwrYnFwrU+m3ZENbiUh0JrgtnpiP2xojXecnuHCm4=; b=AqFq9vAFjeqMbenk3PGGR2j7F50y5CfGmxiaoTByjyCBduh6OEILReOpnorLOOl6Mza/5n ODdn2PBcucSBQP2/Teigvb6qmGYNYHE+RJpp7ESVjEKIz+NVVQCviIXOiCElDlzaq/k8r0 UXq1nYsEj9Lez+XFK8zayEnZXWKh2ehsX8gY90A4Cooh545velOG+pQWHYW+DzhJgUNHuV QFAZLn+Si6kIuHB+xyXMREnAubTKjmVID3nwTMmHiBB7kCFBlev7F9nxR8sHy+TGYMO3BR xRXc5nUfOSA3MkBfhX/dbmSWsV9IWHenboIZZ3PSc7JdHLsrUq4BZmmbSpfyzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699265868; 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=P0pwrYnFwrU+m3ZENbiUh0JrgtnpiP2xojXecnuHCm4=; b=Sr9CL9kX9mgb7Fk4T1A5JTR0A4B4vs+21X7vQNb3rONEMAeieNIZ6A3Su9e/WWqE5GbQZV JN7c7u6vR43Yjobf7RDOaPpyRNLcJAkMX1xoXlWHy1YRkpG14SXFheF9mxznTSznXPrjfa E3fTODxDr4ndtybgom/Z9JIPiLTBnZj/ZEATN6D0ctZD5qD8ELW1lLVfIhwTOBYap0sZbR 1vCEgLNLMCpD1mcZ4FweKUQB7ZjJmrU31EMuz7SNKjzxGsjv95HOnonXOQEAyqjefdHl/z 2WbASp71wt2fdADrMYn7dSyl0Z8kMKh/oGQjR+rIGXTTxCtXuRooJ3H57X7woA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1699265868; a=rsa-sha256; cv=none; b=pwTUeLgUiuzMDctr6mZJY8yCnpXgzJUjWcvWxWWfb5jejRBRk5QTksL3vFYHTaNFfzPmlb 74D5VY4HiUrlOIrwuh4cw57vW1b/UgIAnjgYux3VmYN3prOfWEeFtARaQMvyZfBeEZOMb2 kzgBVozHfo3Q1alriGd5+AXk4lAmJXAK/95RcBPc+klkIcVmkCh2GkRk8YDixBeGLqORCc 5+j5MmvhvOb6YVk+0wwoOOX47KbrvlVsocrm/Z8M2Rfzjr3v+ngevjA9HFJkhkjmCkYCkz huReRjfYN8HLY2rLgx7EV2AFBcQfch9EYybuaBA8Oz86P3AcMurfQyaRPa62lQ== 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 4SP6jl6G1Wz13cF; Mon, 6 Nov 2023 10:17:47 +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 3A6AHl9Z007394; Mon, 6 Nov 2023 10:17:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3A6AHleg007391; Mon, 6 Nov 2023 10:17:47 GMT (envelope-from git) Date: Mon, 6 Nov 2023 10:17:47 GMT Message-Id: <202311061017.3A6AHleg007391@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Roger Pau =?utf-8?Q?Monn=C3=A9?= Subject: git: 1a12f0aea81b - main - xen: fix initialization of grant table frame array 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: royger X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1a12f0aea81b57d0dd2374047b8f4c97a037a8df Auto-Submitted: auto-generated The branch main has been updated by royger: URL: https://cgit.FreeBSD.org/src/commit/?id=1a12f0aea81b57d0dd2374047b8f4c97a037a8df commit 1a12f0aea81b57d0dd2374047b8f4c97a037a8df Author: Roger Pau Monné AuthorDate: 2023-11-02 17:23:25 +0000 Commit: Roger Pau Monné CommitDate: 2023-11-06 10:17:39 +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 --- 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)