<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:"Lucida Console";
        panose-1:2 11 6 9 4 5 4 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="color:#1F497D">PS.. I would use the forum.. but I cannot sign up because recapcha on the site is broken.<br>
The recaptcha directs me to tell you to go to:<br>
g.co/recaptcha/upgrade<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Rusty Weber
<br>
<b>Sent:</b> Thursday, April 19, 2018 9:59 PM<br>
<b>To:</b> 'ipxe-devel@lists.ipxe.org'<br>
<b>Subject:</b> Big endian VS little endian decided during compile time.<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">After setting some machines to re-provision themselves through ipxe, I noted that some of the UUID’s I gathered from the running OS () of the system did not match the UUID that ipxe returned.<br>
Furthermore, I specifically noted a pattern in which the UUID’s returned by ipxe differed in a very big endian to little endian way for the first 8 bytes of the UUID (At first I wasn’t really certain why the last half of the ID worked fine).  To make matters
 more complicated, some of the machines in my lab work as expected while others do not.<br>
<br>
Example:<br>
(System UUID returned by installed OS) != (System UUID returned by ipxe)<br>
>From a Dell R-730<br>
44454c4c-4d00-1051-8037-b8c04f583532 != 4c4c4544-004d-5110-8037-b8c04f583532<br>
>From an HP DL-380 gen8<br>
32333536-3030-5355-4532-333343395834 == 32333536-3030-5355-4532-333343395834<o:p></o:p></p>
<p class="MsoNormal"><br>
The first 8 bytes of the first UUID returned by ipxe in the previous example are wrong,  either that or the Linux and windows guys both got their code for reading the value wrong.  In any case, those values should match and my investigation started with ipxe.<br>
Investigating where the UUID was being generated from, “<span style="font-size:9.0pt;font-family:"Lucida Console"">./core/uuid.c”</span> I noticed that the first half of the uuid was being printed out and processed by a number of macros defined in “<span style="font-size:9.0pt;font-family:"Lucida Console"">./include/byteswap.h“</span>
 named “be(16|32)_to_cpu”.  The names of these macros are as follows:<br>
<br>
```<br>
#if __BYTE_ORDER == __LITTLE_ENDIAN<o:p></o:p></p>
<p class="MsoNormal">#define __cpu_to_leNN( bits, value ) (value)<o:p></o:p></p>
<p class="MsoNormal">#define __cpu_to_beNN( bits, value ) __bswap_ ## bits (value)<o:p></o:p></p>
<p class="MsoNormal">#define __leNN_to_cpu( bits, value ) (value)<o:p></o:p></p>
<p class="MsoNormal">#define __beNN_to_cpu( bits, value ) __bswap_ ## bits (value)<o:p></o:p></p>
<p class="MsoNormal">#define __cpu_to_leNNs( bits, ptr ) do { } while ( 0 )<o:p></o:p></p>
<p class="MsoNormal">#define __cpu_to_beNNs( bits, ptr ) __bswap_ ## bits ## s (ptr)<o:p></o:p></p>
<p class="MsoNormal">#define __leNN_to_cpus( bits, ptr ) do { } while ( 0 )<o:p></o:p></p>
<p class="MsoNormal">#define __beNN_to_cpus( bits, ptr ) __bswap_ ## bits ## s (ptr)<o:p></o:p></p>
<p class="MsoNormal">#endif<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">#if __BYTE_ORDER == __BIG_ENDIAN<o:p></o:p></p>
<p class="MsoNormal">#define __cpu_to_leNN( bits, value ) __bswap_ ## bits (value)<o:p></o:p></p>
<p class="MsoNormal">#define __cpu_to_beNN( bits, value ) (value)<o:p></o:p></p>
<p class="MsoNormal">#define __leNN_to_cpu( bits, value ) __bswap_ ## bits (value)<o:p></o:p></p>
<p class="MsoNormal">#define __beNN_to_cpu( bits, value ) (value)<o:p></o:p></p>
<p class="MsoNormal">#define __cpu_to_leNNs( bits, ptr ) __bswap_ ## bits ## s (ptr)<o:p></o:p></p>
<p class="MsoNormal">#define __cpu_to_beNNs( bits, ptr ) do { } while ( 0 )<o:p></o:p></p>
<p class="MsoNormal">#define __leNN_to_cpus( bits, ptr ) __bswap_ ## bits ## s (ptr)<o:p></o:p></p>
<p class="MsoNormal">#define __beNN_to_cpus( bits, ptr ) do { } while ( 0 )<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt">#endif<o:p></o:p></p>
<p class="MsoNormal">#define be16_to_cpu( value ) __beNN_to_cpu ( 16, value )<o:p></o:p></p>
<p class="MsoNormal">#define be32_to_cpu( value ) __beNN_to_cpu ( 32, value )<o:p></o:p></p>
<p class="MsoNormal">```<br>
<br>
>From uuid.c<br>
```<br>
const char * uuid_ntoa ( const union uuid *uuid ) {<o:p></o:p></p>
<p class="MsoNormal">        static char buf[37]; /* "00000000-0000-0000-0000-000000000000" */<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">        sprintf ( buf, "%08x-%04x-%04x-%04x-%02x%02x%02x%02x%02x%02x",<o:p></o:p></p>
<p class="MsoNormal">                  be32_to_cpu ( uuid->canonical.a ),<o:p></o:p></p>
<p class="MsoNormal">                  be16_to_cpu ( uuid->canonical.b ),<o:p></o:p></p>
<p class="MsoNormal">                  be16_to_cpu ( uuid->canonical.c ),<o:p></o:p></p>
<p class="MsoNormal">                  be16_to_cpu ( uuid->canonical.d ),<o:p></o:p></p>
<p class="MsoNormal">                  uuid->canonical.e[0], uuid->canonical.e[1],<o:p></o:p></p>
<p class="MsoNormal">                  uuid->canonical.e[2], uuid->canonical.e[3],<o:p></o:p></p>
<p class="MsoNormal">                  uuid->canonical.e[4], uuid->canonical.e[5] );<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt">        return buf;<br>
```<br>
<br>
Here is where I get lost/ am not sure to proceed on, why does the UUID differ from the UUID that the OS returned?  Is it possible that there are difference between CPU’s where the valued in the UUID are not little endian?  Differences in endianness from uefi
 and the x86 bios images?<o:p></o:p></p>
<p class="MsoNormal">Russell Weber<br>
Software Support and Quality engineer<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>