From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH] Initialize ioreq_t in hvmemul_do_io() Date: Thu, 22 May 2014 14:47:01 +0100 Message-ID: <537DFFD5.4060908@citrix.com> References: <1400762912-45932-1-git-send-email-paul.durrant@citrix.com> <537E144F0200007800014FAE@mail.emea.novell.com> <9AAE0902D5BC7E449B7C8E4E778ABCD0382539@AMSPEX01CL01.citrite.net> <537E175C0200007800014FD5@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <537E175C0200007800014FD5@mail.emea.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich Cc: Paul Durrant , "Keir (Xen.org)" , "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org On 22/05/14 14:27, Jan Beulich wrote: >>>> On 22.05.14 at 15:20, wrote: >>> -----Original Message----- >>> From: Jan Beulich [mailto:JBeulich@suse.com] >>> Sent: 22 May 2014 14:14 >>> To: Andrew Cooper; Paul Durrant >>> Cc: xen-devel@lists.xen.org; Keir (Xen.org) >>> Subject: Re: [PATCH] Initialize ioreq_t in hvmemul_do_io() >>> >>>>>> On 22.05.14 at 14:48, wrote: >>>> All relevant fields of the ioreq_t are properly initialized but coverity >>>> complains about vp_eport being uninitialized (ID 1215178) because it is >>>> the subject of a struct copy in hvm_send_assist_req(). >>>> >>>> Signed-off-by: Paul Durrant >>>> Cc: Keir Fraser >>>> Cc: Jan Beulich >>>> Cc: Andrew Cooper >>>> --- >>>> xen/arch/x86/hvm/emulate.c | 2 +- >>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>> >>>> diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c >>>> index 904c71a..e516194 100644 >>>> --- a/xen/arch/x86/hvm/emulate.c >>>> +++ b/xen/arch/x86/hvm/emulate.c >>>> @@ -57,7 +57,7 @@ static int hvmemul_do_io( >>>> int value_is_ptr = (p_data == NULL); >>>> struct vcpu *curr = current; >>>> struct hvm_vcpu_io *vio; >>>> - ioreq_t p; >>>> + ioreq_t p = { 0 }; >>> To be honest, I dislike fixes like this to address tool shortcomings. It's >>> not like this is giaramteed to be just a single instruction that gets >>> added (maybe the compiler can figure this, but I would want to rely >>> on it. >>> >> I could always change hvm_send_assist_req() to only copy the relevant fields >> from the proto structure, as it used to in earlier versions of my patch. > But the structure copy is certainly more efficient than the piece-wise > copying. > > Jan > When interpreting the coverity results, I accidentally missed the second occurrence of this issue. It is possible to "goto finished_access" and have p.addr and p.dir uninitialised when tracing the IO. By far the safest option is just initialise the entire structure to 0. ~Andrew