[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen master] xen: Don't cast away const-ness in vcpu_show_registers()
commit c3923b9f30ab5715fa28d922546586875d95ebde Author: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> AuthorDate: Mon Dec 30 06:41:46 2024 +0000 Commit: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> CommitDate: Tue Mar 4 19:46:41 2025 +0000 xen: Don't cast away const-ness in vcpu_show_registers() The final hunk is `(struct vcpu *)v` in disguise, expressed using a runtime pointer chase through memory and a technicality of the C type system to work around the fact that get_hvm_registers() strictly requires a mutable pointer. For anyone interested, this is one reason why C cannot optimise any reads across sequence points, even for a function purporting to take a const object. Anyway, have the function correctly state that it needs a mutable vcpu. All callers have a mutable vCPU to hand, and it removes the runtime pointer chase in x86. Make one style adjustment in ARM while adjusting the parameter type. Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Acked-by: Jan Beulich <jbeulich@xxxxxxxx> Reviewed-by: Stefano Stabellini <sstabellini@xxxxxxxxxx> --- xen/arch/arm/include/asm/domain.h | 2 +- xen/arch/arm/traps.c | 3 ++- xen/arch/x86/include/asm/domain.h | 2 +- xen/arch/x86/x86_64/traps.c | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/xen/arch/arm/include/asm/domain.h b/xen/arch/arm/include/asm/domain.h index f1d72c6e48..50b6a4b009 100644 --- a/xen/arch/arm/include/asm/domain.h +++ b/xen/arch/arm/include/asm/domain.h @@ -243,7 +243,7 @@ struct arch_vcpu } __cacheline_aligned; -void vcpu_show_registers(const struct vcpu *v); +void vcpu_show_registers(struct vcpu *v); void vcpu_switch_to_aarch64_mode(struct vcpu *v); /* diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 3071c38768..445e7378dd 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -964,9 +964,10 @@ void show_registers(const struct cpu_user_regs *regs) _show_registers(regs, &ctxt, guest_mode(regs), current); } -void vcpu_show_registers(const struct vcpu *v) +void vcpu_show_registers(struct vcpu *v) { struct reg_ctxt ctxt; + ctxt.sctlr_el1 = v->arch.sctlr; ctxt.tcr_el1 = v->arch.ttbcr; ctxt.ttbr0_el1 = v->arch.ttbr0; diff --git a/xen/arch/x86/include/asm/domain.h b/xen/arch/x86/include/asm/domain.h index b79d6badd7..5fc1d1e5d0 100644 --- a/xen/arch/x86/include/asm/domain.h +++ b/xen/arch/x86/include/asm/domain.h @@ -688,7 +688,7 @@ bool update_secondary_system_time(struct vcpu *v, void force_update_secondary_system_time(struct vcpu *v, struct vcpu_time_info *map); -void vcpu_show_registers(const struct vcpu *v); +void vcpu_show_registers(struct vcpu *v); static inline struct vcpu_guest_context *alloc_vcpu_guest_context(void) { diff --git a/xen/arch/x86/x86_64/traps.c b/xen/arch/x86/x86_64/traps.c index 02fdb3637d..22d4db240b 100644 --- a/xen/arch/x86/x86_64/traps.c +++ b/xen/arch/x86/x86_64/traps.c @@ -170,7 +170,7 @@ void show_registers(const struct cpu_user_regs *regs) } } -void vcpu_show_registers(const struct vcpu *v) +void vcpu_show_registers(struct vcpu *v) { const struct cpu_user_regs *regs = &v->arch.user_regs; struct cpu_user_regs aux_regs; @@ -180,7 +180,7 @@ void vcpu_show_registers(const struct vcpu *v) if ( is_hvm_vcpu(v) ) { aux_regs = *regs; - get_hvm_registers(v->domain->vcpu[v->vcpu_id], &aux_regs, crs); + get_hvm_registers(v, &aux_regs, crs); regs = &aux_regs; context = CTXT_hvm_guest; } -- generated by git-patchbot for /home/xen/git/xen.git#master
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |