<?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 Re: Regarding PVR register access from user space. in P-Series</title>
    <link>https://community.nxp.com/t5/P-Series/Regarding-PVR-register-access-from-user-space/m-p/148668#M13</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This particular emulation is not configurable.&amp;nbsp; It exists for legacy reasons.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What sort of check are you talking about?&amp;nbsp; Why would the decision to emulate PVR be based on whether the user has a SIGILL handler?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want the kernel to not emulate this, you can change the code in emulate_instruction() in arch/powerpc/kernel/traps.c.&amp;nbsp; Trying to eliminate all "extra jobs" from Linux might be an exercise in futility, though.&amp;nbsp; Why is your userspace accessing PVR?&amp;nbsp; What is the harm in the emulation?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 24 Oct 2012 01:22:51 GMT</pubDate>
    <dc:creator>scottwood</dc:creator>
    <dc:date>2012-10-24T01:22:51Z</dc:date>
    <item>
      <title>Regarding PVR register access from user space.</title>
      <link>https://community.nxp.com/t5/P-Series/Regarding-PVR-register-access-from-user-space/m-p/148667#M12</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif;"&gt;Hi All,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif;"&gt;I'm facing one bottleneck in using the mfpvr instruction on e500mc hardware (user space). This instruction/register execution/access is supervisor privilage, so register&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif;"&gt;access from user space should lead to illegal instruction.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif;"&gt;We I tried to access this PVR register from user space, the app is able to get the PVR value without extra provisioning.When I checked more from &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif;"&gt;Kernel perspective identified one procedure (eumulate_instructio) in traps.c which is emulating the program exceptions&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif;"&gt;irrespective of user/kernel mode.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif;"&gt;I have following queries:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif;"&gt;--&amp;gt; Is this kind of emulation is configurable one?? ( I don't see any compile time MACRO for PVR register).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif;"&gt;--&amp;gt; Any idea why there is no check placed to make sure the process (user level) has signal handler defined for illegal instructions which is about to emulate?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif;"&gt;--&amp;gt; How can remove such dependencies from Kernel ( I don't want the Kernel to perform any extra job like emulation)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif;"&gt;Thanks in Advance.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker" style="color: #000000; font-family: tahoma,arial,helvetica,sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Oct 2012 20:35:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/P-Series/Regarding-PVR-register-access-from-user-space/m-p/148667#M12</guid>
      <dc:creator>Simbu</dc:creator>
      <dc:date>2012-10-23T20:35:30Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding PVR register access from user space.</title>
      <link>https://community.nxp.com/t5/P-Series/Regarding-PVR-register-access-from-user-space/m-p/148668#M13</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This particular emulation is not configurable.&amp;nbsp; It exists for legacy reasons.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What sort of check are you talking about?&amp;nbsp; Why would the decision to emulate PVR be based on whether the user has a SIGILL handler?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want the kernel to not emulate this, you can change the code in emulate_instruction() in arch/powerpc/kernel/traps.c.&amp;nbsp; Trying to eliminate all "extra jobs" from Linux might be an exercise in futility, though.&amp;nbsp; Why is your userspace accessing PVR?&amp;nbsp; What is the harm in the emulation?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Oct 2012 01:22:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/P-Series/Regarding-PVR-register-access-from-user-space/m-p/148668#M13</guid>
      <dc:creator>scottwood</dc:creator>
      <dc:date>2012-10-24T01:22:51Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding PVR register access from user space.</title>
      <link>https://community.nxp.com/t5/P-Series/Regarding-PVR-register-access-from-user-space/m-p/148669#M14</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 10pt; color: #000000;"&gt;Thanks for quick reply Scott !&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 10pt; color: #000000;"&gt;We have a user space application to emulate all the illegal instructions from our end (user space) by creating a virtual environment. We have noticed that this instruction or register&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 10pt; color: #000000;"&gt;access is no more illegal in new kernel (2.6.34.10).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 10pt; color: #000000;"&gt;The problem with this behavior is a system which is under emulation still things that it is running on old hardware by referring to this PVR register,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 10pt; color: #000000;"&gt;but now the behavior is changed because our emulation app is able to retrieve the current running CPU PVR (not matching with virtual one) and not referring the virtual register.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 10pt; color: #000000;"&gt;Also, I can see these changes was not present in Linux 2.6.10 (PPC64) and added later on by patch..True??&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="color: #000000; font-size: 10pt; font-family: tahoma,arial,helvetica,sans-serif;"&gt;What sort of check are you talking about?&amp;nbsp; Why would the decision to emulate PVR be based on whether the user has a SIGILL handler?&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 10pt; color: #000000;"&gt;[S] Like, mentioned above if we have our own emulation path why Kernel is taking extra effort to perform the same.In the other way around, if the interrupted process (process executed the illegal instruction) has the facility to handle&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 10pt; color: #000000;"&gt;illegal instruction action then it impacts the user level virtual environment ?? (I'm not sure whether same applicable for KVM??)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="color: #000000; font-size: 10pt; font-family: tahoma,arial,helvetica,sans-serif;"&gt;If you want the kernel to not emulate this, you can change the code in emulate_instruction() in arch/powerpc/kernel/traps.c.&amp;nbsp; Trying to eliminate all "extra jobs" from Linux might be an exercise in futility, though. &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 10pt; color: #000000;"&gt;[S] Yea.. We're in the progress of making these code changes, but thought some generic check (which will help open source too) to avoid the above situation.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="color: #000000; font-size: 10pt; font-family: tahoma,arial,helvetica,sans-serif;"&gt;Why is your userspace accessing PVR? &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 10pt; color: #000000;"&gt;[S] Operating system which we are emulating from user space level is accessing the PVR and expectation here is to invoke the illegal handler bound for this action.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="color: #000000; font-size: 10pt; font-family: tahoma,arial,helvetica,sans-serif;"&gt;What is the harm in the emulation?&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 10pt; color: #000000;"&gt;[S] Because of this emulation (@Kernel level), the user level process is able to get a new PVR instead of Virtual/hardocoded value which has broken the illusion between the operating system and emulator/hardware.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker" style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 10pt; color: #000000;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Oct 2012 06:41:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/P-Series/Regarding-PVR-register-access-from-user-space/m-p/148669#M14</guid>
      <dc:creator>Simbu</dc:creator>
      <dc:date>2012-10-24T06:41:13Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding PVR register access from user space.</title>
      <link>https://community.nxp.com/t5/P-Series/Regarding-PVR-register-access-from-user-space/m-p/148670#M15</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Simbu wrote:&lt;/P&gt;&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 10pt; color: #000000;"&gt;Thanks for quick reply Scott !&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="min-height: 8pt; padding: 0px;"&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 10pt; color: #000000;"&gt;We have a user space application to emulate all the illegal instructions from our end (user space) by creating a virtual environment. We have noticed that this instruction or register&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 10pt; color: #000000;"&gt;access is no more illegal in new kernel (2.6.34.10).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="min-height: 8pt; padding: 0px;"&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 10pt; color: #000000;"&gt;The problem with this behavior is a system which is under emulation still things that it is running on old hardware by referring to this PVR register,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 10pt; color: #000000;"&gt;but now the behavior is changed because our emulation app is able to retrieve the current running CPU PVR (not matching with virtual one) and not referring the virtual register.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="min-height: 8pt; padding: 0px;"&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 10pt; color: #000000;"&gt;Also, I can see these changes was not present in Linux 2.6.10 (PPC64) and added later on by patch..True??&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;&lt;P&gt;PVR has been emulated by the Linux kernel since the beginning of arch/powerpc (see emulate_instruction() in&amp;nbsp; commit 14cf11af6cf608eb8c23e989ddb17a715ddce109).&amp;nbsp; It was present in arch/ppc and arch/ppc64 as of the first git commit (1da177e4c3f41524e886b7f1b8a0c1fc7321cac2) which represented v2.6.12-rc2.&amp;nbsp; I don't know when prior to that it was added, but it's been around a long time.&lt;/P&gt;&lt;BLOCKQUOTE&gt;
