Giter VIP home page Giter VIP logo

Comments (11)

CensoredUsername avatar CensoredUsername commented on May 28, 2024

I knew that aarch64 has incoherent instruction caches but for some reason I assumed that the relevant mprotect calls would handle those flushes already. I'll add this to the default behaviour on aarch64 👍

from dynasm-rs.

CensoredUsername avatar CensoredUsername commented on May 28, 2024

Do you know by any chance if there's a stable interface in the rust stdlib for performing this operation? I can't find it and I'd rather not have to drop to unsafe behaviour just for this one part of the library.

from dynasm-rs.

CensoredUsername avatar CensoredUsername commented on May 28, 2024

Also, for portability reasons it'll probably have to be an IC IALLU instruction for simplicity, as IC IVAU needs to be performed on a cache-line basis which for larger alter ops would get very complex.

from dynasm-rs.

CensoredUsername avatar CensoredUsername commented on May 28, 2024

Scratch that, I've got a cache-line granularity fix architected but I'm investigating the best way of getting this running on stable rust.

from dynasm-rs.

losfair avatar losfair commented on May 28, 2024

I'm not aware of any stdlib interfaces for flushing caches.

Maybe generate the cache flushing instructions with dynasm itself for stable rust?

from dynasm-rs.

CensoredUsername avatar CensoredUsername commented on May 28, 2024

There's a bunch of options:

  • rust asm!: this is unstable
  • use build script and cc crate to ship a .c file: this complicates the toolchain a lot.
  • use build script to ship a .s file: still requires the cc crate.
  • ship a .a file containing the assembled .s file in the package: this seems quite viable since we just need an interface for two instructions on a single architecture.
  • just ship the assembled machine code we need on aarhc64 as a bytearray that is linked into the ".text" section using the link_section attribute, then transmuting it to a function pointer: this seems to just work, just requires some unsafe and is the simplest of them all. It doesn't require a build script or any shenanigans, just a small architecture-specific unsafe wrapper.
  • use dynasm to generate code at runtime necessary for dynasm: I guess this would work but it feels really silly and would have a lot of overhead potentially.

from dynasm-rs.

CensoredUsername avatar CensoredUsername commented on May 28, 2024

I've done some preliminary work for this at 206cc7b . I'm trying to find a way to test this properly but my VM provider stopped offering aarch64 instances last month for some reason so this might take a bit longer. It should work but no promises of not just getting a SIGILL. It also may still need some dc civac instructions before the I$ invalidation, I have to recheck the docs for that. For now I'm invalidating the cache on a patch by patch basis of the alter API but it might be easier to switch to just invalidating the whole buffer when it's altered.

from dynasm-rs.

losfair avatar losfair commented on May 28, 2024

Looks nice to me! Will try it. Thanks!

from dynasm-rs.

CensoredUsername avatar CensoredUsername commented on May 28, 2024

With inline asm stabilized in rust for aarch64 this can now be implemented in a less hacky way, so I'll get back on this soon.

from dynasm-rs.

CensoredUsername avatar CensoredUsername commented on May 28, 2024

update: don't have the time to finish this for 2.0, but it shouldn't be a breaking change once we're in there. Postponing this for now.

from dynasm-rs.

MarkMcCaskey avatar MarkMcCaskey commented on May 28, 2024

I came across this problem on my own on an M1 mac and ended up finding out about sys_icache_invalidate which seems to be working well for me so far. I don't have enough context to compare or contrast it with ic ivau, but I'm mentioning it here in case it helps anyone in the future.

from dynasm-rs.

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.