From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57867) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y6NvD-0003Ai-AS for qemu-devel@nongnu.org; Wed, 31 Dec 2014 13:23:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y6NvA-0004L6-0H for qemu-devel@nongnu.org; Wed, 31 Dec 2014 13:23:03 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58299) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y6Nv9-0004Kt-Nc for qemu-devel@nongnu.org; Wed, 31 Dec 2014 13:22:59 -0500 Message-ID: <54A43EFE.4030205@redhat.com> Date: Wed, 31 Dec 2014 19:22:54 +0100 From: Laszlo Ersek MIME-Version: 1.0 References: <1420024880-15416-1-git-send-email-lersek@redhat.com> <54A3F829.4000509@redhat.com> <54A4032A.7050808@redhat.com> <54A423ED.3040606@redhat.com> <54A4395D.1040401@redhat.com> In-Reply-To: <54A4395D.1040401@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] fw_cfg: fix endianness in fw_cfg_data_mem_read() / _write() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: qemu devel list , Paolo Bonzini , Drew Jones , Alexander Graf , Gerd Hoffmann On 12/31/14 18:58, Laszlo Ersek wrote: > On 12/31/14 18:44, Peter Maydell wrote: >> On 31 December 2014 at 17:17, Peter Maydell wrote: >>> Unpatched QEMU + QEMU_EFI.fd.v4 : doesn't boot (doesn't load kernel) >>> Patched QEMU + QEMU_EFI.fd.v4_noswizzle : boots OK (dracut-initqueue >>> starts downloading things). >> >> Just noticed you asked for the full matrix of tests: >> patched QEMU + fd.v4 : doesn't boot (doesn't load kernel) >> unpatched + noswizzle : boots OK >> >> That's a bit confusing... > > It's not confusing. When you run unpatched qemu *on a big endian host*, > that's identical to what the patched code does *on a big endian host*. > > The full matrix actually has 8 elements (3 dimensions with 2 values per > dimension) -- host endianness, patched qemu vs. unpatched qemu, and > swizzling vs. non-swizzling firmware. To elaborate a bit more (I hope I can manage after several glasses of wine): The central idea is that the firmware should not swizzle directly in the transport code. It should only swizzle dependent on the individual integer encodings in the payload for a given key. QEMU's read accessor should build the host-endian representation of the big-endian interpretation of the fw_cfg *(sub)string*. This is what the patch does. The matrix is (guest endianness is invariably LE): qemu firmware swizzles host boots patched (== firmware is buggy) endianness ------- ---------------------- ---------- ------------------------- 0 0 BE yes (your test #4) 0 0 LE no (tested right now) 0 1 BE no (your test #1) 0 1 LE yes (my earliest test) 1 0 BE yes (your test #2) 1 0 LE yes (my test for this p.) 1 1 BE no (your test #3) 1 1 LE no (tested right now) Thanks Laszlo