From patchwork Fri Dec 12 12:44:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 420452 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 1588A140081 for ; Fri, 12 Dec 2014 23:46:50 +1100 (AEDT) Received: from localhost ([::1]:56881 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XzPcO-0001Iz-Bj for incoming@patchwork.ozlabs.org; Fri, 12 Dec 2014 07:46:48 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39889) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XzPaA-0006tJ-5g for qemu-devel@nongnu.org; Fri, 12 Dec 2014 07:44:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XzPZt-0001lZ-33 for qemu-devel@nongnu.org; Fri, 12 Dec 2014 07:44:25 -0500 Received: from mail-wi0-x22c.google.com ([2a00:1450:400c:c05::22c]:55702) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XzPZs-0001lL-Su; Fri, 12 Dec 2014 07:44:13 -0500 Received: by mail-wi0-f172.google.com with SMTP id n3so2386781wiv.5; Fri, 12 Dec 2014 04:44:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=Ye4kQXE9iKs0FZlODliN8xx/sSzFiOgfNKXbkQZnF14=; b=LgxAbN/eOdt9xBUGihrL4hZSFVvt0bytH4TqHAQhxp+uObarKXRvdQlM6vVB6OcsXs psZFxspljNr4+9OxbuKgWl18z5w2IxdmV47wxesfo74IjkPAo5yCCcakiBm2PEGra5gU 5ZHzJa4pvohEFFotWYFkYi4tLVKe78hWL00YSI8nWO9pU0gCDRT0OHR/Mha2QCjnfqET 8ZQ1HmkuPTxA71hal8NBnJzUjRo7LRBgJnHMgzRQx5gIct0Wy+v4ssuZk7APHyDwMhXg QPAfuiY/9BvC9FRqJUWaudmZ/rmHonTHSHTaCvWG7QWGaYxZR41dYdGA6+MRWM6uXMcK 38bQ== X-Received: by 10.194.93.5 with SMTP id cq5mr25978701wjb.84.1418388252152; Fri, 12 Dec 2014 04:44:12 -0800 (PST) Received: from playground.station (net-2-35-193-40.cust.vodafonedsl.it. [2.35.193.40]) by mx.google.com with ESMTPSA id hn2sm1716801wjc.5.2014.12.12.04.44.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Dec 2014 04:44:10 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 12 Dec 2014 13:44:00 +0100 Message-Id: <1418388243-1886-2-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1418388243-1886-1-git-send-email-pbonzini@redhat.com> References: <1418388243-1886-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::22c Cc: imammedo@redhat.com, qemu-stable@nongnu.org, andrey@xdel.ru, dgilbert@redhat.com, batuzovk@ispras.ru Subject: [Qemu-devel] [PATCH v3 1/4] serial: reset thri_pending on IER writes with THRI=0 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This is responsible for failure of migration from 2.2 to 2.1, because thr_ipending is always one in practice. serial.c is setting thr_ipending unconditionally. However, thr_ipending is not used at all if THRI=0, and it will be overwritten again the next time THRE or THRI changes. For that reason, we can set thr_ipending to zero every time THRI is reset. This has no semantic change and is enough to fix migration. It does not change the migration format, so 2.2.0 -> 2.1 will remain broken but we can fix 2.2.1 -> 2.1 without breaking 2.2.1 <-> 2.2.0. There is disagreement on whether LSR.THRE should be resampled when IER.THRI goes from 1 to 1. Do not touch the code for now. Cc: qemu-stable@nongnu.org Reported-by: Igor Mammedov Signed-off-by: Paolo Bonzini Reviewed-by: Dr. David Alan Gilbert --- hw/char/serial.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/hw/char/serial.c b/hw/char/serial.c index ebcacdc..8c42d03 100644 --- a/hw/char/serial.c +++ b/hw/char/serial.c @@ -350,10 +350,24 @@ static void serial_ioport_write(void *opaque, hwaddr addr, uint64_t val, s->poll_msl = 0; } } - if (s->lsr & UART_LSR_THRE) { + + /* Turning on the THRE interrupt on IER can trigger the interrupt + * if LSR.THRE=1, even if it had been masked before by reading IIR. + * This is not in the datasheet, but Windows relies on it. It is + * unclear if THRE has to be resampled every time THRI becomes + * 1, or only on the rising edge. Bochs does the latter, and Windows + * always toggles IER to all zeroes and back to all ones. But for + * now leave it as it has always been in QEMU. + * + * If IER.THRI is zero, thr_ipending is not used. Set it to zero + * so that the thr_ipending subsection is not migrated. + */ + if ((s->ier & UART_IER_THRI) && (s->lsr & UART_LSR_THRE)) { s->thr_ipending = 1; - serial_update_irq(s); + } else { + s->thr_ipending = 0; } + serial_update_irq(s); } break; case 2: