From owner-freebsd-ppc@FreeBSD.ORG Fri Jan 20 22:04:40 2012 Return-Path: Delivered-To: freebsd-ppc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id ECEB7106564A for ; Fri, 20 Jan 2012 22:04:40 +0000 (UTC) (envelope-from gavare@gmail.com) Received: from mail-lpp01m010-f54.google.com (mail-lpp01m010-f54.google.com [209.85.215.54]) by mx1.freebsd.org (Postfix) with ESMTP id 6C7028FC20 for ; Fri, 20 Jan 2012 22:04:39 +0000 (UTC) Received: by lahe6 with SMTP id e6so805392lah.13 for ; Fri, 20 Jan 2012 14:04:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=subject:from:reply-to:to:content-type:date:message-id:mime-version :x-mailer:content-transfer-encoding; bh=t1qQqwPcksDgaY2KmYOlyijfdWE08F0txZSYs/dAQN4=; b=ImQ6pnAZBDxArPcD9LtO+vIjrufPB2qMGXMEicOMlutCvNbERU1xdD6pv18z4Um1Te Ll8w8/ScQ4duXVoWd6HjmMiTXgSzbzxdg8ef1SzXna7nhPX0FCmisaiteYGdMCt0NnSn fI8EpgnfklGugSJ5wAI9Xqkvhg3pMlOghUo78= Received: by 10.112.82.73 with SMTP id g9mr8062398lby.60.1327095489754; Fri, 20 Jan 2012 13:38:09 -0800 (PST) Received: from [192.168.1.4] (c80-216-159-27.bredband.comhem.se. [80.216.159.27]) by mx.google.com with ESMTPS id 1sm3282363lbq.10.2012.01.20.13.38.06 (version=SSLv3 cipher=OTHER); Fri, 20 Jan 2012 13:38:07 -0800 (PST) From: Anders Gavare To: freebsd-ppc@freebsd.org Content-Type: text/plain; charset="UTF-8" Date: Fri, 20 Jan 2012 22:38:45 +0100 Message-ID: <1327095525.2825.10.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.32.1 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit Subject: possible bug? OF_getprop() < sizeof() X-BeenThere: freebsd-ppc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: anders@gavare.se List-Id: Porting FreeBSD to the PowerPC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Jan 2012 22:04:41 -0000 If I understood things correctly, there's a possible minor bug in ofw_machdep.c for PowerPC, in parse_ofw_memory: /* * Get #address-cells from root node, defaulting to 1 if it cannot * be found. */ phandle = OF_finddevice("/"); if (OF_getprop(phandle, "#address-cells", &address_cells, sizeof(address_cells)) < sizeof(address_cells)) address_cells = 1; if (OF_getprop(phandle, "#size-cells", &size_cells, sizeof(size_cells)) < sizeof(size_cells)) size_cells = 1; Running the code in GXemul, it seems that the comparison between OF_getprop's return value (-1 in case the property is not found) and the sizeof value is done as unsigned integers. ... <0xfff00000(0x908600,"D",0,0,..)> [ of: getprop(1, "#address-cells", 0x908e7c, 4) ] [ of: WARNING: getprop: no property '#address-cells' at handle 1 (device '') ] 0068bcf8: 2b830003 cmplwi cr7,r3,3 BREAKPOINT: pc = 0x68bcf8 (The instruction has not yet executed.) GXemul> print r3 0xffffffffffffffff GXemul> s 10 0068bcf8: 2b830003 cmplwi cr7,r3,3 0068bcfc: 419d000c bc 12,29,0x68bd08 0068bd08: 7fc3f378 mr r3,r30 0068bd0c: 3c800090 lis r4,144 0068bd10: 3884deb8 subi r4,r4,8520 0068bd14: 38a10818 addi r5,r1,2072 0068bd18: 38c00004 li r6,4 0068bd1c: 4bfe0361 bl 0x66c07c Real machines perhaps always have #address-cells and #size-cells properties for the / node, so this problem perhaps does not show up IRL. However, if this pattern OF_getprop(...) < sizeof(..) is common, maybe there are other similar bugs. Or did I misunderstand the semantics of cmplwi? (The binary and source code were from ftp://ftp.freebsd.org/pub/FreeBSD/releases/powerpc/powerpc/9.0-RELEASE.) Anders (not subscribed to the list)