From: "Jan Beulich" Subject: Re: [PATCH V5] ns16550: Add support for UART present in Broadcom TruManage capable NetXtreme chips Date: Fri, 22 Nov 2013 16:59:21 +0000 Message-ID: <528F9B79020000780010608A@nat28.tlf.novell.com> References: <1385138709-2029-1-git-send-email-Aravind.Gopalakrishnan@amd.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1385138709-2029-1-git-send-email-Aravind.Gopalakrishnan@amd.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Aravind Gopalakrishnan , xen-devel@lists.xen.org Cc: Thomas Lendacky , andrew.cooper3@citrix.com, shurd@broadcom.com, Suravee Suthikulpanit , sherry.hurwitz@amd.com List-Id: xen-devel@lists.xenproject.org >>> On 22.11.13 at 17:45, Aravind Gopalakrishnan wrote: > @@ -432,9 +474,20 @@ static void __init ns16550_endboot(struct serial_port *port) > { > #ifdef HAS_IOPORTS > struct ns16550 *uart = port->uart; > + unsigned long sfn, efn; > > if ( uart->remapped_io_base ) > + { > + sfn = PFN_UP((unsigned long) uart->io_base + (0x8 * (1 << uart->reg_shift))); > + efn = PFN_DOWN((unsigned long) uart->io_base + uart->io_size - 1); So I told you on the previous round that these casts are wrong. Why did you keep them. Also, I don't see why you adjust io_base above - you want to cover the full BAR, no matter what the register shift. > + if ( sfn > efn ) > + BUG(); Ehm - what? Without taking the specifics of BARs into account, this can validly happen (which is why I commented on it on the previous version). But now that I remembered that the value comes from a BAR, it can't happen, and hence you either don't check it at all, or ASSERT() rather than BUG(). > + else > + size = len & PCI_BASE_ADDRESS_MEM_MASK; > + > + size &= -(size); Stray parentheses. > + /* > + * Force length of mmio region to be at least > + * 8 bytes times (1 << reg_shift) > + */ > + if ( size < (0x8 * (1 << uart_config[i].reg_shift)) ) if ( size < (8 << uart_config[i].reg_shift) ) Jan