Follow Slashdot stories on Twitter

 



Forgot your password?
typodupeerror
×
Java Programming

Java-Based x86 Emulator 263

jaavaaguru writes "Researchers at Oxford University have produced a Java-based x86 emulator that they hope will be useful in testing applications and learning about viruses without damaging the host, utilizing the robust sandboxing that Java provides. They have an online demo available that boots DOS and has some games to play. Being purely Java, this emulator should be able to run on almost anything, including cell phones." The code is not yet available outside the Oxford community; the developers are said to be working on a suitable general license. In the meantime the code can be licensed on a case-by-case basis.
This discussion has been archived. No new comments can be posted.

Java-Based x86 Emulator

Comments Filter:
  • by dreamchaser ( 49529 ) on Saturday March 24, 2007 @05:08PM (#18473349) Homepage Journal
    I can only imagine that this will make even Bochs look fast in comparison!

    Still, I'd love to tinker with this from a 'gee whiz' standpoint.
    • Re:Interesting, but (Score:5, Interesting)

      by Qwertie ( 797303 ) on Saturday March 24, 2007 @05:22PM (#18473419) Homepage
      I'd have to agree. Using instruction-by-instruction emulation, a C++ based SNES emulator I wrote around 1998 used at least 150Mhz of processing power to emulate the SNES' 3Mhz processor. When I rewrote it in assembly, it was 5-10 times faster. I expect that some pretty sophisticated techniques would be required to exceed a snail's pace when using Java for emulation, eg "dynamic recompilation": translating sections of x86 machine language to Java bytecode... but getting this to work 100% correctly would be pretty tricky.

      If it's hard to get good emulation speed in C++, it's even harder in Java.
      • by leuk_he ( 194174 ) on Saturday March 24, 2007 @05:47PM (#18473611) Homepage Journal
        THe next question would be: can you run java in the x86 emulator that runs an other emulator that runs java, that runs an other emulator.

        Just like the old days when you ran windows real mode under a windows 386 mode windows.
      • by saboola ( 655522 )
        If I might ask, what emulator was it? I have been an emulator nut for a little over a decade and would love to know if I used yours.
      • Re: (Score:3, Insightful)

        by chorltonian ( 887201 )
        Errm... how about trying it out before judging it? As has been covered god knows how many times before, Java is capable of runtime optimisations not possible with statically compiled languages like C++.
        • by shaitand ( 626655 ) on Saturday March 24, 2007 @06:56PM (#18474091) Journal
          'Java is capable of runtime optimisations not possible with statically compiled languages like C++.'

          And with them it can perform almost as fast as C in some fringe cases.
        • Re: (Score:3, Interesting)

          Java is capable of runtime optimisations not possible with statically compiled languages like C++.

          There is a world of difference between "theoretically capable" and "reliable does". Is there some practical demonstration that compute-intensive tasks like emulation can be reliably executed with Java without sucking?

        • by Anonymous Coward on Saturday March 24, 2007 @08:03PM (#18474485)
          Don't you know, around here:
          • All Java is slow
          • All Perl is unreadable
          • All PHP is insecure
          • All JavaScript is a useless intrusion into your browser
          ... and all comments like those are written by "experts" who've never written one line in the language in question.
          • Re: (Score:3, Funny)

            Ridiculous! Java can perform NOPs as fast as any compiled language.
            • Much faster, actually, thanks to its opportunity to perform runtime optimizations. Why, I've even heard rumours that it can extremely effeciently parallelize particularly long NOP loops!
          • All Java is slow

            Compared to C++, yes, it typically is. But it's usually within 20-30%, sometimes a bit worse, sometiems a bit better. In some rare cases, Java can even beat machine-code compiled languages.

            All Perl is unreadable

            Absolutely not. But Perl culture encourages the kind of programming which leads to unreadable code. And Perl syntax certainly doesn't help either.

            I would much, much rather work on Java code that someone else wrote. It's not that you can't write horrible Java code, it's just that the l

        • by MobyTurbo ( 537363 ) on Saturday March 24, 2007 @08:42PM (#18474809)

          Errm... how about trying it out before judging it? As has been covered god knows how many times before, Java is capable of runtime optimisations not possible with statically compiled languages like C++.
          Maybe so, but it is running much slower than DOSEMU or DOSBOX does in Linux here, which are probably written in C or C++, with possibly some assembly; and can do emulation of all the games it emulates. Java is indeed capable of certain optimizations that are not done in a non-JIT compiler, but that simply is because it needs them. Anyone who tells you that Java operating system emulators typically run faster than C operating system emulators has been smoking SUNW crack. That having been said, there are reasons for choosing Java over C. One of them is built-in security sandboxing, which was obviously the reason for the choice.
        • Re: (Score:3, Insightful)

          by tomhudson ( 43916 )

          Errm... how about trying it out before judging it?

          errm ... how about because the applet failed to load?

          If you go to the site, you'll see their premise is stupid - that game companies will license this to sell old dos games on cell phones, rather than porting them. Of course what they overloook is once you have the emulator, you don't need the game companies - just go through any abandonware site, or your stacks of old floppies.

      • by mgiuca ( 1040724 )

        "dynamic recompilation": translating sections of x86 machine language to Java bytecode...
        Which then gets dynamically recompiled by the Java VM into x86 machine language :)

        (At least, when running on an actual x86).

        Seriously though, this is quite impressive (to have it written in Java). But what are the advantages of this versus QEMU? (Besides a wider range of platforms). I mean... QEMU already offers total sandboxing doesn't it?
    • It's not bad - admittedly it's running DOS - but Prince of Persia seems to run nicely.
    • Sure, an x86 interpreter written in Java is going to be pretty slow, but a JIT written in Java beats a C interpreter (bochs) any day.
    • by mrmeval ( 662166 )
      Why Java? Qemu works as does VMWare and others....

  • So... (Score:5, Funny)

    by mriya3 ( 803189 ) on Saturday March 24, 2007 @05:11PM (#18473369) Homepage
    ... now we should say: "x86 assembler: write once, run everywhere (slow as molasses in January)" ?
    • Molasses - 35mph! (Score:3, Interesting)

      by Anonymous Coward
    • ... now we should say: "x86 assembler: write once, run everywhere (slow as molasses in January)" ?

      You know what would really be kewl? If you could make an integrated circuit that runs java real fast then you would have a chip that runs x86 assembly.
      • 'You know what would really be kewl? If you could make an integrated circuit that runs java real fast then you would have a chip that runs x86 assembly.'

        Why wouldn't you just grab a Pentium 266 and have a chip that runs x86 assembly at twice the speed this thing will on my dual core athlon?
  • by lbft ( 950835 )
    Whilst this looks like a really interesting project, I'm failing to see how it's useful generally due to the limitations of writing it in Java and making it cross-platform. You would lose a lot of those possible (processor- or platform-specific) optimisations that make the leaders in the virtualisation market as fast as they are.

    On, say, a mobile phone (which is mentioned by the site as a possible use) would there be enough processing grunt to do anything useful? I know Java's not as slow as some people wou
    • Well for one (Score:5, Interesting)

      by brunes69 ( 86786 ) <`gro.daetsriek' `ta' `todhsals'> on Saturday March 24, 2007 @05:31PM (#18473479)
      For one this will let you run X86 DOS applications on a SPARC for example.

      I'd like you to point me to the support page for VMWare on SPARC... oh wait that's cause there isn't one. QEMU can't even run most applications on a SPARC.

      And forget about ARM.

      I think this is great. Java is not as slow as people seem to think it is. One thing Java 5 (and 6) have that actually benefits virtualization is dynamic recompilation... the JVM knows the instruction sdequences better than the original author, and in theory can optimize the code paths in ways writing a virtualizer in assembly or C++ can not.

      • Re: (Score:3, Interesting)

        by EvilIdler ( 21087 )
        Java isn't all that slow, but the bad rep is because of its startup time and a really unoptimised GUI.
        It's fine for all sorts of things while running, but the two apps I use it for aren't exactly impressive.
        If I leave Azureus up for a while, it's eating 400 megs of memory. It also takes 10+ seconds to show
        its window. The other thing I regularly use Java for is my bank, which insists on using a friggin'
        control in its window. It takes about a minute to show up, even with other Java apps running. It seems
        the s
        • Re:Well for one (Score:5, Informative)

          by daeg ( 828071 ) on Saturday March 24, 2007 @05:47PM (#18473613)
          If you are using Firefox with Java and having ridiculous applet startup times, you need to disable your Java Cache. This is Java's fault, not Firefox's (supposedly).

          Under the Java control applet, under the General tab, click "Settings..." under "Temporary Internet Files". Then click "View Applets...". It will take a moment to load (or in my case, 2-3 minutes). Then UNcheck "Enable Caching". Firefox now starts my applets almost instantly. This doesn't affect downloaded Java applications such as Azureus or Eclipse (both of which I use extensively).

          Hope this helps.
        • Re: (Score:2, Interesting)

          by jimmydevice ( 699057 )
          I did something even slower in 1973. A Cardiac ( Bell Labs cardboard computer ) emulator written in FORTRAN, running on a FORTRAN emulator written in HP 2000 BASIC running on a HP2100 mini. Cycle time = one instruction / Sec.
          It could play tic-tac-toe, Very slowly.
        • I recently installed Eclipse, and it's a world apart from the slowness of the bank webapp and Azureus. Starts up immediately, ready to rock. I may start using it once I figure out how :P
          Really? Last time I used Eclipse (3.0M6, I think?), it was just as sluggish as Azureus. A shame, since it's an incredibly powerful Java IDE, and not half bad at C++ and Python. I just wish it used shareable project files, not the .workspace mess.
          • Project files (.classpath and .project) in Eclipse are shareable, with a few caveats. If you want to share them across developers, you need to enforce some stricts rules and sometimes it's not worth the shot. Also, do not checkout projects in .workspace.
        • This difference in startup times between Azureus and Eclipse is surprising. Both are based on the same framework (RCP) and I will argue that Eclipse is "bigger" than Azureus. On my box, the startup times are similar. How many torrents are you trying to download? Also, are you sure that Azureus is started in a recent JVM (like 1.6) instead of some ancient 1.4?

          Anyway, in Java, each process runs in a different JVM, so there is absolutely no sharing between processes. This is a long-standing issue and Sun is cl
      • by caseih ( 160668 )
        QEMU is listed as fully supported on SPARC. Both the full hardware emulation (full machine requiring an OS) and Linux-on-Linux mode. The emulated CPU also does dynamic translation so the speed hit shouldn't be nearly as bad as bochs and this java emulator.

        Still, though, your point is taken. This emulator could run x86 software anywhere the JVM is. Of course the primary purpose of it seem to be for research purposes (debugging rootkits, etc). Whether it will metamorphose into something practical remains
      • For one this will let you run X86 DOS applications on a SPARC for example.
        DOSBox already runs on SPARC, as it's a full emulator.
    • Re: (Score:3, Insightful)

      by sumdumass ( 711423 )
      I don't think this is meant for a general purpose vitalization application. This is more or less a research on what something does project. More specifically, You can take a virus and run in it a way to compromise the virtual machine without compromising the machine itself. This means your output is not likely to be damaged in any ways as well as you can monitor the activity from a removed setting while maintaining a presence.

      And this wouldn't be just limited to a virus program either. Suppose we had this a
      • by slamb ( 119285 ) * on Saturday March 24, 2007 @06:01PM (#18473695) Homepage

        More specifically, You can take a virus and run in it a way to compromise the virtual machine without compromising the machine itself. This means your output is not likely to be damaged in any ways as well as you can monitor the activity from a removed setting while maintaining a presence.

        Well, that's great, but you can already do that with VMware, Parallels, QEMU, or other virtualization tools. Sure, virtualization requires the same host and guest architecture, but we all have plenty of x86 machines sitting around, and near-native speeds are necessary to actually boot Windows Vista before the sun goes supernova. So while this is neat software, it's not as suitable for malware researchers as what they are already using. The JPC project needs to find a different niche.

        • 'and near-native speeds are necessary to actually boot Windows Vista before the sun goes supernova'

          near-native? You'd better not only have a native system but a rather fast one to boot Vista in a timely manner. But its all worth it, because you can windows+tab and see a cool 3d cascade of windows. I don't even mind so much that they arbitrarily rearranged all the menus and control panel functions (without adding anything of use) for no apparent reason. All is good just so long as I can see window contents m
        • by kestasjk ( 933987 ) * on Saturday March 24, 2007 @09:22PM (#18475059) Homepage

          near-native speeds are necessary to actually boot Windows Vista before the sun goes supernova.
          The sun isn't close to large enough to end in a supernova; it'll be a red giant, then end as a white dwarf.
          • by slamb ( 119285 ) *
            Thanks for the correction - an unthinking attempt at hyperbole on my part.

            I'll try again - by the time you boot Vista under this emulation, the Sun will have become a red giant, Earth's seas will have boiled away, and its atmosphere will have escaped into space, or at least you'll feel that way... If you were play back a time-lapse of the boot process so that Vista appeared at normal speed, you would look like the villain in Indiana Jones and the Last Crusade after he drank from a false chalice.

      • Re: (Score:2, Interesting)

        by Gromius ( 677157 )
        Actually I think it is for general purpose code. In fact I think its main purpose is for running general code on the grid [wikipedia.org] and giving each process its own virtual sandbox, isolating it from the underlining hardware. This means that some random grid user wont be able to hose the machine they happen to be using which should make things easier from a grid admins point of view. Its the only reason I can possibly think of why they made it.

        Incidently when I first heard about this today, I thought it would be the
  • by christurkel ( 520220 ) on Saturday March 24, 2007 @05:25PM (#18473437) Homepage Journal
    Java only: snail speed
    Java+DOS: Snail with ball and chain
    Java+DOS on non x86: Snail nailed to the table
  • by ookabooka ( 731013 ) on Saturday March 24, 2007 @05:25PM (#18473441)
    But can it run Linux. . .?

    Why did they use Java? It would have been faster in C++.

    I for one welcome our new old x86 overlords.

    Did I miss any?
  • It will take some work to port.

    But still cool though.
    • by pjt33 ( 739471 )
      Java ME isn't a single configuration or profile. It's probably not too hard to port to CDC/PP, but CLDC1.0/MIDP may be trickier.
  • by CTho9305 ( 264265 ) on Saturday March 24, 2007 @05:25PM (#18473445) Homepage
    I was playing around with DEBUG.COM and ran "OUT 20, AX"...and now it's apparently dead [ctho.ath.cx]. A lot of things don't seem to work - e.g. "mode 80,20". Even "dir c:" when the current drive is "a:" seems to hang. I wonder how complete the hardware emulation is. Can you run Windows 3.1 on this? How about programs that probe for a joystick?
    • All I know is, if it can't run Duke Nukem Atomic Edition, Shadow Warrior or Blood it's useless.
    • Re: (Score:2, Funny)

      by Eudial ( 590661 )

      I was playing around with DEBUG.COM and ran "OUT 20, AX"...and now it's apparently dead. A lot of things don't seem to work - e.g. "mode 80,20". Even "dir c:" when the current drive is "a:" seems to hang. I wonder how complete the hardware emulation is. Can you run Windows 3.1 on this? How about programs that probe for a joystick?


      It isn't dead! For crying out loud, it's java! It's still processing the instruction... Come back in September for the result.
    • by jrumney ( 197329 )
      It seems they forgot to emulate the bluescreen.
  • if the emulator itself runs on x86 then the just in time compiler of the Java runtime may optimize the code enough that we get back almost the original assembly code... but without any buffer overflows and other security problems - theoretically.
  • by Boj ( 313432 ) on Saturday March 24, 2007 @06:19PM (#18473845) Homepage
    There are at least 2 solutions doing a similar thing. The open source binarytranslator.org/PearColator offers x86 and PowerPC emulation:
    http://binarytranslator.org/ [binarytranslator.org]
    There are attempts to integrate this into the JNode open source Java OS to make a JNode/GNU stack.

    There is also the VEELS/JXEmu system:
    http://nil.ics.uci.edu/~gal/?page=VEELS [uci.edu]
    which appears not to be publicly available.
  • by Excelcia ( 906188 ) <slashdot@excelcia.ca> on Saturday March 24, 2007 @06:24PM (#18473877) Homepage Journal
    An interpreted language being used to write an opcode interpreter.

    For an encore, perhaps they can write a JVM in BASIC.

    WARNING: Performance implosion imminent due to recursive interpretation.
    • by batkiwi ( 137781 )
      I know you're being funny, but Java isn't interpeted any more than C is. Both are compiled to produce machine code (one meant to be run on a virtual machine, one by a native one, but nothing's preventing someone from making a hardware JVM).
  • Do me a favor and don't pimp software until we can be sure it is non-proprietary.
    • Re: (Score:2, Insightful)

      by mohjlir ( 553108 )
      So should we just run OSS news? Then all the MS trolls would have to get jobs! Seriously, this is news no matter what the copyright holders intend to do (or charge) for the software.
  • Why not Simics? (Score:2, Informative)

    by Anonymous Coward
    I can get Simics for free if I am an academic and Simics gives over 300 MIPS on 2GHz AMD64s (and probaly a lot more on the Core 2 CPU). I really fail to see the use of something that probably is dog slow, written in Java, and probably cannot do reverse execution. Oh, btw, Simics does x86, x86-64, SPARC V8/V9, PPC32/64, MIPS32/64, ARM and perhaps some more.

    Can someone explain the advantages of the Java based x86-emu in TFA over something like Simics?
  • via my Firefox on Kubuntu using the Java 1.5 plugin.

    The demo started up okay, booting and getting to an A: prompt. But it wouldn't accept keyboard focus so I couldn't enter any instructions to run any of the games.

    I contacted the project to let them know. They responded that I probably need to upgrade to Java 1.6 to insure keyboard focus. It's also possible that one of my Firefox extensions might have interfered. They said they have tested JPC with Firefox and Linux but not with Kubuntu specifically.

    I was s
    • I got the same problem with Konqueror and Java 1.6. No keyboard focus. *shrug*
    • by gkhan1 ( 886823 )

      It did that to me at first to (I'm running Firefox under Ubuntu), but after reloading the page a couple of times, and making sure that the applet was the first thing I clicked, it worked fine

      A bigger problem for me is that I use a non-US keyboard which means that it I couldn't do anything because I couldn't change the locale so when I typed ":" it entered ">". Meaning I couldn't do anything since I couldn't change the drive to c :) Anyone got a fix for this?

    • by cecom ( 698048 )
      Same problem here with Firefox and JDK 1.5. Shrug.
  • [1995] When I was at university [unsw.edu.au] on Java 1.0, we were taught operating systems on emulated Minix [minix3.org]. It was fine then, no reason x86 won't be fine now.

    Just give this project time. Everybody is queuing up to knock it down, but it should be fine. They're not planning to put Vista on it, just emulate some DOS data entry applications.
  • Sorry, but I don't get the point.

    Viruses also need OS system calls to do the job. Unless there's also a full Windows emulation in Java (including the Windows bugs and vulnerabilities viruses depend on), how could this be used to analyze how viruses are working? And even if it was the case, what would be the point over QEmu?

    If you need to understand what some piece of code is doing, there are tools called debuggers.
    • by JustNiz ( 692889 )
      Do you realise Windows isn't the only (x86) OS in the world? Actually there are far better ones out there....
    • by jilles ( 20976 )
      The point would be that it can be done. They're academics.

      Having proven that it can be done and having proven that it can be done properly, they effectively prove you and other nay sayers wrong. They are claiming that it works and that it works with acceptable performance (for an emulator). A little out of the box thinking sometimes produces nice results. Why bother with C based emulators if you can do the job in the much more developer friendly Java? As I said, they're academics and probably have better th
  • How much of the x86 instruction set has patents attached to it?

    You probably wouldn't see the likes of Intel suing x86 emulators running on x86 (e.g. virtual machines), but it might be a different story if people start using x86 emulators on other CPU architectures through a Java VM because that cuts into their business.
    • DOSBOX has been around for awhile and uses an emulated CPU. It works well enough to run DOS games and Windows 3.1.
      • Nearly every distribution of DOSBOX is for x86 hosts. The point is that a Java emulator will have more widespread application.
  • Slow by definition. I wonder if you can use JIT techniques with java at all, but in the end, it still would have to be converted to native code.

    Also, for something that's is apparently non-FOSS, they seem to be using both the BOCHS BIOS and the VGA ROM BIOS.... Now the VGA code is AFAIK LGPLd, so they should be okay unless they modified it (a possibility) but I'm pretty sure they had to modify the stock Bochs BIOS, unless they emulated Bochs. In either case, the Bochs BIOS is GPLd.
  • Renders my entering : as a > character (German system). Any other way to change to the c: volume?
  • The next step will be for Microsoft to embrace-extend-exterminate the design for .NET, then use it to run legacy applications on a new OS that locks out native code and unsigned code.

    (This is cynicism - I'm not being too serious.)
  • Because this means non-X86 systems can finally run X86 code. Even if it is slow, it is better than not running X86 code at all. I assume it is a virtual X86 CPU in much the same way that MAME and MESS emulate CPUs via software.

    I understand that until they are able to fully emulate certain hardware than this could be limited to just DOS programs. I think they at least out to be able to emulate a S3 Virge video card, Sound Blaster 16, Intel Chipset network card, and maybe serial ports with a Hayes compatible

I have hardly ever known a mathematician who was capable of reasoning. -- Plato

Working...