From: Juergen Gross <jgross@suse.com>
To: Oleksandr Tyshchenko <olekstysh@gmail.com>,
Xenia Ragiadakou <burzalodowa@gmail.com>
Cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org,
Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>,
Stefano Stabellini <sstabellini@kernel.org>
Subject: Re: [PATCH 1/2] xen/virtio: Fix n_pages calculation in xen_grant_dma_map(unmap)_page()
Date: Thu, 6 Oct 2022 12:24:20 +0200 [thread overview]
Message-ID: <df17af24-632c-6087-43e0-9e4079959437@suse.com> (raw)
In-Reply-To: <CAPD2p-kuXfeQ8G63tSwi4H1Wz8ygwJnp3q1ZXFHi+k+knwT-EA@mail.gmail.com>
[-- Attachment #1.1.1: Type: text/plain, Size: 2665 bytes --]
On 06.10.22 12:14, Oleksandr Tyshchenko wrote:
>
>
> On Thu, Oct 6, 2022 at 11:05 AM Juergen Gross <jgross@suse.com
> <mailto:jgross@suse.com>> wrote:
>
> On 06.10.22 09:35, Xenia Ragiadakou wrote:
>
>
>
> Hello Xenia, Juergen
>
> [sorry for the possible format issues]
>
> >
> > On 10/5/22 20:48, Oleksandr Tyshchenko wrote:
> >> From: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com
> <mailto:oleksandr_tyshchenko@epam.com>>
> >>
> >> Take page offset into the account when calculating the number of pages
> >> to be granted.
> >>
> >> Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com
> <mailto:oleksandr_tyshchenko@epam.com>>
> >> Fixes: d6aca3504c7d ("xen/grant-dma-ops: Add option to restrict memory
> access
> >> under Xen")
> >> ---
> >> drivers/xen/grant-dma-ops.c | 5 +++--
> >> 1 file changed, 3 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/drivers/xen/grant-dma-ops.c b/drivers/xen/grant-dma-ops.c
> >> index 8973fc1e9ccc..1998d0e8ce82 100644
> >> --- a/drivers/xen/grant-dma-ops.c
> >> +++ b/drivers/xen/grant-dma-ops.c
> >> @@ -153,7 +153,7 @@ static dma_addr_t xen_grant_dma_map_page(struct device
> >> *dev, struct page *page,
> >> unsigned long attrs)
> >> {
> >> struct xen_grant_dma_data *data;
> >> - unsigned int i, n_pages = PFN_UP(size);
> >> + unsigned int i, n_pages = PFN_UP(offset + size);
> >
> > Here, why do we use PFN_UP and not XEN_PFN_UP?
> > Also, since the variable 'n_pages' seems to refer to the number of grants
> > (unless I got it all entirely wrong ...), wouldn't it be more suitable to
> call
> > explicitly gnttab_count_grant()?
>
> Good point.
>
>
> +1
>
>
> I think this will need another patch for switching grant-dma-ops.c to
> use XEN_PAGE_SIZE and XEN_PAGE_SHIFT.
>
>
> +1
>
> I can create a separate patch for converting on top of this series, it would be
> nice to clarify one point.
>
> So I will convert PAGE_SIZE/PAGE_SHIFT to XEN_PAGE_SIZE/XEN_PAGE_SHIFT
> respectively (where appropriate).
Yes, that would be the idea.
> Should the PFN_UP be converted to XEN_PFN_UP *or* use
> gnttab_count_grant() explicitly? Personally I would prefer the former, but would
> also be ok with the latter.
I agree XEN_PFN_UP would be better, especially as XEN_PAGE_SIZE/XEN_PAGE_SHIFT
will be used in the same functions.
Juergen
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3149 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]
next prev parent reply other threads:[~2022-10-06 10:24 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-05 17:48 [PATCH 0/2] Misc fixes for Xen grant DMA-mapping layer Oleksandr Tyshchenko
2022-10-05 17:48 ` [PATCH 1/2] xen/virtio: Fix n_pages calculation in xen_grant_dma_map(unmap)_page() Oleksandr Tyshchenko
2022-10-06 0:07 ` Stefano Stabellini
2022-10-06 5:06 ` Juergen Gross
2022-10-06 7:35 ` Xenia Ragiadakou
2022-10-06 8:05 ` Juergen Gross
[not found] ` <CAPD2p-kuXfeQ8G63tSwi4H1Wz8ygwJnp3q1ZXFHi+k+knwT-EA@mail.gmail.com>
2022-10-06 10:24 ` Juergen Gross [this message]
2022-10-05 17:48 ` [PATCH 2/2] xen/virtio: Fix potential deadlock when accessing xen_grant_dma_devices Oleksandr Tyshchenko
2022-10-06 0:19 ` Stefano Stabellini
2022-10-06 5:08 ` Juergen Gross
2022-10-07 5:19 ` [PATCH 0/2] Misc fixes for Xen grant DMA-mapping layer Juergen Gross
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=df17af24-632c-6087-43e0-9e4079959437@suse.com \
--to=jgross@suse.com \
--cc=burzalodowa@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oleksandr_tyshchenko@epam.com \
--cc=olekstysh@gmail.com \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.org \
/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
all inboxes | Powered by JetHome®