From patchwork Tue Oct 15 08:50:11 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 283544 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4CFF72C016E for ; Tue, 15 Oct 2013 19:51:12 +1100 (EST) Received: from localhost ([::1]:40611 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VW0LN-0007e2-R3 for incoming@patchwork.ozlabs.org; Tue, 15 Oct 2013 04:51:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52568) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VW0Kx-0007a9-TN for qemu-devel@nongnu.org; Tue, 15 Oct 2013 04:50:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VW0Km-0004p2-TW for qemu-devel@nongnu.org; Tue, 15 Oct 2013 04:50:43 -0400 Received: from e23smtp04.au.ibm.com ([202.81.31.146]:51051) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VW0Kl-0004oV-Qo for qemu-devel@nongnu.org; Tue, 15 Oct 2013 04:50:32 -0400 Received: from /spool/local by e23smtp04.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 15 Oct 2013 18:50:29 +1000 Received: from d23dlp02.au.ibm.com (202.81.31.213) by e23smtp04.au.ibm.com (202.81.31.210) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 15 Oct 2013 18:50:27 +1000 Received: from d23relay03.au.ibm.com (d23relay03.au.ibm.com [9.190.235.21]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id 1E9EA2BB0052; Tue, 15 Oct 2013 19:50:26 +1100 (EST) Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay03.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r9F8o54466846774; Tue, 15 Oct 2013 19:50:14 +1100 Received: from d23av01.au.ibm.com (localhost [127.0.0.1]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id r9F8oGvI031352; Tue, 15 Oct 2013 19:50:16 +1100 Received: from ozlabs.au.ibm.com (ozlabs.au.ibm.com [9.190.163.12]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id r9F8oGbM031345; Tue, 15 Oct 2013 19:50:16 +1100 Received: from bran.ozlabs.ibm.com (haven.au.ibm.com [9.190.164.82]) by ozlabs.au.ibm.com (Postfix) with ESMTP id EB2BBA0113; Tue, 15 Oct 2013 19:50:15 +1100 (EST) Received: from ka1.ozlabs.ibm.com (ka1.ozlabs.ibm.com [10.61.145.11]) by bran.ozlabs.ibm.com (Postfix) with ESMTP id 8638B16ABB8; Tue, 15 Oct 2013 19:50:15 +1100 (EST) From: Alexey Kardashevskiy To: qemu-devel@nongnu.org Date: Tue, 15 Oct 2013 19:50:11 +1100 Message-Id: <1381827011-7358-1-git-send-email-aik@ozlabs.ru> X-Mailer: git-send-email 1.8.4.rc4 X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13101508-9264-0000-0000-000004B7A42F X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 202.81.31.146 Cc: Alexey Kardashevskiy , qemu-ppc@nongnu.org, Alexander Graf Subject: [Qemu-devel] [RFC PATCH] spapr-vty: workaround "reg" property for old kernels 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 Old kernels (< 3.1) handle hvcX devices different in different parts. Sometime the kernel assumes that the hvc device numbers start from zero and if there is just one hvc, then it is hvc0. However kernel's add_preferred_console() uses the very last byte of the VTY's "reg" property as an hvc number so it might end up with something different than hvc. The problem appears on SLES11SP3 and RHEL6. If to run QEMU without -nodefaults, then the default VTY is created first on a VIO bus and gets reg==0x71000000 so it will be hvc0 and everything will be fine. If to run QEMU with: -nodefaults \ -chardev "socket,id=char1,host=localhost,port=8001,server,telnet,mux=on" \ -device "spapr-vty,chardev=char1" \ -mon "chardev=char1,mode=readline,id=mon1" \ then the exactly the same config is expected but in this case spapr-vty gets reg==0x71000001 and therefore it becomes hvc1 and lots of debug output is missing. SLES11SP3 does not even boot as /dev/console is redirected to /dev/hvc0 which is dead. The issue can be solved by manual selection of VTY's "reg" property to have last byte equal to zero. The alternative would be to use separate "reg" property counter for automatic "reg" property generation and this is what the patch does. Signed-off-by: Alexey Kardashevskiy --- Since libvirt uses "-nodefault" a lot and in this case "spapr-nvram" gets created first and gets reg=0x71000000, we cannot just ignore this. Also, it does not seem an option to require libvirt users to specify spapr-vty "reg" property every time. Can anyone think of a simpler solutionu? Thanks. --- hw/ppc/spapr_vio.c | 7 ++++++- include/hw/ppc/spapr_vio.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/ppc/spapr_vio.c b/hw/ppc/spapr_vio.c index a6a0a51..2d56950 100644 --- a/hw/ppc/spapr_vio.c +++ b/hw/ppc/spapr_vio.c @@ -438,7 +438,11 @@ static int spapr_vio_busdev_init(DeviceState *qdev) VIOsPAPRBus *bus = DO_UPCAST(VIOsPAPRBus, bus, dev->qdev.parent_bus); do { - dev->reg = bus->next_reg++; + if (!object_dynamic_cast(OBJECT(qdev), "spapr-vty")) { + dev->reg = bus->next_reg++; + } else { + dev->reg = bus->next_vty_reg++; + } } while (reg_conflict(dev)); } @@ -501,6 +505,7 @@ VIOsPAPRBus *spapr_vio_bus_init(void) qbus = qbus_create(TYPE_SPAPR_VIO_BUS, dev, "spapr-vio"); bus = DO_UPCAST(VIOsPAPRBus, bus, qbus); bus->next_reg = 0x71000000; + bus->next_vty_reg = 0x71000100; /* hcall-vio */ spapr_register_hypercall(H_VIO_SIGNAL, h_vio_signal); diff --git a/include/hw/ppc/spapr_vio.h b/include/hw/ppc/spapr_vio.h index d8b3b03..3a92d9e 100644 --- a/include/hw/ppc/spapr_vio.h +++ b/include/hw/ppc/spapr_vio.h @@ -73,6 +73,7 @@ struct VIOsPAPRDevice { struct VIOsPAPRBus { BusState bus; uint32_t next_reg; + uint32_t next_vty_reg; int (*init)(VIOsPAPRDevice *dev); int (*devnode)(VIOsPAPRDevice *dev, void *fdt, int node_off); };