]> xenbits.xensource.com Git - people/royger/xen.git/commitdiff
xen: Don't cast away const-ness in vcpu_show_registers()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 30 Dec 2024 06:41:46 +0000 (06:41 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 4 Mar 2025 19:46:41 +0000 (19:46 +0000)
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@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
xen/arch/arm/include/asm/domain.h
xen/arch/arm/traps.c
xen/arch/x86/include/asm/domain.h
xen/arch/x86/x86_64/traps.c

index f1d72c6e48dfeba347b4cd091ca33603c368b7c0..50b6a4b009820f1cf90c0ea674fdd50a486add1b 100644 (file)
@@ -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);
 
 /*
index 3071c38768cbe86fad5817500ea709cba3f38d5a..445e7378dd791b165156e84a11d77b3a38b9f147 100644 (file)
@@ -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;
index b79d6badd71c4d96279555df62fad75fe817a2b6..5fc1d1e5d01a0da2733f5e03f7ac122eee0d1349 100644 (file)
@@ -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)
 {
index 02fdb3637d09b5f2cbda7670c090a63eb1275f83..22d4db240b957ea1d8c6c3e70c5a6d8b91a0401d 100644 (file)
@@ -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;
     }