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

Re: [PATCH v4] is_system_domain: replace open-coded instances


  • To: "Daniel P. Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>
  • Date: Tue, 4 Jan 2022 08:49:35 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.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=K72TlnpBZerG+sGDNdzO6jMYCE2aDUWBtay64/afNyI=; b=h51qvoJ4/MkjwpOQ97538zFPTFVn2dchJoq8A6pH0MU/fZrtvC4wcGvCvyoRuRTTOaMPLVQ6MK6olYNCPUPkWsoOGWK4gl6TnmgepBFN6R8JliWVrfAPMe6QhrgyOBm97Uz87dmBFiegDH/sS/vIF0SDZY9RzWCMQ8EJzvvL7bPwLi/QsbSpit9GJcC/iJ8nSriyxo2DnnSO2D/KVDCj5q0hDJllFg/OitPNXXo4FoFbQuKgYv3paCEH1AEYOq8vGInhq7b8hOJm2w1j41EZrXylYnw7Hgjh/TBcTeGZfbntRbO8nnNuZQJ3r2uudT9LW1YppSqLK1nzLurS4sYtBA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GX0Tx1imWDZfnZFXmPv6wuPQb4zh0hMFpaIdLIC4kbi7RZiF2O7M5f5j3UsClEzLIafCcRDtI0uFue0oX9oGH3sr9uBTS0FpPkDJLFkksAiQ9VGjJwJDT3qJAqLbUQm9KyIE14Uq3PUDcu6ZX12f4hfVE49zv+P/bNhi742605PoYmuSGxaT3LgJIYv3u67zErkR11p5kVmela8/ekk4/eTMYm9rdUl7xzl7BjaVp+KOYdrQR9g53Z8xtnYIshd18mHAAYAy/+TOgwd6HEEqCOWN73p3cZYpBQ+EiVQumYXycVBADBvhwFU3K1j/12+ZhTSD7Xe3fjpCWYt1MWr/og==
  • Cc: Christopher Clark <christopher.w.clark@xxxxxxxxx>, Dario Faggioli <dfaggioli@xxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • Delivery-date: Tue, 04 Jan 2022 08:50:02 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHYAUf/c8i/XyYIMUalffWjV6LCog==
  • Thread-topic: [PATCH v4] is_system_domain: replace open-coded instances

Hi, Daniel!

