mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Jürgen Groß" <jgross@suse.com>
To: Andrew Cooper <amc96@cam.ac.uk>,
	boris.ostrovsky@oracle.com,
	Roger Pau Monne <roger.pau@citrix.com>,
	linux-kernel@vger.kernel.org
Cc: Stefano Stabellini <sstabellini@kernel.org>,
	Paul Durrant <paul.durrant@citrix.com>,
	xen-devel@lists.xenproject.org,
	Andrew Cooper <andrew.cooper3@citrix.com>
Subject: Re: [PATCH] xen/privcmd: allow fetching resource sizes
Date: Tue, 12 Jan 2021 06:50:09 +0100	[thread overview]
Message-ID: <22da01ad-a345-75b9-5f2d-6f8958f31749@suse.com> (raw)
In-Reply-To: <ed089f3f-4950-f3e9-6df6-07ca9148e6a6@cam.ac.uk>


[-- Attachment #1.1.1: Type: text/plain, Size: 1802 bytes --]

On 11.01.21 23:39, Andrew Cooper wrote:
> On 11/01/2021 22:09, boris.ostrovsky@oracle.com wrote:
>> On 1/11/21 10:29 AM, Roger Pau Monne wrote:
>>>   
>>> +	xdata.domid = kdata.dom;
>>> +	xdata.type = kdata.type;
>>> +	xdata.id = kdata.id;
>>> +
>>> +	if (!kdata.addr && !kdata.num) {
>>
>> I think we should not allow only one of them to be zero. If it's only kdata.num then we will end up with pfns array set to ZERO_SIZE_PTR (which is 0x10). We seem to be OK in that we are not derefencing pfns (either in kernel or in hypervisor) if number of frames is zero but IMO we shouldn't be tempting the fate.
>>
>>
>> (And if it's only kdata.addr then we will get a vma but I am not sure it will do what we want.)
> 
> Passing addr == 0 without num being 0 is already an error in Xen, and
> passing num == 0 without addr being 0 is bogus and will be an error by
> the time I'm finished fixing this.
> 
> FWIW, the common usecase for non-trivial examples will be:
> 
> xenforeignmem_resource_size(domid, type, id, &size);
> xenforeignmem_map_resource(domid, type, id, NULL, size, ...);
> 
> which translates into:
> 
> ioctl(MAP_RESOURCE, NULL, 0) => size
> mmap(NULL, size, ...) => ptr
> ioctl(MAP_RESOURCE, ptr, size)
> 
> from the kernels point of view, and two hypercalls from Xen's point of
> view.  The NULL's above are expected to be the common case for letting
> the kernel chose the vma, but ought to be filled in by the time the
> second ioctl() occurs.
> 
> See
> https://lore.kernel.org/xen-devel/20200922182444.12350-1-andrew.cooper3@citrix.com/T/#u
> for all the gory details.

I don't think the kernel should rely on the hypervisor to return
an error in case addr != 0 and num == 0.

The driver should return -EINVAL in that case IMO.


Juergen

[-- Attachment #1.1.2: OpenPGP_0xB0DE9DD628BF132F.asc --]
[-- Type: application/pgp-keys, Size: 3135 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]

  reply	other threads:[~2021-01-12  5:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-11 15:29 Roger Pau Monne
2021-01-11 22:09 ` boris.ostrovsky
2021-01-11 22:39   ` Andrew Cooper
2021-01-12  5:50     ` Jürgen Groß [this message]
2021-01-12  6:01       ` Jürgen Groß
2021-01-12  5:57 ` Jürgen Groß
2021-01-12 10:03   ` Roger Pau Monné
2021-01-12 10:34     ` Jürgen Groß

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=22da01ad-a345-75b9-5f2d-6f8958f31749@suse.com \
    --to=jgross@suse.com \
    --cc=amc96@cam.ac.uk \
    --cc=andrew.cooper3@citrix.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paul.durrant@citrix.com \
    --cc=roger.pau@citrix.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®