From nobody Mon May 6 00:14:54 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=1619104237; cv=none; d=zohomail.com; s=zohoarc; b=d/jtebVawshBgz0zQkZS8ndyVtMNT/bVpQnAcAlK1e8H8nXLO8G/R3kKh0dS9oPWPqndGTrInNqlr3lO00qzXw/24Gr7b+DnRbQ0BdpDPcHaSXDxWZ+MYjCXC9KkiBBrhKYPgXGxGESilw6E2XnbAFgZyZxcsjXClRUcLxFKAnQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619104237; 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=dGYTI5hb6XF/TrVV+tK4E4xlOyG7i9BsqrnGlynZSJM=; b=mL/hOm01WaD2e07af66jQnXtA/Axxq+h3Tw8zOk3Vkq0tmmfRnFptRhydkboCIrtwN0UkafDA0byshJVgT8nI+IPsWJxihvUoO5kuqHfRxWAEFOqRbNDV5jKhZMLspZ35ZfT4SRRaxw5Bfk10eoN4OzfzybI7ZNwsfCEH54gdpY= 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 16191042368891016.9041420746588; Thu, 22 Apr 2021 08:10:36 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.115610.220623 (Exim 4.92) (envelope-from ) id 1lZayB-0000bR-Hi; Thu, 22 Apr 2021 15:10:19 +0000 Received: by outflank-mailman (output) from mailman id 115610.220623; Thu, 22 Apr 2021 15:10:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lZayB-0000bJ-Dp; Thu, 22 Apr 2021 15:10:19 +0000 Received: by outflank-mailman (input) for mailman id 115610; Thu, 22 Apr 2021 15:10:17 +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 1lZay9-0000Wn-GR for xen-devel@lists.xenproject.org; Thu, 22 Apr 2021 15:10:17 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id b288b233-aeff-4338-8886-6ef45220c371; Thu, 22 Apr 2021 15:10:11 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id E9411B16D; Thu, 22 Apr 2021 15:10:10 +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: b288b233-aeff-4338-8886-6ef45220c371 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=1619104211; 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=dGYTI5hb6XF/TrVV+tK4E4xlOyG7i9BsqrnGlynZSJM=; b=rkqpNHxQEq8IWYLVp0llAxNQCop0wQDhH19sDYwFQ1gk0VAjV4ZLRAnd/O5DophQu1UYRk pEiSJ2EiOmjVHzPlg2XnZBk5IWyblvtmK0qwMpFZl7499bg6QnKLQwCytl7FzyMM9fxSya SXO1bDbx/20HgyDjak27WeKH3lnP8Hs= 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 1/3] xen: check required Xen features Date: Thu, 22 Apr 2021 17:10:05 +0200 Message-Id: <20210422151007.2205-2-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210422151007.2205-1-jgross@suse.com> References: <20210422151007.2205-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" Linux kernel is not supported to run on Xen versions older than 4.0. Add tests for required Xen features always being present in Xen 4.0 and newer. Signed-off-by: Juergen Gross Acked-by: Peter Zijlstra (Intel) --- drivers/xen/features.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/xen/features.c b/drivers/xen/features.c index 25c053b09605..60503299c9bc 100644 --- a/drivers/xen/features.c +++ b/drivers/xen/features.c @@ -9,13 +9,26 @@ #include #include #include +#include =20 #include =20 +#include #include #include #include =20 +/* + * Linux kernel expects at least Xen 4.0. + * + * Assume some features to be available for that reason (depending on guest + * mode, of course). + */ +#define chk_feature(f) { \ + if (!xen_feature(f)) \ + pr_err("Xen: feature %s not available!\n", #f); \ + } + u8 xen_features[XENFEAT_NR_SUBMAPS * 32] __read_mostly; EXPORT_SYMBOL_GPL(xen_features); =20 @@ -31,4 +44,9 @@ void xen_setup_features(void) for (j =3D 0; j < 32; j++) xen_features[i * 32 + j] =3D !!(fi.submap & 1< (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 1619104237959303.58433612575004; Thu, 22 Apr 2021 08:10:37 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.115611.220628 (Exim 4.92) (envelope-from ) id 1lZayB-0000by-RB; Thu, 22 Apr 2021 15:10:19 +0000 Received: by outflank-mailman (output) from mailman id 115611.220628; Thu, 22 Apr 2021 15:10:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lZayB-0000bm-Lt; Thu, 22 Apr 2021 15:10:19 +0000 Received: by outflank-mailman (input) for mailman id 115611; Thu, 22 Apr 2021 15:10:17 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lZay9-0000Ws-Ss for xen-devel@lists.xenproject.org; Thu, 22 Apr 2021 15:10:17 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 4c23aae1-91cf-4201-9b32-06884c40c148; Thu, 22 Apr 2021 15:10:12 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 347DEB173; Thu, 22 Apr 2021 15:10:11 +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: 4c23aae1-91cf-4201-9b32-06884c40c148 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=1619104211; 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=BkJA52UJuORwrXbRo8O+/xjjRU0ufo7MZuM5MyCQmjA=; b=CajF134GHN/RbxqiBB/w3atAlNOGdArNwDekAEHKBqOq4v1nRKEOWd8ExSJVO7QyBQRCth ZYn38ypxpyNUQTUfJkWfB0bemGaMLUEISnXe/il8XYc243is2loOvk16Dkjt14VllIaXmm lVEWuVR4bDQVCE/f9TeGxpHMvzi/l98= From: Juergen Gross To: xen-devel@lists.xenproject.org, x86@kernel.org, linux-kernel@vger.kernel.org Cc: Juergen Gross , Boris Ostrovsky , Stefano Stabellini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Peter Zijlstra Subject: [PATCH 2/3] xen: assume XENFEAT_mmu_pt_update_preserve_ad being set for pv guests Date: Thu, 22 Apr 2021 17:10:06 +0200 Message-Id: <20210422151007.2205-3-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210422151007.2205-1-jgross@suse.com> References: <20210422151007.2205-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" XENFEAT_mmu_pt_update_preserve_ad 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) --- arch/x86/xen/enlighten_pv.c | 12 ++---------- arch/x86/xen/mmu_pv.c | 4 ++-- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c index dc0a337f985b..e754927feac7 100644 --- a/arch/x86/xen/enlighten_pv.c +++ b/arch/x86/xen/enlighten_pv.c @@ -116,9 +116,8 @@ static void __init xen_banner(void) HYPERVISOR_xen_version(XENVER_extraversion, &extra); =20 pr_info("Booting paravirtualized kernel on %s\n", pv_info.name); - printk(KERN_INFO "Xen version: %d.%d%s%s\n", - version >> 16, version & 0xffff, extra.extraversion, - xen_feature(XENFEAT_mmu_pt_update_preserve_ad) ? " (preserve-AD)" = : ""); + pr_info("Xen version: %d.%d%s (preserve-AD)\n", + version >> 16, version & 0xffff, extra.extraversion); } =20 static void __init xen_pv_init_platform(void) @@ -1303,13 +1302,6 @@ asmlinkage __visible void __init xen_start_kernel(vo= id) xen_init_apic(); #endif =20 - if (xen_feature(XENFEAT_mmu_pt_update_preserve_ad)) { - pv_ops.mmu.ptep_modify_prot_start =3D - xen_ptep_modify_prot_start; - pv_ops.mmu.ptep_modify_prot_commit =3D - xen_ptep_modify_prot_commit; - } - machine_ops =3D xen_machine_ops; =20 /* diff --git a/arch/x86/xen/mmu_pv.c b/arch/x86/xen/mmu_pv.c index cf2ade864c30..359c711336a8 100644 --- a/arch/x86/xen/mmu_pv.c +++ b/arch/x86/xen/mmu_pv.c @@ -2100,8 +2100,8 @@ static const struct pv_mmu_ops xen_mmu_ops __initcons= t =3D { .set_pte =3D xen_set_pte_init, .set_pmd =3D xen_set_pmd_hyper, =20 - .ptep_modify_prot_start =3D __ptep_modify_prot_start, - .ptep_modify_prot_commit =3D __ptep_modify_prot_commit, + .ptep_modify_prot_start =3D xen_ptep_modify_prot_start, + .ptep_modify_prot_commit =3D xen_ptep_modify_prot_commit, =20 .pte_val =3D PV_CALLEE_SAVE(xen_pte_val), .pgd_val =3D PV_CALLEE_SAVE(xen_pgd_val), --=20 2.26.2 From nobody Mon May 6 00:14:54 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=1619104237; cv=none; d=zohomail.com; s=zohoarc; b=AEQrxYqDb2kMIL8EMPYkomzDJsJvccsbOEenRqkAv0cxPHDOgoqcWQrPgPC4odl74Az2K6tHDwr4mevxLlkQrZ9VjRQlwMvNmB8iUAdhxpn1LpvL1XALwY6iOuULoKxrCVwikVF9OJS6EkW/kjaSCtXJiF0C9tZL+AOcCXULb8Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619104237; 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=gTxz0RbWnUOZh4apGxwrsu84odP0er4fykNXzBAMpag=; b=ntLpiAqNiq3yR7VLKt4AmSV7m/zGdBm/In3ogrzrAXtiYDpxRwXbtqYoXw7x89CkA7MzDgh4yvDwP81yeM0CoCDPMRz1Idxtl1P0Znsgne1MDoL87pcmXujlQ8UV6UBKTTHhwjAqBrJOQjqFqUUEOszPorj5Yk0qKVkWejlvI8s= 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 16191042369031015.598688161119; Thu, 22 Apr 2021 08:10:36 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.115609.220605 (Exim 4.92) (envelope-from ) id 1lZay6-0000XV-B7; Thu, 22 Apr 2021 15:10:14 +0000 Received: by outflank-mailman (output) from mailman id 115609.220605; Thu, 22 Apr 2021 15:10:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lZay6-0000XG-56; Thu, 22 Apr 2021 15:10:14 +0000 Received: by outflank-mailman (input) for mailman id 115609; Thu, 22 Apr 2021 15:10:12 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lZay4-0000Ws-Tj for xen-devel@lists.xenproject.org; Thu, 22 Apr 2021 15:10:12 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 8ef3aeea-b69a-4323-9180-7bdaa8aa7ec1; Thu, 22 Apr 2021 15:10:12 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 63C6EB174; Thu, 22 Apr 2021 15:10:11 +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: 8ef3aeea-b69a-4323-9180-7bdaa8aa7ec1 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=1619104211; 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=gTxz0RbWnUOZh4apGxwrsu84odP0er4fykNXzBAMpag=; b=OX0bucQn5aKzgc3RTioNoOR5BErPdayoju9pA5S5pCYLyODdOwrADpSziKmUf+9lpeLHq/ 9Mf3LUt3Pz6e3HoQaDoc3vmW9oI3MwNlLswg5N8qCQBao4KAVZC3OEBWO7GVTKg5IwH9Ia GF/vmkAWug36+NLP+GZgc6yX11cDe8o= 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 3/3] xen: assume XENFEAT_gnttab_map_avail_bits being set for pv guests Date: Thu, 22 Apr 2021 17:10:07 +0200 Message-Id: <20210422151007.2205-4-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210422151007.2205-1-jgross@suse.com> References: <20210422151007.2205-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" 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 f01d58c7a042..93818816e137 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; @@ -1053,23 +1038,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