On 21.12.21 18:04, Daniel P. Smith wrote:
> From: Christopher Clark <christopher.w.clark@xxxxxxxxx>
>
> This is a split out of the hyperlaunch dom0 series.
>
> There were several instances of open-coded domid range checking. This commit
> replaces those with the is_system_domain or is_system_domid inline function.
>
> Signed-off-by: Christopher Clark <christopher.w.clark@xxxxxxxxx>
> Signed-off-by: Daniel P. Smith <dpsmith@xxxxxxxxxxxxxxxxxxxx>
> Acked-by: Dario Faggioli <dfaggioli@xxxxxxxx>
Reviewed-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@xxxxxxxx>
> ---
>   xen/arch/x86/cpu/mcheck/mce.c | 2 +-
>   xen/arch/x86/cpu/vpmu.c       | 2 +-
>   xen/common/domain.c           | 2 +-
>   xen/common/domctl.c           | 4 ++--
>   xen/common/sched/core.c       | 4 ++--
>   xen/include/xen/sched.h       | 7 ++++++-
>   6 files changed, 13 insertions(+), 8 deletions(-)
>
> diff --git a/xen/arch/x86/cpu/mcheck/mce.c b/xen/arch/x86/cpu/mcheck/mce.c
> index 7f433343bc..5c1df39075 100644
> --- a/xen/arch/x86/cpu/mcheck/mce.c
> +++ b/xen/arch/x86/cpu/mcheck/mce.c
> @@ -1518,7 +1518,7 @@ long do_mca(XEN_GUEST_HANDLE_PARAM(xen_mc_t) u_xen_mc)
>               d = rcu_lock_domain_by_any_id(mc_msrinject->mcinj_domid);
>               if ( d == NULL )
>               {
> -                if ( mc_msrinject->mcinj_domid >= DOMID_FIRST_RESERVED )
> +                if ( is_system_domid(mc_msrinject->mcinj_domid) )
>                       return x86_mcerr("do_mca inject: incompatible flag "
>                                        "MC_MSRINJ_F_GPADDR with domain %d",
>                                        -EINVAL, domid);
> diff --git a/xen/arch/x86/cpu/vpmu.c b/xen/arch/x86/cpu/vpmu.c
> index 8ec4547bed..c6bfa5a00e 100644
> --- a/xen/arch/x86/cpu/vpmu.c
> +++ b/xen/arch/x86/cpu/vpmu.c
> @@ -188,7 +188,7 @@ void vpmu_do_interrupt(struct cpu_user_regs *regs)
>        * in XENPMU_MODE_ALL, for everyone.
>        */
>       if ( (vpmu_mode & XENPMU_MODE_ALL) ||
> -         (sampled->domain->domain_id >= DOMID_FIRST_RESERVED) )
> +         is_system_domain(sampled->domain) )
>       {
>           sampling = choose_hwdom_vcpu();
>           if ( !sampling )
> diff --git a/xen/common/domain.c b/xen/common/domain.c
> index 093bb4403f..347cc073aa 100644
> --- a/xen/common/domain.c
> +++ b/xen/common/domain.c
> @@ -583,7 +583,7 @@ struct domain *domain_create(domid_t domid,
>       /* Sort out our idea of is_hardware_domain(). */
>       if ( domid == 0 || domid == hardware_domid )
>       {
> -        if ( hardware_domid < 0 || hardware_domid >= DOMID_FIRST_RESERVED )
> +        if ( hardware_domid < 0 || is_system_domid(hardware_domid) )
>               panic("The value of hardware_dom must be a valid domain ID\n");
>   
>           old_hwdom = hardware_domain;
> diff --git a/xen/common/domctl.c b/xen/common/domctl.c
> index 879a2adcbe..a3ad1f62b6 100644
> --- a/xen/common/domctl.c
> +++ b/xen/common/domctl.c
> @@ -52,7 +52,7 @@ static inline int is_free_domid(domid_t dom)
>   {
>       struct domain *d;
>   
> -    if ( dom >= DOMID_FIRST_RESERVED )
> +    if ( is_system_domid(dom) )
>           return 0;
>   
>       if ( (d = rcu_lock_domain_by_id(dom)) == NULL )
> @@ -536,7 +536,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) 
> u_domctl)
>           if ( !d )
>           {
>               ret = -EINVAL;
> -            if ( op->domain >= DOMID_FIRST_RESERVED )
> +            if ( is_system_domid(op->domain) )
>                   break;
>   
>               rcu_read_lock(&domlist_read_lock);
> diff --git a/xen/common/sched/core.c b/xen/common/sched/core.c
> index 8f4b1ca10d..6ea8bcf62f 100644
> --- a/xen/common/sched/core.c
> +++ b/xen/common/sched/core.c
> @@ -821,7 +821,7 @@ int sched_init_domain(struct domain *d, unsigned int 
> poolid)
>       int ret;
>   
>       ASSERT(d->cpupool == NULL);
> -    ASSERT(d->domain_id < DOMID_FIRST_RESERVED);
> +    ASSERT(!is_system_domain(d));
>   
>       if ( (ret = cpupool_add_domain(d, poolid)) )
>           return ret;
> @@ -845,7 +845,7 @@ int sched_init_domain(struct domain *d, unsigned int 
> poolid)
>   
>   void sched_destroy_domain(struct domain *d)
>   {
> -    ASSERT(d->domain_id < DOMID_FIRST_RESERVED);
> +    ASSERT(!is_system_domain(d));
>   
>       if ( d->cpupool )
>       {
> diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
> index 28146ee404..cd575d01cf 100644
> --- a/xen/include/xen/sched.h
> +++ b/xen/include/xen/sched.h
> @@ -613,9 +613,14 @@ extern struct vcpu *idle_vcpu[NR_CPUS];
>   #define is_idle_domain(d) ((d)->domain_id == DOMID_IDLE)
>   #define is_idle_vcpu(v)   (is_idle_domain((v)->domain))
>   
> +static inline bool is_system_domid(domid_t id)
> +{
> +    return id >= DOMID_FIRST_RESERVED;
> +}
> +
>   static inline bool is_system_domain(const struct domain *d)
>   {
> -    return d->domain_id >= DOMID_FIRST_RESERVED;
> +    return is_system_domid(d->domain_id);
>   }
>   
>   #define DOMAIN_DESTROYED (1u << 31) /* assumes atomic_t is >= 32 bits */

 


Rackspace

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