<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Is it possible to do rdmsr instruction in android? it's a ring- in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/Is-it-possible-to-do-rdmsr-instruction-in-android-it-s-a-ring-0/m-p/827689#M6177</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;it's always possible to write a kernel module to execute ring-0
instructions.&lt;/P&gt;

&lt;P&gt;On my test device the msr0 and msr1 are accessible through the
/dev directory. So depending on your needs you can use the files there.&lt;/P&gt;

&lt;P&gt;I'm curious. Why you need to access the MSRs?&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;Alex&lt;/P&gt;</description>
    <pubDate>Thu, 19 Jan 2012 13:15:45 GMT</pubDate>
    <dc:creator>Alexander_W_Intel</dc:creator>
    <dc:date>2012-01-19T13:15:45Z</dc:date>
    <item>
      <title>Is it possible to do rdmsr instruction in android? it's a ring-0 instruction.</title>
      <link>https://community.intel.com/t5/Software-Archive/Is-it-possible-to-do-rdmsr-instruction-in-android-it-s-a-ring-0/m-p/827688#M6176</link>
      <description>Hi,&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;I am just wondering is it possible to have application to execute ring-0 instruction like RDMSR in Android OS with Intel Architecture?&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;~yannseng&lt;/DIV&gt;</description>
      <pubDate>Thu, 19 Jan 2012 06:49:03 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Is-it-possible-to-do-rdmsr-instruction-in-android-it-s-a-ring-0/m-p/827688#M6176</guid>
      <dc:creator>yannseng</dc:creator>
      <dc:date>2012-01-19T06:49:03Z</dc:date>
    </item>
    <item>
      <title>Is it possible to do rdmsr instruction in android? it's a ring-</title>
      <link>https://community.intel.com/t5/Software-Archive/Is-it-possible-to-do-rdmsr-instruction-in-android-it-s-a-ring-0/m-p/827689#M6177</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;it's always possible to write a kernel module to execute ring-0
instructions.&lt;/P&gt;

&lt;P&gt;On my test device the msr0 and msr1 are accessible through the
/dev directory. So depending on your needs you can use the files there.&lt;/P&gt;

