From patchwork Mon Jan 6 15:54:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 11319629 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 AAE271398 for ; Mon, 6 Jan 2020 15:55:39 +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 871DC20707 for ; Mon, 6 Jan 2020 15:55:39 +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="Q0Uyzudm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 871DC20707 Authentication-Results: mail.kernel.org; dmarc=fail (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 1ioUiD-0003lY-ER; Mon, 06 Jan 2020 15:54:37 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ioUiC-0003l9-1D for xen-devel@lists.xenproject.org; Mon, 06 Jan 2020 15:54:36 +0000 X-Inumbo-ID: d1065614-309c-11ea-88e7-bc764e2007e4 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id d1065614-309c-11ea-88e7-bc764e2007e4; Mon, 06 Jan 2020 15:54:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1578326068; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xYfBLpw32z+8phIUb6UyBrgOMhXwXqKmYQ6j0RSoVgo=; b=Q0UyzudmIDlVB3s2laH7j/GhtlfKA4tjdmRC6S7LVFNG2RNVp/K6t0Q1 DvXeFlu387ucESx/ACxc2W+OdROCr/DF0lRAnNK1u5Gg0fMSzE44HXCZb PkQOrJJNuonVPYYMp/UMd6xHF33gwU8Y0lHDyW3KiSGuSp0mWlfkmIwle c=; Authentication-Results: esa3.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 (esa3.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=esa3.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa3.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=esa3.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 ip4:168.245.78.127 ~all" Received-SPF: None (esa3.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=esa3.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: FImzxF74mPcHwTMwNZa34I5ddaRUqEQucfT6klwWMuC6SakfRmfe+1Uw1QKy8i/dCyEGusjF5X NKPKL+z6cMO10wejkZ06vcb7tjtV03ZB98WLdm/ueEZBI6BloVxJSVKv2z0WAxvEVYO5Xur5cc fUtmEXAr+PRH1WD/dWkzsE4fRsbg9avUdfeElllvgzBjmQdwI5DvHh6rY7PP3hi05eMbeFqYAm YtMGULcksm4o1lkPg1q5d/NU05mcL4/mmv7qt/DtfYtTzaI96G+6OBe6dqVTC7R3p5ifCklH01 u3o= X-SBRS: 2.7 X-MesageID: 10489150 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,403,1571716800"; d="scan'208";a="10489150" From: Andrew Cooper To: Xen-devel Date: Mon, 6 Jan 2020 15:54:18 +0000 Message-ID: <20200106155423.9508-2-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200106155423.9508-1-andrew.cooper3@citrix.com> References: <20200106155423.9508-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 1/6] x86/boot: Check for E820_RAM earlier when searching the E820 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" There is no point performing the masking calculations if we are going to throw the result away. No functional change. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monné --- xen/arch/x86/setup.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 501f3f5e4b..ed54f79fea 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1033,11 +1033,14 @@ void __init noreturn __start_xen(unsigned long mbi_p) uint64_t s, e, mask = (1UL << L2_PAGETABLE_SHIFT) - 1; uint64_t end, limit = ARRAY_SIZE(l2_identmap) << L2_PAGETABLE_SHIFT; + if ( boot_e820.map[i].type != E820_RAM ) + continue; + /* Superpage-aligned chunks from BOOTSTRAP_MAP_BASE. */ s = (boot_e820.map[i].addr + mask) & ~mask; e = (boot_e820.map[i].addr + boot_e820.map[i].size) & ~mask; s = max_t(uint64_t, s, BOOTSTRAP_MAP_BASE); - if ( (boot_e820.map[i].type != E820_RAM) || (s >= e) ) + if ( s >= e ) continue; if ( s < limit ) @@ -1286,11 +1289,14 @@ void __init noreturn __start_xen(unsigned long mbi_p) uint64_t s, e, mask = PAGE_SIZE - 1; uint64_t map_s, map_e; + if ( boot_e820.map[i].type != E820_RAM ) + continue; + /* Only page alignment required now. */ s = (boot_e820.map[i].addr + mask) & ~mask; e = (boot_e820.map[i].addr + boot_e820.map[i].size) & ~mask; s = max_t(uint64_t, s, 1<<20); - if ( (boot_e820.map[i].type != E820_RAM) || (s >= e) ) + if ( s >= e ) continue; if ( !acpi_boot_table_init_done && From patchwork Mon Jan 6 15:54:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 11319631 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 C6F291398 for ; Mon, 6 Jan 2020 15:55:42 +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 A3F0320707 for ; Mon, 6 Jan 2020 15:55:42 +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="Plq+4N5Z" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A3F0320707 Authentication-Results: mail.kernel.org; dmarc=fail (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 1ioUiA-0003kW-Uq; Mon, 06 Jan 2020 15:54:34 +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.89) (envelope-from ) id 1ioUi8-0003kA-Tr for xen-devel@lists.xenproject.org; Mon, 06 Jan 2020 15:54:32 +0000 X-Inumbo-ID: d0c5a7eb-309c-11ea-ab26-12813bfff9fa Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id d0c5a7eb-309c-11ea-ab26-12813bfff9fa; Mon, 06 Jan 2020 15:54:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1578326069; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=L1QQNGdVLsqA8MSMRT0Tt/3LuVFoJTdQw8tSLXWITNY=; b=Plq+4N5ZuWmBRcG+h6Q2Z27yWLnhK0/2gfAEGEisBh1tw/Uy0p/fI1mw kXXOYXKTfbU48Vm4FP4O8vrAHcnJ8zNqO7gZA9F1VcqRP58HE+RfvoSI6 iuHRUwxo21Yntldy6V0soXHCCCS2y53fep/KdYHidLwgkiUNUNZbKDVqX c=; Authentication-Results: esa2.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 (esa2.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=esa2.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa2.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=esa2.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 ip4:168.245.78.127 ~all" Received-SPF: None (esa2.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=esa2.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: OvLEHby7a+9edCimvODcdR0KiS6pIqhKywKkrI8BaLp8jatGcizTf05GmFrYQYJzVDHyHoP3cK mTe8qKEwVc+QtNVmYx8vdMN2xCex6hf/sJZmszs8WV0GJMIN0nPRfv2Bm8vjivkFKxywmLRhhQ pbk6isbkTC7xGJZCKkV2kgFfJ1WgVA6WRM7DveKKBvYxKYTy4vyYMNzJF3n6duv+W7IOcDEyls LnvhsUVPzotDYcY3XInQ91AndvSW5361gyX2tAbn3LjSRnvj3+leNEG86Z44x2XbmJOK9zyF6u zxo= X-SBRS: 2.7 X-MesageID: 10517689 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,403,1571716800"; d="scan'208";a="10517689" From: Andrew Cooper To: Xen-devel Date: Mon, 6 Jan 2020 15:54:19 +0000 Message-ID: <20200106155423.9508-3-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200106155423.9508-1-andrew.cooper3@citrix.com> References: <20200106155423.9508-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 2/6] x86/boot: Map the trampoline as read-only 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" c/s ec92fcd1d08, which caused the trampoline GDT Access bits to be set, removed the final writes which occurred between enabling paging and switching to the high mappings. There don't plausibly need to be any memory writes in few instructions is takes to perform this transition. As a consequence, we can remove the RWX mapping of the trampoline. It is RX via its identity mapping below 1M, and RW via the directmap. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monné This probably wants backporting, alongside ec92fcd1d08 if it hasn't yet. --- xen/arch/x86/x86_64/mm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c index 8ea09ecc30..b7ce833ffc 100644 --- a/xen/arch/x86/x86_64/mm.c +++ b/xen/arch/x86/x86_64/mm.c @@ -699,7 +699,7 @@ void __init zap_low_mappings(void) /* Replace with mapping of the boot trampoline only. */ map_pages_to_xen(trampoline_phys, maddr_to_mfn(trampoline_phys), PFN_UP(trampoline_end - trampoline_start), - __PAGE_HYPERVISOR); + __PAGE_HYPERVISOR_RX); } int setup_compat_arg_xlat(struct vcpu *v) From patchwork Mon Jan 6 15:54:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 11319635 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 0B7C914B4 for ; Mon, 6 Jan 2020 15:55: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 DBBE320707 for ; Mon, 6 Jan 2020 15:55:45 +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="LCK6xg1G" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DBBE320707 Authentication-Results: mail.kernel.org; dmarc=fail (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 1ioUiF-0003mc-P0; Mon, 06 Jan 2020 15:54:39 +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.89) (envelope-from ) id 1ioUiD-0003lm-Ti for xen-devel@lists.xenproject.org; Mon, 06 Jan 2020 15:54:37 +0000 X-Inumbo-ID: d0c5a7ec-309c-11ea-ab26-12813bfff9fa Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id d0c5a7ec-309c-11ea-ab26-12813bfff9fa; Mon, 06 Jan 2020 15:54:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1578326069; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/8W5g4vOA3z/8TR1C4yHX1N/uH6j+GeIH0yj4PsKNjo=; b=LCK6xg1GeUGf7Z5BkRv54CeW2mkHDEoHJk7R2H1xaQgclreB8juE+wKV IXfuQ9WWcDYwRHMBT9dGrsemAhDhkX34E5Lcbk8gGT0FP0bpF2x0KqzHe hM/ytC9ZNHs8UlQI5wdRxg06ftvRA0fFbLkALoiD200Fug7SUY+S8g3VU E=; Authentication-Results: esa3.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 (esa3.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=esa3.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa3.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=esa3.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 ip4:168.245.78.127 ~all" Received-SPF: None (esa3.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=esa3.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: KYgh+/6aKME6B1TEZsOW63O0O8PHDxryU+HLeRU8jsVoJXszoRUkh/celBQ1odzQMoHJK0CK/o uJY/6LGxpMzzYOP7KCqzd2oUNmGYUZh+8g5ZDUXy1HqbxT+te/PNgPjm/gdDIFHmLrOVz2rY1e DIkW/WYen+aT/bCSiQFd21QZTnJ+la+z1y8L5iHpBxKdLYJ+ibPFnhA2RKMQ7NkGguEu09klL2 N+GFW43+1wLeNEjUjkPLc7uXC/G0/GpNoSCTa67a2N8yY5O3Krl4eSt9MxD8JcxnnjxitMfAaT 7+Q= X-SBRS: 2.7 X-MesageID: 10489151 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,403,1571716800"; d="scan'208";a="10489151" From: Andrew Cooper To: Xen-devel Date: Mon, 6 Jan 2020 15:54:20 +0000 Message-ID: <20200106155423.9508-4-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200106155423.9508-1-andrew.cooper3@citrix.com> References: <20200106155423.9508-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 3/6] x86/boot: Remove the preconstructed low 16M superpage mappings 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" First, it is undefined to have superpages and MTRRs disagree on cacheability boundaries, and nothing this early in boot has checked that it is safe to use superpages here. Furthermore, nothing actually uses the mappings on boot. Build these entries in the directmap when walking the E820 table along with everything else. As a consequence, there are now no _PAGE_PRESENT entries between __page_tables_{start,end} which need to skip relocation. This simplifies the MB1/2 entry path logic to remove the l2_identmap[] special case. The low 2M (using 4k pages) is retained for now. Signed-off-by: Andrew Cooper --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monné --- xen/arch/x86/boot/head.S | 10 ++-------- xen/arch/x86/boot/x86_64.S | 17 ++++++----------- xen/arch/x86/setup.c | 12 ++++++------ xen/arch/x86/x86_64/asm-offsets.c | 3 --- 4 files changed, 14 insertions(+), 28 deletions(-) diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S index 8d0ffbd1b0..7ee4511e26 100644 --- a/xen/arch/x86/boot/head.S +++ b/xen/arch/x86/boot/head.S @@ -661,15 +661,9 @@ trampoline_setup: mov %eax,sym_fs(boot_tsc_stamp) mov %edx,sym_fs(boot_tsc_stamp)+4 - /* - * Update frame addresses in page tables excluding l2_identmap - * without its first entry which points to l1_identmap. - */ + /* Relocate pagetables to point at Xen's current location in memory. */ mov $((__page_tables_end-__page_tables_start)/8),%ecx - mov $(((l2_identmap-__page_tables_start)/8)+1),%edx -1: cmp $((l2_identmap+l2_identmap_sizeof-__page_tables_start)/8),%ecx - cmove %edx,%ecx - testl $_PAGE_PRESENT,sym_fs(__page_tables_start)-8(,%ecx,8) +1: testl $_PAGE_PRESENT,sym_fs(__page_tables_start)-8(,%ecx,8) jz 2f add %esi,sym_fs(__page_tables_start)-8(,%ecx,8) 2: loop 1b diff --git a/xen/arch/x86/boot/x86_64.S b/xen/arch/x86/boot/x86_64.S index b54d3aceea..30c82f9d5c 100644 --- a/xen/arch/x86/boot/x86_64.S +++ b/xen/arch/x86/boot/x86_64.S @@ -66,24 +66,19 @@ l1_identmap: .size l1_identmap, . - l1_identmap /* - * __page_tables_start does not cover l1_identmap because it (l1_identmap) - * contains 1-1 mappings. This means that frame addresses of these mappings - * are static and should not be updated at runtime. + * __page_tables_{start,end} cover the range of pagetables which need + * relocating as Xen moves around physical memory. i.e. each sym_offs() + * reference to a different pagetable in the Xen image. */ GLOBAL(__page_tables_start) /* - * Space for mapping the first 4GB of memory, with the first 16 megabytes - * actualy mapped (mostly using superpages). Uses 4x 4k pages. + * Space for 4G worth of 2M mappings, first 2M actually mapped via + * l1_identmap[]. Uses 4x 4k pages. */ GLOBAL(l2_identmap) .quad sym_offs(l1_identmap) + __PAGE_HYPERVISOR - idx = 1 - .rept 7 - .quad (idx << L2_PAGETABLE_SHIFT) | PAGE_HYPERVISOR | _PAGE_PSE - idx = idx + 1 - .endr - .fill 4 * L2_PAGETABLE_ENTRIES - 8, 8, 0 + .fill 4 * L2_PAGETABLE_ENTRIES - 1, 8, 0 .size l2_identmap, . - l2_identmap /* diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index ed54f79fea..452f5bdd37 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1020,8 +1020,8 @@ void __init noreturn __start_xen(unsigned long mbi_p) * * We require superpage alignment because the boot allocator is * not yet initialised. Hence we can only map superpages in the - * address range BOOTSTRAP_MAP_BASE to 4GB, as this is guaranteed - * not to require dynamic allocation of pagetables. + * address range 2MB to 4GB, as this is guaranteed not to require + * dynamic allocation of pagetables. * * As well as mapping superpages in that range, in preparation for * initialising the boot allocator, we also look for a region to which @@ -1036,10 +1036,10 @@ void __init noreturn __start_xen(unsigned long mbi_p) if ( boot_e820.map[i].type != E820_RAM ) continue; - /* Superpage-aligned chunks from BOOTSTRAP_MAP_BASE. */ + /* Superpage-aligned chunks from 2MB. */ s = (boot_e820.map[i].addr + mask) & ~mask; e = (boot_e820.map[i].addr + boot_e820.map[i].size) & ~mask; - s = max_t(uint64_t, s, BOOTSTRAP_MAP_BASE); + s = max_t(uint64_t, s, MB(2)); if ( s >= e ) continue; @@ -1346,8 +1346,8 @@ void __init noreturn __start_xen(unsigned long mbi_p) set_pdx_range(s >> PAGE_SHIFT, e >> PAGE_SHIFT); - /* Need to create mappings above BOOTSTRAP_MAP_BASE. */ - map_s = max_t(uint64_t, s, BOOTSTRAP_MAP_BASE); + /* Need to create mappings above 2MB. */ + map_s = max_t(uint64_t, s, MB(2)); map_e = min_t(uint64_t, e, ARRAY_SIZE(l2_identmap) << L2_PAGETABLE_SHIFT); diff --git a/xen/arch/x86/x86_64/asm-offsets.c b/xen/arch/x86/x86_64/asm-offsets.c index f9cb78cfdb..07d2155bf5 100644 --- a/xen/arch/x86/x86_64/asm-offsets.c +++ b/xen/arch/x86/x86_64/asm-offsets.c @@ -165,8 +165,5 @@ void __dummy__(void) OFFSET(MB2_efi64_ih, multiboot2_tag_efi64_ih_t, pointer); BLANK(); - DEFINE(l2_identmap_sizeof, sizeof(l2_identmap)); - BLANK(); - OFFSET(DOMAIN_vm_assist, struct domain, vm_assist); } From patchwork Mon Jan 6 15:54:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 11319639 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 D29651398 for ; Mon, 6 Jan 2020 15:55:56 +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 AF3B920707 for ; Mon, 6 Jan 2020 15:55:56 +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="SE6a04X+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AF3B920707 Authentication-Results: mail.kernel.org; dmarc=fail (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 1ioUiW-0003wU-Qb; Mon, 06 Jan 2020 15:54:56 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ioUiV-0003vr-Uf for xen-devel@lists.xenproject.org; Mon, 06 Jan 2020 15:54:55 +0000 X-Inumbo-ID: dcdb1204-309c-11ea-b6f1-bc764e2007e4 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id dcdb1204-309c-11ea-b6f1-bc764e2007e4; Mon, 06 Jan 2020 15:54:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1578326087; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CoPi2cu0FEnqJ+0mJtkSllKmwQGLHCI4qHXbgth2kPo=; b=SE6a04X+NUxNuu/GYgbx1pv4GwegiXKUUmtA21KLUmpkOfxnZTzfyb38 FokwEUgrmHlKFsgLPwV0IWlfjZBx4SXmWbaKiJ2fQ9ZDDdi21UCPrVLbP 5hskGAvo9YpG7WIKLLH2HWp2P0auhigJMX3MEwvg0rNzbiqDRavGnTg2c U=; 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 ip4:168.245.78.127 ~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: 9sJA1sd1VP/qY3YdTOC3D6h6lSpOWTBuhkStlUMFNMLTc5QO4pLJdxvp1YiJcClOpY71WprMiz we8qh7sxEVtPgAyaAfJGkzCITbBFAPqyO6bv5eeNTaS6rHR4jxhppCWGu8+S7hptF+ORXz+hL0 QuZrv5axtBWDEwV+iBOVLZKPze5LS/ux2Ea4LEtlTL16xs//yxrCUHnEuGEe3aFjquWupV6Tkd QwS4rwzlbU/3SeJWsfFfFB2Lr9xifo5Xr0Goiiuk6VRQmhWN+WDV5YxHbZMupy7q1n3HBH+ngw txE= X-SBRS: 2.7 X-MesageID: 10655810 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.69,403,1571716800"; d="scan'208";a="10655810" From: Andrew Cooper To: Xen-devel Date: Mon, 6 Jan 2020 15:54:21 +0000 Message-ID: <20200106155423.9508-5-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200106155423.9508-1-andrew.cooper3@citrix.com> References: <20200106155423.9508-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 4/6] x86/boot: Clean up l?_bootmap[] construction 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" The need for Xen to be identity mapped into the bootmap is not obvious, and differs between the MB and EFI boot paths. Furthermore, the EFI side is further complicated by spraying non-identity aliases into the mix. Simplify the EFI bootmap construction code to make exactly one identity-map of Xen, which now matches the MB path. Comment both pieces of logic, explaining what the mappings are needed for. Finally, leave a linker assert covering the fact that plenty of code blindly assumes that Xen is less that 16M. This wants fixing in due course. Signed-off-by: Andrew Cooper --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monné The MB path's dependency on Xen's identity mapping can be broken by having trampoline_boot_cpu_entry switch the alias of gdt_48 it uses. I took this approach first in an attempt to drop the bootmap entirely, but it is incompatible with the EFI path, and would also work against other plans to avoid using the trampoline during early boot. --- xen/arch/x86/boot/head.S | 8 ++++++-- xen/arch/x86/efi/efi-boot.h | 17 ++++++++++------- xen/arch/x86/xen.lds.S | 3 +++ 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S index 7ee4511e26..f7d273ca36 100644 --- a/xen/arch/x86/boot/head.S +++ b/xen/arch/x86/boot/head.S @@ -668,7 +668,11 @@ trampoline_setup: add %esi,sym_fs(__page_tables_start)-8(,%ecx,8) 2: loop 1b - /* Initialize L2 boot-map/direct map page table entries (16MB). */ + /* + * Map Xen into the directmap (needed for early-boot pagetable + * handling/walking), and identity map Xen into bootmap (needed for + * the transition into long mode), using 2M superpages. + */ lea sym_esi(start),%ebx lea (1<> L2_PAGETABLE_SHIFT) + i; paddr_t addr = slot << L2_PAGETABLE_SHIFT; l2_identmap[slot] = l2e_from_paddr(addr, PAGE_HYPERVISOR|_PAGE_PSE); - slot &= L2_PAGETABLE_ENTRIES - 1; l2_bootmap[slot] = l2e_from_paddr(addr, __PAGE_HYPERVISOR|_PAGE_PSE); } - /* Initialise L3 boot-map page directory entries. */ - l3_bootmap[l3_table_offset(xen_phys_start)] = - l3e_from_paddr((UINTN)l2_bootmap, __PAGE_HYPERVISOR); - l3_bootmap[l3_table_offset(xen_phys_start + (8 << L2_PAGETABLE_SHIFT) - 1)] = - l3e_from_paddr((UINTN)l2_bootmap, __PAGE_HYPERVISOR); + + /* Initialize L3 boot-map page directory entries. */ + for ( i = 0; i < 4; ++i ) + l3_bootmap[i] = l3e_from_paddr((UINTN)l2_bootmap + i * PAGE_SIZE, + __PAGE_HYPERVISOR); } static void __init efi_arch_handle_module(struct file *file, const CHAR16 *name, diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S index 111edb5360..7f82f64078 100644 --- a/xen/arch/x86/xen.lds.S +++ b/xen/arch/x86/xen.lds.S @@ -381,3 +381,6 @@ ASSERT((trampoline_end - trampoline_start) < TRAMPOLINE_SPACE - MBI_SPACE_MIN, "not enough room for trampoline and mbi data") ASSERT((wakeup_stack - wakeup_stack_start) >= WAKEUP_STACK_MIN, "wakeup stack too small") + +/* Plenty of boot code assumes that Xen isn't larger than 16M. */ +ASSERT(_end - _start <= MB(16), "Xen too large for early-boot assumptions") From patchwork Mon Jan 6 15:54:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 11319633 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 3D2D114B4 for ; Mon, 6 Jan 2020 15:55:43 +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 1996C20707 for ; Mon, 6 Jan 2020 15:55:43 +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="P8iF7fZW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1996C20707 Authentication-Results: mail.kernel.org; dmarc=fail (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 1ioUiK-0003og-2p; Mon, 06 Jan 2020 15:54:44 +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.89) (envelope-from ) id 1ioUiI-0003o9-Tm for xen-devel@lists.xenproject.org; Mon, 06 Jan 2020 15:54:42 +0000 X-Inumbo-ID: d1c08b1b-309c-11ea-ab26-12813bfff9fa Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id d1c08b1b-309c-11ea-ab26-12813bfff9fa; Mon, 06 Jan 2020 15:54:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1578326069; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qZVPVwir7bLZw5ZKa9vwUz0eJJ+dk54YhfDW7I8fu8c=; b=P8iF7fZWV5fqFkJ8uCeJU0JKLBWvR51g+AdHMubhjPhUpvzDjH6mNTlB m5isBURrKUkmJ5VaalxRbRzqjm5WzZhbwF813/BV+Wb7YS37gW0jXxEbI Z7L3Bc7jFCOU6pCaE8/GHmL/blEK/+X7R8KNqGd4qNaA97GuY05rGiUN7 k=; Authentication-Results: esa4.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 (esa4.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=esa4.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa4.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=esa4.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 ip4:168.245.78.127 ~all" Received-SPF: None (esa4.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=esa4.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: bDytRq5n+jQWqQQoa+RKowBU+pHrBaOavz7/6h9xPUot4tp8y7SYTTWA+jaqLk86NHi5mX4Dge VCZ3K3ka1Zu7IBim38f2oBs6w5aC1D74QZSmAnVv/+pUYEpdEStSM9UX1cA3kV7nk1nPQ8qXbf VHBuaH4zjAesh/k8xF38zxAeFp22whsgDkuS6k6/OmWvDD9cBG+TN44A7qiUWKuas3/UoJz2sL op3jAnrMLTxN1AdOTMdNcC/kMKKG9gTqg1FnyBLqpEs1WZZDdIulQJZI9kQKO/bMr9Scf5Ah1S /rY= X-SBRS: 2.7 X-MesageID: 11092611 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,403,1571716800"; d="scan'208";a="11092611" From: Andrew Cooper To: Xen-devel Date: Mon, 6 Jan 2020 15:54:22 +0000 Message-ID: <20200106155423.9508-6-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200106155423.9508-1-andrew.cooper3@citrix.com> References: <20200106155423.9508-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 5/6] x86/boot: Don't map 0 during 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 Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" In particular, it causes accidental NULL pointer dereferences to go unnoticed. The majority of the early operation takes place either in Real mode, or Protected Unpaged mode. The only bit which requires pagetable mappings is the trampoline transition into Long mode and jump to the higher mappings, so there is no need for the whole bottom 2M to be mapped. Introduce a new l1_bootmap in .init.data, and use it instead of l1_identmap. The EFI boot path doesn't pass through the trampoline, so doesn't need any adjustment. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monné --- xen/arch/x86/boot/head.S | 15 +++++++++------ xen/arch/x86/boot/x86_64.S | 4 ++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S index f7d273ca36..b338d4ba5c 100644 --- a/xen/arch/x86/boot/head.S +++ b/xen/arch/x86/boot/head.S @@ -689,12 +689,15 @@ trampoline_setup: sub $(L2_PAGETABLE_ENTRIES*8),%eax loop 1b - /* - * During boot, hook 4kB mappings of first 2MB of memory into L2. - * This avoids mixing cachability for the legacy VGA region. - */ - lea __PAGE_HYPERVISOR+sym_esi(l1_identmap),%edi - mov %edi,sym_fs(l2_bootmap) + /* Map the permentant trampoline page into l{1,2}_bootmap[]. */ + mov sym_esi(trampoline_phys), %edx + mov %edx, %ecx + or $__PAGE_HYPERVISOR_RX, %edx /* %edx = PTE to write */ + shr $PAGE_SHIFT, %ecx /* %ecx = Slot to write */ + mov %edx, sym_offs(l1_bootmap)(%esi, %ecx, 8) + + lea __PAGE_HYPERVISOR + sym_esi(l1_bootmap), %edx + mov %edx, sym_offs(l2_bootmap)(%esi) /* Apply relocations to bootstrap trampoline. */ mov sym_fs(trampoline_phys),%edx diff --git a/xen/arch/x86/boot/x86_64.S b/xen/arch/x86/boot/x86_64.S index 30c82f9d5c..e0763a90e3 100644 --- a/xen/arch/x86/boot/x86_64.S +++ b/xen/arch/x86/boot/x86_64.S @@ -156,6 +156,10 @@ GLOBAL(__page_tables_end) .section .init.data, "aw", @progbits .align PAGE_SIZE, 0 +l1_bootmap: + .fill L1_PAGETABLE_ENTRIES, 8, 0 + .size l1_bootmap, . - l1_bootmap + GLOBAL(l2_bootmap) .fill 4 * L2_PAGETABLE_ENTRIES, 8, 0 .size l2_bootmap, . - l2_bootmap From patchwork Mon Jan 6 15:54:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 11319637 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 7581A1398 for ; Mon, 6 Jan 2020 15:55:47 +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 51D0920707 for ; Mon, 6 Jan 2020 15:55:47 +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="hLDtWOEa" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 51D0920707 Authentication-Results: mail.kernel.org; dmarc=fail (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 1ioUiO-0003rL-FU; Mon, 06 Jan 2020 15:54:48 +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.89) (envelope-from ) id 1ioUiN-0003r5-Tt for xen-devel@lists.xenproject.org; Mon, 06 Jan 2020 15:54:47 +0000 X-Inumbo-ID: d1c08b1d-309c-11ea-ab26-12813bfff9fa Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id d1c08b1d-309c-11ea-ab26-12813bfff9fa; Mon, 06 Jan 2020 15:54:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1578326070; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=txX+kNmVQApOldC7zBN7Z5xlDpAhIMo8lfoF5L/PkrE=; b=hLDtWOEaElzYxLoLoheO38RZIPTB8WQ78RkeIR5hP/akPuIBO3nYfJCC yaYGL0hym7bYggb+J010F9+bsi2jGlzQuOjY/UhV1vRs3upwXr8ZxNdwb NxnvIRmxyqmsLBSADzAaB7N3yhHE9w4zyYHeAoISkmYlb+NlrEAxAXwBD k=; Authentication-Results: esa3.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 (esa3.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=esa3.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa3.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=esa3.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 ip4:168.245.78.127 ~all" Received-SPF: None (esa3.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=esa3.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: S5lUoonM/rq6AWq8txQM1THXAI6p9mnvDQr8tlBROtvupKjk4uAeyN4rf8OKAxbYqAwfGYboqc EPq7AROT9sAcT3dWa4Qk2KXTtsTKUau0chMW4ro922oSONP4QnchUbrhMxEo3cap6mQfG7ydeb mssQY5xfYuWsb6E3gadWMvmIBrlMbLS2SmaVgyTfJNkjYf420OtvVoL/QNDpP7mGA0II5IgLiv o1I1x7E7zVuizqMs1BfkPLBhZeiEFUMdV6YOFEKcabwYNDOHuRT4e5Kgg1k4Ab6ZNPnc6YoQ1S shw= X-SBRS: 2.7 X-MesageID: 10489152 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,403,1571716800"; d="scan'208";a="10489152" From: Andrew Cooper To: Xen-devel Date: Mon, 6 Jan 2020 15:54:23 +0000 Message-ID: <20200106155423.9508-7-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200106155423.9508-1-andrew.cooper3@citrix.com> References: <20200106155423.9508-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 6/6] x86/boot: Drop INVALID_VCPU 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" Now that NULL will fault at boot, there is no need for a special constant to signify "current not set up yet". Signed-off-by: Andrew Cooper --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monné --- xen/arch/x86/cpu/mcheck/mce.c | 2 +- xen/arch/x86/domain_page.c | 2 +- xen/arch/x86/setup.c | 2 +- xen/arch/x86/tboot.c | 2 +- xen/include/asm-x86/setup.h | 3 --- 5 files changed, 4 insertions(+), 7 deletions(-) diff --git a/xen/arch/x86/cpu/mcheck/mce.c b/xen/arch/x86/cpu/mcheck/mce.c index c8cecc4976..0c572b04f2 100644 --- a/xen/arch/x86/cpu/mcheck/mce.c +++ b/xen/arch/x86/cpu/mcheck/mce.c @@ -260,7 +260,7 @@ static int mca_init_global(uint32_t flags, struct mcinfo_global *mig) &mig->mc_coreid, &mig->mc_core_threadid, &mig->mc_apicid, NULL, NULL, NULL); - if ( curr != INVALID_VCPU ) + if ( curr ) { mig->mc_domid = curr->domain->domain_id; mig->mc_vcpuid = curr->vcpu_id; diff --git a/xen/arch/x86/domain_page.c b/xen/arch/x86/domain_page.c index 4a07cfb18e..dd32712d2f 100644 --- a/xen/arch/x86/domain_page.c +++ b/xen/arch/x86/domain_page.c @@ -29,7 +29,7 @@ static inline struct vcpu *mapcache_current_vcpu(void) * When current isn't properly set up yet, this is equivalent to * running in an idle vCPU (callers must check for NULL). */ - if ( v == INVALID_VCPU ) + if ( !v ) return NULL; /* diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 452f5bdd37..a7ca2236f4 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -705,7 +705,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) /* Critical region without IDT or TSS. Any fault is deadly! */ set_processor_id(0); - set_current(INVALID_VCPU); /* debug sanity. */ + set_current(NULL); /* debug sanity. */ idle_vcpu[0] = current; init_shadow_spec_ctrl_state(); diff --git a/xen/arch/x86/tboot.c b/xen/arch/x86/tboot.c index 3e828fe204..5020c4ad49 100644 --- a/xen/arch/x86/tboot.c +++ b/xen/arch/x86/tboot.c @@ -392,7 +392,7 @@ void tboot_shutdown(uint32_t shutdown_type) * During early boot, we can be called by panic before idle_vcpu[0] is * setup, but in that case we don't need to change page tables. */ - if ( idle_vcpu[0] != INVALID_VCPU ) + if ( idle_vcpu[0] ) write_ptbase(idle_vcpu[0]); ((void(*)(void))(unsigned long)g_tboot_shared->shutdown_entry)(); diff --git a/xen/include/asm-x86/setup.h b/xen/include/asm-x86/setup.h index 861d46d6ac..28257bc5c8 100644 --- a/xen/include/asm-x86/setup.h +++ b/xen/include/asm-x86/setup.h @@ -4,9 +4,6 @@ #include #include -/* vCPU pointer used prior to there being a valid one around */ -#define INVALID_VCPU ((struct vcpu *)0xccccccccccccc000UL) - extern const char __2M_text_start[], __2M_text_end[]; extern const char __2M_rodata_start[], __2M_rodata_end[]; extern char __2M_init_start[], __2M_init_end[];