From nobody Mon Feb 9 13:39:08 2026 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=1607530226; cv=none; d=zohomail.com; s=zohoarc; b=Zrxi7E/sYRo4iqoc3rAbYmDuv8DOKeMs6SapCYIYGWN+tp3L2fcTgRDNjZqzsqYpQcl/a0wCHe+GCnNFrQ8GunFVBVqUnxZ4ELdCqHUT95g91pLzvyjm5FmHZ4k082Kl4mAwB8rG/pqsG5ZEZ9iKpLNffARwR62KPUI4Mjhbx9E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607530226; 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=BW9eYydQo2F6aub4GEJBwW00UPy+ko8uE06ZsSs8E0c=; b=GSgU0T5rI+NgSMrV1rCeVcY0QXEMXcZKMn3iU1i8rQLGWBKyLo5UiVbNHgiDkiT0BvYs4qQdFKYWKXkpI5G4RBaG3wMjuAyAaaTD4jmiUvBfhb2hamXM2USN60tw78j5cMMaypaVozyjjtQ9wGcbCwABbYIXlnDKCSJ6mG3GUrs= 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 16075302255243.219318476603803; Wed, 9 Dec 2020 08:10:25 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.48428.85654 (Exim 4.92) (envelope-from ) id 1kn22Z-00034q-CQ; Wed, 09 Dec 2020 16:10:07 +0000 Received: by outflank-mailman (output) from mailman id 48428.85654; Wed, 09 Dec 2020 16:10:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kn22Z-00034g-8q; Wed, 09 Dec 2020 16:10:07 +0000 Received: by outflank-mailman (input) for mailman id 48428; Wed, 09 Dec 2020 16:10:06 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kn22Y-0002Oq-0f for xen-devel@lists.xenproject.org; Wed, 09 Dec 2020 16:10:06 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 882a4794-43af-449a-b516-ed041b9e8ffe; Wed, 09 Dec 2020 16:10:00 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 47C3EAFEB; Wed, 9 Dec 2020 16:09:59 +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: 882a4794-43af-449a-b516-ed041b9e8ffe 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=1607530199; 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=BW9eYydQo2F6aub4GEJBwW00UPy+ko8uE06ZsSs8E0c=; b=s+aVsUzKnQvk3WcsKTSlB//9Bhm8JWaN/FT2ryo4p4hQk2LVDSBp0Kxuu+YGIcvzXMOvxL qjvtiIT01twmizuwFx9GviG1TNnOCchq52L2zi6Y6Em/gjvsOhdXLHoN8rpjK/Q56mXh16 suuDBdWc1pID0DjuUOj63IV2JWDxeVQ= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Andrew Cooper , George Dunlap , Ian Jackson , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu Subject: [PATCH v3 2/8] xen/hypfs: switch write function handles to const Date: Wed, 9 Dec 2020 17:09:50 +0100 Message-Id: <20201209160956.32456-3-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201209160956.32456-1-jgross@suse.com> References: <20201209160956.32456-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" The node specific write functions take a void user address handle as parameter. As a write won't change the user memory use a const_void handle instead. This requires a new macro for casting a guest handle to a const type. Suggested-by: Jan Beulich Signed-off-by: Juergen Gross Reviewed-by: Jan Beulich --- V3: - new patch --- xen/common/hypfs.c | 17 +++++++++++------ xen/include/xen/guest_access.h | 5 +++++ xen/include/xen/hypfs.h | 14 +++++++++----- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/xen/common/hypfs.c b/xen/common/hypfs.c index 2e8e90591e..6f822ae097 100644 --- a/xen/common/hypfs.c +++ b/xen/common/hypfs.c @@ -344,7 +344,8 @@ static int hypfs_read(const struct hypfs_entry *entry, } =20 int hypfs_write_leaf(struct hypfs_entry_leaf *leaf, - XEN_GUEST_HANDLE_PARAM(void) uaddr, unsigned int ulen) + XEN_GUEST_HANDLE_PARAM(const_void) uaddr, + unsigned int ulen) { char *buf; int ret; @@ -384,7 +385,8 @@ int hypfs_write_leaf(struct hypfs_entry_leaf *leaf, } =20 int hypfs_write_bool(struct hypfs_entry_leaf *leaf, - XEN_GUEST_HANDLE_PARAM(void) uaddr, unsigned int ulen) + XEN_GUEST_HANDLE_PARAM(const_void) uaddr, + unsigned int ulen) { bool buf; =20 @@ -405,7 +407,8 @@ int hypfs_write_bool(struct hypfs_entry_leaf *leaf, } =20 int hypfs_write_custom(struct hypfs_entry_leaf *leaf, - XEN_GUEST_HANDLE_PARAM(void) uaddr, unsigned int ul= en) + XEN_GUEST_HANDLE_PARAM(const_void) uaddr, + unsigned int ulen) { struct param_hypfs *p; char *buf; @@ -439,13 +442,15 @@ int hypfs_write_custom(struct hypfs_entry_leaf *leaf, } =20 int hypfs_write_deny(struct hypfs_entry_leaf *leaf, - XEN_GUEST_HANDLE_PARAM(void) uaddr, unsigned int ulen) + XEN_GUEST_HANDLE_PARAM(const_void) uaddr, + unsigned int ulen) { return -EACCES; } =20 static int hypfs_write(struct hypfs_entry *entry, - XEN_GUEST_HANDLE_PARAM(void) uaddr, unsigned long u= len) + XEN_GUEST_HANDLE_PARAM(const_void) uaddr, + unsigned long ulen) { struct hypfs_entry_leaf *l; =20 @@ -497,7 +502,7 @@ long do_hypfs_op(unsigned int cmd, break; =20 case XEN_HYPFS_OP_write_contents: - ret =3D hypfs_write(entry, arg3, arg4); + ret =3D hypfs_write(entry, guest_handle_const_cast(arg3, void), ar= g4); break; =20 default: diff --git a/xen/include/xen/guest_access.h b/xen/include/xen/guest_access.h index f9b94cf1f4..5a50c3ccee 100644 --- a/xen/include/xen/guest_access.h +++ b/xen/include/xen/guest_access.h @@ -26,6 +26,11 @@ type *_x =3D (hnd).p; \ (XEN_GUEST_HANDLE_PARAM(type)) { _x }; \ }) +/* Same for casting to a const type. */ +#define guest_handle_const_cast(hnd, type) ({ \ + const type *_x =3D (const type *)((hnd).p); \ + (XEN_GUEST_HANDLE_PARAM(const_##type)) { _x }; \ +}) =20 /* Cast a XEN_GUEST_HANDLE to XEN_GUEST_HANDLE_PARAM */ #define guest_handle_to_param(hnd, type) ({ \ diff --git a/xen/include/xen/hypfs.h b/xen/include/xen/hypfs.h index 53f50772b4..99fd4b036d 100644 --- a/xen/include/xen/hypfs.h +++ b/xen/include/xen/hypfs.h @@ -38,7 +38,7 @@ struct hypfs_funcs { int (*read)(const struct hypfs_entry *entry, XEN_GUEST_HANDLE_PARAM(void) uaddr); int (*write)(struct hypfs_entry_leaf *leaf, - XEN_GUEST_HANDLE_PARAM(void) uaddr, unsigned int ulen); + XEN_GUEST_HANDLE_PARAM(const_void) uaddr, unsigned int ul= en); unsigned int (*getsize)(const struct hypfs_entry *entry); struct hypfs_entry *(*findentry)(const struct hypfs_entry_dir *dir, const char *name, unsigned int name_l= en); @@ -154,13 +154,17 @@ int hypfs_read_dir(const struct hypfs_entry *entry, int hypfs_read_leaf(const struct hypfs_entry *entry, XEN_GUEST_HANDLE_PARAM(void) uaddr); int hypfs_write_deny(struct hypfs_entry_leaf *leaf, - XEN_GUEST_HANDLE_PARAM(void) uaddr, unsigned int ulen= ); + XEN_GUEST_HANDLE_PARAM(const_void) uaddr, + unsigned int ulen); int hypfs_write_leaf(struct hypfs_entry_leaf *leaf, - XEN_GUEST_HANDLE_PARAM(void) uaddr, unsigned int ulen= ); + XEN_GUEST_HANDLE_PARAM(const_void) uaddr, + unsigned int ulen); int hypfs_write_bool(struct hypfs_entry_leaf *leaf, - XEN_GUEST_HANDLE_PARAM(void) uaddr, unsigned int ulen= ); + XEN_GUEST_HANDLE_PARAM(const_void) uaddr, + unsigned int ulen); int hypfs_write_custom(struct hypfs_entry_leaf *leaf, - XEN_GUEST_HANDLE_PARAM(void) uaddr, unsigned int ul= en); + XEN_GUEST_HANDLE_PARAM(const_void) uaddr, + unsigned int ulen); unsigned int hypfs_getsize(const struct hypfs_entry *entry); struct hypfs_entry *hypfs_leaf_findentry(const struct hypfs_entry_dir *dir, const char *name, --=20 2.26.2