From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54682) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wm0Yr-0000rR-4y for qemu-devel@nongnu.org; Sun, 18 May 2014 08:51:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wm0Yj-0000J2-MD for qemu-devel@nongnu.org; Sun, 18 May 2014 08:51:29 -0400 Received: from s16892447.onlinehome-server.info ([82.165.15.123]:44005) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wm0Yj-0000Iq-GA for qemu-devel@nongnu.org; Sun, 18 May 2014 08:51:21 -0400 Message-ID: <5378AC30.9090900@ilande.co.uk> Date: Sun, 18 May 2014 13:48:48 +0100 From: Mark Cave-Ayland MIME-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] target-sparc has inverse cwp logic for SAVE/RESTORE? List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel Cc: Blue Swirl , Richard Henderson Hi all, I've been working on debugging a window-related OpenBIOS issue and noticed that the cwp register logic in QEMU appears to be backwards according to the SPARCv9 specification. From sections 6.3.6.1 and 6.3.6.2: "The SAVE instruction allocates a new register window and saves the caller’s register window by incrementing the CWP register." "The RESTORE instruction restores the previous register window by decrementing the CWP register." In target-sparc/win_helper.c the logic in helper_save() and helper_restore() is inverted, i.e. executing SAVE decrements cwp while executing RESTORE increments cwp. The surprise here was that executing SAVE when cwp == 0 changed cwp to 7 rather than 1. AFAICT there should be no functional difference, but it would make things less confusing when debugging window traps if the logic from the specification was followed. Does anyone know why this is currently done this way? ATB, Mark.