From nobody Fri Nov 29 23:59:04 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=1627629515; cv=none; d=zohomail.com; s=zohoarc; b=C9MrdChJ/eQg+BOjwkZc2md7NfRGdzHO5RjY/Z9Enk5ht8fXvc5mVDMvKSvthNOHepb8L6ZBPqxqImoi+mW+QUYEtWP92Lxme666Ep4Bn5d0Dvvie4PoMWx0B54quMNM39rGnPgxnsvFuj3BWmY1mZKLs68WiWT5ehhbrSk1RaE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1627629515; 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=cyZcoypMsiPyV5D5l5wSyscmkn1Z3KKgfGDueS4Lb8Q=; b=D/W/iA8rEHbY4pMyxTazoItL8O65caZzVJ5o+DWayTWIYoDf2HXCwWx32ziTzaWQ7TqRyBL+02vTr3Z357v7UAbpQ59o1mSFwc7yo2+Z70imQe09/ZEfhmvMaOdOud1rbyYSQUq0sU5CYAGwagmMzOUX2FDRzyfGyllb9/EtliM= 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 1627629515238179.7262955838488; Fri, 30 Jul 2021 00:18:35 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.162328.297763 (Exim 4.92) (envelope-from ) id 1m9Mmi-0007Ba-3g; Fri, 30 Jul 2021 07:18:20 +0000 Received: by outflank-mailman (output) from mailman id 162328.297763; Fri, 30 Jul 2021 07:18:20 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1m9Mmi-0007BP-07; Fri, 30 Jul 2021 07:18:20 +0000 Received: by outflank-mailman (input) for mailman id 162328; Fri, 30 Jul 2021 07:18:18 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1m9Mmg-0006Do-Gm for xen-devel@lists.xenproject.org; Fri, 30 Jul 2021 07:18:18 +0000 Received: from smtp-out2.suse.de (unknown [195.135.220.29]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 49f0c2d2-f106-11eb-9889-12813bfff9fa; Fri, 30 Jul 2021 07:18:08 +0000 (UTC) Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (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 7D68D2020B; Fri, 30 Jul 2021 07:18:07 +0000 (UTC) Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (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 imap1.suse-dmz.suse.de (Postfix) with ESMTPS id 4F3551374D; Fri, 30 Jul 2021 07:18:07 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id wAzgEa+nA2FufQAAGKfGzw (envelope-from ); Fri, 30 Jul 2021 07:18:07 +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: 49f0c2d2-f106-11eb-9889-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1627629487; 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=cyZcoypMsiPyV5D5l5wSyscmkn1Z3KKgfGDueS4Lb8Q=; b=GXcQ+AQRPZJ+G9sddnPaaK086EH9kpql9cfa/M7rnCoYYva1VeOrv39m3yuBfqLvG/hmtm zIL8dEPA2skQc0m4Gm69R5UdSDqG86/k0qiGUZPPoks7j7TRoCWxOS8ApDYgPOkchj5ycQ 9JaOXOFZXnkGxrtmQ4JVPg1/khQ7yaw= From: Juergen Gross To: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Cc: Juergen Gross , Boris Ostrovsky , Stefano Stabellini , Peter Zijlstra Subject: [PATCH v2 3/3] xen: assume XENFEAT_gnttab_map_avail_bits being set for pv guests Date: Fri, 30 Jul 2021 09:18:04 +0200 Message-Id: <20210730071804.4302-4-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210730071804.4302-1-jgross@suse.com> References: <20210730071804.4302-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1627629516797100001 Content-Type: text/plain; charset="utf-8" XENFEAT_gnttab_map_avail_bits is always set in Xen 4.0 and newer. Remove coding assuming it might be zero. Signed-off-by: Juergen Gross Acked-by: Peter Zijlstra (Intel) --- drivers/xen/gntdev.c | 36 ++---------------------------------- 1 file changed, 2 insertions(+), 34 deletions(-) diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c index a3e7be96527d..1e7f6b1c0c97 100644 --- a/drivers/xen/gntdev.c +++ b/drivers/xen/gntdev.c @@ -266,20 +266,13 @@ static int find_grant_ptes(pte_t *pte, unsigned long = addr, void *data) { struct gntdev_grant_map *map =3D data; unsigned int pgnr =3D (addr - map->vma->vm_start) >> PAGE_SHIFT; - int flags =3D map->flags | GNTMAP_application_map | GNTMAP_contains_pte; + int flags =3D map->flags | GNTMAP_application_map | GNTMAP_contains_pte | + (1 << _GNTMAP_guest_avail0); u64 pte_maddr; =20 BUG_ON(pgnr >=3D map->count); pte_maddr =3D arbitrary_virt_to_machine(pte).maddr; =20 - /* - * Set the PTE as special to force get_user_pages_fast() fall - * back to the slow path. If this is not supported as part of - * the grant map, it will be done afterwards. - */ - if (xen_feature(XENFEAT_gnttab_map_avail_bits)) - flags |=3D (1 << _GNTMAP_guest_avail0); - gnttab_set_map_op(&map->map_ops[pgnr], pte_maddr, flags, map->grants[pgnr].ref, map->grants[pgnr].domid); @@ -288,14 +281,6 @@ static int find_grant_ptes(pte_t *pte, unsigned long a= ddr, void *data) return 0; } =20 -#ifdef CONFIG_X86 -static int set_grant_ptes_as_special(pte_t *pte, unsigned long addr, void = *data) -{ - set_pte_at(current->mm, addr, pte, pte_mkspecial(*pte)); - return 0; -} -#endif - int gntdev_map_grant_pages(struct gntdev_grant_map *map) { int i, err =3D 0; @@ -1055,23 +1040,6 @@ static int gntdev_mmap(struct file *flip, struct vm_= area_struct *vma) err =3D vm_map_pages_zero(vma, map->pages, map->count); if (err) goto out_put_map; - } else { -#ifdef CONFIG_X86 - /* - * If the PTEs were not made special by the grant map - * hypercall, do so here. - * - * This is racy since the mapping is already visible - * to userspace but userspace should be well-behaved - * enough to not touch it until the mmap() call - * returns. - */ - if (!xen_feature(XENFEAT_gnttab_map_avail_bits)) { - apply_to_page_range(vma->vm_mm, vma->vm_start, - vma->vm_end - vma->vm_start, - set_grant_ptes_as_special, NULL); - } -#endif } =20 return 0; --=20 2.26.2