&lt;P&gt;I'm curious. Why you need to access the MSRs?&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;Alex&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2012 13:15:45 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Is-it-possible-to-do-rdmsr-instruction-in-android-it-s-a-ring-0/m-p/827689#M6177</guid>
      <dc:creator>Alexander_W_Intel</dc:creator>
      <dc:date>2012-01-19T13:15:45Z</dc:date>
    </item>
    <item>
      <title>Is it possible to do rdmsr instruction in android? it's a ring-</title>
      <link>https://community.intel.com/t5/Software-Archive/Is-it-possible-to-do-rdmsr-instruction-in-android-it-s-a-ring-0/m-p/827690#M6178</link>
      <description>yes, you can execute on ring0&lt;BR /&gt;it's not the best feature though, it opens the door for root kits and such....</description>
      <pubDate>Thu, 26 Jan 2012 09:30:07 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Is-it-possible-to-do-rdmsr-instruction-in-android-it-s-a-ring-0/m-p/827690#M6178</guid>
      <dc:creator>qdb</dc:creator>
      <dc:date>2012-01-26T09:30:07Z</dc:date>
    </item>
    <item>
      <title>Is it possible to do rdmsr instruction in android? it's a ring-</title>
      <link>https://community.intel.com/t5/Software-Archive/Is-it-possible-to-do-rdmsr-instruction-in-android-it-s-a-ring-0/m-p/827691#M6179</link>
      <description>Hi Alex,&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;I don't think it is possible to write a kernel module within an application though even with NDK. Not going to deploy OS.&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;I just saw /dev/msr0 in my android x86 emulator but how do i use it? for example how do i read MSR 0x1A0.&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Just trying to read CPU temperature with RDMSR.&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Thanks,&lt;/DIV&gt;&lt;DIV&gt;YannSeng&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 30 Jan 2012 02:48:14 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Is-it-possible-to-do-rdmsr-instruction-in-android-it-s-a-ring-0/m-p/827691#M6179</guid>
      <dc:creator>yannseng</dc:creator>
      <dc:date>2012-01-30T02:48:14Z</dc:date>
    </item>
    <item>
      <title>Is it possible to do rdmsr instruction in android? it's a ring-</title>
      <link>https://community.intel.com/t5/Software-Archive/Is-it-possible-to-do-rdmsr-instruction-in-android-it-s-a-ring-0/m-p/827692#M6180</link>
      <description>&lt;P&gt;Below is typical code to read MSRs on linux.&lt;BR /&gt;The only change for android is to the pathname.&lt;BR /&gt;You may need to do 'modprobe msr' before running the code.&lt;BR /&gt;Pat&lt;BR /&gt;&lt;BR /&gt;int rdmsr_for_pat (int CPU_number, unsigned int MsrNum, unsigned long long *MsrVal)&lt;BR /&gt;{&lt;BR /&gt;static int nodriver=0;&lt;BR /&gt;char msrname[PATH_MAX];&lt;BR /&gt;unsigned char MsrBuffer[8];&lt;BR /&gt;int fh;&lt;BR /&gt;off_t offset, fpos;&lt;BR /&gt;/* Ok, use the /dev/CPU interface */&lt;BR /&gt;#ifdef __ANDROID__&lt;BR /&gt;snprintf (msrname,sizeof(msrname), "/dev/msr%d", CPU_number);&lt;BR /&gt;#else&lt;BR /&gt;snprintf (msrname,sizeof(msrname), "/dev/cpu/%d/msr", CPU_number);&lt;BR /&gt;#endif&lt;BR /&gt;fh = open (msrname, O_RDONLY);&lt;BR /&gt;if (fh != -1) {&lt;BR /&gt;offset = (off_t)MsrNum;&lt;BR /&gt;fpos = lseek (fh, offset, SEEK_SET);&lt;BR /&gt;if(fpos != offset)&lt;BR /&gt;{&lt;BR /&gt;printf("seek %s to offset= 0x%x failed at %s %d\n", &lt;BR /&gt;msrname, MsrNum, __FILE__, __LINE__);&lt;BR /&gt;return -1;&lt;BR /&gt;}&lt;BR /&gt;read (fh, MsrBuffer, sizeof(MsrBuffer));&lt;BR /&gt;if (MsrVal!=0) *MsrVal = (*(unsigned long long *)MsrBuffer);&lt;BR /&gt;close (fh);&lt;BR /&gt;return 0;&lt;BR /&gt;} else {&lt;BR /&gt;/* Something went wrong, just get out. */&lt;BR /&gt;printf("Open of msr dev= '%s' failed at %s %d\n", msrname, __FILE__, __LINE__);&lt;BR /&gt;printf("You may need to do (as root) 'modprobe msr'\n");&lt;BR /&gt;return -1;&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Mon, 06 Feb 2012 12:50:19 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Is-it-possible-to-do-rdmsr-instruction-in-android-it-s-a-ring-0/m-p/827692#M6180</guid>
      <dc:creator>Patrick_F_Intel1</dc:creator>
      <dc:date>2012-02-06T12:50:19Z</dc:date>
    </item>
    <item>
      <title>Is it possible to do rdmsr instruction in android? it's a ring-</title>
      <link>https://community.intel.com/t5/Software-Archive/Is-it-possible-to-do-rdmsr-instruction-in-android-it-s-a-ring-0/m-p/827693#M6181</link>
      <description>Hi,&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;I just took the code from Patrick and made a full example out of it to try it out. See below.&lt;/DIV&gt;&lt;DIV&gt;The code is working on the phone. Please note that I guessed the TJunction Max temperature for the CPU.&lt;/DIV&gt;&lt;DIV&gt;An issue you will be facing is that accessing the MSRs is only allowed for root.&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;PRE&gt;[cpp]#include &lt;STDIO.H&gt;
#include &lt;LINUX&gt;
#include &lt;FCNTL.H&gt;

#define IA32_THERMAL_STATUS 0x19C
//just a guess
#define TJ_MAX 90

int rdmsr_for_pat (int CPU_number, unsigned int MsrNum, unsigned long long *MsrVal) {
        static int nodriver=0;
        char msrname[PATH_MAX];
        unsigned char MsrBuffer[8];
        int fh;
        off_t offset, fpos;
        /* Ok, use the /dev/CPU interface */
        #ifdef __ANDROID__
                snprintf (msrname,sizeof(msrname), "/dev/msr%d", CPU_number);
        #else
                snprintf (msrname,sizeof(msrname), "/dev/cpu/%d/msr", CPU_number);
        #endif
        fh = open (msrname, O_RDONLY);
        if (fh != -1) {
                offset = (off_t)MsrNum;
                fpos = lseek (fh, offset, SEEK_SET);
                if(fpos != offset) {
                        printf("seek %s to offset= 0x%x failed at %s %dn",
                        msrname, MsrNum, __FILE__, __LINE__);
                        return -1;
                }
                read (fh, MsrBuffer, sizeof(MsrBuffer));
                if (MsrVal!=0) *MsrVal = (*(unsigned long long *)MsrBuffer);
                close (fh);
                return 0;
        } else {
                /* Something went wrong, just get out. */
                printf("Open of msr dev= '%s' failed at %s %dn", msrname, __FILE__, __LINE__);
                printf("You may need to do (as root) 'modprobe msr'n");
                return -1;
        }
}

int main() {
        unsigned long long ret = 0;
        rdmsr_for_pat(0, IA32_THERMAL_STATUS, &amp;amp;ret);
        printf("Result from MSR: %llxn", ret);
        unsigned int thermal_status = (unsigned int) ret;
        if (thermal_status &amp;amp;&amp;amp; 1&amp;lt;&amp;lt;31) {
                int dsr = ((thermal_status&amp;gt;&amp;gt;16) &amp;amp; 0x7F);
                printf("DSR reading: %un", dsr);
                printf("Temperature: %un", TJ_MAX-dsr);
        } else {
                printf("Invalid thermal status reading (Bit31 is not set)n");
        }
}
[/cpp]&lt;/FCNTL.H&gt;&lt;/LINUX&gt;&lt;/STDIO.H&gt;&lt;/PRE&gt; &lt;/DIV&gt;&lt;DIV&gt;Thanks,&lt;/DIV&gt;&lt;DIV&gt;Alex&lt;/DIV&gt;</description>
      <pubDate>Wed, 08 Feb 2012 09:57:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Is-it-possible-to-do-rdmsr-instruction-in-android-it-s-a-ring-0/m-p/827693#M6181</guid>
      <dc:creator>Alexander_W_Intel</dc:creator>
      <dc:date>2012-02-08T09:57:22Z</dc:date>
    </item>
    <item>
      <title>Is it possible to do rdmsr instruction in android? it's a ring-</title>
      <link>https://community.intel.com/t5/Software-Archive/Is-it-possible-to-do-rdmsr-instruction-in-android-it-s-a-ring-0/m-p/827694#M6182</link>
      <description>&lt;DIV&gt;Thank you so much for the replies, guys!&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;However, that's awful. Is there anyway to get root access for the phone? Else, all of this is meaningless.</description>
      <pubDate>Mon, 20 Feb 2012 03:04:38 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Is-it-possible-to-do-rdmsr-instruction-in-android-it-s-a-ring-0/m-p/827694#M6182</guid>
      <dc:creator>yannseng</dc:creator>
      <dc:date>2012-02-20T03:04:38Z</dc:date>
    </item>
  </channel>
</rss>

