From nobody Thu Nov 18 08:47:00 2021 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 3146A189342C; Thu, 18 Nov 2021 08:47:01 +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 4HvthP0qSgz3CWD; Thu, 18 Nov 2021 08:47:01 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 EC07B12120; Thu, 18 Nov 2021 08:47:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1AI8l0CC047240; Thu, 18 Nov 2021 08:47:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1AI8l0JP047239; Thu, 18 Nov 2021 08:47:00 GMT (envelope-from git) Date: Thu, 18 Nov 2021 08:47:00 GMT Message-Id: <202111180847.1AI8l0JP047239@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Roger Pau Monn=C3=A9?= Subject: git: 50d7d967bbfd - main - xen/privcmd: fix MMAP_RESOURCE ioctl to copy out results 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: 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/main X-Git-Reftype: branch X-Git-Commit: 50d7d967bbfdcaf38bfac1c3bcc985a31fed26ab Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by royger: URL: https://cgit.FreeBSD.org/src/commit/?id=50d7d967bbfdcaf38bfac1c3bcc985a31fed26ab commit 50d7d967bbfdcaf38bfac1c3bcc985a31fed26ab Author: Roger Pau Monné AuthorDate: 2021-11-17 10:48:35 +0000 Commit: Roger Pau Monné CommitDate: 2021-11-18 08:46:44 +0000 xen/privcmd: fix MMAP_RESOURCE ioctl to copy out results The current definition for the MMAP_RESOURCE ioctl was wrong as it didn't copy back the result to the caller. Fix the definition and also remove the bogus attempt to copy the result in the implementation. Note such copy back is only needed when querying the size of a resource. Sponsored by: Citrix Systems R&D --- sys/dev/xen/privcmd/privcmd.c | 8 +++----- sys/xen/privcmd.h | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/sys/dev/xen/privcmd/privcmd.c b/sys/dev/xen/privcmd/privcmd.c index 0ef6737df64f..763c2f471c4f 100644 --- a/sys/dev/xen/privcmd/privcmd.c +++ b/sys/dev/xen/privcmd/privcmd.c @@ -426,12 +426,10 @@ mmap_out: if (mmap->addr == 0 && mmap->num == 0) { error = HYPERVISOR_memory_op(XENMEM_acquire_resource, &adq); - if (error != 0) { + if (error != 0) error = xen_translate_error(error); - break; - } - error = copyout(&adq.nr_frames, &mmap->num, - sizeof(mmap->num)); + else + mmap->num = adq.nr_frames; break; } diff --git a/sys/xen/privcmd.h b/sys/xen/privcmd.h index 55a1cdc86471..605ba018ac34 100644 --- a/sys/xen/privcmd.h +++ b/sys/xen/privcmd.h @@ -79,7 +79,7 @@ struct ioctl_privcmd_dmop { #define IOCTL_PRIVCMD_MMAPBATCH \ _IOWR('E', 1, struct ioctl_privcmd_mmapbatch) #define IOCTL_PRIVCMD_MMAP_RESOURCE \ - _IOW('E', 2, struct ioctl_privcmd_mmapresource) + _IOWR('E', 2, struct ioctl_privcmd_mmapresource) #define IOCTL_PRIVCMD_DM_OP \ _IOW('E', 3, struct ioctl_privcmd_dmop) #define IOCTL_PRIVCMD_RESTRICT \