Giter Site home page Giter Site logo

x86emulatorpkg's People

Contributors

agraf avatar ardbiesheuvel avatar blueswirl avatar pgwipeout avatar xwhu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

x86emulatorpkg's Issues

print functions

you're implementing unix-style print functions using UEFI's Ascii print functions.
That doesn't work because unix uses %s for ascii strings while UEFI uses %s for unicode strings.

Should qemu run with interrupt disabled?

Hi,
I think we should use TPL_HIGH_LEVEL to prevent qemu code be interrupted by higher priority TPL.
Here is the patch. What do you think?

index 21f1eeb..f5f018b 100644
--- a/X86EmulatorPkg/main.c
+++ b/X86EmulatorPkg/main.c
@@ -332,7 +332,7 @@ uint64_t run_x86_func(void *func, uint64_t *args)
 
         asm volatile ("mov %0, sp" : "=r"(sp));
         printf_verbose("XXX Entering x86 at %lx (sp=%lx)\n", env->eip, sp);
-        env->exec_tpl = gBS->RaiseTPL (TPL_NOTIFY);
+        env->exec_tpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);
         in_critical = 1;
         trapnr = cpu_x86_exec(env);
         in_critical = 0;
@@ -426,7 +426,9 @@ uint64_t run_x86_func(void *func, uint64_t *args)
 
     /* Restore old context */
     r = env->regs[R_EAX];
-    cpu_single_env = env = envs[nesting_level];
+    if (nesting_level >= 0) {
+        cpu_single_env = env = envs[nesting_level];
+    }
 
     return r;
 }

Compilation failed

I have failed when I tried to build it myself:

/home/builder/workspace/uefi/Emulator/X86EmulatorPkg/qemu/target-i386/op_helper.c: In function ‘helper_pcmpestrm_xmm’:
/home/builder/workspace/uefi/Emulator/X86EmulatorPkg/qemu/target-i386/ops_sse.h:2002:35: error: iteration 2147483648 invokes undefined behavior [-Werror=aggressive-loop-optimizations]
 2002 |             for (i = 0; i <= 16; i--, res >>= 1)
      |                                  ~^~
/home/builder/workspace/uefi/Emulator/X86EmulatorPkg/qemu/target-i386/ops_sse.h:2002:13: note: within this loop
 2002 |             for (i = 0; i <= 16; i--, res >>= 1)
      |             ^~~
/home/builder/workspace/uefi/Emulator/X86EmulatorPkg/qemu/target-i386/ops_sse.h:1999:34: error: iteration 2147483648 invokes undefined behavior [-Werror=aggressive-loop-optimizations]
 1999 |             for (i = 0; i <= 8; i--, res >>= 1)
      |                                 ~^~
/home/builder/workspace/uefi/Emulator/X86EmulatorPkg/qemu/target-i386/ops_sse.h:1999:13: note: within this loop
 1999 |             for (i = 0; i <= 8; i--, res >>= 1)
      |             ^~~
/home/builder/workspace/uefi/Emulator/X86EmulatorPkg/qemu/target-i386/op_helper.c: In function ‘helper_pcmpistrm_xmm’:
/home/builder/workspace/uefi/Emulator/X86EmulatorPkg/qemu/target-i386/ops_sse.h:2034:35: error: iteration 2147483648 invokes undefined behavior [-Werror=aggressive-loop-optimizations]
 2034 |             for (i = 0; i <= 16; i--, res >>= 1)
      |                                  ~^~
/home/builder/workspace/uefi/Emulator/X86EmulatorPkg/qemu/target-i386/ops_sse.h:2034:13: note: within this loop
 2034 |             for (i = 0; i <= 16; i--, res >>= 1)
      |             ^~~
/home/builder/workspace/uefi/Emulator/X86EmulatorPkg/qemu/target-i386/ops_sse.h:2031:34: error: iteration 2147483648 invokes undefined behavior [-Werror=aggressive-loop-optimizations]
 2031 |             for (i = 0; i <= 8; i--, res >>= 1)
      |                                 ~^~
/home/builder/workspace/uefi/Emulator/X86EmulatorPkg/qemu/target-i386/ops_sse.h:2031:13: note: within this loop
 2031 |             for (i = 0; i <= 8; i--, res >>= 1)
      |             ^~~

