[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v4 07/11] vpci/header: program p2m with guest BAR view


  • To: Oleksandr Andrushchenko <andr2000@xxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Fri, 19 Nov 2021 13:33:59 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=yQ4mYTWdI627UFE54cE0Y2ZnmHlgdUOswhx5HOMPLhM=; b=E2j+6glfQF4eZp2HwLk0eFk0iTe2gEWM/blzqGHY0HCT+aC8QrjhCDiGhXgCqm3glSEzQBjJnrd9q41ItN/fS8WrIiasWvH/voPbjPCUpA0dQNmyqqSMCAKpiHqorYpQxHOyF4cf/DRwAorFpH8jtLfEJaIav1rQgk3Sc4UGleBWvqm1RaRFlysS1UN+5aU8SfGhD7xAVwTssEupd/Irtvu2pebOhs5+rDVkM54NOlZyu4S0VYMXVBIKjhwUnqwwt+xgXof49CZDSkXL3gagd3LZQz00Cy3JJ9ZFQd5mZhn9TrNOuhfM1KwMNkKV6yMW5SSp2Aqf+tjbUENyEd07Hw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fAQ8tyjVFYScj75jscQrBcDf2u2z4S/ZBg3ct8Wy4tCyfxXct7ktObTlYH1pA8dg2YMfSbjl9kmTe5981f8bBl2rOM9OaMIT7d066m8X5UTKOlquax7jCJ1O0yrugVbo2k6TyxXYMM7qcB1AiJtm7g8o5kDD/qQUZFLJxCd8jWnmQ+qRHjahfCaxnkhfq0gzyHTaPxtsVty8KDMayLwHhiDie5S7CzidyVh/25brEJuRtYy3uAEXEF8kda7ADovlwGOnQluG1cgQ9ERhSequHqqanS+8//uigzOgeLG/HknDHB7C80kFWj67zWS+zb48JKrpFeJ02wthkPoRQD+gWQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: julien@xxxxxxx, sstabellini@xxxxxxxxxx, oleksandr_tyshchenko@xxxxxxxx, volodymyr_babchuk@xxxxxxxx, Artem_Mygaiev@xxxxxxxx, roger.pau@xxxxxxxxxx, andrew.cooper3@xxxxxxxxxx, george.dunlap@xxxxxxxxxx, paul@xxxxxxx, bertrand.marquis@xxxxxxx, rahul.singh@xxxxxxx, Oleksandr Andrushchenko <oleksandr_andrushchenko@xxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Fri, 19 Nov 2021 12:34:41 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 05.11.2021 07:56, Oleksandr Andrushchenko wrote:
> From: Oleksandr Andrushchenko <oleksandr_andrushchenko@xxxxxxxx>
> 
> Take into account guest's BAR view and program its p2m accordingly:
> gfn is guest's view of the BAR and mfn is the physical BAR value as set
> up by the host bridge in the hardware domain.

I'm sorry to be picky, but I don't think host bridges set up BARs. What
I think you mean is "as set up by the PCI bus driver in the hardware
domain". Of course this then still leaves out the case of firmware
doing so, and hence the dom0less case.

> --- a/xen/drivers/vpci/header.c
> +++ b/xen/drivers/vpci/header.c
> @@ -30,6 +30,10 @@
>  
>  struct map_data {
>      struct domain *d;
> +    /* Start address of the BAR as seen by the guest. */
> +    gfn_t start_gfn;
> +    /* Physical start address of the BAR. */
> +    mfn_t start_mfn;

As of the previous patch you process this on a per-BAR basis. Why don't
you simply put const struct vpci_bar * here? This would e.g. avoid the
need to keep in sync the identical expressions in vpci_process_pending()
and apply_map().

> @@ -37,12 +41,24 @@ static int map_range(unsigned long s, unsigned long e, 
> void *data,
>                       unsigned long *c)
>  {
>      const struct map_data *map = data;
> +    gfn_t start_gfn;

Imo this wants to move into the more narrow scope, ...

>      int rc;
>  
>      for ( ; ; )
>      {
>          unsigned long size = e - s + 1;
>  
> +        /*
> +         * Ranges to be mapped don't always start at the BAR start address, 
> as
> +         * there can be holes or partially consumed ranges. Account for the
> +         * offset of the current address from the BAR start.
> +         */
> +        start_gfn = gfn_add(map->start_gfn, s - mfn_x(map->start_mfn));

... allowing (in principle) for this to become its initializer.

Jan




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.