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

RE: [PATCH v7 08/11] IOMMU/VT-d: wire common device reserved memory API


  • To: "Marczykowski, Marek" <marmarek@xxxxxxxxxxxxxxxxxxxxxx>
  • From: "Tian, Kevin" <kevin.tian@xxxxxxxxx>
  • Date: Wed, 28 Sep 2022 05:15:27 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.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=bfOyxd0JFT9Wik7hBR/LzX5S89ipwV9LmvGZ6XanbP0=; b=DD9xE4waPD46yfo9M1YkWA/zrPO09FDJTTcLXwPb3f5Osww+zvUMLEYLvOgSQFQ0jIKdTbvsVVvn4hznLQB9ga8FWptD5/JAZEwQVVJ8bXrDt4DAbhiHVvLeFwbWPNsqRXoikubtyCEEIOd2v24AiGt6mEsdiv+Sue5ZylBnAsnVK0JKATqIgdxbEQ83nkgOGcpFn1ipXZ1D/2QYU6bUNtSDD3eti6JN3BGH0NnlyUDCXCRnkbzWnWonWP1jUA0dcxG3ZjuWE1hmEpTEtXZtSXa+Te43VVU7qTgzvTQgalEzgxPLutmf2PSunHwYccqnmOx1akE/SuoBZy0eRZiTEA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J/mOlEWQY+YwPdn5WiIm2vXMCAT8nya024Ov4haFEwRdR9iKpRPdXIE78nOb9PEi73ZUCsTL5XaBEuoaa1QtZqn7wvSaJ7ICgYu1wAz39vsMgW8mfVwMpRWeRsyb5EenuJSPYs1pp9RqocwW9Pb5hMgJLDBzGZbJauESW83iAsMmLpLVgQqe3eNqJL7r0uU5Bzju+P6c+XEpx1XtAPpi8F0bh+a1D3jt3tY+xe+4fCVC2GD96717QG5fLuTjM78EcqBR61rh2kOdP4HZJRj4EcyK0Y0BoDkvPGJajynhMz7FkrREd7SCpoHKMfnzN+RkmbIyi0PeJUD+ikFbRc6OMg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Wed, 28 Sep 2022 05:15:48 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHYykB/Pv1Ek/NIGEWzHFZweNfBzq3so7bggAXOUoCAAevfEA==
  • Thread-topic: [PATCH v7 08/11] IOMMU/VT-d: wire common device reserved memory API

> From: Marczykowski, Marek <marmarek@xxxxxxxxxxxxxxxxxxxxxx>
> Sent: Tuesday, September 27, 2022 7:54 AM
> 
> On Fri, Sep 23, 2022 at 07:21:04AM +0000, Tian, Kevin wrote:
> > > From: Marek Marczykowski-Górecki
> > > Sent: Saturday, September 17, 2022 10:51 AM
> > >
> > > Re-use rmrr= parameter handling code to handle common device
> reserved
> > > memory.
> > >
> > > Signed-off-by: Marek Marczykowski-Górecki
> > > <marmarek@xxxxxxxxxxxxxxxxxxxxxx>
> > > ---
> > > Changes in v3:
> > > - make MAX_USER_RMRR_PAGES applicable only to user-configured
> RMRR
> > > ---
> > >  xen/drivers/passthrough/vtd/dmar.c | 201 +++++++++++++++++------------
> -
> > >  1 file changed, 119 insertions(+), 82 deletions(-)
> > >
> > > diff --git a/xen/drivers/passthrough/vtd/dmar.c
> > > b/xen/drivers/passthrough/vtd/dmar.c
> > > index 367304c8739c..3df5f6b69719 100644
> > > --- a/xen/drivers/passthrough/vtd/dmar.c
> > > +++ b/xen/drivers/passthrough/vtd/dmar.c
> > > @@ -861,111 +861,139 @@ static struct user_rmrr __initdata
> > > user_rmrrs[MAX_USER_RMRR];
> > >
> > >  /* Macro for RMRR inclusive range formatting. */
> > >  #define ERMRRU_FMT "[%lx-%lx]"
> > > -#define ERMRRU_ARG(eru) eru.base_pfn, eru.end_pfn
> > > +#define ERMRRU_ARG base_pfn, end_pfn
> > > +
> > > +static int __init add_one_user_rmrr(unsigned long base_pfn,
> > > +                                    unsigned long end_pfn,
> > > +                                    unsigned int dev_count,
> > > +                                    uint32_t *sbdf);
> >
> > Just move the function here then no need of a declaration.
> 
> Ok.
> 
> > >
> > >  static int __init add_user_rmrr(void)
> > >  {
> > > +    unsigned int i;
> > > +    int ret;
> > > +
> > > +    for ( i = 0; i < nr_rmrr; i++ )
> > > +    {
> > > +        ret = add_one_user_rmrr(user_rmrrs[i].base_pfn,
> > > +                                user_rmrrs[i].end_pfn,
> > > +                                user_rmrrs[i].dev_count,
> > > +                                user_rmrrs[i].sbdf);
> > > +        if ( ret < 0 )
> > > +            return ret;
> > > +    }
> > > +    return 0;
> > > +}
> > > +
> > > +/* Returns 1 on success, 0 when ignoring and < 0 on error. */
> >
> > I'm not sure the point of 'ignoring'. If user specifies a wrong RMRR
> > range (overlap, mfn invalid, etc.) just return an error similar to
> > -ENOMEM. Ignoring a user-specified range implies that something
> > would potentially get broken hence better fail it early.
> 
> That's the behaviour that was here before, I simply added a comment
> about it explicitly (previously it used 'continue' heavily, now it's a
> separate function so it's a return value).
> While I agree in principle, I don't think such change should be part of
> this patch.
> 
> (...)
> 
> > > @@ -1108,6 +1136,15 @@ static int __init cf_check
> parse_rmrr_param(const
> > > char *str)
> > >          else
> > >              end = start;
> > >
> > > +        if ( (end - start) >= MAX_USER_RMRR_PAGES )
> > > +        {
> > > +            printk(XENLOG_ERR VTDPREFIX
> > > +                    "RMRR range "ERMRRU_FMT" exceeds "\
> > > +                    __stringify(MAX_USER_RMRR_PAGES)" pages\n",
> > > +                    start, end);
> > > +            return -E2BIG;
> > > +        }
> > > +
> >
> > why moving this error check out of add_one_user_rmrr()? I didn't
> > get why it's special from other checks there, e.g. having base>end...
> 
> To allow internal callers bypass MAX_USER_RMRR_PAGES, and make it apply
> really only to user-provided ranges.
> 

With above clarification and order adjustment,

Reviewed-by: Kevin Tian <kevin.tian@xxxxxxxxx>

 


Rackspace

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