From patchwork Thu Mar 26 20:45:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 46391 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1FD8721584 for ; Thu, 26 Mar 2015 20:45:46 +0000 (UTC) Received: by lahp7 with SMTP id p7sf8294241lah.0 for ; Thu, 26 Mar 2015 13:45:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:subject :precedence:reply-to:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:x-original-sender :x-original-authentication-results:mailing-list; bh=QGWAINziUwZMSkqss2iHeVJDkz2ofoVTD/PcgEbmSKI=; b=jwvsbrBdwmcCuWVllQoiv6JAgCwabOrkfbnAsa71xExtyg5lafRNVI/yriZiev7ffb 99rkyaLClxQzS4xKqm66n19TVb/GUjScz0NEdgMPqvsYmXlLE6rL5lrB4KDXBl69CmrU TJZMlr3E9B1RgQX+640c0HYYgH6HWibxx4Fr4xVmBN1xljBy0cvq0Zj7HHLSsByP/ZaJ KyRs9zB4d1RhLsEurRVk0nN90LdjTVHyz53qUl6RUlMipbzm6yMIObMleJ1q0w5mXqDT uIpuyPr97wMwubFvEXlLLrKlynPpzQi0F5GvD/q73wLThty4+t8dwXyLvjBS0BxKwCGT Sp7A== X-Gm-Message-State: ALoCoQnejYHY0/jyAcV5JTIht6B6dlTuIiLQFPI4SSR2UrM7R27gCqaE3Yum5tkwFgTtGczLs90Z X-Received: by 10.112.44.167 with SMTP id f7mr3905013lbm.9.1427402744955; Thu, 26 Mar 2015 13:45:44 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.205.33 with SMTP id ld1ls306844lac.11.gmail; Thu, 26 Mar 2015 13:45:44 -0700 (PDT) X-Received: by 10.152.37.202 with SMTP id a10mr15448784lak.0.1427402744643; Thu, 26 Mar 2015 13:45:44 -0700 (PDT) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id de9si5299987lac.21.2015.03.26.13.45.44 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Mar 2015 13:45:44 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by labto5 with SMTP id to5so55680490lab.0 for ; Thu, 26 Mar 2015 13:45:44 -0700 (PDT) X-Received: by 10.152.197.34 with SMTP id ir2mr15004625lac.36.1427402744528; Thu, 26 Mar 2015 13:45:44 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.57.201 with SMTP id k9csp851560lbq; Thu, 26 Mar 2015 13:45:43 -0700 (PDT) X-Received: by 10.107.17.155 with SMTP id 27mr23079719ior.64.1427402743421; Thu, 26 Mar 2015 13:45:43 -0700 (PDT) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id gb8si276250igd.61.2015.03.26.13.45.42 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 26 Mar 2015 13:45:43 -0700 (PDT) Received-SPF: pass (google.com: domain of edk2-devel-bounces@lists.sourceforge.net designates 216.34.181.88 as permitted sender) client-ip=216.34.181.88; Received: from localhost ([127.0.0.1] helo=sfs-ml-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YbEeg-0005PS-0k; Thu, 26 Mar 2015 20:45:30 +0000 Received: from sog-mx-1.v43.ch3.sourceforge.com ([172.29.43.191] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YbEee-0005PM-Jt for edk2-devel@lists.sourceforge.net; Thu, 26 Mar 2015 20:45:28 +0000 Received-SPF: pass (sog-mx-1.v43.ch3.sourceforge.com: domain of linaro.org designates 74.125.82.53 as permitted sender) client-ip=74.125.82.53; envelope-from=ard.biesheuvel@linaro.org; helo=mail-wg0-f53.google.com; Received: from mail-wg0-f53.google.com ([74.125.82.53]) by sog-mx-1.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1YbEed-0000Z8-MW for edk2-devel@lists.sourceforge.net; Thu, 26 Mar 2015 20:45:28 +0000 Received: by wgs2 with SMTP id 2so78074599wgs.1 for ; Thu, 26 Mar 2015 13:45:21 -0700 (PDT) X-Received: by 10.180.82.169 with SMTP id j9mr41233215wiy.40.1427402721674; Thu, 26 Mar 2015 13:45:21 -0700 (PDT) Received: from ards-macbook-pro.local ([90.174.5.29]) by mx.google.com with ESMTPSA id e2sm9923311wjy.46.2015.03.26.13.45.17 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 26 Mar 2015 13:45:20 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.sourceforge.net, leif.lindholm@linaro.org, roy.franz@linaro.org, ian.campbell@citrix.com, stefano.stabellini@eu.citrix.com, lersek@redhat.com, julien.grall@linaro.org Date: Thu, 26 Mar 2015 21:45:14 +0100 Message-Id: <1427402714-15564-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 X-Spam-Score: -1.5 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 SPF_PASS SPF: sender matches SPF record X-Headers-End: 1YbEed-0000Z8-MW Subject: [edk2] [PATCH] XenConsoleSerialPortLib: deal with output overflow X-BeenThere: edk2-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list Reply-To: edk2-devel@lists.sourceforge.net List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.sourceforge.net X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 This fixes a particularly nasty interaction between TerminalDxe and XenConsoleSerialPortLib where the latter may write fewer bytes than it was passed in its ->Write() function, which is interpreted by TerminalDxe as a failure condition, causing the its driver binding to fail, which in turn causes other drivers (the Intel BDS under ArmPlatformPkg) to fail due to a missing console pipe. While one would assume that throttling of the output is the responsibility of the console/terminal layer, in this case we can work around it by notifying the hypervisor of the partial write, and looping until it makes some more room for us. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- .../XenConsoleSerialPortLib.c | 24 ++++++++++++---------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPortLib.c b/OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPortLib.c index 467cb27a30c4..9bb2016c2f32 100644 --- a/OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPortLib.c +++ b/OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPortLib.c @@ -80,22 +80,24 @@ SerialPortWrite ( return 0; } - Consumer = mXenConsoleInterface->out_cons; - Producer = mXenConsoleInterface->out_prod; + Sent = 0; + do { + Consumer = mXenConsoleInterface->out_cons; + Producer = mXenConsoleInterface->out_prod; - MemoryFence (); + MemoryFence (); - Sent = 0; - while (Sent < NumberOfBytes && ((Producer - Consumer) < sizeof (mXenConsoleInterface->out))) - mXenConsoleInterface->out[MASK_XENCONS_IDX(Producer++, mXenConsoleInterface->out)] = Buffer[Sent++]; + while (Sent < NumberOfBytes && ((Producer - Consumer) < sizeof (mXenConsoleInterface->out))) + mXenConsoleInterface->out[MASK_XENCONS_IDX(Producer++, mXenConsoleInterface->out)] = Buffer[Sent++]; - MemoryFence (); + MemoryFence (); - mXenConsoleInterface->out_prod = Producer; + mXenConsoleInterface->out_prod = Producer; - if (Sent > 0) { - XenHypercallEventChannelOp (EVTCHNOP_send, &mXenConsoleEventChain); - } + if (Sent > 0) { + XenHypercallEventChannelOp (EVTCHNOP_send, &mXenConsoleEventChain); + } + } while (Sent < NumberOfBytes); return Sent; }