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