From patchwork Fri Oct 11 14:36:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 3024671 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C0526BF924 for ; Fri, 11 Oct 2013 14:36:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 902712014B for ; Fri, 11 Oct 2013 14:36:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5F0082011D for ; Fri, 11 Oct 2013 14:36:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755106Ab3JKOg3 (ORCPT ); Fri, 11 Oct 2013 10:36:29 -0400 Received: from service87.mimecast.com ([91.220.42.44]:46580 "EHLO service87.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753445Ab3JKOgY (ORCPT ); Fri, 11 Oct 2013 10:36:24 -0400 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Fri, 11 Oct 2013 15:36:22 +0100 Received: from e102391-lin.cambridge.arm.com ([10.1.255.212]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.0); Fri, 11 Oct 2013 15:36:21 +0100 From: Marc Zyngier To: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org Cc: Rusty Russell , "Michael S. Tsirkin" , Pawel Moll Subject: [PATCH 1/3] virtio: let the guest report its endianess if advertized by the host Date: Fri, 11 Oct 2013 15:36:09 +0100 Message-Id: <1381502171-8187-2-git-send-email-marc.zyngier@arm.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1381502171-8187-1-git-send-email-marc.zyngier@arm.com> References: <1381502171-8187-1-git-send-email-marc.zyngier@arm.com> X-OriginalArrivalTime: 11 Oct 2013 14:36:21.0400 (UTC) FILETIME=[41082980:01CEC68F] X-MC-Unique: 113101115362203201 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In order for a guest to report its endianess, we introduce a pair of per-ring flags: VIRTIO_RING_F_GUEST_{LE,BE}. A host is allowed to advertise support for either or both endianess for this ring. If it advertises none, it is assumed to be able to handle the guest (best effort). A guest is allowed to select one of the endiannesses advertised by the host (but obviously not both). If none is selected, it is assumed to be of an endianness compatible with the host (best effort). This mechanism allows the host to deal with guests of different endiannesses. Cc: Rusty Russell Cc: Michael S. Tsirkin Cc: Pawel Moll Signed-off-by: Marc Zyngier --- drivers/virtio/virtio_ring.c | 8 ++++++++ include/uapi/linux/virtio_ring.h | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 6b4a4db..efff20a 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -813,6 +813,14 @@ void vring_transport_features(struct virtio_device *vdev) break; case VIRTIO_RING_F_EVENT_IDX: break; +#ifdef __LITTLE_ENDIAN + case VIRTIO_RING_F_GUEST_LE: + break; +#endif +#ifdef __BIG_ENDIAN + case VIRTIO_RING_F_GUEST_BE: + break; +#endif default: /* We don't understand this bit. */ clear_bit(i, vdev->features); diff --git a/include/uapi/linux/virtio_ring.h b/include/uapi/linux/virtio_ring.h index a99f9b7..496b46a 100644 --- a/include/uapi/linux/virtio_ring.h +++ b/include/uapi/linux/virtio_ring.h @@ -58,6 +58,14 @@ * at the end of the used ring. Guest should ignore the used->flags field. */ #define VIRTIO_RING_F_EVENT_IDX 29 +/* The Host can advertise to support either or both endianness for the vring. + * If it advertise none, it is assumed to be able to handle the Guest + * endianness. + * The Guest can select either (but not both) endianness. If it selects none, + * it is assumed to be of an endianness compatible with the Host. */ +#define VIRTIO_RING_F_GUEST_LE 30 +#define VIRTIO_RING_F_GUEST_BE 31 + /* Virtio ring descriptors: 16 bytes. These can chain together via "next". */ struct vring_desc { /* Address (guest-physical). */