From nobody Thu May 2 05:35:21 2024 Delivered-To: importer@patchew.org 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; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1580517241069313.09626545315666; Fri, 31 Jan 2020 16:34:01 -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 1ixgj7-0006Ls-20; Sat, 01 Feb 2020 00:33:33 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ixgj5-0006Ke-3M for xen-devel@lists.xenproject.org; Sat, 01 Feb 2020 00:33:31 +0000 Received: from merlin.infradead.org (unknown [2001:8b0:10b:1231::1]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 6aebf9fe-448a-11ea-ad98-bc764e2007e4; Sat, 01 Feb 2020 00:33:08 +0000 (UTC) Received: from i7.infradead.org ([2001:8b0:10b:1:21e:67ff:fecb:7a92]) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1ixgie-0007nw-0B; Sat, 01 Feb 2020 00:33:04 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.92 #3 (Red Hat Linux)) id 1ixgid-009uks-6M; Sat, 01 Feb 2020 00:33:03 +0000 X-Inumbo-ID: 6aebf9fe-448a-11ea-ad98-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=lqMSMeVhKSgPkcVvfREuVIy712hBBzMUz6KHWtaUJ6o=; b=VNjT65H8BTvvScEhCYnSNWyjs8 s7+jsssKumAgt3XOQJL3P4rgH6yuyixBpBxIFNrAsAu+peJme8cPwMz3wL9KP1ianREkmyxnWGC02 qxbJT/Ke3Hrrr1rhg0nS266EO3nwAqFPKNt6GQH83sFFY+2OppMSDBziSRPZG0qV4YrsqvqYI0UWO yLo/IytfJkHcgtvpt+ZfakHECZN+VF6lMgo4B5UZb/QWG7qrFL2QSzI4uTUj7bIoccpxqkw+OUgcz o+RkYlFO0FAymArBv8+5IFzk6049nD4eUGnXCUXM6mgbhuQHyGQ+gQpPnp+vE+y6oBvXqDt0U9KlX +NiPQpYw==; From: David Woodhouse To: xen-devel@lists.xenproject.org Date: Sat, 1 Feb 2020 00:32:56 +0000 Message-Id: <20200201003303.2363081-1-dwmw2@infradead.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <8a95f787ca93b23ee8d8c0b55fcc63d22a75c5f3.camel@infradead.org> References: <8a95f787ca93b23ee8d8c0b55fcc63d22a75c5f3.camel@infradead.org> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by merlin.infradead.org. See http://www.infradead.org/rpr.html Subject: [Xen-devel] [PATCH 1/8] x86/smp: reset x2apic_enabled in smp_send_stop() 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: Stefano Stabellini , Julien Grall , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Varad Gautam , Ian Jackson , Hongyan Xia , Paul Durrant , =?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) From: David Woodhouse Just before smp_send_stop() re-enables interrupts when shutting down for reboot or kexec, it calls __stop_this_cpu() which in turn calls disable_local_APIC(), which puts the APIC back in to the mode Xen found it in at boot. If that means turning x2APIC off and going back into xAPIC mode, then a timer interrupt occurring just after interrupts come back on will lead to a GP# when apic_timer_interrupt() attempts to ack the IRQ through the EOI register in x2APIC MSR 0x80b: (XEN) Executing kexec image on cpu0 (XEN) ----[ Xen-4.14-unstable x86_64 debug=3Dn Not tainted ]---- (XEN) CPU: 0 (XEN) RIP: e008:[] apic_timer_interrupt+0x29/0x40 (XEN) RFLAGS: 0000000000010046 CONTEXT: hypervisor (XEN) rax: 0000000000000000 rbx: 00000000000000fa rcx: 000000000000080b =E2=80=A6 (XEN) Xen code around (apic_timer_interrupt+0x29/0x40): (XEN) c0 b9 0b 08 00 00 89 c2 <0f> 30 31 ff e9 0e c9 fb ff 0f 1f 40 00 66 = 2e 0f =E2=80=A6 (XEN) Xen call trace: (XEN) [] R apic_timer_interrupt+0x29/0x40 (XEN) [] S do_IRQ+0x95/0x750 =E2=80=A6 (XEN) [] S smp_send_stop+0x42/0xd0 We can't clear the global x2apic_enabled variable in disable_local_APIC() itself because that runs on each CPU. Instead, correct it (by using current_local_apic_mode()) in smp_send_stop() while interrupts are still disabled immediately after calling __stop_this_cpu() for the boot CPU, after all other CPUs have been stopped. cf: d639bdd9bbe ("x86/apic: Disable the LAPIC later in smp_send_stop()") ... which didn't quite fix it completely. Signed-off-by: David Woodhouse Reviewed-by: Roger Pau Monn=C3=A9 --- xen/arch/x86/smp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/xen/arch/x86/smp.c b/xen/arch/x86/smp.c index 65eb7cbda8..fac295fa6f 100644 --- a/xen/arch/x86/smp.c +++ b/xen/arch/x86/smp.c @@ -354,6 +354,7 @@ void smp_send_stop(void) disable_IO_APIC(); hpet_disable(); __stop_this_cpu(); + x2apic_enabled =3D (current_local_apic_mode() =3D=3D APIC_MODE_X2A= PIC); local_irq_enable(); } } --=20 2.21.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu May 2 05:35:21 2024 Delivered-To: importer@patchew.org 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; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1580517225762902.3034119414024; Fri, 31 Jan 2020 16:33:45 -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 1ixgiq-0006B0-WC; Sat, 01 Feb 2020 00:33:16 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ixgiq-0006Aa-2p for xen-devel@lists.xenproject.org; Sat, 01 Feb 2020 00:33:16 +0000 Received: from bombadil.infradead.org (unknown [2607:7c80:54:e::133]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 69022c1c-448a-11ea-b211-bc764e2007e4; Sat, 01 Feb 2020 00:33:05 +0000 (UTC) Received: from i7.infradead.org ([2001:8b0:10b:1:21e:67ff:fecb:7a92]) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1ixgie-0007N1-EE; Sat, 01 Feb 2020 00:33:04 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.92 #3 (Red Hat Linux)) id 1ixgid-009ukw-78; Sat, 01 Feb 2020 00:33:03 +0000 X-Inumbo-ID: 69022c1c-448a-11ea-b211-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Ibs6daSKtbv9Id382VB9N53Kh+mTH7nRJBEXpgxFwj4=; b=AJCLu528w1dy/ftJ1htU1LxNuW JLvfzBBOSxZSFrRSOEtUIK/RI55eTh3xdN1QiQm0f1lzjIcYkdufAkIR7nMvYtgkyNcVJavE8xNHh Jun5RftCpCSJuKsQAfz8uJd+YThEcpyU25OijDxF/aiLKhqqiP41MWU14vwoStufOmOZQdGPk/zN8 T4KCit/6twmjcTkKq5K0RSL6CPFAh2As1cbknqBYyBL+5HF9Ln7ohhDvHh/OtmlrxB7gBBxlXz4KA 04ctUoZn3gJTk0Fr+OJnixHye6bwmihXSO64bE0lxHFAlXBX0XObXwiDAOyHpMdmpyCHAS8pnGCwW KFFw4I/A==; From: David Woodhouse To: xen-devel@lists.xenproject.org Date: Sat, 1 Feb 2020 00:32:57 +0000 Message-Id: <20200201003303.2363081-2-dwmw2@infradead.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <8a95f787ca93b23ee8d8c0b55fcc63d22a75c5f3.camel@infradead.org> References: <8a95f787ca93b23ee8d8c0b55fcc63d22a75c5f3.camel@infradead.org> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Subject: [Xen-devel] [PATCH 2/8] x86/setup: Fix badpage= handling for memory above HYPERVISOR_VIRT_END 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: Stefano Stabellini , Julien Grall , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Varad Gautam , Ian Jackson , Hongyan Xia , Paul Durrant , =?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) From: David Woodhouse Bad pages are identified by get_platform_badpages() and with badpage=3D on the command line. The boot allocator currently automatically elides these from the regions passed to it with init_boot_pages(). The xenheap is then initialised with the pages which are still marked as free by the boot allocator when end_boot_allocator() is called. However, any memory above HYPERVISOR_VIRT_END is passed directly to init_domheap_pages() later in __start_xen(), and the bad page list is not consulted. Fix this by marking those pages as PGC_broken in the frametable at the time end_boot_allocator() runs, and then making init_heap_pages() skip over any pages which are so marked. Signed-off-by: David Woodhouse --- xen/common/page_alloc.c | 82 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 79 insertions(+), 3 deletions(-) diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 919a270587..3cf478311b 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -1758,6 +1758,18 @@ int query_page_offline(mfn_t mfn, uint32_t *status) return 0; } =20 +static unsigned long contig_avail_pages(struct page_info *pg, unsigned lon= g max_pages) +{ + unsigned long i; + + for ( i =3D 0 ; i < max_pages; i++) + { + if ( pg[i].count_info & PGC_broken ) + break; + } + return i; +} + /* * Hand the specified arbitrary page range to the specified heap zone * checking the node_id of the previous page. If they differ and the @@ -1799,18 +1811,23 @@ static void init_heap_pages( { unsigned int nid =3D phys_to_nid(page_to_maddr(pg+i)); =20 + /* If the (first) page is already marked broken, don't add it. */ + if ( pg[i].count_info & PGC_broken ) + continue; + if ( unlikely(!avail[nid]) ) { + unsigned long contig_nr_pages =3D contig_avail_pages(pg + i, n= r_pages); unsigned long s =3D mfn_x(page_to_mfn(pg + i)); - unsigned long e =3D mfn_x(mfn_add(page_to_mfn(pg + nr_pages - = 1), 1)); + unsigned long e =3D mfn_x(mfn_add(page_to_mfn(pg + i + contig_= nr_pages - 1), 1)); bool use_tail =3D (nid =3D=3D phys_to_nid(pfn_to_paddr(e - 1))= ) && !(s & ((1UL << MAX_ORDER) - 1)) && (find_first_set_bit(e) <=3D find_first_set_bit= (s)); unsigned long n; =20 - n =3D init_node_heap(nid, mfn_x(page_to_mfn(pg + i)), nr_pages= - i, + n =3D init_node_heap(nid, mfn_x(page_to_mfn(pg + i)), contig_n= r_pages, &use_tail); - BUG_ON(i + n > nr_pages); + BUG_ON(n > contig_nr_pages); if ( n && !use_tail ) { i +=3D n - 1; @@ -1846,6 +1863,63 @@ static unsigned long avail_heap_pages( return free_pages; } =20 +static void mark_bad_pages(void) +{ + unsigned long bad_spfn, bad_epfn; + const char *p; + struct page_info *pg; +#ifdef CONFIG_X86 + const struct platform_bad_page *badpage; + unsigned int i, j, array_size; + + badpage =3D get_platform_badpages(&array_size); + if ( badpage ) + { + for ( i =3D 0; i < array_size; i++ ) + { + for ( j =3D 0; j < 1UL << badpage->order; j++ ) + { + if ( mfn_valid(_mfn(badpage->mfn + j)) ) + { + pg =3D mfn_to_page(_mfn(badpage->mfn + j)); + pg->count_info |=3D PGC_broken; + page_list_add_tail(pg, &page_broken_list); + } + } + } + } +#endif + + /* Check new pages against the bad-page list. */ + p =3D opt_badpage; + while ( *p !=3D '\0' ) + { + bad_spfn =3D simple_strtoul(p, &p, 0); + bad_epfn =3D bad_spfn; + + if ( *p =3D=3D '-' ) + { + p++; + bad_epfn =3D simple_strtoul(p, &p, 0); + if ( bad_epfn < bad_spfn ) + bad_epfn =3D bad_spfn; + } + + if ( *p =3D=3D ',' ) + p++; + else if ( *p !=3D '\0' ) + break; + + while ( mfn_valid(_mfn(bad_spfn)) && bad_spfn < bad_epfn ) + { + pg =3D mfn_to_page(_mfn(bad_spfn)); + pg->count_info |=3D PGC_broken; + page_list_add_tail(pg, &page_broken_list); + bad_spfn++; + } + } +} + void __init end_boot_allocator(void) { unsigned int i; @@ -1870,6 +1944,8 @@ void __init end_boot_allocator(void) } nr_bootmem_regions =3D 0; =20 + mark_bad_pages(); + if ( !dma_bitsize && (num_online_nodes() > 1) ) dma_bitsize =3D arch_get_dma_bitsize(); =20 --=20 2.21.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu May 2 05:35:21 2024 Delivered-To: importer@patchew.org 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; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 158051724706454.07764170103485; Fri, 31 Jan 2020 16:34:07 -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 1ixgjB-0006QX-Mb; Sat, 01 Feb 2020 00:33: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 1ixgjA-0006Pa-3a for xen-devel@lists.xenproject.org; Sat, 01 Feb 2020 00:33:36 +0000 Received: from merlin.infradead.org (unknown [2001:8b0:10b:1231::1]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 6aebfdc8-448a-11ea-ad98-bc764e2007e4; Sat, 01 Feb 2020 00:33:09 +0000 (UTC) Received: from i7.infradead.org ([2001:8b0:10b:1:21e:67ff:fecb:7a92]) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1ixgie-0007nx-29; Sat, 01 Feb 2020 00:33:04 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.92 #3 (Red Hat Linux)) id 1ixgid-009ul1-7i; Sat, 01 Feb 2020 00:33:03 +0000 X-Inumbo-ID: 6aebfdc8-448a-11ea-ad98-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=cii2sqUGqqIXyUMQJswpEp7YbOA1HrjdrYUaabsuQ94=; b=O9J5HksmOcBX4+CEMauqFjccYp qkLKFWyYOeZYF6mp1Z0zuhktL+zSKdJ//KbGVkNEtYdceoRlOmoZHxL8KVb4vVGb+snsieCYChJvn Sc9NwawuJEUWX3iWFvW1sA232aqNeYwfm7TNTiwjHX8VClL4qiaBAxHnsP28RazZ/92hXLTs56l6O S8TjWe6b9Tcra3nA3bnlNT3lcw9KFSRez0qOJw2xWlz8/o6DWlw1mX5s/mSk+3wbLmQXBzhUUSlnC 6wZInBZRZbO7I3EMEtR3gzOXVvCO6b83LvgO3CqN5cISjX/lFy9sbxQUmFO4QWlT360+zsljkMX4C 1f5IbzaQ==; From: David Woodhouse To: xen-devel@lists.xenproject.org Date: Sat, 1 Feb 2020 00:32:58 +0000 Message-Id: <20200201003303.2363081-3-dwmw2@infradead.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <8a95f787ca93b23ee8d8c0b55fcc63d22a75c5f3.camel@infradead.org> References: <8a95f787ca93b23ee8d8c0b55fcc63d22a75c5f3.camel@infradead.org> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by merlin.infradead.org. See http://www.infradead.org/rpr.html Subject: [Xen-devel] [PATCH 3/8] x86/setup: Don't skip 2MiB underneath relocated Xen image 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: Stefano Stabellini , Julien Grall , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Varad Gautam , Ian Jackson , Hongyan Xia , Paul Durrant , =?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) From: David Woodhouse Set 'e' correctly to reflect the location that Xen is actually relocated to from its default 2MiB location. Not 2MiB below that. This is only vaguely a bug fix. The "missing" 2MiB would have been used in the end, and fed to the allocator. It's just that other things don't get to sit right up *next* to the Xen image, and it isn't very tidy. For live update, I'd quite like a single contiguous region for the reserved bootmem and Xen, allowing the 'slack' in the former to be used when Xen itself grows larger. Let's not allow 2MiB of random heap pages to get in the way... Signed-off-by: David Woodhouse --- xen/arch/x86/setup.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index d858883404..2677f127b9 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1080,9 +1080,9 @@ void __init noreturn __start_xen(unsigned long mbi_p) unsigned long pte_update_limit; =20 /* Select relocation address. */ - e =3D end - reloc_size; - xen_phys_start =3D e; - bootsym(trampoline_xen_phys_start) =3D e; + xen_phys_start =3D end - reloc_size; + e =3D xen_phys_start + XEN_IMG_OFFSET; + bootsym(trampoline_xen_phys_start) =3D xen_phys_start; =20 /* * No PTEs pointing above this address are candidates for relo= cation. @@ -1090,7 +1090,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) * and the beginning of region for destination image some PTEs= may * point to addresses in range [e, e + XEN_IMG_OFFSET). */ - pte_update_limit =3D PFN_DOWN(e + XEN_IMG_OFFSET); + pte_update_limit =3D PFN_DOWN(e); =20 /* * Perform relocation to new physical address. @@ -1099,7 +1099,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) * data until after we have switched to the relocated pagetabl= es! */ barrier(); - move_memory(e + XEN_IMG_OFFSET, XEN_IMG_OFFSET, _end - _start,= 1); + move_memory(e, XEN_IMG_OFFSET, _end - _start, 1); =20 /* Walk initial pagetables, relocating page directory entries.= */ pl4e =3D __va(__pa(idle_pg_table)); --=20 2.21.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu May 2 05:35:21 2024 Delivered-To: importer@patchew.org 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; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1580517240990840.5125987866489; Fri, 31 Jan 2020 16:34:00 -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 1ixgj1-0006Ht-Mk; Sat, 01 Feb 2020 00:33:27 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ixgj0-0006Gw-35 for xen-devel@lists.xenproject.org; Sat, 01 Feb 2020 00:33:26 +0000 Received: from merlin.infradead.org (unknown [2001:8b0:10b:1231::1]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 6aebf134-448a-11ea-ad98-bc764e2007e4; Sat, 01 Feb 2020 00:33:08 +0000 (UTC) Received: from i7.infradead.org ([2001:8b0:10b:1:21e:67ff:fecb:7a92]) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1ixgie-0007ny-26; Sat, 01 Feb 2020 00:33:04 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.92 #3 (Red Hat Linux)) id 1ixgid-009ul6-8J; Sat, 01 Feb 2020 00:33:03 +0000 X-Inumbo-ID: 6aebf134-448a-11ea-ad98-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=L2O922a9WZmlPredpfqcFeznyIaN0AM+ucM06nCll7Q=; b=No0A83rVbOVV5rEeJzoNIyXz3A Rcgg05mHipCfPSnQWuhaKEDyVDOH9ha7+kiGdycMjUMIj6UdNZhIeYOZUb8HEOSOhuc4fxOL3MLHT VXEdEZg/z6EL6FqQKqH/5PKps9MWqPF/MQ3m/tTkiF2oliajcDjn25p/OFX09lmuywhSUtAgOShJC H/Z39RMrAwvLipmeSPnUOYyduJYY3hXwQfXSZXFk54iozykrOrsIbE81gks6O11dLAZ09Dqfm9HNr PDxp0ms//Pht0aKPcqD3WKNxkjxKf472NwXL3jO18TWhjHL+9nBtWMKjEgW90s3sA2A8TcMQiBbdX p0gBhh7g==; From: David Woodhouse To: xen-devel@lists.xenproject.org Date: Sat, 1 Feb 2020 00:32:59 +0000 Message-Id: <20200201003303.2363081-4-dwmw2@infradead.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <8a95f787ca93b23ee8d8c0b55fcc63d22a75c5f3.camel@infradead.org> References: <8a95f787ca93b23ee8d8c0b55fcc63d22a75c5f3.camel@infradead.org> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by merlin.infradead.org. See http://www.infradead.org/rpr.html Subject: [Xen-devel] [PATCH 4/8] xen/vmap: allow vm_init_type to be called during early_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: Stefano Stabellini , Julien Grall , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Varad Gautam , Ian Jackson , Hongyan Xia , Paul Durrant , =?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) From: Wei Liu We want to move vm_init, which calls vm_init_type under the hood, to early boot stage. Add a path to get page from boot allocator instead. Add an emacs block to that file while I was there. Signed-off-by: Wei Liu Reviewed-by: Jan Beulich --- xen/common/vmap.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/xen/common/vmap.c b/xen/common/vmap.c index faebc1ddf1..37922f735b 100644 --- a/xen/common/vmap.c +++ b/xen/common/vmap.c @@ -34,9 +34,15 @@ void __init vm_init_type(enum vmap_region type, void *st= art, void *end) =20 for ( i =3D 0, va =3D (unsigned long)vm_bitmap(type); i < nr; ++i, va = +=3D PAGE_SIZE ) { - struct page_info *pg =3D alloc_domheap_page(NULL, 0); - - map_pages_to_xen(va, page_to_mfn(pg), 1, PAGE_HYPERVISOR); + mfn_t mfn; + int rc; + + if ( system_state =3D=3D SYS_STATE_early_boot ) + mfn =3D alloc_boot_pages(1, 1); + else + mfn =3D page_to_mfn(alloc_domheap_page(NULL, 0)); + rc =3D map_pages_to_xen(va, mfn, 1, PAGE_HYPERVISOR); + BUG_ON(rc); clear_page((void *)va); } bitmap_fill(vm_bitmap(type), vm_low[type]); @@ -330,3 +336,13 @@ void vfree(void *va) free_domheap_page(pg); } #endif + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ --=20 2.21.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu May 2 05:35:21 2024 Delivered-To: importer@patchew.org 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; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1580517235686548.7927346333897; Fri, 31 Jan 2020 16:33:55 -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 1ixgiw-0006Eo-Bz; Sat, 01 Feb 2020 00:33:22 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ixgiv-0006Dt-2u for xen-devel@lists.xenproject.org; Sat, 01 Feb 2020 00:33:21 +0000 Received: from merlin.infradead.org (unknown [2001:8b0:10b:1231::1]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 6aebf616-448a-11ea-ad98-bc764e2007e4; Sat, 01 Feb 2020 00:33:09 +0000 (UTC) Received: from i7.infradead.org ([2001:8b0:10b:1:21e:67ff:fecb:7a92]) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1ixgie-0007nz-2s; Sat, 01 Feb 2020 00:33:04 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.92 #3 (Red Hat Linux)) id 1ixgid-009ulB-8s; Sat, 01 Feb 2020 00:33:03 +0000 X-Inumbo-ID: 6aebf616-448a-11ea-ad98-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=8bCC1czvIgY7PeMeaG5CbgEmu47OJWNzV1dFnhwyx6o=; b=fjdh81HBbuGIUWbLgEJMmNX8n5 uMOU+EcN5hcjHntnUKM3Fr6y+TWG4aZdowrQltKhwbP1vLojAn7c4UYJjAcGp/K573h+vCfJ5BMjK Nm4sPVJUNLHRXCfg3A5vFHMTnbPN7vVkZOiSq9S50jeW402xalvVjjbWmYjzRKat6usN9hj5XTifJ APOfvIP/ahzPFi2kiRwE8MbrWUjFO5ggxrIj9F9VTMHKcVAOBfM7aRoOEedjrjSQrr5jOZeAhRe5a /sQkU1DNMoHIfL2+MqlsWHvl5RBPP9VZnxNK7M5+lKkhbdW8CBG/aXb2S1LjDDY4McO74VRc5Vtdm B7hLRQFA==; From: David Woodhouse To: xen-devel@lists.xenproject.org Date: Sat, 1 Feb 2020 00:33:00 +0000 Message-Id: <20200201003303.2363081-5-dwmw2@infradead.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <8a95f787ca93b23ee8d8c0b55fcc63d22a75c5f3.camel@infradead.org> References: <8a95f787ca93b23ee8d8c0b55fcc63d22a75c5f3.camel@infradead.org> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by merlin.infradead.org. See http://www.infradead.org/rpr.html Subject: [Xen-devel] [PATCH 5/8] xen/vmap: allow vmap() to be called during early 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: Stefano Stabellini , Julien Grall , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Varad Gautam , Ian Jackson , Hongyan Xia , Paul Durrant , =?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) From: David Woodhouse Signed-off-by: David Woodhouse --- xen/common/vmap.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/xen/common/vmap.c b/xen/common/vmap.c index 37922f735b..8343460794 100644 --- a/xen/common/vmap.c +++ b/xen/common/vmap.c @@ -68,7 +68,7 @@ static void *vm_alloc(unsigned int nr, unsigned int align, spin_lock(&vm_lock); for ( ; ; ) { - struct page_info *pg; + mfn_t mfn; =20 ASSERT(vm_low[t] =3D=3D vm_top[t] || !test_bit(vm_low[t], vm_bitma= p(t))); for ( start =3D vm_low[t]; start < vm_top[t]; ) @@ -103,9 +103,17 @@ static void *vm_alloc(unsigned int nr, unsigned int al= ign, if ( vm_top[t] >=3D vm_end[t] ) return NULL; =20 - pg =3D alloc_domheap_page(NULL, 0); - if ( !pg ) - return NULL; + if ( system_state =3D=3D SYS_STATE_early_boot ) + { + mfn =3D alloc_boot_pages(1, 1); + } + else + { + struct page_info *pg =3D alloc_domheap_page(NULL, 0); + if ( !pg ) + return NULL; + mfn =3D page_to_mfn(pg); + } =20 spin_lock(&vm_lock); =20 @@ -113,7 +121,7 @@ static void *vm_alloc(unsigned int nr, unsigned int ali= gn, { unsigned long va =3D (unsigned long)vm_bitmap(t) + vm_top[t] /= 8; =20 - if ( !map_pages_to_xen(va, page_to_mfn(pg), 1, PAGE_HYPERVISOR= ) ) + if ( !map_pages_to_xen(va, mfn, 1, PAGE_HYPERVISOR) ) { clear_page((void *)va); vm_top[t] +=3D PAGE_SIZE * 8; @@ -123,7 +131,10 @@ static void *vm_alloc(unsigned int nr, unsigned int al= ign, } } =20 - free_domheap_page(pg); + if ( system_state =3D=3D SYS_STATE_early_boot ) + init_boot_pages(mfn_to_maddr(mfn), mfn_to_maddr(mfn) + PAGE_SI= ZE); + else + free_domheap_page(mfn_to_page(mfn)); =20 if ( start >=3D vm_top[t] ) { --=20 2.21.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu May 2 05:35:21 2024 Delivered-To: importer@patchew.org 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; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1580517225838388.92337090631315; Fri, 31 Jan 2020 16:33:45 -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 1ixgii-000678-Ar; Sat, 01 Feb 2020 00:33:08 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ixgig-00066E-Fy for xen-devel@lists.xenproject.org; Sat, 01 Feb 2020 00:33:06 +0000 Received: from bombadil.infradead.org (unknown [2607:7c80:54:e::133]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 690dca7c-448a-11ea-ad98-bc764e2007e4; Sat, 01 Feb 2020 00:33:05 +0000 (UTC) Received: from i7.infradead.org ([2001:8b0:10b:1:21e:67ff:fecb:7a92]) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1ixgie-0007N2-GR; Sat, 01 Feb 2020 00:33:04 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.92 #3 (Red Hat Linux)) id 1ixgid-009ulG-9S; Sat, 01 Feb 2020 00:33:03 +0000 X-Inumbo-ID: 690dca7c-448a-11ea-ad98-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=oJ4ggL9B9DVukcCynxJbKxFVyNAbYCr/rqO67ToM4Zo=; b=hzTcrbp90+kCz6dQW0ZDbXyGIT 5pcfR+6ziBec6NiKYoonyuJ3QM9uiA52qCYX1zGtvA2gbNh0K+jId5ntgXohROwOkidHTrjYfzncO 0P8mEZdJVb9CX732ntt/Uc52BG4LHmaNqKnDDXflYAbXmL08K/rXFVL0b9d4EGR954RS71+ur+UzW IYmlO3Bym4lxxO09ZLcDMTOmXTq4VBnWNj3fLpic7ZQwLowu5nSanaslrhib7oaPeTvnFOhhOD/Dh QdZDNcxSvBLDOjlywdF1DORCMCg//x1uzGx+2mhbFH9e7ciY7h+JVmZGDKC1ogO00oZgJ9fuD7SPy AXIyUiLg==; From: David Woodhouse To: xen-devel@lists.xenproject.org Date: Sat, 1 Feb 2020 00:33:01 +0000 Message-Id: <20200201003303.2363081-6-dwmw2@infradead.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <8a95f787ca93b23ee8d8c0b55fcc63d22a75c5f3.camel@infradead.org> References: <8a95f787ca93b23ee8d8c0b55fcc63d22a75c5f3.camel@infradead.org> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Subject: [Xen-devel] [PATCH 6/8] x86/setup: move vm_init() before end_boot_allocator() 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: Stefano Stabellini , Julien Grall , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Varad Gautam , Ian Jackson , Hongyan Xia , Paul Durrant , =?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) From: David Woodhouse We would like to be able to use vmap() to map the live update data, and we need to do a first pass of the live update data before we prime the heap because we need to know which pages need to be preserved. The warning about ACPI code can be dropped, since that problem no longer exists when things are done in this order. Signed-off-by: David Woodhouse Reviewed-by: Jan Beulich --- xen/arch/x86/setup.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 2677f127b9..5f68a1308f 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1489,6 +1489,8 @@ void __init noreturn __start_xen(unsigned long mbi_p) =20 numa_initmem_init(0, raw_max_page); =20 + vm_init(); + if ( max_page - 1 > virt_to_mfn(HYPERVISOR_VIRT_END - 1) ) { unsigned long limit =3D virt_to_mfn(HYPERVISOR_VIRT_END - 1); @@ -1519,12 +1521,6 @@ void __init noreturn __start_xen(unsigned long mbi_p) end_boot_allocator(); =20 system_state =3D SYS_STATE_boot; - /* - * No calls involving ACPI code should go between the setting of - * SYS_STATE_boot and vm_init() (or else acpi_os_{,un}map_memory() - * will break). - */ - vm_init(); =20 console_init_ring(); vesa_init(); --=20 2.21.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu May 2 05:35:21 2024 Delivered-To: importer@patchew.org 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; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1580517221728460.4394106475397; Fri, 31 Jan 2020 16:33:41 -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 1ixgim-00068c-Kv; Sat, 01 Feb 2020 00:33:12 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ixgil-00068C-2j for xen-devel@lists.xenproject.org; Sat, 01 Feb 2020 00:33:11 +0000 Received: from bombadil.infradead.org (unknown [2607:7c80:54:e::133]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 690f4b7c-448a-11ea-8396-bc764e2007e4; Sat, 01 Feb 2020 00:33:05 +0000 (UTC) Received: from i7.infradead.org ([2001:8b0:10b:1:21e:67ff:fecb:7a92]) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1ixgie-0007N3-Gv; Sat, 01 Feb 2020 00:33:04 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.92 #3 (Red Hat Linux)) id 1ixgid-009ulL-A1; Sat, 01 Feb 2020 00:33:03 +0000 X-Inumbo-ID: 690f4b7c-448a-11ea-8396-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=sNt82ToGZTbiQmLWphlDTKMwMKPPJsJCzyiuyVo3of4=; b=XPXbANAX5EkzvwMZXCL6YQWqFT UwQKHjnRbQhYzz6TzL6iT0FomQOYie7PrhlRwEXQgbact2p8ZGcEgQkYCs/N5xYTsmYqhvgO8Rwyv eSJsPqMPk3KPFzrtZXaGj3OdYv0VWMjWCxj4zZc2ogY6SKoXFXIGlUQSE6tC+TpbjJxSuDHG+RgHA OQdifP35PbU4h2PPR+YfFvLf5v9WlVm5Ru4FBmy9aHDIaokHQnvl8wyVl7njv1x5iCeOSxEIp/jBP hk9d7gJ5IJbAelDhRX28AKMMSky6GUm5JLfUqhpXZel7dFWLLiRd0PSBTdXEahVfxFDeL9kPGnNAn QKOfB3iQ==; From: David Woodhouse To: xen-devel@lists.xenproject.org Date: Sat, 1 Feb 2020 00:33:02 +0000 Message-Id: <20200201003303.2363081-7-dwmw2@infradead.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <8a95f787ca93b23ee8d8c0b55fcc63d22a75c5f3.camel@infradead.org> References: <8a95f787ca93b23ee8d8c0b55fcc63d22a75c5f3.camel@infradead.org> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Subject: [Xen-devel] [PATCH 7/8] x86/setup: simplify handling of initrdidx when no initrd present 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: Stefano Stabellini , Julien Grall , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Varad Gautam , Ian Jackson , Hongyan Xia , Paul Durrant , =?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) From: David Woodhouse Remove a ternary operator that made my brain hurt. Replace it with something simpler that makes it somewhat clearer that the check for initrdidx < mbi->mods_count is because mbi->mods_count is what find_first_bit() will return when it doesn't find anything. Signed-off-by: David Woodhouse Acked-by: Julien Grall --- xen/arch/x86/setup.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 5f68a1308f..10209e6bfb 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -687,7 +687,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) char *cmdline, *kextra, *loader; unsigned int initrdidx, num_parked =3D 0; multiboot_info_t *mbi; - module_t *mod; + module_t *mod, *initrd =3D NULL; unsigned long nr_pages, raw_max_page, modules_headroom, module_map[1]; int i, j, e820_warn =3D 0, bytes =3D 0; bool acpi_boot_table_init_done =3D false, relocated =3D false; @@ -1793,6 +1793,9 @@ void __init noreturn __start_xen(unsigned long mbi_p) xen_processor_pmbits |=3D XEN_PROCESSOR_PM_CX; =20 initrdidx =3D find_first_bit(module_map, mbi->mods_count); + if ( initrdidx < mbi->mods_count ) + initrd =3D mod + initrdidx; + if ( bitmap_weight(module_map, mbi->mods_count) > 1 ) printk(XENLOG_WARNING "Multiple initrd candidates, picking module #%u\n", @@ -1817,9 +1820,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) * We're going to setup domain0 using the module(s) that we stashed sa= fely * above our heap. The second module, if present, is an initrd ramdisk. */ - if ( construct_dom0(dom0, mod, modules_headroom, - (initrdidx > 0) && (initrdidx < mbi->mods_count) - ? mod + initrdidx : NULL, cmdline) !=3D 0) + if ( construct_dom0(dom0, mod, modules_headroom, initrd, cmdline) !=3D= 0 ) panic("Could not set up DOM0 guest OS\n"); =20 if ( cpu_has_smap ) --=20 2.21.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Thu May 2 05:35:21 2024 Delivered-To: importer@patchew.org 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; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1580517223238652.1706637012699; Fri, 31 Jan 2020 16:33:43 -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 1ixgig-00066L-Qk; Sat, 01 Feb 2020 00:33:06 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ixgig-000665-31 for xen-devel@lists.xenproject.org; Sat, 01 Feb 2020 00:33:06 +0000 Received: from bombadil.infradead.org (unknown [2607:7c80:54:e::133]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 692917f0-448a-11ea-b211-bc764e2007e4; Sat, 01 Feb 2020 00:33:05 +0000 (UTC) Received: from i7.infradead.org ([2001:8b0:10b:1:21e:67ff:fecb:7a92]) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1ixgie-0007N4-Ht; Sat, 01 Feb 2020 00:33:04 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.92 #3 (Red Hat Linux)) id 1ixgid-009ulQ-Aa; Sat, 01 Feb 2020 00:33:03 +0000 X-Inumbo-ID: 692917f0-448a-11ea-b211-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=9RgL2Z0Xollm7VQ7ZAaxx2QpOXyoyuKPohgfc0eH1Ss=; b=eFU58qvhYpUtIqy87KfpVaTJ92 5HEBBsN5oI+cAmfW4Ti/JZ5ybBrqQ6NltS7LQEWQ3nkp6ZNqrC6vwLcdsTVpxHA2SZdNrNVambHsT ZoHkBGYcKdl+gvUNTmKugfQovzfNNHmGKIqn2Wfv1ZAKaQS9nkPTZhryzBXSHWZsRk8sueBMAewN7 lnXv8ButxqqztB5CQeDuaLJj+EEgY+BXdCyWOXQq8hPe2X2AQBQsAljS39IBIlgldn0CGL/y5HVEA bfYCV3GjEx46hBRaDUlQqpk7GBwRDPJK3MBFFNbh3ujTzLDljhCZ7w0KNoHxpCcwbwkwcu/xDNLDa AcD+TnjA==; From: David Woodhouse To: xen-devel@lists.xenproject.org Date: Sat, 1 Feb 2020 00:33:03 +0000 Message-Id: <20200201003303.2363081-8-dwmw2@infradead.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <8a95f787ca93b23ee8d8c0b55fcc63d22a75c5f3.camel@infradead.org> References: <8a95f787ca93b23ee8d8c0b55fcc63d22a75c5f3.camel@infradead.org> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Subject: [Xen-devel] [PATCH 8/8] x86/setup: lift dom0 creation out into create_dom0() function 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: Stefano Stabellini , Julien Grall , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Varad Gautam , Ian Jackson , Hongyan Xia , Paul Durrant , =?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) From: David Woodhouse The creation of dom0 can be relatively self-contained. Shift it into a separate function and simplify __start_xen() a little bit. This is a cleanup in its own right, but will be even more desireable when live update provides an alternative path through __start_xen() that doesn't involve creating a new dom0 at all. Signed-off-by: David Woodhouse --- xen/arch/x86/setup.c | 169 +++++++++++++++++++++++-------------------- 1 file changed, 92 insertions(+), 77 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 10209e6bfb..9d86722ecd 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -678,6 +678,92 @@ static unsigned int __init copy_bios_e820(struct e820e= ntry *map, unsigned int li return n; } =20 +static struct domain * __init create_dom0(const module_t *image, + unsigned long headroom, + module_t *initrd, char *kextra, + char *loader) +{ + struct xen_domctl_createdomain dom0_cfg =3D { + .flags =3D IS_ENABLED(CONFIG_TBOOT) ? XEN_DOMCTL_CDF_s3_integrity = : 0, + .max_evtchn_port =3D -1, + .max_grant_frames =3D -1, + .max_maptrack_frames =3D -1, + }; + struct domain *d; + char *cmdline; + + if ( opt_dom0_pvh ) + { + dom0_cfg.flags |=3D (XEN_DOMCTL_CDF_hvm | + ((hvm_hap_supported() && !opt_dom0_shadow) ? + XEN_DOMCTL_CDF_hap : 0)); + + dom0_cfg.arch.emulation_flags |=3D + XEN_X86_EMU_LAPIC | XEN_X86_EMU_IOAPIC | XEN_X86_EMU_VPCI; + } + dom0_cfg.max_vcpus =3D dom0_max_vcpus(); + + if ( iommu_enabled ) + dom0_cfg.flags |=3D XEN_DOMCTL_CDF_iommu; + + /* Create initial domain 0. */ + d =3D domain_create(get_initial_domain_id(), &dom0_cfg, !pv_shim); + if ( IS_ERR(d) || (alloc_dom0_vcpu0(d) =3D=3D NULL) ) + panic("Error creating domain 0\n"); + + /* Grab the DOM0 command line. */ + cmdline =3D (char *)(image->string ? __va(image->string) : NULL); + if ( (cmdline !=3D NULL) || (kextra !=3D NULL) ) + { + static char __initdata dom0_cmdline[MAX_GUEST_CMDLINE]; + + cmdline =3D cmdline_cook(cmdline, loader); + safe_strcpy(dom0_cmdline, cmdline); + + if ( kextra !=3D NULL ) + /* kextra always includes exactly one leading space. */ + safe_strcat(dom0_cmdline, kextra); + + /* Append any extra parameters. */ + if ( skip_ioapic_setup && !strstr(dom0_cmdline, "noapic") ) + safe_strcat(dom0_cmdline, " noapic"); + if ( (strlen(acpi_param) =3D=3D 0) && acpi_disabled ) + { + printk("ACPI is disabled, notifying Domain 0 (acpi=3Doff)\n"); + safe_strcpy(acpi_param, "off"); + } + if ( (strlen(acpi_param) !=3D 0) && !strstr(dom0_cmdline, "acpi=3D= ") ) + { + safe_strcat(dom0_cmdline, " acpi=3D"); + safe_strcat(dom0_cmdline, acpi_param); + } + + cmdline =3D dom0_cmdline; + } + + /* + * Temporarily clear SMAP in CR4 to allow user-accesses in construct_d= om0(). + * This saves a large number of corner cases interactions with + * copy_from_user(). + */ + if ( cpu_has_smap ) + { + cr4_pv32_mask &=3D ~X86_CR4_SMAP; + write_cr4(read_cr4() & ~X86_CR4_SMAP); + } + + if ( construct_dom0(d, image, headroom, initrd, cmdline) !=3D 0 ) + panic("Could not construct domain 0\n"); + + if ( cpu_has_smap ) + { + write_cr4(read_cr4() | X86_CR4_SMAP); + cr4_pv32_mask |=3D X86_CR4_SMAP; + } + + return d; +} + /* How much of the directmap is prebuilt at compile time. */ #define PREBUILT_MAP_LIMIT (1 << L2_PAGETABLE_SHIFT) =20 @@ -697,12 +783,6 @@ void __init noreturn __start_xen(unsigned long mbi_p) .parity =3D 'n', .stop_bits =3D 1 }; - struct xen_domctl_createdomain dom0_cfg =3D { - .flags =3D IS_ENABLED(CONFIG_TBOOT) ? XEN_DOMCTL_CDF_s3_integrity = : 0, - .max_evtchn_port =3D -1, - .max_grant_frames =3D -1, - .max_maptrack_frames =3D -1, - }; const char *hypervisor_name; =20 /* Critical region without IDT or TSS. Any fault is deadly! */ @@ -1740,58 +1820,13 @@ void __init noreturn __start_xen(unsigned long mbi_= p) init_guest_cpuid(); init_guest_msr_policy(); =20 - if ( opt_dom0_pvh ) - { - dom0_cfg.flags |=3D (XEN_DOMCTL_CDF_hvm | - ((hvm_hap_supported() && !opt_dom0_shadow) ? - XEN_DOMCTL_CDF_hap : 0)); - - dom0_cfg.arch.emulation_flags |=3D - XEN_X86_EMU_LAPIC | XEN_X86_EMU_IOAPIC | XEN_X86_EMU_VPCI; - } - dom0_cfg.max_vcpus =3D dom0_max_vcpus(); - - if ( iommu_enabled ) - dom0_cfg.flags |=3D XEN_DOMCTL_CDF_iommu; - - /* Create initial domain 0. */ - dom0 =3D domain_create(get_initial_domain_id(), &dom0_cfg, !pv_shim); - if ( IS_ERR(dom0) || (alloc_dom0_vcpu0(dom0) =3D=3D NULL) ) - panic("Error creating domain 0\n"); - - /* Grab the DOM0 command line. */ - cmdline =3D (char *)(mod[0].string ? __va(mod[0].string) : NULL); - if ( (cmdline !=3D NULL) || (kextra !=3D NULL) ) - { - static char __initdata dom0_cmdline[MAX_GUEST_CMDLINE]; - - cmdline =3D cmdline_cook(cmdline, loader); - safe_strcpy(dom0_cmdline, cmdline); - - if ( kextra !=3D NULL ) - /* kextra always includes exactly one leading space. */ - safe_strcat(dom0_cmdline, kextra); - - /* Append any extra parameters. */ - if ( skip_ioapic_setup && !strstr(dom0_cmdline, "noapic") ) - safe_strcat(dom0_cmdline, " noapic"); - if ( (strlen(acpi_param) =3D=3D 0) && acpi_disabled ) - { - printk("ACPI is disabled, notifying Domain 0 (acpi=3Doff)\n"); - safe_strcpy(acpi_param, "off"); - } - if ( (strlen(acpi_param) !=3D 0) && !strstr(dom0_cmdline, "acpi=3D= ") ) - { - safe_strcat(dom0_cmdline, " acpi=3D"); - safe_strcat(dom0_cmdline, acpi_param); - } - - cmdline =3D dom0_cmdline; - } - if ( xen_cpuidle ) xen_processor_pmbits |=3D XEN_PROCESSOR_PM_CX; =20 + printk("%sNX (Execute Disable) protection %sactive\n", + cpu_has_nx ? XENLOG_INFO : XENLOG_WARNING "Warning: ", + cpu_has_nx ? "" : "not "); + initrdidx =3D find_first_bit(module_map, mbi->mods_count); if ( initrdidx < mbi->mods_count ) initrd =3D mod + initrdidx; @@ -1801,34 +1836,14 @@ void __init noreturn __start_xen(unsigned long mbi_= p) "Multiple initrd candidates, picking module #%u\n", initrdidx); =20 - /* - * Temporarily clear SMAP in CR4 to allow user-accesses in construct_d= om0(). - * This saves a large number of corner cases interactions with - * copy_from_user(). - */ - if ( cpu_has_smap ) - { - cr4_pv32_mask &=3D ~X86_CR4_SMAP; - write_cr4(read_cr4() & ~X86_CR4_SMAP); - } - - printk("%sNX (Execute Disable) protection %sactive\n", - cpu_has_nx ? XENLOG_INFO : XENLOG_WARNING "Warning: ", - cpu_has_nx ? "" : "not "); - /* * We're going to setup domain0 using the module(s) that we stashed sa= fely * above our heap. The second module, if present, is an initrd ramdisk. */ - if ( construct_dom0(dom0, mod, modules_headroom, initrd, cmdline) !=3D= 0 ) + dom0 =3D create_dom0(mod, modules_headroom, initrd, kextra, loader); + if ( dom0 =3D=3D NULL ) panic("Could not set up DOM0 guest OS\n"); =20 - if ( cpu_has_smap ) - { - write_cr4(read_cr4() | X86_CR4_SMAP); - cr4_pv32_mask |=3D X86_CR4_SMAP; - } - heap_init_late(); =20 init_trace_bufs(); --=20 2.21.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel