From nobody Fri May 3 01:55:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1607531777; cv=none; d=zohomail.com; s=zohoarc; b=DVxX3WYBBubO4in1qCkd6+1mrlbdpvXbtlWReDaZ3mtjA0YGEvucZyorqDKMhZKfjQxPXnR7L8dykqXxExq6WF3CRfrFO0FqE5uKka6mPhK22LIzCBhsFpnDWcSezGCLHrrz3CmuUMseu0/v7wWmiQbI2zoRhsLiAqDdF3jODK4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607531777; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=b+/TxrF4qJUX0wGGTUMyByEWIjy0WZY4LBlGieHkPRc=; b=USHL6ZYH5N5Ec2M4YTVWEFG3EVR+cFawO2xGAzBQDXYbRIUcczwjiGCEgzTCy+nWUtxaLFq7ivPFeM6/ZU+4m9hmN73EK6EreSv1s995ZEsj7mgaBTosS2lcrcRVjjTFKP7+g6tNMvYHdIC3RHoDfx/cztEWGzQTgoJzSSZa8ww= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1607531777617750.6841234696109; Wed, 9 Dec 2020 08:36:17 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.48484.85763 (Exim 4.92) (envelope-from ) id 1kn28j-0004Um-5r; Wed, 09 Dec 2020 16:16:29 +0000 Received: by outflank-mailman (output) from mailman id 48484.85763; Wed, 09 Dec 2020 16:16:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kn28j-0004Ue-1i; Wed, 09 Dec 2020 16:16:29 +0000 Received: by outflank-mailman (input) for mailman id 48484; Wed, 09 Dec 2020 16:16:27 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kn28h-0004SF-1r for xen-devel@lists.xenproject.org; Wed, 09 Dec 2020 16:16:27 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 7e50217e-569d-4108-be58-42ac93a182cc; Wed, 09 Dec 2020 16:16:21 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id B4591ADAA; Wed, 9 Dec 2020 16:16:20 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version 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" X-Inumbo-ID: 7e50217e-569d-4108-be58-42ac93a182cc X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1607530580; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=b+/TxrF4qJUX0wGGTUMyByEWIjy0WZY4LBlGieHkPRc=; b=jCp82V2QdeP4AHedfgWNEX4ayd24waSekvuv7niZe9ARvaGxoizwmB79CEDgcSySxGJu4H U+ePcxt0UxSvKq2vKr1u3xy6b7L4QN61f12K0uVv7+tq3a2gnT56NXko65QyoE4WBNgdOg ugTHHXmSBDCbg1ppbWxjOP4ipVg14DQ= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: paul@xen.org, Juergen Gross , Andrew Cooper , George Dunlap , Ian Jackson , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu Subject: [PATCH RFC 1/3] xen/hypfs: add support for bool leafs in dynamic directories Date: Wed, 9 Dec 2020 17:16:16 +0100 Message-Id: <20201209161618.309-2-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201209161618.309-1-jgross@suse.com> References: <20201209161618.309-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) Content-Type: text/plain; charset="utf-8" Add support for reading fixed sized leafs and writing bool leafs in dynamic directories with the backing variable being a member of the structure anchored in struct hypfs_dyndir->data. This adds the related leaf read and write functions and a helper macro HYPFS_STRUCT_ELEM() for referencing the element. Signed-off-by: Juergen Gross --- xen/common/hypfs.c | 53 +++++++++++++++++++++++++++++++++++------ xen/include/xen/hypfs.h | 7 ++++++ 2 files changed, 53 insertions(+), 7 deletions(-) diff --git a/xen/common/hypfs.c b/xen/common/hypfs.c index 087c63b92f..caee48cc97 100644 --- a/xen/common/hypfs.c +++ b/xen/common/hypfs.c @@ -501,17 +501,26 @@ int hypfs_read_dir(const struct hypfs_entry *entry, return 0; } =20 -int hypfs_read_leaf(const struct hypfs_entry *entry, - XEN_GUEST_HANDLE_PARAM(void) uaddr) +static int hypfs_read_leaf_off(const struct hypfs_entry *entry, + XEN_GUEST_HANDLE_PARAM(void) uaddr, + void *off) { const struct hypfs_entry_leaf *l; unsigned int size =3D entry->funcs->getsize(entry); + const void *ptr; =20 ASSERT(this_cpu(hypfs_locked) !=3D hypfs_unlocked); =20 l =3D container_of(entry, const struct hypfs_entry_leaf, e); + ptr =3D off ? off + (unsigned long)l->u.content : l->u.content; + + return copy_to_guest(uaddr, ptr, size) ? -EFAULT : 0; +} =20 - return copy_to_guest(uaddr, l->u.content, size) ? -EFAULT : 0; +int hypfs_read_leaf(const struct hypfs_entry *entry, + XEN_GUEST_HANDLE_PARAM(void) uaddr) +{ + return hypfs_read_leaf_off(entry, uaddr, NULL); } =20 static int hypfs_read(const struct hypfs_entry *entry, @@ -587,11 +596,12 @@ int hypfs_write_leaf(struct hypfs_entry_leaf *leaf, return ret; } =20 -int hypfs_write_bool(struct hypfs_entry_leaf *leaf, - XEN_GUEST_HANDLE_PARAM(const_void) uaddr, - unsigned int ulen) +static int hypfs_write_bool_off(struct hypfs_entry_leaf *leaf, + XEN_GUEST_HANDLE_PARAM(const_void) uaddr, + unsigned int ulen, void *off) { bool buf; + bool *ptr; =20 ASSERT(this_cpu(hypfs_locked) =3D=3D hypfs_write_locked); ASSERT(leaf->e.type =3D=3D XEN_HYPFS_TYPE_BOOL && @@ -604,11 +614,19 @@ int hypfs_write_bool(struct hypfs_entry_leaf *leaf, if ( copy_from_guest(&buf, uaddr, ulen) ) return -EFAULT; =20 - *(bool *)leaf->u.write_ptr =3D buf; + ptr =3D off ? off + (unsigned long)leaf->u.write_ptr : leaf->u.write_p= tr; + *ptr =3D buf; =20 return 0; } =20 +int hypfs_write_bool(struct hypfs_entry_leaf *leaf, + XEN_GUEST_HANDLE_PARAM(const_void) uaddr, + unsigned int ulen) +{ + return hypfs_write_bool_off(leaf, uaddr, ulen, NULL); +} + int hypfs_write_custom(struct hypfs_entry_leaf *leaf, XEN_GUEST_HANDLE_PARAM(const_void) uaddr, unsigned int ulen) @@ -644,6 +662,27 @@ int hypfs_write_custom(struct hypfs_entry_leaf *leaf, return ret; } =20 +int hypfs_dyndir_id_read_leaf(const struct hypfs_entry *entry, + XEN_GUEST_HANDLE_PARAM(void) uaddr) +{ + struct hypfs_dyndir_id *dyndata; + + dyndata =3D hypfs_get_dyndata(); + + return hypfs_read_leaf_off(entry, uaddr, dyndata->data); +} + +int hypfs_dyndir_id_write_bool(struct hypfs_entry_leaf *leaf, + XEN_GUEST_HANDLE_PARAM(const_void) uaddr, + unsigned int ulen) +{ + struct hypfs_dyndir_id *dyndata; + + dyndata =3D hypfs_get_dyndata(); + + return hypfs_write_bool_off(leaf, uaddr, ulen, dyndata->data); +} + int hypfs_write_deny(struct hypfs_entry_leaf *leaf, XEN_GUEST_HANDLE_PARAM(const_void) uaddr, unsigned int ulen) diff --git a/xen/include/xen/hypfs.h b/xen/include/xen/hypfs.h index 34073faff8..670dc68b48 100644 --- a/xen/include/xen/hypfs.h +++ b/xen/include/xen/hypfs.h @@ -160,6 +160,8 @@ static inline void hypfs_string_set_reference(struct hy= pfs_entry_leaf *leaf, HYPFS_FIXEDSIZE_INIT(var, XEN_HYPFS_TYPE_BOOL, nam, contvar, \ &hypfs_bool_wr_funcs, 1) =20 +#define HYPFS_STRUCT_ELEM(type, elem) (((type *)NULL)->elem) + extern struct hypfs_entry_dir hypfs_root; =20 int hypfs_add_dir(struct hypfs_entry_dir *parent, @@ -204,6 +206,11 @@ struct hypfs_entry *hypfs_gen_dyndir_id_entry( const struct hypfs_entry_dir *template, unsigned int id, void *data); unsigned int hypfs_dynid_entry_size(const struct hypfs_entry *template, unsigned int id); +int hypfs_dyndir_id_read_leaf(const struct hypfs_entry *entry, + XEN_GUEST_HANDLE_PARAM(void) uaddr); +int hypfs_dyndir_id_write_bool(struct hypfs_entry_leaf *leaf, + XEN_GUEST_HANDLE_PARAM(const_void) uaddr, + unsigned int ulen); #endif =20 #endif /* __XEN_HYPFS_H__ */ --=20 2.26.2 From nobody Fri May 3 01:55:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1607531779; cv=none; d=zohomail.com; s=zohoarc; b=RD35ZRjs0ye4AGCrq7kkkeRaTXwit6Pbemkp49J5BlilmcidQ/ixBEyrQPkNuWvw27L49yewUV8TxT+iPYHO9NSruEnGd5TdVjR5/aiFUdwTJHm2Cp35u2lfF6vEx00P8gPxULCJv1OgtBFzep+df3HhiPwHSI1ENWc3O1ipiOs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607531779; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KRtEHnVaMwtk5C3UwqZutxYpthuwswPsa5VGCeAsQUM=; b=gK8edzKaDMN9+x1+yz5lBVJT4kkh6vcQjj1f8ZVYKpKnnY5b7+M7o4r1K2KopNRquPFSbRt9ZYrJCdBFRDm5R8HsF/TJzXbU70r6x5LN51y90vwpaJwTd5iJ2C6KjKRbnVhFz5KNYlu7bFFtidHAVjlMnYuHRjkIm/eenXLYxFw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1607531779306493.5693399693936; Wed, 9 Dec 2020 08:36:19 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.48485.85774 (Exim 4.92) (envelope-from ) id 1kn28n-0004YE-Cf; Wed, 09 Dec 2020 16:16:33 +0000 Received: by outflank-mailman (output) from mailman id 48485.85774; Wed, 09 Dec 2020 16:16:33 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kn28n-0004Y7-9V; Wed, 09 Dec 2020 16:16:33 +0000 Received: by outflank-mailman (input) for mailman id 48485; Wed, 09 Dec 2020 16:16:32 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kn28m-0004SF-21 for xen-devel@lists.xenproject.org; Wed, 09 Dec 2020 16:16:32 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 0ea05d4a-9f24-491c-9980-a2f279dc18e2; Wed, 09 Dec 2020 16:16:21 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id F1257ADC5; Wed, 9 Dec 2020 16:16:20 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version 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" X-Inumbo-ID: 0ea05d4a-9f24-491c-9980-a2f279dc18e2 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1607530581; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KRtEHnVaMwtk5C3UwqZutxYpthuwswPsa5VGCeAsQUM=; b=IBlresOrvNrwtJf7ZbuEUaOvcpmnBPzux8muFTgD+31wgPQ6wDdatxNJHt1AUo0ZV3Tn3Q AdqtrHkD2RrTqrFyh8SrImPxPYJinrpTTsn9MP/TlG8lddn/+nTcTQYpi7loEs0k9kJ8ig DrrUGtUt8zl7uKYuZscvo6OvcfxTPjc= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: paul@xen.org, Juergen Gross , Andrew Cooper , George Dunlap , Ian Jackson , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu Subject: [PATCH RFC 2/3] xen/domain: add domain hypfs directories Date: Wed, 9 Dec 2020 17:16:17 +0100 Message-Id: <20201209161618.309-3-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201209161618.309-1-jgross@suse.com> References: <20201209161618.309-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) Content-Type: text/plain; charset="utf-8" Add /domain/ directories to hypfs. Those are completely dynamic, so the related hypfs access functions need to be implemented. Signed-off-by: Juergen Gross --- V3: - new patch --- docs/misc/hypfs-paths.pandoc | 10 +++ xen/common/Makefile | 1 + xen/common/hypfs_dom.c | 137 +++++++++++++++++++++++++++++++++++ 3 files changed, 148 insertions(+) create mode 100644 xen/common/hypfs_dom.c diff --git a/docs/misc/hypfs-paths.pandoc b/docs/misc/hypfs-paths.pandoc index e86f7d0dbe..116642e367 100644 --- a/docs/misc/hypfs-paths.pandoc +++ b/docs/misc/hypfs-paths.pandoc @@ -34,6 +34,7 @@ not containing any '/' character. The names "." and ".." = are reserved for file system internal use. =20 VALUES are strings and can take the following forms (note that this repres= ents +>>>>>>> patched only the syntax used in this document): =20 * STRING -- an arbitrary 0-delimited byte string. @@ -191,6 +192,15 @@ The scheduling granularity of a cpupool. Writing a value is allowed only for cpupools with no cpu assigned and if t= he architecture is supporting different scheduling granularities. =20 +#### /domain/ + +A directory of all current domains. + +#### /domain/*/ + +The individual domains. Each entry is a directory with the name being the +domain-id (e.g. /domain/0/). + #### /params/ =20 A directory of runtime parameters. diff --git a/xen/common/Makefile b/xen/common/Makefile index d109f279a4..e88a9ee91e 100644 --- a/xen/common/Makefile +++ b/xen/common/Makefile @@ -15,6 +15,7 @@ obj-$(CONFIG_GRANT_TABLE) +=3D grant_table.o obj-y +=3D guestcopy.o obj-bin-y +=3D gunzip.init.o obj-$(CONFIG_HYPFS) +=3D hypfs.o +obj-$(CONFIG_HYPFS) +=3D hypfs_dom.o obj-y +=3D irq.o obj-y +=3D kernel.o obj-y +=3D keyhandler.o diff --git a/xen/common/hypfs_dom.c b/xen/common/hypfs_dom.c new file mode 100644 index 0000000000..241e379b24 --- /dev/null +++ b/xen/common/hypfs_dom.c @@ -0,0 +1,137 @@ +/*************************************************************************= ***** + * + * hypfs_dom.c + * + * Per domain hypfs nodes. + */ + +#include +#include +#include +#include + +static const struct hypfs_entry *domain_domdir_enter( + const struct hypfs_entry *entry) +{ + struct hypfs_dyndir_id *data; + struct domain *d; + + data =3D hypfs_get_dyndata(); + d =3D get_domain_by_id(data->id); + data->data =3D d; + if ( !d ) + return ERR_PTR(-ENOENT); + + return entry; +} + +static void domain_domdir_exit(const struct hypfs_entry *entry) +{ + struct hypfs_dyndir_id *data; + struct domain *d; + + data =3D hypfs_get_dyndata(); + d =3D data->data; + put_domain(d); +} + +static const struct hypfs_funcs domain_domdir_funcs =3D { + .enter =3D domain_domdir_enter, + .exit =3D domain_domdir_exit, + .read =3D hypfs_read_dir, + .write =3D hypfs_write_deny, + .getsize =3D hypfs_getsize, + .findentry =3D hypfs_dir_findentry, +}; + +static HYPFS_DIR_INIT_FUNC(domain_domdir, "%u", &domain_domdir_funcs); + +static int domain_dir_read(const struct hypfs_entry *entry, + XEN_GUEST_HANDLE_PARAM(void) uaddr) +{ + int ret =3D 0; + const struct domain *d; + + for_each_domain ( d ) + { + ret =3D hypfs_read_dyndir_id_entry(&domain_domdir, d->domain_id, + !d->next_in_list, &uaddr); + if ( ret ) + break; + } + + return ret; +} + +static unsigned int domain_dir_getsize(const struct hypfs_entry *entry) +{ + const struct domain *d; + unsigned int size =3D 0; + + for_each_domain ( d ) + size +=3D hypfs_dynid_entry_size(entry, d->domain_id); + + return size; +} + +static const struct hypfs_entry *domain_dir_enter( + const struct hypfs_entry *entry) +{ + struct hypfs_dyndir_id *data; + + data =3D hypfs_alloc_dyndata(struct hypfs_dyndir_id); + if ( !data ) + return ERR_PTR(-ENOMEM); + data->id =3D DOMID_SELF; + + rcu_read_lock(&domlist_read_lock); + + return entry; +} + +static void domain_dir_exit(const struct hypfs_entry *entry) +{ + rcu_read_unlock(&domlist_read_lock); + + hypfs_free_dyndata(); +} + +static struct hypfs_entry *domain_dir_findentry( + const struct hypfs_entry_dir *dir, const char *name, unsigned int name= _len) +{ + unsigned long id; + const char *end; + struct domain *d; + + id =3D simple_strtoul(name, &end, 10); + if ( end !=3D name + name_len ) + return ERR_PTR(-ENOENT); + + d =3D rcu_lock_domain_by_id(id); + if ( !d ) + return ERR_PTR(-ENOENT); + + rcu_unlock_domain(d); + + return hypfs_gen_dyndir_id_entry(&domain_domdir, id, d); +} + +static const struct hypfs_funcs domain_dir_funcs =3D { + .enter =3D domain_dir_enter, + .exit =3D domain_dir_exit, + .read =3D domain_dir_read, + .write =3D hypfs_write_deny, + .getsize =3D domain_dir_getsize, + .findentry =3D domain_dir_findentry, +}; + +static HYPFS_DIR_INIT_FUNC(domain_dir, "domain", &domain_dir_funcs); + +static int __init domhypfs_init(void) +{ + hypfs_add_dir(&hypfs_root, &domain_dir, true); + hypfs_add_dyndir(&domain_dir, &domain_domdir); + + return 0; +} +__initcall(domhypfs_init); --=20 2.26.2 From nobody Fri May 3 01:55:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1607531451; cv=none; d=zohomail.com; s=zohoarc; b=WjetCA3MJEZNOhEtHOp5Bmr7dqiY914cq17dMxj8c8SBJA+gJ1QlwHE0Rpzc8gSFkgbsjsLITnlLisjEeDDmN//WHoyUnGHUV9VthJf29YmKbwitNh2FjnJBBB1tIqCDMzHdoShVdfcAh971R3a52NEcFDsotUAQSR0/mPZRGHI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607531451; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=g8rJKVfvD7B5g+TUwc6aQ0QAVGKg6M4SOf5V18X4xJk=; b=Q1FUpq5QoXey984OYxAQ96TCtgqJo3hnCQ9QCjgsLCBHtWWkVnYYmuc9ZZCfL0czCF6eeuteDgnc22VYVkrbSEfNic52wXnYEh5OB7tHEi3hWEGdmyB1L5MfgwF8qCqZrty+zn+sM1GAHiOt2HudOJIIkpQfDXZ4hbo82dzMMCA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1607531451244639.0219038307941; Wed, 9 Dec 2020 08:30:51 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.48486.85787 (Exim 4.92) (envelope-from ) id 1kn28s-0004cy-M1; Wed, 09 Dec 2020 16:16:38 +0000 Received: by outflank-mailman (output) from mailman id 48486.85787; Wed, 09 Dec 2020 16:16:38 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kn28s-0004cn-Ht; Wed, 09 Dec 2020 16:16:38 +0000 Received: by outflank-mailman (input) for mailman id 48486; Wed, 09 Dec 2020 16:16:37 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kn28r-0004SF-2F for xen-devel@lists.xenproject.org; Wed, 09 Dec 2020 16:16:37 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id d08d6373-737d-49ff-ac70-952481d7f693; Wed, 09 Dec 2020 16:16:22 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 444A3AF8A; Wed, 9 Dec 2020 16:16:21 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version 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" X-Inumbo-ID: d08d6373-737d-49ff-ac70-952481d7f693 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1607530581; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g8rJKVfvD7B5g+TUwc6aQ0QAVGKg6M4SOf5V18X4xJk=; b=Gr6xFEk+e4HbG53mSI/tfN9x/ztLT9J2Zxt4L6Qqof0hSTZHL5Nq6i8ZsB+1CPQgqTnG+x 52z7Na5xWdk5TXma52nhw8mqa7aeoxBofwRZMBIk2SKhl6tsDo5mZoy6jqNoOZ1Ep1iNyc Hvs7W0Uq5gR2nqDxE++F3QCbGktgcLI= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: paul@xen.org, Juergen Gross , Andrew Cooper , George Dunlap , Ian Jackson , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu Subject: [PATCH RFC 3/3] xen/domain: add per-domain hypfs directory abi-features Date: Wed, 9 Dec 2020 17:16:18 +0100 Message-Id: <20201209161618.309-4-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201209161618.309-1-jgross@suse.com> References: <20201209161618.309-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) Content-Type: text/plain; charset="utf-8" Add a new per-domain hypfs directory "abi-features" used to control some feature availability. Changing the availability of a feature is allowed only before the first activation of the domain. The related leafs right now are "event-channel-upcall" and "fifo-event-channels". For those bool elements are added to struct domain, but for now without any further handling. Signed-off-by: Juergen Gross --- xen/common/hypfs_dom.c | 39 +++++++++++++++++++++++++++++++++++++++ xen/include/xen/sched.h | 4 ++++ 2 files changed, 43 insertions(+) diff --git a/xen/common/hypfs_dom.c b/xen/common/hypfs_dom.c index 241e379b24..b54e246ad6 100644 --- a/xen/common/hypfs_dom.c +++ b/xen/common/hypfs_dom.c @@ -10,6 +10,42 @@ #include #include =20 +static int domain_abifeat_write(struct hypfs_entry_leaf *leaf, + XEN_GUEST_HANDLE_PARAM(const_void) uaddr, + unsigned int ulen) +{ + struct hypfs_dyndir_id *data; + struct domain *d; + + data =3D hypfs_get_dyndata(); + d =3D data->data; + + if ( d->creation_finished ) + return -EBUSY; + + return hypfs_dyndir_id_write_bool(leaf, uaddr, ulen); +} + +static const struct hypfs_funcs abifeat_funcs =3D { + .enter =3D hypfs_node_enter, + .exit =3D hypfs_node_exit, + .read =3D hypfs_dyndir_id_read_leaf, + .write =3D domain_abifeat_write, + .getsize =3D hypfs_getsize, + .findentry =3D hypfs_leaf_findentry, +}; + +static HYPFS_FIXEDSIZE_INIT(abifeat_evtupcall, XEN_HYPFS_TYPE_BOOL, + "event-channel-upcall", + HYPFS_STRUCT_ELEM(struct domain, abi_evt_upcal= l), + &abifeat_funcs, 1); +static HYPFS_FIXEDSIZE_INIT(abifeat_fifoevnt, XEN_HYPFS_TYPE_BOOL, + "fifo-event-channels", + HYPFS_STRUCT_ELEM(struct domain, abi_fifo_evt), + &abifeat_funcs, 1); + +static HYPFS_DIR_INIT(domain_abifeatdir, "abi-features"); + static const struct hypfs_entry *domain_domdir_enter( const struct hypfs_entry *entry) { @@ -131,6 +167,9 @@ static int __init domhypfs_init(void) { hypfs_add_dir(&hypfs_root, &domain_dir, true); hypfs_add_dyndir(&domain_dir, &domain_domdir); + hypfs_add_dir(&domain_domdir, &domain_abifeatdir, true); + hypfs_add_leaf(&domain_abifeatdir, &abifeat_evtupcall, true); + hypfs_add_leaf(&domain_abifeatdir, &abifeat_fifoevnt, true); =20 return 0; } diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 31abbe7a99..fb99249743 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -424,6 +424,10 @@ struct domain */ bool creation_finished; =20 + /* ABI-features (can be set via hypfs before first unpause).*/ + bool abi_fifo_evt; + bool abi_evt_upcall; + /* Which guest this guest has privileges on */ struct domain *target; =20 --=20 2.26.2