qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Halil Pasic <pasic@linux.vnet.ibm.com>
To: "Gonglei (Arei)" <arei.gonglei@huawei.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"virtio-dev@lists.oasis-open.org"
	<virtio-dev@lists.oasis-open.org>
Cc: "Huangweidong (C)" <weidong.huang@huawei.com>,
	"stefanha@redhat.com" <stefanha@redhat.com>,
	"Hanweidong (Randy)" <hanweidong@huawei.com>,
	Claudio Fontana <Claudio.Fontana@huawei.com>,
	"mst@redhat.com" <mst@redhat.com>,
	Luonengjun <luonengjun@huawei.com>,
	"xin.zeng@intel.com" <xin.zeng@intel.com>,
	"agraf@suse.de" <agraf@suse.de>,
	"mike.caraman@nxp.com" <mike.caraman@nxp.com>,
	"nmorey@kalray.eu" <nmorey@kalray.eu>,
	"Zhoujian (jay, Euler)" <jianjay.zhou@huawei.com>,
	"pbonzini@redhat.com" <pbonzini@redhat.com>,
	"Huangpeng (Peter)" <peter.huangpeng@huawei.com>,
	"vincent.jardin@6wind.com" <vincent.jardin@6wind.com>,
	"Wubin (H)" <wu.wubin@huawei.com>,
	"arei.gonglei@hotmail.com" <arei.gonglei@hotmail.com>
Subject: Re: [Qemu-devel] [PATCH v9 00/12] virtio-crypto: introduce framework and device emulation
Date: Wed, 2 Nov 2016 18:34:51 +0100	[thread overview]
Message-ID: <fe72b9d0-9d82-f532-73c0-f444d7d4578f@linux.vnet.ibm.com> (raw)
In-Reply-To: <33183CC9F5247A488A2544077AF19020B0410E38@SZXEMA503-MBS.china.huawei.com>



On 10/31/2016 03:52 AM, Gonglei (Arei) wrote:
>> > Unfortunately I encountered a problem already on x86_64, more precisely
>> > the guest hangs in virtio_crypto_alg_ablkcipher_init_session after the
>> > kick. But before I start explaining in detail let me ask you: what are
>> > your plans for the linux kernel driver? I used the most current version
>> > from your github, but also tried to look for patches on mailing lists
>> > and I have found none. 
> I haven't submit the virtio-crypto driver to the mailing list yet cause
> I wanted to the patches on the QEMU side can be merged firstly,
> and then focus to the frontend driver.
> 

That is fine and the QEMU stuff does look good :). I'm still curious
about your road map that is what should I expect on the kernel side
and when? You could also cc me ;) when sending to the list.

>> > IMHO the problem causing my hang is in the kernel
>> > module. But I do not know here am I supposed to comment on it -- so I'm
>> > commenting here. Furthermore your kernel module currently do not seem to
>> > care about endianness which is bad for s390x.
>> > 
> That's true.
> 

For the sake of the experiment I have reworked 
virtio_crypto_alg_ablkcipher_init_session so that id does care
about the endianness of the guest. With that the functions seems
to work on s390x (but of course the next byte order problem warrants
that encryption/decryption does not work yet). It is not beautiful
but I can give you a patch if you want.

>> > The hangs  basically boils down to the following: after the kick in
>> > virtio_crypto_alg_ablkcipher_init_session we reach the point (in QEMU)
>> > where we want to translate the address for the third descriptor, the one
>> > which designates a buffer for the virtio_crypto_session_input. My
>> > backtrace looks like this:
>> > 
>> > 
>> > #0  address_space_translate (as=<optimized out>,
>> > as@entry=0x55555607d700 <address_space_memory>,
>> > addr=addr@entry=71468256835928, xlat=xlat@entry=0x7fffef4dc1a0,
>> > plen=plen@entry=0x7fffef4dc198, is_write=is_write@entry=true)
>> >     at /home/pasic/devel/qemu/exec.c:481
>> > #1  0x000055555575ef19 in address_space_map (as=0x55555607d700
>> > <address_space_memory>, addr=71468256835928, plen=<optimized out>,
>> > is_write=<optimized out>) at /home/pasic/devel/qemu/exec.c:2927
>> > #2  0x00005555557e5d00 in virtqueue_map_desc (vdev=0x555557d80de0,
>> > p_num_sg=0x7fffef4dc2bc, addr=0x7fffef4dc2f0, iov=0x7fffef4de300,
>> > max_num_sg=1022, is_write=true, pa=71468256835928, sz=16)
>> >     at /home/pasic/devel/qemu/hw/virtio/virtio.c:558
>> > #3  0x00005555557e5f86 in virtqueue_pop (vq=0x7fffef4dc2c0,
>> > sz=93825003936576) at /home/pasic/devel/qemu/hw/virtio/virtio.c:717
>> > #4  0x00005555557ed80b in virtio_crypto_handle_ctrl (vdev=<optimized out>,
>> > vq=0x7fffeec3e090) at /home/pasic/devel/qemu/hw/virtio/virtio-crypto.c:218
>> > 
>> > Now the first suspicious thing I see is that address_space_translate
>> > returns a pointer to the memory region io_mem_unassigned. Next thing
>> > happening is that we take the !memory_access_is_direct(mr, is_write)
>> > branch in address_space_map and return NULL at line 2932 which however
>> > makes  virtqueue_map_desc report "qemu-system-x86_64: virtio: bogus
>> > descriptor or out of resources" and return with false. Then pop returns
>> > null too and spins virtio_crypto_alg_ablkcipher_init_session till the
>> > end of time waiting for the answer.
>> > 
> It seems that the frontend driver passed a invalid gpa to the QEMU side,
> The Qemu side will invokes virtio_error() to notify the guest to reset the
> device.
> 

