[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] [IA64] clean up pal_emul.c compiler warnings



# HG changeset patch
# User awilliam@xxxxxxxxxxx
# Node ID e5c7350b8cbbfd282c06c40af00c048dcfbca378
# Parent  8ad37880564dff8599f2f410f7bd0c54a50a29e2
[IA64] clean up pal_emul.c compiler warnings

This patch cleans up some compiler warnings in pal_emul.c.  The
problem was that a struct ia64_pal_retval was being used to return
the results from emulated PAL calls, but not all of the fields
were being initialized.  Given that fields were not initialized,
I was also thinking that there might be a remote chance of data
leaking between vcpu's -- but I haven't convinced myself that
that could actually happen.

Signed-off-by: Al Stone <ahs3@xxxxxxxxx>
[whitespace and line wrapping cleanup throughout file]
Signed-off-by: Alex Williamson <alex.williamson@xxxxxx>
---
 xen/arch/ia64/vmx/pal_emul.c |  585 +++++++++++++++++++++++--------------------
 1 files changed, 316 insertions(+), 269 deletions(-)

diff -r 8ad37880564d -r e5c7350b8cbb xen/arch/ia64/vmx/pal_emul.c
--- a/xen/arch/ia64/vmx/pal_emul.c      Mon Jul 10 13:12:41 2006 -0600
+++ b/xen/arch/ia64/vmx/pal_emul.c      Mon Jul 10 13:53:17 2006 -0600
@@ -27,17 +27,36 @@
 #include <xen/hypercall.h>
 #include <public/sched.h>
 
+/*
+ * Handy macros to make sure that the PAL return values start out
+ * as something meaningful.
+ */
+#define INIT_PAL_STATUS_UNIMPLEMENTED(x)               \
+       {                                               \
+               x.status = PAL_STATUS_UNIMPLEMENTED;    \
+               x.v0 = 0;                               \
+               x.v1 = 0;                               \
+               x.v2 = 0;                               \
+       }
+
+#define INIT_PAL_STATUS_SUCCESS(x)                     \
+       {                                               \
+               x.status = PAL_STATUS_SUCCESS;          \
+               x.v0 = 0;                               \
+               x.v1 = 0;                               \
+               x.v2 = 0;                               \
+       }
+
 static void
