From patchwork Wed Jun 12 12:34:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Tsirakis X-Patchwork-Id: 10989825 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DC8F976 for ; Wed, 12 Jun 2019 12:36:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C666328A05 for ; Wed, 12 Jun 2019 12:36:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B72C828A12; Wed, 12 Jun 2019 12:36:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3317D28A05 for ; Wed, 12 Jun 2019 12:36:47 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hb2TM-0006Op-3d; Wed, 12 Jun 2019 12:35:24 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hb2TK-0006Oj-UD for xen-devel@lists.xenproject.org; Wed, 12 Jun 2019 12:35:22 +0000 X-Inumbo-ID: 8b056b2a-8d0e-11e9-8980-bc764e045a96 Received: from mail-qt1-x844.google.com (unknown [2607:f8b0:4864:20::844]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 8b056b2a-8d0e-11e9-8980-bc764e045a96; Wed, 12 Jun 2019 12:35:21 +0000 (UTC) Received: by mail-qt1-x844.google.com with SMTP id x47so18262824qtk.11 for ; Wed, 12 Jun 2019 05:35:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2a6XZx9xgsw8kOJxsWXYh5kBadD14RGl5iKLKSprIQc=; b=GFvzogg+albm3Tgak6euGsWijtFcQTKujdW2vV+ur8Z77r/2992sOjCUjNHrvrvZVs Rsr4B1VVgEsOm29ieGl2mTPieHaBjf1d4V93R5GDYwRU/+zedL0Ag7A7Ze9NCfNeHW0Z MsbqwoORJR4xWNJLzr5Bpy1hDKg//6292kKXIEoksucUqG7itHow/XMkxXm6qg13QUl8 lDadK49hSdvKBFL2Eu3u4rsgQZp5MbuzJGVvOQVFGBVvTCCF1iIuQ6f4ohtd59Pzg1qx bDzsWgAOMfTCITiTIQ0fAFWsx0lnMMjzGqw9u4taTvLy6osixm4g9FYmBWT4mo8uBZ0H BzkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2a6XZx9xgsw8kOJxsWXYh5kBadD14RGl5iKLKSprIQc=; b=oCmyAuvof6s4S1Gznj5c0MSDrot6tWVugSjlZ+3dupgLxDFikOK1R9nCBb1MNYpPsC 1snaC4MQJK+GkhsYWbHaKbqOVfCdqR33ukvRDn+x+y6O28pp3XFRksktrNRkjZfHDu1e kaUEQ1muO6aEAnMVvKlkOyiNgJVhLCaq1ny+Ba8vMhM1JiItBnSS+K7eV2Gpxa4fJWPp EJYMHOixpfEhjRNm324HNIgaUXU6ZulYFPrgnGqtxoJguJ6bqbxdI4eiSfbB2y56o7Zu Ss1dWk0f06yZdew4Xx8IZMCH1pRbsde3G/QC8k94YmbqwlbeV++K4mTjv7Gv5tTPzmw0 amog== X-Gm-Message-State: APjAAAXG5LM0R+alsoo+MhemWlItu4CdbfmQbk1w3DJ0ihO46TkYGq7N rBNRj+pyajqYzqH1YPqyf6GFkYlcuJ0= X-Google-Smtp-Source: APXvYqy5fTI6zsY5NcKFg6beqVIAzDDdlX5IO6ZRJ5EZfHfqLhYVJjn0IWSWeiGwgCbB7OY4y3XVUg== X-Received: by 2002:ac8:3a63:: with SMTP id w90mr68662115qte.371.1560342920756; Wed, 12 Jun 2019 05:35:20 -0700 (PDT) Received: from niko-Latitude-E7470.fios-router.home (pool-108-54-183-56.nycmny.fios.verizon.net. [108.54.183.56]) by smtp.gmail.com with ESMTPSA id o38sm9442666qto.96.2019.06.12.05.35.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Jun 2019 05:35:20 -0700 (PDT) From: Nicholas Tsirakis X-Google-Original-From: Nicholas Tsirakis To: xen-devel@lists.xenproject.org Date: Wed, 12 Jun 2019 08:34:45 -0400 Message-Id: <7dafb0d7608ca1d245967382da5eb2e6cbe2c5b6.1560342869.git.tsirakisn@ainfosec.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v3 2/2] argo: correctly report pending message length X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Nicholas Tsirakis , Christopher Clark MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP When a message is requeue'd in Xen's internal queue, the queue entry contains the length of the message so that Xen knows to send a VIRQ to the respective domain when enough space frees up in the ring. Due to a small bug, however, Xen doesn't populate the length of the msg if a given write fails, so this length is always reported as zero. This causes Xen to spurriously wake up a domain even when the ring doesn't have enough space. This patch makes sure that the msg len is properly reported by populating it in the event of a write failure. Signed-off-by: Nicholas Tsirakis Reviewed-by: Christopher Clark --- xen/common/argo.c | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/xen/common/argo.c b/xen/common/argo.c index 2f874a570d..c8f4302963 100644 --- a/xen/common/argo.c +++ b/xen/common/argo.c @@ -765,27 +765,20 @@ iov_count(const xen_argo_iov_t *piov, unsigned int niov, static int ringbuf_insert(const struct domain *d, struct argo_ring_info *ring_info, const struct argo_ring_id *src_id, xen_argo_iov_t *iovs, - unsigned int niov, uint32_t message_type, - unsigned long *out_len) + unsigned int niov, uint32_t message_type, unsigned int len) { xen_argo_ring_t ring; struct xen_argo_ring_message_header mh = { }; int sp, ret; - unsigned int len = 0; xen_argo_iov_t *piov; XEN_GUEST_HANDLE(uint8) NULL_hnd = { }; ASSERT(LOCKING_L3(d, ring_info)); /* - * Obtain the total size of data to transmit -- sets the 'len' variable - * -- and sanity check that the iovs conform to size and number limits. * Enforced below: no more than 'len' bytes of guest data * (plus the message header) will be sent in this operation. */ - ret = iov_count(iovs, niov, &len); - if ( ret ) - return ret; /* * Upper bound check the message len against the ring size. @@ -983,8 +976,6 @@ ringbuf_insert(const struct domain *d, struct argo_ring_info *ring_info, * versus performance cost could be added to decide that here. */ - *out_len = len; - return ret; } @@ -1976,7 +1967,7 @@ sendv(struct domain *src_d, xen_argo_addr_t *src_addr, struct argo_ring_id src_id; struct argo_ring_info *ring_info; int ret = 0; - unsigned long len = 0; + unsigned int len = 0; argo_dprintk("sendv: (%u:%x)->(%u:%x) niov:%u type:%x\n", src_addr->domain_id, src_addr->aport, dst_addr->domain_id, @@ -2044,17 +2035,25 @@ sendv(struct domain *src_d, xen_argo_addr_t *src_addr, { spin_lock(&ring_info->L3_lock); - ret = ringbuf_insert(dst_d, ring_info, &src_id, iovs, niov, - message_type, &len); - if ( ret == -EAGAIN ) + /* + * Obtain the total size of data to transmit -- sets the 'len' variable + * -- and sanity check that the iovs conform to size and number limits. + */ + ret = iov_count(iovs, niov, &len); + if ( !ret ) { - int rc; + ret = ringbuf_insert(dst_d, ring_info, &src_id, iovs, niov, + message_type, len); + if ( ret == -EAGAIN ) + { + int rc; - argo_dprintk("argo_ringbuf_sendv failed, EAGAIN\n"); - /* requeue to issue a notification when space is there */ - rc = pending_requeue(dst_d, ring_info, src_id.domain_id, len); - if ( rc ) - ret = rc; + argo_dprintk("argo_ringbuf_sendv failed, EAGAIN\n"); + /* requeue to issue a notification when space is there */ + rc = pending_requeue(dst_d, ring_info, src_id.domain_id, len); + if ( rc ) + ret = rc; + } } spin_unlock(&ring_info->L3_lock);