Message ID | 20170811180257.5493-8-julien.grall@arm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Hi Julien, On 11 August 2017 at 23:32, Julien Grall <julien.grall@arm.com> wrote: > A follow-up patch will move some parts of traps.c in separate files. > The will require to use helpers that are currently statically defined. > Export the following helpers: > - inject_undef64_exception > - inject_undef_exception > - check_conditional_instr > - advance_pc > - handle_raz_wi > - handle_wo_wi > - handle_ro_raz > > Note that asm-arm/arm32/traps.h is empty but it is to keep parity with > the arm64 counterpart. > > Signed-off-by: Julien Grall <julien.grall@arm.com> > > --- > > Cc: volodymyr_babchuk@epam.com > --- > xen/arch/arm/traps.c | 43 +++++++++++++++++++-------------------- > xen/include/asm-arm/arm32/traps.h | 13 ++++++++++++ > xen/include/asm-arm/arm64/traps.h | 15 ++++++++++++++ > xen/include/asm-arm/traps.h | 35 +++++++++++++++++++++++++++++++ > 4 files changed, 84 insertions(+), 22 deletions(-) > create mode 100644 xen/include/asm-arm/arm32/traps.h > create mode 100644 xen/include/asm-arm/arm64/traps.h > create mode 100644 xen/include/asm-arm/traps.h > > diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c > index d79e9605b5..ab56958717 100644 > --- a/xen/arch/arm/traps.c > +++ b/xen/arch/arm/traps.c > @@ -49,6 +49,7 @@ > #include <asm/monitor.h> > #include <asm/mmio.h> > #include <asm/regs.h> > +#include <asm/traps.h> > #include <asm/vgic.h> > #include <asm/vtimer.h> > > @@ -545,7 +546,7 @@ static vaddr_t exception_handler64(struct cpu_user_regs *regs, vaddr_t offset) > } > > /* Inject an undefined exception into a 64 bit guest */ > -static void inject_undef64_exception(struct cpu_user_regs *regs, int instr_len) > +void inject_undef64_exception(struct cpu_user_regs *regs, int instr_len) > { > vaddr_t handler; > const union hsr esr = { > @@ -618,8 +619,7 @@ static void inject_iabt64_exception(struct cpu_user_regs *regs, > > #endif > > -static void inject_undef_exception(struct cpu_user_regs *regs, > - const union hsr hsr) > +void inject_undef_exception(struct cpu_user_regs *regs, const union hsr hsr) > { > if ( is_32bit_domain(current->domain) ) > inject_undef32_exception(regs); > @@ -1712,8 +1712,7 @@ static const unsigned short cc_map[16] = { > 0 /* NV */ > }; > > -static int check_conditional_instr(struct cpu_user_regs *regs, > - const union hsr hsr) > +int check_conditional_instr(struct cpu_user_regs *regs, const union hsr hsr) > { > unsigned long cpsr, cpsr_cond; > int cond; > @@ -1758,7 +1757,7 @@ static int check_conditional_instr(struct cpu_user_regs *regs, > return 1; > } > > -static void advance_pc(struct cpu_user_regs *regs, const union hsr hsr) > +void advance_pc(struct cpu_user_regs *regs, const union hsr hsr) > { > unsigned long itbits, cond, cpsr = regs->cpsr; > > @@ -1799,11 +1798,11 @@ static void advance_pc(struct cpu_user_regs *regs, const union hsr hsr) > } > > /* Read as zero and write ignore */ > -static void handle_raz_wi(struct cpu_user_regs *regs, > - int regidx, > - bool read, > - const union hsr hsr, > - int min_el) > +void handle_raz_wi(struct cpu_user_regs *regs, > + int regidx, > + bool read, > + const union hsr hsr, > + int min_el) > { > ASSERT((min_el == 0) || (min_el == 1)); > > @@ -1817,12 +1816,12 @@ static void handle_raz_wi(struct cpu_user_regs *regs, > advance_pc(regs, hsr); > } > > -/* Write only as write ignore */ > -static void handle_wo_wi(struct cpu_user_regs *regs, > - int regidx, > - bool read, > - const union hsr hsr, > - int min_el) > +/* write only as write ignore */ > +void handle_wo_wi(struct cpu_user_regs *regs, > + int regidx, > + bool read, > + const union hsr hsr, > + int min_el) > { > ASSERT((min_el == 0) || (min_el == 1)); > > @@ -1837,11 +1836,11 @@ static void handle_wo_wi(struct cpu_user_regs *regs, > } > > /* Read only as read as zero */ > -static void handle_ro_raz(struct cpu_user_regs *regs, > - int regidx, > - bool read, > - const union hsr hsr, > - int min_el) > +void handle_ro_raz(struct cpu_user_regs *regs, > + int regidx, > + bool read, > + const union hsr hsr, > + int min_el) > { > ASSERT((min_el == 0) || (min_el == 1)); > > diff --git a/xen/include/asm-arm/arm32/traps.h b/xen/include/asm-arm/arm32/traps.h > new file mode 100644 > index 0000000000..e3c4a8b473 > --- /dev/null > +++ b/xen/include/asm-arm/arm32/traps.h > @@ -0,0 +1,13 @@ > +#ifndef __ASM_ARM32_TRAPS__ > +#define __ASM_ARM32_TRAPS__ > + > +#endif /* __ASM_ARM32_TRAPS__ */ > +/* > + * Local variables: > + * mode: C > + * c-file-style: "BSD" > + * c-basic-offset: 4 > + * indent-tabs-mode: nil > + * End: > + */ > + > diff --git a/xen/include/asm-arm/arm64/traps.h b/xen/include/asm-arm/arm64/traps.h > new file mode 100644 > index 0000000000..5cb45df6bd > --- /dev/null > +++ b/xen/include/asm-arm/arm64/traps.h > @@ -0,0 +1,15 @@ > +#ifndef __ASM_ARM32_TRAPS__ > +#define __ASM_ARM32_TRAPS__ I think it should be __ASM_ARM64_TRAPS__ here. > + > +void inject_undef64_exception(struct cpu_user_regs *regs, int instr_len); > + > +#endif /* __ASM_ARM32_TRAPS__ */ > +/* > + * Local variables: > + * mode: C > + * c-file-style: "BSD" > + * c-basic-offset: 4 > + * indent-tabs-mode: nil > + * End: > + */ > + > diff --git a/xen/include/asm-arm/traps.h b/xen/include/asm-arm/traps.h > new file mode 100644 > index 0000000000..4e227c4dd2 > --- /dev/null > +++ b/xen/include/asm-arm/traps.h > @@ -0,0 +1,35 @@ > +#ifndef __ASM_ARM_TRAPS__ > +#define __ASM_ARM_TRAPS__ > + > +#include <asm/processor.h> > + > +#if defined(CONFIG_ARM_32) > +# include <asm/arm32/traps.h> > +#elif defined(CONFIG_ARM_64) > +# include <asm/arm64/traps.h> > +#endif > + > +int check_conditional_instr(struct cpu_user_regs *regs, const union hsr hsr); a newline can be added here. > +void advance_pc(struct cpu_user_regs *regs, const union hsr hsr); > + > +void inject_undef_exception(struct cpu_user_regs *regs, const union hsr hsr); > + > +void handle_raz_wi(struct cpu_user_regs *regs, int regidx, bool read, > + const union hsr hsr, int min_el); > + > +void handle_wo_wi(struct cpu_user_regs *regs, int regidx, bool read, > + const union hsr hsr, int min_el); > + > +void handle_ro_raz(struct cpu_user_regs *regs, int regidx, bool read, > + const union hsr hsr, int min_el); > + > +#endif /* __ASM_ARM_TRAPS__ */ > +/* > + * Local variables: > + * mode: C > + * c-file-style: "BSD" > + * c-basic-offset: 4 > + * indent-tabs-mode: nil > + * End: > + */ > + > -- > 2.11.0 > Regards, Bhupinder
On 16/08/17 10:30, Bhupinder Thakur wrote: > Hi Julien, Hi Bhupinder, > On 11 August 2017 at 23:32, Julien Grall <julien.grall@arm.com> wrote: >> diff --git a/xen/include/asm-arm/arm64/traps.h b/xen/include/asm-arm/arm64/traps.h >> new file mode 100644 >> index 0000000000..5cb45df6bd >> --- /dev/null >> +++ b/xen/include/asm-arm/arm64/traps.h >> @@ -0,0 +1,15 @@ >> +#ifndef __ASM_ARM32_TRAPS__ >> +#define __ASM_ARM32_TRAPS__ > > I think it should be __ASM_ARM64_TRAPS__ here. Hmmm yes and ... > >> + >> +void inject_undef64_exception(struct cpu_user_regs *regs, int instr_len); >> + >> +#endif /* __ASM_ARM32_TRAPS__ */ here too. I will fix it in the next version. >> +/* >> + * Local variables: >> + * mode: C >> + * c-file-style: "BSD" >> + * c-basic-offset: 4 >> + * indent-tabs-mode: nil >> + * End: >> + */ >> + >> diff --git a/xen/include/asm-arm/traps.h b/xen/include/asm-arm/traps.h >> new file mode 100644 >> index 0000000000..4e227c4dd2 >> --- /dev/null >> +++ b/xen/include/asm-arm/traps.h >> @@ -0,0 +1,35 @@ >> +#ifndef __ASM_ARM_TRAPS__ >> +#define __ASM_ARM_TRAPS__ >> + >> +#include <asm/processor.h> >> + >> +#if defined(CONFIG_ARM_32) >> +# include <asm/arm32/traps.h> >> +#elif defined(CONFIG_ARM_64) >> +# include <asm/arm64/traps.h> >> +#endif >> + >> +int check_conditional_instr(struct cpu_user_regs *regs, const union hsr hsr); > a newline can be added here. I will do that. > >> +void advance_pc(struct cpu_user_regs *regs, const union hsr hsr); >> + >> +void inject_undef_exception(struct cpu_user_regs *regs, const union hsr hsr); >> + >> +void handle_raz_wi(struct cpu_user_regs *regs, int regidx, bool read, >> + const union hsr hsr, int min_el); >> + >> +void handle_wo_wi(struct cpu_user_regs *regs, int regidx, bool read, >> + const union hsr hsr, int min_el); >> + >> +void handle_ro_raz(struct cpu_user_regs *regs, int regidx, bool read, >> + const union hsr hsr, int min_el); >> + >> +#endif /* __ASM_ARM_TRAPS__ */ >> +/* >> + * Local variables: >> + * mode: C >> + * c-file-style: "BSD" >> + * c-basic-offset: 4 >> + * indent-tabs-mode: nil >> + * End: >> + */ >> + >> -- >> 2.11.0 >> Cheers,
diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index d79e9605b5..ab56958717 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -49,6 +49,7 @@ #include <asm/monitor.h> #include <asm/mmio.h> #include <asm/regs.h> +#include <asm/traps.h> #include <asm/vgic.h> #include <asm/vtimer.h> @@ -545,7 +546,7 @@ static vaddr_t exception_handler64(struct cpu_user_regs *regs, vaddr_t offset) } /* Inject an undefined exception into a 64 bit guest */ -static void inject_undef64_exception(struct cpu_user_regs *regs, int instr_len) +void inject_undef64_exception(struct cpu_user_regs *regs, int instr_len) { vaddr_t handler; const union hsr esr = { @@ -618,8 +619,7 @@ static void inject_iabt64_exception(struct cpu_user_regs *regs, #endif -static void inject_undef_exception(struct cpu_user_regs *regs, - const union hsr hsr) +void inject_undef_exception(struct cpu_user_regs *regs, const union hsr hsr) { if ( is_32bit_domain(current->domain) ) inject_undef32_exception(regs); @@ -1712,8 +1712,7 @@ static const unsigned short cc_map[16] = { 0 /* NV */ }; -static int check_conditional_instr(struct cpu_user_regs *regs, - const union hsr hsr) +int check_conditional_instr(struct cpu_user_regs *regs, const union hsr hsr) { unsigned long cpsr, cpsr_cond; int cond; @@ -1758,7 +1757,7 @@ static int check_conditional_instr(struct cpu_user_regs *regs, return 1; } -static void advance_pc(struct cpu_user_regs *regs, const union hsr hsr) +void advance_pc(struct cpu_user_regs *regs, const union hsr hsr) { unsigned long itbits, cond, cpsr = regs->cpsr; @@ -1799,11 +1798,11 @@ static void advance_pc(struct cpu_user_regs *regs, const union hsr hsr) } /* Read as zero and write ignore */ -static void handle_raz_wi(struct cpu_user_regs *regs, - int regidx, - bool read, - const union hsr hsr, - int min_el) +void handle_raz_wi(struct cpu_user_regs *regs, + int regidx, + bool read, + const union hsr hsr, + int min_el) { ASSERT((min_el == 0) || (min_el == 1)); @@ -1817,12 +1816,12 @@ static void handle_raz_wi(struct cpu_user_regs *regs, advance_pc(regs, hsr); } -/* Write only as write ignore */ -static void handle_wo_wi(struct cpu_user_regs *regs, - int regidx, - bool read, - const union hsr hsr, - int min_el) +/* write only as write ignore */ +void handle_wo_wi(struct cpu_user_regs *regs, + int regidx, + bool read, + const union hsr hsr, + int min_el) { ASSERT((min_el == 0) || (min_el == 1)); @@ -1837,11 +1836,11 @@ static void handle_wo_wi(struct cpu_user_regs *regs, } /* Read only as read as zero */ -static void handle_ro_raz(struct cpu_user_regs *regs, - int regidx, - bool read, - const union hsr hsr, - int min_el) +void handle_ro_raz(struct cpu_user_regs *regs, + int regidx, + bool read, + const union hsr hsr, + int min_el) { ASSERT((min_el == 0) || (min_el == 1)); diff --git a/xen/include/asm-arm/arm32/traps.h b/xen/include/asm-arm/arm32/traps.h new file mode 100644 index 0000000000..e3c4a8b473 --- /dev/null +++ b/xen/include/asm-arm/arm32/traps.h @@ -0,0 +1,13 @@ +#ifndef __ASM_ARM32_TRAPS__ +#define __ASM_ARM32_TRAPS__ + +#endif /* __ASM_ARM32_TRAPS__ */ +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ + diff --git a/xen/include/asm-arm/arm64/traps.h b/xen/include/asm-arm/arm64/traps.h new file mode 100644 index 0000000000..5cb45df6bd --- /dev/null +++ b/xen/include/asm-arm/arm64/traps.h @@ -0,0 +1,15 @@ +#ifndef __ASM_ARM32_TRAPS__ +#define __ASM_ARM32_TRAPS__ + +void inject_undef64_exception(struct cpu_user_regs *regs, int instr_len); + +#endif /* __ASM_ARM32_TRAPS__ */ +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ + diff --git a/xen/include/asm-arm/traps.h b/xen/include/asm-arm/traps.h new file mode 100644 index 0000000000..4e227c4dd2 --- /dev/null +++ b/xen/include/asm-arm/traps.h @@ -0,0 +1,35 @@ +#ifndef __ASM_ARM_TRAPS__ +#define __ASM_ARM_TRAPS__ + +#include <asm/processor.h> + +#if defined(CONFIG_ARM_32) +# include <asm/arm32/traps.h> +#elif defined(CONFIG_ARM_64) +# include <asm/arm64/traps.h> +#endif + +int check_conditional_instr(struct cpu_user_regs *regs, const union hsr hsr); +void advance_pc(struct cpu_user_regs *regs, const union hsr hsr); + +void inject_undef_exception(struct cpu_user_regs *regs, const union hsr hsr); + +void handle_raz_wi(struct cpu_user_regs *regs, int regidx, bool read, + const union hsr hsr, int min_el); + +void handle_wo_wi(struct cpu_user_regs *regs, int regidx, bool read, + const union hsr hsr, int min_el); + +void handle_ro_raz(struct cpu_user_regs *regs, int regidx, bool read, + const union hsr hsr, int min_el); + +#endif /* __ASM_ARM_TRAPS__ */ +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ +
A follow-up patch will move some parts of traps.c in separate files. The will require to use helpers that are currently statically defined. Export the following helpers: - inject_undef64_exception - inject_undef_exception - check_conditional_instr - advance_pc - handle_raz_wi - handle_wo_wi - handle_ro_raz Note that asm-arm/arm32/traps.h is empty but it is to keep parity with the arm64 counterpart. Signed-off-by: Julien Grall <julien.grall@arm.com> --- Cc: volodymyr_babchuk@epam.com --- xen/arch/arm/traps.c | 43 +++++++++++++++++++-------------------- xen/include/asm-arm/arm32/traps.h | 13 ++++++++++++ xen/include/asm-arm/arm64/traps.h | 15 ++++++++++++++ xen/include/asm-arm/traps.h | 35 +++++++++++++++++++++++++++++++ 4 files changed, 84 insertions(+), 22 deletions(-) create mode 100644 xen/include/asm-arm/arm32/traps.h create mode 100644 xen/include/asm-arm/arm64/traps.h create mode 100644 xen/include/asm-arm/traps.h