Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1920912pxb; Fri, 24 Sep 2021 15:19:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKf3mwQH7Cj/us0MYlPohRm+a2aiQSLJaHFj8ZAnTe1KXHls5Esq41elmkObPzqAeItadf X-Received: by 2002:a05:6e02:961:: with SMTP id q1mr10656316ilt.307.1632521984851; Fri, 24 Sep 2021 15:19:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632521984; cv=none; d=google.com; s=arc-20160816; b=TgMSp0DJYjzvElAGP8XaES96QVRaE+7FL+dHBLkaGXUnsRfDG+tKMBdAJhoVstPzZ5 oncU8Tnshy5jkOhX1WXKdrRtka77tLzVf76nN7L5bptv01ykLnwlcYfDlIbYw1CrxMTN IzYuWWGcomWb8wFl7cklbQFar9yWBGrh9T/2B5hTnOM+2BPRlbntC81YZcNAge4rsVKN cEEl176rPSHgkqX9hLpDPHor31m3BfjDsXQU8mVlVNaDi8TYFejjqjP96exhQdC2Svez V93BDIUojwvxfLV+pr4roJFWu/XJ2Um9d4kqoag+a2mpgRy24b6d0G5opEV6g+DvKDt/ VDew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-id:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature; bh=zmDsVgNx+izj2CuDJHs3Aoda1gwAq9y+oqPUA3eXllc=; b=dkGdNcnT+s00vAmInlIfWnWMmw6INjc4zV1Ji1mAOyGgUj7Igr4vp4fPlR+sIbiVgm tlIFgsnHoEtX3ei+2OC6j2vmCpksqrIy57ptt4PRx1A2svvwB1f1ultYpW6bhqtIikgh i+csnlhe8YJDgvVwtrOKflCwR8Mhd7BDQkBmDP9og5Bt/0Zb2s4H5l7XMn3OSeJJ7dUm k8RJUfmz4+dBsaFOVUJh2ai/7PohbBg6z+6eiamRSHaB8XEuLbSB1jYQ3+GVeeijgof5 zy4Kh8c8uWAf3X/2qvV/4m0ygCMAg6LsCvfWFLLLH288uFuEgLg3f7SEwFoAbSwznzKV /iDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lmDBZ9oI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 205si11514663ioa.52.2021.09.24.15.19.34; Fri, 24 Sep 2021 15:19:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lmDBZ9oI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231942AbhIXUGA (ORCPT + 99 others); Fri, 24 Sep 2021 16:06:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:44770 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345661AbhIXUF4 (ORCPT ); Fri, 24 Sep 2021 16:05:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7DC2B61107; Fri, 24 Sep 2021 20:04:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632513862; bh=5g6F24eAkfUrluLlmCOMkaLhZyk84IZGlaFRfiC0LOE=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=lmDBZ9oIyS3njcFNZoPha7UcobA4aS2FQkVoccD3LUilnqmsyJrUfNqkmWR8yOB3t 8gbmOYvaF43D55psInmqaApM29ibqVjCF3q0iWMhNWZejhTBf16LlT8XDlYP/fnHMX Dt5XOweabDGODl/B+KyIhLcaXT+S08vFjV90vk2cmsrtWNdgwXvWuviwLz/6byzySc BeG8mbo13ZAdxU/T9llrJzg8G4nbQgevNASLL/ys8+F0tTqo6BRrzQP0D9Q5NZqahq SaQeX5Hw8NIojx1AZbVFK0OufMlA62FfoHWWQ6n3vY5YqOehQqRG4GQEEnOAz6Uo7J NFCZmDQbtjK2w== Date: Fri, 24 Sep 2021 13:04:21 -0700 (PDT) From: Stefano Stabellini X-X-Sender: sstabellini@sstabellini-ThinkPad-T480s To: Oleksandr Andrushchenko cc: Stefano Stabellini , "jgross@suse.com" , "xen-devel@lists.xenproject.org" , "linux-kernel@vger.kernel.org" , "boris.ostrovsky@oracle.com" , "julien@xen.org" , "jbeulich@suse.com" , Anastasiia Lukianenko Subject: Re: [PATCH v3 2/2] xen-pciback: allow compiling on other archs than x86 In-Reply-To: <7310d23e-4193-3f4c-06da-606b30e73f24@epam.com> Message-ID: References: <20210923095345.185489-1-andr2000@gmail.com> <20210923095345.185489-2-andr2000@gmail.com> <7310d23e-4193-3f4c-06da-606b30e73f24@epam.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: multipart/mixed; BOUNDARY="8323329-2142721594-1632513512=:17979" Content-ID: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-2142721594-1632513512=:17979 Content-Type: text/plain; CHARSET=UTF-8 Content-Transfer-Encoding: 8BIT Content-ID: On Fri, 24 Sep 2021, Oleksandr Andrushchenko wrote: > On 24.09.21 08:46, Oleksandr Andrushchenko wrote: > > On 23.09.21 23:00, Stefano Stabellini wrote: > >> On Thu, 23 Sep 2021, Oleksandr Andrushchenko wrote: > >>> From: Oleksandr Andrushchenko > >>> > >>> Xen-pciback driver was designed to be built for x86 only. But it > >>> can also be used by other architectures, e.g. Arm. > >>> Re-structure the driver in a way that it can be built for other > >>> platforms as well. > >>> > >>> Signed-off-by: Oleksandr Andrushchenko > >>> Signed-off-by: Anastasiia Lukianenko > >> The patch looks good to me. Only one thing: on ARM32 I get: > > WE do not yet support Xen PCI passthrough for ARM32 Keep in mind that it is possible to run ARM32 guests on an ARM64 hypervisor. > >> drivers/xen/xen-pciback/conf_space_header.c: In function ‘bar_init’: > >> drivers/xen/xen-pciback/conf_space_header.c:239:34: warning: right shift count >= width of type [-Wshift-count-overflow] > >> bar->val = res[pos - 1].start >> 32; > >> ^~ > >> drivers/xen/xen-pciback/conf_space_header.c:240:49: warning: right shift count >= width of type [-Wshift-count-overflow] > >> bar->len_val = -resource_size(&res[pos - 1]) >> 32; > >> > >> > >> resource_size_t is defined as phys_addr_t and it can be 32bit on arm32. > >> > >> > >> One fix is to surround: > >> > >> if (pos && (res[pos - 1].flags & IORESOURCE_MEM_64)) { > >> bar->val = res[pos - 1].start >> 32; > >> bar->len_val = -resource_size(&res[pos - 1]) >> 32; > >> return bar; > >> } > >> > >> with #ifdef PHYS_ADDR_T_64BIT > >> > > This might not be correct. We are dealing here with a 64-bit BAR on a 32-bit OS. > > > > I think that this can still be valid use-case if BAR64.hi == 0. So, not sure > > > > we can just skip it with ifdef. > > > > Instead, to be on the safe side, we can have: > > > > config XEN_PCIDEV_STUB > >        tristate "Xen PCI-device stub driver" > >        depends on PCI && ARM64 && XEN > > e.g. only allow building the "stub" for ARM64 for now. This is a pretty drastic solution. I would be OK with it but I prefer the solution below >> 16 >> 16. > Or... there are couple of places in the kernel where PCI deals with the 32 bit shift as: > > drivers/pci/setup-res.c:108:        new = region.start >> 16 >> 16; > drivers/pci/iov.c:949:        new = region.start >> 16 >> 16; > > commit cf7bee5a0bf270a4eace0be39329d6ac0136cc47 > Date:   Sun Aug 7 13:49:59 *2005* +0400 > > [snip] > >     Also make sure to write high bits - use "x >> 16 >> 16" (rather than the >     simpler ">> 32") to avoid warnings on 32-bit architectures where we're >     not going to have any high bits. I think this is the best option > This might not be(?) immediately correct in case of LPAE though, e.g. > > 64-bit BAR may tolerate 40-bit address in some use-cases? It is correct for LPAE too, it is just that with LPAE it would be unnecessary. --8323329-2142721594-1632513512=:17979--