Hello,<br /><br />Thank you for the patch! I reviewed the code and noticed select issues explained below.<br /><br />1. The following construction:<br /><br /><span style="white-space: pre-wrap;">if (RegEbx == 0) {</span><br style="white-space: pre-wrap;" /><span style="white-space: pre-wrap;"> DEBUG ((DEBUG_ERROR, "The CPU is not capble for Core Crystal Clock Frequency !!\n"));</span><br style="white-space: pre-wrap;" /><span style="white-space: pre-wrap;"> ASSERT (RegEbx != 0);</span><br style="white-space: pre-wrap;" /><span style="white-space: pre-wrap;">}<br /><br /></span>Does not look good to me, and in my opinion, should be written differently:<br /><br /><span style="white-space: pre-wrap;">if (RegEbx == 0 || </span><span style="white-space: pre-wrap;">RegEax == 0</span><span style="white-space: pre-wrap;">) {</span><br style="white-space: pre-wrap;" /><span style="white-space: pre-wrap;"> DEBUG ((DEBUG_ERROR, "The CPU is not capble for Core Crystal Clock Frequency !!\n"));<br /></span><span style="white-space: pre-wrap;"> ASSERT (RegEbx != 0);</span><br style="white-space: pre-wrap;" />  ASSERT (RegEax != 0);<br />  return 0;<br style="white-space: pre-wrap;" /><span style="white-space: pre-wrap;">}</span><br /><br />The reason for the above code being wrong is potential division by zero below, which behaviour is undefined (and in fact unknown due to unspecified interrupt table state). Even though the intent is to not permit the use of this library on an unsupported platform, runtime checks and assertions are essentially NO-OPs, should be separate and not confused. For this to work properly the call to <span style="white-space: pre-wrap;">CpuidCoreClockCalculateTscFrequency should happen in library constructor with EFI_UNSUPPORTED return on </span><span style="white-space: pre-wrap;">CpuidCoreClockCalculateTscFrequency returning 0.</span><br /><br />2. The notes about crystal clock frequency for 06_55H CPU signature:<br /><span style="white-space: pre-wrap;">"25000000 - Intel Xeon Processor Scalable Family with CPUID signature 06_55H(25MHz).<BR>\n"<br /></span><span style="white-space: pre-wrap;"># Intel Xeon Processor Scalable Family with CPUID signature 06_55H = 25000000 (25MHz)<br /></span><span style="white-space: pre-wrap;"><br /></span>are misleading in both this library and Intel SDM. Intel Xeon W processors have the same CPUID signature (<span style="white-space: pre-wrap;">06_55H)</span>, they report 0 crystal clock frequency, and their crystal clock frequency is 24 MHz. This should at least be mentioned in the lower part mentioning <span style="white-space: pre-wrap;">Intel Xeon W Processor Family(24MHz).</span><br /><br /><span style="white-space: pre-wrap;">Actually, given that many Intel guys are here, I wonder whether anybody knows if there is any better approach to distinguish Xeon Scalable CPUs and Xeon W CPUs besides using brand string or using marketing frequency from CPUID 16H to determine crystal clock frequency (this is what Linux does at the moment)?</span><br /><br />3. Intel Atom Denverton with CPUID signature (06_5FH), also known as Goldmont X, reports 0 crystal clock frequency as well, and has 25 MHz frequency. This is missing from SDM, but once again I believe it should be included in the two places from the above to avoid confusion.<br /><br />Besides these 3 points, honestly, the library itself appears to be very limited for anything but embedding it into the firmware with known hardware, which already works just fine by defining the PCD. Missing 0 crystal clock frequency handling in runtime with hardcoding the PCD value looks very bad, because the number of modern Intel CPU models reporting 0 crystal clock frequency and having non 24 MHz frequency is quite far from 0. This makes the library essentially impossible to use in any UEFI application or third-party product even when targeting Skylake+ generation. To resolute this I vote for additional detection functionality to be added to the library to obtain crystal clock frequency when the CPUID reports 0. The PCD could be the last resort when no other method works. My opinion is that this should be resolved prior to merging the patch.<br /><br />Best regards,<br />Vitaly

<div width="1" style="color:white;clear:both">_._,_._,_</div>
<hr>
Groups.io Links:<p>

You receive all messages sent to this group.


<p>

<a target="_blank" href="https://edk2.groups.io/g/devel/message/45689">View/Reply Online (#45689)</a> |


  


|


  
    <a target="_blank" href="https://groups.io/mt/32839184/1813853">Mute This Topic</a>
  

| <a href="https://edk2.groups.io/g/devel/post">New Topic</a><br>



<br>

<a href="https://edk2.groups.io/g/devel/editsub/1813853">Your Subscription</a> |
<a href="mailto:devel+owner@edk2.groups.io">Contact Group Owner</a> |

<a href="https://edk2.groups.io/g/devel/unsub">Unsubscribe</a>

 [edk2-devel-archive@redhat.com]<br>
<div width="1" style="color:white;clear:both">_._,_._,_</div>