On Tue, Feb 1, 2022 at 12:53 AM Kees Cook <keescook@xxxxxxxxxxxx> wrote: > > + > > +According to `the GCC docs on inline asm > > +https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#Volatile`_: > > + > > + asm statements that have no output operands and asm goto statements, > > + are implicitly volatile. > > Does this mean "volatile" _is_ needed when there are operands, etc? It depends on what you want to express. The idea here is to give a way to gcc for optimizing out anything with an output, like x86 rdtsc() when the result is not used, which is sensible. If there is no output, such as in writel(), you don't need 'volatile' because gcc can assume that an inline asm without outputs has side-effects already. A case where you need to add volatile is for (void)readl(ADDR), which is an operation that has an output as well as a side-effect. Arnd