mini-os: support of auto-ballooning
Subsystems (3)
v3 cover mini-os: support of auto-ballooning
Support ballooning Mini-OS automatically up in case of memory shortage.
Do some cleanups, a small correction and add some basic features to lay groundwork for support of ballooning in Mini-OS (patches 1-14).
The main visible change is the virtual memory layout: to be able to add memory to the running Mini-OS we need to have some spare areas especially after the 1:1 mapping of physical memory.
Then add the ballooning functionality: the p2m map must be expanded, the page allocator's bitmap must be expanded and we must get new memory from the hypervisor.
In case of a detected memory shortage the domain will balloon up until either enough memory is available or the upper limit has been reached.
Ballooning has been tested with a xenstore stubdom. Regression tests have been done with:
- pure mini-os
- ioemu stubdom
- pvgrub 64 bit
pvgrub 32 bit didn't work before applying the series, it just entered the grub shell. With the series applied the behavior was exactly the same. The grub shell however was working (I tried "help" and "reboot").
I tried to modify arm specific files in order not to break the non-ballooning case, but I haven't tested it to either work or to compile.
V1 of this series consisted of patches 1-9 only.
Changes in V3:
- some minor adjustments as requested by Samuel Thibault
- added patch 19
Changes in V2:
- added patches 10-18
- some coding style corrections
- patch 7: introduced balloon specific source files
- moved ballooning specific functions/definitions to ballon specific files
- patch 9: avoid conflict with hypervisor mapped area on 32 bits
Juergen Gross (19):
mini-os: correct first free pfn
mini-os: remove unused alloc_contig_pages() function
mini-os: remove MM_DEBUG code
mini-os: add description of x86 memory usage
mini-os: add nr_free_pages counter
mini-os: let memory allocation fail if no free page available
mini-os: add ballooning config item
mini-os: get maximum memory size from hypervisor
mini-os: modify virtual memory layout for support of ballooning
mini-os: remove unused mem_test() function
mini-os: add checks for out of memory
mini-os: don't allocate new pages for level 1 p2m tree
mini-os: add function to map one frame
mini-os: move p2m related macros to header file
mini-os: remap p2m list in case of ballooning
mini-os: map page allocator's bitmap to virtual kernel area for
ballooning
mini-os: add support for ballooning up
mini-os: balloon up in case of oom
mini-os: repair build system
Config.mk | 93 +++++++++++++++ Makefile | 43 +------ arch/arm/balloon.c | 39 +++++++ arch/arm/mm.c | 10 +- arch/x86/Makefile | 3 - arch/x86/balloon.c | 147 +++++++++++++++++++++++ arch/x86/mm.c | 314 +++++++------------------------------------------- balloon.c | 160 +++++++++++++++++++++++++ config/MiniOS.mk | 10 -- config/StdGNU.mk | 47 -------- config/arm32.mk | 22 ---- config/arm64.mk | 19 --- config/x86_32.mk | 20 ---- config/x86_64.mk | 33 ------ include/arm/arch_mm.h | 2 + include/balloon.h | 59 ++++++++++ include/mm.h | 13 ++- include/x86/arch_mm.h | 70 +++++++++++ minios.mk | 4 +- mm.c | 131 ++++++++------------- 20 files changed, 682 insertions(+), 557 deletions(-) create mode 100644 arch/arm/balloon.c create mode 100644 arch/x86/balloon.c create mode 100644 balloon.c delete mode 100644 config/MiniOS.mk delete mode 100644 config/StdGNU.mk delete mode 100644 config/arm32.mk delete mode 100644 config/arm64.mk delete mode 100644 config/x86_32.mk delete mode 100644 config/x86_64.mk create mode 100644 include/balloon.h
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v3 1/19 mini-os: correct first free pfn
The first free pfn available for allocation is calculated by adding the number of page table frames to the pfn of the first page table and then the magic number 3 to account for start info page et al.
As the start info page, xenstore page and console page are allocated _before_ the page tables leaving room for these pages behind the page tables makes no sense.
--- arch/x86/mm.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
arch/x86/mm.c +2 -3
@@ -867,9 +867,8 @@ void arch_init_mm(unsigned long* start_pfn_p, unsigned long* max_pfn_p)printk ("stack start: %p(VA)\n" , stack);printk (" _end: %p(VA)\n" , &_end); -/* First page follows page table pages and 3 more pages (store page etc) */ - start_pfn =PFN_UP (to_phys (start_info.pt_base)) + - start_info.nr_pt_frames +3 ; +/* First page follows page table pages. */ + start_pfn =PFN_UP (to_phys (start_info.pt_base)) + start_info.nr_pt_frames; max_pfn = start_info.nr_pages;/* We need room for demand mapping and heap, clip available memory */
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v3 2/19 mini-os: remove unused alloc_contig_pages() function
In reply to Juergen Grossalloc_contig_pages() is never used anywhere in mini-os. Remove it.
--- arch/x86/mm.c | 142 ---------------------------------------------------------- include/mm.h | 1 - 2 files changed, 143 deletions(-)
arch/x86/mm.c +0 -142
@@ -652,148 +652,6 @@ int unmap_frames(unsigned long va, unsigned long num_frames) }/* -* Allocate pages which are contiguous in machine memory. -* Returns a VA to where they are mapped or 0 on failure. -* -* addr_bits indicates if the region has restrictions on where it is -* located. Typical values are 32 (if for example PCI devices can't access -* 64bit memory) or 0 for no restrictions. -* -* Allocated pages can be freed using the page allocators free_pages() -* function. -* -* based on Linux function xen_create_contiguous_region() -*/ -#define MAX_CONTIG_ORDER 9/* 2MB */ -unsigned long alloc_contig_pages (int order,unsigned int addr_bits) -{ -unsigned long in_va, va; -unsigned long in_frames[1UL << order], out_frames, mfn; -multicall_entry_t call[1UL << order]; -unsigned int i, num_pages =1UL << order; -int ret, exch_success; - -/* pass in num_pages 'extends' of size 1 and -* request 1 extend of size 'order */ -struct xen_memory_exchange exchange = { - .in = { - .nr_extents = num_pages, - .extent_order =0 , - .domid =DOMID_SELF - }, - .out = { - .nr_extents =1 , - .extent_order = order, - .address_bits = addr_bits, - .domid =DOMID_SELF - }, - .nr_exchanged =0 - }; - -if ( order >MAX_CONTIG_ORDER ) - { -printk ("alloc_contig_pages: order too large 0x%x > 0x%x\n" , - order,MAX_CONTIG_ORDER ); -return 0 ; - } - -/* Allocate some potentially discontiguous pages */ - in_va =alloc_pages (order); -if ( !in_va ) - { -printk ("alloc_contig_pages: could not get enough pages (order=0x%x\n" , - order); -return 0 ; - } - -/* set up arguments for exchange hyper call */ -set_xen_guest_handle (exchange.in.extent_start, in_frames); -set_xen_guest_handle (exchange.out.extent_start, &out_frames); - -/* unmap current frames, keep a list of MFNs */ -for ( i =0 ; i < num_pages; i++ ) - { -int arg =0 ; - - va = in_va + (PAGE_SIZE * i); - in_frames[i] =virt_to_mfn (va); - -/* update P2M mapping */ - phys_to_machine_mapping[virt_to_pfn (va)] =INVALID_P2M_ENTRY ; - -/* build multi call */ - call[i].op = __HYPERVISOR_update_va_mapping; - call[i].args[arg++] = va; - call[i].args[arg++] =0 ; -#ifdef __i386__ - call[i].args[arg++] =0 ; -#endif - call[i].args[arg++] =UVMF_INVLPG ; - } - - ret =HYPERVISOR_multicall (call, i); -if ( ret ) - { -printk ("Odd, update_va_mapping hypercall failed with rc=%d.\n" , ret); -return 0 ; - } - -/* try getting a contig range of MFNs */ - out_frames =virt_to_pfn (in_va);/* PFNs to populate */ - ret =HYPERVISOR_memory_op (XENMEM_exchange, &exchange); -if ( ret ) { -printk ("mem exchanged order=0x%x failed with rc=%d, nr_exchanged=%lu\n" , - order, ret, exchange.nr_exchanged); -/* we still need to return the allocated pages above to the pool -* ie. map them back into the 1:1 mapping etc. so we continue but -* in the end return the pages to the page allocator and return 0. */ - exch_success =0 ; - } -else - exch_success =1 ; - -/* map frames into 1:1 and update p2m */ -for ( i =0 ; i < num_pages; i++ ) - { -int arg =0 ; -pte_t pte; - - va = in_va + (PAGE_SIZE * i); - mfn = i < exchange.nr_exchanged ? (out_frames + i) : in_frames[i]; - pte =__pte (mfn <<PAGE_SHIFT |L1_PROT ); - -/* update P2M mapping */ - phys_to_machine_mapping[virt_to_pfn (va)] = mfn; - -/* build multi call */ - call[i].op = __HYPERVISOR_update_va_mapping; - call[i].args[arg++] = va; -#ifdef __x86_64__ - call[i].args[arg++] = (pgentry_t )pte.pte; -#else - call[i].args[arg++] = pte.pte_low; - call[i].args[arg++] = pte.pte_high; -#endif - call[i].args[arg++] =UVMF_INVLPG ; - } - ret =HYPERVISOR_multicall (call, i); -if ( ret ) - { -printk ("update_va_mapping hypercall no. 2 failed with rc=%d.\n" , ret); -return 0 ; - } - -if ( !exch_success ) - { -/* since the exchanged failed we just free the pages as well */ -free_pages ((void *) in_va, order); -return 0 ; - } - -return in_va; -} - -/* * Clear some of the bootstrap memory */ static void clear_bootstrap (void )
include/mm.h +0 -1
@@ -71,7 +71,6 @@ void do_map_frames(unsigned long addr, const unsigned long *f, unsigned long n, unsigned long stride, unsigned long increment, domid_t id, int *err, unsigned long prot);int unmap_frames (unsigned long va,unsigned long num_frames); -unsigned long alloc_contig_pages (int order,unsigned int addr_bits);#ifdef HAVE_LIBC extern unsigned long heap, brk, heap_mapped, heap_end;#endif
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v3 3/19 mini-os: remove MM_DEBUG code
In reply to Juergen Grossmm.c contains unused code inside #ifdef MM_DEBUG areas. Its usability is rather questionable and some parts are even wrong (e.g. print_chunks() called with nr_pages > 1000 will clobber an arbitrary stack content with a 0 byte).
Remove this code.
--- mm.c | 60 ------------------------------------------------------------ 1 file changed, 60 deletions(-)
mm.c +0 -60
@@ -42,13 +42,6 @@#include <mini-os/lib.h> #include <mini-os/xmalloc.h> -#ifdef MM_DEBUG -#define DEBUG(_f, _a...) \ - printk("MINI_OS(file=mm.c, line=%d) " _f "\n", __LINE__, ## _a) -#else -#define DEBUG(_f, _a...) ((void)0) -#endif -/********************* * ALLOCATION BITMAP * One bit per page of memory. Bit set => page is allocated.
@@ -140,59 +133,6 @@ static chunk_head_t free_tail[FREELIST_SIZE];#define round_pgdown (_p) ((_p)&PAGE_MASK)#define round_pgup (_p) (((_p)+(PAGE_SIZE-1))&PAGE_MASK) -#ifdef MM_DEBUG -/* -* Prints allocation[0/1] for @nr_pages, starting at @start -* address (virtual). -*/ -USED static void print_allocation(void *start, int nr_pages) -{ -unsigned long pfn_start =virt_to_pfn (start); -int count; -for (count =0 ; count < nr_pages; count++) -if (allocated_in_map (pfn_start + count))printk ("1" ); -else printk ("0" ); - -printk ("\n" ); -} - -/* -* Prints chunks (making them with letters) for @nr_pages starting -* at @start (virtual). -*/ -USED static void print_chunks(void *start, int nr_pages) -{ -char chunks[1001 ], current='A' ; -int order, count; -chunk_head_t *head; -unsigned long pfn_start =virt_to_pfn (start); - -memset (chunks, (int )'_' ,1000 ); -if (nr_pages >1000 ) - { -DEBUG ("Can only pring 1000 pages. Increase buffer size." ); - } - -for (order=0 ; order <FREELIST_SIZE ; order++) - { - head = free_head[order]; -while (!FREELIST_EMPTY (head)) - { -for (count =0 ; count <1UL << head->level; count++) - { -if (count +virt_to_pfn (head) - pfn_start <1000 ) - chunks[count +virt_to_pfn (head) - pfn_start] = current; - } - head = head->next; - current++; - } - } - chunks[nr_pages] ='\0' ; -printk ("%s\n" , chunks); -} -#endif - -/* * Initialise allocator, placing addresses [@min,@max] in free pool. * @min and @max are PHYSICAL addresses.
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v3 4/19 mini-os: add description of x86 memory usage
In reply to Juergen GrossAdd a brief description how the physical and virtual address usage looks like on x86 to include/x86/arch_mm.h
--- include/x86/arch_mm.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
include/x86/arch_mm.h +20 -0
@@ -36,6 +36,26 @@#endif #endif +/* +* Physical address space usage: +* +* 0..._edata: kernel text/data +* *stack : kernel stack (thread 0) +* hypervisor allocated data: p2m_list, start_info page, xenstore page, +* console page, initial page tables +* bitmap of allocated pages +* pages controlled by the page allocator +* +* +* Virtual address space usage: +* +* 1:1 mapping of physical memory starting at VA(0) +* 1 unallocated page +* demand map area (32 bits: 2 GB, 64 bits: 128 GB) for virtual allocations +* 1 unallocated page +* with libc: heap area (32 bits: 1 GB, 64 bits: 128 GB) +*/ +#define L1_FRAME 1#define L2_FRAME 2#define L3_FRAME 3
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v3 5/19 mini-os: add nr_free_pages counter
In reply to Juergen GrossAdd a variable holding the number of available memory pages. This will aid auto-ballooning later.
--- include/mm.h | 1 + mm.c | 6 ++++++ 2 files changed, 7 insertions(+)
include/mm.h +1 -0
@@ -42,6 +42,7 @@#define STACK_SIZE_PAGE_ORDER __STACK_SIZE_PAGE_ORDER#define STACK_SIZE __STACK_SIZE +extern unsigned long nr_free_pages;void init_mm (void );unsigned long alloc_pages (int order);
mm.c +6 -0
@@ -53,6 +53,8 @@ static unsigned long *alloc_bitmap;#define allocated_in_map (_pn) \ (alloc_bitmap[(_pn)/PAGES_PER_MAPWORD] & (1UL<<((_pn)&(PAGES_PER_MAPWORD-1)))) +unsigned long nr_free_pages; +/* * Hint regarding bitwise arithmetic in map_{alloc,free}: * -(1<<n) sets all bits >= n.
@@ -81,6 +83,8 @@ static void map_alloc(unsigned long first_page, unsigned long nr_pages)while ( ++curr_idx < end_idx ) alloc_bitmap[curr_idx] = ~0UL ; alloc_bitmap[curr_idx] |= (1UL <<end_off)-1 ; } + + nr_free_pages -= nr_pages; }
@@ -93,6 +97,8 @@ static void map_free(unsigned long first_page, unsigned long nr_pages) end_idx = (first_page + nr_pages) /PAGES_PER_MAPWORD ; end_off = (first_page + nr_pages) & (PAGES_PER_MAPWORD -1 ); + nr_free_pages += nr_pages; +if ( curr_idx == end_idx ) { alloc_bitmap[curr_idx] &= -(1UL <<end_off) | ((1UL <<start_off)-1 );
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v3 6/19 mini-os: let memory allocation fail if no free page available
In reply to Juergen GrossInstead of panicing when no page can be allocated try to fail the memory allocation by returning NULL instead.
---
V2: fixed minor style issue
--- mm.c | 7 +++++++ 1 file changed, 7 insertions(+)
mm.c +7 -0
@@ -335,6 +335,13 @@ void *sbrk(ptrdiff_t increment)if (new_brk > heap_mapped) {unsigned long n = (new_brk - heap_mapped +PAGE_SIZE -1 ) /PAGE_SIZE ; + +if ( n > nr_free_pages ) + { +printk ("Memory exhausted: want %ld pages, but only %ld are left\n" , + n, nr_free_pages); +return NULL ; + }do_map_zero (heap_mapped, n); heap_mapped += n *PAGE_SIZE ; }
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v3 7/19 mini-os: add ballooning config item
In reply to Juergen GrossAdd CONFIG_BALLOON defaulting to 'n' as a config item to Mini-OS.
Add balloon.c, balloon.h and arch/*/balloon.c for future use.
---
V2: Added dummy sources and header
--- Makefile | 3 +++ arch/arm/balloon.c | 28 ++++++++++++++++++++++++++++ arch/x86/balloon.c | 28 ++++++++++++++++++++++++++++ balloon.c | 24 ++++++++++++++++++++++++ include/balloon.h | 32 ++++++++++++++++++++++++++++++++ 5 files changed, 115 insertions(+) create mode 100644 arch/arm/balloon.c create mode 100644 arch/x86/balloon.c create mode 100644 balloon.c create mode 100644 include/balloon.h
Makefile +3 -0
@@ -33,6 +33,7 @@ CONFIG_CONSFRONT ?= y CONFIG_XENBUS ?= y CONFIG_XC ?=y CONFIG_LWIP ?= $(lwip) +CONFIG_BALLOON ?= n # Export config items as compiler directives flags-$(CONFIG_START_NETWORK) += -DCONFIG_START_NETWORK
@@ -48,6 +49,7 @@ flags-$(CONFIG_KBDFRONT) += -DCONFIG_KBDFRONT flags-$(CONFIG_FBFRONT) += -DCONFIG_FBFRONT flags-$(CONFIG_CONSFRONT) += -DCONFIG_CONSFRONT flags-$(CONFIG_XENBUS) += -DCONFIG_XENBUS +flags-$(CONFIG_BALLOON) += -DCONFIG_BALLOON DEF_CFLAGS += $(flags-y)
@@ -96,6 +98,7 @@ src-$(CONFIG_NETFRONT) += netfront.c src-$(CONFIG_PCIFRONT) += pcifront.c src-y += sched.c src-$(CONFIG_TEST) += test.c +src-$(CONFIG_BALLOON) += balloon.c src-y += lib/ctype.c src-y += lib/math.c
arch/arm/balloon.c new file +28 -0
@@ -0,0 +1,28 @@ +/* -*- Mode:C; c-basic-offset:4; tab-width:4 -*- +* +* (C) 2016 - Juergen Gross, SUSE Linux GmbH +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to +* deal in the Software without restriction, including without limitation the +* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +* sell copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#include <mini-os/balloon.h> + +#ifdef CONFIG_BALLOON + +#endif
arch/x86/balloon.c new file +28 -0
@@ -0,0 +1,28 @@ +/* -*- Mode:C; c-basic-offset:4; tab-width:4 -*- +* +* (C) 2016 - Juergen Gross, SUSE Linux GmbH +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to +* deal in the Software without restriction, including without limitation the +* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +* sell copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#include <mini-os/balloon.h> + +#ifdef CONFIG_BALLOON + +#endif
balloon.c new file +24 -0
@@ -0,0 +1,24 @@ +/* -*- Mode:C; c-basic-offset:4; tab-width:4 -*- +* +* (C) 2016 - Juergen Gross, SUSE Linux GmbH +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to +* deal in the Software without restriction, including without limitation the +* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +* sell copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#include <mini-os/balloon.h>
include/balloon.h new file +32 -0
@@ -0,0 +1,32 @@ +/* -*- Mode:C; c-basic-offset:4; tab-width:4 -*- +* +* (C) 2016 - Juergen Gross, SUSE Linux GmbH +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to +* deal in the Software without restriction, including without limitation the +* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +* sell copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +*/ + +#ifndef _BALLOON_H_ +#define _BALLOON_H_ + +#ifdef CONFIG_BALLOON + +#else /* CONFIG_BALLOON */ + +#endif /* CONFIG_BALLOON */ +#endif /* _BALLOON_H_ */
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v3 8/19 mini-os: get maximum memory size from hypervisor
In reply to Juergen GrossAdd support for obtaining the maximum memory size from the hypervisor. This will make it possible to support ballooning.
---
V2: Moved new stuff to balloon.c
--- balloon.c | 22 ++++++++++++++++++++++ include/balloon.h | 6 ++++++ mm.c | 2 ++ 3 files changed, 30 insertions(+)
balloon.c +22 -0
@@ -21,4 +21,26 @@* DEALINGS IN THE SOFTWARE. */ +#include <mini-os/os.h> #include <mini-os/balloon.h> +#include <mini-os/lib.h> +#include <xen/xen.h> +#include <xen/memory.h> + +unsigned long nr_max_pages; + +void get_max_pages (void ) +{ +long ret; +domid_t domid =DOMID_SELF ; + + ret =HYPERVISOR_memory_op (XENMEM_maximum_reservation, &domid); +if ( ret <0 ) + { +printk ("Could not get maximum pfn\n" ); +return ; + } + + nr_max_pages = ret; +printk ("Maximum memory size: %ld pages\n" , nr_max_pages); +}
include/balloon.h +6 -0
@@ -26,7 +26,13 @@#ifdef CONFIG_BALLOON +extern unsigned long nr_max_pages; + +void get_max_pages (void ); +#else /* CONFIG_BALLOON */ +static inline void get_max_pages (void ) { } +#endif /* CONFIG_BALLOON */ #endif /* _BALLOON_H_ */
mm.c +2 -0
@@ -38,6 +38,7 @@#include <mini-os/hypervisor.h> #include <xen/memory.h> #include <mini-os/mm.h> +#include <mini-os/balloon.h> #include <mini-os/types.h> #include <mini-os/lib.h> #include <mini-os/xmalloc.h>
@@ -361,6 +362,7 @@ void init_mm(void)printk ("MM: Init\n" ); +get_max_pages ();arch_init_mm (&start_pfn, &max_pfn);/* * now we can initialise the page allocator
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v3 9/19 mini-os: modify virtual memory layout for support of ballooning
In reply to Juergen GrossIn order to be able to support ballooning the virtual memory layout of Mini-OS has to be modified: instead of a (nearly) consecutive area used for physical memory mapping, on demand mappings, and heap we need enough spare place for adding new memory.
So instead of dynamically place the different regions based on found memory size locate them statically at fixed virtual addresses:
area x86-64 x86-32
------------------------------------------------------------
mapped physical memory 00000000 00000000 kernel virtual mappings 8000000000 3f000000 demand mappings 100000000000 40000000 heap 200000000000 b0000000
This will enable Mini-OS to support up to 512GB of domain memory with a 64 bit kernel and nearly 1GB with a 32 bit kernel.
For a 32 bit Mini-OS we have to avoid a conflict between heap and m2p table which the hypervisor maps at f5600000. So the demand mapping size is reduced by 256MB in order to keep the heap at about 1GB.
The kernel virtual mappings are a new area needed for being able to grow the p2m list without having to relocate it in physical memory.
Modify the placement of the demand mappings and heap and adjust the memory layout description.
---
V2: avoid conflict with hypervisor mapped area on 32 bits
--- arch/arm/mm.c | 2 +- arch/x86/mm.c | 44 +++++++++++--------------------------------- include/mm.h | 2 +- include/x86/arch_mm.h | 35 ++++++++++++++++++++++++++++++----- mm.c | 2 +- 5 files changed, 44 insertions(+), 41 deletions(-)
arch/arm/mm.c +1 -1
@@ -75,7 +75,7 @@ void arch_init_p2m(unsigned long max_pfn) { } -void arch_init_demand_mapping_area (unsigned long cur_pfn) +void arch_init_demand_mapping_area (void ) { }
arch/x86/mm.c +11 -33
62 lines not on this page · raw message
include/mm.h +1 -1
@@ -59,7 +59,7 @@ static __inline__ int get_order(unsigned long size)return order; } -void arch_init_demand_mapping_area (unsigned long max_pfn); +void arch_init_demand_mapping_area (void );void arch_init_mm (unsigned long * start_pfn_p,unsigned long * max_pfn_p);void arch_init_p2m (unsigned long max_pfn_p);
include/x86/arch_mm.h +30 -5
@@ -49,11 +49,13 @@* * Virtual address space usage: * -* 1:1 mapping of physical memory starting at VA(0) -* 1 unallocated page -* demand map area (32 bits: 2 GB, 64 bits: 128 GB) for virtual allocations -* 1 unallocated page -* with libc: heap area (32 bits: 1 GB, 64 bits: 128 GB) +* area x86-64 x86-32 +* ------------------------------------------------------------ +* mapped physical memory 00000000 00000000 +* kernel virtual mappings 8000000000 3f000000 +* demand mappings 100000000000 40000000 +* heap (with libc only) 200000000000 b0000000 +* */ #define L1_FRAME 1
@@ -81,6 +83,15 @@typedef uint64_t pgentry_t ;#endif +#define MAX_MEM_SIZE 0x3f000000UL +#define VIRT_KERNEL_AREA 0x3f000000UL +#define VIRT_DEMAND_AREA 0x40000000UL +#define VIRT_HEAP_AREA 0xb0000000UL + +#define DEMAND_MAP_PAGES 0x6ffffUL +#define HEAP_PAGES_MAX ((HYPERVISOR_VIRT_START - VIRT_HEAP_AREA) / \ + PAGE_SIZE - 1) +#elif defined(__x86_64__)#define L2_PAGETABLE_SHIFT 21
@@ -106,6 +117,20 @@ typedef uint64_t pgentry_t;typedef unsigned long pgentry_t ;#endif +#define MAX_MEM_SIZE (512ULL << 30) +#define VIRT_KERNEL_AREA 0x0000008000000000UL +#define VIRT_DEMAND_AREA 0x0000100000000000UL +#define VIRT_HEAP_AREA 0x0000200000000000UL + +#define DEMAND_MAP_PAGES 0x8000000UL +#define HEAP_PAGES_MAX 0x8000000UL + +#endif + +#ifndef HAVE_LIBC +#define HEAP_PAGES 0 +#else +#define HEAP_PAGES HEAP_PAGES_MAX#endif #define L1_MASK ((1UL << L2_PAGETABLE_SHIFT) - 1)
mm.c +1 -1
@@ -375,7 +375,7 @@ void init_mm(void)arch_init_p2m (max_pfn); -arch_init_demand_mapping_area (max_pfn); +arch_init_demand_mapping_area (); }void fini_mm (void )
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v3 10/19 mini-os: remove unused mem_test() function
In reply to Juergen Grossmem_test() isn't used anywhere and its value is rather questionable with mini-os being in a mature state. Remove the function.
--- arch/x86/mm.c | 55 ------------------------------------------------------- 1 file changed, 55 deletions(-)
arch/x86/mm.c +0 -55
@@ -302,61 +302,6 @@ static void set_readonly(void *text, void *etext) }/* -* A useful mem testing function. Write the address to every address in the -* range provided and read back the value. If verbose, print page walk to -* some VA -* -* If we get MEM_TEST_MAX_ERRORS we might as well stop -*/ -#define MEM_TEST_MAX_ERRORS 10 -int mem_test (unsigned long *start_va,unsigned long *end_va,int verbose) -{ -unsigned long mask =0x10000 ; -unsigned long *pointer; -int error_count =0 ; - -/* write values and print page walks */ -if ( verbose && (((unsigned long )start_va) &0xfffff ) ) - { -printk ("MemTest Start: 0x%p\n" , start_va); -page_walk ((unsigned long )start_va); - } -for ( pointer = start_va; pointer < end_va; pointer++ ) - { -if ( verbose && !(((unsigned long )pointer) &0xfffff ) ) - { -printk ("Writing to %p\n" , pointer); -page_walk ((unsigned long )pointer); - } - *pointer = (unsigned long )pointer & ~mask; - } -if ( verbose && (((unsigned long )end_va) &0xfffff ) ) - { -printk ("MemTest End: %p\n" , end_va-1 ); -page_walk ((unsigned long )end_va-1 ); - } - -/* verify values */ -for ( pointer = start_va; pointer < end_va; pointer++ ) - { -if ( ((unsigned long )pointer & ~mask) != *pointer ) - { -printk ("Read error at 0x%lx. Read: 0x%lx, should read 0x%lx\n" , - (unsigned long )pointer, *pointer, - ((unsigned long )pointer & ~mask)); - error_count++; -if ( error_count >=MEM_TEST_MAX_ERRORS ) - { -printk ("mem_test: too many errors\n" ); -return -1 ; - } - } - } -return 0 ; -} - - -/* * get the PTE for virtual address va if it exists. Otherwise NULL. */ static pgentry_t *get_pgt (unsigned long va)
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v3 11/19 mini-os: add checks for out of memory
In reply to Juergen GrossThere are several core functions in Mini-OS not checking for failed memory allocations. Add such checks.
Add do_map_frames() dummy function to arm architecture as it will be needed in future for compilations to succeed.
--- arch/arm/mm.c | 8 ++++++++ arch/x86/mm.c | 26 +++++++++++++++++++------- include/mm.h | 2 +- 3 files changed, 28 insertions(+), 8 deletions(-)
arch/arm/mm.c +8 -0
@@ -1,6 +1,7 @@#include <mini-os/console.h> #include <xen/memory.h> #include <arch_mm.h> +#include <mini-os/errno.h> #include <mini-os/hypervisor.h> #include <libfdt.h> #include <lib.h>
@@ -79,6 +80,13 @@ void arch_init_demand_mapping_area(void) { } +int do_map_frames (unsigned long addr, +const unsigned long *f,unsigned long n,unsigned long stride, +unsigned long increment,domid_t id,int *err,unsigned long prot) +{ +return -ENOSYS ; +} +/* Get Xen's suggested physical page assignments for the grant table. */ static paddr_t get_gnttab_base (void ) {
arch/x86/mm.c +19 -7
@@ -34,6 +34,7 @@* DEALINGS IN THE SOFTWARE. */ +#include <mini-os/errno.h> #include <mini-os/os.h> #include <mini-os/hypervisor.h> #include <mini-os/mm.h>
@@ -354,6 +355,8 @@ pgentry_t *need_pgt(unsigned long va)if ( !(tab[offset] & _PAGE_PRESENT) ) { pt_pfn =virt_to_pfn (alloc_page ()); +if ( !pt_pfn ) +return NULL ;new_pt_frame (&pt_pfn, pt_mfn, offset,L3_FRAME ); }ASSERT (tab[offset] & _PAGE_PRESENT);
@@ -364,6 +367,8 @@ pgentry_t *need_pgt(unsigned long va)if ( !(tab[offset] & _PAGE_PRESENT) ) { pt_pfn =virt_to_pfn (alloc_page ()); +if ( !pt_pfn ) +return NULL ;new_pt_frame (&pt_pfn, pt_mfn, offset,L2_FRAME ); }ASSERT (tab[offset] & _PAGE_PRESENT);
@@ -373,6 +378,8 @@ pgentry_t *need_pgt(unsigned long va)if ( !(tab[offset] & _PAGE_PRESENT) ) { pt_pfn =virt_to_pfn (alloc_page ()); +if ( !pt_pfn ) +return NULL ;new_pt_frame (&pt_pfn, pt_mfn, offset,L1_FRAME ); }ASSERT (tab[offset] & _PAGE_PRESENT);
@@ -445,10 +452,10 @@ unsigned long allocate_ondemand(unsigned long n, unsigned long alignment)* va. map f[i*stride]+i*increment for i in 0..n-1. */ #define MAP_BATCH ((STACK_SIZE / 2) / sizeof(mmu_update_t)) -void do_map_frames (unsigned long va, -const unsigned long *mfns,unsigned long n, -unsigned long stride,unsigned long incr, -domid_t id,int *err,unsigned long prot) +int do_map_frames (unsigned long va, +const unsigned long *mfns,unsigned long n, +unsigned long stride,unsigned long incr, +domid_t id,int *err,unsigned long prot) {pgentry_t *pgt =NULL ;unsigned long done =0 ;
@@ -458,7 +465,7 @@ void do_map_frames(unsigned long va,if ( !mfns ) {printk ("do_map_frames: no mfns supplied\n" ); -return ; +return -EINVAL ; }DEBUG ("va=%p n=0x%lx, mfns[0]=0x%lx stride=0x%lx incr=0x%lx prot=0x%lx\n" , va, n, mfns[0 ], stride, incr, prot);
@@ -484,7 +491,9 @@ void do_map_frames(unsigned long va, {if ( !pgt || !(va &L1_MASK ) ) pgt =need_pgt (va); - +if ( !pgt ) +return -ENOMEM ; + mmu_updates[i].ptr =virt_to_mach (pgt) |MMU_NORMAL_PT_UPDATE ; mmu_updates[i].val = ((pgentry_t)(mfns[(done + i) * stride] + (done + i) * incr)
@@ -505,6 +514,8 @@ void do_map_frames(unsigned long va, } done += todo; } + +return 0 ; }/*
@@ -521,7 +532,8 @@ void *map_frames_ex(const unsigned long *mfns, unsigned long n,if ( !va )return NULL ; -do_map_frames (va, mfns, n, stride, incr, id, err, prot); +if (do_map_frames (va, mfns, n, stride, incr, id, err, prot) ) +return NULL ;return (void *)va; }
include/mm.h +1 -1
@@ -68,7 +68,7 @@ unsigned long allocate_ondemand(unsigned long n, unsigned long alignment);void *map_frames_ex (const unsigned long *f,unsigned long n,unsigned long stride,unsigned long increment,unsigned long alignment,domid_t id,int *err,unsigned long prot); -void do_map_frames (unsigned long addr, +int do_map_frames (unsigned long addr,const unsigned long *f,unsigned long n,unsigned long stride,unsigned long increment,domid_t id,int *err,unsigned long prot);int unmap_frames (unsigned long va,unsigned long num_frames);
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v3 12/19 mini-os: don't allocate new pages for level 1 p2m tree
In reply to Juergen GrossWhen constructing the 3 level p2m tree there is no need to allocate new pages for the level 1 containing the p2m info for all pages. The pages from the linear p2m list constructed by the hypervisor can be used for that purpose.
--- arch/x86/mm.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
arch/x86/mm.c +4 -10
@@ -625,11 +625,11 @@ void arch_init_p2m(unsigned long max_pfn)#define L2_P2M_MASK (L2_P2M_ENTRIES - 1)#define L3_P2M_MASK (L3_P2M_ENTRIES - 1) -unsigned long *l1_list =NULL , *l2_list =NULL , *l3_list; +unsigned long *l2_list =NULL , *l3_list;unsigned long pfn; l3_list = (unsigned long *)alloc_page (); -for ( pfn=0 ; pfn<max_pfn; pfn++ ) +for ( pfn =0 ; pfn < max_pfn; pfn +=L1_P2M_ENTRIES ) {if ( !(pfn % (L1_P2M_ENTRIES *L2_P2M_ENTRIES )) ) {
@@ -641,14 +641,8 @@ void arch_init_p2m(unsigned long max_pfn) } l3_list[(pfn >>L2_P2M_SHIFT )] =virt_to_mfn (l2_list); } -if ( !(pfn % (L1_P2M_ENTRIES )) ) - { - l1_list = (unsigned long *)alloc_page (); - l2_list[(pfn >>L1_P2M_SHIFT ) &L2_P2M_MASK ] = -virt_to_mfn (l1_list); - } - - l1_list[pfn &L1_P2M_MASK ] =pfn_to_mfn (pfn); + l2_list[(pfn >>L1_P2M_SHIFT ) &L2_P2M_MASK ] = +virt_to_mfn (phys_to_machine_mapping + pfn); } HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list =virt_to_mfn (l3_list);
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v3 13/19 mini-os: add function to map one frame
In reply to Juergen GrossAdd a function to map one physical frame to a specified virtual address as read/write. This will be used later multiple times.
--- include/arm/arch_mm.h | 2 ++ include/mm.h | 1 + mm.c | 5 +++++ 3 files changed, 8 insertions(+)
include/arm/arch_mm.h +2 -0
@@ -14,6 +14,8 @@ extern uint32_t physical_address_offset; /* Add this to a virtual address to get#define L1_PAGETABLE_SHIFT 12 +#define L1_PROT 0 +#define to_phys (x) (((paddr_t)(x)+physical_address_offset) & 0xffffffff)#define to_virt (x) ((void *)(((x)-physical_address_offset) & 0xffffffff))
include/mm.h +1 -0
@@ -72,6 +72,7 @@ int do_map_frames(unsigned long addr, const unsigned long *f, unsigned long n, unsigned long stride, unsigned long increment, domid_t id, int *err, unsigned long prot);int unmap_frames (unsigned long va,unsigned long num_frames); +int map_frame_rw (unsigned long addr,unsigned long mfn);#ifdef HAVE_LIBC extern unsigned long heap, brk, heap_mapped, heap_end;#endif
mm.c +5 -0
@@ -319,6 +319,11 @@ int free_physical_pages(xen_pfn_t *mfns, int n)return HYPERVISOR_memory_op (XENMEM_decrease_reservation, &reservation); } +int map_frame_rw (unsigned long addr,unsigned long mfn) +{ +return do_map_frames (addr, &mfn,1 ,1 ,1 ,DOMID_SELF ,NULL ,L1_PROT ); +} +#ifdef HAVE_LIBC void *sbrk (ptrdiff_t increment) {
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v3 14/19 mini-os: move p2m related macros to header file
In reply to Juergen GrossIn order to be able to use p2m related macros for ballooning move their definitions to arch/x86/mm.h.
There is no need to define different macros regarding index masks and number of entries for the different levels, as all levels share the same entry format (a plain mfn). So reduce the number of macros accordingly.
Add some macros to get the indices into p2m pages from a pfn and make use of them in current p2m code.
--- arch/x86/mm.c | 31 +++++-------------------------- include/x86/arch_mm.h | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+), 26 deletions(-)
arch/x86/mm.c +5 -26
@@ -609,40 +609,19 @@ static void clear_bootstrap(void)void arch_init_p2m (unsigned long max_pfn) { -#ifdef __x86_64__ -#define L1_P2M_SHIFT 9 -#define L2_P2M_SHIFT 18 -#define L3_P2M_SHIFT 27 -#else -#define L1_P2M_SHIFT 10 -#define L2_P2M_SHIFT 20 -#define L3_P2M_SHIFT 30 -#endif -#define L1_P2M_ENTRIES (1 << L1_P2M_SHIFT) -#define L2_P2M_ENTRIES (1 << (L2_P2M_SHIFT - L1_P2M_SHIFT)) -#define L3_P2M_ENTRIES (1 << (L3_P2M_SHIFT - L2_P2M_SHIFT)) -#define L1_P2M_MASK (L1_P2M_ENTRIES - 1) -#define L2_P2M_MASK (L2_P2M_ENTRIES - 1) -#define L3_P2M_MASK (L3_P2M_ENTRIES - 1) -unsigned long *l2_list =NULL , *l3_list;unsigned long pfn; +p2m_chk_pfn (max_pfn -1 ); l3_list = (unsigned long *)alloc_page (); -for ( pfn =0 ; pfn < max_pfn; pfn +=L1_P2M_ENTRIES ) +for ( pfn =0 ; pfn < max_pfn; pfn +=P2M_ENTRIES ) { -if ( !(pfn % (L1_P2M_ENTRIES *L2_P2M_ENTRIES )) ) +if ( !(pfn % (P2M_ENTRIES *P2M_ENTRIES )) ) { l2_list = (unsigned long *)alloc_page (); -if ( (pfn >>L3_P2M_SHIFT ) >0 ) - { -printk ("Error: Too many pfns.\n" ); -do_exit (); - } - l3_list[(pfn >>L2_P2M_SHIFT )] =virt_to_mfn (l2_list); + l3_list[L3_P2M_IDX (pfn)] =virt_to_mfn (l2_list); } - l2_list[(pfn >>L1_P2M_SHIFT ) &L2_P2M_MASK ] = -virt_to_mfn (phys_to_machine_mapping + pfn); + l2_list[L2_P2M_IDX (pfn)] =virt_to_mfn (phys_to_machine_mapping + pfn); } HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list =virt_to_mfn (l3_list);
include/x86/arch_mm.h +21 -0
@@ -176,7 +176,28 @@ typedef unsigned long pgentry_t;#define IO_PROT_NOCACHE (L1_PROT | _PAGE_PCD)/* for P2M */ +#ifdef __x86_64__ +#define P2M_SHIFT 9 +#else +#define P2M_SHIFT 10 +#endif +#define P2M_ENTRIES (1UL << P2M_SHIFT) +#define P2M_MASK (P2M_ENTRIES - 1) +#define L1_P2M_SHIFT P2M_SHIFT +#define L2_P2M_SHIFT (2 * P2M_SHIFT) +#define L3_P2M_SHIFT (3 * P2M_SHIFT) +#define L1_P2M_IDX (pfn) ((pfn) & P2M_MASK) +#define L2_P2M_IDX (pfn) (((pfn) >> L1_P2M_SHIFT) & P2M_MASK) +#define L3_P2M_IDX (pfn) (((pfn) >> L2_P2M_SHIFT) & P2M_MASK)#define INVALID_P2M_ENTRY (~0UL) +static inline void p2m_chk_pfn (unsigned long pfn) +{ +if ( (pfn >>L3_P2M_SHIFT ) >0 ) + { +printk ("Error: Too many pfns.\n" ); +do_exit (); + } +}#include "arch_limits.h" #define PAGE_SIZE __PAGE_SIZE
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v3 15/19 mini-os: remap p2m list in case of ballooning
In reply to Juergen GrossIn case of enabled ballooning we must be prepared for a growing p2m list. If the maximum memory size of the domain can't be covered by the actual p2m list remap it to the kernel virtual mapping area and leave enough space at the end.
---
V3: add assertion as requested by Samuel Thibault
--- arch/arm/balloon.c | 2 ++ arch/x86/balloon.c | 25 +++++++++++++++++++++++++ arch/x86/mm.c | 3 +++ include/balloon.h | 3 +++ include/x86/arch_mm.h | 4 ++++ 5 files changed, 37 insertions(+)
arch/arm/balloon.c +2 -0
@@ -25,4 +25,6 @@#ifdef CONFIG_BALLOON +unsigned long virt_kernel_area_end;/* TODO: find a virtual area */ +#endif
arch/x86/balloon.c +25 -0
@@ -21,8 +21,33 @@* DEALINGS IN THE SOFTWARE. */ +#include <mini-os/os.h> #include <mini-os/balloon.h> +#include <mini-os/lib.h> +#include <mini-os/mm.h> #ifdef CONFIG_BALLOON +unsigned long virt_kernel_area_end =VIRT_KERNEL_AREA ; + +void arch_remap_p2m (unsigned long max_pfn) +{ +unsigned long pfn; + +if (p2m_pages (nr_max_pages) <=p2m_pages (max_pfn) ) +return ; + +for ( pfn =0 ; pfn < max_pfn; pfn +=P2M_ENTRIES ) + { +map_frame_rw (virt_kernel_area_end +PAGE_SIZE * (pfn /P2M_ENTRIES ), +virt_to_mfn (phys_to_machine_mapping + pfn)); + } + + phys_to_machine_mapping = (unsigned long *)virt_kernel_area_end; +printk ("remapped p2m list to %p\n" , phys_to_machine_mapping); + + virt_kernel_area_end +=PAGE_SIZE *p2m_pages (nr_max_pages); +ASSERT (virt_kernel_area_end <=VIRT_DEMAND_AREA ); +} +#endif
arch/x86/mm.c +3 -0
@@ -37,6 +37,7 @@#include <mini-os/errno.h> #include <mini-os/os.h> #include <mini-os/hypervisor.h> +#include <mini-os/balloon.h> #include <mini-os/mm.h> #include <mini-os/types.h> #include <mini-os/lib.h>
@@ -626,6 +627,8 @@ void arch_init_p2m(unsigned long max_pfn) HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list =virt_to_mfn (l3_list); HYPERVISOR_shared_info->arch.max_pfn = max_pfn; + +arch_remap_p2m (max_pfn); }void arch_init_mm (unsigned long * start_pfn_p,unsigned long * max_pfn_p)
include/balloon.h +3 -0
@@ -27,12 +27,15 @@#ifdef CONFIG_BALLOON extern unsigned long nr_max_pages; +extern unsigned long virt_kernel_area_end;void get_max_pages (void ); +void arch_remap_p2m (unsigned long max_pfn);#else /* CONFIG_BALLOON */ static inline void get_max_pages (void ) { } +static inline void arch_remap_p2m (unsigned long max_pfn) { }#endif /* CONFIG_BALLOON */ #endif /* _BALLOON_H_ */
include/x86/arch_mm.h +4 -0
@@ -198,6 +198,10 @@ static inline void p2m_chk_pfn(unsigned long pfn)do_exit (); } } +static inline unsigned long p2m_pages (unsigned long pages) +{ +return (pages +P2M_ENTRIES -1 ) >>L1_P2M_SHIFT ; +}#include "arch_limits.h" #define PAGE_SIZE __PAGE_SIZE
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v3 16/19 mini-os: map page allocator's bitmap to virtual kernel area for ballooning
In reply to Juergen GrossIn case of CONFIG_BALLOON the page allocator's bitmap needs some space to be able to grow. Remap it to kernel virtual area if the preallocated area isn't large enough.
---
V3: - add assertion as requested by Samuel Thibault
- rename functions to have mm_ prefix as requested by Samuel Thibault
--- balloon.c | 18 ++++++++++++++++++ include/balloon.h | 2 ++ include/mm.h | 6 ++++++ mm.c | 43 ++++++++++++++++++++++--------------------- 4 files changed, 48 insertions(+), 21 deletions(-)
balloon.c +18 -0
@@ -44,3 +44,21 @@ void get_max_pages(void) nr_max_pages = ret;printk ("Maximum memory size: %ld pages\n" , nr_max_pages); } + +void mm_alloc_bitmap_remap (void ) +{ +unsigned long i; + +if ( mm_bitmap_size >= ((nr_max_pages +1 ) >> (PAGE_SHIFT +3 )) ) +return ; + +for ( i =0 ; i < mm_bitmap_size; i +=PAGE_SIZE ) + { +map_frame_rw (virt_kernel_area_end + i, +virt_to_mfn ((unsigned long )(mm_bitmap) + i)); + } + + mm_bitmap = (unsigned long *)virt_kernel_area_end; + virt_kernel_area_end +=round_pgup ((nr_max_pages +1 ) >> (PAGE_SHIFT +3 )); +ASSERT (virt_kernel_area_end <=VIRT_DEMAND_AREA ); +}
include/balloon.h +2 -0
@@ -31,11 +31,13 @@ extern unsigned long virt_kernel_area_end;void get_max_pages (void );void arch_remap_p2m (unsigned long max_pfn); +void mm_alloc_bitmap_remap (void );#else /* CONFIG_BALLOON */ static inline void get_max_pages (void ) { }static inline void arch_remap_p2m (unsigned long max_pfn) { } +static inline void mm_alloc_bitmap_remap (void ) { }#endif /* CONFIG_BALLOON */ #endif /* _BALLOON_H_ */
include/mm.h +6 -0
@@ -42,8 +42,14 @@#define STACK_SIZE_PAGE_ORDER __STACK_SIZE_PAGE_ORDER#define STACK_SIZE __STACK_SIZE +#define round_pgdown (_p) ((_p) & PAGE_MASK) +#define round_pgup (_p) (((_p) + (PAGE_SIZE - 1)) & PAGE_MASK) +extern unsigned long nr_free_pages; +extern unsigned long *mm_bitmap; +extern unsigned long mm_bitmap_size; +void init_mm (void );unsigned long alloc_pages (int order);#define alloc_page () alloc_pages(0)
mm.c +22 -21
103 lines not on this page · raw message
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v3 17/19 mini-os: add support for ballooning up
In reply to Juergen GrossAdd support for ballooning the domain up by a specified amount of pages. Following steps are performed:
- extending the p2m map
- extending the page allocator's bitmap
- getting new memory pages from the hypervisor
- adding the memory at the current end of guest memory
---
V3: change "if" to "while" in balloon_up() as requested by Samuel Thibault
--- arch/arm/balloon.c | 9 ++++++ arch/x86/balloon.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ balloon.c | 64 +++++++++++++++++++++++++++++++++++++ include/balloon.h | 5 +++ mm.c | 4 +++ 5 files changed, 176 insertions(+)
arch/arm/balloon.c +9 -0
@@ -27,4 +27,13 @@unsigned long virt_kernel_area_end;/* TODO: find a virtual area */ +int arch_expand_p2m (unsigned long max_pfn) +{ +return 0 ; +} + +void arch_pfn_add (unsigned long pfn,unsigned long mfn) +{ +} +#endif
arch/x86/balloon.c +94 -0
113 lines not on this page · raw message
balloon.c +64 -0
78 lines not on this page · raw message
include/balloon.h +5 -0
@@ -28,10 +28,15 @@extern unsigned long nr_max_pages;extern unsigned long virt_kernel_area_end; +extern unsigned long nr_mem_pages;void get_max_pages (void ); +int balloon_up (unsigned long n_pages); +void arch_remap_p2m (unsigned long max_pfn);void mm_alloc_bitmap_remap (void ); +int arch_expand_p2m (unsigned long max_pfn); +void arch_pfn_add (unsigned long pfn,unsigned long mfn);#else /* CONFIG_BALLOON */
mm.c +4 -0
@@ -382,6 +382,10 @@ void init_mm(void)arch_init_p2m (max_pfn);arch_init_demand_mapping_area (); + +#ifdef CONFIG_BALLOON + nr_mem_pages = max_pfn; +#endif }void fini_mm (void )
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v3 18/19 mini-os: balloon up in case of oom
In reply to Juergen GrossIf a memory shortage is detected balloon up.
Be careful to always leave some pages free as ballooning up might need some memory, too:
- new p2m frames
- page tables for addressing new p2m frame
- new frame for page allocation bitmap
- page table for addressing new page allocation bitmap frame
- page tables for addressing new 1:1 mapped frames
For the moment we only balloon up synchronously when memory shortage is detected in allocation routines with irqs on.
---
V3: Reverse chk_free_pages() return value as requested by Samuel Thibault
--- balloon.c | 32 ++++++++++++++++++++++++++++++++ include/balloon.h | 11 +++++++++++ mm.c | 4 +++- 3 files changed, 46 insertions(+), 1 deletion(-)
balloon.c +32 -0
@@ -126,3 +126,35 @@ int balloon_up(unsigned long n_pages)return rc; } + +static int in_balloon; + +int chk_free_pages (unsigned long needed) +{ +unsigned long n_pages; + +/* No need for ballooning if plenty of space available. */ +if ( needed +BALLOON_EMERGENCY_PAGES <= nr_free_pages ) +return 1 ; + +/* If we are already ballooning up just hope for the best. */ +if ( in_balloon ) +return 1 ; + +/* Interrupts disabled can't be handled right now. */ +if (irqs_disabled () ) +return 1 ; + + in_balloon =1 ; + +while ( needed +BALLOON_EMERGENCY_PAGES > nr_free_pages ) + { + n_pages = needed +BALLOON_EMERGENCY_PAGES - nr_free_pages; +if ( !balloon_up (n_pages) ) +break ; + } + + in_balloon =0 ; + +return needed <= nr_free_pages; +}
include/balloon.h +11 -0
@@ -26,6 +26,12 @@#ifdef CONFIG_BALLOON +/* +* Always keep some pages free for allocations while ballooning or +* interrupts disabled. +*/ +#define BALLOON_EMERGENCY_PAGES 64 +extern unsigned long nr_max_pages;extern unsigned long virt_kernel_area_end;extern unsigned long nr_mem_pages;
@@ -37,12 +43,17 @@ void arch_remap_p2m(unsigned long max_pfn);void mm_alloc_bitmap_remap (void );int arch_expand_p2m (unsigned long max_pfn);void arch_pfn_add (unsigned long pfn,unsigned long mfn); +int chk_free_pages (unsigned long needed);#else /* CONFIG_BALLOON */ static inline void get_max_pages (void ) { }static inline void arch_remap_p2m (unsigned long max_pfn) { }static inline void mm_alloc_bitmap_remap (void ) { } +static inline int chk_free_pages (unsigned long needed) +{ +return needed <= nr_free_pages; +}#endif /* CONFIG_BALLOON */ #endif /* _BALLOON_H_ */
mm.c +3 -1
@@ -209,6 +209,8 @@ unsigned long alloc_pages(int order)chunk_head_t *alloc_ch, *spare_ch;chunk_tail_t *spare_ct; +if ( !chk_free_pages (1UL << order) ) + goto no_memory;/* Find smallest order which can satisfy the request. */ for ( i = order; i <FREELIST_SIZE ; i++ ) {
@@ -343,7 +345,7 @@ void *sbrk(ptrdiff_t increment)if (new_brk > heap_mapped) {unsigned long n = (new_brk - heap_mapped +PAGE_SIZE -1 ) /PAGE_SIZE ; -if ( n > nr_free_pages ) +if ( !chk_free_pages (n) ) {printk ("Memory exhausted: want %ld pages, but only %ld are left\n" , n, nr_free_pages);
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v3 19/19 mini-os: repair build system
In reply to Juergen GrossThe build system of Mini-OS is using different settings for arch/*/* than for the rest of the tree. The main reasons are that Config.mk is included only conditionally in the top level Makefile, while minios.mk isn't included by the arch Makefiles.
Repairing this mess enables us to move the CONFIG_* handling to Config.mk enabling the arch sources to make use of those even if no MINIOS_CONFIG was specified by the caller.
Most of the files under config were not used. Integrate the used ones into Config.mk and delete the rest.
The CONFIG_* defines should be set for assembler sources, too.
--- Config.mk | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ Makefile | 44 -------------------------- arch/x86/Makefile | 3 -- config/MiniOS.mk | 10 ------ config/StdGNU.mk | 47 ---------------------------- config/arm32.mk | 22 ------------- config/arm64.mk | 19 ------------ config/x86_32.mk | 20 ------------ config/x86_64.mk | 33 -------------------- minios.mk | 4 +-- 10 files changed, 95 insertions(+), 200 deletions(-) delete mode 100644 config/MiniOS.mk delete mode 100644 config/StdGNU.mk delete mode 100644 config/arm32.mk delete mode 100644 config/arm64.mk delete mode 100644 config/x86_32.mk delete mode 100644 config/x86_64.mk
Config.mk +93 -0
@@ -23,6 +23,11 @@ cc-option = $(shell if test -z "`echo 'void*p=1;' | \ $(1) $(2) -S -o /dev/null -x c - 2>&1 | grep -- $(2) -`"; \ then echo "$(2)"; else echo "$(3)"; fi ;) +ifneq ($(MINIOS_CONFIG),) +EXTRA_DEPS += $(MINIOS_CONFIG) +include $(MINIOS_CONFIG) +endif + # Compatibility with Xen's stubdom build environment. If we are building # stubdom, some XEN_ variables are set, set MINIOS_ variables accordingly. #
@@ -97,3 +102,91 @@ DEF_CPPFLAGS += -DHAVE_LWIP DEF_CPPFLAGS += -isystem $(LWIPDIR)/src/include DEF_CPPFLAGS += -isystem $(LWIPDIR)/src/include/ipv4 endif + +# Set tools +AS = $(CROSS_COMPILE)as +LD = $(CROSS_COMPILE)ld +ifeq ($(clang),y) +CC = $(CROSS_COMPILE)clang +LD_LTO = $(CROSS_COMPILE)llvm-ld +else +CC = $(CROSS_COMPILE)gcc +LD_LTO = $(CROSS_COMPILE)ld +endif +CPP = $(CC) -E +AR = $(CROSS_COMPILE)ar +RANLIB = $(CROSS_COMPILE)ranlib +NM = $(CROSS_COMPILE)nm +STRIP = $(CROSS_COMPILE)strip +OBJCOPY = $(CROSS_COMPILE)objcopy +OBJDUMP = $(CROSS_COMPILE)objdump +SIZEUTIL = $(CROSS_COMPILE)size + +# Allow git to be wrappered in the environment +GIT ?= git + +INSTALL = install +INSTALL_DIR = $(INSTALL) -d -m0755 -p +INSTALL_DATA = $(INSTALL) -m0644 -p +INSTALL_PROG = $(INSTALL) -m0755 -p + +BOOT_DIR ?= /boot + +SOCKET_LIBS = +UTIL_LIBS = -lutil +DLOPEN_LIBS = -ldl + +SONAME_LDFLAG = -soname +SHLIB_LDFLAGS = -shared + +ifneq ($(debug),y) +CFLAGS += -O2 -fomit-frame-pointer +else +# Less than -O1 produces bad code and large stack frames +CFLAGS += -O1 -fno-omit-frame-pointer +CFLAGS-$(gcc) += -fno-optimize-sibling-calls +endif + +ifeq ($(lto),y) +CFLAGS += -flto +LDFLAGS-$(clang) += -plugin LLVMgold.so +endif + +# Configuration defaults +CONFIG_START_NETWORK ?= y +CONFIG_SPARSE_BSS ?= y +CONFIG_QEMU_XS_ARGS ?= n +CONFIG_TEST ?= n +CONFIG_PCIFRONT ?= n +CONFIG_BLKFRONT ?= y +CONFIG_TPMFRONT ?= n +CONFIG_TPM_TIS ?= n +CONFIG_TPMBACK ?= n +CONFIG_NETFRONT ?= y +CONFIG_FBFRONT ?= y +CONFIG_KBDFRONT ?= y +CONFIG_CONSFRONT ?= y +CONFIG_XENBUS ?= y +CONFIG_XC ?=y +CONFIG_LWIP ?= $(lwip) +CONFIG_BALLOON ?= n + +# Export config items as compiler directives +DEFINES-$(CONFIG_START_NETWORK) += -DCONFIG_START_NETWORK +DEFINES-$(CONFIG_SPARSE_BSS) += -DCONFIG_SPARSE_BSS +DEFINES-$(CONFIG_QEMU_XS_ARGS) += -DCONFIG_QEMU_XS_ARGS +DEFINES-$(CONFIG_PCIFRONT) += -DCONFIG_PCIFRONT +DEFINES-$(CONFIG_BLKFRONT) += -DCONFIG_BLKFRONT +DEFINES-$(CONFIG_TPMFRONT) += -DCONFIG_TPMFRONT +DEFINES-$(CONFIG_TPM_TIS) += -DCONFIG_TPM_TIS +DEFINES-$(CONFIG_TPMBACK) += -DCONFIG_TPMBACK +DEFINES-$(CONFIG_NETFRONT) += -DCONFIG_NETFRONT +DEFINES-$(CONFIG_KBDFRONT) += -DCONFIG_KBDFRONT +DEFINES-$(CONFIG_FBFRONT) += -DCONFIG_FBFRONT +DEFINES-$(CONFIG_CONSFRONT) += -DCONFIG_CONSFRONT +DEFINES-$(CONFIG_XENBUS) += -DCONFIG_XENBUS +DEFINES-$(CONFIG_BALLOON) += -DCONFIG_BALLOON + +# Override settings for this OS +PTHREAD_LIBS = +nosharedlibs=y
Makefile +0 -44
51 lines not on this page · raw message
arch/x86/Makefile +0 -3
@@ -6,9 +6,6 @@ TOPLEVEL_DIR = $(CURDIR)/../.. include ../../Config.mk -# include arch.mk has to be before mini-os.mk! - -include arch.mk include ../../minios.mk # Sources here are all *.c *.S without $(MINIOS_TARGET_ARCH).S
config/MiniOS.mk deleted +0 -10
@@ -1,10 +0,0 @@ -include $(MINIOS_ROOT)/config/StdGNU.mk -include $(MINIOS_ROOT)/Config.mk -CFLAGS += $(DEF_CFLAGS) $(ARCH_CFLAGS) -CPPFLAGS += $(DEF_CPPFLAGS) $(ARCH_CPPFLAGS) $(extra_incl) -ASFLAGS += $(DEF_ASFLAGS) $(ARCH_ASFLAGS) -LDFLAGS += $(DEF_LDFLAGS) $(ARCH_LDFLAGS) - -# Override settings for this OS -PTHREAD_LIBS = -nosharedlibs=y
config/StdGNU.mk deleted +0 -47
47 lines not on this page · raw message
config/arm32.mk deleted +0 -22
@@ -1,22 +0,0 @@ -CONFIG_ARM := y -CONFIG_ARM_32 := y -CONFIG_ARM_$(XEN_OS) := y - -CONFIG_XEN_INSTALL_SUFFIX := - -# -march= -mcpu= - -# Explicitly specifiy 32-bit ARM ISA since toolchain default can be -mthumb: -CFLAGS += -marm - -HAS_PL011 := y -HAS_EXYNOS4210 := y -HAS_OMAP := y -HAS_NS16550 := y - -# Use only if calling $(LD) directly. -LDFLAGS_DIRECT += -EL - -CONFIG_LOAD_ADDRESS ?= 0x80000000 - -IOEMU_CPU_ARCH ?= arm
config/arm64.mk deleted +0 -19
@@ -1,19 +0,0 @@ -CONFIG_ARM := y -CONFIG_ARM_64 := y -CONFIG_ARM_$(XEN_OS) := y - -CONFIG_XEN_INSTALL_SUFFIX := - -CFLAGS += #-marm -march= -mcpu= etc - -HAS_PL011 := y -HAS_NS16550 := y - -# Use only if calling $(LD) directly. -LDFLAGS_DIRECT += -EL - -CONFIG_LOAD_ADDRESS ?= 0x80000000 - -IOEMU_CPU_ARCH ?= aarch64 - -EFI_DIR ?= /usr/lib64/efi
config/x86_32.mk deleted +0 -20
@@ -1,20 +0,0 @@ -CONFIG_X86 := y -CONFIG_X86_32 := y -CONFIG_X86_$(XEN_OS) := y - -CONFIG_HVM := y -CONFIG_MIGRATE := y -CONFIG_XCUTILS := y - -HAS_MEM_ACCESS := y -HAS_MEM_PAGING := y -HAS_MEM_SHARING := y - -CFLAGS += -m32 -march=i686 - -# Use only if calling $(LD) directly. -LDFLAGS_DIRECT_OpenBSD = _obsd -LDFLAGS_DIRECT_FreeBSD = _fbsd -LDFLAGS_DIRECT += -melf_i386$(LDFLAGS_DIRECT_$(XEN_OS)) - -IOEMU_CPU_ARCH ?= i386
config/x86_64.mk deleted +0 -33
@@ -1,33 +0,0 @@ -CONFIG_X86 := y -CONFIG_X86_64 := y -CONFIG_X86_$(XEN_OS) := y - -CONFIG_COMPAT := y -CONFIG_HVM := y -CONFIG_MIGRATE := y -CONFIG_XCUTILS := y - -HAS_MEM_ACCESS := y -HAS_MEM_PAGING := y -HAS_MEM_SHARING := y - -CONFIG_XEN_INSTALL_SUFFIX := .gz - -CFLAGS += -m64 - -SunOS_LIBDIR = $(SunOS_LIBDIR_x86_64) - -EFI_DIR ?= /usr/lib64/efi - -# Use only if calling $(LD) directly. -ifeq ($(XEN_OS),OpenBSD) -LDFLAGS_DIRECT += -melf_x86_64_obsd -else -ifeq ($(XEN_OS),FreeBSD) -LDFLAGS_DIRECT += -melf_x86_64_fbsd -else -LDFLAGS_DIRECT += -melf_x86_64 -endif -endif - -IOEMU_CPU_ARCH ?= x86_64
minios.mk +2 -2
@@ -32,9 +32,9 @@ DEF_CFLAGS += -D__INSIDE_MINIOS__ # Build the CFLAGS and ASFLAGS for compiling and assembling. # DEF_... flags are the common mini-os flags, # ARCH_... flags may be defined in arch/$(TARGET_ARCH_FAM/rules.mk -CFLAGS := $(DEF_CFLAGS) $(ARCH_CFLAGS) +CFLAGS := $(DEF_CFLAGS) $(ARCH_CFLAGS) $(DEFINES-y) CPPFLAGS := $(DEF_CPPFLAGS) $(ARCH_CPPFLAGS) -ASFLAGS := $(DEF_ASFLAGS) $(ARCH_ASFLAGS) +ASFLAGS := $(DEF_ASFLAGS) $(ARCH_ASFLAGS) $(DEFINES-y) LDFLAGS := $(DEF_LDFLAGS) $(ARCH_LDFLAGS) # Special build dependencies.
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v3 16/19] mini-os: map page allocator's bitmap to virtual kernel area for ballooning
In reply to Juergen Grossinclude/mm.h line 51
Quoted 2 lines · Juergen Gross, on Thu 11 Aug 2016 11:18:19 +0200, wrote:
include/mm.h +2
-0+extern unsigned long *mm_bitmap; +extern unsigned long mm_bitmap_size;
Ah I was thinking to have these use mm_malloc_ too. "mm_bitmap" seems short for namespace pollution.
Samuel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v3 16/19] mini-os: map page allocator's bitmap to virtual kernel area for ballooning
Quoted 6 lines · Samuel Thibault
include/mm.h line 51
Quoted 2 lines · Juergen Gross, on Thu 11 Aug 2016 11:18:19 +0200, wrote:
include/mm.h +2
-0+extern unsigned long *mm_bitmap; +extern unsigned long mm_bitmap_size;Ah I was thinking to have these use
mm_malloc_too. "mm_bitmap" seems short for namespace pollution.
Quoted 1 line · you
Ditto,
mm_bitmapandmm_bitmap_size.
So I thought you wanted it to be that way.
I can easily change it again.
Wei, do I need to send all patches again, or is it enough to start with patch 16? Patches 1-15 are already Acked/Reviewed by Samuel.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v3 16/19] mini-os: map page allocator's bitmap to virtual kernel area for ballooning
Quoted 10 lines · Juergen Gross
Quoted 6 lines · Samuel Thibault
include/mm.h line 51
Quoted 2 lines · Juergen Gross, on Thu 11 Aug 2016 11:18:19 +0200, wrote:
include/mm.h +2
-0+extern unsigned long *mm_bitmap; +extern unsigned long mm_bitmap_size;Ah I was thinking to have these use
mm_malloc_too. "mm_bitmap" seems short for namespace pollution.Sorry, you wrote:
Quoted 10 lines
Quoted 1 line
Ditto,
mm_bitmapandmm_bitmap_size.So I thought you wanted it to be that way.
I can easily change it again.
Wei, do I need to send all patches again, or is it enough to start with patch 16? Patches 1-15 are already Acked/Reviewed by Samuel.
No need to resend all of them. Resending this one is ok.
I would in fact even prefer a git branch that I can pull and commit directly.
Wei.
Quoted 1 line
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v3 16/19] mini-os: map page allocator's bitmap to virtual kernel area for ballooning
In reply to Juergen GrossQuoted 8 lines · Juergen Gross, on Thu 11 Aug 2016 12:19:20 +0200, wrote:
Quoted 6 lines · Samuel Thibault
include/mm.h line 51
Quoted 2 lines · Juergen Gross, on Thu 11 Aug 2016 11:18:19 +0200, wrote:
include/mm.h +2
-0+extern unsigned long *mm_bitmap; +extern unsigned long mm_bitmap_size;Ah I was thinking to have these use
mm_malloc_too. "mm_bitmap" seems short for namespace pollution.
Quoted 5 lines
Quoted 1 line · you
Ditto,
mm_bitmapandmm_bitmap_size.So I thought you wanted it to be that way.
Oops, sorry about my typo.
Samuel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v3 16/19] mini-os: map page allocator's bitmap to virtual kernel area for ballooning
In reply to Wei LiuQuoted 15 lines · Wei Liu
Quoted 14 lines · Juergen Gross
Quoted 6 lines · Samuel Thibault
include/mm.h line 51
Quoted 2 lines · Juergen Gross, on Thu 11 Aug 2016 11:18:19 +0200, wrote:
include/mm.h +2
-0+extern unsigned long *mm_bitmap; +extern unsigned long mm_bitmap_size;Ah I was thinking to have these use
mm_malloc_too. "mm_bitmap" seems short for namespace pollution.Quoted 1 line · you
Ditto,
mm_bitmapandmm_bitmap_size.So I thought you wanted it to be that way.
Quoted 8 lines
Quoted 6 lines
I can easily change it again.
Wei, do I need to send all patches again, or is it enough to start with patch 16? Patches 1-15 are already Acked/Reviewed by Samuel.
No need to resend all of them. Resending this one is ok.
I think I'll need to modify at least one other patch due to this change. So I'll resend all modified patches.
Quoted 3 lines
I would in fact even prefer a git branch that I can pull and commit directly.
NP.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Series pushed, except for the last patch that changed the build system because it is not yet acked or reviewed.
Note that patch #16 and #17 are resent in another thread.
Thank you both.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v3 19/19] mini-os: repair build system
In reply to Juergen GrossQuoted 9 lines · Juergen Gross
The build system of Mini-OS is using different settings for
arch/*/*than for the rest of the tree. The main reasons are that Config.mk is included only conditionally in the top levelMakefile, while minios.mk isn't included by the arch Makefiles.Repairing this mess enables us to move the CONFIG_* handling to Config.mk enabling the arch sources to make use of those even if no
MINIOS_CONFIGwas specified by the caller.
Quoted 6 lines
Most of the files under config were not used. Integrate the used ones into Config.mk and delete the rest.
The CONFIG_* defines should be set for assembler sources, too.
Signed-off-by Juergen Gross <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v3 19/19] mini-os: repair build system
In reply to Juergen GrossQuoted 9 lines · Juergen Gross, on Thu 11 Aug 2016 11:18:22 +0200, wrote:
The build system of Mini-OS is using different settings for
arch/*/*than for the rest of the tree. The main reasons are that Config.mk is included only conditionally in the top levelMakefile, while minios.mk isn't included by the arch Makefiles.Repairing this mess enables us to move the CONFIG_* handling to Config.mk enabling the arch sources to make use of those even if no
MINIOS_CONFIGwas specified by the caller.
Quoted 6 lines
Most of the files under config were not used. Integrate the used ones into Config.mk and delete the rest.
The CONFIG_* defines should be set for assembler sources, too.
Signed-off-by Juergen Gross <[email protected]>
Quoted 403 lines
--- Config.mk | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ Makefile | 44 -------------------------- arch/x86/Makefile | 3 -- config/MiniOS.mk | 10 ------ config/StdGNU.mk | 47 ---------------------------- config/arm32.mk | 22 ------------- config/arm64.mk | 19 ------------ config/x86_32.mk | 20 ------------ config/x86_64.mk | 33 -------------------- minios.mk | 4 +-- 10 files changed, 95 insertions(+), 200 deletions(-) delete mode 100644 config/MiniOS.mk delete mode 100644 config/StdGNU.mk delete mode 100644 config/arm32.mk delete mode 100644 config/arm64.mk delete mode 100644 config/x86_32.mk delete mode 100644 config/x86_64.mkConfig.mk +93
-0@@ -23,6 +23,11 @@ cc-option = $(shell if test -z "`echo 'void*p=1;' | \ $(1) $(2) -S -o /dev/null -x c - 2>&1 | grep -- $(2) -`"; \ then echo "$(2)"; else echo "$(3)"; fi ;) +ifneq ($(MINIOS_CONFIG),) +EXTRA_DEPS += $(MINIOS_CONFIG) +include $(MINIOS_CONFIG) +endif + # Compatibility with Xen's stubdom build environment. If we are building # stubdom, some XEN_ variables are set, set MINIOS_ variables accordingly. #@@ -97,3 +102,91 @@ DEF_CPPFLAGS += -DHAVE_LWIP DEF_CPPFLAGS += -isystem $(LWIPDIR)/src/include DEF_CPPFLAGS += -isystem $(LWIPDIR)/src/include/ipv4 endif + +# Set tools +AS = $(CROSS_COMPILE)as +LD = $(CROSS_COMPILE)ld +ifeq ($(clang),y) +CC = $(CROSS_COMPILE)clang +LD_LTO = $(CROSS_COMPILE)llvm-ld +else +CC = $(CROSS_COMPILE)gcc +LD_LTO = $(CROSS_COMPILE)ld +endif +CPP = $(CC) -E +AR = $(CROSS_COMPILE)ar +RANLIB = $(CROSS_COMPILE)ranlib +NM = $(CROSS_COMPILE)nm +STRIP = $(CROSS_COMPILE)strip +OBJCOPY = $(CROSS_COMPILE)objcopy +OBJDUMP = $(CROSS_COMPILE)objdump +SIZEUTIL = $(CROSS_COMPILE)size + +# Allow git to be wrappered in the environment +GIT ?= git + +INSTALL = install +INSTALL_DIR = $(INSTALL) -d -m0755 -p +INSTALL_DATA = $(INSTALL) -m0644 -p +INSTALL_PROG = $(INSTALL) -m0755 -p + +BOOT_DIR ?= /boot + +SOCKET_LIBS = +UTIL_LIBS = -lutil +DLOPEN_LIBS = -ldl + +SONAME_LDFLAG = -soname +SHLIB_LDFLAGS = -shared + +ifneq ($(debug),y) +CFLAGS += -O2 -fomit-frame-pointer +else +# Less than -O1 produces bad code and large stack frames +CFLAGS += -O1 -fno-omit-frame-pointer +CFLAGS-$(gcc) += -fno-optimize-sibling-calls +endif + +ifeq ($(lto),y) +CFLAGS += -flto +LDFLAGS-$(clang) += -plugin LLVMgold.so +endif + +# Configuration defaults +CONFIG_START_NETWORK ?= y +CONFIG_SPARSE_BSS ?= y +CONFIG_QEMU_XS_ARGS ?= n +CONFIG_TEST ?= n +CONFIG_PCIFRONT ?= n +CONFIG_BLKFRONT ?= y +CONFIG_TPMFRONT ?= n +CONFIG_TPM_TIS ?= n +CONFIG_TPMBACK ?= n +CONFIG_NETFRONT ?= y +CONFIG_FBFRONT ?= y +CONFIG_KBDFRONT ?= y +CONFIG_CONSFRONT ?= y +CONFIG_XENBUS ?= y +CONFIG_XC ?=y +CONFIG_LWIP ?= $(lwip) +CONFIG_BALLOON ?= n + +# Export config items as compiler directives +DEFINES-$(CONFIG_START_NETWORK) += -DCONFIG_START_NETWORK +DEFINES-$(CONFIG_SPARSE_BSS) += -DCONFIG_SPARSE_BSS +DEFINES-$(CONFIG_QEMU_XS_ARGS) += -DCONFIG_QEMU_XS_ARGS +DEFINES-$(CONFIG_PCIFRONT) += -DCONFIG_PCIFRONT +DEFINES-$(CONFIG_BLKFRONT) += -DCONFIG_BLKFRONT +DEFINES-$(CONFIG_TPMFRONT) += -DCONFIG_TPMFRONT +DEFINES-$(CONFIG_TPM_TIS) += -DCONFIG_TPM_TIS +DEFINES-$(CONFIG_TPMBACK) += -DCONFIG_TPMBACK +DEFINES-$(CONFIG_NETFRONT) += -DCONFIG_NETFRONT +DEFINES-$(CONFIG_KBDFRONT) += -DCONFIG_KBDFRONT +DEFINES-$(CONFIG_FBFRONT) += -DCONFIG_FBFRONT +DEFINES-$(CONFIG_CONSFRONT) += -DCONFIG_CONSFRONT +DEFINES-$(CONFIG_XENBUS) += -DCONFIG_XENBUS +DEFINES-$(CONFIG_BALLOON) += -DCONFIG_BALLOON + +# Override settings for this OS +PTHREAD_LIBS = +nosharedlibs=yMakefile +0
-44@@ -7,51 +7,7 @@ OBJ_DIR=$(CURDIR) TOPLEVEL_DIR=$(CURDIR) -ifeq ($(MINIOS_CONFIG),) include Config.mk -else -EXTRA_DEPS += $(MINIOS_CONFIG) -include $(MINIOS_CONFIG) -endif - -include $(MINIOS_ROOT)/config/MiniOS.mk - -# Configuration defaults -CONFIG_START_NETWORK ?= y -CONFIG_SPARSE_BSS ?= y -CONFIG_QEMU_XS_ARGS ?= n -CONFIG_TEST ?= n -CONFIG_PCIFRONT ?= n -CONFIG_BLKFRONT ?= y -CONFIG_TPMFRONT ?= n -CONFIG_TPM_TIS ?= n -CONFIG_TPMBACK ?= n -CONFIG_NETFRONT ?= y -CONFIG_FBFRONT ?= y -CONFIG_KBDFRONT ?= y -CONFIG_CONSFRONT ?= y -CONFIG_XENBUS ?= y -CONFIG_XC ?=y -CONFIG_LWIP ?= $(lwip) -CONFIG_BALLOON ?= n - -# Export config items as compiler directives -flags-$(CONFIG_START_NETWORK) += -DCONFIG_START_NETWORK -flags-$(CONFIG_SPARSE_BSS) += -DCONFIG_SPARSE_BSS -flags-$(CONFIG_QEMU_XS_ARGS) += -DCONFIG_QEMU_XS_ARGS -flags-$(CONFIG_PCIFRONT) += -DCONFIG_PCIFRONT -flags-$(CONFIG_BLKFRONT) += -DCONFIG_BLKFRONT -flags-$(CONFIG_TPMFRONT) += -DCONFIG_TPMFRONT -flags-$(CONFIG_TPM_TIS) += -DCONFIG_TPM_TIS -flags-$(CONFIG_TPMBACK) += -DCONFIG_TPMBACK -flags-$(CONFIG_NETFRONT) += -DCONFIG_NETFRONT -flags-$(CONFIG_KBDFRONT) += -DCONFIG_KBDFRONT -flags-$(CONFIG_FBFRONT) += -DCONFIG_FBFRONT -flags-$(CONFIG_CONSFRONT) += -DCONFIG_CONSFRONT -flags-$(CONFIG_XENBUS) += -DCONFIG_XENBUS -flags-$(CONFIG_BALLOON) += -DCONFIG_BALLOON - -DEF_CFLAGS += $(flags-y) # Symlinks and headers that must be created before building the C files GENERATED_HEADERS := include/list.h $(ARCH_LINKS) include/mini-os include/$(TARGET_ARCH_FAM)/mini-osarch/x86/Makefile +0
-3@@ -6,9 +6,6 @@ TOPLEVEL_DIR = $(CURDIR)/../.. include ../../Config.mk -# include arch.mk has to be before mini-os.mk! - -include arch.mk include ../../minios.mk # Sources here are all *.c *.S without $(MINIOS_TARGET_ARCH).Sconfig/MiniOS.mk deleted +0
-10@@ -1,10 +0,0 @@ -include $(MINIOS_ROOT)/config/StdGNU.mk -include $(MINIOS_ROOT)/Config.mk -CFLAGS += $(DEF_CFLAGS) $(ARCH_CFLAGS) -CPPFLAGS += $(DEF_CPPFLAGS) $(ARCH_CPPFLAGS) $(extra_incl) -ASFLAGS += $(DEF_ASFLAGS) $(ARCH_ASFLAGS) -LDFLAGS += $(DEF_LDFLAGS) $(ARCH_LDFLAGS) - -# Override settings for this OS -PTHREAD_LIBS = -nosharedlibs=yconfig/StdGNU.mk deleted +0
-47@@ -1,47 +0,0 @@ -AS = $(CROSS_COMPILE)as -LD = $(CROSS_COMPILE)ld -ifeq ($(clang),y) -CC = $(CROSS_COMPILE)clang -LD_LTO = $(CROSS_COMPILE)llvm-ld -else -CC = $(CROSS_COMPILE)gcc -LD_LTO = $(CROSS_COMPILE)ld -endif -CPP = $(CC) -E -AR = $(CROSS_COMPILE)ar -RANLIB = $(CROSS_COMPILE)ranlib -NM = $(CROSS_COMPILE)nm -STRIP = $(CROSS_COMPILE)strip -OBJCOPY = $(CROSS_COMPILE)objcopy -OBJDUMP = $(CROSS_COMPILE)objdump -SIZEUTIL = $(CROSS_COMPILE)size - -# Allow git to be wrappered in the environment -GIT ?= git - -INSTALL = install -INSTALL_DIR = $(INSTALL) -d -m0755 -p -INSTALL_DATA = $(INSTALL) -m0644 -p -INSTALL_PROG = $(INSTALL) -m0755 -p - -BOOT_DIR ?= /boot - -SOCKET_LIBS = -UTIL_LIBS = -lutil -DLOPEN_LIBS = -ldl - -SONAME_LDFLAG = -soname -SHLIB_LDFLAGS = -shared - -ifneq ($(debug),y) -CFLAGS += -O2 -fomit-frame-pointer -else -# Less than -O1 produces bad code and large stack frames -CFLAGS += -O1 -fno-omit-frame-pointer -CFLAGS-$(gcc) += -fno-optimize-sibling-calls -endif - -ifeq ($(lto),y) -CFLAGS += -flto -LDFLAGS-$(clang) += -plugin LLVMgold.so -endifconfig/arm32.mk deleted +0
-22@@ -1,22 +0,0 @@ -CONFIG_ARM := y -CONFIG_ARM_32 := y -CONFIG_ARM_$(XEN_OS) := y - -CONFIG_XEN_INSTALL_SUFFIX := - -# -march= -mcpu= - -# Explicitly specifiy 32-bit ARM ISA since toolchain default can be -mthumb: -CFLAGS += -marm - -HAS_PL011 := y -HAS_EXYNOS4210 := y -HAS_OMAP := y -HAS_NS16550 := y - -# Use only if calling $(LD) directly. -LDFLAGS_DIRECT += -EL - -CONFIG_LOAD_ADDRESS ?= 0x80000000 - -IOEMU_CPU_ARCH ?= armconfig/arm64.mk deleted +0
-19@@ -1,19 +0,0 @@ -CONFIG_ARM := y -CONFIG_ARM_64 := y -CONFIG_ARM_$(XEN_OS) := y - -CONFIG_XEN_INSTALL_SUFFIX := - -CFLAGS += #-marm -march= -mcpu= etc - -HAS_PL011 := y -HAS_NS16550 := y - -# Use only if calling $(LD) directly. -LDFLAGS_DIRECT += -EL - -CONFIG_LOAD_ADDRESS ?= 0x80000000 - -IOEMU_CPU_ARCH ?= aarch64 - -EFI_DIR ?= /usr/lib64/eficonfig/x86_32.mk deleted +0
-20@@ -1,20 +0,0 @@ -CONFIG_X86 := y -CONFIG_X86_32 := y -CONFIG_X86_$(XEN_OS) := y - -CONFIG_HVM := y -CONFIG_MIGRATE := y -CONFIG_XCUTILS := y - -HAS_MEM_ACCESS := y -HAS_MEM_PAGING := y -HAS_MEM_SHARING := y - -CFLAGS += -m32 -march=i686 - -# Use only if calling $(LD) directly. -LDFLAGS_DIRECT_OpenBSD = _obsd -LDFLAGS_DIRECT_FreeBSD = _fbsd -LDFLAGS_DIRECT += -melf_i386$(LDFLAGS_DIRECT_$(XEN_OS)) - -IOEMU_CPU_ARCH ?= i386config/x86_64.mk deleted +0
-33@@ -1,33 +0,0 @@ -CONFIG_X86 := y -CONFIG_X86_64 := y -CONFIG_X86_$(XEN_OS) := y - -CONFIG_COMPAT := y -CONFIG_HVM := y -CONFIG_MIGRATE := y -CONFIG_XCUTILS := y - -HAS_MEM_ACCESS := y -HAS_MEM_PAGING := y -HAS_MEM_SHARING := y - -CONFIG_XEN_INSTALL_SUFFIX := .gz - -CFLAGS += -m64 - -SunOS_LIBDIR = $(SunOS_LIBDIR_x86_64) - -EFI_DIR ?= /usr/lib64/efi - -# Use only if calling $(LD) directly. -ifeq ($(XEN_OS),OpenBSD) -LDFLAGS_DIRECT += -melf_x86_64_obsd -else -ifeq ($(XEN_OS),FreeBSD) -LDFLAGS_DIRECT += -melf_x86_64_fbsd -else -LDFLAGS_DIRECT += -melf_x86_64 -endif -endif - -IOEMU_CPU_ARCH ?= x86_64minios.mk +2
-2@@ -32,9 +32,9 @@ DEF_CFLAGS += -D__INSIDE_MINIOS__ # Build the CFLAGS and ASFLAGS for compiling and assembling. # DEF_... flags are the common mini-os flags, # ARCH_... flags may be defined in arch/$(TARGET_ARCH_FAM/rules.mk -CFLAGS := $(DEF_CFLAGS) $(ARCH_CFLAGS) +CFLAGS := $(DEF_CFLAGS) $(ARCH_CFLAGS) $(DEFINES-y) CPPFLAGS := $(DEF_CPPFLAGS) $(ARCH_CPPFLAGS) -ASFLAGS := $(DEF_ASFLAGS) $(ARCH_ASFLAGS) +ASFLAGS := $(DEF_ASFLAGS) $(ARCH_ASFLAGS) $(DEFINES-y) LDFLAGS := $(DEF_LDFLAGS) $(ARCH_LDFLAGS) # Special build dependencies.Signature · 1 line
2.6.6
Signature · 8 lines
Samuel <s> on se croirait en cool : Some browsers close comments on the first ">" character, so to hide script content from such browsers, you can transpose operands for relational and shift operators (e.g., use "y < x" rather than "x > y") or use scripting language-dependent escapes for ">". -+- #ens-mim -+- _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Quoted 13 lines · Juergen Gross
Support ballooning Mini-OS automatically up in case of memory shortage.
Do some cleanups, a small correction and add some basic features to lay groundwork for support of ballooning in Mini-OS (patches 1-14).
The main visible change is the virtual memory layout: to be able to add memory to the running Mini-OS we need to have some spare areas especially after the 1:1 mapping of physical memory.
Then add the ballooning functionality: the p2m map must be expanded, the page allocator's bitmap must be expanded and we must get new memory from the hypervisor.
Quoted 9 lines
In case of a detected memory shortage the domain will balloon up until either enough memory is available or the upper limit has been reached.
Ballooning has been tested with a xenstore stubdom. Regression tests have been done with:
- pure mini-os
- ioemu stubdom
- pvgrub 64 bit
Unfortunately vtmpmgr stubdom build failed. :-/
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 17 lines · Wei Liu
Quoted 16 lines · Juergen Gross
Support ballooning Mini-OS automatically up in case of memory shortage.
Do some cleanups, a small correction and add some basic features to lay groundwork for support of ballooning in Mini-OS (patches 1-14).
The main visible change is the virtual memory layout: to be able to add memory to the running Mini-OS we need to have some spare areas especially after the 1:1 mapping of physical memory.
Then add the ballooning functionality: the p2m map must be expanded, the page allocator's bitmap must be expanded and we must get new memory from the hypervisor.
In case of a detected memory shortage the domain will balloon up until either enough memory is available or the upper limit has been reached.
Quoted 9 lines
Quoted 6 lines
Ballooning has been tested with a xenstore stubdom. Regression tests have been done with:
- pure mini-os
- ioemu stubdom
- pvgrub 64 bitUnfortunately vtmpmgr stubdom build failed. :-/
And that's probably because vtpmmgr uses printk or whatever...
Here is a patch that seems to fix the build:
---8<---
From d72510368cdc3c73af3c8918a404a8137f40bd9c Mon Sep 17 00:00:00 2001
From: Wei Liu <[email protected]>
Date: Fri, 12 Aug 2016 11:32:57 +0100
Subject: [PATCH] x86/arch_mm.h: move p2m_chk_pfn to x86/mm.c
Making that function inlined won't buy us much and is causing error in vtpm manager stubdom build.
--- arch/x86/mm.c | 9 +++++++++ include/x86/arch_mm.h | 11 +++-------- 2 files changed, 12 insertions(+), 8 deletions(-)
arch/x86/mm.c +9 -0
@@ -608,6 +608,15 @@ static void clear_bootstrap(void)printk ("Unable to unmap NULL page. rc=%d\n" , rc); } +void p2m_chk_pfn (unsigned long pfn) +{ +if ( (pfn >>L3_P2M_SHIFT ) >0 ) + { +printk ("Error: Too many pfns.\n" ); +do_exit (); + } +} +void arch_init_p2m (unsigned long max_pfn) {unsigned long *l2_list =NULL , *l3_list;
include/x86/arch_mm.h +3 -8
@@ -190,14 +190,9 @@ typedef unsigned long pgentry_t;#define L2_P2M_IDX (pfn) (((pfn) >> L1_P2M_SHIFT) & P2M_MASK)#define L3_P2M_IDX (pfn) (((pfn) >> L2_P2M_SHIFT) & P2M_MASK)#define INVALID_P2M_ENTRY (~0UL) -static inline void p2m_chk_pfn (unsigned long pfn) -{ -if ( (pfn >>L3_P2M_SHIFT ) >0 ) - { -printk ("Error: Too many pfns.\n" ); -do_exit (); - } -} + +void p2m_chk_pfn (unsigned long pfn); +static inline unsigned long p2m_pages (unsigned long pages) {return (pages +P2M_ENTRIES -1 ) >>L1_P2M_SHIFT ;
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Samuel Thibault
Acked-byQuoted 10 lines · Wei Liu, on Fri 12 Aug 2016 13:48:09 +0100, wrote:
---8<---
Fromd72510368cdc3c73af3c8918a404a8137f40bd9cMon Sep 17 00:00:00 2001
From: Wei Liu <[email protected]>
Date: Fri, 12 Aug 2016 11:32:57 +0100
Subject: [PATCH]x86/arch_mm.h: movep2m_chk_pfntox86/mm.cMaking that function inlined won't buy us much and is causing error in vtpm manager stubdom build.
Signed-off-by Wei Liu <[email protected]>
Quoted 50 lines
--- arch/x86/mm.c | 9 +++++++++ include/x86/arch_mm.h | 11 +++-------- 2 files changed, 12 insertions(+), 8 deletions(-)arch/x86/mm.c +9
-0@@ -608,6 +608,15 @@ static void clear_bootstrap(void)printk ("Unable to unmap NULL page. rc=%d\n" , rc); } +void p2m_chk_pfn (unsigned long pfn) +{ +if ( (pfn >>L3_P2M_SHIFT ) >0 ) + { +printk ("Error: Too many pfns.\n" ); +do_exit (); + } +} +void arch_init_p2m (unsigned long max_pfn) {unsigned long *l2_list =NULL , *l3_list;include/x86/arch_mm.h +3
-8@@ -190,14 +190,9 @@ typedef unsigned long pgentry_t;#define L2_P2M_IDX (pfn) (((pfn) >> L1_P2M_SHIFT) & P2M_MASK)#define L3_P2M_IDX (pfn) (((pfn) >> L2_P2M_SHIFT) & P2M_MASK)#define INVALID_P2M_ENTRY (~0UL) -static inline void p2m_chk_pfn (unsigned long pfn) -{ -if ( (pfn >>L3_P2M_SHIFT ) >0 ) - { -printk ("Error: Too many pfns.\n" ); -do_exit (); - } -} + +void p2m_chk_pfn (unsigned long pfn); +static inline unsigned long p2m_pages (unsigned long pages) {return (pages +P2M_ENTRIES -1 ) >>L1_P2M_SHIFT ;Signature · 1 line
2.1.4
Signature · 9 lines
Samuel "How should I know if it works? That's what beta testers are for. I only coded it." (Attributed to Linus Torvalds, somewhere in a posting) _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel