From nobody Sat May 4 08:24:03 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1578326123; cv=none; d=zohomail.com; s=zohoarc; b=MakZBjZmh6Zy+eki2lkyfjwQC1tIvsk3vwPuxpclpTuy9fUnM8bClMl6RLiJAm4tfbiZE6MpkimQI99+zW3dsdmJLC3oOCKS25EGcTQ3bXT1c1jOW/fshKTKkWHksRMK8Df/uZxeJCOjrnX0xd60E+OG/J5+4q2Sy0twx7YvdEE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578326123; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2ywbn4qvHgvhLvIvHI6+ENSyzHF07e4dvbIVbslYpuE=; b=D1585TXim+RqVq4vwjn1Nu69zZUj9IR/DGLyzS3Qb0JfPDvwo3BrSFoODaUlLAvNOmat9oqgHGD3MhZjhWbypB/sRe0pIZxcQFC8f8x85GTPoOlU+qdLWr740aABHe24UZ7Svg7QUY0MGfKnyT/LAPlI+lVMbnAl0f8/0JXd6Us= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1578326123077102.24880730378675; Mon, 6 Jan 2020 07:55:23 -0800 (PST) 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 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) X-Inumbo-ID: d1065614-309c-11ea-88e7-bc764e2007e4 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 (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; 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=20Pau=20Monn=C3=A9?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9 --- 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 =3D (1UL << L2_PAGETABLE_SHIFT) - 1; uint64_t end, limit =3D ARRAY_SIZE(l2_identmap) << L2_PAGETABLE_SH= IFT; =20 + if ( boot_e820.map[i].type !=3D E820_RAM ) + continue; + /* Superpage-aligned chunks from BOOTSTRAP_MAP_BASE. */ s =3D (boot_e820.map[i].addr + mask) & ~mask; e =3D (boot_e820.map[i].addr + boot_e820.map[i].size) & ~mask; s =3D max_t(uint64_t, s, BOOTSTRAP_MAP_BASE); - if ( (boot_e820.map[i].type !=3D E820_RAM) || (s >=3D e) ) + if ( s >=3D e ) continue; =20 if ( s < limit ) @@ -1286,11 +1289,14 @@ void __init noreturn __start_xen(unsigned long mbi_= p) uint64_t s, e, mask =3D PAGE_SIZE - 1; uint64_t map_s, map_e; =20 + if ( boot_e820.map[i].type !=3D E820_RAM ) + continue; + /* Only page alignment required now. */ s =3D (boot_e820.map[i].addr + mask) & ~mask; e =3D (boot_e820.map[i].addr + boot_e820.map[i].size) & ~mask; s =3D max_t(uint64_t, s, 1<<20); - if ( (boot_e820.map[i].type !=3D E820_RAM) || (s >=3D e) ) + if ( s >=3D e ) continue; =20 if ( !acpi_boot_table_init_done && --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sat May 4 08:24:03 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1578326121; cv=none; d=zohomail.com; s=zohoarc; b=BT9JqE8VA8yjZ/dTUoRe4xghmmO/wC1Z0f6dug1VqRv4BzDDf3P3bfFgoxn5mT0D0e8wGb9T7m63Do/1/acizsA6A9Qr/YjZ6Mm/AHwpTi+jdsmGyWGolKvu/8VBvgYYZR5ewMaMRy5UaJuOdRwkCAGJBc9km/z5Esn2e0Jz/SQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578326121; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gWMTYkTeLykNAy2Kp8sURgBpHfYNzBp4xrMLIjdmk8E=; b=QH7Xgy7Ep/CEpRFcueCDTbrgOwFuVhF5I3Vc+B1sIyU+DvPKMxXq8kjPtcNKbRr9KqiNb3d50NATTXdgN0fQymuPFlIdfSmElF+6qJns04ssBtXNW4NjUnZtEVJWGdWbgSw8howgTcRFrzP5r9zLeej32B8QafPiuFhW8Q6Fulg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 157832612169866.15478583113281; Mon, 6 Jan 2020 07:55:21 -0800 (PST) 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 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) X-Inumbo-ID: d0c5a7eb-309c-11ea-ab26-12813bfff9fa 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 (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; 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=20Pau=20Monn=C3=A9?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) c/s ec92fcd1d08, which caused the trampoline GDT Access bits to be set, removed the final writes which occurred between enabling paging and switchi= ng 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=C3=A9 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); } =20 int setup_compat_arg_xlat(struct vcpu *v) --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sat May 4 08:24:03 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1578326126; cv=none; d=zohomail.com; s=zohoarc; b=RiEwmF5KiAV4NjVb9hvphivwlcorNxopXMSUkB2rHKwJ6c/8NihXN7V77VWiPnvnZsKTxFqEBoMWvciltIOQqTw0tpJmh1BewRqDGve8dMlHjM9aCAS2NZuA/9wET1qr89GpE1bozPTS524pkOHCpZ7RSB3peLK/sfRgBQ2Sat4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578326126; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=JRug8UrZeRCV/HaKuCQqi1j07IezBSLsf7qPjxGCwLg=; b=iJRrNtcBQaCM3Sc3wx8CcbDp+grJNbUheMomyJbG8gkrMCsEkpWymoDneP54zXNtj/CclaztULe8lL1r8H+Sed1/L597z/6rcBO0hHXXO7rhzGoD+IraYXE3BBNWYgmlKd4HrP5pzhv0e+Md0kKmLJCkF7Z+8mBQ7cTRVoOHUjs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1578326126533753.9680685139017; Mon, 6 Jan 2020 07:55:26 -0800 (PST) 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 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) X-Inumbo-ID: d0c5a7ec-309c-11ea-ab26-12813bfff9fa 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 (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; 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=20Pau=20Monn=C3=A9?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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 u= se superpages here. Furthermore, nothing actually uses the mappings on boot. Build these entri= es 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 t= he 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=C3=A9 --- 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 =20 - /* - * 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 memor= y. */ 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 =20 /* - * __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) =20 /* - * 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 =3D 1 - .rept 7 - .quad (idx << L2_PAGETABLE_SHIFT) | PAGE_HYPERVISOR | _PAGE_PSE - idx =3D idx + 1 - .endr - .fill 4 * L2_PAGETABLE_ENTRIES - 8, 8, 0 + .fill 4 * L2_PAGETABLE_ENTRIES - 1, 8, 0 .size l2_identmap, . - l2_identmap =20 /* 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 !=3D E820_RAM ) continue; =20 - /* Superpage-aligned chunks from BOOTSTRAP_MAP_BASE. */ + /* Superpage-aligned chunks from 2MB. */ s =3D (boot_e820.map[i].addr + mask) & ~mask; e =3D (boot_e820.map[i].addr + boot_e820.map[i].size) & ~mask; - s =3D max_t(uint64_t, s, BOOTSTRAP_MAP_BASE); + s =3D max_t(uint64_t, s, MB(2)); if ( s >=3D e ) continue; =20 @@ -1346,8 +1346,8 @@ void __init noreturn __start_xen(unsigned long mbi_p) =20 set_pdx_range(s >> PAGE_SHIFT, e >> PAGE_SHIFT); =20 - /* Need to create mappings above BOOTSTRAP_MAP_BASE. */ - map_s =3D max_t(uint64_t, s, BOOTSTRAP_MAP_BASE); + /* Need to create mappings above 2MB. */ + map_s =3D max_t(uint64_t, s, MB(2)); map_e =3D min_t(uint64_t, e, ARRAY_SIZE(l2_identmap) << L2_PAGETABLE_SHIFT); =20 diff --git a/xen/arch/x86/x86_64/asm-offsets.c b/xen/arch/x86/x86_64/asm-of= fsets.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(); =20 - DEFINE(l2_identmap_sizeof, sizeof(l2_identmap)); - BLANK(); - OFFSET(DOMAIN_vm_assist, struct domain, vm_assist); } --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sat May 4 08:24:03 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1578326140; cv=none; d=zohomail.com; s=zohoarc; b=OrDTDWPxw6CjrUl7NqPS0hyOWRG1Lv4zxjQYHObXX60E3LCY9cfwdtGVkRAItTJhPY7HFBajEWsagNoL96zBBgoVlLQAO/z7jM2ztlqZHDOjmwENtGFU73CpsQzwq1Z445gJ1DyKj+T0L1CqxW/DJHiYT7A76YMnuhiC/qlK6s0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578326140; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Em5ZW5bJdRyfUHuz3iq0WeBHcTzcvcFAG9f2KoOtUas=; b=G/39eiOPiCxRBQGybdmMJ748rdHWv1fTnD46l7mSxOr+1Lhij2TO5ERuclT4KNR5BVui/1scs5npd0HF6K+fwMtwv+ztpDr9Ojk4MnD4Tl4JwCW9+YdU0eJrpUc88nOxuXHOUv26N4sqlVDblOvEMwEMQ9ZoDp1iaw88ja48OLc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1578326140628456.3755298280904; Mon, 6 Jan 2020 07:55:40 -0800 (PST) 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 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) X-Inumbo-ID: dcdb1204-309c-11ea-b6f1-bc764e2007e4 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 (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; 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=20Pau=20Monn=C3=A9?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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, explaini= ng 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=C3=A9 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 =20 - /* 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 =3D slot << L2_PAGETABLE_SHIFT; =20 l2_identmap[slot] =3D l2e_from_paddr(addr, PAGE_HYPERVISOR|_PAGE_P= SE); - slot &=3D L2_PAGETABLE_ENTRIES - 1; l2_bootmap[slot] =3D l2e_from_paddr(addr, __PAGE_HYPERVISOR|_PAGE_= PSE); } - /* Initialise L3 boot-map page directory entries. */ - l3_bootmap[l3_table_offset(xen_phys_start)] =3D - l3e_from_paddr((UINTN)l2_bootmap, __PAGE_HYPERVISOR); - l3_bootmap[l3_table_offset(xen_phys_start + (8 << L2_PAGETABLE_SHIFT) = - 1)] =3D - l3e_from_paddr((UINTN)l2_bootmap, __PAGE_HYPERVISOR); + + /* Initialize L3 boot-map page directory entries. */ + for ( i =3D 0; i < 4; ++i ) + l3_bootmap[i] =3D l3e_from_paddr((UINTN)l2_bootmap + i * PAGE_SIZE, + __PAGE_HYPERVISOR); } =20 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) >=3D WAKEUP_STACK_MIN, "wakeup stack too small") + +/* Plenty of boot code assumes that Xen isn't larger than 16M. */ +ASSERT(_end - _start <=3D MB(16), "Xen too large for early-boot assumption= s") --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sat May 4 08:24:03 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1578326126; cv=none; d=zohomail.com; s=zohoarc; b=Mm0siqVuA0nDidVWtkHZB8SXX20+aKeaCx9M3K85w9LP2gjbGjdM51Om52lOu35Ku9rWXlzUdMUVW64oWCV5jP2O/MWezt+l2PDTUXHjq2FB3NC8Lsd3439WUNT9FjBqjDfUm8C21t5RVDo3nWggoZJhyeaaWYM3bNBbxxuIqtI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578326126; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1OMxN5oRD2phbQPbOwj6hgT7lAyONZBV21hZMvJRZ0k=; b=OfcWDvBm2wGrmKjCk2hYX3BJ85hWzPGNjMfx8Cwmg6xvkoe6S1+pQtdgIXN4tgwhVEqIT789NmcsXUPP/BmdDi/ibcaylDMdMoX923feBtF35lQH8k6OWFiaXV5pnFQs7Cbc1iTuEX56Z0p7/iF6xW54G9g9vopyGLCapOUidRo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1578326126464696.7785650770526; Mon, 6 Jan 2020 07:55:26 -0800 (PST) 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 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) X-Inumbo-ID: d1c08b1b-309c-11ea-ab26-12813bfff9fa 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 (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; 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=20Pau=20Monn=C3=A9?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) In particular, it causes accidental NULL pointer dereferences to go unnotic= ed. 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 th= ere 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=C3=A9 --- 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 =20 - /* - * 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 =3D PTE to write */ + shr $PAGE_SHIFT, %ecx /* %ecx =3D 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) =20 /* 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 =20 +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 --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sat May 4 08:24:03 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1578326130; cv=none; d=zohomail.com; s=zohoarc; b=QPVIJ8TT/MkYTv91bLcTspOLsUBIvAk8SSSLi0YglehAaMup0KivbOPoZC+iggYSSuDeQY8IWVl0Pc8eS9AItqHZBeW1+wZK3yctnmdfNUCKi1Bz6e2y1DbjQocwj87UHqen9A2hMXR+0TeVWnoooE9nub/t1j/SSGEAYqSqjAE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578326130; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mHGjiCRfI+pNG8NJK7EQFcAPtHh5x5YWIum/li7KfiY=; b=BVm0IJr1CEWyHc7iFH3y4yd1AW6aY50NXZmIoXivrn+ld81tt8E+4f0kuXlgfshLeZO66rpaKqakbZw2Q75E/2mNgHHOzXAIn4i2ktE9h3OvA2KJrsElFSy7ESHclRgqWTjhXMnnMJwhlxI2Wa+SQtpFkFEPeUjoVY4KPZ+XHWo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1578326130570671.6775646378167; Mon, 6 Jan 2020 07:55:30 -0800 (PST) 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 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) X-Inumbo-ID: d1c08b1d-309c-11ea-ab26-12813bfff9fa 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 (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; 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=20Pau=20Monn=C3=A9?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9 --- 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 mcinf= o_global *mig) &mig->mc_coreid, &mig->mc_core_threadid, &mig->mc_apicid, NULL, NULL, NULL); =20 - if ( curr !=3D INVALID_VCPU ) + if ( curr ) { mig->mc_domid =3D curr->domain->domain_id; mig->mc_vcpuid =3D 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 =3D=3D INVALID_VCPU ) + if ( !v ) return NULL; =20 /* 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! */ =20 set_processor_id(0); - set_current(INVALID_VCPU); /* debug sanity. */ + set_current(NULL); /* debug sanity. */ idle_vcpu[0] =3D current; init_shadow_spec_ctrl_state(); =20 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] !=3D INVALID_VCPU ) + if ( idle_vcpu[0] ) write_ptbase(idle_vcpu[0]); =20 ((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 =20 -/* 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[]; --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel