From patchwork Thu Jan 9 19:32:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 11326347 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 F00C3109A for ; Thu, 9 Jan 2020 19:34:12 +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 CB8CE20721 for ; Thu, 9 Jan 2020 19:34:12 +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="iX1Pz4q/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CB8CE20721 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 1ipdYD-0001uB-Qd; Thu, 09 Jan 2020 19:33:01 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ipdYB-0001ti-Ry for xen-devel@lists.xenproject.org; Thu, 09 Jan 2020 19:32:59 +0000 X-Inumbo-ID: d049c2e8-3316-11ea-ac27-bc764e2007e4 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id d049c2e8-3316-11ea-ac27-bc764e2007e4; Thu, 09 Jan 2020 19:32:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1578598366; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TUgSJcvrtirnKoh5NZO7xoERz9S6nXrtyBnu1JNNQyo=; b=iX1Pz4q/Fag89XoA1aIp9djJZZZx+/2HkhLS4/kMuCmawf36PR4ZesiK 0WtexTTsYsRcdX665occOdi9HbzidIjYHetjjjkVVW2w8X9Xg2PjjFCOY dqrQi3/xkuQJ5aTj81m/sN66waJ/vhJ9D+V1IiltlIe9biysSsJPdV0YC E=; Authentication-Results: esa5.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 (esa5.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=esa5.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa5.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=esa5.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 (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="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: 9g+cp44T7LVkWnkx5tocdIhT2jPVosjMB+R3gL3eoKSvuzcZngER5UjV1DeN27ePwq35z2CPp3 95sB/zqzNBZuscktsviwDqGUSXMvbupZjScxTDzcJLKq9Tn50ObDCDaHGXDeXQwzm57oR8RDcR 0GKD2Q16z35nfuZGsS9UTgFvTSHqiy6gDi17CMxugkx/d56/xp6YYVK+bInEI+duoy+PbhGdTC tt8DGektGI4eU3Ufzm84H4k5ns2InnLXsDTBRgUkZoNXVtU5H86X/MIXzDiStZSk1a+FnTRERv aEE= X-SBRS: 2.7 X-MesageID: 11081780 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.69,414,1571716800"; d="scan'208";a="11081780" From: Andrew Cooper To: Xen-devel Date: Thu, 9 Jan 2020 19:32:40 +0000 Message-ID: <20200109193241.14542-4-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200109193241.14542-1-andrew.cooper3@citrix.com> References: <20200109193241.14542-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2 3/4] 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 | 14 ++++++++------ xen/arch/x86/boot/x86_64.S | 4 ++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S index 0b75d33a25..d246e374f1 100644 --- a/xen/arch/x86/boot/head.S +++ b/xen/arch/x86/boot/head.S @@ -689,12 +689,14 @@ 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 permanent trampoline page into l{1,2}_bootmap[]. */ + mov sym_esi(trampoline_phys), %ecx + lea __PAGE_HYPERVISOR_RX(%ecx), %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_esi(l2_bootmap) /* 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 de555f87f4..af62850589 100644 --- a/xen/arch/x86/boot/x86_64.S +++ b/xen/arch/x86/boot/x86_64.S @@ -155,6 +155,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