From patchwork Fri Jul 27 13:45:46 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Landley X-Patchwork-Id: 173684 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id CAE5C2C0078 for ; Sat, 28 Jul 2012 00:14:50 +1000 (EST) Received: from localhost ([::1]:54291 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SulJY-0001t4-Cg for incoming@patchwork.ozlabs.org; Fri, 27 Jul 2012 10:14:48 -0400 Received: from eggs.gnu.org ([208.118.235.92]:46679) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SulJO-0001sw-UJ for qemu-devel@nongnu.org; Fri, 27 Jul 2012 10:14:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SulJI-0005Ct-Sk for qemu-devel@nongnu.org; Fri, 27 Jul 2012 10:14:38 -0400 Received: from mail-ob0-f173.google.com ([209.85.214.173]:38141) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SulJI-0005Cn-NW for qemu-devel@nongnu.org; Fri, 27 Jul 2012 10:14:32 -0400 Received: by obbta14 with SMTP id ta14so4116335obb.4 for ; Fri, 27 Jul 2012 07:14:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding:x-gm-message-state; bh=67Cwga+dSFQRoZGCFs1uayjKInO8u3wQrIFNlEdCrTA=; b=dBKa6H/KLU7SCvrqrJXoQaErRLr1bdBvp2J14z8P7LKxaOZMgLmMKpbcbAdo/mZq4L m1LD2ohiXVnT57hpu0OOkgv3spBU+UdwAlj3dlAdc6NJ/E1C6OktR6m0vy8DZDVJXF6A h/KBSKPxOLvOVoWD/NozOJstOwymjG9L1TmcDxxSAOiECSxbMee/KyplaDG3GcoCkzxX OHzwn/l8cRmEsnCV28+a1/5LTStdt0Lg2rKv2TlEn31caiXmMIu00dPESdtTzaF5c0cD DW1zM/Xe1vq9XyfCbWyc1/VvyqgT3C/G+KCDV78CycNztQ/p91mEMeKOOPMsB3hlzI0Z oRnA== Received: by 10.182.88.9 with SMTP id bc9mr3866782obb.4.1343398471354; Fri, 27 Jul 2012 07:14:31 -0700 (PDT) Received: from [192.168.1.5] (cpe-72-177-21-136.austin.res.rr.com. [72.177.21.136]) by mx.google.com with ESMTPS id o4sm1411659oef.11.2012.07.27.07.14.29 (version=SSLv3 cipher=OTHER); Fri, 27 Jul 2012 07:14:30 -0700 (PDT) Message-ID: <50129B8A.3060102@landley.net> Date: Fri, 27 Jul 2012 08:45:46 -0500 From: Rob Landley User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 MIME-Version: 1.0 To: aboriginal@lists.landley.net, qemu-devel X-Gm-Message-State: ALoCoQl1iPVMtCu5wUFG9aCmNElxYn9Y1nRHy7MqOxNjcCvJ67CnLglZaZZ6BnLvVn59xdpcR7g1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.214.173 Subject: [Qemu-devel] [PATCH] Fixing sh4 serial abort 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 If you grab the current aboriginal linux build scripts: http://landley.net/hg/aboriginal/archive/tip.tar.bz2 And "./build.sh sh4", then cd to build/system-image-sh4 and "./run-emulator.sh" you get this: sh_serial: unsupported read from 0x18 Aborted The bug was triggered by linux kernel commit 73c3d53f38e0a8e6 back between v3.2 and v3.3, which did this: break; -#if 0 case 0x18: ret = s->fcr; break; -#endif case 0x1c: ret = s->rx_cnt; break; (It can also just do ret = 0; and that works too. Or comment out the abort() near the end of the function.) Doing that, qemu boots the sh4 system image to a shell prompt, and the result compiles "hello world" natively. By the way, this board emulation (r2d) only has 64 megs ram. Is there an easy way to get 256 megs out of it? Rob --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -1771,18 +1771,25 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios, sci_init_pins(port, termios->c_cflag); - if (s->cfg->capabilities & SCIx_HAVE_RTSCTS) { - reg = sci_getreg(port, SCFCR); - if (reg->size) { - unsigned short ctrl; + reg = sci_getreg(port, SCFCR); + if (reg->size) { + unsigned short ctrl = sci_in(port, SCFCR); - ctrl = sci_in(port, SCFCR); + if (s->cfg->capabilities & SCIx_HAVE_RTSCTS) { I.E. sci_getreg(port, SCFCR) move to before checking whether or not we'll ever possibly use the result. SCFCR is 0x18 and QEMU calls abort() on an attempt to read from an unimplemented register. I can patch the kernel to work around this (and probably will for this release), but the _proper_ fix is to get qemu not to abort on a register read that works fine if it just returns 0. It turns out the qemu fix (in current git) is just: --- a/hw/sh_serial.c +++ b/hw/sh_serial.c @@ -248,11 +248,9 @@ static uint64_t sh_serial_read(void *opaque, target_phys s->flags &= ~SH_SERIAL_FLAG_RDF; }