I did not say previously but I have checked and the gpa is good, that
is it has a correct offset in respect to ctrl's gpa (the next variable
on stack, which is the previous desc.addr used read only) which is good.
Furthermore the issue seems to be platform dependent as I do not see this
on s390x.

>> > Now if I change the code so that the virtio_crypto_session_input
>> > instance's backing memory is allocated with  kzalloc(sizeof(*input),
>> > GFP_DMA|GFP_NOIO) of allocating the on the stack things start working
>> > for me. I'm not too deep into this yet, so please forgive me if
>> > I'm a bit vague.
>> > 
> Good, maybe you find a bug of the frontend driver. Using stack memory
> might not be a good idea ;)
> 

Yeah, as I said, can't say (that is my understanding too shallow).

Cheers,
Halil

  parent reply	other threads:[~2016-11-02 17:35 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-20 11:45 [Qemu-devel] [PATCH v9 00/12] virtio-crypto: introduce framework and device emulation Gonglei
2016-10-20 11:45 ` [Qemu-devel] [PATCH v9 01/12] cryptodev: introduce cryptodev backend interface Gonglei
2016-10-20 11:45 ` [Qemu-devel] [PATCH v9 02/12] cryptodev: add symmetric algorithm operation stuff Gonglei
2016-10-20 11:45 ` [Qemu-devel] [PATCH v9 03/12] virtio-crypto: introduce virtio_crypto.h Gonglei
2016-10-20 11:45 ` [Qemu-devel] [PATCH v9 04/12] cryptodev: introduce a new cryptodev backend Gonglei
2016-10-20 11:45 ` [Qemu-devel] [PATCH v9 05/12] virtio-crypto: add virtio crypto device emulation Gonglei
2016-10-20 11:45 ` [Qemu-devel] [PATCH v9 06/12] virtio-crypto-pci: add virtio crypto pci support Gonglei
2016-10-20 11:45 ` [Qemu-devel] [PATCH v9 07/12] virtio-crypto: set capacity of algorithms supported Gonglei
2016-10-20 11:45 ` [Qemu-devel] [PATCH v9 08/12] virtio-crypto: add control queue handler Gonglei
2016-10-20 11:45 ` [Qemu-devel] [PATCH v9 09/12] virtio-crypto: add data queue processing handler Gonglei
2016-10-27 16:59   ` Michael S. Tsirkin
2016-10-28  0:50     ` [Qemu-devel] [virtio-dev] " Gonglei (Arei)
2016-10-20 11:45 ` [Qemu-devel] [PATCH v9 10/12] cryptodev: introduce an unified wrapper for crypto operation Gonglei
2016-10-20 11:45 ` [Qemu-devel] [PATCH v9 11/12] virtio-crypto: using bh to handle dataq's requests Gonglei
2016-10-20 11:45 ` [Qemu-devel] [PATCH v9 12/12] virtio-crypto: add myself as virtio-crypto and cryptodev backends maintainer Gonglei
2016-10-20 12:25 ` [Qemu-devel] [PATCH v9 00/12] virtio-crypto: introduce framework and device emulation no-reply
2016-10-27  8:03   ` Gonglei (Arei)
2016-10-25 11:20 ` Gonglei (Arei)
2016-10-25 16:50   ` Michael S. Tsirkin
2016-10-26  0:54     ` [Qemu-devel] [virtio-dev] " Gonglei (Arei)
2016-10-27 16:12       ` Michael S. Tsirkin
2016-10-30 20:00 ` [Qemu-devel] " Halil Pasic
2016-10-31  2:52   ` Gonglei (Arei)
2016-10-31  9:41     ` Cornelia Huck
2016-11-02 17:34     ` Halil Pasic [this message]
2016-11-04  2:49       ` Gonglei (Arei)

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=fe72b9d0-9d82-f532-73c0-f444d7d4578f@linux.vnet.ibm.com \
    --to=pasic@linux.vnet.ibm.com \
    --cc=Claudio.Fontana@huawei.com \
    --cc=agraf@suse.de \
    --cc=arei.gonglei@hotmail.com \
    --cc=arei.gonglei@huawei.com \
    --cc=hanweidong@huawei.com \
    --cc=jianjay.zhou@huawei.com \
    --cc=luonengjun@huawei.com \
    --cc=mike.caraman@nxp.com \
    --cc=mst@redhat.com \
    --cc=nmorey@kalray.eu \
    --cc=pbonzini@redhat.com \
    --cc=peter.huangpeng@huawei.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=vincent.jardin@6wind.com \
    --cc=virtio-dev@lists.oasis-open.org \
    --cc=weidong.huang@huawei.com \
    --cc=wu.wubin@huawei.com \
    --cc=xin.zeng@intel.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;
as well as URLs for NNTP newsgroup(s).