Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932136AbbHXTIk (ORCPT ); Mon, 24 Aug 2015 15:08:40 -0400 Received: from e23smtp01.au.ibm.com ([202.81.31.143]:38476 "EHLO e23smtp01.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751989AbbHXTIi (ORCPT ); Mon, 24 Aug 2015 15:08:38 -0400 X-Helo: d23dlp01.au.ibm.com X-MailFrom: honclo@linux.vnet.ibm.com X-RcptTo: linux-kernel@vger.kernel.org Subject: [Fwd: Re: [PATCH v4 1/2] vTPM: support little endian guests] From: "Hon Ching(Vicky) Lo" To: peterhuewe@gmx.de Cc: tpmdd-devel@lists.sourceforge.net, ashley@ashleylai.com, honclo2014@gmail.com, linux-kernel@vger.kernel.org, jmlatten@linux.vnet.ibm.com Content-Type: text/plain; charset="UTF-8" Date: Mon, 24 Aug 2015 15:07:32 -0400 Message-ID: <1440443252.4381.4.camel@vtpm2014.ibm.com> Mime-Version: 1.0 X-Mailer: Evolution 2.32.3 (2.32.3-34.el6) Content-Transfer-Encoding: 8bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15082419-1618-0000-0000-000002A89948 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3371 Lines: 115 Hi Peter, Did you the explanations in the following reply make sense to you? If you needed more clarifications, please advice. Thanks! -------- Forwarded Message -------- From: Hon Ching(Vicky) Lo To: Peter Hüwe Cc: tpmdd-devel@lists.sourceforge.net, Ashley Lai , Vicky Lo , linux-kernel@vger.kernel.org, Joy Latten Subject: Re: [PATCH v4 1/2] vTPM: support little endian guests Date: Fri, 17 Jul 2015 16:07:50 -0400 On Thu, 2015-07-16 at 20:43 +0200, Peter Hüwe wrote: > Hi Vicky, > Am Donnerstag, 16. Juli 2015, 19:54:15 schrieb Hon Ching(Vicky) Lo: > > Hi Peter, > > > > On Mon, 2015-07-13 at 23:08 +0200, Peter Hüwe wrote: > > > Hi Vicky, > > > > > > sorry for the late reply > > > > > > > This patch makes the code endianness independent. We defined a > > > > macro do_endian_conversion to apply endianness to raw integers > > > > in the event entries so that they will be displayed properly. > > > > tpm_binary_bios_measurements_show() is modified for the display. > > > > > > > > Signed-off-by: Hon Ching(Vicky) Lo > > > > Signed-off-by: Joy Latten > > > > > > > > b/drivers/char/tpm/tpm_eventlog.h index e7da086..267bfbd 100644 > > > > --- a/drivers/char/tpm/tpm_eventlog.h > > > > +++ b/drivers/char/tpm/tpm_eventlog.h > > > > @@ -6,6 +6,12 @@ > > > > > > > > #define MAX_TEXT_EVENT 1000 /* Max event string length */ > > > > #define ACPI_TCPA_SIG "TCPA" /* 0x41504354 /'TCPA' */ > > > > > > > > +#ifdef CONFIG_PPC64 > > > > +#define do_endian_conversion(x) be32_to_cpu(x) > > > > +#else > > > > +#define do_endian_conversion(x) x > > > > +#endif > > > > > > Why is this macro needed? > > > shouldn't the be32_to_cpu macro already do correct thing? > > > Or am I missing something here? > > > > > > > > > Thanks, > > > Peter > > > > The macro is defined to not do the conversion in the architecture > > that does not need it. > > Unfortunately I'm still not convinced this is needed? > be32_to_cpu(x) > should already do the right thing if no conversion is needed ? (being defined > as (x)) > Or is it not? > > > > Peter > include/linux/byteorder/generic.h: #define be32_to_cpu __be32_to_cpu include/uapi/linux/byteorder/little_endian.h: #define __be32_to_cpu(x) __swab32((__force __u32)(__be32)(x)) include/uapi/linux/byteorder/big_endian.h: #define __be32_to_cpu(x) ((__force __u32)(__be32)(x)) The above defines show that be32_to_cpu(x) would do a byte swap on x. The defines for __be32_to_cpu(x) in both little_endian.h and big_endian.h are doing the "right thing" that you mentioned. However, with the architecture differences between ppc64 and x86 for instance, we need the new macro to not do the conversion. The power firmware will always be in BE. Therefore, firmware will pass BE data to an LE operating system, so the conversion is needed. Whereas for an x86 system, BIOS gives LE data to the LE OS. (i.e. the macro is needed for LE support. Does it make sense? Vicky -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/