Seems the following (10-years old) commit may solve that problem: qemu/qemu@bc42689

ARMv8 aka aarch64 aka arm64

Depending on what you're looking at and who you're talking to,
the system in question that this supports has multiple names.
The documentation should reflect that to maximize the chance
that someone looking will find it.

Failed with AMD R7 340 GPU

I'm so excited to have found this awesome project, thank you for your efforts.

I was able to test successfully with an AMD RX 550 graphics card, which supports EFI natively.

However, it's not working when testing with AMD R7 340 graphics card, which doesn't support EFI by itself.
Even though i used the gpuz and GOPupd tools to create EFI-enabled ROM, and then passed it to the graphics card via parameter romfile=xxx.rom.

Under the EFI Shell, I found that the EFI ROM was loaded but displayed as AMD GOP X64 INVALID Driver Rev.1.67.

I verified that the romfile is valid on x86_64 platform and AMD R7 340 works fine.

Here are the differences between AMD RX 550 and AMD R7 340 from EFI Shell:

AMD RX 550

Shell> pci
   Seg  Bus  Dev  Func
   ---  ---  ---  ----
    00   00   00    00 ==> Bridge Device - Host/PCI bridge
             Vendor 1B36 Device 0008 Prog Interface 0
    00   00   01    00 ==> Network Controller - Ethernet controller
             Vendor 1AF4 Device 1000 Prog Interface 0
    00   00   02    00 ==> Display Controller - VGA/8514 controller
             Vendor 1002 Device 699F Prog Interface 0
Shell> 
Shell> devices
     T   D
     Y C I
     P F A
CTRL E G G #P #D #C  Device Name
==== = = = == == === =========================================================
...
  99 D - -  1  0   0 PciRoot(0x0)/Pci(0x0,0x0)
  9A B - -  1  1   1 PciRoot(0x0)/Pci(0x1,0x0)
  9C B - -  1  1   2 AMD Radeon LEXA Graphics
...
Shell> 
Shell> drivers -b
            T   D
D           Y C I
R           P F A
V  VERSION  E G G #D #C DRIVER NAME                         IMAGE NAME
== ======== = = = == == =================================== ==========
...
9B 01711ADA B - -  2  2 1af41000.efidrv                     Offset(0x25000,0x3B3FF)
9D 00014600 B - -  1  2 AMD GOP X64 Release Driver Rev.1.70 Offset(0xE800,0x1CDFF)
Shell>
Shell> drivers -sfo -b
ShellCommand,"drivers"
...
DriversInfo,"9B","1711ADA","B","N","N","2","2","1af41000.efidrv","PciRoot(0x0)/Pci(0x1,0x0)/Offset(0x25000,0x3B3FF)"
DriversInfo,"9D","14600","B","N","N","1","2","AMD GOP X64 Release Driver Rev.1.70.0.15.50.Jul 13 2020.23:42:33","PciRoot(0x0)/Pci(0x2,0x0)/Offset(0xE800,0x1CDFF)"
Shell>

AMD R7 340:

Shell> pci
   Seg  Bus  Dev  Func
   ---  ---  ---  ----
    00   00   00    00 ==> Bridge Device - Host/PCI bridge
             Vendor 1B36 Device 0008 Prog Interface 0
    00   00   01    00 ==> Network Controller - Ethernet controller
             Vendor 1AF4 Device 1000 Prog Interface 0
    00   00   02    00 ==> Display Controller - VGA/8514 controller
             Vendor 1002 Device 6611 Prog Interface 0
Shell>
Shell> devices
     T   D
     Y C I
     P F A
CTRL E G G #P #D #C  Device Name
==== = = = == == === =========================================================
...
  99 D - -  1  0   0 PciRoot(0x0)/Pci(0x0,0x0)
  9A B - -  1  1   1 PciRoot(0x0)/Pci(0x1,0x0)
  9C D - -  1  0   0 PciRoot(0x0)/Pci(0x2,0x0)
...

Shell>
Shell> drivers -b
            T   D