&lt;P style="min-height: 8pt; padding: 0px;"&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM style="color: #000000; font-size: 10pt; font-family: tahoma,arial,helvetica,sans-serif;"&gt;What sort of check are you talking about?&amp;nbsp; Why would the decision to emulate PVR be based on whether the user has a SIGILL handler?&lt;/EM&gt;&lt;/P&gt;
&lt;P style="min-height: 8pt; padding: 0px;"&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 10pt; color: #000000;"&gt;[S] Like, mentioned above if we have our own emulation path why Kernel is taking extra effort to perform the same.In the other way around, if the interrupted process (process executed the illegal instruction) has the facility to handle&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 10pt; color: #000000;"&gt;illegal instruction action then it impacts the user level virtual environment ?? (I'm not sure whether same applicable for KVM??)&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;&lt;P&gt;Having a SIGILL handler registered does not mean you want to emulate everything yourself.&amp;nbsp; There are lots of reasons for registering such a handler -- you may just want the ability to do some cleanup and error logging before the process dies.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;KVM has its own exception handling and is not affected by this (though we do not support PVR different from host in KVM on embedded PPC -- we can't even trap on it when using HV extensions).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Running kernel code in an ordinary user process is not supported, regardless of what signal handlers you have installed.&amp;nbsp; If you can make it work to your satisfaction, great, but expect difficulty.&amp;nbsp; If you really need to do this, and need the code to see a different PVR, I suggest using QEMU to emulate the CPU in question.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 08:50:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/P-Series/Regarding-PVR-register-access-from-user-space/m-p/148670#M15</guid>
      <dc:creator>scottwood</dc:creator>
      <dc:date>2020-10-29T08:50:23Z</dc:date>
    </item>
  </channel>
</rss>

