From nobody Mon Feb 9 18:19:38 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=1638775452; cv=none; d=zohomail.com; s=zohoarc; b=EZvr663j+pVeO8ZWWZnBn39d8azyNrjlH8CkOiXi3qc7TY+WR3ikCxbznQJRYl7QnAJOBHklU2YA3tUkCnN/jnCO/rSds7rdbun7sAiLW6JYQMBWHepvBI3kOtxYDw0+fO7MKRpY0fVTG2Sh3cvrva0VQu6Yekz66lMs0Zh7yKI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638775452; 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=jJ0RmLtKB8UkcvX+Y3JuijTbu6nHqV/hpfXxOIuN+R4=; b=SeLJPzkD+0tdBK9b3xA05pF2Sq9okAim16S63rZD6mDijo8fZVhZJtIQSsFhiHul7wEsUrHPHLQXTc1nRSi38Qi8OuvPU2BJKffDIFi4PepQiHm90YQJlOmx2mTA2cgz4ksw9vZWRgeQdvZAzJk2u5cVgYZHF1MkqSW5+4rm2rg= 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) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1638775452145973.7720282710512; Sun, 5 Dec 2021 23:24:12 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.238647.413655 (Exim 4.92) (envelope-from ) id 1mu8Ll-000120-8z; Mon, 06 Dec 2021 07:23:49 +0000 Received: by outflank-mailman (output) from mailman id 238647.413655; Mon, 06 Dec 2021 07:23:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mu8Lk-0000zi-QB; Mon, 06 Dec 2021 07:23:48 +0000 Received: by outflank-mailman (input) for mailman id 238647; Mon, 06 Dec 2021 07:23:47 +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 1mu8Lj-0008Mw-Ff for xen-devel@lists.xenproject.org; Mon, 06 Dec 2021 07:23:47 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 7022dedf-5665-11ec-a5e1-b9374ead2679; Mon, 06 Dec 2021 08:23:42 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 0823F1FE04; Mon, 6 Dec 2021 07:23:41 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id D21C21330B; Mon, 6 Dec 2021 07:23:40 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id YC8CMny6rWHVdAAAMHmgww (envelope-from ); Mon, 06 Dec 2021 07:23:40 +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 Sender: "Xen-devel" X-Inumbo-ID: 7022dedf-5665-11ec-a5e1-b9374ead2679 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1638775421; 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=jJ0RmLtKB8UkcvX+Y3JuijTbu6nHqV/hpfXxOIuN+R4=; b=dNA4rT4w7GOiBlM5Kmz8jsutTtW4O/BdSr4y396zKhGKNlRRf6sRGYOoPEhT9pubzIaxgV vUNVo9O8b28ePqjllYVqkYx5QLJLa+NLpclGZLvUJHx6m1m/s2KjJbR4625rUfKAMVbAHh hh/ji8MQP/L/ZsLI+F2z3eDzE5ZiHW0= From: Juergen Gross To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org Cc: samuel.thibault@ens-lyon.org, wl@xen.org, Juergen Gross Subject: [PATCH 07/10] mini-os: move x86 specific gnttab coding into arch/x86/gnttab.c Date: Mon, 6 Dec 2021 08:23:34 +0100 Message-Id: <20211206072337.9517-8-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20211206072337.9517-1-jgross@suse.com> References: <20211206072337.9517-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1638775453690100002 Content-Type: text/plain; charset="utf-8" Having grant table code in arch/x86/mm.c seems wrong. Move it to the new file arch/x86/gnttab.c, especially as the amount of code is expected to grow further. No functional change. Signed-off-by: Juergen Gross Reviewed-by: Samuel Thibault --- arch/x86/gnttab.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++ arch/x86/mm.c | 47 ---------------------------- 2 files changed, 78 insertions(+), 47 deletions(-) create mode 100644 arch/x86/gnttab.c diff --git a/arch/x86/gnttab.c b/arch/x86/gnttab.c new file mode 100644 index 0000000..56e59d7 --- /dev/null +++ b/arch/x86/gnttab.c @@ -0,0 +1,78 @@ +/* -*- Mode:C; c-basic-offset:4; tab-width:4 -*- + * + * (C) 2021 - Juergen Gross, SUSE Software Solutions Germany GmbH + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation = the + * rights to use, copy, modify, merge, publish, distribute, sublicense, an= d/or + * sell copies of the Software, and to permit persons to whom the Software= is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL= THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include +#include +#include +#include +#include + +grant_entry_v1_t *arch_init_gnttab(int nr_grant_frames) +{ + struct gnttab_setup_table setup; + unsigned long frames[nr_grant_frames]; + + setup.dom =3D DOMID_SELF; + setup.nr_frames =3D nr_grant_frames; + set_xen_guest_handle(setup.frame_list, frames); + + HYPERVISOR_grant_table_op(GNTTABOP_setup_table, &setup, 1); + return map_frames(frames, nr_grant_frames); +} + +void arch_suspend_gnttab(grant_entry_v1_t *gnttab_table, int nr_grant_fram= es) +{ +#ifdef CONFIG_PARAVIRT + int i; + + for ( i =3D 0; i < nr_grant_frames; i++ ) + { + HYPERVISOR_update_va_mapping((unsigned long)gnttab_table + PAGE_SI= ZE * i, + __pte(0x0 << PAGE_SHIFT), UVMF_INVLPG); + } +#endif + return; +} + +void arch_resume_gnttab(grant_entry_v1_t *gnttab_table, int nr_grant_frame= s) +{ + struct gnttab_setup_table setup; + unsigned long frames[nr_grant_frames]; +#ifdef CONFIG_PARAVIRT + int i; +#endif + + setup.dom =3D DOMID_SELF; + setup.nr_frames =3D nr_grant_frames; + set_xen_guest_handle(setup.frame_list, frames); + + HYPERVISOR_grant_table_op(GNTTABOP_setup_table, &setup, 1); + +#ifdef CONFIG_PARAVIRT + for ( i =3D 0; i < nr_grant_frames; i++ ) + { + HYPERVISOR_update_va_mapping((unsigned long)gnttab_table + PAGE_SI= ZE * i, + __pte((frames[i] << PAGE_SHIFT) | L1_PROT), UVMF_INVLPG); + } +#endif +} diff --git a/arch/x86/mm.c b/arch/x86/mm.c index c30d8bc..220c0b4 100644 --- a/arch/x86/mm.c +++ b/arch/x86/mm.c @@ -837,53 +837,6 @@ void arch_init_mm(unsigned long* start_pfn_p, unsigned= long* max_pfn_p) #endif } =20 -grant_entry_v1_t *arch_init_gnttab(int nr_grant_frames) -{ - struct gnttab_setup_table setup; - unsigned long frames[nr_grant_frames]; - - setup.dom =3D DOMID_SELF; - setup.nr_frames =3D nr_grant_frames; - set_xen_guest_handle(setup.frame_list, frames); - - HYPERVISOR_grant_table_op(GNTTABOP_setup_table, &setup, 1); - return map_frames(frames, nr_grant_frames); -} - -void arch_suspend_gnttab(grant_entry_v1_t *gnttab_table, int nr_grant_fram= es) -{ -#ifdef CONFIG_PARAVIRT - int i; - - for (i =3D 0; i < nr_grant_frames; i++) { - HYPERVISOR_update_va_mapping((unsigned long)(((char *)gnttab_table= ) + PAGE_SIZE * i), - (pte_t){0x0<