xen/arm: Allow AArch32 guest to boot with GICv3
cover xen/arm: Allow AArch32 guest to boot with GICv3
Hi all,
Currently, it is only possible to start AArch32 guest with GICv2. This means that if the host interrupt controller is not compatible with GICv2, it will not be possible to boot AArch32 guest.
The vGICv3 code is nearly fully compatible with AArch32 guest except that co-processor access to ICC_SGI1R_EL1 is not emulated.
The first part (#1 - #11) of the series contains clean-up, only patch #12 and #13 contains the meat.
Note this is only allowing AArch32 guest to use GICv3 on AArch64 host. This series does not add support for GICv3 on AArch32 host.
A branch with all the patches can be found on xenbits:
git://xenbits.xen.org/people/julieng/xen-unstable.git branch gicv3-32bit-v1
Regards,
Julien Grall (13):
xen/arm: vtimer: Switch the emulation functions return from int to
bool
xen/arm: vtimer: Switch the read variable in the emulation from int to
bool
xen/arm: traps: Switch from bool_t to bool
xen/arm: vgic: Switch from bool_t to bool
xen/arm: vgic: Switch vgic_to_sgi return from int to bool and progate
up to...
xen/arm: vgic: Switch emulate_sysreg return from int to bool xen/arm: vgic: Clean-up the sysreg emulation
xen/arm: vgic-v3: Build vgic-v3.c when CONFIG_HAS_GICV3 is enabled. xen/arm: vtimer: Move emulate_sysreg* callback in a separate header xen/arm: vreg: Introduce vreg_emulate_cp{32,64}
xen/arm: vgic: Rename emulate_sysreg callback to emulate_reg xen/arm: vgic-v3: Move the emulation of ICC_SGI1R_EL1 in a separate
helper
xen/arm: vgic-v3: Allow AArch32 guest booting with GICv3
xen/arch/arm/Makefile | 2 +- xen/arch/arm/traps.c | 42 +++++++------ xen/arch/arm/vgic-v2.c | 4 +- xen/arch/arm/vgic-v3.c | 64 ++++++++++++++++---- xen/arch/arm/vgic.c | 22 +++---- xen/arch/arm/vtimer.c | 126 ++++++++------------------------------- xen/arch/arm/vtimer.h | 2 +- xen/include/asm-arm/cpregs.h | 3 + xen/include/asm-arm/perfc_defn.h | 2 + xen/include/asm-arm/vgic.h | 20 +++---- xen/include/asm-arm/vreg.h | 110 ++++++++++++++++++++++++++++++++++ 11 files changed, 240 insertions(+), 157 deletions(-) create mode 100644 xen/include/asm-arm/vreg.h
Signature · 7 lines
1.9.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 1/13 xen/arm: vtimer: Switch the emulation functions return from int to bool
The emulation functions are always returning 0 or 1. Use bool instead to make clear only two possible values exist.
--- xen/arch/arm/vtimer.c | 60 +++++++++++++++++++++++++-------------------------- xen/arch/arm/vtimer.h | 2 +- 2 files changed, 31 insertions(+), 31 deletions(-)
xen/arch/arm/vtimer.c +30 -30
@@ -164,12 +164,12 @@ int virt_timer_restore(struct vcpu *v)return 0 ; } -static int vtimer_cntp_ctl (struct cpu_user_regs *regs,uint32_t *r,int read) +static bool vtimer_cntp_ctl (struct cpu_user_regs *regs,uint32_t *r,int read) {struct vcpu *v = current;if ( !ACCESS_ALLOWED (regs,EL0PTEN ) ) -return 0 ; +return false;if ( read ) {
@@ -190,16 +190,16 @@ static int vtimer_cntp_ctl(struct cpu_user_regs *regs, uint32_t *r, int read)else stop_timer (&v->arch.phys_timer.timer); } -return 1 ; +return true; } -static int vtimer_cntp_tval (struct cpu_user_regs *regs,uint32_t *r,int read) +static bool vtimer_cntp_tval (struct cpu_user_regs *regs,uint32_t *r,int read) {struct vcpu *v = current;s_time_t now;if ( !ACCESS_ALLOWED (regs,EL0PTEN ) ) -return 0 ; +return false; now =NOW () - v->domain->arch.phys_timer_base.offset;
@@ -218,15 +218,15 @@ static int vtimer_cntp_tval(struct cpu_user_regs *regs, uint32_t *r, int read) v->domain->arch.phys_timer_base.offset); } } -return 1 ; +return true; } -static int vtimer_cntp_cval (struct cpu_user_regs *regs,uint64_t *r,int read) +static bool vtimer_cntp_cval (struct cpu_user_regs *regs,uint64_t *r,int read) {struct vcpu *v = current;if ( !ACCESS_ALLOWED (regs,EL0PTEN ) ) -return 0 ; +return false;if ( read ) {
@@ -243,10 +243,10 @@ static int vtimer_cntp_cval(struct cpu_user_regs *regs, uint64_t *r, int read) v->domain->arch.phys_timer_base.offset); } } -return 1 ; +return true; } -static int vtimer_emulate_cp32 (struct cpu_user_regs *regs,union hsr hsr) +static bool vtimer_emulate_cp32 (struct cpu_user_regs *regs,union hsr hsr) {struct hsr_cp32 cp32 = hsr.cp32;/*
@@ -255,7 +255,7 @@ static int vtimer_emulate_cp32(struct cpu_user_regs *regs, union hsr hsr)* setting r). */ uint32_t r =0 ; -int res; +bool res;if ( cp32.read )
@@ -277,7 +277,7 @@ static int vtimer_emulate_cp32(struct cpu_user_regs *regs, union hsr hsr)break ;default : -return 0 ; +return false; }if ( res && cp32.read )
@@ -286,7 +286,7 @@ static int vtimer_emulate_cp32(struct cpu_user_regs *regs, union hsr hsr)return res; } -static int vtimer_emulate_cp64 (struct cpu_user_regs *regs,union hsr hsr) +static bool vtimer_emulate_cp64 (struct cpu_user_regs *regs,union hsr hsr) {struct hsr_cp64 cp64 = hsr.cp64;uint32_t r1 =get_user_reg (regs, cp64.reg1);
@@ -302,11 +302,11 @@ static int vtimer_emulate_cp64(struct cpu_user_regs *regs, union hsr hsr) {case HSR_CPREG64 (CNTP_CVAL ):if ( !vtimer_cntp_cval (regs, &x, cp64.read) ) -return 0 ; +return false;break ;default : -return 0 ; +return false; }if ( cp64.read )
@@ -315,21 +315,21 @@ static int vtimer_emulate_cp64(struct cpu_user_regs *regs, union hsr hsr)set_user_reg (regs, cp64.reg2, x >>32 ); } -return 1 ; +return true; }#ifdef CONFIG_ARM_64 -typedef int (*vtimer_sysreg32_fn_t )(struct cpu_user_regs *regs,uint32_t *r, -int read); -typedef int (*vtimer_sysreg64_fn_t )(struct cpu_user_regs *regs,uint64_t *r, -int read); +typedef bool (*vtimer_sysreg32_fn_t )(struct cpu_user_regs *regs,uint32_t *r, +int read); +typedef bool (*vtimer_sysreg64_fn_t )(struct cpu_user_regs *regs,uint64_t *r, +int read); -static int vtimer_emulate_sysreg32 (struct cpu_user_regs *regs,union hsr hsr, -vtimer_sysreg32_fn_t fn) +static bool vtimer_emulate_sysreg32 (struct cpu_user_regs *regs,union hsr hsr, +vtimer_sysreg32_fn_t fn) {struct hsr_sysreg sysreg = hsr.sysreg;uint32_t r =0 ; -int ret; +bool ret;if ( !sysreg.read ) r =get_user_reg (regs, sysreg.reg);
@@ -342,8 +342,8 @@ static int vtimer_emulate_sysreg32(struct cpu_user_regs *regs, union hsr hsr,return ret; } -static int vtimer_emulate_sysreg64 (struct cpu_user_regs *regs,union hsr hsr, -vtimer_sysreg64_fn_t fn) +static bool vtimer_emulate_sysreg64 (struct cpu_user_regs *regs,union hsr hsr, +vtimer_sysreg64_fn_t fn) {struct hsr_sysreg sysreg = hsr.sysreg;/*
@@ -352,7 +352,7 @@ static int vtimer_emulate_sysreg64(struct cpu_user_regs *regs, union hsr hsr,* setting x). */ uint64_t x =0 ; -int ret; +bool ret;if ( !sysreg.read ) x =get_user_reg (regs, sysreg.reg);
@@ -365,7 +365,7 @@ static int vtimer_emulate_sysreg64(struct cpu_user_regs *regs, union hsr hsr,return ret; } -static int vtimer_emulate_sysreg (struct cpu_user_regs *regs,union hsr hsr) +static bool vtimer_emulate_sysreg (struct cpu_user_regs *regs,union hsr hsr) {struct hsr_sysreg sysreg = hsr.sysreg;
@@ -384,13 +384,13 @@ static int vtimer_emulate_sysreg(struct cpu_user_regs *regs, union hsr hsr)return vtimer_emulate_sysreg64 (regs, hsr, vtimer_cntp_cval);default : - return 0; + return false; } }#endif -int vtimer_emulate (struct cpu_user_regs *regs,union hsr hsr) +bool vtimer_emulate (struct cpu_user_regs *regs,union hsr hsr) {switch (hsr.ec) {
@@ -403,7 +403,7 @@ int vtimer_emulate(struct cpu_user_regs *regs, union hsr hsr)return vtimer_emulate_sysreg (regs, hsr);#endif default : -return 0 ; +return false; } }
xen/arch/arm/vtimer.h +1 -1
@@ -23,7 +23,7 @@extern int domain_vtimer_init (struct domain *d,struct xen_arch_domainconfig *config);extern int vcpu_vtimer_init (struct vcpu *v); -extern int vtimer_emulate (struct cpu_user_regs *regs,union hsr hsr); +extern bool vtimer_emulate (struct cpu_user_regs *regs,union hsr hsr);extern int virt_timer_save (struct vcpu *v);extern int virt_timer_restore (struct vcpu *v);extern void vcpu_timer_destroy (struct vcpu *v);
Signature · 7 lines
1.9.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 01/13] xen/arm: vtimer: Switch the emulation functions return from int to bool
Quoted 4 lines · Julien Grall
The emulation functions are always returning 0 or 1. Use bool instead to make clear only two possible values exist.
Signed-off-by Julien Grall <[email protected]>
Quoted 216 lines
xen/arch/arm/vtimer.c | 60 +++++++++++++++++++++++++-------------------------- xen/arch/arm/vtimer.h | 2 +- 2 files changed, 31 insertions(+), 31 deletions(-)xen/arch/arm/vtimer.c +30
-30@@ -164,12 +164,12 @@ int virt_timer_restore(struct vcpu *v)return 0 ; } -static int vtimer_cntp_ctl (struct cpu_user_regs *regs,uint32_t *r,int read) +static bool vtimer_cntp_ctl (struct cpu_user_regs *regs,uint32_t *r,int read) {struct vcpu *v = current;if ( !ACCESS_ALLOWED (regs,EL0PTEN ) ) -return 0 ; +return false;if ( read ) {@@ -190,16 +190,16 @@ static int vtimer_cntp_ctl(struct cpu_user_regs *regs, uint32_t *r, int read)else stop_timer (&v->arch.phys_timer.timer); } -return 1 ; +return true; } -static int vtimer_cntp_tval (struct cpu_user_regs *regs,uint32_t *r,int read) +static bool vtimer_cntp_tval (struct cpu_user_regs *regs,uint32_t *r,int read) {struct vcpu *v = current;s_time_t now;if ( !ACCESS_ALLOWED (regs,EL0PTEN ) ) -return 0 ; +return false; now =NOW () - v->domain->arch.phys_timer_base.offset;@@ -218,15 +218,15 @@ static int vtimer_cntp_tval(struct cpu_user_regs *regs, uint32_t *r, int read) v->domain->arch.phys_timer_base.offset); } } -return 1 ; +return true; } -static int vtimer_cntp_cval (struct cpu_user_regs *regs,uint64_t *r,int read) +static bool vtimer_cntp_cval (struct cpu_user_regs *regs,uint64_t *r,int read) {struct vcpu *v = current;if ( !ACCESS_ALLOWED (regs,EL0PTEN ) ) -return 0 ; +return false;if ( read ) {@@ -243,10 +243,10 @@ static int vtimer_cntp_cval(struct cpu_user_regs *regs, uint64_t *r, int read) v->domain->arch.phys_timer_base.offset); } } -return 1 ; +return true; } -static int vtimer_emulate_cp32 (struct cpu_user_regs *regs,union hsr hsr) +static bool vtimer_emulate_cp32 (struct cpu_user_regs *regs,union hsr hsr) {struct hsr_cp32 cp32 = hsr.cp32;/* @@ -255,7 +255,7 @@ static int vtimer_emulate_cp32(struct cpu_user_regs *regs, union hsr hsr)* setting r). */ uint32_t r =0 ; -int res; +bool res;if ( cp32.read )@@ -277,7 +277,7 @@ static int vtimer_emulate_cp32(struct cpu_user_regs *regs, union hsr hsr)break ;default : -return 0 ; +return false; }if ( res && cp32.read )@@ -286,7 +286,7 @@ static int vtimer_emulate_cp32(struct cpu_user_regs *regs, union hsr hsr)return res; } -static int vtimer_emulate_cp64 (struct cpu_user_regs *regs,union hsr hsr) +static bool vtimer_emulate_cp64 (struct cpu_user_regs *regs,union hsr hsr) {struct hsr_cp64 cp64 = hsr.cp64;uint32_t r1 =get_user_reg (regs, cp64.reg1);@@ -302,11 +302,11 @@ static int vtimer_emulate_cp64(struct cpu_user_regs *regs, union hsr hsr) {case HSR_CPREG64 (CNTP_CVAL ):if ( !vtimer_cntp_cval (regs, &x, cp64.read) ) -return 0 ; +return false;break ;default : -return 0 ; +return false; }if ( cp64.read )@@ -315,21 +315,21 @@ static int vtimer_emulate_cp64(struct cpu_user_regs *regs, union hsr hsr)set_user_reg (regs, cp64.reg2, x >>32 ); } -return 1 ; +return true; }#ifdef CONFIG_ARM_64 -typedef int (*vtimer_sysreg32_fn_t )(struct cpu_user_regs *regs,uint32_t *r, -int read); -typedef int (*vtimer_sysreg64_fn_t )(struct cpu_user_regs *regs,uint64_t *r, -int read); +typedef bool (*vtimer_sysreg32_fn_t )(struct cpu_user_regs *regs,uint32_t *r, +int read); +typedef bool (*vtimer_sysreg64_fn_t )(struct cpu_user_regs *regs,uint64_t *r, +int read); -static int vtimer_emulate_sysreg32 (struct cpu_user_regs *regs,union hsr hsr, -vtimer_sysreg32_fn_t fn) +static bool vtimer_emulate_sysreg32 (struct cpu_user_regs *regs,union hsr hsr, +vtimer_sysreg32_fn_t fn) {struct hsr_sysreg sysreg = hsr.sysreg;uint32_t r =0 ; -int ret; +bool ret;if ( !sysreg.read ) r =get_user_reg (regs, sysreg.reg);@@ -342,8 +342,8 @@ static int vtimer_emulate_sysreg32(struct cpu_user_regs *regs, union hsr hsr,return ret; } -static int vtimer_emulate_sysreg64 (struct cpu_user_regs *regs,union hsr hsr, -vtimer_sysreg64_fn_t fn) +static bool vtimer_emulate_sysreg64 (struct cpu_user_regs *regs,union hsr hsr, +vtimer_sysreg64_fn_t fn) {struct hsr_sysreg sysreg = hsr.sysreg;/* @@ -352,7 +352,7 @@ static int vtimer_emulate_sysreg64(struct cpu_user_regs *regs, union hsr hsr,* setting x). */ uint64_t x =0 ; -int ret; +bool ret;if ( !sysreg.read ) x =get_user_reg (regs, sysreg.reg);@@ -365,7 +365,7 @@ static int vtimer_emulate_sysreg64(struct cpu_user_regs *regs, union hsr hsr,return ret; } -static int vtimer_emulate_sysreg (struct cpu_user_regs *regs,union hsr hsr) +static bool vtimer_emulate_sysreg (struct cpu_user_regs *regs,union hsr hsr) {struct hsr_sysreg sysreg = hsr.sysreg;@@ -384,13 +384,13 @@ static int vtimer_emulate_sysreg(struct cpu_user_regs *regs, union hsr hsr)return vtimer_emulate_sysreg64 (regs, hsr, vtimer_cntp_cval);default : - return 0; + return false; } }#endif -int vtimer_emulate (struct cpu_user_regs *regs,union hsr hsr) +bool vtimer_emulate (struct cpu_user_regs *regs,union hsr hsr) {switch (hsr.ec) {@@ -403,7 +403,7 @@ int vtimer_emulate(struct cpu_user_regs *regs, union hsr hsr)return vtimer_emulate_sysreg (regs, hsr);#endif default : -return 0 ; +return false; } }xen/arch/arm/vtimer.h +1
-1@@ -23,7 +23,7 @@extern int domain_vtimer_init (struct domain *d,struct xen_arch_domainconfig *config);extern int vcpu_vtimer_init (struct vcpu *v); -extern int vtimer_emulate (struct cpu_user_regs *regs,union hsr hsr); +extern bool vtimer_emulate (struct cpu_user_regs *regs,union hsr hsr);extern int virt_timer_save (struct vcpu *v);extern int virt_timer_restore (struct vcpu *v);extern void vcpu_timer_destroy (struct vcpu *v);Signature · 1 line
1.9.1
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 2/13 xen/arm: vtimer: Switch the read variable in the emulation from int to bool
In reply to Julien GrallThe read variable can only take two values: 1 => read, 0 => write. Use bool instead to make clear the variable can only take 2 values.
--- xen/arch/arm/vtimer.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
xen/arch/arm/vtimer.c +7 -5
@@ -164,7 +164,7 @@ int virt_timer_restore(struct vcpu *v)return 0 ; } -static bool vtimer_cntp_ctl (struct cpu_user_regs *regs,uint32_t *r,int read) +static bool vtimer_cntp_ctl (struct cpu_user_regs *regs,uint32_t *r,bool read) {struct vcpu *v = current;
@@ -193,7 +193,8 @@ static bool vtimer_cntp_ctl(struct cpu_user_regs *regs, uint32_t *r, int read)return true; } -static bool vtimer_cntp_tval (struct cpu_user_regs *regs,uint32_t *r,int read) +static bool vtimer_cntp_tval (struct cpu_user_regs *regs,uint32_t *r, +bool read) {struct vcpu *v = current;s_time_t now;
@@ -221,7 +222,8 @@ static bool vtimer_cntp_tval(struct cpu_user_regs *regs, uint32_t *r, int read)return true; } -static bool vtimer_cntp_cval (struct cpu_user_regs *regs,uint64_t *r,int read) +static bool vtimer_cntp_cval (struct cpu_user_regs *regs,uint64_t *r, +bool read) {struct vcpu *v = current;
@@ -320,9 +322,9 @@ static bool vtimer_emulate_cp64(struct cpu_user_regs *regs, union hsr hsr)#ifdef CONFIG_ARM_64 typedef bool (*vtimer_sysreg32_fn_t )(struct cpu_user_regs *regs,uint32_t *r, -int read); +bool read);typedef bool (*vtimer_sysreg64_fn_t )(struct cpu_user_regs *regs,uint64_t *r, -int read); +bool read);static bool vtimer_emulate_sysreg32 (struct cpu_user_regs *regs,union hsr hsr,vtimer_sysreg32_fn_t fn)
Signature · 7 lines
1.9.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 02/13] xen/arm: vtimer: Switch the read variable in the emulation from int to bool
Quoted 4 lines · Julien Grall
The read variable can only take two values: 1 => read, 0 => write. Use bool instead to make clear the variable can only take 2 values.
Signed-off-by Julien Grall <[email protected]>
Quoted 51 lines
xen/arch/arm/vtimer.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)xen/arch/arm/vtimer.c +7
-5@@ -164,7 +164,7 @@ int virt_timer_restore(struct vcpu *v)return 0 ; } -static bool vtimer_cntp_ctl (struct cpu_user_regs *regs,uint32_t *r,int read) +static bool vtimer_cntp_ctl (struct cpu_user_regs *regs,uint32_t *r,bool read) {struct vcpu *v = current;@@ -193,7 +193,8 @@ static bool vtimer_cntp_ctl(struct cpu_user_regs *regs, uint32_t *r, int read)return true; } -static bool vtimer_cntp_tval (struct cpu_user_regs *regs,uint32_t *r,int read) +static bool vtimer_cntp_tval (struct cpu_user_regs *regs,uint32_t *r, +bool read) {struct vcpu *v = current;s_time_t now;@@ -221,7 +222,8 @@ static bool vtimer_cntp_tval(struct cpu_user_regs *regs, uint32_t *r, int read)return true; } -static bool vtimer_cntp_cval (struct cpu_user_regs *regs,uint64_t *r,int read) +static bool vtimer_cntp_cval (struct cpu_user_regs *regs,uint64_t *r, +bool read) {struct vcpu *v = current;@@ -320,9 +322,9 @@ static bool vtimer_emulate_cp64(struct cpu_user_regs *regs, union hsr hsr)#ifdef CONFIG_ARM_64 typedef bool (*vtimer_sysreg32_fn_t )(struct cpu_user_regs *regs,uint32_t *r, -int read); +bool read);typedef bool (*vtimer_sysreg64_fn_t )(struct cpu_user_regs *regs,uint64_t *r, -int read); +bool read);static bool vtimer_emulate_sysreg32 (struct cpu_user_regs *regs,union hsr hsr,vtimer_sysreg32_fn_t fn)Signature · 1 line
1.9.1
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 3/13 xen/arm: traps: Switch from bool_t to bool
In reply to Julien GrallSince commit 9202342 "xen/build: Use C99 booleans", bool_t is an alias to bool. Going forward, there is a preference to use bool rather than bool_t. Also replace 0 and 1 by true and false when relevant.
--- xen/arch/arm/traps.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
xen/arch/arm/traps.c +7 -7
@@ -154,13 +154,13 @@ static void print_xen_info(void) }#ifdef CONFIG_ARM_32 -static inline bool_t is_zero_register (int reg) +static inline bool is_zero_register (int reg) {/* There is no zero register for ARM32 */ -return 0 ; +return false; }#else -static inline bool_t is_zero_register (int reg) +static inline bool is_zero_register (int reg) {/* * For store/load and sysreg instruction, the encoding 31 always
@@ -1500,7 +1500,7 @@ static void do_trap_hypercall(struct cpu_user_regs *regs, register_t *nr,#endif } -static bool_t check_multicall_32bit_clean (struct multicall_entry *multi) +static bool check_multicall_32bit_clean (struct multicall_entry *multi) {int i;
@@ -1661,7 +1661,7 @@ 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_t read, +bool read,const union hsr hsr,int min_el) {
@@ -1680,7 +1680,7 @@ static void handle_raz_wi(struct cpu_user_regs *regs,/* Write only as write ignore */ static void handle_wo_wi (struct cpu_user_regs *regs,int regidx, -bool_t read, +bool read,const union hsr hsr,int min_el) {
@@ -1699,7 +1699,7 @@ 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_t read, +bool read,const union hsr hsr,int min_el) {
Signature · 7 lines
1.9.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 03/13] xen/arm: traps: Switch from bool_t to bool
Quoted 5 lines · Julien Grall
Since commit 9202342 "xen/build: Use C99 booleans",
bool_tis an alias to bool. Going forward, there is a preference to use bool rather thanbool_t. Also replace 0 and 1 by true and false when relevant.Signed-off-by Julien Grall <[email protected]>
Quoted 64 lines
--- xen/arch/arm/traps.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)xen/arch/arm/traps.c +7
-7@@ -154,13 +154,13 @@ static void print_xen_info(void) }#ifdef CONFIG_ARM_32 -static inline bool_t is_zero_register (int reg) +static inline bool is_zero_register (int reg) {/* There is no zero register for ARM32 */ -return 0 ; +return false; }#else -static inline bool_t is_zero_register (int reg) +static inline bool is_zero_register (int reg) {/* * For store/load and sysreg instruction, the encoding 31 always @@ -1500,7 +1500,7 @@ static void do_trap_hypercall(struct cpu_user_regs *regs, register_t *nr,#endif } -static bool_t check_multicall_32bit_clean (struct multicall_entry *multi) +static bool check_multicall_32bit_clean (struct multicall_entry *multi) {int i;@@ -1661,7 +1661,7 @@ 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_t read, +bool read,const union hsr hsr,int min_el) {@@ -1680,7 +1680,7 @@ static void handle_raz_wi(struct cpu_user_regs *regs,/* Write only as write ignore */ static void handle_wo_wi (struct cpu_user_regs *regs,int regidx, -bool_t read, +bool read,const union hsr hsr,int min_el) {@@ -1699,7 +1699,7 @@ 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_t read, +bool read,const union hsr hsr,int min_el) {Signature · 1 line
1.9.1
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 4/13 xen/arm: vgic: Switch from bool_t to bool
In reply to Julien GrallSince commit 9202342 "xen/build: Use C99 booleans", bool_t is an alias to bool. Going forward, therer is a preference to use bool rather than bool_t. Also replace 0 and 1 by false and true when relevant.
--- xen/arch/arm/vgic.c | 8 ++++---- xen/include/asm-arm/vgic.h | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-)
xen/arch/arm/vgic.c +4 -4
@@ -482,7 +482,7 @@ void vgic_vcpu_inject_irq(struct vcpu *v, unsigned int virq)uint8_t priority;struct pending_irq *iter, *n =irq_to_pending (v, virq);unsigned long flags; -bool_t running; +bool running; priority =vgic_get_virq_priority (v, virq);
@@ -555,15 +555,15 @@ int vgic_emulate(struct cpu_user_regs *regs, union hsr hsr)return v->domain->arch.vgic.handler->emulate_sysreg (regs, hsr); } -bool_t vgic_reserve_virq (struct domain *d,unsigned int virq) +bool vgic_reserve_virq (struct domain *d,unsigned int virq) {if ( virq >=vgic_num_irqs (d) ) -return 0 ; +return false;return !test_and_set_bit (virq, d->arch.vgic.allocated_irqs); } -int vgic_allocate_virq (struct domain *d,bool_t spi) +int vgic_allocate_virq (struct domain *d,bool spi) {int first, end;unsigned int virq;
xen/include/asm-arm/vgic.h +4 -4
@@ -315,23 +315,23 @@ extern int vgic_to_sgi(struct vcpu *v, register_t sgir,extern void vgic_migrate_irq (struct vcpu *old,struct vcpu *new,unsigned int irq);/* Reserve a specific guest vIRQ */ -extern bool_t vgic_reserve_virq (struct domain *d,unsigned int virq); +extern bool vgic_reserve_virq (struct domain *d,unsigned int virq);/* * Allocate a guest VIRQ * - spi == 0 => allocate a PPI. It will be the same on every vCPU * - spi == 1 => allocate an SPI */ -extern int vgic_allocate_virq (struct domain *d,bool_t spi); +extern int vgic_allocate_virq (struct domain *d,bool spi);static inline int vgic_allocate_ppi (struct domain *d) { -return vgic_allocate_virq (d,0 /* ppi */ ); +return vgic_allocate_virq (d, false/* ppi */ ); }static inline int vgic_allocate_spi (struct domain *d) { -return vgic_allocate_virq (d,1 /* spi */ ); +return vgic_allocate_virq (d, true/* spi */ ); }extern void vgic_free_virq (struct domain *d,unsigned int virq);
Signature · 7 lines
1.9.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 04/13] xen/arm: vgic: Switch from bool_t to bool
Quoted 5 lines · Julien Grall
Since commit 9202342 "xen/build: Use C99 booleans",
bool_tis an alias to bool. Going forward, therer is a preference to use bool rather thanbool_t. Also replace 0 and 1 by false and true when relevant.Signed-off-by Julien Grall <[email protected]>
Quoted 72 lines
--- xen/arch/arm/vgic.c | 8 ++++---- xen/include/asm-arm/vgic.h | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-)xen/arch/arm/vgic.c +4
-4@@ -482,7 +482,7 @@ void vgic_vcpu_inject_irq(struct vcpu *v, unsigned int virq)uint8_t priority;struct pending_irq *iter, *n =irq_to_pending (v, virq);unsigned long flags; -bool_t running; +bool running; priority =vgic_get_virq_priority (v, virq);@@ -555,15 +555,15 @@ int vgic_emulate(struct cpu_user_regs *regs, union hsr hsr)return v->domain->arch.vgic.handler->emulate_sysreg (regs, hsr); } -bool_t vgic_reserve_virq (struct domain *d,unsigned int virq) +bool vgic_reserve_virq (struct domain *d,unsigned int virq) {if ( virq >=vgic_num_irqs (d) ) -return 0 ; +return false;return !test_and_set_bit (virq, d->arch.vgic.allocated_irqs); } -int vgic_allocate_virq (struct domain *d,bool_t spi) +int vgic_allocate_virq (struct domain *d,bool spi) {int first, end;unsigned int virq;xen/include/asm-arm/vgic.h +4
-4@@ -315,23 +315,23 @@ extern int vgic_to_sgi(struct vcpu *v, register_t sgir,extern void vgic_migrate_irq (struct vcpu *old,struct vcpu *new,unsigned int irq);/* Reserve a specific guest vIRQ */ -extern bool_t vgic_reserve_virq (struct domain *d,unsigned int virq); +extern bool vgic_reserve_virq (struct domain *d,unsigned int virq);/* * Allocate a guest VIRQ * - spi == 0 => allocate a PPI. It will be the same on every vCPU * - spi == 1 => allocate an SPI */ -extern int vgic_allocate_virq (struct domain *d,bool_t spi); +extern int vgic_allocate_virq (struct domain *d,bool spi);static inline int vgic_allocate_ppi (struct domain *d) { -return vgic_allocate_virq (d,0 /* ppi */ ); +return vgic_allocate_virq (d, false/* ppi */ ); }static inline int vgic_allocate_spi (struct domain *d) { -return vgic_allocate_virq (d,1 /* spi */ ); +return vgic_allocate_virq (d, true/* spi */ ); }extern void vgic_free_virq (struct domain *d,unsigned int virq);Signature · 1 line
1.9.1
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 5/13 xen/arm: vgic: Switch vgic_to_sgi return from int to bool and progate up to...
In reply to Julien Grallvgic_v{2,3}_to_sgi.
vgic_*to_sgi functions can only return 2 values: 0 or 1. Use bool instead to make clear only two possible values exist.
--- xen/arch/arm/vgic-v2.c | 4 ++-- xen/arch/arm/vgic-v3.c | 2 +- xen/arch/arm/vgic.c | 8 ++++---- xen/include/asm-arm/vgic.h | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-)
xen/arch/arm/vgic-v2.c +2 -2
@@ -374,7 +374,7 @@ read_reserved:return 1 ; } -static int vgic_v2_to_sgi (struct vcpu *v,register_t sgir) +static bool vgic_v2_to_sgi (struct vcpu *v,register_t sgir) {int virq;
@@ -403,7 +403,7 @@ static int vgic_v2_to_sgi(struct vcpu *v, register_t sgir)printk (XENLOG_G_DEBUG "%pv: vGICD: unhandled GICD_SGIR write %" PRIregister" with wrong mode\n" , v, sgir); -return 0 ; +return false; }return vgic_to_sgi (v, sgir, sgi_mode, virq, &target);
xen/arch/arm/vgic-v3.c +1 -1
@@ -1269,7 +1269,7 @@ write_reserved:return 1 ; } -static int vgic_v3_to_sgi (struct vcpu *v,register_t sgir) +static bool vgic_v3_to_sgi (struct vcpu *v,register_t sgir) {int virq;int irqmode;
xen/arch/arm/vgic.c +4 -4
@@ -393,8 +393,8 @@ void vgic_enable_irqs(struct vcpu *v, uint32_t r, int n) } } -int vgic_to_sgi (struct vcpu *v,register_t sgir,enum gic_sgi_mode irqmode,int virq, -const struct sgi_target *target) +bool vgic_to_sgi (struct vcpu *v,register_t sgir,enum gic_sgi_mode irqmode, +int virq,const struct sgi_target *target) {struct domain *d = v->domain;int vcpuid;
@@ -440,10 +440,10 @@ int vgic_to_sgi(struct vcpu *v, register_t sgir, enum gic_sgi_mode irqmode, intgprintk (XENLOG_WARNING ,"vGICD:unhandled GICD_SGIR write %" PRIregister" \ with wrong mode\n" , sgir); -return 0 ; +return false; } -return 1 ; +return true; }struct pending_irq *irq_to_pending (struct vcpu *v,unsigned int irq)
xen/include/asm-arm/vgic.h +3 -3
@@ -309,9 +309,9 @@ int vgic_v3_init(struct domain *d, int *mmio_count);extern int domain_vgic_register (struct domain *d,int *mmio_count);extern int vcpu_vgic_free (struct vcpu *v); -extern int vgic_to_sgi (struct vcpu *v,register_t sgir, -enum gic_sgi_mode irqmode,int virq, -const struct sgi_target *target); +extern bool vgic_to_sgi (struct vcpu *v,register_t sgir, +enum gic_sgi_mode irqmode,int virq, +const struct sgi_target *target);extern void vgic_migrate_irq (struct vcpu *old,struct vcpu *new,unsigned int irq);/* Reserve a specific guest vIRQ */
Signature · 7 lines
1.9.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 05/13] xen/arm: vgic: Switch vgic_to_sgi return from int to bool and progate up to...
Quoted 6 lines · Julien Grall
vgic_v{2,3}_to_sgi.
vgic_*to_sgi functions can only return 2 values: 0 or 1. Use bool instead to make clear only two possible values exist.
Signed-off-by Julien Grall <[email protected]>
Quoted 90 lines
--- xen/arch/arm/vgic-v2.c | 4 ++-- xen/arch/arm/vgic-v3.c | 2 +- xen/arch/arm/vgic.c | 8 ++++---- xen/include/asm-arm/vgic.h | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-)xen/arch/arm/vgic-v2.c +2
-2@@ -374,7 +374,7 @@ read_reserved:return 1 ; } -static int vgic_v2_to_sgi (struct vcpu *v,register_t sgir) +static bool vgic_v2_to_sgi (struct vcpu *v,register_t sgir) {int virq;@@ -403,7 +403,7 @@ static int vgic_v2_to_sgi(struct vcpu *v, register_t sgir)printk (XENLOG_G_DEBUG "%pv: vGICD: unhandled GICD_SGIR write %" PRIregister" with wrong mode\n" , v, sgir); -return 0 ; +return false; }return vgic_to_sgi (v, sgir, sgi_mode, virq, &target);xen/arch/arm/vgic-v3.c +1
-1@@ -1269,7 +1269,7 @@ write_reserved:return 1 ; } -static int vgic_v3_to_sgi (struct vcpu *v,register_t sgir) +static bool vgic_v3_to_sgi (struct vcpu *v,register_t sgir) {int virq;int irqmode;xen/arch/arm/vgic.c +4
-4@@ -393,8 +393,8 @@ void vgic_enable_irqs(struct vcpu *v, uint32_t r, int n) } } -int vgic_to_sgi (struct vcpu *v,register_t sgir,enum gic_sgi_mode irqmode,int virq, -const struct sgi_target *target) +bool vgic_to_sgi (struct vcpu *v,register_t sgir,enum gic_sgi_mode irqmode, +int virq,const struct sgi_target *target) {struct domain *d = v->domain;int vcpuid;@@ -440,10 +440,10 @@ int vgic_to_sgi(struct vcpu *v, register_t sgir, enum gic_sgi_mode irqmode, intgprintk (XENLOG_WARNING ,"vGICD:unhandled GICD_SGIR write %" PRIregister" \ with wrong mode\n" , sgir); -return 0 ; +return false; } -return 1 ; +return true; }struct pending_irq *irq_to_pending (struct vcpu *v,unsigned int irq)xen/include/asm-arm/vgic.h +3
-3@@ -309,9 +309,9 @@ int vgic_v3_init(struct domain *d, int *mmio_count);extern int domain_vgic_register (struct domain *d,int *mmio_count);extern int vcpu_vgic_free (struct vcpu *v); -extern int vgic_to_sgi (struct vcpu *v,register_t sgir, -enum gic_sgi_mode irqmode,int virq, -const struct sgi_target *target); +extern bool vgic_to_sgi (struct vcpu *v,register_t sgir, +enum gic_sgi_mode irqmode,int virq, +const struct sgi_target *target);extern void vgic_migrate_irq (struct vcpu *old,struct vcpu *new,unsigned int irq);/* Reserve a specific guest vIRQ */ Signature · 1 line
1.9.1
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 05/13] xen/arm: vgic: Switch vgic_to_sgi return from int to bool and progate up to...
Quoted 9 lines · Stefano Stabellini
Quoted 6 lines · Julien Grall
vgic_v{2,3}_to_sgi.
vgic_*to_sgi functions can only return 2 values: 0 or 1. Use bool instead to make clear only two possible values exist.
Signed-off-by Julien Grall <[email protected]>Reviewed-by Stefano Stabellini <[email protected]>
Actually, you missed one see below.
Quoted 37 lines
Quoted 37 lines
--- xen/arch/arm/vgic-v2.c | 4 ++-- xen/arch/arm/vgic-v3.c | 2 +- xen/arch/arm/vgic.c | 8 ++++---- xen/include/asm-arm/vgic.h | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-)xen/arch/arm/vgic-v2.c +2
-2@@ -374,7 +374,7 @@ read_reserved:return 1 ; } -static int vgic_v2_to_sgi (struct vcpu *v,register_t sgir) +static bool vgic_v2_to_sgi (struct vcpu *v,register_t sgir) {int virq;@@ -403,7 +403,7 @@ static int vgic_v2_to_sgi(struct vcpu *v, register_t sgir)printk (XENLOG_G_DEBUG "%pv: vGICD: unhandled GICD_SGIR write %" PRIregister" with wrong mode\n" , v, sgir); -return 0 ; +return false; }return vgic_to_sgi (v, sgir, sgi_mode, virq, &target);xen/arch/arm/vgic-v3.c +0
-0@@ -1269,7 +1269,7 @@ write_reserved:return 1 ; }
Quoted 5 lines
xen/arch/arm/vgic-v3.c write_reserved: · line 1275
Quoted 5 lines
xen/arch/arm/vgic-v3.c +1
-1-static int vgic_v3_to_sgi (struct vcpu *v,register_t sgir) +static bool vgic_v3_to_sgi (struct vcpu *v,register_t sgir) {int virq;int irqmode;
You missed a 0 to false change here, if you don't mind, I'll do it.
Quoted 44 lines
Quoted 44 lines
xen/arch/arm/vgic.c +4
-4@@ -393,8 +393,8 @@ void vgic_enable_irqs(struct vcpu *v, uint32_t r, int n) } } -int vgic_to_sgi (struct vcpu *v,register_t sgir,enum gic_sgi_mode irqmode,int virq, -const struct sgi_target *target) +bool vgic_to_sgi (struct vcpu *v,register_t sgir,enum gic_sgi_mode irqmode, +int virq,const struct sgi_target *target) {struct domain *d = v->domain;int vcpuid;@@ -440,10 +440,10 @@ int vgic_to_sgi(struct vcpu *v, register_t sgir, enum gic_sgi_mode irqmode, intgprintk (XENLOG_WARNING ,"vGICD:unhandled GICD_SGIR write %" PRIregister" \ with wrong mode\n" , sgir); -return 0 ; +return false; } -return 1 ; +return true; }struct pending_irq *irq_to_pending (struct vcpu *v,unsigned int irq)xen/include/asm-arm/vgic.h +3
-3@@ -309,9 +309,9 @@ int vgic_v3_init(struct domain *d, int *mmio_count);extern int domain_vgic_register (struct domain *d,int *mmio_count);extern int vcpu_vgic_free (struct vcpu *v); -extern int vgic_to_sgi (struct vcpu *v,register_t sgir, -enum gic_sgi_mode irqmode,int virq, -const struct sgi_target *target); +extern bool vgic_to_sgi (struct vcpu *v,register_t sgir, +enum gic_sgi_mode irqmode,int virq, +const struct sgi_target *target);extern void vgic_migrate_irq (struct vcpu *old,struct vcpu *new,unsigned int irq);
Quoted 5 lines
Quoted 4 lines
xen/include/asm-arm/vgic.h +0
-0/* Reserve a specific guest vIRQ */ Signature · 1 line
1.9.1
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 6/13 xen/arm: vgic: Switch emulate_sysreg return from int to bool
In reply to Julien Grallemulate_sysreg callback can only return 2 values: 0 or 1. Use bool instead to make clear only two possible values exist.
--- xen/arch/arm/vgic-v3.c | 6 +++--- xen/arch/arm/vgic.c | 2 +- xen/include/asm-arm/vgic.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-)
xen/arch/arm/vgic-v3.c +3 -3
@@ -1300,7 +1300,7 @@ static bool vgic_v3_to_sgi(struct vcpu *v, register_t sgir)return vgic_to_sgi (v, sgir, sgi_mode, virq, &target); } -static int vgic_v3_emulate_sysreg (struct cpu_user_regs *regs,union hsr hsr) +static bool vgic_v3_emulate_sysreg (struct cpu_user_regs *regs,union hsr hsr) {struct vcpu *v = current;struct hsr_sysreg sysreg = hsr.sysreg;
@@ -1321,10 +1321,10 @@ static int vgic_v3_emulate_sysreg(struct cpu_user_regs *regs, union hsr hsr)else {gprintk (XENLOG_WARNING ,"Reading SGI1R_EL1 - WO register\n" ); -return 0 ; +return false; }default : -return 0 ; +return false; } }
xen/arch/arm/vgic.c +1 -1
@@ -546,7 +546,7 @@ void arch_evtchn_inject(struct vcpu *v)vgic_vcpu_inject_irq (v, v->domain->arch.evtchn_irq); } -int vgic_emulate (struct cpu_user_regs *regs,union hsr hsr) +bool vgic_emulate (struct cpu_user_regs *regs,union hsr hsr) {struct vcpu *v = current;
xen/include/asm-arm/vgic.h +2 -2
@@ -131,7 +131,7 @@ struct vgic_ops {/* Release resources that were allocated by domain_init */ void (*domain_free)(struct domain *d);/* vGIC sysreg emulation */ -int (*emulate_sysreg)(struct cpu_user_regs *regs,union hsr hsr); +bool (*emulate_sysreg)(struct cpu_user_regs *regs,union hsr hsr);/* Maximum number of vCPU supported */ const unsigned int max_vcpus; };
@@ -300,7 +300,7 @@ extern struct pending_irq *irq_to_pending(struct vcpu *v, unsigned int irq);extern struct pending_irq *spi_to_pending (struct domain *d,unsigned int irq);extern struct vgic_irq_rank *vgic_rank_offset (struct vcpu *v,int b,int n,int s);extern struct vgic_irq_rank *vgic_rank_irq (struct vcpu *v,unsigned int irq); -extern int vgic_emulate (struct cpu_user_regs *regs,union hsr hsr); +extern bool vgic_emulate (struct cpu_user_regs *regs,union hsr hsr);extern void vgic_disable_irqs (struct vcpu *v,uint32_t r,int n);extern void vgic_enable_irqs (struct vcpu *v,uint32_t r,int n);extern void register_vgic_ops (struct domain *d,const struct vgic_ops *ops);
Signature · 7 lines
1.9.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 06/13] xen/arm: vgic: Switch emulate_sysreg return from int to bool
Quoted 4 lines · Julien Grall
emulate_sysregcallback can only return 2 values: 0 or 1. Use bool instead to make clear only two possible values exist.Signed-off-by Julien Grall <[email protected]>
Quoted 69 lines
xen/arch/arm/vgic-v3.c | 6 +++--- xen/arch/arm/vgic.c | 2 +- xen/include/asm-arm/vgic.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-)xen/arch/arm/vgic-v3.c +3
-3@@ -1300,7 +1300,7 @@ static bool vgic_v3_to_sgi(struct vcpu *v, register_t sgir)return vgic_to_sgi (v, sgir, sgi_mode, virq, &target); } -static int vgic_v3_emulate_sysreg (struct cpu_user_regs *regs,union hsr hsr) +static bool vgic_v3_emulate_sysreg (struct cpu_user_regs *regs,union hsr hsr) {struct vcpu *v = current;struct hsr_sysreg sysreg = hsr.sysreg;@@ -1321,10 +1321,10 @@ static int vgic_v3_emulate_sysreg(struct cpu_user_regs *regs, union hsr hsr)else {gprintk (XENLOG_WARNING ,"Reading SGI1R_EL1 - WO register\n" ); -return 0 ; +return false; }default : -return 0 ; +return false; } }xen/arch/arm/vgic.c +1
-1@@ -546,7 +546,7 @@ void arch_evtchn_inject(struct vcpu *v)vgic_vcpu_inject_irq (v, v->domain->arch.evtchn_irq); } -int vgic_emulate (struct cpu_user_regs *regs,union hsr hsr) +bool vgic_emulate (struct cpu_user_regs *regs,union hsr hsr) {struct vcpu *v = current;xen/include/asm-arm/vgic.h +2
-2@@ -131,7 +131,7 @@ struct vgic_ops {/* Release resources that were allocated by domain_init */ void (*domain_free)(struct domain *d);/* vGIC sysreg emulation */ -int (*emulate_sysreg)(struct cpu_user_regs *regs,union hsr hsr); +bool (*emulate_sysreg)(struct cpu_user_regs *regs,union hsr hsr);/* Maximum number of vCPU supported */ const unsigned int max_vcpus; };@@ -300,7 +300,7 @@ extern struct pending_irq *irq_to_pending(struct vcpu *v, unsigned int irq);extern struct pending_irq *spi_to_pending (struct domain *d,unsigned int irq);extern struct vgic_irq_rank *vgic_rank_offset (struct vcpu *v,int b,int n,int s);extern struct vgic_irq_rank *vgic_rank_irq (struct vcpu *v,unsigned int irq); -extern int vgic_emulate (struct cpu_user_regs *regs,union hsr hsr); +extern bool vgic_emulate (struct cpu_user_regs *regs,union hsr hsr);extern void vgic_disable_irqs (struct vcpu *v,uint32_t r,int n);extern void vgic_enable_irqs (struct vcpu *v,uint32_t r,int n);extern void register_vgic_ops (struct domain *d,const struct vgic_ops *ops);Signature · 1 line
1.9.1
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 7/13 xen/arm: vgic: Clean-up the sysreg emulation
In reply to Julien GrallCouple of clean-up for the vgic sysreg emulation:
- Reference the public documentation rather than a non-public one
- Let the vgic emulation decides whether a register needs to be emulated
- Drop unnecessary debug printk. They don't bring much information and can be misleading (vGICv2 does not support thoses registers)
--- xen/arch/arm/traps.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-)
xen/arch/arm/traps.c +4 -12
@@ -2261,23 +2261,15 @@ static void do_sysreg(struct cpu_user_regs *regs,/* * HCR_EL2.FMO or HCR_EL2.IMO * -* ARMv8: GIC Architecture Specification (PRD03-GENC-010745 24.0) -* Section 4.6.8. +* GIC Architecture Specification (IHI 0069C): Section 4.6.3 */ case HSR_SYSREG_ICC_SGI1R_EL1 : +case HSR_SYSREG_ICC_ASGI1R_EL1 : +case HSR_SYSREG_ICC_SGI0R_EL1 : +if ( !vgic_emulate (regs, hsr) ) - { -dprintk (XENLOG_WARNING , -"failed emulation of sysreg ICC_SGI1R_EL1 access\n" );return inject_undef64_exception (regs, hsr.len); - }break ; -case HSR_SYSREG_ICC_SGI0R_EL1 : -case HSR_SYSREG_ICC_ASGI1R_EL1 : -/* TBD: Implement to support secure grp0/1 SGI forwarding */ -dprintk (XENLOG_WARNING , -"Emulation of sysreg ICC_SGI0R_EL1/ASGI1R_EL1 not supported\n" ); -return inject_undef64_exception (regs, hsr.len);/* * ICC_SRE_EL2.Enable = 0
Signature · 7 lines
1.9.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 07/13] xen/arm: vgic: Clean-up the sysreg emulation
Quoted 8 lines · Julien Grall
Couple of clean-up for the vgic sysreg emulation:
- Reference the public documentation rather than a non-public one
- Let the vgic emulation decides whether a register needs to be emulated
- Drop unnecessary debug printk. They don't bring much information and can be misleading (vGICv2 does not support thoses registers)Signed-off-by Julien Grall <[email protected]>
Aside from a couple of typos in the commit message that I'll fix.
Quoted 38 lines
xen/arch/arm/traps.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-)xen/arch/arm/traps.c +4
-12@@ -2261,23 +2261,15 @@ static void do_sysreg(struct cpu_user_regs *regs,/* * HCR_EL2.FMO or HCR_EL2.IMO * -* ARMv8: GIC Architecture Specification (PRD03-GENC-010745 24.0) -* Section 4.6.8. +* GIC Architecture Specification (IHI 0069C): Section 4.6.3 */ case HSR_SYSREG_ICC_SGI1R_EL1 : +case HSR_SYSREG_ICC_ASGI1R_EL1 : +case HSR_SYSREG_ICC_SGI0R_EL1 : +if ( !vgic_emulate (regs, hsr) ) - { -dprintk (XENLOG_WARNING , -"failed emulation of sysreg ICC_SGI1R_EL1 access\n" );return inject_undef64_exception (regs, hsr.len); - }break ; -case HSR_SYSREG_ICC_SGI0R_EL1 : -case HSR_SYSREG_ICC_ASGI1R_EL1 : -/* TBD: Implement to support secure grp0/1 SGI forwarding */ -dprintk (XENLOG_WARNING , -"Emulation of sysreg ICC_SGI0R_EL1/ASGI1R_EL1 not supported\n" ); -return inject_undef64_exception (regs, hsr.len);/* * ICC_SRE_EL2.Enable = 0 Signature · 1 line
1.9.1
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 8/13 xen/arm: vgic-v3: Build vgic-v3.c when CONFIG_HAS_GICV3 is enabled.
In reply to Julien GrallThe vGICv3 depends whether Xen has a host driver for GICv3, not on the architecture (AArch64 vs AArch32).
Note CONFIG_HAS_GICV3 is enabled only when for ARM64 build, so there is no functional change.
--- xen/arch/arm/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/Makefile +1 -1
@@ -43,7 +43,7 @@ obj-y += time.o obj-y += traps.o obj-y += vgic.o obj-y += vgic-v2.o -obj-$(CONFIG_ARM_64) += vgic-v3.o +obj-$(CONFIG_HAS_GICV3) += vgic-v3.o obj-y += vm_event.o obj-y += vtimer.o obj-y += vpsci.o
Signature · 7 lines
1.9.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 08/13] xen/arm: vgic-v3: Build vgic-v3.c when CONFIG_HAS_GICV3 is enabled.
Quoted 7 lines · Julien Grall
The vGICv3 depends whether Xen has a host driver for GICv3, not on the architecture (AArch64 vs AArch32).
Note
CONFIG_HAS_GICV3is enabled only when for ARM64 build, so there is no functional change.Signed-off-by Julien Grall <[email protected]>
Quoted 20 lines
--- xen/arch/arm/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)xen/arch/arm/Makefile +1
-1@@ -43,7 +43,7 @@ obj-y += time.o obj-y += traps.o obj-y += vgic.o obj-y += vgic-v2.o -obj-$(CONFIG_ARM_64) += vgic-v3.o +obj-$(CONFIG_HAS_GICV3) += vgic-v3.o obj-y += vm_event.o obj-y += vtimer.o obj-y += vpsci.oSignature · 1 line
1.9.1
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 9/13 xen/arm: vtimer: Move emulate_sysreg* callback in a separate header
In reply to Julien GrallThe core emulation of sysreg (reading/writing registers) is not specific to the virtual timer. Move the helpers in a new header vreg.h.
---
The helpers will be necessary in a follow-up patch to emulate sysreg for another components.
--- xen/arch/arm/vtimer.c | 53 ++++--------------------------------------- xen/include/asm-arm/vreg.h | 56 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 49 deletions(-) create mode 100644 xen/include/asm-arm/vreg.h
xen/arch/arm/vtimer.c +4 -49
@@ -27,6 +27,7 @@#include <asm/time.h> #include <asm/gic.h> #include <asm/vgic.h> +#include <asm/vreg.h> #include <asm/regs.h> /*
@@ -321,52 +322,6 @@ static bool vtimer_emulate_cp64(struct cpu_user_regs *regs, union hsr hsr) }#ifdef CONFIG_ARM_64 -typedef bool (*vtimer_sysreg32_fn_t )(struct cpu_user_regs *regs,uint32_t *r, -bool read); -typedef bool (*vtimer_sysreg64_fn_t )(struct cpu_user_regs *regs,uint64_t *r, -bool read); - -static bool vtimer_emulate_sysreg32 (struct cpu_user_regs *regs,union hsr hsr, -vtimer_sysreg32_fn_t fn) -{ -struct hsr_sysreg sysreg = hsr.sysreg; -uint32_t r =0 ; -bool ret; - -if ( !sysreg.read ) - r =get_user_reg (regs, sysreg.reg); - - ret =fn (regs, &r, sysreg.read); - -if ( ret && sysreg.read ) -set_user_reg (regs, sysreg.reg, r); - -return ret; -} - -static bool vtimer_emulate_sysreg64 (struct cpu_user_regs *regs,union hsr hsr, -vtimer_sysreg64_fn_t fn) -{ -struct hsr_sysreg sysreg = hsr.sysreg; -/* -* Initialize to zero to avoid leaking data if there is an -* implementation error in the emulation (such as not correctly -* setting x). -*/ -uint64_t x =0 ; -bool ret; - -if ( !sysreg.read ) - x =get_user_reg (regs, sysreg.reg); - - ret =fn (regs, &x, sysreg.read); - -if ( ret && sysreg.read ) -set_user_reg (regs, sysreg.reg, x); - -return ret; -} -static bool vtimer_emulate_sysreg (struct cpu_user_regs *regs,union hsr hsr) {struct hsr_sysreg sysreg = hsr.sysreg;
@@ -379,11 +334,11 @@ static bool vtimer_emulate_sysreg(struct cpu_user_regs *regs, union hsr hsr)switch ( hsr.bits &HSR_SYSREG_REGS_MASK ) {case HSR_SYSREG_CNTP_CTL_EL0 : -return vtimer_emulate_sysreg32 (regs, hsr, vtimer_cntp_ctl); +return vreg_emulate_sysreg32 (regs, hsr, vtimer_cntp_ctl);case HSR_SYSREG_CNTP_TVAL_EL0 : -return vtimer_emulate_sysreg32 (regs, hsr, vtimer_cntp_tval); +return vreg_emulate_sysreg32 (regs, hsr, vtimer_cntp_tval);case HSR_SYSREG_CNTP_CVAL_EL0 : -return vtimer_emulate_sysreg64 (regs, hsr, vtimer_cntp_cval); +return vreg_emulate_sysreg64 (regs, hsr, vtimer_cntp_cval);default :return false;
xen/include/asm-arm/vreg.h new file +56 -0
56 lines not on this page · raw message
Signature · 7 lines
1.9.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 09/13] xen/arm: vtimer: Move emulate_sysreg* callback in a separate header
Quoted 4 lines · Julien Grall
The core emulation of sysreg (reading/writing registers) is not specific to the virtual timer. Move the helpers in a new header
vreg.h.Signed-off-by Julien Grall <[email protected]>
Quoted 155 lines
---
The helpers will be necessary in a follow-up patch to emulate sysreg for another components.
--- xen/arch/arm/vtimer.c | 53 ++++--------------------------------------- xen/include/asm-arm/vreg.h | 56 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 49 deletions(-) create mode 100644 xen/include/asm-arm/vreg.hxen/arch/arm/vtimer.c +4
-49@@ -27,6 +27,7 @@#include <asm/time.h> #include <asm/gic.h> #include <asm/vgic.h> +#include <asm/vreg.h> #include <asm/regs.h> /* @@ -321,52 +322,6 @@ static bool vtimer_emulate_cp64(struct cpu_user_regs *regs, union hsr hsr) }#ifdef CONFIG_ARM_64 -typedef bool (*vtimer_sysreg32_fn_t )(struct cpu_user_regs *regs,uint32_t *r, -bool read); -typedef bool (*vtimer_sysreg64_fn_t )(struct cpu_user_regs *regs,uint64_t *r, -bool read); - -static bool vtimer_emulate_sysreg32 (struct cpu_user_regs *regs,union hsr hsr, -vtimer_sysreg32_fn_t fn) -{ -struct hsr_sysreg sysreg = hsr.sysreg; -uint32_t r =0 ; -bool ret; - -if ( !sysreg.read ) - r =get_user_reg (regs, sysreg.reg); - - ret =fn (regs, &r, sysreg.read); - -if ( ret && sysreg.read ) -set_user_reg (regs, sysreg.reg, r); - -return ret; -} - -static bool vtimer_emulate_sysreg64 (struct cpu_user_regs *regs,union hsr hsr, -vtimer_sysreg64_fn_t fn) -{ -struct hsr_sysreg sysreg = hsr.sysreg; -/* -* Initialize to zero to avoid leaking data if there is an -* implementation error in the emulation (such as not correctly -* setting x). -*/ -uint64_t x =0 ; -bool ret; - -if ( !sysreg.read ) - x =get_user_reg (regs, sysreg.reg); - - ret =fn (regs, &x, sysreg.read); - -if ( ret && sysreg.read ) -set_user_reg (regs, sysreg.reg, x); - -return ret; -} -static bool vtimer_emulate_sysreg (struct cpu_user_regs *regs,union hsr hsr) {struct hsr_sysreg sysreg = hsr.sysreg;@@ -379,11 +334,11 @@ static bool vtimer_emulate_sysreg(struct cpu_user_regs *regs, union hsr hsr)switch ( hsr.bits &HSR_SYSREG_REGS_MASK ) {case HSR_SYSREG_CNTP_CTL_EL0 : -return vtimer_emulate_sysreg32 (regs, hsr, vtimer_cntp_ctl); +return vreg_emulate_sysreg32 (regs, hsr, vtimer_cntp_ctl);case HSR_SYSREG_CNTP_TVAL_EL0 : -return vtimer_emulate_sysreg32 (regs, hsr, vtimer_cntp_tval); +return vreg_emulate_sysreg32 (regs, hsr, vtimer_cntp_tval);case HSR_SYSREG_CNTP_CVAL_EL0 : -return vtimer_emulate_sysreg64 (regs, hsr, vtimer_cntp_cval); +return vreg_emulate_sysreg64 (regs, hsr, vtimer_cntp_cval);default :return false;xen/include/asm-arm/vreg.h new file +56
-0@@ -0,0 +1,56 @@ +/* +* Helpers to emulate co-processor and system registers +*/ +#ifndef __ASM_ARM_VREG__ +#define __ASM_ARM_VREG__ + +#ifdef CONFIG_ARM_64 +typedef bool (*vreg_sysreg32_fn_t )(struct cpu_user_regs *regs,uint32_t *r, +bool read); +typedef bool (*vreg_sysreg64_fn_t )(struct cpu_user_regs *regs,uint64_t *r, +bool read); + +static inline bool vreg_emulate_sysreg32 (struct cpu_user_regs *regs,union hsr hsr, +vreg_sysreg32_fn_t fn) +{ +struct hsr_sysreg sysreg = hsr.sysreg; +uint32_t r =0 ; +bool ret; + +if ( !sysreg.read ) + r =get_user_reg (regs, sysreg.reg); + + ret =fn (regs, &r, sysreg.read); + +if ( ret && sysreg.read ) +set_user_reg (regs, sysreg.reg, r); + +return ret; +} + +static inline bool vreg_emulate_sysreg64 (struct cpu_user_regs *regs,union hsr hsr, +vreg_sysreg64_fn_t fn) +{ +struct hsr_sysreg sysreg = hsr.sysreg; +/* +* Initialize to zero to avoid leaking data if there is an +* implementation error in the emulation (such as not correctly +* setting x). +*/ +uint64_t x =0 ; +bool ret; + +if ( !sysreg.read ) + x =get_user_reg (regs, sysreg.reg); + + ret =fn (regs, &x, sysreg.read); + +if ( ret && sysreg.read ) +set_user_reg (regs, sysreg.reg, x); + +return ret; +} + +#endif + +#endif /* __ASM_ARM_VREG__ */ Signature · 1 line
1.9.1
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 10/13 xen/arm: vreg: Introduce vreg_emulate_cp{32, 64}
In reply to Julien GrallFactorize the code to emulate 32-bit and 64-bit access to a co-processor in specific helpers.
The new helpers will be used in different components to simplify the emulation.
Finally, the prototypes for the callbacks to emulate 32-bit and 64-bit co-processor access are the same as the sysreg one. Rather than introducing new ones, repurpose the existent prototypes.
--- xen/arch/arm/vtimer.c | 37 +++------------------------ xen/include/asm-arm/vreg.h | 64 ++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 62 insertions(+), 39 deletions(-)
xen/arch/arm/vtimer.c +3 -34
@@ -252,49 +252,28 @@ static bool vtimer_cntp_cval(struct cpu_user_regs *regs, uint64_t *r,static bool vtimer_emulate_cp32 (struct cpu_user_regs *regs,union hsr hsr) {struct hsr_cp32 cp32 = hsr.cp32; -/* -* Initialize to zero to avoid leaking data if there is an -* implementation error in the emulation (such as not correctly -* setting r). -*/ -uint32_t r =0 ; -bool res; -if ( cp32.read )perfc_incr (vtimer_cp32_reads);else perfc_incr (vtimer_cp32_writes); -if ( !cp32.read ) - r =get_user_reg (regs, cp32.reg); -switch ( hsr.bits &HSR_CP32_REGS_MASK ) {case HSR_CPREG32 (CNTP_CTL ): - res =vtimer_cntp_ctl (regs, &r, cp32.read); -break ; +return vreg_emulate_cp32 (regs, hsr, vtimer_cntp_ctl);case HSR_CPREG32 (CNTP_TVAL ): - res =vtimer_cntp_tval (regs, &r, cp32.read); -break ; +return vreg_emulate_cp32 (regs, hsr, vtimer_cntp_tval);default :return false; } - -if ( res && cp32.read ) -set_user_reg (regs, cp32.reg, r); - -return res; }static bool vtimer_emulate_cp64 (struct cpu_user_regs *regs,union hsr hsr) {struct hsr_cp64 cp64 = hsr.cp64; -uint32_t r1 =get_user_reg (regs, cp64.reg1); -uint32_t r2 =get_user_reg (regs, cp64.reg2); -uint64_t x = (uint64_t )r1 | ((uint64_t )r2 <<32 );if ( cp64.read )perfc_incr (vtimer_cp64_reads);
@@ -304,21 +283,11 @@ static bool vtimer_emulate_cp64(struct cpu_user_regs *regs, union hsr hsr)switch ( hsr.bits &HSR_CP64_REGS_MASK ) {case HSR_CPREG64 (CNTP_CVAL ): -if ( !vtimer_cntp_cval (regs, &x, cp64.read) ) -return false; -break ; +return vreg_emulate_cp64 (regs, hsr, vtimer_cntp_cval);default :return false; } - -if ( cp64.read ) - { -set_user_reg (regs, cp64.reg1, x &0xffffffff ); -set_user_reg (regs, cp64.reg2, x >>32 ); - } - -return true; }#ifdef CONFIG_ARM_64
xen/include/asm-arm/vreg.h +59 -5
80 lines not on this page · raw message
Signature · 7 lines
1.9.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 10/13] xen/arm: vreg: Introduce vreg_emulate_cp{32, 64}
Quoted 11 lines · Julien Grall
Factorize the code to emulate 32-bit and 64-bit access to a co-processor in specific helpers.
The new helpers will be used in different components to simplify the emulation.
Finally, the prototypes for the callbacks to emulate 32-bit and 64-bit co-processor access are the same as the sysreg one. Rather than introducing new ones, repurpose the existent prototypes.
Signed-off-by Julien Grall <[email protected]>
Quoted 173 lines
--- xen/arch/arm/vtimer.c | 37 +++------------------------ xen/include/asm-arm/vreg.h | 64 ++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 62 insertions(+), 39 deletions(-)xen/arch/arm/vtimer.c +3
-34@@ -252,49 +252,28 @@ static bool vtimer_cntp_cval(struct cpu_user_regs *regs, uint64_t *r,static bool vtimer_emulate_cp32 (struct cpu_user_regs *regs,union hsr hsr) {struct hsr_cp32 cp32 = hsr.cp32; -/* -* Initialize to zero to avoid leaking data if there is an -* implementation error in the emulation (such as not correctly -* setting r). -*/ -uint32_t r =0 ; -bool res; -if ( cp32.read )perfc_incr (vtimer_cp32_reads);else perfc_incr (vtimer_cp32_writes); -if ( !cp32.read ) - r =get_user_reg (regs, cp32.reg); -switch ( hsr.bits &HSR_CP32_REGS_MASK ) {case HSR_CPREG32 (CNTP_CTL ): - res =vtimer_cntp_ctl (regs, &r, cp32.read); -break ; +return vreg_emulate_cp32 (regs, hsr, vtimer_cntp_ctl);case HSR_CPREG32 (CNTP_TVAL ): - res =vtimer_cntp_tval (regs, &r, cp32.read); -break ; +return vreg_emulate_cp32 (regs, hsr, vtimer_cntp_tval);default :return false; } - -if ( res && cp32.read ) -set_user_reg (regs, cp32.reg, r); - -return res; }static bool vtimer_emulate_cp64 (struct cpu_user_regs *regs,union hsr hsr) {struct hsr_cp64 cp64 = hsr.cp64; -uint32_t r1 =get_user_reg (regs, cp64.reg1); -uint32_t r2 =get_user_reg (regs, cp64.reg2); -uint64_t x = (uint64_t )r1 | ((uint64_t )r2 <<32 );if ( cp64.read )perfc_incr (vtimer_cp64_reads);@@ -304,21 +283,11 @@ static bool vtimer_emulate_cp64(struct cpu_user_regs *regs, union hsr hsr)switch ( hsr.bits &HSR_CP64_REGS_MASK ) {case HSR_CPREG64 (CNTP_CVAL ): -if ( !vtimer_cntp_cval (regs, &x, cp64.read) ) -return false; -break ; +return vreg_emulate_cp64 (regs, hsr, vtimer_cntp_cval);default :return false; } - -if ( cp64.read ) - { -set_user_reg (regs, cp64.reg1, x &0xffffffff ); -set_user_reg (regs, cp64.reg2, x >>32 ); - } - -return true; }#ifdef CONFIG_ARM_64 xen/include/asm-arm/vreg.h +59
-5@@ -4,14 +4,68 @@ #ifndef __ASM_ARM_VREG__ #define __ASM_ARM_VREG__ -#ifdef CONFIG_ARM_64 -typedef bool (*vreg_sysreg32_fn_t)(struct cpu_user_regs *regs, uint32_t *r, +typedef bool (*vreg_reg32_fn_t)(struct cpu_user_regs *regs, uint32_t *r, bool read); -typedef bool (*vreg_sysreg64_fn_t)(struct cpu_user_regs *regs, uint64_t *r, +typedef bool (*vreg_reg64_fn_t)(struct cpu_user_regs *regs, uint64_t *r, bool read); +static inline bool vreg_emulate_cp32(struct cpu_user_regs *regs, union hsr hsr, + vreg_reg32_fn_t fn) +{ + struct hsr_cp32 cp32 = hsr.cp32; + /* + * Initialize to zero to avoid leaking data if there is an + * implementation error in the emulation (such as not correctly + * setting r). + */ + uint32_t r = 0; + bool ret; + + if ( !cp32.read ) + r = get_user_reg(regs, cp32.reg); + + ret = fn(regs, &r, cp32.read); + + if ( ret && cp32.read ) + set_user_reg(regs, cp32.reg, r); + + return ret; +} + +static inline bool vreg_emulate_cp64(struct cpu_user_regs *regs, union hsr hsr, + vreg_reg64_fn_t fn) +{ + struct hsr_cp64 cp64 = hsr.cp64; + /* + * Initialize to zero to avoid leaking data if there is an + * implementation error in the emulation (such as not correctly + * setting x). + */ + uint64_t x = 0; + bool ret; + + if ( !cp64.read ) + { + uint32_t r1 = get_user_reg(regs, cp64.reg1); + uint32_t r2 = get_user_reg(regs, cp64.reg2); + + x = (uint64_t)r1 | ((uint64_t)r2 << 32); + } + + ret = fn(regs, &x, cp64.read); + + if ( ret && cp64.read ) + { + set_user_reg(regs, cp64.reg1, x & 0xffffffff); + set_user_reg(regs, cp64.reg2, x >> 32); + } + + return ret; +} + +#ifdef CONFIG_ARM_64 static inline bool vreg_emulate_sysreg32(struct cpu_user_regs *regs, union hsr hsr, - vreg_sysreg32_fn_t fn) + vreg_reg32_fn_t fn) { struct hsr_sysreg sysreg = hsr.sysreg; uint32_t r = 0;@@ -29,7 +83,7 @@ static inline bool vreg_emulate_sysreg32(struct cpu_user_regs *regs, union hsr h }static inline bool vreg_emulate_sysreg64 (struct cpu_user_regs *regs,union hsr hsr, -vreg_sysreg64_fn_t fn) +vreg_reg64_fn_t fn) {struct hsr_sysreg sysreg = hsr.sysreg;/* Signature · 1 line
1.9.1
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 11/13 xen/arm: vgic: Rename emulate_sysreg callback to emulate_reg
In reply to Julien GrallWe will want to emulate co-processor registers access in a follow-up patch.
--- xen/arch/arm/vgic-v3.c | 13 ++++++++++++- xen/arch/arm/vgic.c | 4 ++-- xen/include/asm-arm/vgic.h | 4 ++-- 3 files changed, 16 insertions(+), 5 deletions(-)
xen/arch/arm/vgic-v3.c +12 -1
@@ -1328,6 +1328,17 @@ static bool vgic_v3_emulate_sysreg(struct cpu_user_regs *regs, union hsr hsr) } } +static bool vgic_v3_emulate_reg (struct cpu_user_regs *regs,union hsr hsr) +{ +switch (hsr.ec) + { +case HSR_EC_SYSREG : +return vgic_v3_emulate_sysreg (regs, hsr); +default : +return false; + } +} +static const struct mmio_handler_ops vgic_rdistr_mmio_handler = { .read = vgic_v3_rdistr_mmio_read, .write = vgic_v3_rdistr_mmio_write,
@@ -1491,7 +1502,7 @@ static const struct vgic_ops v3_ops = { .vcpu_init = vgic_v3_vcpu_init, .domain_init = vgic_v3_domain_init, .domain_free = vgic_v3_domain_free, - .emulate_sysreg = vgic_v3_emulate_sysreg, + .emulate_reg = vgic_v3_emulate_reg,/* * We use both AFF1 and AFF0 in (v)MPIDR. Thus, the max number of CPU * that can be supported is up to 4096(==256*16) in theory.
xen/arch/arm/vgic.c +2 -2
@@ -550,9 +550,9 @@ bool vgic_emulate(struct cpu_user_regs *regs, union hsr hsr) {struct vcpu *v = current; -ASSERT (v->domain->arch.vgic.handler->emulate_sysreg !=NULL ); +ASSERT (v->domain->arch.vgic.handler->emulate_reg !=NULL ); -return v->domain->arch.vgic.handler->emulate_sysreg (regs, hsr); +return v->domain->arch.vgic.handler->emulate_reg (regs, hsr); }bool vgic_reserve_virq (struct domain *d,unsigned int virq)
xen/include/asm-arm/vgic.h +2 -2
@@ -130,8 +130,8 @@ struct vgic_ops {int (*domain_init)(struct domain *d);/* Release resources that were allocated by domain_init */ void (*domain_free)(struct domain *d); -/* vGIC sysreg emulation */ -bool (*emulate_sysreg)(struct cpu_user_regs *regs,union hsr hsr); +/* vGIC sysreg/cpregs emulate */ +bool (*emulate_reg)(struct cpu_user_regs *regs,union hsr hsr);/* Maximum number of vCPU supported */ const unsigned int max_vcpus; };
Signature · 7 lines
1.9.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 11/13] xen/arm: vgic: Rename emulate_sysreg callback to emulate_reg
Quoted 4 lines · Julien Grall
We will want to emulate co-processor registers access in a follow-up patch.
Signed-off-by Julien Grall <[email protected]>
Quoted 71 lines
--- xen/arch/arm/vgic-v3.c | 13 ++++++++++++- xen/arch/arm/vgic.c | 4 ++-- xen/include/asm-arm/vgic.h | 4 ++-- 3 files changed, 16 insertions(+), 5 deletions(-)xen/arch/arm/vgic-v3.c +12
-1@@ -1328,6 +1328,17 @@ static bool vgic_v3_emulate_sysreg(struct cpu_user_regs *regs, union hsr hsr) } } +static bool vgic_v3_emulate_reg (struct cpu_user_regs *regs,union hsr hsr) +{ +switch (hsr.ec) + { +case HSR_EC_SYSREG : +return vgic_v3_emulate_sysreg (regs, hsr); +default : +return false; + } +} +static const struct mmio_handler_ops vgic_rdistr_mmio_handler = { .read = vgic_v3_rdistr_mmio_read, .write = vgic_v3_rdistr_mmio_write,@@ -1491,7 +1502,7 @@ static const struct vgic_ops v3_ops = { .vcpu_init = vgic_v3_vcpu_init, .domain_init = vgic_v3_domain_init, .domain_free = vgic_v3_domain_free, - .emulate_sysreg = vgic_v3_emulate_sysreg, + .emulate_reg = vgic_v3_emulate_reg,/* * We use both AFF1 and AFF0 in (v)MPIDR. Thus, the max number of CPU * that can be supported is up to 4096(==256*16) in theory. xen/arch/arm/vgic.c +2
-2@@ -550,9 +550,9 @@ bool vgic_emulate(struct cpu_user_regs *regs, union hsr hsr) {struct vcpu *v = current; -ASSERT (v->domain->arch.vgic.handler->emulate_sysreg !=NULL ); +ASSERT (v->domain->arch.vgic.handler->emulate_reg !=NULL ); -return v->domain->arch.vgic.handler->emulate_sysreg (regs, hsr); +return v->domain->arch.vgic.handler->emulate_reg (regs, hsr); }bool vgic_reserve_virq (struct domain *d,unsigned int virq)xen/include/asm-arm/vgic.h +2
-2@@ -130,8 +130,8 @@ struct vgic_ops {int (*domain_init)(struct domain *d);/* Release resources that were allocated by domain_init */ void (*domain_free)(struct domain *d); -/* vGIC sysreg emulation */ -bool (*emulate_sysreg)(struct cpu_user_regs *regs,union hsr hsr); +/* vGIC sysreg/cpregs emulate */ +bool (*emulate_reg)(struct cpu_user_regs *regs,union hsr hsr);/* Maximum number of vCPU supported */ const unsigned int max_vcpus; };Signature · 1 line
1.9.1
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 12/13 xen/arm: vgic-v3: Move the emulation of ICC_SGI1R_EL1 in a separate helper
In reply to Julien GrallThe emulation of the co-processor register ICC_SGI1R is the same as the system register ICC_SGI1R_EL1. So move the emulation outside and use the newly introduced helper vreg_emulate_sysreg64 to abstract the access.
--- xen/arch/arm/vgic-v3.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-)
xen/arch/arm/vgic-v3.c +16 -9
@@ -31,6 +31,7 @@#include <asm/gic_v3_defs.h> #include <asm/vgic.h> #include <asm/vgic-emul.h> +#include <asm/vreg.h> /* * PIDR2: Only bits[7:4] are not implementation defined. We are
@@ -1300,9 +1301,21 @@ static bool vgic_v3_to_sgi(struct vcpu *v, register_t sgir)return vgic_to_sgi (v, sgir, sgi_mode, virq, &target); } +static bool vgic_v3_emulate_sgi1r (struct cpu_user_regs *regs,uint64_t *r, +bool read) +{ +/* WO */ +if ( !read ) +return vgic_v3_to_sgi (current, *r); +else + { +gdprintk (XENLOG_WARNING ,"Reading SGI1R_EL1 - WO register\n" ); +return false; + } +} +static bool vgic_v3_emulate_sysreg (struct cpu_user_regs *regs,union hsr hsr) { -struct vcpu *v = current;struct hsr_sysreg sysreg = hsr.sysreg;ASSERT (hsr.ec ==HSR_EC_SYSREG );
@@ -1315,14 +1328,8 @@ static bool vgic_v3_emulate_sysreg(struct cpu_user_regs *regs, union hsr hsr)switch ( hsr.bits &HSR_SYSREG_REGS_MASK ) {case HSR_SYSREG_ICC_SGI1R_EL1 : -/* WO */ -if ( !sysreg.read ) -return vgic_v3_to_sgi (v,get_user_reg (regs, sysreg.reg)); -else - { -gprintk (XENLOG_WARNING ,"Reading SGI1R_EL1 - WO register\n" ); -return false; - } +return vreg_emulate_sysreg64 (regs, hsr, vgic_v3_emulate_sgi1r); +default :return false; }
Signature · 7 lines
1.9.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 12/13] xen/arm: vgic-v3: Move the emulation of ICC_SGI1R_EL1 in a separate helper
Quoted 5 lines · Julien Grall
The emulation of the co-processor register
ICC_SGI1Ris the same as the system registerICC_SGI1R_EL1. So move the emulation outside and use the newly introduced helpervreg_emulate_sysreg64to abstract the access.Signed-off-by Julien Grall <[email protected]>
Quoted 59 lines
--- xen/arch/arm/vgic-v3.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-)xen/arch/arm/vgic-v3.c +16
-9@@ -31,6 +31,7 @@#include <asm/gic_v3_defs.h> #include <asm/vgic.h> #include <asm/vgic-emul.h> +#include <asm/vreg.h> /* * PIDR2: Only bits[7:4] are not implementation defined. We are @@ -1300,9 +1301,21 @@ static bool vgic_v3_to_sgi(struct vcpu *v, register_t sgir)return vgic_to_sgi (v, sgir, sgi_mode, virq, &target); } +static bool vgic_v3_emulate_sgi1r (struct cpu_user_regs *regs,uint64_t *r, +bool read) +{ +/* WO */ +if ( !read ) +return vgic_v3_to_sgi (current, *r); +else + { +gdprintk (XENLOG_WARNING ,"Reading SGI1R_EL1 - WO register\n" ); +return false; + } +} +static bool vgic_v3_emulate_sysreg (struct cpu_user_regs *regs,union hsr hsr) { -struct vcpu *v = current;struct hsr_sysreg sysreg = hsr.sysreg;ASSERT (hsr.ec ==HSR_EC_SYSREG );@@ -1315,14 +1328,8 @@ static bool vgic_v3_emulate_sysreg(struct cpu_user_regs *regs, union hsr hsr)switch ( hsr.bits &HSR_SYSREG_REGS_MASK ) {case HSR_SYSREG_ICC_SGI1R_EL1 : -/* WO */ -if ( !sysreg.read ) -return vgic_v3_to_sgi (v,get_user_reg (regs, sysreg.reg)); -else - { -gprintk (XENLOG_WARNING ,"Reading SGI1R_EL1 - WO register\n" ); -return false; - } +return vreg_emulate_sysreg64 (regs, hsr, vgic_v3_emulate_sgi1r); +default :return false; }Signature · 1 line
1.9.1
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 13/13 xen/arm: vgic-v3: Allow AArch32 guest booting with GICv3
In reply to Julien GrallAArch32 guest will use co-processor registers to access the GICv3 (see 8.5 in IHI 0069C). Some of the registers have to be trapped and emulated (e.g ICC_SGI1R), this is the purpose of this patch.
The rest of the emulation already supports access required for AArch32 so nothing has to be changed there.
Note this is only enabling 32-bit guest using GICv3 on Xen ARM64. Further work would be required to compile GICv3 and vGICv3 for Xen ARM32.
--- xen/arch/arm/traps.c | 12 ++++++++++++ xen/arch/arm/vgic-v3.c | 20 ++++++++++++++++++++ xen/include/asm-arm/cpregs.h | 3 +++ xen/include/asm-arm/perfc_defn.h | 2 ++ 4 files changed, 37 insertions(+)
xen/arch/arm/traps.c +12 -0
@@ -1876,6 +1876,18 @@ static void do_cp15_64(struct cpu_user_regs *regs,break ;/* +* HCR_EL2.FMO or HCR_EL2.IMO +* +* GIC Architecture Specification (IHI 0069C): Section 4.6.3 +*/ +case HSR_CPREG64 (ICC_SGI1R ): +case HSR_CPREG64 (ICC_ASGI1R ): +case HSR_CPREG64 (ICC_SGI0R ): +if ( !vgic_emulate (regs, hsr) ) +return inject_undef_exception (regs, hsr); +break ; + +/* * CPTR_EL2.T{0..9,12..13} * * ARMv7 (DDI 0406C.b): B1.14.12
xen/arch/arm/vgic-v3.c +20 -0
@@ -1335,12 +1335,32 @@ static bool vgic_v3_emulate_sysreg(struct cpu_user_regs *regs, union hsr hsr) } } +static bool vgic_v3_emulate_cp64 (struct cpu_user_regs *regs,union hsr hsr) +{ +struct hsr_cp64 cp64 = hsr.cp64; + +if ( cp64.read ) +perfc_incr (vgic_cp64_reads); +else +perfc_incr (vgic_cp64_writes); + +switch ( hsr.bits &HSR_CP64_REGS_MASK ) + { +case HSR_CPREG64 (ICC_SGI1R ): +return vreg_emulate_cp64 (regs, hsr, vgic_v3_emulate_sgi1r); +default : +return false; + } +} +static bool vgic_v3_emulate_reg (struct cpu_user_regs *regs,union hsr hsr) {switch (hsr.ec) {case HSR_EC_SYSREG :return vgic_v3_emulate_sysreg (regs, hsr); +case HSR_EC_CP15_64 : +return vgic_v3_emulate_cp64 (regs, hsr);default :return false; }
xen/include/asm-arm/cpregs.h +3 -0
@@ -246,6 +246,9 @@/* CP15 CR11: DMA Operations for TCM Access */ /* CP15 CR12: */ +#define ICC_SGI1R p15,0,c12/* Interrupt Controller SGI Group 1 */ +#define ICC_ASGI1R p15,1,c12/* Interrupt Controller Alias SGI Group 1 Register */ +#define ICC_SGI0R p15,2,c12/* Interrupt Controller SGI Group 0 */ #define VBAR p15,0,c12,c0,0/* Vector Base Address Register */ #define HVBAR p15,4,c12,c0,0/* Hyp. Vector Base Address Register */
xen/include/asm-arm/perfc_defn.h +2 -0
@@ -38,6 +38,8 @@ PERFCOUNTER(vgicd_reads, "vgicd: read") PERFCOUNTER(vgicd_writes, "vgicd: write") PERFCOUNTER(vgicr_reads, "vgicr: read") PERFCOUNTER(vgicr_writes, "vgicr: write") +PERFCOUNTER(vgic_cp64_reads, "vgic: cp64 read") +PERFCOUNTER(vgic_cp64_writes, "vgic: cp64 write") PERFCOUNTER(vgic_sysreg_reads, "vgic: sysreg read") PERFCOUNTER(vgic_sysreg_writes, "vgic: sysreg write")PERFCOUNTER (vgic_sgi_list ,"vgic: SGI send to list" )
Signature · 7 lines
1.9.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 13/13] xen/arm: vgic-v3: Allow AArch32 guest booting with GICv3
Quoted 11 lines · Julien Grall
AArch32 guest will use co-processor registers to access the GICv3 (see 8.5 in IHI 0069C). Some of the registers have to be trapped and emulated (e.g
ICC_SGI1R), this is the purpose of this patch.The rest of the emulation already supports access required for AArch32 so nothing has to be changed there.
Note this is only enabling 32-bit guest using GICv3 on Xen ARM64. Further work would be required to compile GICv3 and vGICv3 for Xen ARM32.
Signed-off-by Julien Grall <[email protected]>
Quoted 97 lines
--- xen/arch/arm/traps.c | 12 ++++++++++++ xen/arch/arm/vgic-v3.c | 20 ++++++++++++++++++++ xen/include/asm-arm/cpregs.h | 3 +++ xen/include/asm-arm/perfc_defn.h | 2 ++ 4 files changed, 37 insertions(+)xen/arch/arm/traps.c +12
-0@@ -1876,6 +1876,18 @@ static void do_cp15_64(struct cpu_user_regs *regs,break ;/* +* HCR_EL2.FMO or HCR_EL2.IMO +* +* GIC Architecture Specification (IHI 0069C): Section 4.6.3 +*/ +case HSR_CPREG64 (ICC_SGI1R ): +case HSR_CPREG64 (ICC_ASGI1R ): +case HSR_CPREG64 (ICC_SGI0R ): +if ( !vgic_emulate (regs, hsr) ) +return inject_undef_exception (regs, hsr); +break ; + +/* * CPTR_EL2.T{0..9,12..13} * * ARMv7 (DDI 0406C.b): B1.14.12 xen/arch/arm/vgic-v3.c +20
-0@@ -1335,12 +1335,32 @@ static bool vgic_v3_emulate_sysreg(struct cpu_user_regs *regs, union hsr hsr) } } +static bool vgic_v3_emulate_cp64 (struct cpu_user_regs *regs,union hsr hsr) +{ +struct hsr_cp64 cp64 = hsr.cp64; + +if ( cp64.read ) +perfc_incr (vgic_cp64_reads); +else +perfc_incr (vgic_cp64_writes); + +switch ( hsr.bits &HSR_CP64_REGS_MASK ) + { +case HSR_CPREG64 (ICC_SGI1R ): +return vreg_emulate_cp64 (regs, hsr, vgic_v3_emulate_sgi1r); +default : +return false; + } +} +static bool vgic_v3_emulate_reg (struct cpu_user_regs *regs,union hsr hsr) {switch (hsr.ec) {case HSR_EC_SYSREG :return vgic_v3_emulate_sysreg (regs, hsr); +case HSR_EC_CP15_64 : +return vgic_v3_emulate_cp64 (regs, hsr);default :return false; }xen/include/asm-arm/cpregs.h +3
-0@@ -246,6 +246,9 @@/* CP15 CR11: DMA Operations for TCM Access */ /* CP15 CR12: */ +#define ICC_SGI1R p15,0,c12/* Interrupt Controller SGI Group 1 */ +#define ICC_ASGI1R p15,1,c12/* Interrupt Controller Alias SGI Group 1 Register */ +#define ICC_SGI0R p15,2,c12/* Interrupt Controller SGI Group 0 */ #define VBAR p15,0,c12,c0,0/* Vector Base Address Register */ #define HVBAR p15,4,c12,c0,0/* Hyp. Vector Base Address Register */ xen/include/asm-arm/perfc_defn.h +2
-0@@ -38,6 +38,8 @@ PERFCOUNTER(vgicd_reads, "vgicd: read") PERFCOUNTER(vgicd_writes, "vgicd: write") PERFCOUNTER(vgicr_reads, "vgicr: read") PERFCOUNTER(vgicr_writes, "vgicr: write") +PERFCOUNTER(vgic_cp64_reads, "vgic: cp64 read") +PERFCOUNTER(vgic_cp64_writes, "vgic: cp64 write") PERFCOUNTER(vgic_sysreg_reads, "vgic: sysreg read") PERFCOUNTER(vgic_sysreg_writes, "vgic: sysreg write")PERFCOUNTER (vgic_sgi_list ,"vgic: SGI send to list" )Signature · 1 line
1.9.1
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 12 lines · Julien Grall
Hi all,
Currently, it is only possible to start AArch32 guest with GICv2. This means that if the host interrupt controller is not compatible with GICv2, it will not be possible to boot AArch32 guest.
The vGICv3 code is nearly fully compatible with AArch32 guest except that co-processor access to
ICC_SGI1R_EL1is not emulated.The first part (#1 - #11) of the series contains clean-up, only patch #12 and #13 contains the meat.
Quoted 6 lines
Note this is only allowing AArch32 guest to use GICv3 on AArch64 host. This series does not add support for GICv3 on AArch32 host.
A branch with all the patches can be found on xenbits:
git://xenbits.xen.org/people/julieng/xen-unstable.gitbranch gicv3-32bit-v1
Nice and clean series. Only a couple of minor issues, I fixed them as I applied the patches.
Thanks,
Stefano
Quoted 21 lines
Regards,
Julien Grall (13):
xen/arm: vtimer: Switch the emulation functions return from int to
bool
xen/arm: vtimer: Switch the read variable in the emulation from int to
bool
xen/arm: traps: Switch frombool_tto bool
xen/arm: vgic: Switch frombool_tto bool
xen/arm: vgic: Switchvgic_to_sgireturn from int to bool and progateup to...xen/arm: vgic: Switch
emulate_sysregreturn from int to bool xen/arm: vgic: Clean-up the sysreg emulation
xen/arm: vgic-v3: Buildvgic-v3.cwhenCONFIG_HAS_GICV3is enabled. xen/arm: vtimer: Move emulate_sysreg* callback in a separate header xen/arm: vreg: Introduce vreg_emulate_cp{32,64}
xen/arm: vgic: Renameemulate_sysregcallback toemulate_regxen/arm: vgic-v3: Move the emulation ofICC_SGI1R_EL1in a separate
helper
xen/arm: vgic-v3: Allow AArch32 guest booting with GICv3
Quoted 17 lines
xen/arch/arm/Makefile | 2 +- xen/arch/arm/traps.c | 42 +++++++------ xen/arch/arm/vgic-v2.c | 4 +- xen/arch/arm/vgic-v3.c | 64 ++++++++++++++++---- xen/arch/arm/vgic.c | 22 +++---- xen/arch/arm/vtimer.c | 126 ++++++++------------------------------- xen/arch/arm/vtimer.h | 2 +- xen/include/asm-arm/cpregs.h | 3 + xen/include/asm-arm/perfc_defn.h | 2 + xen/include/asm-arm/vgic.h | 20 +++---- xen/include/asm-arm/vreg.h | 110 ++++++++++++++++++++++++++++++++++ 11 files changed, 240 insertions(+), 157 deletions(-) create mode 100644 xen/include/asm-arm/vreg.hSignature · 1 line
1.9.1
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Hi Stefano,
Quoted 16 lines · Stefano Stabellini
Quoted 15 lines · Julien Grall
Hi all,
Currently, it is only possible to start AArch32 guest with GICv2. This means that if the host interrupt controller is not compatible with GICv2, it will not be possible to boot AArch32 guest.
The vGICv3 code is nearly fully compatible with AArch32 guest except that co-processor access to
ICC_SGI1R_EL1is not emulated.The first part (#1 - #11) of the series contains clean-up, only patch #12 and #13 contains the meat.
Note this is only allowing AArch32 guest to use GICv3 on AArch64 host. This series does not add support for GICv3 on AArch32 host.
Quoted 6 lines
Quoted 3 lines
A branch with all the patches can be found on xenbits:
git://xenbits.xen.org/people/julieng/xen-unstable.gitbranch gicv3-32bit-v1Nice and clean series. Only a couple of minor issues, I fixed them as I applied the patches.
Thank you! Good catch for the missing 0 to false change.
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel