From patchwork Wed Jun 2 18:58:53 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 54416 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 83CEEB7D48 for ; Thu, 3 Jun 2010 05:00:39 +1000 (EST) Received: from localhost ([127.0.0.1]:59952 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OJtB5-0006hl-Mn for incoming@patchwork.ozlabs.org; Wed, 02 Jun 2010 15:00:35 -0400 Received: from [140.186.70.92] (port=51715 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OJt9l-0006IM-Kt for qemu-devel@nongnu.org; Wed, 02 Jun 2010 14:59:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OJt9g-0003xk-Ow for qemu-devel@nongnu.org; Wed, 02 Jun 2010 14:59:13 -0400 Received: from e39.co.us.ibm.com ([32.97.110.160]:37000) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OJt9g-0003xV-JQ for qemu-devel@nongnu.org; Wed, 02 Jun 2010 14:59:08 -0400 Received: from d03relay03.boulder.ibm.com (d03relay03.boulder.ibm.com [9.17.195.228]) by e39.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id o52Io95j005138 for ; Wed, 2 Jun 2010 12:50:09 -0600 Received: from d03av05.boulder.ibm.com (d03av05.boulder.ibm.com [9.17.195.85]) by d03relay03.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o52IwtU1124146 for ; Wed, 2 Jun 2010 12:59:00 -0600 Received: from d03av05.boulder.ibm.com (loopback [127.0.0.1]) by d03av05.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id o52IwtNx026866 for ; Wed, 2 Jun 2010 12:58:55 -0600 Received: from localhost.localdomain (dyn9413588.austin.ibm.com [9.41.35.88]) by d03av05.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id o52IwtAo026839; Wed, 2 Jun 2010 12:58:55 -0600 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Wed, 2 Jun 2010 13:58:53 -0500 Message-Id: <1275505133-3734-1-git-send-email-aliguori@us.ibm.com> X-Mailer: git-send-email 1.7.0.4 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Cc: Anthony Liguori Subject: [Qemu-devel] [PATCH] Fix console_write_ch on 64-bit big-endian hosts X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Currently, console_ch_t is defined as an unsigned long. However, immediately after it's definition, we treat it as a uint32_t *. This will work on a little endian system because of the way bits are layed out but will fail miserably on big endian hosts. This patch fixes the code to do the correct thing. This addresses https://bugs.launchpad.net/qemu/+bug/568614 Reported-by: Devin J. Pohly Signed-off-by: Anthony Liguori diff --git a/console.h b/console.h index cac959f..ddd1bbf 100644 --- a/console.h +++ b/console.h @@ -326,9 +326,11 @@ static inline int ds_get_bytes_per_pixel(DisplayState *ds) typedef unsigned long console_ch_t; static inline void console_write_ch(console_ch_t *dest, uint32_t ch) { + uint32_t p; if (!(ch & 0xff)) ch |= ' '; - cpu_to_le32wu((uint32_t *) dest, ch); + cpu_to_le32wu(&p, ch); + *dest = p; } typedef void (*vga_hw_update_ptr)(void *);