From patchwork Tue Aug 27 11:48:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Druzhinin X-Patchwork-Id: 11116759 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 930C31395 for ; Tue, 27 Aug 2019 11:49:46 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6D25B2173E for ; Tue, 27 Aug 2019 11:49:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="cp59d4wW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6D25B2173E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i2ZxL-0003w6-Hl; Tue, 27 Aug 2019 11:48:11 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i2ZxK-0003w1-7a for xen-devel@lists.xenproject.org; Tue, 27 Aug 2019 11:48:10 +0000 X-Inumbo-ID: 8a27a0ca-c8c0-11e9-8980-bc764e2007e4 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 8a27a0ca-c8c0-11e9-8980-bc764e2007e4; Tue, 27 Aug 2019 11:48:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1566906489; h=from:to:cc:subject:date:message-id:mime-version; bh=xQF4Doh6NDJnOkoiuhHA2YLyEFMGdmf6f9naygQWoo0=; b=cp59d4wWPUk8R/V0enqv2VFm/U/k4kMYzrStefzi3WGB5FeDLht1AJ7o fUIZqFYv36swnHNgmvSl5XxmwHRo+LKDTmHtt737sudy+iNf4MAtcT5sc 5M4zWPrffzubokZ7d5vjf4AWgWkTbRu2Mj+jbnuQwLCxUotJT4ghl7zPZ U=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=igor.druzhinin@citrix.com; spf=Pass smtp.mailfrom=igor.druzhinin@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa5.hc3370-68.iphmx.com: no sender authenticity information available from domain of igor.druzhinin@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="igor.druzhinin@citrix.com"; x-sender="igor.druzhinin@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa5.hc3370-68.iphmx.com: domain of igor.druzhinin@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="igor.druzhinin@citrix.com"; x-sender="igor.druzhinin@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ~all" Received-SPF: None (esa5.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="igor.druzhinin@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: KU0xJV+McsfTR8m5cY3NdW7gnLpK5CX31cJauLxbsQBuS0LeP7LsyJRXK6YJLklPA9ZUMkRP7u qn5mIKxbGpBlArfo9V7aiRo0LpsLSl5Nkvib1M7kmb4/5ffOjWvTSGrr2A/WVP8yV8ImWzt74Q ELJznKhnYzG4fzKXoW6KetF7EkJW1bNEwCLnvPy7EBwEaqOLhefGjZ1MLWetcTDyWIdrN6782q sdnfH2JLLYFUElkQUlWssJ7x2NgDmmM105H74nguGgNmUOafotGCzDBN0Ad+86KhrzRYFJqLAY dzw= X-SBRS: 2.7 X-MesageID: 4944202 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,437,1559534400"; d="scan'208";a="4944202" From: Igor Druzhinin To: Date: Tue, 27 Aug 2019 12:48:05 +0100 Message-ID: <1566906485-13731-1-git-send-email-igor.druzhinin@citrix.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Subject: [Xen-devel] [PATCH] x86/mm: correctly initialize M2P entries on boot X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: andrew.cooper3@citrix.com, Igor Druzhinin , wl@xen.org, jbeulich@suse.com, roger.pau@citrix.com Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Since guest resource management work it's now possible to have a page assigned to a domain without a valid M2P entry. Some pathes in the code rely on the fact a GFN returned from mfn_to_gfn() for such a page is not valid as well, i.e. see arch_iommu_populate_page_table(). For systems without 512GB contiguous RAM M2P entries were already correctly initialized on boot with INVALID_M2P_ENTRY (~0UL) but on systems where M2P could be covered by a single 1GB page directory 0x77 poison was used instead. That eventually resulted in a crash during IOMMU construction on systems without shared PTs enabled. While here fixup compat M2P entries as well. Signed-off-by: Igor Druzhinin Reviewed-by: Andrew Cooper --- xen/arch/x86/x86_64/mm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c index 1919cae..a741d4e 100644 --- a/xen/arch/x86/x86_64/mm.c +++ b/xen/arch/x86/x86_64/mm.c @@ -574,8 +574,9 @@ void __init paging_init(void) page_to_mfn(l1_pg), 1UL << (2 * PAGETABLE_ORDER), PAGE_HYPERVISOR); + /* Fill with INVALID_M2P_ENTRY. */ memset((void *)(RDWR_MPT_VIRT_START + (i << L2_PAGETABLE_SHIFT)), - 0x77, 1UL << L3_PAGETABLE_SHIFT); + 0xFF, 1UL << L3_PAGETABLE_SHIFT); ASSERT(!l2_table_offset(va)); /* NB. Cannot be GLOBAL: guest user mode should not see it. */ @@ -666,9 +667,10 @@ void __init paging_init(void) page_to_mfn(l1_pg), 1UL << PAGETABLE_ORDER, PAGE_HYPERVISOR); + /* Fill with INVALID_M2P_ENTRY. */ memset((void *)(RDWR_COMPAT_MPT_VIRT_START + (i << L2_PAGETABLE_SHIFT)), - 0x55, + 0xFF, 1UL << L2_PAGETABLE_SHIFT); /* NB. Cannot be GLOBAL as the ptes get copied into per-VM space. */ l2e_write(l2_ro_mpt, l2e_from_page(l1_pg, _PAGE_PSE|_PAGE_PRESENT));