-get_pal_parameters (VCPU *vcpu, UINT64 *gr29,
-                       UINT64 *gr30, UINT64 *gr31) {
-
-       vcpu_get_gr_nat(vcpu,29,gr29);
-       vcpu_get_gr_nat(vcpu,30,gr30); 
-       vcpu_get_gr_nat(vcpu,31,gr31);
+get_pal_parameters(VCPU *vcpu, UINT64 *gr29, UINT64 *gr30, UINT64 *gr31) {
+
+       vcpu_get_gr_nat(vcpu,29,gr29);
+       vcpu_get_gr_nat(vcpu,30,gr30); 
+       vcpu_get_gr_nat(vcpu,31,gr31);
 }
 
 static void
-set_pal_result (VCPU *vcpu,struct ia64_pal_retval result) {
+set_pal_result(VCPU *vcpu,struct ia64_pal_retval result) {
 
        vcpu_set_gr(vcpu,8, result.status,0);
        vcpu_set_gr(vcpu,9, result.v0,0);
@@ -46,58 +65,60 @@ set_pal_result (VCPU *vcpu,struct ia64_p
 }
 
 static void
-set_sal_result (VCPU *vcpu,struct sal_ret_values result) {
+set_sal_result(VCPU *vcpu,struct sal_ret_values result) {
 
        vcpu_set_gr(vcpu,8, result.r8,0);
        vcpu_set_gr(vcpu,9, result.r9,0);
        vcpu_set_gr(vcpu,10, result.r10,0);
        vcpu_set_gr(vcpu,11, result.r11,0);
 }
-static struct ia64_pal_retval
-pal_cache_flush (VCPU *vcpu) {
+
+static struct ia64_pal_retval
+pal_cache_flush(VCPU *vcpu) {
        UINT64 gr28,gr29, gr30, gr31;
        struct ia64_pal_retval result;
 
-       get_pal_parameters (vcpu, &gr29, &gr30, &gr31);
-       vcpu_get_gr_nat(vcpu,28,&gr28);
+       get_pal_parameters(vcpu, &gr29, &gr30, &gr31);
+       vcpu_get_gr_nat(vcpu, 28, &gr28);
 
        /* Always call Host Pal in int=1 */
-       gr30 = gr30 &(~(0x2UL));
-
-       /* call Host PAL cache flush */
-       result=ia64_pal_call_static(gr28 ,gr29, gr30,gr31,1);  // Clear psr.ic 
when call PAL_CACHE_FLUSH
+       gr30 = gr30 & ~0x2UL;
+
+       /*
+        * Call Host PAL cache flush
+        * Clear psr.ic when call PAL_CACHE_FLUSH
+        */
+       result = ia64_pal_call_static(gr28 ,gr29, gr30, gr31, 1);
 
        /* If host PAL call is interrupted, then loop to complete it */
-//     while (result.status == 1) {
-//             ia64_pal_call_static(gr28 ,gr29, gr30, 
-//                             result.v1,1LL);
-//     }
-       if(result.status != 0) {
-               panic_domain(vcpu_regs(vcpu),"PAL_CACHE_FLUSH ERROR, status 
%ld", result.status);
-       }
-
-       return result;
-}
-
-static struct ia64_pal_retval
-pal_vm_tr_read (VCPU *vcpu ) {
-       struct ia64_pal_retval result;
-
-       result.status= -1; //unimplemented
-
-       return result;
-}
-
-
-static struct ia64_pal_retval
-pal_prefetch_visibility (VCPU *vcpu)  {
+//     while (result.status == 1)
+//             ia64_pal_call_static(gr28 ,gr29, gr30, result.v1, 1LL);
+//
+       if (result.status != 0)
+               panic_domain(vcpu_regs(vcpu), "PAL_CACHE_FLUSH ERROR, "
+                            "status %ld", result.status);
+
+       return result;
+}
+
+static struct ia64_pal_retval
+pal_vm_tr_read(VCPU *vcpu) {
+       struct ia64_pal_retval result;
+
+       INIT_PAL_STATUS_UNIMPLEMENTED(result);
+
+       return result;
+}
+
+static struct ia64_pal_retval
+pal_prefetch_visibility(VCPU *vcpu) {
        /* Due to current MM virtualization algorithm,
         * We do not allow guest to change mapping attribute.
         * Thus we will not support PAL_PREFETCH_VISIBILITY
         */
        struct ia64_pal_retval result;
 
-       result.status= -1; //unimplemented
+       INIT_PAL_STATUS_UNIMPLEMENTED(result);
 
        return result;
 }
@@ -106,290 +127,315 @@ pal_platform_addr(VCPU *vcpu) {
 pal_platform_addr(VCPU *vcpu) {
        struct ia64_pal_retval result;
 
-       result.status= 0; //success
-
-       return result;
-}
-
-static struct ia64_pal_retval
-pal_halt (VCPU *vcpu) {
+       INIT_PAL_STATUS_SUCCESS(result);
+
+       return result;
+}
+
+static struct ia64_pal_retval
+pal_halt(VCPU *vcpu) {
        //bugbug: to be implement. 
        struct ia64_pal_retval result;
 
-       result.status= -1; //unimplemented
-
-       return result;
-}
-
-
-static struct ia64_pal_retval
-pal_halt_light (VCPU *vcpu) {
+       INIT_PAL_STATUS_UNIMPLEMENTED(result);
+
+       return result;
+}
+
+static struct ia64_pal_retval
+pal_halt_light(VCPU *vcpu) {
        struct ia64_pal_retval result;
        
-       if(SPURIOUS_VECTOR==vmx_check_pending_irq(vcpu))
-               do_sched_op_compat(SCHEDOP_block,0);
+       if (SPURIOUS_VECTOR == vmx_check_pending_irq(vcpu))
+               do_sched_op_compat(SCHEDOP_block, 0);
            
-       result.status= 0;
-       return result;
-}
-
-static struct ia64_pal_retval
-pal_cache_read (VCPU *vcpu) {
-       struct ia64_pal_retval result;
-
-       result.status= -1; //unimplemented
-
-       return result;
-}
-
-static struct ia64_pal_retval
-pal_cache_write (VCPU *vcpu) {
-       struct ia64_pal_retval result;
-
-       result.status= -1; //unimplemented
-
-       return result;
-}
-
-static struct ia64_pal_retval
-pal_bus_get_features(VCPU *vcpu){
-       struct ia64_pal_retval result;
-
-       result.status= -1; //unimplemented
-       return result;
-}
-
-static struct ia64_pal_retval
-pal_cache_summary(VCPU *vcpu){
-       struct ia64_pal_retval result;
-
-       result.status= -1; //unimplemented
-       return result;
-}
-
-static struct ia64_pal_retval
-pal_cache_init(VCPU *vcpu){
-       struct ia64_pal_retval result;
-       result.status=0;
-       return result;
-}
-
-static struct ia64_pal_retval
-pal_cache_info(VCPU *vcpu){
-       struct ia64_pal_retval result;
-
-       result.status= -1; //unimplemented
-       return result;
-}
-
-static struct ia64_pal_retval
-pal_cache_prot_info(VCPU *vcpu){
-       struct ia64_pal_retval result;
-
-       result.status= -1; //unimplemented
-       return result;
-}
-
-static struct ia64_pal_retval
-pal_mem_attrib(VCPU *vcpu){
-       struct ia64_pal_retval result;
-
-       result.status= -1; //unimplemented
-       return result;
-}
-
-static struct ia64_pal_retval
-pal_debug_info(VCPU *vcpu){
-       struct ia64_pal_retval result;
-
-       result.status= -1; //unimplemented
-       return result;
-}
-
-static struct ia64_pal_retval
-pal_fixed_addr(VCPU *vcpu){
-       struct ia64_pal_retval result;
-
-       result.status= -1; //unimplemented
-       return result;
-}
-
-static struct ia64_pal_retval
-pal_freq_base(VCPU *vcpu){
-    struct ia64_pal_retval result;
-    struct ia64_sal_retval isrv;
-
-    PAL_CALL(result,PAL_FREQ_BASE, 0, 0, 0);
-    if(result.v0 == 0){ //PAL_FREQ_BASE may not be implemented in some 
platforms, call SAL instead.
-        SAL_CALL(isrv, SAL_FREQ_BASE, 
-                SAL_FREQ_BASE_PLATFORM, 0, 0, 0, 0, 0, 0);
-        result.status = isrv.status;
-        result.v0 = isrv.v0;
-        result.v1 = result.v2 =0;
-    }
-    return result;
-}
-
-static struct ia64_pal_retval
-pal_freq_ratios(VCPU *vcpu){
-    struct ia64_pal_retval result;
-
-    PAL_CALL(result,PAL_FREQ_RATIOS, 0, 0, 0);
-    return result;
-}
-
-static struct ia64_pal_retval
-pal_halt_info(VCPU *vcpu){
-       struct ia64_pal_retval result;
-
-       result.status= -1; //unimplemented
-       return result;
-}
-
-static struct ia64_pal_retval
-pal_logical_to_physica(VCPU *vcpu){
-       struct ia64_pal_retval result;
-
-       result.status= -1; //unimplemented
-       return result;
-}
-
-static struct ia64_pal_retval
-pal_perf_mon_info(VCPU *vcpu){
-       struct ia64_pal_retval result;
-
-       result.status= -1; //unimplemented
-       return result;
-}
-
-static struct ia64_pal_retval
-pal_proc_get_features(VCPU *vcpu){
-       struct ia64_pal_retval result;
-
-       result.status= -1; //unimplemented
-       return result;
-}
-
-static struct ia64_pal_retval
-pal_ptce_info(VCPU *vcpu){
-       struct ia64_pal_retval result;
-
-       result.status= -1; //unimplemented
-       return result;
-}
-
-static struct ia64_pal_retval
-pal_register_info(VCPU *vcpu){
-       struct ia64_pal_retval result;
-
-       result.status= -1; //unimplemented
-       return result;
-}
-
-static struct ia64_pal_retval
-pal_rse_info(VCPU *vcpu){
-       struct ia64_pal_retval result;
-
-       result.status= -1; //unimplemented
-       return result;
-}
-static struct ia64_pal_retval
-pal_test_info(VCPU *vcpu){
-       struct ia64_pal_retval result;
-
-       result.status= -1; //unimplemented
-       return result;
-}
-
-static struct ia64_pal_retval
-pal_vm_summary(VCPU *vcpu){
+       INIT_PAL_STATUS_SUCCESS(result);
+
+       return result;
+}
+
+static struct ia64_pal_retval
+pal_cache_read(VCPU *vcpu) {
+       struct ia64_pal_retval result;
+
+       INIT_PAL_STATUS_UNIMPLEMENTED(result);
+
+       return result;
+}
+
+static struct ia64_pal_retval
+pal_cache_write(VCPU *vcpu) {
+       struct ia64_pal_retval result;
+
+       INIT_PAL_STATUS_UNIMPLEMENTED(result);
+
+       return result;
+}
+
+static struct ia64_pal_retval
+pal_bus_get_features(VCPU *vcpu) {
+       struct ia64_pal_retval result;
+
+       INIT_PAL_STATUS_UNIMPLEMENTED(result);
+
+       return result;
+}
+
+static struct ia64_pal_retval
+pal_cache_summary(VCPU *vcpu) {
+       struct ia64_pal_retval result;
+
+       INIT_PAL_STATUS_UNIMPLEMENTED(result);
+
+       return result;
+}
+
+static struct ia64_pal_retval
+pal_cache_init(VCPU *vcpu) {
+       struct ia64_pal_retval result;
+
+       INIT_PAL_STATUS_SUCCESS(result);
+
+       return result;
+}
+
+static struct ia64_pal_retval
+pal_cache_info(VCPU *vcpu) {
+       struct ia64_pal_retval result;
+
+       INIT_PAL_STATUS_UNIMPLEMENTED(result);
+
+       return result;
+}
+
+static struct ia64_pal_retval
+pal_cache_prot_info(VCPU *vcpu) {
+       struct ia64_pal_retval result;
+
+       INIT_PAL_STATUS_UNIMPLEMENTED(result);
+
+       return result;
+}
+
+static struct ia64_pal_retval
+pal_mem_attrib(VCPU *vcpu) {
+       struct ia64_pal_retval result;
+
+       INIT_PAL_STATUS_UNIMPLEMENTED(result);
+
+       return result;
+}
+
+static struct ia64_pal_retval
+pal_debug_info(VCPU *vcpu) {
+       struct ia64_pal_retval result;
+
+       INIT_PAL_STATUS_UNIMPLEMENTED(result);
+
+       return result;
+}
+
+static struct ia64_pal_retval
+pal_fixed_addr(VCPU *vcpu) {
+       struct ia64_pal_retval result;
+
+       INIT_PAL_STATUS_UNIMPLEMENTED(result);
+
+       return result;
+}
+
+static struct ia64_pal_retval
+pal_freq_base(VCPU *vcpu) {
+       struct ia64_pal_retval result;
+       struct ia64_sal_retval isrv;
+
+       PAL_CALL(result,PAL_FREQ_BASE, 0, 0, 0);
+       /*
+        * PAL_FREQ_BASE may not be implemented in some platforms,
+        * call SAL instead.
+        */
+       if (result.v0 == 0) {
+               SAL_CALL(isrv, SAL_FREQ_BASE, 
+                        SAL_FREQ_BASE_PLATFORM, 0, 0, 0, 0, 0, 0);
+               result.status = isrv.status;
+               result.v0 = isrv.v0;
+               result.v1 = result.v2 = 0;
+       }
+       return result;
+}
+
+static struct ia64_pal_retval
+pal_freq_ratios(VCPU *vcpu) {
+       struct ia64_pal_retval result;
+
+       PAL_CALL(result, PAL_FREQ_RATIOS, 0, 0, 0);
+       return result;
+}
+
+static struct ia64_pal_retval
+pal_halt_info(VCPU *vcpu) {
+       struct ia64_pal_retval result;
+
+       INIT_PAL_STATUS_UNIMPLEMENTED(result);
+
+       return result;
+}
+
+static struct ia64_pal_retval
+pal_logical_to_physica(VCPU *vcpu) {
+       struct ia64_pal_retval result;
+
+       INIT_PAL_STATUS_UNIMPLEMENTED(result);
+
+       return result;
+}
+
+static struct ia64_pal_retval
+pal_perf_mon_info(VCPU *vcpu) {
+       struct ia64_pal_retval result;
+
+       INIT_PAL_STATUS_UNIMPLEMENTED(result);
+
+       return result;
+}
+
+static struct ia64_pal_retval
+pal_proc_get_features(VCPU *vcpu) {
+       struct ia64_pal_retval result;
+
+       INIT_PAL_STATUS_UNIMPLEMENTED(result);
+
+       return result;
+}
+
+static struct ia64_pal_retval
+pal_ptce_info(VCPU *vcpu) {
+       struct ia64_pal_retval result;
+
+       INIT_PAL_STATUS_UNIMPLEMENTED(result);
+
+       return result;
+}
+
+static struct ia64_pal_retval
+pal_register_info(VCPU *vcpu) {
+       struct ia64_pal_retval result;
+
+       INIT_PAL_STATUS_UNIMPLEMENTED(result);
+
+       return result;
+}
+
+static struct ia64_pal_retval
+pal_rse_info(VCPU *vcpu) {
+       struct ia64_pal_retval result;
+
+       INIT_PAL_STATUS_UNIMPLEMENTED(result);
+
+       return result;
+}
+
+static struct ia64_pal_retval
+pal_test_info(VCPU *vcpu) {
+       struct ia64_pal_retval result;
+
+       INIT_PAL_STATUS_UNIMPLEMENTED(result);
+
+       return result;
+}
+
+static struct ia64_pal_retval
+pal_vm_summary(VCPU *vcpu) {
        pal_vm_info_1_u_t vminfo1;
        pal_vm_info_2_u_t vminfo2;      
        struct ia64_pal_retval result;
        
-       PAL_CALL(result,PAL_VM_SUMMARY,0,0,0);
-       if(!result.status){
+       PAL_CALL(result, PAL_VM_SUMMARY, 0, 0, 0);
+       if (!result.status) {
                vminfo1.pvi1_val = result.v0;
                vminfo1.pal_vm_info_1_s.max_itr_entry = NITRS -1;
                vminfo1.pal_vm_info_1_s.max_dtr_entry = NDTRS -1;
                result.v0 = vminfo1.pvi1_val;
                vminfo2.pal_vm_info_2_s.impl_va_msb = GUEST_IMPL_VA_MSB;
-               vminfo2.pal_vm_info_2_s.rid_size = 
current->domain->arch.rid_bits;
+               vminfo2.pal_vm_info_2_s.rid_size =
+                                            current->domain->arch.rid_bits;
                result.v1 = vminfo2.pvi2_val;
        } 
        return result;
 }
 
 static struct ia64_pal_retval
-pal_vm_info(VCPU *vcpu){
-       struct ia64_pal_retval result;
-
-       result.status= -1; //unimplemented
-       return result;
-}
-
-static struct ia64_pal_retval
-pal_vm_page_size(VCPU *vcpu){
-       struct ia64_pal_retval result;
-
-       result.status= -1; //unimplemented
-       return result;
-}
+pal_vm_info(VCPU *vcpu) {
+       struct ia64_pal_retval result;
+
+       INIT_PAL_STATUS_UNIMPLEMENTED(result);
+
+       return result;
+}
+
+static struct ia64_pal_retval
+pal_vm_page_size(VCPU *vcpu) {
+       struct ia64_pal_retval result;
+
+       INIT_PAL_STATUS_UNIMPLEMENTED(result);
+
+       return result;
+}
+
 void
-pal_emul( VCPU *vcpu) {
+pal_emul(VCPU *vcpu) {
        UINT64 gr28;
        struct ia64_pal_retval result;
-
 
        vcpu_get_gr_nat(vcpu,28,&gr28);  //bank1
 
        switch (gr28) {
                case PAL_CACHE_FLUSH:
-                       result = pal_cache_flush (vcpu);
+                       result = pal_cache_flush(vcpu);
                        break;
 
                case PAL_PREFETCH_VISIBILITY:
-                       result = pal_prefetch_visibility (vcpu);
+                       result = pal_prefetch_visibility(vcpu);
                        break;
 
                case PAL_VM_TR_READ:
-                       result = pal_vm_tr_read (vcpu);
+                       result = pal_vm_tr_read(vcpu);
                        break;
 
                case PAL_HALT:
-                       result = pal_halt (vcpu);
+                       result = pal_halt(vcpu);
                        break;
 
                case PAL_HALT_LIGHT:
-                       result = pal_halt_light (vcpu);
+                       result = pal_halt_light(vcpu);
                        break;
 
                case PAL_CACHE_READ:
-                       result = pal_cache_read (vcpu);
+                       result = pal_cache_read(vcpu);
                        break;
 
                case PAL_CACHE_WRITE:
-                       result = pal_cache_write (vcpu);
+                       result = pal_cache_write(vcpu);
                        break;
 
                case PAL_PLATFORM_ADDR:
-                       result = pal_platform_addr (vcpu);
+                       result = pal_platform_addr(vcpu);
                        break;
 
                case PAL_FREQ_RATIOS:
-                       result = pal_freq_ratios (vcpu);
+                       result = pal_freq_ratios(vcpu);
                        break;
 
                case PAL_FREQ_BASE:
-                       result = pal_freq_base (vcpu);
+                       result = pal_freq_base(vcpu);
                        break;
 
                case PAL_BUS_GET_FEATURES :
-                       result = pal_bus_get_features (vcpu);
+                       result = pal_bus_get_features(vcpu);
                        break;
 
                case PAL_CACHE_SUMMARY :
-                       result = pal_cache_summary (vcpu);
+                       result = pal_cache_summary(vcpu);
                        break;
 
                case PAL_CACHE_INIT :
@@ -461,17 +507,18 @@ pal_emul( VCPU *vcpu) {
                        break;
 
                default:
-                       panic_domain(vcpu_regs(vcpu),"pal_emul(): guest call 
unsupported pal" );
-  }
-               set_pal_result (vcpu, result);
+                       panic_domain(vcpu_regs(vcpu),"pal_emul(): guest "
+                                    "call unsupported pal" );
+       }
+       set_pal_result(vcpu, result);
 }
 
 void
 sal_emul(VCPU *v) {
        struct sal_ret_values result;
-       result = sal_emulator(vcpu_get_gr(v,32),vcpu_get_gr(v,33),
-                             vcpu_get_gr(v,34),vcpu_get_gr(v,35),
-                             vcpu_get_gr(v,36),vcpu_get_gr(v,37),
-                             vcpu_get_gr(v,38),vcpu_get_gr(v,39));
+       result = sal_emulator(vcpu_get_gr(v, 32), vcpu_get_gr(v, 33),
+                             vcpu_get_gr(v, 34), vcpu_get_gr(v, 35),
+                             vcpu_get_gr(v, 36), vcpu_get_gr(v, 37),
+                             vcpu_get_gr(v, 38), vcpu_get_gr(v, 39));
        set_sal_result(v, result);      
 }

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.