From nobody Fri Dec 19 17:16:32 2025 Received: from mail-io1-f41.google.com (mail-io1-f41.google.com [209.85.166.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E1569167A5E for ; Thu, 11 Apr 2024 15:41:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712850103; cv=none; b=ob5k9r3AcPLhCz1Tt6QTF4lrk6ex+tp3Gr8tKACl8cff51/timrUXemGV+r97SNXoRcmZ5K0ucylq3ueDmM/gABIgEs2E5AJh9+sUaXPLw75W4hAzHFHZT1JszblL/ZsQJ/IFKrosGluClW3icYYp9ZcgEiX2xxnG2gDnDqOlck= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712850103; c=relaxed/simple; bh=FkYWqTvM+2jSptowiPOt+barHIkCI9dC3b27o9bdQqE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=K9J0e9JpYIAG/2iG9MftDTz+5s7SzL7oPZ1FqOtA0vVv/kxSBUCSUQlNbk2mPGnFNEuPe57MqtNclRMFcyv0ReKmUXg7x2AyOv5CfYyrJ9xhtG0evQ4aUCjn6Vl3EUrwHKoif0V53QMW5bfPKq+gTvjx20UoUsiL7WCUxwETMlg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.dk; spf=pass smtp.mailfrom=kernel.dk; dkim=pass (2048-bit key) header.d=kernel-dk.20230601.gappssmtp.com header.i=@kernel-dk.20230601.gappssmtp.com header.b=1YGtsZTR; arc=none smtp.client-ip=209.85.166.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.dk Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kernel.dk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel-dk.20230601.gappssmtp.com header.i=@kernel-dk.20230601.gappssmtp.com header.b="1YGtsZTR" Received: by mail-io1-f41.google.com with SMTP id ca18e2360f4ac-7d5ed700c2dso16253139f.0 for ; Thu, 11 Apr 2024 08:41:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1712850099; x=1713454899; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tjm37oBDCr6T/2qjJEXIR+jYlGucpRAsXgmpYtn7BVc=; b=1YGtsZTR4IDAc1pljtlWcCxLQJ5XPo5F0KXFezIE1arDbtxn6/EmKyhJNomkpaE9gG dagPFE5A78+TzxX7xfkLznhG8D4HsfofvHJFFIF4sLWabEDa5v7OnDSiGQyye4pumNzu kgjC+/LY9QD34V87SQcII7tKH9CnwqNz6VRHoGYTK7Pl/qM5KzZ1Dbo9355H0PCrD18T Wb8efdUbyjYMYgU6rW6V9Nim3OQoOMAtabJvUwcgjMwj8dFTrODi2DD1qGI/gwB4giWg o/1gopv7VIwDktPszRGNOESphq/gw3y/j/pqNz4QiC3J3nzPcIov+sJJ98TBkPI7JbXE CsfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712850099; x=1713454899; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tjm37oBDCr6T/2qjJEXIR+jYlGucpRAsXgmpYtn7BVc=; b=Lq/clTKdV4Ue8xvQgjOXHNRWYxK/tSgNXwSUYvrj8g36lBkK05WrdrVaPYLRK1lPyW r5uQBqh3kgmJ0IhyGX620qu7OTBGK/c7pLtJmP4HS9lga0pcR6eGPYKJs/6awp2fluGw lboCJW+9q3k6uqnGTl0pQe427+32lWs4WBajn1oLYRBDdQ5WsISluGjBaof0IzwbEitD ZL2XOb05fLibIcHIUNBVtSt+C1EqaCpoDcFsx/nOyhVLQaVZkigvNCOjs449AffVy4Ye 9gVIFOvxGMx4MJZIjLyBmzI2oBKBbEfCUOtQ9rRu+47uuLviFI4MX69fBi4xRlTHFUQK 9JQw== X-Gm-Message-State: AOJu0YwSGCxbansDS+5HCtQ5D8kPzKiiZ3nAYwBz/8ga494S3pMWpEyV +VnqYQ0R4RsK/KWNfvvtv+Hlo0VagNZrs+7xLvfGDe15HW5UBv52gnp5Slbzr/t2E8H8BDrKAmh P X-Google-Smtp-Source: AGHT+IEhHZinlhSLuM6YKkPR3YHa9s8EMI9PdzE7fWRTEwfoQStXLGimgMsv/BHWlyxYHGZuJGIm5w== X-Received: by 2002:a6b:f312:0:b0:7d5:de23:13a9 with SMTP id m18-20020a6bf312000000b007d5de2313a9mr176510ioh.1.1712850099437; Thu, 11 Apr 2024 08:41:39 -0700 (PDT) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id jc25-20020a056638891900b0047f14b7f6c0sm457056jab.5.2024.04.11.08.41.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 08:41:37 -0700 (PDT) From: Jens Axboe To: linux-kernel@vger.kernel.org Cc: Jens Axboe Subject: [PATCH 357/437] samples/vfio-mdev: convert to read/write iterators Date: Thu, 11 Apr 2024 09:18:17 -0600 Message-ID: <20240411153126.16201-358-axboe@kernel.dk> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240411153126.16201-1-axboe@kernel.dk> References: <20240411153126.16201-1-axboe@kernel.dk> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Signed-off-by: Jens Axboe --- samples/vfio-mdev/mtty.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/samples/vfio-mdev/mtty.c b/samples/vfio-mdev/mtty.c index 2284b3751240..b7b9c39a0497 100644 --- a/samples/vfio-mdev/mtty.c +++ b/samples/vfio-mdev/mtty.c @@ -881,16 +881,17 @@ static long mtty_precopy_ioctl(struct file *filp, uns= igned int cmd, return ret; } =20 -static ssize_t mtty_save_read(struct file *filp, char __user *buf, - size_t len, loff_t *pos) +static ssize_t mtty_save_read(struct kiocb *iocb, struct iov_iter *to) { - struct mtty_migration_file *migf =3D filp->private_data; + struct mtty_migration_file *migf =3D iocb->ki_filp->private_data; + size_t len =3D iov_iter_count(to); ssize_t ret =3D 0; + loff_t *pos; =20 - if (pos) + if (iocb->ki_pos) return -ESPIPE; =20 - pos =3D &filp->f_pos; + pos =3D &iocb->ki_filp->f_pos; =20 mutex_lock(&migf->lock); =20 @@ -908,7 +909,7 @@ static ssize_t mtty_save_read(struct file *filp, char _= _user *buf, =20 len =3D min_t(size_t, migf->filled_size - *pos, len); if (len) { - if (copy_to_user(buf, (void *)&migf->data + *pos, len)) { + if (!copy_to_iter_full((void *)&migf->data + *pos, len, to)) { ret =3D -EFAULT; goto out_unlock; } @@ -923,7 +924,7 @@ static ssize_t mtty_save_read(struct file *filp, char _= _user *buf, =20 static const struct file_operations mtty_save_fops =3D { .owner =3D THIS_MODULE, - .read =3D mtty_save_read, + .read_iter =3D mtty_save_read, .unlocked_ioctl =3D mtty_precopy_ioctl, .compat_ioctl =3D compat_ptr_ioctl, .release =3D mtty_release_migf, @@ -1018,18 +1019,19 @@ mtty_save_device_data(struct mdev_state *mdev_state, return ret; } =20 -static ssize_t mtty_resume_write(struct file *filp, const char __user *buf, - size_t len, loff_t *pos) +static ssize_t mtty_resume_write(struct kiocb *iocb, struct iov_iter *from) { - struct mtty_migration_file *migf =3D filp->private_data; + struct mtty_migration_file *migf =3D iocb->ki_filp->private_data; struct mdev_state *mdev_state =3D migf->mdev_state; + size_t len =3D iov_iter_count(from); loff_t requested_length; ssize_t ret =3D 0; + loff_t *pos; =20 - if (pos) + if (iocb->ki_pos) return -ESPIPE; =20 - pos =3D &filp->f_pos; + pos =3D &iocb->ki_filp->f_pos; =20 if (*pos < 0 || check_add_overflow((loff_t)len, *pos, &requested_length)) @@ -1045,7 +1047,7 @@ static ssize_t mtty_resume_write(struct file *filp, c= onst char __user *buf, goto out_unlock; } =20 - if (copy_from_user((void *)&migf->data + *pos, buf, len)) { + if (!copy_from_iter_full((void *)&migf->data + *pos, len, from)) { ret =3D -EFAULT; goto out_unlock; } @@ -1080,7 +1082,7 @@ static ssize_t mtty_resume_write(struct file *filp, c= onst char __user *buf, =20 static const struct file_operations mtty_resume_fops =3D { .owner =3D THIS_MODULE, - .write =3D mtty_resume_write, + .write_iter =3D mtty_resume_write, .release =3D mtty_release_migf, .llseek =3D no_llseek, }; --=20 2.43.0