From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753212AbcFFOei (ORCPT ); Mon, 6 Jun 2016 10:34:38 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:20713 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752534AbcFFOaI (ORCPT ); Mon, 6 Jun 2016 10:30:08 -0400 Subject: Re: [PATCH 1/2] xen-pciback: return proper values during BAR sizing To: Jan Beulich References: <57554B8D02000078000F1DE4@prv-mh.provo.novell.com> <57554C5D02000078000F1DF1@prv-mh.provo.novell.com> <5755748D.6050900@oracle.com> <57559C1D02000078000F20DF@prv-mh.provo.novell.com> Cc: David Vrabel , xen-devel , Konrad Rzeszutek Wilk , Juergen Gross , linux-kernel@vger.kernel.org From: Boris Ostrovsky Message-ID: <575588A6.8070205@oracle.com> Date: Mon, 6 Jun 2016 10:28:54 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <57559C1D02000078000F20DF@prv-mh.provo.novell.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Source-IP: userv0022.oracle.com [156.151.31.74] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/06/2016 09:51 AM, Jan Beulich wrote: >>>> On 06.06.16 at 15:03, wrote: >> On 06/06/2016 04:11 AM, Jan Beulich wrote: >>> @@ -225,38 +225,42 @@ static inline void read_dev_bar(struct p >>> (PCI_BASE_ADDRESS_SPACE_MEMORY | >>> PCI_BASE_ADDRESS_MEM_TYPE_64))) { >>> bar_info->val = res[pos - 1].start >> 32; >>> - bar_info->len_val = res[pos - 1].end >> 32; >>> + bar_info->len_val = -resource_size(&res[pos - 1]) >> 32; >>> return; >>> } >>> } >>> >>> + if (!res[pos].flags || >>> + (res[pos].flags & (IORESOURCE_DISABLED | IORESOURCE_UNSET | >>> + IORESOURCE_BUSY))) >>> + return; >> Why are you not making this check first thing in the routine? > For one, pos isn't set there yet. And I'd also rather avoid the > complications resulting from 64-bit memory resources spanning > two entries. I thought that both words of a 64-bit BAR would result in a return under this check so both would be zero. But yes, pos needs to be initialized anyway (I didn't see this in the diff). Reviewed-by: Boris Ostrovsky