From patchwork Mon Nov 28 19:42:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 9450131 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1456E60756 for ; Mon, 28 Nov 2016 19:44:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 008BF27F9C for ; Mon, 28 Nov 2016 19:44:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E8EE027FBB; Mon, 28 Nov 2016 19:44:49 +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=-4.2 required=2.0 tests=BAYES_00, 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 AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E682127FA1 for ; Mon, 28 Nov 2016 19:44:48 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cBRox-0000UZ-IR; Mon, 28 Nov 2016 19:42:35 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cBRow-0000U9-4K for xen-devel@lists.xenproject.org; Mon, 28 Nov 2016 19:42:34 +0000 Received: from [85.158.143.35] by server-5.bemta-6.messagelabs.com id 64/5A-19272-9A88C385; Mon, 28 Nov 2016 19:42:33 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrNLMWRWlGSWpSXmKPExsVybKJsh+6KDps Ig8vPjC2+b5nM5MDocfjDFZYAxijWzLyk/IoE1owT084xFqzkrDizfBpjA2MfexcjF4eQwFRG ictnL0I525kkVuyZy9bFyMnBJmAo8ffJJjBbREBM4vTuaUwgRcwCTxglWvvmM4IkhAUsJLrXH QArYhFQlThwbSYziM0r4CZxcvoHsBoJATmJk8cms4LYnALuEt//fwSLCwm0M0r8PlkDUZMhMa 9nDiuE7SWx6MYlKFtN4uq5TcwTGPkWMDKsYlQvTi0qSy3SNdFLKspMzyjJTczM0TU0MNPLTS0 uTkxPzUlMKtZLzs/dxAgMFAYg2MHYfdn/EKMkB5OSKO90N5sIIb6k/JTKjMTijPii0pzU4kOM MhwcShK839qBcoJFqempFWmZOcCQhUlLcPAoifAKAsNWiLe4IDG3ODMdInWKUVFKnPcsSJ8AS CKjNA+uDRYnlxhlpYR5GYEOEeIpSC3KzSxBlX/FKM7BqCTMOw9kCk9mXgnc9FdAi5mAFr99bQ 2yuCQRISUFjLy3tcYh5l/D/i7MP2f0XqTc6nT9XJOmku3yi7veSL1V33jw6n7BV9eNw7jvZze 6KXOY1UXMUJMTOf2y7UKzp55X6zr/5W8CrocYCJ4XPsBjufXzw8kRV7yNJ3OHi+2xiHA1cHgY cclu8qErGvJ7XZfPSS5MrJh+9dTy/Q0xS/zzA3e7zlqaqcRSnJFoqMVcVJwIAMS6SNyOAgAA X-Env-Sender: sstabellini@kernel.org X-Msg-Ref: server-7.tower-21.messagelabs.com!1480362151!45643624!1 X-Originating-IP: [198.145.29.136] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.0.16; banners=-,-,- X-VirusChecked: Checked Received: (qmail 33811 invoked from network); 28 Nov 2016 19:42:32 -0000 Received: from mail.kernel.org (HELO mail.kernel.org) (198.145.29.136) by server-7.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 28 Nov 2016 19:42:32 -0000 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 602D02013D; Mon, 28 Nov 2016 19:42:30 +0000 (UTC) Received: from sstabellini-ThinkPad-X260.hsd1.ca.comcast.net (96-82-76-110-static.hfc.comcastbusiness.net [96.82.76.110]) (using TLSv1.2 with cipher AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2B0AE2017D; Mon, 28 Nov 2016 19:42:29 +0000 (UTC) From: Stefano Stabellini To: stefanha@gmail.com Date: Mon, 28 Nov 2016 11:42:24 -0800 Message-Id: <1480362146-14873-2-git-send-email-sstabellini@kernel.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1480362146-14873-1-git-send-email-sstabellini@kernel.org> References: <1480362146-14873-1-git-send-email-sstabellini@kernel.org> X-Virus-Scanned: ClamAV using ClamSMTP Cc: peter.maydell@linaro.org, sstabellini@kernel.org, Jan Beulich , qemu-devel@nongnu.org, stefanha@redhat.com, anthony.perard@citrix.com, xen-devel@lists.xenproject.org Subject: [Xen-devel] [PULL 2/4] xen: fix quad word bufioreq handling X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jan Beulich We should not consume the second slot if it didn't get written yet. Normal writers - i.e. Xen - would not update write_pointer between the two writes, but the page may get fiddled with by the guest itself, and we're better off avoiding to enter an infinite loop in that case. Reported-by: yanghongke Signed-off-by: Jan Beulich Reviewed-by: Paul Durrant Reviewed-by: Stefano Stabellini Signed-off-by: Stefano Stabellini --- xen-hvm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/xen-hvm.c b/xen-hvm.c index 99b8ee8..d74e233 100644 --- a/xen-hvm.c +++ b/xen-hvm.c @@ -1021,6 +1021,9 @@ static int handle_buffered_iopage(XenIOState *state) xen_rmb(); qw = (req.size == 8); if (qw) { + if (rdptr + 1 == wrptr) { + hw_error("Incomplete quad word buffered ioreq"); + } buf_req = &buf_page->buf_ioreq[(rdptr + 1) % IOREQ_BUFFER_SLOT_NUM]; req.data |= ((uint64_t)buf_req->data) << 32;