All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: jiangyiwen <jiangyiwen@huawei.com>
Cc: kvm@vger.kernel.org, mst@redhat.com, netdev@vger.kernel.org,
	virtualization@lists.linux-foundation.org,
	David Miller <davem@davemloft.net>
Subject: Re: [PATCH v2 2/5] VSOCK: support fill data to mergeable rx buffer in host
Date: Thu, 13 Dec 2018 15:46:16 +0000	[thread overview]
Message-ID: <20181213154616.GM23318__30347.2854699523$1544715881$gmane$org@stefanha-x1.localdomain> (raw)
In-Reply-To: <5C120D69.10201@huawei.com>


[-- Attachment #1.1: Type: text/plain, Size: 1792 bytes --]

On Thu, Dec 13, 2018 at 03:42:33PM +0800, jiangyiwen wrote:
> On 2018/12/13 13:59, David Miller wrote:
> > From: jiangyiwen <jiangyiwen@huawei.com>
> > Date: Thu, 13 Dec 2018 11:11:48 +0800
> > 
> >> I hope Host can fill fewer bytes into rx virtqueue, so
> >> I keep structure virtio_vsock_mrg_rxbuf_hdr one byte
> >> alignment.
> > 
> > The question is if this actully matters.
> > 
> > Do you know?
> > 
> > If the obejct this is embeeded inside of is at least 2 byte aligned,
> > you are marking it packed for nothing.
> > 
> > There are only %100 downsides to using the packed attribute.
> > 
> > Simply define your datastructures properly, with fixed sized types,
> > and all padding defined explicitly.
> > 
> > .
> > 
> 
> Hi David,
> 
> Thanks a lot, I need to send number buffers from Host to Guest, so I think
> we need to keep the structure size the same between host and guest.
> But after your reminder, I feel my code may exist a serious problem,
> that in mergeable mode, I send the total structure virtio_vsock_pkt
> from Host to Guest, however, this structure size may be different
> under different compilers (Guest and Host are different). Then, Guest
> may parse the wrong packet length.
> 
> David, I want to ask if there is such a problem?
> 
> In addition, why I send total virtio_vsock_pkt structure from Host to Guest?
> - In order to avoid to allocate virtio_vsock_pkt memory when receiving
>   packets, in case of insufficient memory, it may have some advantages, and
>   we may keep consistent with old version.

Yes, virtio_vsock_pkt is internal driver state and should not be part of
the host<->guest interface (also for security reasons it's not good to
expose internal state structs across the interface).

Stefan

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

[-- Attachment #2: Type: text/plain, Size: 183 bytes --]

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

  reply	other threads:[~2018-12-13 15:46 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-12  9:29 [PATCH v2 2/5] VSOCK: support fill data to mergeable rx buffer in host jiangyiwen
2018-12-12 15:37 ` Michael S. Tsirkin
2018-12-12 15:37 ` Michael S. Tsirkin
2018-12-13  3:08   ` jiangyiwen
2018-12-13 14:48     ` Michael S. Tsirkin
2018-12-13 14:48     ` Michael S. Tsirkin
2018-12-14  7:41       ` jiangyiwen
2018-12-14  7:41       ` jiangyiwen
2018-12-13 15:49     ` Stefan Hajnoczi
2018-12-14  7:49       ` jiangyiwen
2018-12-14  7:49       ` jiangyiwen
2018-12-13 15:49     ` Stefan Hajnoczi
2018-12-12 19:09 ` David Miller
2018-12-12 19:09 ` David Miller
2018-12-13  3:11   ` jiangyiwen
2018-12-13  3:11   ` jiangyiwen
2018-12-13  5:59     ` David Miller
2018-12-13  5:59     ` David Miller
2018-12-13  7:42       ` jiangyiwen
2018-12-13  7:42       ` jiangyiwen
2018-12-13 15:46         ` Stefan Hajnoczi [this message]
2018-12-13 15:46         ` Stefan Hajnoczi
2018-12-13 14:50     ` Michael S. Tsirkin
2018-12-14  7:47       ` jiangyiwen
2018-12-14  7:47       ` jiangyiwen
2018-12-13 14:50     ` Michael S. Tsirkin
  -- strict thread matches above, loose matches on Subject: below --
2018-12-12  9:29 jiangyiwen

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='20181213154616.GM23318__30347.2854699523$1544715881$gmane$org@stefanha-x1.localdomain' \
    --to=stefanha@redhat.com \
    --cc=davem@davemloft.net \
    --cc=jiangyiwen@huawei.com \
    --cc=kvm@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=virtualization@lists.linux-foundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.