xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Stefano Stabellini <sstabellini@kernel.org>,
	Jan Beulich <JBeulich@suse.com>
Cc: "Juergen Gross" <jgross@suse.com>,
	JulienGrall <julien.grall@arm.com>,
	Xen-devel <xen-devel@lists.xen.org>,
	"Wei Liu" <wei.liu2@citrix.com>,
	"Roger Pau Monné" <roger.pau@citrix.com>
Subject: Re: [PATCH RFC] xen/evtchn: Implement EVTCHNOP_send_imm as a companian to EVTCHNOP_send
Date: Mon, 17 Jul 2017 23:54:52 +0100	[thread overview]
Message-ID: <09d87bd7-d3a4-103a-84d7-490ecd419bb7@citrix.com> (raw)
In-Reply-To: <alpine.DEB.2.10.1707171116510.5713@sstabellini-ThinkPad-X260>

On 17/07/2017 19:30, Stefano Stabellini wrote:
> On Fri, 14 Jul 2017, Jan Beulich wrote:
>>>>> On 13.07.17 at 09:50, <andrew.cooper3@citrix.com> wrote:
>>> --- a/xen/common/event_channel.c
>>> +++ b/xen/common/event_channel.c
>>> @@ -1098,6 +1098,10 @@ long do_event_channel_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
>>>          break;
>>>      }
>>>  
>>> +    case EVTCHNOP_send_imm:
>>> +        rc = evtchn_send(current->domain, (unsigned long)arg.p);
>> Two more things: For one this discards the upper half of the 64-bit
>> handle. I'd suggest you instead check it to be zero.
> +1, keeping in mind that arg will be 32-bit on ARM32 platforms and
> 64-bit on ARM64 platforms.
>
> Moreover, evtchn_send takes an unsigned int as argument, why are you
> casting arg.p to (unsigned long)?

Because arg.p is a pointer, and casting that to an unsigned int will
break on 64bit builds.  (IIRC, GCC tolerates casting a pointer to an
integer of suitable width, but not if a truncation would happen).

It probably wants to be:

uintptr_t port = (uintptr_t)arg.p;

if ( port > (evtchn_port_t)-1 )
    fail;

to be properly within the C spec.

~Andrew

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

      reply	other threads:[~2017-07-17 22:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-13  7:50 [PATCH RFC] xen/evtchn: Implement EVTCHNOP_send_imm as a companian to EVTCHNOP_send Andrew Cooper
2017-07-13  9:44 ` Paul Durrant
2017-07-13 10:14 ` Juergen Groß
2017-07-13 12:04   ` Wei Liu
2017-07-13 19:36 ` Jan Beulich
2017-07-14  7:35   ` Paul Durrant
2017-07-14 10:57 ` Jan Beulich
2017-07-17 18:30   ` Stefano Stabellini
2017-07-17 22:54     ` Andrew Cooper [this message]

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=09d87bd7-d3a4-103a-84d7-490ecd419bb7@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=jgross@suse.com \
    --cc=julien.grall@arm.com \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.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;
as well as URLs for NNTP newsgroup(s).