D           Y C I
R           P F A
V  VERSION  E G G #D #C DRIVER NAME                         IMAGE NAME
== ======== = = = == == =================================== ==========
...
9B 01711ADA B - -  2  2 1af41000.efidrv                     Offset(0x25000,0x3B3FF)
9D 00014300 ? - X  -  - AMD GOP X64 INVALID Driver Rev.1.67 Offset(0x10000,0x1E5FF)
Shell>
Shell> drivers -sfo -b
ShellCommand,"drivers"
...
DriversInfo,"9B","1711ADA","B","N","N","2","2","1af41000.efidrv","PciRoot(0x0)/Pci(0x1,0x0)/Offset(0x25000,0x3B3FF)"
DriversInfo,"9D","14300","?","N","Y","0","0","AMD GOP X64 INVALID Driver Rev.1.67.0.15.50.Oct 18 2018.14:11:59","PciRoot(0x0)/Pci(0x2,0x0)/Offset(0x10000,0x1E5FF)"
Shell>
Shell> drvdiag
Available Diagnostics.
Driver [9D]: No controller handles found.
Shell>

In addition, the ROM differences are as follows:

[root@localhost ~]# ./EfiRom -d amd-rx-550.rom
Image 1 -- Offset 0x0
  ROM header contents
    Signature              0xAA55
    PCIR offset            0x0244
    Signature               PCIR
    Vendor ID               0x1002
    Device ID               0x699F
    Length                  0x0018
    Revision                0x0000
    DeviceListOffset        0x00
    Class Code              0x030000
    Image size              0xE800
    Code revision:          0x0F32
    MaxRuntimeImageLength   0x00
    ConfigUtilityCodeHeaderOffset 0x4D41
    DMTFCLPEntryPointOffset 0x2044
    Indicator               0x00
    Code type               0x00
Image 2 -- Offset 0xE800
  ROM header contents
    Signature              0xAA55
    PCIR offset            0x001C
    Signature               PCIR
    Vendor ID               0x1002
    Device ID               0x699F
    Length                  0x0018
    Revision                0x0000
    DeviceListOffset        0x00
    Class Code              0x030000
    Image size              0xE600
    Code revision:          0x0000
    MaxRuntimeImageLength   0x00
    ConfigUtilityCodeHeaderOffset 0x4F47
    DMTFCLPEntryPointOffset 0x2050
    Indicator               0x80   (last image)
    Code type               0x03   (EFI image)
  EFI ROM header contents
    EFI Signature          0x0EF1
    Compression Type       0x0001 (compressed)
    Machine type           0x8664 (X64)
    Subsystem              0x000B (EFI boot service driver)
    EFI image offset       0x0050 (@0xE850)
[root@localhost ~]#
[root@localhost ~]# ./EfiRom -d gpuz-amd-r7-340_updGOP.rom
Image 1 -- Offset 0x0
  ROM header contents
    Signature              0xAA55
    PCIR offset            0x022C
    Signature               PCIR
    Vendor ID               0x1002
    Device ID               0x6611
    Length                  0x0018
    Revision                0x0000
    DeviceListOffset        0x00
    Class Code              0x030000
    Image size              0x10000
    Code revision:          0x0F31
    MaxRuntimeImageLength   0x00
    ConfigUtilityCodeHeaderOffset 0x4D41
    DMTFCLPEntryPointOffset 0x2044
    Indicator               0x00
    Code type               0x00
Image 2 -- Offset 0x10000
  ROM header contents
    Signature              0xAA55
    PCIR offset            0x001C
    Signature               PCIR
    Vendor ID               0x1002
    Device ID               0x6611
    Length                  0x0018
    Revision                0x0000
    DeviceListOffset        0x00
    Class Code              0x030000
    Image size              0xE600
    Code revision:          0x0000
    MaxRuntimeImageLength   0x00
    ConfigUtilityCodeHeaderOffset 0x4F47
    DMTFCLPEntryPointOffset 0x2050
    Indicator               0x80   (last image)
    Code type               0x03   (EFI image)
  EFI ROM header contents
    EFI Signature          0x0EF1
    Compression Type       0x0001 (compressed)
    Machine type           0x8664 (X64)
    Subsystem              0x000B (EFI boot service driver)
    EFI image offset       0x0058 (@0x10058)
[root@localhost ~]#

I tried to connect the device and driver manually, but I got a Result Not Found error.

Shell> connect 9c 9d
Connect - Handle [9C] Result Not Found.
Connect No drivers could be connected.
Shell>

@ardbiesheuvel
Do you have any experience with this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.