Re: [PATCH v3 01/22] arm64: Add macros to read/write system registers
On Mon, Dec 07, 2015 at 10:53:17AM +, Marc Zyngier wrote: > From: Mark Rutland> > Rather than crafting custom macros for reading/writing each system > register provide generics accessors, read_sysreg and write_sysreg, for > this purpose. > > Unlike read_cpuid, calls to read_exception_reg are never expected > to be optimized away or replaced with synthetic values. What's read_exception_reg? Is it a macro somewhere? > diff --git a/arch/arm64/include/asm/sysreg.h b/arch/arm64/include/asm/sysreg.h > index d48ab5b..c9c283a 100644 > --- a/arch/arm64/include/asm/sysreg.h > +++ b/arch/arm64/include/asm/sysreg.h > @@ -20,6 +20,8 @@ > #ifndef __ASM_SYSREG_H > #define __ASM_SYSREG_H > > +#include > + > #include > > /* > @@ -208,6 +210,8 @@ > > #else > > +#include > + > asm( > ".irp > num,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30\n" > ".equ__reg_num_x\\num, \\num\n" > @@ -232,6 +236,19 @@ static inline void config_sctlr_el1(u32 clear, u32 set) > val |= set; > asm volatile("msr sctlr_el1, %0" : : "r" (val)); > } > + > +#define read_sysreg(r) ({\ > + u64 __val; \ > + asm volatile("mrs %0, " __stringify(r) : "=r" (__val)); \ > + __val; \ > +}) And maybe a comment here on why this is always volatile. Otherwise: Acked-by: Catalin Marinas -- Catalin -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 01/22] arm64: Add macros to read/write system registers
On Mon, Dec 07, 2015 at 05:35:20PM +, Catalin Marinas wrote: > On Mon, Dec 07, 2015 at 10:53:17AM +, Marc Zyngier wrote: > > From: Mark Rutland> > > > Rather than crafting custom macros for reading/writing each system > > register provide generics accessors, read_sysreg and write_sysreg, for > > this purpose. > > > > Unlike read_cpuid, calls to read_exception_reg are never expected > > to be optimized away or replaced with synthetic values. > > What's read_exception_reg? Is it a macro somewhere? That was what read_sysreg used to be called on a local branch of mine. I didn't spot that when reworking the patch. So s/read_exception_reg/read_sysreg/ here. > > +#define read_sysreg(r) ({ \ > > + u64 __val; \ > > + asm volatile("mrs %0, " __stringify(r) : "=r" (__val)); \ > > + __val; \ > > +}) > > And maybe a comment here on why this is always volatile. Makes sense to me. Marc, are you happy to turn the last sentence from the commit message into a comment here (with the substitution)? Thanks, Mark. -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 01/22] arm64: Add macros to read/write system registers
On 07/12/15 17:45, Mark Rutland wrote: > On Mon, Dec 07, 2015 at 05:35:20PM +, Catalin Marinas wrote: >> On Mon, Dec 07, 2015 at 10:53:17AM +, Marc Zyngier wrote: >>> From: Mark Rutland>>> >>> Rather than crafting custom macros for reading/writing each system >>> register provide generics accessors, read_sysreg and write_sysreg, for >>> this purpose. >>> >>> Unlike read_cpuid, calls to read_exception_reg are never expected >>> to be optimized away or replaced with synthetic values. >> >> What's read_exception_reg? Is it a macro somewhere? > > That was what read_sysreg used to be called on a local branch of mine. I > didn't spot that when reworking the patch. > > So s/read_exception_reg/read_sysreg/ here. > >>> +#define read_sysreg(r) ({ \ >>> + u64 __val; \ >>> + asm volatile("mrs %0, " __stringify(r) : "=r" (__val)); \ >>> + __val; \ >>> +}) >> >> And maybe a comment here on why this is always volatile. > > Makes sense to me. > > Marc, are you happy to turn the last sentence from the commit message > into a comment here (with the substitution)? Sure, I'll update the patch and push the branch out again, together with Catalin's Ack. Thanks, M. -- Jazz is not dead. It just smells funny... -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html