title: How to make changes to msr 0x199 from EFI stick?
body: <p>I have a macbookpro11,3 without a battery.  When battery is removed the firmware throttles the CPU to half speed.  In Windows I can override this using Throttlestop to turn off BD PROCHOT and set multiplier to 25.  I want to do this from EFI so that boot and updates run at a normal speed.</p>
  
  <p>Based on source for <a href="https://sourceforge.net/projects/refind/files/0.11.4/" rel="nofollow noreferrer">rEFInd</a> which updates 0x3a register I wrote this program but while BD PROCHOT is disabled correctly after booting into Windows the multiplier is not. </p>
  
  <pre><code>#include "../include/tiano_includes.h"
  static VOID DisablePROCHOT(VOID)
  {
      UINT32 msr = 0x1FC;
      UINT32 low_bits = 0, high_bits = 0;
  
      __asm__ volatile ("rdmsr" : "=a" (low_bits), "=d" (high_bits) : "c" (msr));
  
      // lowest bit is BD PROCHOT 
      low_bits &amp;= ~(1 &lt;&lt; 0);
  
      __asm__ volatile ("wrmsr" : : "c" (msr), "a" (low_bits), "d" (high_bits));
  } // VOID DisablePROCHOT()
  
  static VOID SetMultiplier25(VOID)
  {
      UINT32 msr = 0x199;
      UINT32 low_bits = 0, high_bits = 0;
  
      __asm__ volatile ("rdmsr" : "=a" (low_bits), "=d" (high_bits) : "c" (msr));
  
      // second lowest byte is multiplier
      // 25 is .... xxxxxxxx 00011001 xxxxxxxx 
      low_bits |= 1 &lt;&lt; 8;
      low_bits &amp;= ~(1 &lt;&lt; 9);
      low_bits &amp;= ~(1 &lt;&lt; 10);
      low_bits |= 1 &lt;&lt; 11;
      low_bits |= 1 &lt;&lt; 12;
      low_bits &amp;= ~(1 &lt;&lt; 13);
      low_bits &amp;= ~(1 &lt;&lt; 14);
      low_bits &amp;= ~(1 &lt;&lt; 15);
  
      __asm__ volatile ("wrmsr" : : "c" (msr), "a" (low_bits), "d" (high_bits));
  } // VOID SetMultiplier25()
  
  EFI_STATUS
  EFIAPI
  efi_main (
    IN EFI_HANDLE        ImageHandle,
    IN EFI_SYSTEM_TABLE  *SystemTable
    )
  {
    DisablePROCHOT();
    SetMultiplier25();
  
    return EFI_SUCCESS;
  }
  </code></pre>
  
  <p>Reading the registers with rdmsr from EFI appears to show both are set correctly however when booted into Windows while bit 0 of 0x1FC is correctly set off the multiplier stored in 0x199 is unchanged from the default of 12 when I expect it to be 25.</p>
  
  <p><strong>Default values</strong></p>
  
  <p>These are values after standard boot into Windows (from RWEverything)</p>
  
  <p><a href="https://i.stack.imgur.com/JYg4s.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JYg4s.png" alt="Standard boot"></a></p>
  
  <p><strong>Results after calling program</strong></p>
  
  <p>Program was called from EFI shell before calling Windows boot loader <em>bootmgfw.efi</em>  </p>
  
  <p>0x1FC is updated, 0x199 is not.</p>
  
  <p><a href="https://i.stack.imgur.com/bjYCM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bjYCM.png" alt="Boot after calling program"></a>  </p>
  
  <p>Updating 0x199 with RWEverything from within Windows changes the multiplier correctly so I'm fairly sure it is the correct register.</p>
  
  <p>As this is my first EFI (or C) program I may have overlooked something trivial.</p>