GithubHelp home page GithubHelp logo

Comments (4)

ksco avatar ksco commented on June 7, 2024

If all the emitted code is messed around by the optimizer, it's difficult to do accurate signal handling -- how do we know the exact x86 register status in the guest sighandler when a signal is delivered?

But to my understanding, a peephole optimizer with accurate signal handling in mind is possible.

from box64.

jhe33 avatar jhe33 commented on June 7, 2024

If all the emitted code is messed around by the optimizer, it's difficult to do accurate signal handling -- how do we know the exact x86 register status in the guest sighandler when a signal is delivered?

But to my understanding, a peephole optimizer with accurate signal handling in mind is possible.

I think there is a trade-off for this situation, for some cases which doesn't care signal handling precision, user could get a performance improvement due to compiler optimization; otherwise one can disable the optimizations.

from box64.

xctan avatar xctan commented on June 7, 2024

The x86 cache behavior is another tricky thing. Box64 is designed to handle JIT inside Box64 JIT correctly. The x86 hardware automatically invalidates (instruction) cache line when corresponding memory location is written to without an explicit flush or fence instruction, which Box64 is trying to emulate. Therefore, Box64 protects the x86 code memory pages when generating its JIT code, so a SIGSEGV would be triggered when the x86 code mutates. This signal would be intercepted by Box64, and the JIT cache of the entire memory page where the signal emits will be marked as dirty. Current practice of generating one JIT code block for one continuous x86 code block leads to simpler integrity check.

from box64.

jhe33 avatar jhe33 commented on June 7, 2024

The x86 cache behavior is another tricky thing. Box64 is designed to handle JIT inside Box64 JIT correctly. The x86 hardware automatically invalidates (instruction) cache line when corresponding memory location is written to without an explicit flush or fence instruction, which Box64 is trying to emulate. Therefore, Box64 protects the x86 code memory pages when generating its JIT code, so a SIGSEGV would be triggered when the x86 code mutates. This signal would be intercepted by Box64, and the JIT cache of the entire memory page where the signal emits will be marked as dirty. Current practice of generating one JIT code block for one continuous x86 code block leads to simpler integrity check.

I think it's a common technique for SMC, in most DBT solutions, they also take it to handle SMC unless the hardware provides some supports, e.g. mmu could notify the BT when data cache changes to instr cache.

from box64.

Related Issues (20)

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.