From patchwork Tue Jun 11 21:14:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Tsirakis X-Patchwork-Id: 10988297 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 6DE6C13AF for ; Tue, 11 Jun 2019 21:16:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5EA5B28420 for ; Tue, 11 Jun 2019 21:16:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 522AB2846D; Tue, 11 Jun 2019 21:16:02 +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 C645B288D0 for ; Tue, 11 Jun 2019 21:16:01 +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 1hao6R-0003XJ-UU; Tue, 11 Jun 2019 21:14:47 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hao6Q-0003Wc-Gb for xen-devel@lists.xenproject.org; Tue, 11 Jun 2019 21:14:46 +0000 X-Inumbo-ID: ef879ab1-8c8d-11e9-8980-bc764e045a96 Received: from mail-qt1-x843.google.com (unknown [2607:f8b0:4864:20::843]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id ef879ab1-8c8d-11e9-8980-bc764e045a96; Tue, 11 Jun 2019 21:14:45 +0000 (UTC) Received: by mail-qt1-x843.google.com with SMTP id p15so8941521qtl.3 for ; Tue, 11 Jun 2019 14:14:45 -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 :in-reply-to:references; bh=bSxMQeoBCOzKfYSpv+gnDmnsvRm8sBZinCauBKMr1/Y=; b=EENHGxscZHQrfjSiPRgvpABR+PbMI5Da3HCxzTEHHvM6jZbYCR7TcZiT01hhKGEirI n5xm+2e56s7NqhSVVS3p5f01/MLrQGZonboTiC1iKQhat10zQyekPQvW6ES72wxpwQgH ut1ckxK3dJk5WnrM4CcQr2LXlt3TOb7M7m20CieTkPa644gk2Z0Aa2zasvvEMscpTMqT dHThNWmhNcZX1EaqeMJu/cZy3/pZur+lC8LlfgDHlOD2lzUktCCKMPGLjCB6kbAui3rR GNyyvzk1l40xBtlhdOEya7QQ0WbA17YH5jDpZFScUXdV55vU+26AdkhHVnuNu3QFhZW6 qgow== 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:in-reply-to:references; bh=bSxMQeoBCOzKfYSpv+gnDmnsvRm8sBZinCauBKMr1/Y=; b=KuCBIQwIhs5OSRmN7r2VWLWIm2+Bx2GgQzlJKT8PS3g5fJ7JFAU3aQj+98XO86pJJ+ 6y2arQBKF6nujs22M+vgggwHKPlVvsvNrXOLBaCajXUgfWNU4ZuQeCoXTKDUkJjNNOIl DPrEQyf8jvAF0nlXfnkWaj9TbDkzr0sv2isyQ+OMpSTqKG6TJJK8Sn8cA71TZaYjH9Gi Gtb1o7IgRNHBLJRGPBrIEO5teCgxnJZCXlMDug7DMWOBinC2/FuCGvYsCcvZ4VbNRlla nk4tmqKZntvJhPwj5dQ8rUFKfxi9hp+krTpMruxbhXcGTfI6c2lyFJffFNwGkZaNtwNa J2FQ== X-Gm-Message-State: APjAAAWo2j8B1s8ud4N0tsX7o85YOMR4DkSLHb8+W/WuEC3JfIzCV9N2 rOW2RSMRaHChrUNXhqIG+RFWiyL7UjY= X-Google-Smtp-Source: APXvYqxfyabkq4sck5usPj/YZ/r2yJf56HhbR82VdimvJAdI+VM4JgvUI1EAfJT8rJ/Kk6g7L+5Gpg== X-Received: by 2002:ac8:3271:: with SMTP id y46mr28324467qta.185.1560287684480; Tue, 11 Jun 2019 14:14:44 -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 34sm10070811qtq.59.2019.06.11.14.14.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Jun 2019 14:14:44 -0700 (PDT) From: Nicholas Tsirakis X-Google-Original-From: Nicholas Tsirakis To: xen-devel@lists.xenproject.org Date: Tue, 11 Jun 2019 17:14:27 -0400 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Subject: [Xen-devel] [PATCH v2 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 --- xen/common/argo.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/xen/common/argo.c b/xen/common/argo.c index 2f874a570d..31baf4beed 100644 --- a/xen/common/argo.c +++ b/xen/common/argo.c @@ -766,26 +766,20 @@ 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 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 +977,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 +1968,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,8 +2036,16 @@ sendv(struct domain *src_d, xen_argo_addr_t *src_addr, { spin_lock(&ring_info->L3_lock); + /* + * 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 ) + return ret; + ret = ringbuf_insert(dst_d, ring_info, &src_id, iovs, niov, - message_type, &len); + message_type, len); if ( ret == -EAGAIN ) { int rc;