public inbox for linux-s390@vger.kernel.org
 help / color / mirror / Atom feed
From: Matthew Rosato <mjrosato@linux.ibm.com>
To: Eric Farman <farman@linux.ibm.com>, Halil Pasic <pasic@linux.ibm.com>
Cc: Heiko Carstens <hca@linux.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Alexander Gordeev <agordeev@linux.ibm.com>,
	Christian Borntraeger <borntraeger@linux.ibm.com>,
	Sven Schnelle <svens@linux.ibm.com>,
	Vineeth Vijayan <vneethv@linux.ibm.com>,
	Peter Oberparleiter <oberpar@linux.ibm.com>,
	linux-s390@vger.kernel.org, kvm@vger.kernel.org
Subject: Re: [PATCH v2 11/16] vfio/ccw: read only one Format-1 IDAW
Date: Tue, 20 Dec 2022 12:24:51 -0500	[thread overview]
Message-ID: <d3f130b3-5196-6a02-9b6b-162c3082396b@linux.ibm.com> (raw)
In-Reply-To: <20221220171008.1362680-12-farman@linux.ibm.com>

On 12/20/22 12:10 PM, Eric Farman wrote:
> The intention is to read the first IDAW to determine the starting
> location of an I/O operation, knowing that the second and any/all
> subsequent IDAWs will be aligned per architecture. But, this read
> receives 64-bits of data, which is the size of a Format-2 IDAW.
> 
> In the event that Format-1 IDAWs are presented, adjust the size
> of the read to 32-bits. The data will end up occupying the upper
> word of the target iova variable, so shift it down to the lower
> word for use as an adddress. (By definition, this IDAW format
> uses a 31-bit address, so the "sign" bit will always be off and
> there is no concern about sign extension.)
> 
> Signed-off-by: Eric Farman <farman@linux.ibm.com>
> ---
>  drivers/s390/cio/vfio_ccw_cp.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/s390/cio/vfio_ccw_cp.c b/drivers/s390/cio/vfio_ccw_cp.c
> index 9d74e0b74da7..29d1e418b2e2 100644
> --- a/drivers/s390/cio/vfio_ccw_cp.c
> +++ b/drivers/s390/cio/vfio_ccw_cp.c
> @@ -509,6 +509,7 @@ static int ccw_count_idaws(struct ccw1 *ccw,
>  	struct vfio_device *vdev =
>  		&container_of(cp, struct vfio_ccw_private, cp)->vdev;
>  	u64 iova;
> +	int size = cp->orb.cmd.c64 ? sizeof(u64) : sizeof(u32);
>  	int ret;
>  	int bytes = 1;
>  
> @@ -516,11 +517,15 @@ static int ccw_count_idaws(struct ccw1 *ccw,
>  		bytes = ccw->count;
>  
>  	if (ccw_is_idal(ccw)) {
> -		/* Read first IDAW to see if it's 4K-aligned or not. */
> -		/* All subsequent IDAws will be 4K-aligned. */
> -		ret = vfio_dma_rw(vdev, ccw->cda, &iova, sizeof(iova), false);
> +		/* Read first IDAW to check its starting address. */
> +		/* All subsequent IDAWs will be 2K- or 4K-aligned. */
> +		ret = vfio_dma_rw(vdev, ccw->cda, &iova, size, false);
>  		if (ret)
>  			return ret;
> +
> +		/* Format-1 IDAWs only occupy the first int */

nit: s/int/32 bits/

Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com>

> +		if (!cp->orb.cmd.c64)
> +			iova = iova >> 32;
>  	} else {
>  		iova = ccw->cda;
>  	}


  reply	other threads:[~2022-12-20 17:25 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-20 17:09 [PATCH v2 00/16] vfio/ccw: channel program cleanup Eric Farman
2022-12-20 17:09 ` [PATCH v2 01/16] vfio/ccw: cleanup some of the mdev commentary Eric Farman
2022-12-20 17:09 ` [PATCH v2 02/16] vfio/ccw: simplify the cp_get_orb interface Eric Farman
2022-12-20 17:09 ` [PATCH v2 03/16] vfio/ccw: allow non-zero storage keys Eric Farman
2022-12-20 17:09 ` [PATCH v2 04/16] vfio/ccw: move where IDA flag is set in ORB Eric Farman
2022-12-20 17:09 ` [PATCH v2 05/16] vfio/ccw: replace copy_from_iova with vfio_dma_rw Eric Farman
2022-12-20 17:09 ` [PATCH v2 06/16] vfio/ccw: simplify CCW chain fetch routines Eric Farman
2022-12-20 17:09 ` [PATCH v2 07/16] vfio/ccw: remove unnecessary malloc alignment Eric Farman
2022-12-20 17:22   ` Matthew Rosato
2022-12-20 17:10 ` [PATCH v2 08/16] vfio/ccw: pass page count to page_array struct Eric Farman
2022-12-20 17:10 ` [PATCH v2 09/16] vfio/ccw: populate page_array struct inline Eric Farman
2022-12-20 17:10 ` [PATCH v2 10/16] vfio/ccw: refactor the idaw counter Eric Farman
2022-12-20 17:10 ` [PATCH v2 11/16] vfio/ccw: read only one Format-1 IDAW Eric Farman
2022-12-20 17:24   ` Matthew Rosato [this message]
2022-12-20 17:10 ` [PATCH v2 12/16] vfio/ccw: calculate number of IDAWs regardless of format Eric Farman
2022-12-20 17:10 ` [PATCH v2 13/16] vfio/ccw: allocate/populate the guest idal Eric Farman
2022-12-20 17:45   ` Matthew Rosato
2022-12-20 17:10 ` [PATCH v2 14/16] vfio/ccw: handle a guest Format-1 IDAL Eric Farman
2022-12-20 17:10 ` [PATCH v2 15/16] vfio/ccw: don't group contiguous pages on 2K IDAWs Eric Farman
2022-12-20 17:10 ` [PATCH v2 16/16] vfio/ccw: remove old IDA format restrictions Eric Farman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d3f130b3-5196-6a02-9b6b-162c3082396b@linux.ibm.com \
    --to=mjrosato@linux.ibm.com \
    --cc=agordeev@linux.ibm.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=farman@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=oberpar@linux.ibm.com \
    --cc=pasic@linux.ibm.com \
    --cc=svens@linux.ibm.com \
    --cc=vneethv@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox