Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1599017rwb; Fri, 12 Aug 2022 03:54:47 -0700 (PDT) X-Google-Smtp-Source: AA6agR6mXda6xAjuqAeGHN6kdSeokjljW0a1SOPCW8uzrBfvDX5Kpb5hlUlfUI/uoG/8eYuj0JF/ X-Received: by 2002:a17:906:6a28:b0:731:48a0:71d with SMTP id qw40-20020a1709066a2800b0073148a0071dmr2254911ejc.249.1660301687226; Fri, 12 Aug 2022 03:54:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660301687; cv=none; d=google.com; s=arc-20160816; b=ptRIu3uGvdNoCN/EI1W8+mWO4AxT1Z7CRFp/3v6u3XTYQbVQRczY7PKaygoGibVdkN 77RNeaccNvuOiQfki9Fm8Sq1eCM8Ex8O4Rnjr3hC+AmEanE1DlrTdnPWw7unI4xN7oRx XVJZxypgIN35cNOGfsrsEDlyz9nthWMz6Iwtdq1gnD8GZmyfyd5KoxNIraHYIhcjeYH6 INOjSwuWadeyC/31PBDQgfo0GzVOcBX+YlGGj2gjcmG0hbPV5QYSXsI2XMPEY97HCmlT fbTUBJkBhzdPNckApba7PZMmEw0aJAImzt3+UUmCD7PmcUqbcGJl6xxx4altVUoZ1c37 Uvaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=F+ArX95v1d48JDmHY0masvzODL5LCniO4zuCFwg4jI4=; b=0vGDRKLnvgIXB1UbiG3w8Euz97l6O/Ndv9uvzGjnN7ejMHFtfHiBeD4Sf7+dgOaOUJ XHoUNxgye0SUfD5pt2b+UKRoT1ZFT1i+NebzZSPIuEDuBDcWB25FU1SPW6DBSCkQibd+ 8w+EUwHqaE4+gqgLYtW805Pie0b0Vc/FYI7ryrApg0XIxO+WZj0OOqFo9QeCF213sQdH b7/USTer52KmHroxRf56yrmli8wCq01X1Eck8wJiNNpVIARyYL98iUNGeiPqXNmb+0Og +D90iCxmgRuy5gZAN3M74lcV5QN4GrcyEXzHqCNYhB/x1jgmOLGcM5Pzo7czjwDAKAkk pYTw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f12-20020a1709062c4c00b007331498ad9bsi1386670ejh.540.2022.08.12.03.54.21; Fri, 12 Aug 2022 03:54:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238580AbiHLKdI (ORCPT + 99 others); Fri, 12 Aug 2022 06:33:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238572AbiHLKdG (ORCPT ); Fri, 12 Aug 2022 06:33:06 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9A1C75FA8; Fri, 12 Aug 2022 03:33:05 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2D0A6106F; Fri, 12 Aug 2022 03:33:06 -0700 (PDT) Received: from [10.57.12.42] (unknown [10.57.12.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2051B3F70D; Fri, 12 Aug 2022 03:33:03 -0700 (PDT) Message-ID: <3096bb82-62e6-bc9f-1600-fb58d6826302@arm.com> Date: Fri, 12 Aug 2022 11:32:59 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Subject: Re: [PATCH] PCI: mvebu: Fix endianity when accessing pci emul bridge members Content-Language: en-GB To: =?UTF-8?Q?Pali_Roh=c3=a1r?= , Lorenzo Pieralisi , Thomas Petazzoni , =?UTF-8?Q?Krzysztof_Wilczy=c5=84ski?= , Bjorn Helgaas Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20220812094058.16141-1-pali@kernel.org> From: Robin Murphy In-Reply-To: <20220812094058.16141-1-pali@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022-08-12 10:40, Pali Rohár wrote: > PCI emul bridge members iolimitupper, iobaseupper, memlimit and membase are > of type __le16, so correctly access these members via le16_to_cpu() macros. > > Fixes: 4ded69473adb ("PCI: mvebu: Propagate errors when updating PCI_IO_BASE and PCI_MEM_BASE registers") > Reported-by: kernel test robot > Signed-off-by: Pali Rohár > --- > drivers/pci/controller/pci-mvebu.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/drivers/pci/controller/pci-mvebu.c b/drivers/pci/controller/pci-mvebu.c > index c1ffdb06c971..00ea0836b81a 100644 > --- a/drivers/pci/controller/pci-mvebu.c > +++ b/drivers/pci/controller/pci-mvebu.c > @@ -523,7 +523,7 @@ static int mvebu_pcie_handle_iobase_change(struct mvebu_pcie_port *port) > > /* Are the new iobase/iolimit values invalid? */ > if (conf->iolimit < conf->iobase || > - conf->iolimitupper < conf->iobaseupper) > + le16_to_cpu(conf->iolimitupper) < le16_to_cpu(conf->iobaseupper)) > return mvebu_pcie_set_window(port, port->io_target, port->io_attr, > &desired, &port->iowin); > > @@ -535,10 +535,10 @@ static int mvebu_pcie_handle_iobase_change(struct mvebu_pcie_port *port) > * is the CPU address. > */ > desired.remap = ((conf->iobase & 0xF0) << 8) | > - (conf->iobaseupper << 16); > + le16_to_cpu(conf->iobaseupper << 16); This will always give 0, even when natively LE. > desired.base = port->pcie->io.start + desired.remap; > desired.size = ((0xFFF | ((conf->iolimit & 0xF0) << 8) | > - (conf->iolimitupper << 16)) - > + le16_to_cpu(conf->iolimitupper << 16)) - Similarly here. Robin. > desired.remap) + > 1; > > @@ -552,7 +552,7 @@ static int mvebu_pcie_handle_membase_change(struct mvebu_pcie_port *port) > struct pci_bridge_emul_conf *conf = &port->bridge.conf; > > /* Are the new membase/memlimit values invalid? */ > - if (conf->memlimit < conf->membase) > + if (le16_to_cpu(conf->memlimit) < le16_to_cpu(conf->membase)) > return mvebu_pcie_set_window(port, port->mem_target, port->mem_attr, > &desired, &port->memwin); > > @@ -562,8 +562,8 @@ static int mvebu_pcie_handle_membase_change(struct mvebu_pcie_port *port) > * window to setup, according to the PCI-to-PCI bridge > * specifications. > */ > - desired.base = ((conf->membase & 0xFFF0) << 16); > - desired.size = (((conf->memlimit & 0xFFF0) << 16) | 0xFFFFF) - > + desired.base = ((le16_to_cpu(conf->membase) & 0xFFF0) << 16); > + desired.size = (((le16_to_cpu(conf->memlimit) & 0xFFF0) << 16) | 0xFFFFF) - > desired.base + 1; > > return mvebu_pcie_set_window(port, port->mem_target, port->mem_attr, &desired,