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

Re: [RFC 4/6] capabilities: introduce console io as a domain capability


  • To: "Daniel P. Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 8 Aug 2023 17:24:36 +0200
  • 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=Iac+cMqKUP/CLiNKEpV07tq09X8Swz8dmGF7ta92L0U=; b=aFqQzBHoCgmMyvV+04Ta2YOtWiLwMySaBfbcKU6iXqYrm4rFDAggn+6BOLL+k7ifyF+2slV6VxNc6Ik8lN73clToOxwsqWvf1j8mch8YVCzkizAbtYqiOM+4LqSz1ibB1N7u232ubwg3K2TA12rc5OLF8hMpH14mJMOnDboWfjiilyefxoIL8pe0NiixaVdGiPpwgI9i47m9geqVw8xDT7CUBP7GaXmeirZmZIMoGmI178TRaMerEBaGmE+nhcvTPQtYCqQ90BSkyBClSKEw8v7c3+PXL00cozhsOioGcHhmijzNklSjiKRoQssQg7l3126xfk59XFHPeK47EyyHiw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XZiIfzy1WNlAn3kC2JdN7yNJIZ2QbtdYw3IRa4k/BFJrMMzWoJGqi+/RtAp/8kiWXx4M3uUVtLAy7C+LCWfK2jsdQguR3/xl1avq70KU0QfPmLEQVd1OsxqLHPilo0uOWMcMT5uI+ESo0Zm7YJNMx1ontHi/Q7IDEK4UQA/p/4x1NfthtWm0Ncbtk/U8dRZlwmWC5pOqJwxH9DEhjR6JRJXeMvyo87Ij4G2wdTGBYZKKfmAJDNLOjok0wyDMhV8V1/INNRsh8EqY7rSgShcHEGmFJSrxEftIWKIcY6dBo+bhFcXyQfBs7HiI/4G4vG1J8/r4dIbH3NPY6Mt7DuolfQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Tue, 08 Aug 2023 15:24:57 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 01.08.2023 22:20, Daniel P. Smith wrote:
> --- a/xen/include/xen/sched.h
> +++ b/xen/include/xen/sched.h
> @@ -472,8 +472,8 @@ struct domain
>  #define ROLE_HARDWARE_DOMAIN   (1U<<2)
>  #define ROLE_XENSTORE_DOMAIN   (1U<<3)
>      uint8_t          role;
> -    /* Can this guest access the Xen console? */
> -    bool             is_console;
> +#define CAP_CONSOLE_IO  (1U<<0)
> +    uint8_t          capabilities;
>      /* Is this guest being debugged by dom0? */
>      bool             debugger_attached;
>      /*
> @@ -1146,6 +1146,27 @@ static always_inline bool is_hvm_vcpu(const struct 
> vcpu *v)
>      return is_hvm_domain(v->domain);
>  }
>  
> +static always_inline bool domain_has_cap(
> +    const struct domain *d, uint8_t cap)
> +{
> +    return d->capabilities & cap;
> +}

What you implement here is effectively domain_has_any_cap(), which I
don't think is of much use. At the very least you want to assert that
cap is a power of two. But perhaps you rather want the caller to pass
in a bit number, not a mask, such that it's obvious that only one
thing can be checked at a time.

> +static always_inline bool domain_set_cap(
> +    struct domain *d, uint8_t cap)
> +{
> +    switch ( cap )
> +    {
> +    case CAP_CONSOLE_IO:
> +        d->capabilities |= cap;
> +        break;
> +    default:
> +        return false;
> +    }
> +
> +    return domain_has_cap(d, cap);
> +}

The "set" operation doesn't need to be an inline function, does it?

Jan



 


Rackspace

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