From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 119C7C432BE for ; Thu, 19 Aug 2021 12:36:02 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D15536023D for ; Thu, 19 Aug 2021 12:36:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D15536023D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.168730.308059 (Exim 4.92) (envelope-from ) id 1mGhGs-0001DA-NT; Thu, 19 Aug 2021 12:35:46 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 168730.308059; Thu, 19 Aug 2021 12:35:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mGhGs-0001D3-Jo; Thu, 19 Aug 2021 12:35:46 +0000 Received: by outflank-mailman (input) for mailman id 168730; Thu, 19 Aug 2021 12:35:44 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mGhGq-0001Cx-Lt for xen-devel@lists.xenproject.org; Thu, 19 Aug 2021 12:35:44 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mGhGo-0007Mx-KH; Thu, 19 Aug 2021 12:35:42 +0000 Received: from [54.239.6.188] (helo=a483e7b01a66.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mGhGo-0003LN-EE; Thu, 19 Aug 2021 12:35:42 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:Content-Type:In-Reply-To: MIME-Version:Date:Message-ID:From:References:Cc:To:Subject; bh=n6LIJHD1Xnz+JdeLxZiwmOlO0nKpLSO1NO4GN2lDWRE=; b=sH3ykembIb0Vp5IWYtnl6fq6q3 4WKTnMB3RS16tld/WstAkoH/ggIwvm5SQP/Qdxg42vl7jbhyRH7FAWyPCa1dc/UbEEXJ5Ox7fLV2l NstHi1+g6JlP3zOGOFJZw87YNoDtS8SZJAhUYJEzAINWbrwVXLzkMPX+BCt48C+F3ArQ=; Subject: Re: [PATCH v1 10/14] xen/arm: Discovering PCI devices and add the PCI devices in XEN. To: Rahul Singh , xen-devel@lists.xenproject.org Cc: bertrand.marquis@arm.com, Stefano Stabellini , Volodymyr Babchuk , Jan Beulich References: From: Julien Grall Message-ID: <367ea162-9afb-1e30-860a-117abaf38867@xen.org> Date: Thu, 19 Aug 2021 13:35:40 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit (+ Jan) Hi Rahul, On 19/08/2021 13:02, Rahul Singh wrote: > Hardware domain is in charge of doing the PCI enumeration and will > discover the PCI devices and then will communicate to XEN via hyper > call PHYSDEVOP_pci_device_add to add the PCI devices in XEN. There are other PHYSDEVOP operations to add PCI devices. I think it is fine to only implement the latest (CC Jan for some opinion and confirm this is the latest). However, this ought to be explained in the commit message. Also, public/arch-arm.h will need to be updated as we now support the PHYSDEVOP hypercall. > > Signed-off-by: Rahul Singh > --- > xen/arch/arm/physdev.c | 39 ++++++++++++++++++++++++++++++++++++--- > 1 file changed, 36 insertions(+), 3 deletions(-) > > diff --git a/xen/arch/arm/physdev.c b/xen/arch/arm/physdev.c > index e91355fe22..ccce8f0eba 100644 > --- a/xen/arch/arm/physdev.c > +++ b/xen/arch/arm/physdev.c > @@ -9,12 +9,45 @@ > #include > #include > #include > - > +#include > +#include > > int do_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) > { > - gdprintk(XENLOG_DEBUG, "PHYSDEVOP cmd=%d: not implemented\n", cmd); > - return -ENOSYS; > + int ret = 0; > + > + switch ( cmd ) > + { > +#ifdef CONFIG_HAS_PCI > + case PHYSDEVOP_pci_device_add: { > + struct physdev_pci_device_add add; > + struct pci_dev_info pdev_info; > + nodeid_t node = NUMA_NO_NODE; > + > + ret = -EFAULT; > + if ( copy_from_guest(&add, arg, 1) != 0 ) > + break; > + > + pdev_info.is_extfn = !!(add.flags & XEN_PCI_DEV_EXTFN); > + if ( add.flags & XEN_PCI_DEV_VIRTFN ) > + { > + pdev_info.is_virtfn = 1; > + pdev_info.physfn.bus = add.physfn.bus; > + pdev_info.physfn.devfn = add.physfn.devfn; > + } > + else > + pdev_info.is_virtfn = 0; > + > + ret = pci_add_device(add.seg, add.bus, add.devfn, &pdev_info, node); > + break; > + } This is pretty much a copy of the x86 version without the NUMA bit. So I think we want to move the implementation in common code. > +#endif > + default: > + gdprintk(XENLOG_DEBUG, "PHYSDEVOP cmd=%d: not implemented\n", cmd); > + ret = -ENOSYS; > + } > + > + return ret; > } > > /* > Cheers, -- Julien Grall