Announcement

Collapse
No announcement yet.

MSR Reading Bug in MemTest86 for Virtual Machines

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • MSR Reading Bug in MemTest86 for Virtual Machines

    Hello Team,

    MemTest86 fails to run under VirtualBox.

    VirtualBox developers say that the way you're reading MSR registers is not correct:

    memtest is executing an rdmsr instruction for an MSR which is not existing for the selected CPU profile. This raises a #GP(0) exception which is not expected sending memtest into an error loop. They seem to assume that certain MSRs exist based on maybe CPUID values (they don't seem to expect that memtest can be run in a VM which has a stripped down CPU model).
    Trunk contains a Ryzen 1800X profile which adds this MSR and with that memtest works, you could try it from here. Whether we include the profile into the next 6.1 maintenance release is being discussed but memtest should probably handle non existing MSRs properly in the first place.
    Please fix.

    // Artem S. Tashkinov
    Last edited by bugmenot2; Oct-06-2020, 09:34 AM.

  • #2
    MSR are part of all modern CPUs.
    What this means is that Virtual box fails to correct emulate whatever real CPU it is they are trying to emulate. Doesn't make sense to emulate just some of the CPUs instructions/ registers (in my opinion this is asking for random unexpected crashes).

    i.e. their CPU profile is wrong.

    Comment


    • #3
      It sucks to work as a broken telephone but I've got no other choice.

      A reply from a VirtualBox developer:

      CPU profiles are used to present a more precise model of the host CPU to the guest, see the database we have in trunk here. By default the profile matching the host CPU the closest is selected (for 6.1 where the Ryzen profile does not exist VBox selects a "AMD FX-8150 Eight-Core" CPU iirc).
      The response of the memtest86 developer does not take into account that we don't emulate the CPU (what qemu without kvm or bochs are doing) but virtualize the real one so that the host and guest can share it. What this means is that we can't just pass through all available MSRs of the host CPU to the guest or it might mess up some internal state leading to host crashes. VirtualBox also can't emulate all existing MSRs for all possible CPUs because modern CPUs have thousands of those many of which are poorly documented or not documented at all by the vendor. Thatswhy VBox exposes only MSRs which are safe because they are emulated and pretends the other MSRs don't exist and throws a #GP(0) instead of ignoring reads or writes to them which can lead to weird mishbehavior inside the guest as well. This is a common technique in virtualization not only for MSRs but also when exposing features through cpuid, features which are not supported are stripped from what is presented to the guest.


      CPU profiles are used to present a more precise model of the host CPU to the guest, see the database we have in trunk here. By default the profile matching the host CPU the closest is selected (for 6.1 where the Ryzen profile does not exist VBox selects a "AMD FX-8150 Eight-Core" CPU iirc).
      The response of the memtest86 developer does not take into account that we don't emulate the CPU (what qemu without kvm or bochs are doing) but virtualize the real one so that the host and guest can share it. What this means is that we can't just pass through all available MSRs of the host CPU to the guest or it might mess up some internal state leading to host crashes. VirtualBox also can't emulate all existing MSRs for all possible CPUs because modern CPUs have thousands of those many of which are poorly documented or not documented at all by the vendor. Thatswhy VBox exposes only MSRs which are safe because they are emulated and pretends the other MSRs don't exist and throws a #GP(0) instead of ignoring reads or writes to them which can lead to weird mishbehavior inside the guest as well. This is a common technique in virtualization not only for MSRs but also when exposing features through cpuid, features which are not supported are stripped from what is presented to the guest.
      Maybe you could share what MSR registers you read/use exactly, so that I could pass this info onto VirtualBox developers.

      Comment


      • #4
        If possible, can you run MemTest86 on Virtualbox and send the MemTest86.log file stored under EFI\BOOT directory of the virtual disk.

        Comment


        • #5
          Originally posted by keith View Post
          If possible, can you run MemTest86 on Virtualbox and send the MemTest86.log file stored under EFI\BOOT directory of the virtual disk.
          Serial console output:

          Code:
          Retrieving hardware info. Please wait...
          Getting CPUID info...
          Getting cache size...
          Measuring CPU/cache/mem speeds...
          Retrieving CPU MSR data...
          !!!! X64 Exception Type - 0D(#GP - General Protection)  CPU Apic ID - 00000000 !!!!
          ExceptionData - 0000000000000000
          RIP  - 000000007D6CE0F5, CS  - 0000000000000038, RFLAGS - 0000000000010246
          RAX  - 0000000000000008, RCX - 00000000C0010292, RDX - 000000000000000F
          RBX  - 000000007D7A1720, RSP - 000000007F235E20, RBP - 000000007F235EE9
          RSI  - 0000000000000008, RDI - 00000000FFFFFFFF
          R8   - 000000007D790D60, R9  - 00000000C0010292, R10 - 0000000030726670
          R11  - 000000007F24E368, R12 - 0000000000000000, R13 - 0000000000000000
          R14  - 0000000000000001, R15 - 0000000000000018
          DS   - 0000000000000030, ES  - 0000000000000030, FS  - 0000000000000030
          GS   - 0000000000000030, SS  - 0000000000000030
          CR0  - 0000000080010033, CR2 - 0000000000000000, CR3 - 000000007F001000
          CR4  - 0000000000000668, CR8 - 0000000000000000
          DR0  - 0000000000000000, DR1 - 0000000000000000, DR2 - 0000000000000000
          DR3  - 0000000000000000, DR6 - 00000000FFFF0FF0, DR7 - 0000000000000400
          GDTR - 000000007EFF2018 0000000000000047, LDTR - 0000000000000000
          IDTR - 000000007EC09018 0000000000000FFF,   TR - 0000000000000000
          FXSAVE_STATE - 000000007F235A80
          !!!! Find image based on IP(0x7D6CE0F5) (No PDB)  (ImageBase=000000007D678000, EntryPoint=000000007D6783E0) !!!!
          A MemTest86.log attached.
          Attached Files
          Last edited by bugmenot2; Oct-20-2020, 07:51 PM.

          Comment


          • #6
            Thanks for the logs.

            We added a check to read MSRs only if we are not running in VirtualBox.

            Can you give this build a try:
            https://www.passmark.com/temp/memtes...b-8.4.1022.zip

            Comment


            • #7
              Originally posted by keith View Post
              Thanks for the logs.

              We added a check to read MSRs only if we are not running in VirtualBox.

              Can you give this build a try:
              https://www.passmark.com/temp/memtes...b-8.4.1022.zip
              Thanks! This build fixes the issue however I cannot make mouse work.

              VirtualBox has three options:
              • PS/2 Mouse
              • USB Tablet
              • USB Multi-touch Tablet
              None of them work - I see a mouse cursor on the screen but I cannot move it. Everything can be done using the keyboard, so it's not a big deal.

              Comment


              • #8
                I suspect the lack of mouse support in Virtualbox is out of our control.

                Comment

                Working...
                X