From patchwork Thu Sep 5 19:04:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 11133817 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 5B0C2924 for ; Thu, 5 Sep 2019 19:05:52 +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 89CB8206BA for ; Thu, 5 Sep 2019 19:05:52 +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="TmycnDFq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 89CB8206BA 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 1i5x3Q-0001zy-9X; Thu, 05 Sep 2019 19:04:24 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i5x3P-0001zt-G2 for xen-devel@lists.xenproject.org; Thu, 05 Sep 2019 19:04:23 +0000 X-Inumbo-ID: f880337e-d00f-11e9-978d-bc764e2007e4 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id f880337e-d00f-11e9-978d-bc764e2007e4; Thu, 05 Sep 2019 19:04:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1567710263; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=hExIHzdIdg08QlNobWWYZCUCJXXAhRRk07yqRWjUBro=; b=TmycnDFqHSi2NVqCFWRghqXlaIx/BLV7OgOqQBXn0q6Ha/sVutgw/ZjN TzcmvBzBo6peThf8W/WUAoV8bViF1o+6P+GB+BOzmYYHgSX6g6svkvmks G0okUsKczygO3J9pNWpqC6ZXbJBgzKKxuqTYUaX9pHpw7ceZCLYb8jcm7 4=; Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@citrix.com; spf=Pass smtp.mailfrom=Andrew.Cooper3@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of andrew.cooper3@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.hc3370-68.iphmx.com: domain of Andrew.Cooper3@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="Andrew.Cooper3@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 (esa1.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=esa1.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: HNF69+ZlEYzbkpnHp34yC+WZsEMuHwFL0uUPr+kDuWndPIlfpC34u0dB9ywVRxQAni+f4Bao76 Dbd5MaAFeSXXmJbnwiMNfIt3bDxLprqnssxjr8aBIfcxTZlb7/uah9TqNt2scc4WRAZTVrjUSa hMOk661eds63YMifZ8sqF2vrx1O0+Zck2P1SOOpXoXGZViga8ZyashdQW0yFpYroi9xAh/3jtY 2apBBQ2sfPfKv5devIL4KWeu5573qH6fVxxM/JOB7Am3BLZnvEq5YArBxcut2Dunm07zMq4snM 0cQ= X-SBRS: 2.7 X-MesageID: 5252875 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,471,1559534400"; d="scan'208";a="5252875" From: Andrew Cooper To: Xen-devel Date: Thu, 5 Sep 2019 20:04:18 +0100 Message-ID: <20190905190418.15142-1-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Subject: [Xen-devel] [PATCH] x86/boot: Don't explicitly map the VGA region as UC- 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 Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" All 64-bit capable processors use PAT, and with PAT, it is explicitly permitted to have mappings with a cacheability different to MTRRs. On a native system with a real legacy VGA region, MTRRs will cause the region to be UC-. When booting virtualised, this range may be RAM and not a legacy VGA region, at which point it wants to be WB. Use WB mapping in the pagetables, such that in systems without a legacy VGA region, the RAM between 0xa0000 and 0xc0000 doesn't become unnecesserily UC-. However, we still must use small pages to avoid the undefined behaviour caused by superpages crossing MTRRs of different cacheability. While adjusting the pagetable construction, switch from pfn to idx for consistency with all the other construction logic. Signed-off-by: Andrew Cooper Reviewed-by: Roger Pau Monné --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monné As a future optimisation, Xen could rewrite l2_identmap with a superpage if it finds that MTRRs are disabled. However, this probably needs to wait until Xen no longer unconditionally assumes a legacy VGA region to be present in the e820 if it finds something other than a hole --- xen/arch/x86/boot/x86_64.S | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/xen/arch/x86/boot/x86_64.S b/xen/arch/x86/boot/x86_64.S index 5ab24d73fc..1ca986f882 100644 --- a/xen/arch/x86/boot/x86_64.S +++ b/xen/arch/x86/boot/x86_64.S @@ -51,19 +51,13 @@ GLOBAL(stack_start) /* * Mapping of first 2 megabytes of memory. This is mapped with 4kB mappings * to avoid type conflicts with fixed-range MTRRs covering the lowest megabyte - * of physical memory. In any case the VGA hole should be mapped with type UC. - * Uses 1x 4k page. + * of physical memory. Uses 1x 4k page. */ l1_identmap: - pfn = 0 + idx = 0 .rept L1_PAGETABLE_ENTRIES - /* VGA hole (0xa0000-0xc0000) should be mapped UC-. */ - .if pfn >= 0xa0 && pfn < 0xc0 - .quad (pfn << PAGE_SHIFT) | PAGE_HYPERVISOR_UCMINUS | MAP_SMALL_PAGES - .else - .quad (pfn << PAGE_SHIFT) | PAGE_HYPERVISOR | MAP_SMALL_PAGES - .endif - pfn = pfn + 1 + .quad (idx << PAGE_SHIFT) | PAGE_HYPERVISOR | MAP_SMALL_PAGES + idx = idx + 1 .endr .size l1_identmap, . - l1_identmap