Using `pointer::add` with volatile memory

Abierto
#582 13 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
25/100
Tipo de issue
Documentación
Claridad
Necesita aclaración
Estado de actividad
Estancado
Stack tecnológico
rust
Área
compilers

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Sin datos de lenguaje
Estrellas
760
Forks
68
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de rust-lang/unsafe-code-guidelines

Todos los issues de rust-lang/unsafe-code-guidelines

Issues similares

Más issues de Compilers

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.