lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87mvsk19qx.fsf@vitty.brq.redhat.com>
Date:	Tue, 05 Jan 2016 13:39:02 +0100
From:	Vitaly Kuznetsov <vkuznets@...hat.com>
To:	Dexuan Cui <decui@...rosoft.com>
Cc:	gregkh@...uxfoundation.org, davem@...emloft.net,
	stephen@...workplumber.org, netdev@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	driverdev-devel@...uxdriverproject.org, olaf@...fle.de,
	apw@...onical.com, jasowang@...hat.com, kys@...rosoft.com,
	pebolle@...cali.nl, stefanha@...hat.com, dan.carpenter@...cle.com
Subject: Re: [PATCH V5 5/9] Drivers: hv: vmbus: add APIs to send/recv hvsock packets

Dexuan Cui <decui@...rosoft.com> writes:

> This will be used by the coming net/hvsock driver.
>
> Signed-off-by: Dexuan Cui <decui@...rosoft.com>
> ---
>  drivers/hv/channel.c   | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  include/linux/hyperv.h |  9 ++++++++
>  2 files changed, 68 insertions(+)
>
> diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
> index cc49966..ce1b885 100644
> --- a/drivers/hv/channel.c
> +++ b/drivers/hv/channel.c
> @@ -924,6 +924,52 @@ int vmbus_sendpacket_multipagebuffer(struct vmbus_channel *channel,
>  }
>  EXPORT_SYMBOL_GPL(vmbus_sendpacket_multipagebuffer);
>
> +/*
> + * vmbus_sendpacket_hvsock - Send the hvsock payload 'buf' of a length 'len'
> + */
> +int vmbus_sendpacket_hvsock(struct vmbus_channel *channel, void *buf, u32 len)
> +{
> +	struct vmpipe_proto_header pipe_hdr;
> +	struct vmpacket_descriptor desc;
> +	struct kvec bufferlist[4];
> +	u32 packetlen_aligned;
> +	u32 packetlen;
> +	u64 aligned_data = 0;
> +	bool signal = false;
> +	int ret;
> +
> +	packetlen = HVSOCK_HEADER_LEN + len;
> +	packetlen_aligned = ALIGN(packetlen, sizeof(u64));
> +
> +	/* Setup the descriptor */
> +	desc.type = VM_PKT_DATA_INBAND;
> +	/* in 8-bytes granularity */
> +	desc.offset8 = sizeof(struct vmpacket_descriptor) >> 3;
> +	desc.len8 = (u16)(packetlen_aligned >> 3);
> +	desc.flags = 0;
> +	desc.trans_id = 0;
> +
> +	pipe_hdr.pkt_type = 1;
> +	pipe_hdr.data_size = len;
> +
> +	bufferlist[0].iov_base = &desc;
> +	bufferlist[0].iov_len  = sizeof(struct vmpacket_descriptor);
> +	bufferlist[1].iov_base = &pipe_hdr;
> +	bufferlist[1].iov_len  = sizeof(struct vmpipe_proto_header);
> +	bufferlist[2].iov_base = buf;
> +	bufferlist[2].iov_len  = len;
> +	bufferlist[3].iov_base = &aligned_data;
> +	bufferlist[3].iov_len  = packetlen_aligned - packetlen;
> +
> +	ret = hv_ringbuffer_write(&channel->outbound, bufferlist, 4,
> &signal);

Using ARRAY_SIZE(bufferlist) instead of 4 would allow us to keep this
line untouched when we decide to add something (and compiler will
optimize it to 4 anyway).

> +
> +	if (ret == 0 && signal)
> +		vmbus_setevent(channel);
> +
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(vmbus_sendpacket_hvsock);
> +
>  /**
>   * vmbus_recvpacket() - Retrieve the user packet on the specified channel
>   * @channel: Pointer to vmbus_channel structure.
> @@ -976,3 +1022,16 @@ int vmbus_recvpacket_raw(struct vmbus_channel *channel, void *buffer,
>  				  HV_RINGBUFFER_READ_FLAG_RAW);
>  }
>  EXPORT_SYMBOL_GPL(vmbus_recvpacket_raw);
> +
> +/*
> + * vmbus_recvpacket_hvsock - Receive the hvsock payload from the vmbus
> + * ringbuffer into the 'buffer'.
> + */
> +int vmbus_recvpacket_hvsock(struct vmbus_channel *channel, void *buffer,
> +			    u32 bufferlen, u32 *buffer_actual_len)
> +{
> +	return __vmbus_recvpacket(channel, buffer, bufferlen,
> +				  buffer_actual_len, NULL,
> +				  HV_RINGBUFFER_READ_FLAG_HVSOCK);
> +}
> +EXPORT_SYMBOL_GPL(vmbus_recvpacket_hvsock);
> diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
> index e005223..646c20d 100644
> --- a/include/linux/hyperv.h
> +++ b/include/linux/hyperv.h
> @@ -908,6 +908,9 @@ extern int vmbus_sendpacket_ctl(struct vmbus_channel *channel,
>  				  u32 flags,
>  				  bool kick_q);
>
> +extern int vmbus_sendpacket_hvsock(struct vmbus_channel *channel,
> +				   void *buf, u32 len);
> +
>  extern int vmbus_sendpacket_pagebuffer(struct vmbus_channel *channel,
>  					    struct hv_page_buffer pagebuffers[],
>  					    u32 pagecount,
> @@ -958,6 +961,9 @@ extern int vmbus_recvpacket_raw(struct vmbus_channel *channel,
>  				     u64 *requestid);
>
> +extern int vmbus_recvpacket_hvsock(struct vmbus_channel *channel, void *buffer,
> +				   u32 bufferlen, u32 *buffer_actual_len);
> +
>  extern void vmbus_ontimer(unsigned long data);
>
>  /* Base driver object */
> @@ -1280,4 +1286,7 @@ struct vmpipe_proto_header {
>  	};
>  } __packed;
>
> +#define HVSOCK_HEADER_LEN	(sizeof(struct vmpacket_descriptor) + \
> +				 sizeof(struct vmpipe_proto_header))
> +
>  #endif /* _HYPERV_H */

-- 
  Vitaly
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