From patchwork Wed Jan 22 08:53:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Woodhouse X-Patchwork-Id: 11345343 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3AE5D924 for ; Wed, 22 Jan 2020 08:55:02 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1641A2253D for ; Wed, 22 Jan 2020 08:55:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="dOdgykW4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1641A2253D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iuBm6-0000oV-Co; Wed, 22 Jan 2020 08:54:10 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iuBm5-0000oI-So for xen-devel@lists.xenproject.org; Wed, 22 Jan 2020 08:54:09 +0000 X-Inumbo-ID: baa781c2-3cf4-11ea-8e9a-bc764e2007e4 Received: from bombadil.infradead.org (unknown [2607:7c80:54:e::133]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id baa781c2-3cf4-11ea-8e9a-bc764e2007e4; Wed, 22 Jan 2020 08:53:59 +0000 (UTC) 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=nomD+Gv8dJiIbPvpWMfuujdVDfv/pDuaZ7kWfwN+3EU=; b=dOdgykW4tyC+jVWLudNrBsu52Y pggBBrIwUVTEW3Uy8iRymVi5f/rUxNQLwL+gT4kujmqjg0ZFab9JHROUSQ5hyw6GovIpS0XGOryxw 3a60GVNRCW1rLfX2MP64n0k68KeGTQl3FP8lKQ3GYFr+rDvytx8Jeem0IC9iY/IdaJHx1nhy77jy0 77TTTxxv06zQS503/eo3ZaByeWM0VwPLBJtr0nz1axYKa3vOZ/44lqmpLg3faROSZQM6WRKdWyiL5 7cuzFSWJUc4r+zc8lvxVTjdOx3PNFs3N7ubEB61ivAMArOD6si6I1jHlKjuBXoyjpHw89NvqmHDuD vwclYk3Q==; 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 1iuBlu-0001yA-EW; Wed, 22 Jan 2020 08:53:58 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.92 #3 (Red Hat Linux)) id 1iuBlt-008mRA-6y; Wed, 22 Jan 2020 08:53:57 +0000 From: David Woodhouse To: Xen-devel Date: Wed, 22 Jan 2020 08:53:44 +0000 Message-Id: <20200122085357.2092778-1-dwmw2@infradead.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <6cbe16ae42ab806df513d359220212d4f01ce43d.camel@infradead.org> References: <6cbe16ae42ab806df513d359220212d4f01ce43d.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] [RFC PATCH v2 01/14] 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 , paul@xen.org, Ian Jackson , Hongyan Xia , Amit Shah , =?utf-8?q?Ro?= =?utf-8?q?ger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" 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 1b6ca4a47d..3c6d0a5b35 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; /* Select relocation address. */ - e = end - reloc_size; - xen_phys_start = e; - bootsym(trampoline_xen_phys_start) = e; + xen_phys_start = end - reloc_size; + e = xen_phys_start + XEN_IMG_OFFSET; + bootsym(trampoline_xen_phys_start) = xen_phys_start; /* * No PTEs pointing above this address are candidates for relocation. @@ -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 = PFN_DOWN(e + XEN_IMG_OFFSET); + pte_update_limit = PFN_DOWN(e); /* * 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 pagetables! */ barrier(); - move_memory(e + XEN_IMG_OFFSET, XEN_IMG_OFFSET, _end - _start, 1); + move_memory(e, XEN_IMG_OFFSET, _end - _start, 1); /* Walk initial pagetables, relocating page directory entries. */ pl4e = __va(__pa(idle_pg_table)); From patchwork Wed Jan 22 08:53:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Woodhouse X-Patchwork-Id: 11345363 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 200CA1580 for ; Wed, 22 Jan 2020 08:55:52 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E5A6E2253D for ; Wed, 22 Jan 2020 08:55:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="AP2P+Yre" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E5A6E2253D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iuBmq-0001KJ-Hv; Wed, 22 Jan 2020 08: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 1iuBmo-0001J4-Tv for xen-devel@lists.xenproject.org; Wed, 22 Jan 2020 08:54:54 +0000 X-Inumbo-ID: be43464a-3cf4-11ea-9fd7-bc764e2007e4 Received: from merlin.infradead.org (unknown [2001:8b0:10b:1231::1]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id be43464a-3cf4-11ea-9fd7-bc764e2007e4; Wed, 22 Jan 2020 08:54:05 +0000 (UTC) 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=YpVFjO2NezexUvdfjMwtHGGd0yQpiB47FeeWuJ9xZnM=; b=AP2P+Yre0b0pUu1To+6JfJhj7B jx/4r7+NAcAQk9rxNn+ejVGNXpYAQCDklTA0K2n7dA+78wYJJJj2PG0G6uJ/6OER1h9UJ12+yNsBF d50RfF9xs6iz63f7aJn8VAxJqVmUihNMPernPUZu/+rurHpsBcDdCDs37fEf1Us17hK1TaV6jLnKQ UlLmuh9TroMkLYYHU+f0k3efnZeHVTvORXwHcloZ21oy/y6ZIgq1J/Vmu93ZELCsoHtnIURAHBrmL HaIzufg2AvBkrMXxN3bhS58JgHCXsAJsfRPg6Vc4CdWbQXbhqjEciHyk33zf2EO2yFFZdqeh1K0+j S2pt8w8Q==; 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 1iuBlu-0002co-1N; Wed, 22 Jan 2020 08:53:59 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.92 #3 (Red Hat Linux)) id 1iuBlt-008mRD-7Y; Wed, 22 Jan 2020 08:53:57 +0000 From: David Woodhouse To: Xen-devel Date: Wed, 22 Jan 2020 08:53:45 +0000 Message-Id: <20200122085357.2092778-2-dwmw2@infradead.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200122085357.2092778-1-dwmw2@infradead.org> References: <6cbe16ae42ab806df513d359220212d4f01ce43d.camel@infradead.org> <20200122085357.2092778-1-dwmw2@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] [RFC PATCH v2 02/14] x86/boot: Reserve live update boot memory 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 , paul@xen.org, Ian Jackson , Hongyan Xia , Amit Shah , =?utf-8?q?Ro?= =?utf-8?q?ger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: David Woodhouse For live update to work, it will need a region of memory that can be given to the boot allocator while it parses the state information from the previous Xen and works out which of the other pages of memory it can consume. Reserve that like the crashdump region, and accept it on the command line. Use only that region for early boot, and register the remaining RAM (all of it for now, until the real live update happens) later. Signed-off-by: David Woodhouse --- xen/arch/x86/setup.c | 114 ++++++++++++++++++++++++++++++++--- xen/include/asm-x86/config.h | 1 + 2 files changed, 108 insertions(+), 7 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 3c6d0a5b35..420c38456b 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -681,6 +681,41 @@ static unsigned int __init copy_bios_e820(struct e820entry *map, unsigned int li /* How much of the directmap is prebuilt at compile time. */ #define PREBUILT_MAP_LIMIT (1 << L2_PAGETABLE_SHIFT) +static unsigned long lu_bootmem_start, lu_bootmem_size, lu_data; + +static int __init parse_liveupdate(const char *str) +{ + const char *cur; + lu_bootmem_size = parse_size_and_unit(cur = str, &str); + if (!lu_bootmem_size || cur == str) + return -EINVAL; + + if (!*str) { + printk("Live update size 0x%lx\n", lu_bootmem_size); + return 0; + } + if (*str != '@') + return -EINVAL; + lu_bootmem_start = parse_size_and_unit(cur = str + 1, &str); + if (!lu_bootmem_start || cur == str) + return -EINVAL; + + printk("Live update area 0x%lx-0x%lx (0x%lx)\n", lu_bootmem_start, + lu_bootmem_start + lu_bootmem_size, lu_bootmem_size); + + if (!*str) + return 0; + if (*str != ':') + return -EINVAL; + lu_data = simple_strtoull(cur = str + 1, &str, 0); + if (!lu_data || cur == str) + return -EINVAL; + + printk("Live update data at 0x%lx\n", lu_data); + return 0; +} +custom_param("liveupdate", parse_liveupdate); + void __init noreturn __start_xen(unsigned long mbi_p) { char *memmap_type = NULL; @@ -690,7 +725,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) module_t *mod; unsigned long nr_pages, raw_max_page, modules_headroom, module_map[1]; int i, j, e820_warn = 0, bytes = 0; - bool acpi_boot_table_init_done = false, relocated = false; + bool acpi_boot_table_init_done = false, relocated = false, lu_reserved = false; int ret; struct ns16550_defaults ns16550 = { .data_bits = 8, @@ -980,6 +1015,22 @@ void __init noreturn __start_xen(unsigned long mbi_p) set_kexec_crash_area_size((u64)nr_pages << PAGE_SHIFT); kexec_reserve_area(&boot_e820); + if ( lu_bootmem_start ) + { + /* XX: Check it's in usable memory first */ + reserve_e820_ram(&boot_e820, lu_bootmem_start, lu_bootmem_start + lu_bootmem_size); + + /* Since it will already be out of the e820 map by the time the first + * loop over physical memory, map it manually already. */ + set_pdx_range(lu_bootmem_start >> PAGE_SHIFT, + (lu_bootmem_start + lu_bootmem_size) >> PAGE_SHIFT); + map_pages_to_xen((unsigned long)__va(lu_bootmem_start), + maddr_to_mfn(lu_bootmem_start), + PFN_DOWN(lu_bootmem_size), PAGE_HYPERVISOR); + + lu_reserved = true; + } + initial_images = mod; nr_initial_images = mbi->mods_count; @@ -1207,6 +1258,16 @@ void __init noreturn __start_xen(unsigned long mbi_p) printk("New Xen image base address: %#lx\n", xen_phys_start); } + /* Is the region suitable for the live update bootmem region? */ + if ( lu_bootmem_size && ! lu_bootmem_start && e < limit ) + { + end = consider_modules(s, e, lu_bootmem_size, mod, mbi->mods_count + relocated, -1); + if ( end ) + { + e = lu_bootmem_start = end - lu_bootmem_size; + } + } + /* Is the region suitable for relocating the multiboot modules? */ for ( j = mbi->mods_count - 1; j >= 0; j-- ) { @@ -1270,6 +1331,15 @@ void __init noreturn __start_xen(unsigned long mbi_p) if ( !xen_phys_start ) panic("Not enough memory to relocate Xen\n"); + if ( lu_bootmem_start ) + { + if ( !lu_reserved ) + reserve_e820_ram(&boot_e820, lu_bootmem_start, lu_bootmem_start + lu_bootmem_size); + printk("LU bootmem: 0x%lx - 0x%lx\n", lu_bootmem_start, lu_bootmem_start + lu_bootmem_size); + init_boot_pages(lu_bootmem_start, lu_bootmem_start + lu_bootmem_size); + lu_reserved = true; + } + /* This needs to remain in sync with xen_in_range(). */ reserve_e820_ram(&boot_e820, __pa(_stext), __pa(__2M_rwdata_end)); @@ -1281,8 +1351,8 @@ void __init noreturn __start_xen(unsigned long mbi_p) xenheap_max_mfn(PFN_DOWN(highmem_start - 1)); /* - * Walk every RAM region and map it in its entirety (on x86/64, at least) - * and notify it to the boot allocator. + * Walk every RAM region and map it in its entirety and (unless in + * live update mode) notify it to the boot allocator. */ for ( i = 0; i < boot_e820.nr_map; i++ ) { @@ -1335,6 +1405,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) printk(XENLOG_WARNING "Ignoring inaccessible memory range" " %013"PRIx64"-%013"PRIx64"\n", s, e); + reserve_e820_ram(&boot_e820, s, e); continue; } map_e = e; @@ -1342,6 +1413,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) printk(XENLOG_WARNING "Ignoring inaccessible memory range" " %013"PRIx64"-%013"PRIx64"\n", e, map_e); + reserve_e820_ram(&boot_e820, e, map_e); } set_pdx_range(s >> PAGE_SHIFT, e >> PAGE_SHIFT); @@ -1352,7 +1424,9 @@ void __init noreturn __start_xen(unsigned long mbi_p) ARRAY_SIZE(l2_identmap) << L2_PAGETABLE_SHIFT); /* Pass mapped memory to allocator /before/ creating new mappings. */ - init_boot_pages(s, min(map_s, e)); + if ( !lu_reserved) + init_boot_pages(s, min(map_s, e)); + s = map_s; if ( s < map_e ) { @@ -1360,7 +1434,8 @@ void __init noreturn __start_xen(unsigned long mbi_p) map_s = (s + mask) & ~mask; map_e &= ~mask; - init_boot_pages(map_s, map_e); + if ( !lu_reserved) + init_boot_pages(map_s, map_e); } if ( map_s > map_e ) @@ -1376,7 +1451,8 @@ void __init noreturn __start_xen(unsigned long mbi_p) { map_pages_to_xen((unsigned long)__va(map_e), maddr_to_mfn(map_e), PFN_DOWN(end - map_e), PAGE_HYPERVISOR); - init_boot_pages(map_e, end); + if ( !lu_reserved) + init_boot_pages(map_e, end); map_e = end; } } @@ -1391,7 +1467,8 @@ void __init noreturn __start_xen(unsigned long mbi_p) { map_pages_to_xen((unsigned long)__va(s), maddr_to_mfn(s), PFN_DOWN(map_s - s), PAGE_HYPERVISOR); - init_boot_pages(s, map_s); + if ( !lu_reserved) + init_boot_pages(s, map_s); } } @@ -1489,6 +1566,29 @@ void __init noreturn __start_xen(unsigned long mbi_p) numa_initmem_init(0, raw_max_page); + if ( lu_bootmem_start ) + { + unsigned long limit = virt_to_mfn(HYPERVISOR_VIRT_END - 1); + uint64_t mask = PAGE_SIZE - 1; + + for ( i = 0; i < boot_e820.nr_map; i++ ) + { + uint64_t s, e; + + if ( boot_e820.map[i].type != E820_RAM ) + continue; + s = (boot_e820.map[i].addr + mask) & ~mask; + e = (boot_e820.map[i].addr + boot_e820.map[i].size) & ~mask; + s = max_t(uint64_t, s, 1<<20); + if ( PFN_DOWN(s) > limit ) + continue; + if ( PFN_DOWN(e) > limit ) + e = pfn_to_paddr(limit); + + init_boot_pages(s, e); + } + } + if ( max_page - 1 > virt_to_mfn(HYPERVISOR_VIRT_END - 1) ) { unsigned long limit = virt_to_mfn(HYPERVISOR_VIRT_END - 1); diff --git a/xen/include/asm-x86/config.h b/xen/include/asm-x86/config.h index dab7d7bade..55f327db70 100644 --- a/xen/include/asm-x86/config.h +++ b/xen/include/asm-x86/config.h @@ -278,6 +278,7 @@ extern unsigned char boot_edid_info[128]; #ifndef __ASSEMBLY__ extern unsigned long xen_phys_start; +extern unsigned long lu_bootmem_start, lu_bootmem_size; #endif /* GDT/LDT shadow mapping area. The first per-domain-mapping sub-area. */ From patchwork Wed Jan 22 08:53:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Woodhouse X-Patchwork-Id: 11345353 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 45C6D139A for ; Wed, 22 Jan 2020 08:55:20 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2257824672 for ; Wed, 22 Jan 2020 08:55:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="Qb0F7KSy" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2257824672 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iuBmQ-0000zl-Nj; Wed, 22 Jan 2020 08:54:30 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iuBmP-0000zJ-Sb for xen-devel@lists.xenproject.org; Wed, 22 Jan 2020 08:54:29 +0000 X-Inumbo-ID: baa5799a-3cf4-11ea-9fd7-bc764e2007e4 Received: from bombadil.infradead.org (unknown [2607:7c80:54:e::133]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id baa5799a-3cf4-11ea-9fd7-bc764e2007e4; Wed, 22 Jan 2020 08:53:59 +0000 (UTC) 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=dC/5xgPaZcGVU6/NspTQoCE57tJqbFRm5i5/smAHE/E=; b=Qb0F7KSyhYwZZyHkZq8owFPz1k TFWQFuID9E5LrD1+Y817zw/FUZGqBzUILG6S7g7MFo5Le0L/+FVYgW17mDcrMn8jqBoTLbCuDyS8M M/OaoHostB7JXRbtpakAphbo/ABsrhsLgbpCoIqqEH8egr/wAyoXEceQLafk8ZMlWa32EY9mvedE3 muAQvUtCxfQTlXs9A872t77ItsFELKNzVoZ2w58MTUjBf/U1BhrJPmt6NExFa1QHKYi5MtVZ+XNo0 fAkSRb3PQanawvFn/Din09/I0o/kVBO7HxwaIFTSzkCHpElKtpx5gms5q6srUNVtJkPRX1iI/cgfh rTAmvKNQ==; 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 1iuBlu-0001yB-F1; Wed, 22 Jan 2020 08:53:58 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.92 #3 (Red Hat Linux)) id 1iuBlt-008mRJ-86; Wed, 22 Jan 2020 08:53:57 +0000 From: David Woodhouse To: Xen-devel Date: Wed, 22 Jan 2020 08:53:46 +0000 Message-Id: <20200122085357.2092778-3-dwmw2@infradead.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200122085357.2092778-1-dwmw2@infradead.org> References: <6cbe16ae42ab806df513d359220212d4f01ce43d.camel@infradead.org> <20200122085357.2092778-1-dwmw2@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] [RFC PATCH v2 03/14] Don't add unused parts of live update reserved bootmem to heap 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 , paul@xen.org, Ian Jackson , Hongyan Xia , Amit Shah , =?utf-8?q?Ro?= =?utf-8?q?ger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: David Woodhouse We need to promise that we won't use it for anything that will need to persist across live update. Until we can achieve that (which will build on of some of the work Hongyan is doing for secret hiding), the easy answer is just not to add that region to the main heap at all. If it was sized appropriately there isn't even much wastage. --- xen/arch/x86/setup.c | 10 ++++++++++ xen/common/page_alloc.c | 5 +++++ xen/include/xen/mm.h | 1 + 3 files changed, 16 insertions(+) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 420c38456b..4296447d9f 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1571,6 +1571,16 @@ void __init noreturn __start_xen(unsigned long mbi_p) unsigned long limit = virt_to_mfn(HYPERVISOR_VIRT_END - 1); uint64_t mask = PAGE_SIZE - 1; + /* + * Pages in the reserved LU region must not be used for anything which + * will need to persist across a live update. There is ongoing work to + * eliminate or limit the use of share_xen_page_with_guest() and get + * to a point where we can actually honour that promise, but for now + * just *don't* add those pages to the heap. Clear the boot allocator + * out completely, before adding the non-reserved ranges. + */ + clear_boot_allocator(); + for ( i = 0; i < boot_e820.nr_map; i++ ) { uint64_t s, e; diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 919a270587..20ef25d45a 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -1879,6 +1879,11 @@ void __init end_boot_allocator(void) printk("\n"); } +void __init clear_boot_allocator(void) +{ + nr_bootmem_regions = 0; +} + static void __init smp_scrub_heap_pages(void *data) { unsigned long mfn, start, end; diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h index 8d0ddfb60c..5bce174a3e 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -158,6 +158,7 @@ struct domain *__must_check page_get_owner_and_reference(struct page_info *); void init_boot_pages(paddr_t ps, paddr_t pe); mfn_t alloc_boot_pages(unsigned long nr_pfns, unsigned long pfn_align); void end_boot_allocator(void); +void clear_boot_allocator(void); /* Xen suballocator. These functions are interrupt-safe. */ void init_xenheap_pages(paddr_t ps, paddr_t pe); From patchwork Wed Jan 22 08:53:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Woodhouse X-Patchwork-Id: 11345351 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E2EF6924 for ; Wed, 22 Jan 2020 08:55:17 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BFD3B24672 for ; Wed, 22 Jan 2020 08:55:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="YOmVLemi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BFD3B24672 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iuBmM-0000wy-EW; Wed, 22 Jan 2020 08:54:26 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iuBmK-0000wN-T1 for xen-devel@lists.xenproject.org; Wed, 22 Jan 2020 08:54:24 +0000 X-Inumbo-ID: baa6db50-3cf4-11ea-aecd-bc764e2007e4 Received: from bombadil.infradead.org (unknown [2607:7c80:54:e::133]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id baa6db50-3cf4-11ea-aecd-bc764e2007e4; Wed, 22 Jan 2020 08:53:59 +0000 (UTC) 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=+S0kYvpeLyNkUVGsaMuA5j56PCidM2RGqFP/X8l6vkw=; b=YOmVLemikCO2OXuoyQqA3IfyUG 7henKRTtEACbH1kRe6mYnnTxl+1RcjKBqxxVTgPAORNDMDYn1NUCRifEtjPtBJXuWjDhS9e5ddnyD sSDBpadE1LJjxhYMm32hoqzf8DUJwX18X08po+jCrj072FcMIm+5vxdSKXS8lUbfdNfOviNfesKTA fHV5kBIMCiS+J1wBWYeDozS0ZPBHx29iN9wmSNfhA8pAu6nOicodRNXxuSbmWX0DZtBajkZshZ1DG Q4Zm+quI5XvpI3PqxmOQR+6bByY3T0vRhoZ7TEOcG3hniij0sURLPrl79xdGEYBUoqplg5V/KtDyl zUbKwvvA==; 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 1iuBlu-0001yC-FK; Wed, 22 Jan 2020 08:53:58 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.92 #3 (Red Hat Linux)) id 1iuBlt-008mRO-8g; Wed, 22 Jan 2020 08:53:57 +0000 From: David Woodhouse To: Xen-devel Date: Wed, 22 Jan 2020 08:53:47 +0000 Message-Id: <20200122085357.2092778-4-dwmw2@infradead.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200122085357.2092778-1-dwmw2@infradead.org> References: <6cbe16ae42ab806df513d359220212d4f01ce43d.camel@infradead.org> <20200122085357.2092778-1-dwmw2@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] [RFC PATCH v2 04/14] Add KEXEC_RANGE_MA_LIVEUPDATE 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 , paul@xen.org, Ian Jackson , Hongyan Xia , Amit Shah , =?utf-8?q?Ro?= =?utf-8?q?ger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: David Woodhouse This allows kexec userspace to tell the next Xen where the range is, on its command line. Signed-off-by: David Woodhouse --- xen/arch/x86/machine_kexec.c | 13 ++++++++++--- xen/arch/x86/setup.c | 2 +- xen/include/public/kexec.h | 1 + 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/machine_kexec.c b/xen/arch/x86/machine_kexec.c index b70d5a6a86..273bc20664 100644 --- a/xen/arch/x86/machine_kexec.c +++ b/xen/arch/x86/machine_kexec.c @@ -186,9 +186,16 @@ void machine_kexec(struct kexec_image *image) int machine_kexec_get(xen_kexec_range_t *range) { - if (range->range != KEXEC_RANGE_MA_XEN) - return -EINVAL; - return machine_kexec_get_xen(range); + switch (range->range) { + case KEXEC_RANGE_MA_XEN: + return machine_kexec_get_xen(range); + case KEXEC_RANGE_MA_LIVEUPDATE: + range->start = lu_bootmem_start; + range->size = lu_bootmem_size; + return 0; + default: + return -EINVAL; + } } void arch_crash_save_vmcoreinfo(void) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 4296447d9f..521946dc27 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -681,7 +681,7 @@ static unsigned int __init copy_bios_e820(struct e820entry *map, unsigned int li /* How much of the directmap is prebuilt at compile time. */ #define PREBUILT_MAP_LIMIT (1 << L2_PAGETABLE_SHIFT) -static unsigned long lu_bootmem_start, lu_bootmem_size, lu_data; +unsigned long lu_bootmem_start, lu_bootmem_size, lu_data; static int __init parse_liveupdate(const char *str) { diff --git a/xen/include/public/kexec.h b/xen/include/public/kexec.h index 3f2a118381..298381af8d 100644 --- a/xen/include/public/kexec.h +++ b/xen/include/public/kexec.h @@ -150,6 +150,7 @@ typedef struct xen_kexec_load_v1 { #define KEXEC_RANGE_MA_EFI_MEMMAP 5 /* machine address and size of * of the EFI Memory Map */ #define KEXEC_RANGE_MA_VMCOREINFO 6 /* machine address and size of vmcoreinfo */ +#define KEXEC_RANGE_MA_LIVEUPDATE 7 /* Boot mem for live update */ /* * Find the address and size of certain memory areas From patchwork Wed Jan 22 08:53:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Woodhouse X-Patchwork-Id: 11345341 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 86D51139A for ; Wed, 22 Jan 2020 08:54:55 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 636DF2253D for ; Wed, 22 Jan 2020 08:54:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="B0/HP7/M" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 636DF2253D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iuBm1-0000m9-Tv; Wed, 22 Jan 2020 08:54:05 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iuBm0-0000lq-TE for xen-devel@lists.xenproject.org; Wed, 22 Jan 2020 08:54:04 +0000 X-Inumbo-ID: baa823d4-3cf4-11ea-8e9a-bc764e2007e4 Received: from bombadil.infradead.org (unknown [2607:7c80:54:e::133]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id baa823d4-3cf4-11ea-8e9a-bc764e2007e4; Wed, 22 Jan 2020 08:53:59 +0000 (UTC) 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=qmmRLb0NdTnw1b2mbJsYwt47rxkECNQNxPoVyBberGo=; b=B0/HP7/M7TR7D/wAqiepBoD0Qq qh8NKwlV/RsV55qEQbUXCzdVf4AdwD+SPLH0HKNF7309ZikoxJ1V6HNpnvtY3WAKqmC069mnGcxP6 2RrqpPm6pNCyXclEJw0Eym3iNFVMs+jK8N6Hp4u+6vTljMO3RD7Crehhw5lNrWGT4kshJunJ5OJ7p CI9FYfwHIiEvcdgc5DB2ifAx5LmVpC/vei0Ax4JYc8irP4ApZ+vCk5iGo792wpbsIFOHU1hnJT7+u Z+lDzZJxLKsQ4OfqGOY0QB+WmlU0RBLhTgFWYsQJWd1Kcz3GB06GbJo8paWVAqKGwawmN6l5hR8MV cEtn2voA==; 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 1iuBlu-0001yD-Fr; Wed, 22 Jan 2020 08:53:58 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.92 #3 (Red Hat Linux)) id 1iuBlt-008mRT-9E; Wed, 22 Jan 2020 08:53:57 +0000 From: David Woodhouse To: Xen-devel Date: Wed, 22 Jan 2020 08:53:48 +0000 Message-Id: <20200122085357.2092778-5-dwmw2@infradead.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200122085357.2092778-1-dwmw2@infradead.org> References: <6cbe16ae42ab806df513d359220212d4f01ce43d.camel@infradead.org> <20200122085357.2092778-1-dwmw2@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] [RFC PATCH v2 05/14] Add KEXEC_TYPE_LIVE_UPDATE 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 , paul@xen.org, Ian Jackson , Hongyan Xia , Amit Shah , =?utf-8?q?Ro?= =?utf-8?q?ger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: David Woodhouse This is identical to the default case... for now. Signed-off-by: David Woodhouse --- xen/common/kexec.c | 18 ++++++++++++++++++ xen/include/public/kexec.h | 12 ++++++++---- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/xen/common/kexec.c b/xen/common/kexec.c index a262cc5a18..a78aa4f5b0 100644 --- a/xen/common/kexec.c +++ b/xen/common/kexec.c @@ -404,6 +404,19 @@ static long kexec_reboot(void *_image) return 0; } +static long kexec_live_update(void *_image) +{ + struct kexec_image *image = _image; + + kexecing = TRUE; + + kexec_common_shutdown(); + machine_reboot_kexec(image); + + BUG(); + return 0; +} + static void do_crashdump_trigger(unsigned char key) { printk("'%c' pressed -> triggering crashdump\n", key); @@ -736,6 +749,7 @@ static int kexec_load_get_bits(int type, int *base, int *bit) switch ( type ) { case KEXEC_TYPE_DEFAULT: + case KEXEC_TYPE_LIVE_UPDATE: *base = KEXEC_IMAGE_DEFAULT_BASE; *bit = KEXEC_FLAG_DEFAULT_POS; break; @@ -837,6 +851,10 @@ static int kexec_exec(XEN_GUEST_HANDLE_PARAM(void) uarg) image = kexec_image[base + pos]; ret = continue_hypercall_on_cpu(0, kexec_reboot, image); break; + case KEXEC_TYPE_LIVE_UPDATE: + image = kexec_image[base + pos]; + ret = continue_hypercall_on_cpu(0, kexec_live_update, image); + break; case KEXEC_TYPE_CRASH: kexec_crash(); /* Does not return */ break; diff --git a/xen/include/public/kexec.h b/xen/include/public/kexec.h index 298381af8d..f5230286d3 100644 --- a/xen/include/public/kexec.h +++ b/xen/include/public/kexec.h @@ -71,18 +71,22 @@ */ /* - * Kexec supports two types of operation: + * Kexec supports three types of operation: * - kexec into a regular kernel, very similar to a standard reboot * - KEXEC_TYPE_DEFAULT is used to specify this type * - kexec into a special "crash kernel", aka kexec-on-panic * - KEXEC_TYPE_CRASH is used to specify this type * - parts of our system may be broken at kexec-on-panic time * - the code should be kept as simple and self-contained as possible + * - Live update into a new Xen, preserving all running domains + * - KEXEC_TYPE_LIVE_UPDATE is used to specify this type + * - Xen performs guest-transparent live migration and stores live + * update state in memory, passing it to the new Xen. */ -#define KEXEC_TYPE_DEFAULT 0 -#define KEXEC_TYPE_CRASH 1 - +#define KEXEC_TYPE_DEFAULT 0 +#define KEXEC_TYPE_CRASH 1 +#define KEXEC_TYPE_LIVE_UPDATE 2 /* The kexec implementation for Xen allows the user to load two * types of kernels, KEXEC_TYPE_DEFAULT and KEXEC_TYPE_CRASH. From patchwork Wed Jan 22 08:53:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Woodhouse X-Patchwork-Id: 11345345 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 53FC61820 for ; Wed, 22 Jan 2020 08:55:02 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3040224672 for ; Wed, 22 Jan 2020 08:55:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="rowZcxFz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3040224672 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iuBlx-0000kb-KH; Wed, 22 Jan 2020 08:54:01 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iuBlv-0000kI-TH for xen-devel@lists.xenproject.org; Wed, 22 Jan 2020 08:53:59 +0000 X-Inumbo-ID: baa6679c-3cf4-11ea-aecd-bc764e2007e4 Received: from bombadil.infradead.org (unknown [2607:7c80:54:e::133]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id baa6679c-3cf4-11ea-aecd-bc764e2007e4; Wed, 22 Jan 2020 08:53:59 +0000 (UTC) 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=p233OatuRQuoWS6LOUmWPlwIXjbBEnNCI12DOuMnnC8=; b=rowZcxFz/1a7uBUKZ17pXnmB2I /W39PPTxOf1xBW2Ii5tK8aLOW4VNsaaxj7rIjUtfSTpBs/FwX17XnIuSKCGNrK91AS3n6MP/F3k1A pfbtB3RYSlB3lpFIBj9ZgRva3ppPTlYc08LZk6+tpkRxdG8mhhEOFeiHuBi6U/6dGy6d4kevzby2h 3Wbza7rp+B/zXXvVLp01GLmWMTC6Izi3r+LnGhT7/FKtfswzB7ifmnd5z+8mCfB5bIGe1rjsQvnu3 i1Y/pJpFjg2sR6FHcYklDcdAnXkK/FY5ToMi4taaA9FhxvRXkuwk2MtErNdbTSn+b6ZtZLO4RLVOn oa498Vzg==; 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 1iuBlu-0001yE-Gf; Wed, 22 Jan 2020 08:53:58 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.92 #3 (Red Hat Linux)) id 1iuBlt-008mRY-9l; Wed, 22 Jan 2020 08:53:57 +0000 From: David Woodhouse To: Xen-devel Date: Wed, 22 Jan 2020 08:53:49 +0000 Message-Id: <20200122085357.2092778-6-dwmw2@infradead.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200122085357.2092778-1-dwmw2@infradead.org> References: <6cbe16ae42ab806df513d359220212d4f01ce43d.camel@infradead.org> <20200122085357.2092778-1-dwmw2@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] [RFC PATCH v2 06/14] Add IND_WRITE64 primitive to kexec kimage 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 , paul@xen.org, Ian Jackson , Hongyan Xia , Amit Shah , =?utf-8?q?Ro?= =?utf-8?q?ger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: David Woodhouse This allows a single page-aligned physical address to be written to the current destination, intended to pass the location of the live update data stream from one Xen to the next. Signed-off-by: David Woodhouse --- xen/arch/x86/x86_64/kexec_reloc.S | 9 ++++++++- xen/include/xen/kimage.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/x86_64/kexec_reloc.S b/xen/arch/x86/x86_64/kexec_reloc.S index d488d127cf..a75f989926 100644 --- a/xen/arch/x86/x86_64/kexec_reloc.S +++ b/xen/arch/x86/x86_64/kexec_reloc.S @@ -131,11 +131,18 @@ is_source: jmp next_entry is_zero: testb $IND_ZERO, %cl - jz next_entry + jz is_write64 movl $(PAGE_SIZE / 8), %ecx /* Zero the destination page. */ xorl %eax, %eax rep stosq jmp next_entry +is_write64: + testb $IND_WRITE64, %cl + jz next_entry + andq $PAGE_MASK, %rcx + movq %rcx, %rax + stosq + jmp next_entry done: popq %rbx ret diff --git a/xen/include/xen/kimage.h b/xen/include/xen/kimage.h index cbfb9e9054..e94839d7c3 100644 --- a/xen/include/xen/kimage.h +++ b/xen/include/xen/kimage.h @@ -6,6 +6,7 @@ #define IND_DONE 0x4 #define IND_SOURCE 0x8 #define IND_ZERO 0x10 +#define IND_WRITE64 0x20 #ifndef __ASSEMBLY__ From patchwork Wed Jan 22 08:53:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Woodhouse X-Patchwork-Id: 11345365 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 203C01580 for ; Wed, 22 Jan 2020 08:55:58 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F125A2253D for ; Wed, 22 Jan 2020 08:55:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="SHbZotmy" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F125A2253D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iuBmv-0001OO-40; Wed, 22 Jan 2020 08:55:01 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iuBmt-0001NY-Tl for xen-devel@lists.xenproject.org; Wed, 22 Jan 2020 08:54:59 +0000 X-Inumbo-ID: be432692-3cf4-11ea-aecd-bc764e2007e4 Received: from merlin.infradead.org (unknown [2001:8b0:10b:1231::1]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id be432692-3cf4-11ea-aecd-bc764e2007e4; Wed, 22 Jan 2020 08:54:05 +0000 (UTC) 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=hoCDVMisbEijMobCdAo8zjqMwSBE37ecdhHuRielXvg=; b=SHbZotmychYr+IjAlXS1yg1KHL 6pp4Ltjdm+MFJRlleRXuQeA/U/N6+nCXwNrN2/lxawd5r/kuHu3WCLfHyPnsrwA8zpW4+UcVsnmZx bRyKobS7+oq9frDnbIhc4G5nWsUC4O74uFAj1liui1YvH1T0SsOiWDlhCb4NzqAUqzsFYe20A1bgd 2g8cmDfGzsldWbVZtrJtLAikM1DReandXv6RiyYazys5Z+iRGWJ8w5da4eUn5cgplCcLfkX6m3KoX 37KlK2HxnjSaJiG6/cM6rCBWpRDZ6cUdNWQELjnAAPBIds9juO76RHdyrj0UkTOyRjd5iXXLU27Mp sanCkemA==; 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 1iuBlu-0002cp-3v; Wed, 22 Jan 2020 08:53:58 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.92 #3 (Red Hat Linux)) id 1iuBlt-008mRd-AH; Wed, 22 Jan 2020 08:53:57 +0000 From: David Woodhouse To: Xen-devel Date: Wed, 22 Jan 2020 08:53:50 +0000 Message-Id: <20200122085357.2092778-7-dwmw2@infradead.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200122085357.2092778-1-dwmw2@infradead.org> References: <6cbe16ae42ab806df513d359220212d4f01ce43d.camel@infradead.org> <20200122085357.2092778-1-dwmw2@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] [RFC PATCH v2 07/14] Add kimage_add_live_update_data() 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 , paul@xen.org, Ian Jackson , Hongyan Xia , Amit Shah , =?utf-8?q?Ro?= =?utf-8?q?ger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: David Woodhouse Signed-off-by: David Woodhouse --- xen/common/kimage.c | 33 +++++++++++++++++++++++++++++++++ xen/include/asm-x86/config.h | 2 ++ xen/include/xen/kimage.h | 3 +++ 3 files changed, 38 insertions(+) diff --git a/xen/common/kimage.c b/xen/common/kimage.c index 210241dfb7..eafa6a9c26 100644 --- a/xen/common/kimage.c +++ b/xen/common/kimage.c @@ -938,6 +938,39 @@ done: return ret; } +int kimage_add_live_update_data(struct kexec_image *image, mfn_t data, int nr_mfns) +{ + int ret; + + /* + * For live update, we place the physical location of 'data' + * into the first 64 bits of the reserved live update bootmem + * region. At 'data' is an MFN list of pages containing the + * actual live update stream, which the new Xen can vmap(). + * + * Append IND_WRITE64 operations to the end of the kimage stream + * to store the live update magic and the address of 'data' for + * the new Xen to see. + */ + if (!lu_bootmem_start || kimage_dst_used(image, lu_bootmem_start)) + return -EINVAL; + + ret = machine_kexec_add_page(image, lu_bootmem_start, lu_bootmem_start); + if ( ret < 0 ) + return ret; + + ret = kimage_set_destination(image, lu_bootmem_start); + if (!ret) + ret = kimage_add_entry(image, LIVE_UPDATE_MAGIC | IND_WRITE64); + if (!ret) + ret = kimage_add_entry(image, mfn_to_maddr(data) | IND_WRITE64); + if (!ret) + ret = kimage_add_entry(image, (nr_mfns << PAGE_SHIFT) | IND_WRITE64); + + kimage_terminate(image); + + return ret; +} /* * Local variables: * mode: C diff --git a/xen/include/asm-x86/config.h b/xen/include/asm-x86/config.h index 55f327db70..e80cfd54f0 100644 --- a/xen/include/asm-x86/config.h +++ b/xen/include/asm-x86/config.h @@ -281,6 +281,8 @@ extern unsigned long xen_phys_start; extern unsigned long lu_bootmem_start, lu_bootmem_size; #endif +#define LIVE_UPDATE_MAGIC (0x4c69766555700000UL) + /* GDT/LDT shadow mapping area. The first per-domain-mapping sub-area. */ #define GDT_LDT_VCPU_SHIFT 5 #define GDT_LDT_VCPU_VA_SHIFT (GDT_LDT_VCPU_SHIFT + PAGE_SHIFT) diff --git a/xen/include/xen/kimage.h b/xen/include/xen/kimage.h index e94839d7c3..1e0e378afd 100644 --- a/xen/include/xen/kimage.h +++ b/xen/include/xen/kimage.h @@ -54,6 +54,9 @@ unsigned long kimage_entry_ind(kimage_entry_t *entry, bool_t compat); int kimage_build_ind(struct kexec_image *image, mfn_t ind_mfn, bool_t compat); +int kimage_add_live_update_data(struct kexec_image *image, mfn_t data, + int nr_mfns); + #endif /* __ASSEMBLY__ */ #endif /* __XEN_KIMAGE_H__ */ From patchwork Wed Jan 22 08:53:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Woodhouse X-Patchwork-Id: 11345367 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0F190139A for ; Wed, 22 Jan 2020 08:56:05 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DFAAC2253D for ; Wed, 22 Jan 2020 08:56:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="NB9NZBVZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DFAAC2253D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iuBn0-0001T1-Fh; Wed, 22 Jan 2020 08:55: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 1iuBmy-0001Rz-Un for xen-devel@lists.xenproject.org; Wed, 22 Jan 2020 08:55:04 +0000 X-Inumbo-ID: be42c6ac-3cf4-11ea-8e9a-bc764e2007e4 Received: from merlin.infradead.org (unknown [2001:8b0:10b:1231::1]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id be42c6ac-3cf4-11ea-8e9a-bc764e2007e4; Wed, 22 Jan 2020 08:54:06 +0000 (UTC) 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=FHPcS0DtLZaNzZQhavkVgyBADnomo0xIa8I6Bc0tqgM=; b=NB9NZBVZUY79m7tHXxgG0Sw4+b /FTkzCLDttmfU7na20FdCMM+MCb9SLUXxlXp+B4YMt4/R4EQSRHHVpK3XH0E4cX6kflOkn8YbqvnL IqDjcmfxU5KH1uFei4ZFB3V4dkP28/NNnGcPMAW1Mp2MXsmQaJxXpxMAvPwo3gFAhzfckAcHt/xvo 1J8Wok025Tj8vHE0CZeiw5q/+wWKlTMF4wcbQz2Toj+7K27KirxeFt8y3kvVz6ArRkVUoKTbHa8JV L1dAWztQ3FnSWxtCaad7JWVY5dyLiYdMjGewRg0uCUgqusLaHbV/qm4TEAkdYbRc8zD/I0LRNvItK UeDE1A0g==; 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 1iuBlu-0002cq-4Q; Wed, 22 Jan 2020 08:53:58 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.92 #3 (Red Hat Linux)) id 1iuBlt-008mRi-Ap; Wed, 22 Jan 2020 08:53:57 +0000 From: David Woodhouse To: Xen-devel Date: Wed, 22 Jan 2020 08:53:51 +0000 Message-Id: <20200122085357.2092778-8-dwmw2@infradead.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200122085357.2092778-1-dwmw2@infradead.org> References: <6cbe16ae42ab806df513d359220212d4f01ce43d.camel@infradead.org> <20200122085357.2092778-1-dwmw2@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] [RFC PATCH v2 08/14] Add basic live update stream creation 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 , paul@xen.org, Ian Jackson , Hongyan Xia , Amit Shah , =?utf-8?q?Ro?= =?utf-8?q?ger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: David Woodhouse Signed-off-by: David Woodhouse --- xen/common/Makefile | 1 + xen/common/lu/Makefile | 1 + xen/common/lu/stream.c | 108 +++++++++++++++++++++++++++++++++++++++++ xen/include/xen/lu.h | 12 +++++ 4 files changed, 122 insertions(+) create mode 100644 xen/common/lu/Makefile create mode 100644 xen/common/lu/stream.c create mode 100644 xen/include/xen/lu.h diff --git a/xen/common/Makefile b/xen/common/Makefile index 62b34e69e9..36c824a99a 100644 --- a/xen/common/Makefile +++ b/xen/common/Makefile @@ -78,3 +78,4 @@ subdir-$(CONFIG_UBSAN) += ubsan subdir-$(CONFIG_NEEDS_LIBELF) += libelf subdir-$(CONFIG_HAS_DEVICE_TREE) += libfdt +subdir-y += lu diff --git a/xen/common/lu/Makefile b/xen/common/lu/Makefile new file mode 100644 index 0000000000..68991b3ca4 --- /dev/null +++ b/xen/common/lu/Makefile @@ -0,0 +1 @@ +obj-y += stream.o diff --git a/xen/common/lu/stream.c b/xen/common/lu/stream.c new file mode 100644 index 0000000000..52030e8b2e --- /dev/null +++ b/xen/common/lu/stream.c @@ -0,0 +1,108 @@ +/* + * Live update data stream handling. + * + * During live update, one version of Xen (Xen#1) performs a kexec into + * a new version of Xen (Xen#2), performing guest-transparent live + * migration of all existing domains. + * + * Xen#2 must avoid scribbling on any pages which may belong to existing + * domains. In order to achieve this, we reserve a contiguous area of + * physical memory to be used by the boot allocator in Xen#2. Xen must + * not allocate pages from that region which are later shared with + * guests or need to persist across live update. + * + * The live update bootmem region is reserved by the first Xen to boot, + * and userspace can obtain its address using KEXEC_CMD_kexec_get_range + * with the new KEXEC_RANGE_MA_LIVEUPDATE type. Userspace kexec(8) + * appends the appropriate 'liveupdate=' parameter to the command line + * of Xen#2 when setting up the kexec image. + * + * At the time of kexec, Xen#1 serialises the domain state into buffers + * allocated from its own heap., then creates a single physically + * contiguous scatter-gather list containing the MFNs of those data + * pages (which Xen#2 can then trivially vmap()). In a system with + * 4KiB pages, the MFN list for the live update data stream will fit + * into a single page until the total size of the live update data + * exceeds 2MiB. + * + * The physical address of the MFN list is passed to Xen#2 by placing + * it at the start of the reserved live update bootmem region, with a + * magic number to avoid false positives. + */ + +#include +#include +#include + +static int lu_stream_extend(struct lu_stream *stream, int nr_pages) +{ + int order = get_order_from_bytes((nr_pages + 1) * sizeof(mfn_t)); + int old_order = get_order_from_bytes((stream->nr_pages + 1) * sizeof(mfn_t)); + + if (!stream->nr_pages || order > old_order) { + mfn_t *new_pglist = alloc_xenheap_pages(order, 0); + if (!new_pglist) + return -ENOMEM; + + if (stream->nr_pages) { + memcpy(new_pglist, stream->pagelist, + stream->nr_pages * sizeof(mfn_t)); + free_xenheap_pages(stream->pagelist, old_order); + } + stream->pagelist = new_pglist; + } + while (stream->nr_pages < nr_pages) { + struct page_info *pg = alloc_domheap_page(NULL, MEMF_no_owner); + if (!pg) { + /* Ensure the cleanup frees the correct order of pagelist */ + stream->nr_pages++; + return -ENOMEM; + } + stream->pagelist[stream->nr_pages++] = page_to_mfn(pg); + stream->pagelist[stream->nr_pages] = 0; + } + + if (stream->data) + vunmap(stream->data); + stream->data = vmap(stream->pagelist, stream->nr_pages); + if (!stream->data) + return -ENOMEM; + + return 0; +} + +void *lu_stream_reserve(struct lu_stream *stream, size_t size) +{ + int nr_pages = (stream->len + size + PAGE_SIZE - 1) >> PAGE_SHIFT; + + if (stream->nr_pages < nr_pages && lu_stream_extend(stream, nr_pages)) + return NULL; + + return stream->data + stream->len; +} + +void lu_stream_end_reservation(struct lu_stream *stream, size_t size) +{ + stream->len += size; +} + +int lu_stream_append(struct lu_stream *stream, void *data, size_t size) +{ + void *p = lu_stream_reserve(stream, size); + if (!p) + return -ENOMEM; + memcpy(p, data, size); + lu_stream_end_reservation(stream, size); + + return 0; +} + +void lu_stream_free(struct lu_stream *stream) +{ + int order = get_order_from_bytes((stream->nr_pages + 1) * sizeof(mfn_t)); + + if (stream->pagelist) + free_xenheap_pages(stream->pagelist, order); + if (stream->data) + vunmap(stream->data); +} diff --git a/xen/include/xen/lu.h b/xen/include/xen/lu.h new file mode 100644 index 0000000000..cb2f1dbe06 --- /dev/null +++ b/xen/include/xen/lu.h @@ -0,0 +1,12 @@ + +struct lu_stream { + mfn_t *pagelist; + size_t len; + int nr_pages; + char *data; +}; + +void *lu_stream_reserve(struct lu_stream *stream, size_t size); +void lu_stream_end_reservation(struct lu_stream *stream, size_t size); +int lu_stream_append(struct lu_stream *stream, void *data, size_t size); +void lu_stream_free(struct lu_stream *stream); From patchwork Wed Jan 22 08:53:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Woodhouse X-Patchwork-Id: 11345359 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8352E924 for ; Wed, 22 Jan 2020 08:55:37 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5FE012253D for ; Wed, 22 Jan 2020 08:55:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="gO3le3Jn" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5FE012253D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iuBml-0001Fy-7J; Wed, 22 Jan 2020 08:54:51 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iuBmj-0001F0-Tr for xen-devel@lists.xenproject.org; Wed, 22 Jan 2020 08:54:49 +0000 X-Inumbo-ID: be41eb74-3cf4-11ea-b833-bc764e2007e4 Received: from merlin.infradead.org (unknown [2001:8b0:10b:1231::1]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id be41eb74-3cf4-11ea-b833-bc764e2007e4; Wed, 22 Jan 2020 08:54:05 +0000 (UTC) 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=var8fE0CFHkpxyo42WantTfe48iSaJODKoM74jdvIxc=; b=gO3le3JnxQ0OtMC/4Vv9LkHByH 6vKiRqSrQV5nC2AQ/bZ5HTjgVnKfW/J6LpF8izGwUAsCnJxmvfU/DvWHDyfFJvVoHZR87tQuEx8pJ 7r3YcpRFR4+p8eIbLskjmjCnU5W99+OVwhNzfNQF8gXgl6w8x30nt6XB4Y8Oo0D5IsW8q1MjduMOm TR5P8171UWcfs/fNMZaoIBZpWvC3JENUioJQt2FYTs1kG+yH5h1dE3NzL4AIpGeZliWjYpl8MwZwJ sXzR0Cnjuvekfufvda7SVxxKzITb0REugBHippyzAZgkOmKceDWu0Cqi/ohKty58ulh3Lgean1I3S 2oDZWQmA==; 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 1iuBlu-0002cr-53; Wed, 22 Jan 2020 08:53:58 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.92 #3 (Red Hat Linux)) id 1iuBlt-008mRn-BM; Wed, 22 Jan 2020 08:53:57 +0000 From: David Woodhouse To: Xen-devel Date: Wed, 22 Jan 2020 08:53:52 +0000 Message-Id: <20200122085357.2092778-9-dwmw2@infradead.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200122085357.2092778-1-dwmw2@infradead.org> References: <6cbe16ae42ab806df513d359220212d4f01ce43d.camel@infradead.org> <20200122085357.2092778-1-dwmw2@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] [RFC PATCH v2 09/14] Add basic lu_save_all() shell 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 , paul@xen.org, Ian Jackson , Hongyan Xia , Amit Shah , =?utf-8?q?Ro?= =?utf-8?q?ger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: David Woodhouse --- xen/common/kexec.c | 6 ++++++ xen/common/lu/Makefile | 2 +- xen/common/lu/save.c | 45 ++++++++++++++++++++++++++++++++++++++++++ xen/include/xen/lu.h | 3 +++ 4 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 xen/common/lu/save.c diff --git a/xen/common/kexec.c b/xen/common/kexec.c index a78aa4f5b0..658fe3d3d4 100644 --- a/xen/common/kexec.c +++ b/xen/common/kexec.c @@ -29,6 +29,7 @@ #include #include #include +#include #ifdef CONFIG_COMPAT #include #endif @@ -407,6 +408,11 @@ static long kexec_reboot(void *_image) static long kexec_live_update(void *_image) { struct kexec_image *image = _image; + int ret; + + ret = lu_save_all(image); + if (ret) + return ret; kexecing = TRUE; diff --git a/xen/common/lu/Makefile b/xen/common/lu/Makefile index 68991b3ca4..7b7d975f65 100644 --- a/xen/common/lu/Makefile +++ b/xen/common/lu/Makefile @@ -1 +1 @@ -obj-y += stream.o +obj-y += stream.o save.o diff --git a/xen/common/lu/save.c b/xen/common/lu/save.c new file mode 100644 index 0000000000..c767abd8f4 --- /dev/null +++ b/xen/common/lu/save.c @@ -0,0 +1,45 @@ + +#include +#include +#include +#include +#include + +int lu_save_global(struct lu_stream *stream) +{ + return 0; +} + + +int lu_save_domain(struct lu_stream *stream, struct domain *d) +{ + return 0; +} + +int lu_save_all(struct kexec_image *image) +{ + struct lu_stream stream; + struct domain *d; + int ret; + + memset(&stream, 0, sizeof(stream)); + + ret = lu_save_global(&stream); + + for_each_domain ( d ) { + if (ret) + break; + + ret = lu_save_domain(&stream, d); + } + + if (!ret) + ret = kimage_add_live_update_data(image, + virt_to_mfn(stream.pagelist), + stream.nr_pages); + + if (ret) + lu_stream_free(&stream); + + return ret; +} diff --git a/xen/include/xen/lu.h b/xen/include/xen/lu.h index cb2f1dbe06..6e8377b6c3 100644 --- a/xen/include/xen/lu.h +++ b/xen/include/xen/lu.h @@ -10,3 +10,6 @@ void *lu_stream_reserve(struct lu_stream *stream, size_t size); void lu_stream_end_reservation(struct lu_stream *stream, size_t size); int lu_stream_append(struct lu_stream *stream, void *data, size_t size); void lu_stream_free(struct lu_stream *stream); + +struct kexec_image; +int lu_save_all(struct kexec_image *image); From patchwork Wed Jan 22 08:53:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Woodhouse X-Patchwork-Id: 11345349 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 01DBA924 for ; Wed, 22 Jan 2020 08:55:14 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D1D282253D for ; Wed, 22 Jan 2020 08:55:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="ipMAg5MF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D1D282253D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iuBmH-0000u6-3f; Wed, 22 Jan 2020 08:54:21 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iuBmF-0000tT-SQ for xen-devel@lists.xenproject.org; Wed, 22 Jan 2020 08:54:19 +0000 X-Inumbo-ID: baa607ca-3cf4-11ea-9fd7-bc764e2007e4 Received: from bombadil.infradead.org (unknown [2607:7c80:54:e::133]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id baa607ca-3cf4-11ea-9fd7-bc764e2007e4; Wed, 22 Jan 2020 08:53:59 +0000 (UTC) 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=+BtXSlgyeflrSdE48ilu1IH+30zwlR/Piqnq0fHOrOg=; b=ipMAg5MFbk5EoiEZYS2WBQY4/a gcsKHd32ySPl4cbfXWc39bU7zqWfnhkxtCBY5ziBkHxOWFQAFowixubw7dPEYjm4ZXr9GmSnuksDI lgWYQqqVheQPYyO/JEAy0HmL6TTgpgZGVuIQXrm9KBAVCoNuPqmD8Hz/zL0TIvFJce+UOokwVvQN0 +Ld95xEj+a02un5ELLu059R/S0v+IcslzVBMuH9kjZZkuJn/UB1IbbMz3Ig+w6Ot1mwkHnQcEYGwA kw+RFPAC2r7fLkd/GTY87mS0U8qo/4yLhlubBULhUBkhb5bV84bG1IhZWT7VfrF2hWoQN6D60UnzZ 2QHJvvvw==; 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 1iuBlu-0001yF-JC; Wed, 22 Jan 2020 08:53:58 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.92 #3 (Red Hat Linux)) id 1iuBlt-008mRs-C3; Wed, 22 Jan 2020 08:53:57 +0000 From: David Woodhouse To: Xen-devel Date: Wed, 22 Jan 2020 08:53:53 +0000 Message-Id: <20200122085357.2092778-10-dwmw2@infradead.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200122085357.2092778-1-dwmw2@infradead.org> References: <6cbe16ae42ab806df513d359220212d4f01ce43d.camel@infradead.org> <20200122085357.2092778-1-dwmw2@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] [RFC PATCH v2 10/14] Put *something* into LU data... 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 , paul@xen.org, Ian Jackson , Hongyan Xia , Amit Shah , =?utf-8?q?Ro?= =?utf-8?q?ger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: David Woodhouse Signed-off-by: David Woodhouse --- xen/common/lu/save.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/common/lu/save.c b/xen/common/lu/save.c index c767abd8f4..24d727ff47 100644 --- a/xen/common/lu/save.c +++ b/xen/common/lu/save.c @@ -7,7 +7,7 @@ int lu_save_global(struct lu_stream *stream) { - return 0; + return lu_stream_append(stream, "Hello World!", 12); } From patchwork Wed Jan 22 08:53:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Woodhouse X-Patchwork-Id: 11345361 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1FD60924 for ; Wed, 22 Jan 2020 08:55:40 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F018524672 for ; Wed, 22 Jan 2020 08:55:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="gVZ3r8Jp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F018524672 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iuBmb-00017w-Hu; Wed, 22 Jan 2020 08:54:41 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iuBmZ-00016q-TZ for xen-devel@lists.xenproject.org; Wed, 22 Jan 2020 08:54:39 +0000 X-Inumbo-ID: be438876-3cf4-11ea-aecd-bc764e2007e4 Received: from merlin.infradead.org (unknown [2001:8b0:10b:1231::1]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id be438876-3cf4-11ea-aecd-bc764e2007e4; Wed, 22 Jan 2020 08:54:05 +0000 (UTC) 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=9TwAYGYlcelt/F0YlAPGXX2H4Bo71w4f4pVagbaPYhM=; b=gVZ3r8JpLQ8Y8spelTlHomcOBP AWVkWXYYOZb11Y+mk3hK8f9x1uBsmtxqA0/6lk8N0zr66bMtCym0Kwn9k85RLEi3o1uRrPzPx6izQ svSWDaCt+wJvK5LjAQg/WN4OFn4pXANhHbs4nrHMKGr0316FaS2YWOOz/bXiHB1ihbP6qCUEiDczv wCyDY5GjoBTsWsiVqnlrjpJysJOZEGx1RMBvLIZVeCh9vThYM341mUO9zllryFxxX6upinypApOQT Im/BdElVJdQnXjzhh/V0fpUOdNaNTwUcHErzR3keo+oyPJSg84rbDnFQf7LmN2k6RvCVYUsA2CxyM 5k5kpy5g==; 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 1iuBlu-0002cs-6E; Wed, 22 Jan 2020 08:53:58 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.92 #3 (Red Hat Linux)) id 1iuBlt-008mRx-Ca; Wed, 22 Jan 2020 08:53:57 +0000 From: David Woodhouse To: Xen-devel Date: Wed, 22 Jan 2020 08:53:54 +0000 Message-Id: <20200122085357.2092778-11-dwmw2@infradead.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200122085357.2092778-1-dwmw2@infradead.org> References: <6cbe16ae42ab806df513d359220212d4f01ce43d.camel@infradead.org> <20200122085357.2092778-1-dwmw2@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] [RFC PATCH v2 11/14] Don't panic if no multiboot modules are provided on live update 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 , paul@xen.org, Ian Jackson , Hongyan Xia , Amit Shah , =?utf-8?q?Ro?= =?utf-8?q?ger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: David Woodhouse Signed-off-by: David Woodhouse --- xen/arch/x86/setup.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 521946dc27..bd65d6bf5d 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -883,9 +883,14 @@ void __init noreturn __start_xen(unsigned long mbi_p) printk(" Found %d EDD information structures\n", bootsym(boot_edd_info_nr)); - /* Check that we have at least one Multiboot module. */ - if ( !(mbi->flags & MBI_MODULES) || (mbi->mods_count == 0) ) - panic("dom0 kernel not specified. Check bootloader configuration\n"); + if ( lu_data ) { + if ( (mbi->flags & MBI_MODULES) && (mbi->mods_count > 0) ) + panic("Multiboot modules provided with live update data\n"); + } else { + /* Check that we have at least one Multiboot module. */ + if ( !(mbi->flags & MBI_MODULES) || (mbi->mods_count == 0) ) + panic("dom0 kernel not specified. Check bootloader configuration\n"); + } /* Check that we don't have a silly number of modules. */ if ( mbi->mods_count > sizeof(module_map) * 8 ) From patchwork Wed Jan 22 08:53:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Woodhouse X-Patchwork-Id: 11345357 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 352F1924 for ; Wed, 22 Jan 2020 08:55:36 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 120A42253D for ; Wed, 22 Jan 2020 08:55:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="sD+wemh9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 120A42253D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iuBmW-00013L-1C; Wed, 22 Jan 2020 08:54:36 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iuBmU-00012b-TL for xen-devel@lists.xenproject.org; Wed, 22 Jan 2020 08:54:35 +0000 X-Inumbo-ID: be4353b0-3cf4-11ea-9fd7-bc764e2007e4 Received: from merlin.infradead.org (unknown [2001:8b0:10b:1231::1]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id be4353b0-3cf4-11ea-9fd7-bc764e2007e4; Wed, 22 Jan 2020 08:54:05 +0000 (UTC) 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=wbgu2T5PM1NqsO6J+RaAdJbHvsoVj2zMh9jVS8dJmgE=; b=sD+wemh9o82wMKOKWrbHJIXjXw IbSLDuvy8oEBAWy/OQDVVTtemWSEEvEHnDPdHZA6X0WE1TNyVIfkEWtb33d/Py0aVKbrunu0hZNLv HPqH3f6NUzLFHfdcS1XGgRZ1G0PWjhe7GNPkTalMCvEqnDHz43sPusiszb+D9XMWUhLUDdFZjAKV8 8QGdIeXmm0QwLOg35ZjGKrwsjCWlAf7eJ4Uf10EmytMcc76QkcXNwI5BuRvAUGADaqng35BXR6/RS EnFJWnh6BLwrJWSvEyKtHKZubSMzBuiFAjTpv07Zdrtvz/DVBIXown80LPqSAoWNukua1LRssuPGg AdnDM6BA==; 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 1iuBlu-0002ct-6i; Wed, 22 Jan 2020 08:53:58 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.92 #3 (Red Hat Linux)) id 1iuBlt-008mS2-D8; Wed, 22 Jan 2020 08:53:57 +0000 From: David Woodhouse To: Xen-devel Date: Wed, 22 Jan 2020 08:53:55 +0000 Message-Id: <20200122085357.2092778-12-dwmw2@infradead.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200122085357.2092778-1-dwmw2@infradead.org> References: <6cbe16ae42ab806df513d359220212d4f01ce43d.camel@infradead.org> <20200122085357.2092778-1-dwmw2@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] [RFC PATCH v2 12/14] Don't add bad pages above HYPERVISOR_VIRT_END to the domheap 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 , paul@xen.org, Ian Jackson , Hongyan Xia , Amit Shah , =?utf-8?q?Ro?= =?utf-8?q?ger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: David Woodhouse Signed-off-by: David Woodhouse --- xen/common/page_alloc.c | 83 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 80 insertions(+), 3 deletions(-) diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 20ef25d45a..2a20c12abb 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; } +static unsigned long contig_avail_pages(struct page_info *pg, unsigned long max_pages) +{ + unsigned long i; + + for ( i = 0 ; i < max_pages; i++) + { + if ( pg[i].count_info & (PGC_broken | PGC_allocated) ) + 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,24 @@ static void init_heap_pages( { unsigned int nid = phys_to_nid(page_to_maddr(pg+i)); + /* If the (first) page is already marked bad, or allocated in advance + * due to live update, don't add it to the heap. */ + if (pg[i].count_info & (PGC_broken | PGC_allocated)) + continue; + if ( unlikely(!avail[nid]) ) { + unsigned long contig_nr_pages = contig_avail_pages(pg + i, nr_pages); unsigned long s = mfn_x(page_to_mfn(pg + i)); - unsigned long e = mfn_x(mfn_add(page_to_mfn(pg + nr_pages - 1), 1)); + unsigned long e = mfn_x(mfn_add(page_to_mfn(pg + contig_nr_pages - 1), 1)); bool use_tail = (nid == phys_to_nid(pfn_to_paddr(e - 1))) && !(s & ((1UL << MAX_ORDER) - 1)) && (find_first_set_bit(e) <= find_first_set_bit(s)); unsigned long n; - n = init_node_heap(nid, mfn_x(page_to_mfn(pg + i)), nr_pages - i, + n = init_node_heap(nid, mfn_x(page_to_mfn(pg + i)), contig_nr_pages - i, &use_tail); - BUG_ON(i + n > nr_pages); + BUG_ON(i + n > contig_nr_pages); if ( n && !use_tail ) { i += n - 1; @@ -1846,6 +1864,63 @@ static unsigned long avail_heap_pages( return free_pages; } +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 = get_platform_badpages(&array_size); + if ( badpage ) + { + for ( i = 0; i < array_size; i++ ) + { + for ( j = 0; j < 1UL << badpage->order; j++ ) + { + if ( mfn_valid(badpage->mfn + j) ) + { + pg = mfn_to_page(badpage->mfn + j); + pg->count_info |= PGC_broken; + page_list_add_tail(pg, &page_broken_list); + } + } + } + } +#endif + + /* Check new pages against the bad-page list. */ + p = opt_badpage; + while ( *p != '\0' ) + { + bad_spfn = simple_strtoul(p, &p, 0); + bad_epfn = bad_spfn; + + if ( *p == '-' ) + { + p++; + bad_epfn = simple_strtoul(p, &p, 0); + if ( bad_epfn < bad_spfn ) + bad_epfn = bad_spfn; + } + + if ( *p == ',' ) + p++; + else if ( *p != '\0' ) + break; + + while ( mfn_valid(_mfn(bad_spfn)) && bad_spfn < bad_epfn ) + { + pg = mfn_to_page(_mfn(bad_spfn)); + pg->count_info |= PGC_broken; + page_list_add_tail(pg, &page_broken_list); + bad_spfn++; + } + } +} + void __init end_boot_allocator(void) { unsigned int i; @@ -1870,6 +1945,8 @@ void __init end_boot_allocator(void) } nr_bootmem_regions = 0; + mark_bad_pages(); + if ( !dma_bitsize && (num_online_nodes() > 1) ) dma_bitsize = arch_get_dma_bitsize(); From patchwork Wed Jan 22 08:53:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Woodhouse X-Patchwork-Id: 11345355 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 77993139A for ; Wed, 22 Jan 2020 08:55:35 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 53DE92253D for ; Wed, 22 Jan 2020 08:55:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="MU5/IOhg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 53DE92253D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iuBmf-0001BE-Ta; Wed, 22 Jan 2020 08:54:45 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iuBme-0001AQ-Tf for xen-devel@lists.xenproject.org; Wed, 22 Jan 2020 08:54:44 +0000 X-Inumbo-ID: be438c90-3cf4-11ea-aecd-bc764e2007e4 Received: from merlin.infradead.org (unknown [2001:8b0:10b:1231::1]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id be438c90-3cf4-11ea-aecd-bc764e2007e4; Wed, 22 Jan 2020 08:54:05 +0000 (UTC) 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=wFdAjds4p6PT7zF+YrhEzxwIdt++tvE/OSjxnQSp3Os=; b=MU5/IOhgi4VtGKWyrZNzzl2LSj pdH9hEaeqNRt2OGgi7HB4RFAFuzdlWqjFO5xNAaGZP7p6YmD9bPIcxvV06iBES7tzXodZg8oacUF1 0FXQmXsdhrhWIgGbE/6BGDV75U/Q1p9yED4jOcmxkyEfO7fkgT2Nb8AaFrg9m6PIK36rzppgCThBG d1uQ5Q1wUkHmOd2CYbxDm4n97GLzDSubp5vxiWjyQ+yETwyDuleD8PUm2HpUEe/2obLi+wT3eE5wh NEhPeIcR48B6W24t7JvEB3ZFbvOcUXOt4nBirIuihTXd5r0TLDnsEZq89Ux/9PS69Tm2Hg53zI4/g ps3oPWAQ==; 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 1iuBlu-0002cu-7O; Wed, 22 Jan 2020 08:53:58 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.92 #3 (Red Hat Linux)) id 1iuBlt-008mS7-Df; Wed, 22 Jan 2020 08:53:57 +0000 From: David Woodhouse To: Xen-devel Date: Wed, 22 Jan 2020 08:53:56 +0000 Message-Id: <20200122085357.2092778-13-dwmw2@infradead.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200122085357.2092778-1-dwmw2@infradead.org> References: <6cbe16ae42ab806df513d359220212d4f01ce43d.camel@infradead.org> <20200122085357.2092778-1-dwmw2@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] [RFC PATCH v2 13/14] Basic shell of lu_reserve_all() from breadcrumb at 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 , paul@xen.org, Ian Jackson , Hongyan Xia , Amit Shah , =?utf-8?q?Ro?= =?utf-8?q?ger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: David Woodhouse This mostly just reserves pages, hence the name. The rest of the actual restoration will happen later, after the heap allocator works. Signed-off-by: David Woodhouse --- xen/arch/x86/setup.c | 20 +++++++++++++++++++ xen/common/lu/Makefile | 2 +- xen/common/lu/restore.c | 44 +++++++++++++++++++++++++++++++++++++++++ xen/include/xen/lu.h | 1 + 4 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 xen/common/lu/restore.c diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index bd65d6bf5d..af874ee8b5 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -739,6 +740,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) .max_maptrack_frames = -1, }; const char *hypervisor_name; + uint64_t lu_mfnlist_phys = 0, lu_nr_pages = 0; /* Critical region without IDT or TSS. Any fault is deadly! */ @@ -1336,6 +1338,21 @@ void __init noreturn __start_xen(unsigned long mbi_p) if ( !xen_phys_start ) panic("Not enough memory to relocate Xen\n"); + if ( lu_data ) + { + uint64_t *breadcrumb = maddr_to_virt(lu_data); + + lu_mfnlist_phys = breadcrumb[1]; + lu_nr_pages = breadcrumb[2] >> PAGE_SHIFT; + + if ( breadcrumb[0] == LIVE_UPDATE_MAGIC && lu_nr_pages) { + printk("%ld pages of live update data at 0x%lx\n", lu_nr_pages, lu_mfnlist_phys); + } else { + panic("Live update breadcrumb not found: %lx %lx %lx at %lx\n", + breadcrumb[0], breadcrumb[1], breadcrumb[2], lu_data); + } + } + if ( lu_bootmem_start ) { if ( !lu_reserved ) @@ -1571,6 +1588,9 @@ void __init noreturn __start_xen(unsigned long mbi_p) numa_initmem_init(0, raw_max_page); + if ( lu_data ) + lu_reserve_pages(lu_mfnlist_phys, lu_nr_pages); + if ( lu_bootmem_start ) { unsigned long limit = virt_to_mfn(HYPERVISOR_VIRT_END - 1); diff --git a/xen/common/lu/Makefile b/xen/common/lu/Makefile index 7b7d975f65..592c72e1ec 100644 --- a/xen/common/lu/Makefile +++ b/xen/common/lu/Makefile @@ -1 +1 @@ -obj-y += stream.o save.o +obj-y += stream.o save.o restore.o diff --git a/xen/common/lu/restore.c b/xen/common/lu/restore.c new file mode 100644 index 0000000000..7f40513ef9 --- /dev/null +++ b/xen/common/lu/restore.c @@ -0,0 +1,44 @@ +#include +#include +#include +#include + +#define MFNS_PER_PAGE (PAGE_SIZE / sizeof(mfn_t)) + +/* Returns void. There's not a lot we can do if this fails except panic. */ +void lu_reserve_pages(paddr_t mfns_p, int nr_pages) +{ + unsigned int index_pages = (nr_pages + MFNS_PER_PAGE - 1) / MFNS_PER_PAGE; + unsigned char *p; + mfn_t *mfns; + int i; + + /* Would like to vmap(). Too early. */ + mfns = __va(mfns_p); + map_pages_to_xen((unsigned long)mfns, maddr_to_mfn(mfns_p), index_pages, PAGE_HYPERVISOR); + + for ( i = 0; i < index_pages; i++ ) + { + maddr_to_page(mfns_p + (i << PAGE_SHIFT))->count_info |= PGC_allocated; + } + + for ( i = 0; i < nr_pages; i++ ) + { + if (!mfn_valid(mfns[i])) + panic("Invalid MFN %lx in live update stream\n", mfn_x(mfns[i])); + + mfn_to_page(mfns[i])->count_info |= PGC_allocated; + } + + /* XX: Consume the stream of data and mark all domain pages as allocated too. */ +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/include/xen/lu.h b/xen/include/xen/lu.h index 6e8377b6c3..496db9bfe1 100644 --- a/xen/include/xen/lu.h +++ b/xen/include/xen/lu.h @@ -13,3 +13,4 @@ void lu_stream_free(struct lu_stream *stream); struct kexec_image; int lu_save_all(struct kexec_image *image); +void lu_reserve_pages(paddr_t mfnlist, int nr_pages); From patchwork Wed Jan 22 08:53:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Woodhouse X-Patchwork-Id: 11345347 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 42081924 for ; Wed, 22 Jan 2020 08:55:09 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1E4DE2253D for ; Wed, 22 Jan 2020 08:55:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="hXaXTXm+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1E4DE2253D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iuBmB-0000r7-Oj; Wed, 22 Jan 2020 08:54:15 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iuBmA-0000qm-So for xen-devel@lists.xenproject.org; Wed, 22 Jan 2020 08:54:14 +0000 X-Inumbo-ID: baa725ec-3cf4-11ea-b833-bc764e2007e4 Received: from bombadil.infradead.org (unknown [2607:7c80:54:e::133]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id baa725ec-3cf4-11ea-b833-bc764e2007e4; Wed, 22 Jan 2020 08:53:59 +0000 (UTC) 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=VgQjjHotepf4XKe5zdOlsNW1e89KCj7K1D1AbkLnhS4=; b=hXaXTXm+hmlsR5lct6q96AYwUn ClRVFl0q3mQeuttNIYqt7+GQX0XdmDS7iEunk4uQJuhYQbVrIL4fl4hYCLfclqv4aUyTavpllODa2 FaAmgVIdFs2FRP/WFOfpFhSIKJVjQ5lrBotT37AHQtZLS7Zfna8u7jXsGPDhErs+k5uzmLpnrUvRC KEj5c+5NhqFXwCd3ecCFd6vMqdO5KLK//oip7+85GyB9BAGqOll+7Ox0UlR3NgScgmQLcGRrskckQ 7yVcj7O9Er9TiuSaiQykV4EwydL7aADJ0RqTf4qnRvPYGbS+dossKGYIZLGONwy3aaT6f11gFfryt 0u0F+dKA==; 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 1iuBlu-0001yG-Kr; Wed, 22 Jan 2020 08:53:58 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.92 #3 (Red Hat Linux)) id 1iuBlt-008mSC-ED; Wed, 22 Jan 2020 08:53:57 +0000 From: David Woodhouse To: Xen-devel Date: Wed, 22 Jan 2020 08:53:57 +0000 Message-Id: <20200122085357.2092778-14-dwmw2@infradead.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200122085357.2092778-1-dwmw2@infradead.org> References: <6cbe16ae42ab806df513d359220212d4f01ce43d.camel@infradead.org> <20200122085357.2092778-1-dwmw2@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] [RFC PATCH v2 14/14] debug hacks 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 , paul@xen.org, Ian Jackson , Hongyan Xia , Amit Shah , =?utf-8?q?Ro?= =?utf-8?q?ger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: David Woodhouse --- xen/common/lu/restore.c | 7 +++++++ xen/common/lu/stream.c | 2 ++ xen/common/page_alloc.c | 6 ++++++ 3 files changed, 15 insertions(+) diff --git a/xen/common/lu/restore.c b/xen/common/lu/restore.c index 7f40513ef9..fa168bdac1 100644 --- a/xen/common/lu/restore.c +++ b/xen/common/lu/restore.c @@ -31,6 +31,13 @@ void lu_reserve_pages(paddr_t mfns_p, int nr_pages) } /* XX: Consume the stream of data and mark all domain pages as allocated too. */ + + printk("First live update data page at MFN %lx:\n", mfns[0]); + p = mfn_to_virt(mfns[0]); + map_pages_to_xen((unsigned long)p, mfns[0], 1, PAGE_HYPERVISOR); + for (i = 0; i < 16; i++) + printk(" %02x", p[i]); + printk("\n"); } /* diff --git a/xen/common/lu/stream.c b/xen/common/lu/stream.c index 52030e8b2e..327c0396ff 100644 --- a/xen/common/lu/stream.c +++ b/xen/common/lu/stream.c @@ -65,6 +65,7 @@ static int lu_stream_extend(struct lu_stream *stream, int nr_pages) if (stream->data) vunmap(stream->data); stream->data = vmap(stream->pagelist, stream->nr_pages); + printk("Mapped %d MFNs at %lx to %p\n", stream->nr_pages, stream->pagelist[0], stream->data); if (!stream->data) return -ENOMEM; @@ -91,6 +92,7 @@ int lu_stream_append(struct lu_stream *stream, void *data, size_t size) void *p = lu_stream_reserve(stream, size); if (!p) return -ENOMEM; + printk("Copy %ld starting %02x to %p\n", size, *(unsigned char *)data, p); memcpy(p, data, size); lu_stream_end_reservation(stream, size); diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 2a20c12abb..a3668a517f 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -1765,7 +1765,10 @@ static unsigned long contig_avail_pages(struct page_info *pg, unsigned long max_ for ( i = 0 ; i < max_pages; i++) { if ( pg[i].count_info & (PGC_broken | PGC_allocated) ) + { + printk("Skipping reserved MFN %lx\n", mfn_x(page_to_mfn(&pg[i]))); break; + } } return i; } @@ -1814,7 +1817,10 @@ static void init_heap_pages( /* If the (first) page is already marked bad, or allocated in advance * due to live update, don't add it to the heap. */ if (pg[i].count_info & (PGC_broken | PGC_allocated)) + { + printk("Skipping reserved MFN %lx\n", mfn_x(page_to_mfn(&pg[i]))); continue; + } if ( unlikely(!avail[nid]) ) {