From nobody Tue Feb 10 12:58:36 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 ARC-Seal: i=1; a=rsa-sha256; t=1677771333; cv=none; d=zohomail.com; s=zohoarc; b=fGu7j2q3FHInRhWUH34FXIDmiRx2nBXJgzYdd2N537+aZOCTW5qvR4AD+IEoHtxvmOW0PuDc8CB0i+u9ukInz/xkK6tNSRwP1mHf5Ogr0f1sZpKL2VMGHcB3iEeSWhIHzP/kLCPy4xbzM80j4QZq+gq/0mLk6y0sVImXLlT4azQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677771333; 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=7gK7dvxz5pclX0MnciBP6zR++gp8k+vbHhIgn8vIfXk=; b=CeH7xvMhUCYjz9mmIqtZz5l6vwWgtD8uEDbqwxAMdUvMra0dWtcBu0yZJ663ocujeYoEcyMzZ9N/55duxMevAHGR0NJVkwC/z54JHI2hLFbPt7It6cB9z/TE5wFRwenhUXl8v/N0shFnFvqm/m4nORJbUS3WGrt+k+Ae89OBoVA= 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1677771333864714.1453672643606; Thu, 2 Mar 2023 07:35:33 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.505058.777664 (Exim 4.92) (envelope-from ) id 1pXkxR-0003QU-Ek; Thu, 02 Mar 2023 15:35:01 +0000 Received: by outflank-mailman (output) from mailman id 505058.777664; Thu, 02 Mar 2023 15:35:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pXkxR-0003Nk-0L; Thu, 02 Mar 2023 15:35:01 +0000 Received: by outflank-mailman (input) for mailman id 505058; Thu, 02 Mar 2023 15:34:57 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pXkxN-0001Jv-5e for xen-devel@lists.xenproject.org; Thu, 02 Mar 2023 15:34:57 +0000 Received: from desiato.infradead.org (desiato.infradead.org [2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id c2d1fed5-b90f-11ed-96ad-2f268f93b82a; Thu, 02 Mar 2023 16:34:49 +0100 (CET) Received: from i7.infradead.org ([2001:8b0:10b:1:21e:67ff:fecb:7a92]) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1pXkx5-00FL3s-0L; Thu, 02 Mar 2023 15:34:42 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1pXkx4-004uzq-38; Thu, 02 Mar 2023 15:34:38 +0000 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 X-Inumbo-ID: c2d1fed5-b90f-11ed-96ad-2f268f93b82a DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=7gK7dvxz5pclX0MnciBP6zR++gp8k+vbHhIgn8vIfXk=; b=S4wCJdfuWRVgYPx9kKLk0xA+ko e7ZB09+Rs2KKJZoF7A2nmmbx4uXvWmZO8R/FlyeezVVODqEnTf3UGYROuP6Ln2PAMwseYTN+2ylze WIfvuHbVTq++w7YQm5Vbz/zeKfYK1n4sx2f5k04ZVAHmCRLfGQwoOYxPP1YEA3GydmIPPuBaH8GNB fGb6PBC9kgdipKoQRH374/cqIfbNOBYuXtA8yjW1vqiPTLpcrzZiC75A0JNifqzBbPAFr9ljsFUdh KEDDSRCDfn/eyuwne1D+npgC4VoXBRwdD1DixUj1yJ7RIQ1iNcFzRd/3NfjLSX4lq+9xdEeh/ExL5 gpA4JCLQ==; From: David Woodhouse To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Paul Durrant , Joao Martins , Ankur Arora , Stefano Stabellini , vikram.garhwal@amd.com, Anthony Perard , xen-devel@lists.xenproject.org Subject: [RFC PATCH v1 23/25] hw/xen: Map guest XENSTORE_PFN grant in emulated Xenstore Date: Thu, 2 Mar 2023 15:34:33 +0000 Message-Id: <20230302153435.1170111-24-dwmw2@infradead.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230302153435.1170111-1-dwmw2@infradead.org> References: <20230302153435.1170111-1-dwmw2@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: David Woodhouse X-SRS-Rewrite: SMTP reverse-path rewritten from by desiato.infradead.org. See http://www.infradead.org/rpr.html X-ZohoMail-DKIM: pass (identity @infradead.org) X-ZM-MESSAGEID: 1677771335648100023 Content-Type: text/plain; charset="utf-8" From: David Woodhouse Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- hw/i386/kvm/xen_xenstore.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/hw/i386/kvm/xen_xenstore.c b/hw/i386/kvm/xen_xenstore.c index 028f80499e..f9b7387024 100644 --- a/hw/i386/kvm/xen_xenstore.c +++ b/hw/i386/kvm/xen_xenstore.c @@ -21,6 +21,7 @@ =20 #include "hw/sysbus.h" #include "hw/xen/xen.h" +#include "hw/xen/xen_backend_ops.h" #include "xen_overlay.h" #include "xen_evtchn.h" #include "xen_xenstore.h" @@ -34,6 +35,7 @@ =20 #include "hw/xen/interface/io/xs_wire.h" #include "hw/xen/interface/event_channel.h" +#include "hw/xen/interface/grant_table.h" =20 #define TYPE_XEN_XENSTORE "xen-xenstore" OBJECT_DECLARE_SIMPLE_TYPE(XenXenstoreState, XEN_XENSTORE) @@ -66,6 +68,9 @@ struct XenXenstoreState { =20 uint8_t *impl_state; uint32_t impl_state_size; + + struct xengntdev_handle *gt; + void *granted_xs; }; =20 struct XenXenstoreState *xen_xenstore_singleton; @@ -1452,6 +1457,17 @@ int xen_xenstore_reset(void) } s->be_port =3D err; =20 + /* + * We don't actually access the guest's page through the grant, because + * this isn't real Xen, and we can just use the page we gave it in the + * first place. Map the grant anyway, mostly for cosmetic purposes so + * it *looks* like it's in use in the guest-visible grant table. + */ + s->gt =3D qemu_xen_gnttab_open(); + uint32_t xs_gntref =3D GNTTAB_RESERVED_XENSTORE; + s->granted_xs =3D qemu_xen_gnttab_map_refs(s->gt, 1, xen_domid, &xs_gn= tref, + PROT_READ | PROT_WRITE); + return 0; } =20 --=20 2.39.0