Using `pointer::add` with volatile memory

Đang mở
#582 13 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
25/100
Loại issue
Tài liệu
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
rust
Lĩnh vực
compilers

Hướng nghiên cứu

Start with the quoted pointer::add safety requirements and the linked Rust std::ptr sections on provenance and allocations. Then examine how those rules apply to &raw mut (*volatile_ptr).field for volatile memory. Done means resolving or documenting whether this pattern is valid and what supported approach should be used.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

When working with volatile memory it's common to do so entirely using raw pointers, making sure to never create a reference so that the volatile memory never gets considered a real allocation in the opsem.

The pointer::add method has these safety requirements:

If the computed offset is non-zero, then self must be derived from a pointer to some allocation, and the entire memory range between self and the result must be in bounds of that allocation. In particular, this range must not “wrap around” the edge of the address space.

The point of never creating a reference to the memory is to avoid assuming that there is a real allocation there. This is so that it's illegal for LLVM to introduce a spurious read to the volatile memory. From my reading of pointer::add it seems the same applies to that method.

However, this puts us in a somewhat tricky situation. It means that &raw mut (*volatile_ptr).field does not work for getting a pointer to a field of a struct in volatile memory, and the layout of volatile memory is often described by referring to an equivalent C struct. This is a challenge since there are no convenient alternatives to &raw mut.

Ngôn ngữ chính
Không có dữ liệu ngôn ngữ
Star
760
Fork
68
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của rust-lang/unsafe-code-guidelines

Tất cả issue của rust-lang/unsafe-code-guidelines

Issue tương tự

Thêm issue về Compilers

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.