Skip to contentSkip to conversation

vTPM: support little endian guests]

PATCH In review Hon Ching(Vicky) Lo 2 participants 2 messages Aug 24, 2015

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/2 vTPM: support little endian guests]

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 <[email protected]>
To: Peter Hüwe <[email protected]>
Cc: [email protected], Ashley Lai <[email protected]>, Vicky Lo <[email protected]>, [email protected], Joy Latten <[email protected]>
Subject: Re: [PATCH v4 1/2] vTPM: support little endian guests
Date: Fri, 17 Jul 2015 16:07:50 -0400

Quoted 50 lines · Peter Hüwe

Hi Vicky,
Am Donnerstag, 16. Juli 2015, 19:54:15 schrieb Hon Ching(Vicky) Lo:

Quoted 34 lines

Hi Peter,

Quoted 31 lines · Peter Hüwe

Hi Vicky,

sorry for the late reply

Quoted 12 lines

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.

b/drivers/char/tpm/tpm_eventlog.h index e7da086..267bfbd 100644

drivers/char/tpm/tpm_eventlog.h line 14

Quoted 9 lines
drivers/char/tpm/tpm_eventlog.h +5 -0
@@ -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?

Quoted 5 lines
Quoted 2 lines

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?

Quoted 2 lines

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

#1 lore raw

Am Montag, 24. August 2015, 21:07:32 schrieb Hon Ching(Vicky) Lo:

Quoted 5 lines

Hi Peter,

Did you the explanations in the following reply make sense to you? If you needed more clarifications, please advice. Thanks!

I trust your explanations - I just haven't gotten around to apply them. Sorry about that - will apply them for the next cycle.

Peter