mini-os: support HVMlite mode
Subsystems (4)
Juergen Gross
maintainercover mini-os: support HVMlite mode
This patch series adds HVMlite support for Mini-OS. Setting CONFIG_PARAVIRT to "n" (default is "y") will build mini-os as a HVMlite domain on x86. Both 32- and 64-bit builds are supported.
Tested with plain Mini-OS configuration to work in 32- and 64-bit mode either paravirtualized or as HVM domain (device-model none).
Ballooning should basically work, too, but there is some support for a sparse memory map missing in HVMlite mode.
Juergen Gross (22):
mini-os: resync xen headers
mini-os: make dump_regs() work in early boot
mini-os: add CONFIG_PARAVIRT
mini-os: make some memory management related macros usable from
assembler
mini-os: add boot code for HVMlite support
mini-os: setup hypercall page for HVMlite
mini-os: support hvm_op hypercall
mini-os: initialize trap handling for HVMlite
mini-os: support HVMlite traps
mini-os: make p2m related code depend on CONFIG_PARAVIRT
mini-os: add static page tables for virtual kernel area for HVMlite
mini-os: add x86 native page table handling
mini-os: correct wrong calculation of alloc bitmap size
mini-os: add map_frame_virt() function
mini-os: setup console interface parameters
mini-os: setup xenbus interface parameters
mini-os: add get_cmdline() function
mini-os: map shared info page for HVMlite
mini-os: remove using start_info in architecture independent code
mini-os: print start of day messages depending on domain type
mini-os: get physical memory map
mini-os: support idle for HVMlite
Config.mk | 6 + Makefile | 2 +- arch/arm/arm32.S | 4 +- arch/arm/balloon.c | 7 - arch/arm/mm.c | 17 +- arch/arm/setup.c | 66 +----- arch/x86/arch.mk | 4 + arch/x86/balloon.c | 26 ++- arch/x86/events.c | 4 +- arch/x86/mm.c | 347 +++++++++++++++++++++++++++----- arch/x86/setup.c | 155 ++++++++------ arch/x86/time.c | 11 +- arch/x86/traps.c | 108 +++++++++- arch/x86/x86_32.S | 50 ++++- arch/x86/x86_64.S | 66 +++++- arch/x86/x86_hvm.S | 77 +++++++ balloon.c | 12 +- console/xencons_ring.c | 38 +++- daytime.c | 2 +- events.c | 3 +- hypervisor.c | 44 ++++ include/arm/arch_mm.h | 3 - include/balloon.h | 4 - include/compiler.h | 1 + include/console.h | 3 +- include/e820.h | 48 +++++ include/hypervisor.h | 17 +- include/kernel.h | 3 + include/mm.h | 3 +- include/paravirt.h | 81 ++++++++ include/x86/arch_mm.h | 101 +++++----- include/x86/desc.h | 366 ++++++++++++++++++++++++++++++++++ include/x86/os.h | 104 +++++++++- include/x86/x86_32/hypercall-x86_32.h | 6 + include/x86/x86_64/hypercall-x86_64.h | 6 + include/xen/arch-x86/hvm/start_info.h | 98 +++++++++ include/xen/arch-x86/xen-x86_32.h | 2 + include/xen/arch-x86/xen-x86_64.h | 2 + include/xen/elfnote.h | 12 +- include/xenbus.h | 3 + kernel.c | 7 +- main.c | 11 +- minios.mk | 2 +- mm.c | 80 +++++--- test.c | 20 +- xenbus/xenbus.c | 40 +++- 46 files changed, 1697 insertions(+), 375 deletions(-) create mode 100644 arch/x86/x86_hvm.S create mode 100644 include/e820.h create mode 100644 include/paravirt.h create mode 100644 include/x86/desc.h create mode 100644 include/xen/arch-x86/hvm/start_info.h
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Juergen Gross
maintainerPATCH 1/22 mini-os: resync xen headers
Use the latest Xen headers.
--- include/xen/arch-x86/hvm/start_info.h | 98 +++++++++++++++++++++++++++++++++++ include/xen/elfnote.h | 12 ++++- 2 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 include/xen/arch-x86/hvm/start_info.h
include/xen/arch-x86/hvm/start_info.h new file +98 -0
@@ -0,0 +1,98 @@ +/* +* 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. +* +* Copyright (c) 2016, Citrix Systems, Inc. +*/ + +#ifndef __XEN_PUBLIC_ARCH_X86_HVM_START_INFO_H__ +#define __XEN_PUBLIC_ARCH_X86_HVM_START_INFO_H__ + +/* +* Start of day structure passed to PVH guests and to HVM guests in %ebx. +* +* NOTE: nothing will be loaded at physical address 0, so a 0 value in any +* of the address fields should be treated as not present. +* +* 0 +----------------+ +* | magic | Contains the magic value XEN_HVM_START_MAGIC_VALUE +* | | ("xEn3" with the 0x80 bit of the "E" set). +* 4 +----------------+ +* | version | Version of this structure. Current version is 0. New +* | | versions are guaranteed to be backwards-compatible. +* 8 +----------------+ +* | flags | SIF_xxx flags. +* 12 +----------------+ +* | nr_modules | Number of modules passed to the kernel. +* 16 +----------------+ +* | modlist_paddr | Physical address of an array of modules +* | | (layout of the structure below). +* 24 +----------------+ +* | cmdline_paddr | Physical address of the command line, +* | | a zero-terminated ASCII string. +* 32 +----------------+ +* | rsdp_paddr | Physical address of the RSDP ACPI data structure. +* 40 +----------------+ +* +* The layout of each entry in the module structure is the following: +* +* 0 +----------------+ +* | paddr | Physical address of the module. +* 8 +----------------+ +* | size | Size of the module in bytes. +* 16 +----------------+ +* | cmdline_paddr | Physical address of the command line, +* | | a zero-terminated ASCII string. +* 24 +----------------+ +* | reserved | +* 32 +----------------+ +* +* The address and sizes are always a 64bit little endian unsigned integer. +* +* NB: Xen on x86 will always try to place all the data below the 4GiB +* boundary. +*/ +#define XEN_HVM_START_MAGIC_VALUE 0x336ec578 + +/* +* C representation of the x86/HVM start info layout. +* +* The canonical definition of this layout is above, this is just a way to +* represent the layout described there using C types. +*/ +struct hvm_start_info { +uint32_t magic;/* Contains the magic value 0x336ec578 */ +/* ("xEn3" with the 0x80 bit of the "E" set).*/ +uint32_t version;/* Version of this structure. */ +uint32_t flags;/* SIF_xxx flags. */ +uint32_t nr_modules;/* Number of modules passed to the kernel. */ +uint64_t modlist_paddr;/* Physical address of an array of */ +/* hvm_modlist_entry. */ +uint64_t cmdline_paddr;/* Physical address of the command line. */ +uint64_t rsdp_paddr;/* Physical address of the RSDP ACPI data */ +/* structure. */ +}; + +struct hvm_modlist_entry { +uint64_t paddr;/* Physical address of the module. */ +uint64_t size;/* Size of the module in bytes. */ +uint64_t cmdline_paddr;/* Physical address of the command line. */ +uint64_t reserved; +}; + +#endif /* __XEN_PUBLIC_ARCH_X86_HVM_START_INFO_H__ */
include/xen/elfnote.h +11 -1
@@ -200,9 +200,19 @@#define XEN_ELFNOTE_SUPPORTED_FEATURES 17/* +* Physical entry point into the kernel. +* +* 32bit entry point into the kernel. When requested to launch the +* guest kernel in a HVM container, Xen will use this entry point to +* launch the guest in 32bit protected mode with paging disabled. +* Ignored otherwise. +*/ +#define XEN_ELFNOTE_PHYS32_ENTRY 18 + +/* * The number of the highest elfnote defined. */ -#define XEN_ELFNOTE_MAX XEN_ELFNOTE_SUPPORTED_FEATURES +#define XEN_ELFNOTE_MAX XEN_ELFNOTE_PHYS32_ENTRY/* * System information exported through crash notes.
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 01/22] mini-os: resync xen headers
Quoted 3 lines · Juergen Gross, on Tue 23 Aug 2016 17:15:47 +0200, wrote:
Use the latest Xen headers.
Signed-off-by Juergen Gross <[email protected]>
Quoted 138 lines
--- include/xen/arch-x86/hvm/start_info.h | 98 +++++++++++++++++++++++++++++++++++ include/xen/elfnote.h | 12 ++++- 2 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 include/xen/arch-x86/hvm/start_info.hinclude/xen/arch-x86/hvm/start_info.h new file +98
-0@@ -0,0 +1,98 @@ +/* +* 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. +* +* Copyright (c) 2016, Citrix Systems, Inc. +*/ + +#ifndef __XEN_PUBLIC_ARCH_X86_HVM_START_INFO_H__ +#define __XEN_PUBLIC_ARCH_X86_HVM_START_INFO_H__ + +/* +* Start of day structure passed to PVH guests and to HVM guests in %ebx. +* +* NOTE: nothing will be loaded at physical address 0, so a 0 value in any +* of the address fields should be treated as not present. +* +* 0 +----------------+ +* | magic | Contains the magic value XEN_HVM_START_MAGIC_VALUE +* | | ("xEn3" with the 0x80 bit of the "E" set). +* 4 +----------------+ +* | version | Version of this structure. Current version is 0. New +* | | versions are guaranteed to be backwards-compatible. +* 8 +----------------+ +* | flags | SIF_xxx flags. +* 12 +----------------+ +* | nr_modules | Number of modules passed to the kernel. +* 16 +----------------+ +* | modlist_paddr | Physical address of an array of modules +* | | (layout of the structure below). +* 24 +----------------+ +* | cmdline_paddr | Physical address of the command line, +* | | a zero-terminated ASCII string. +* 32 +----------------+ +* | rsdp_paddr | Physical address of the RSDP ACPI data structure. +* 40 +----------------+ +* +* The layout of each entry in the module structure is the following: +* +* 0 +----------------+ +* | paddr | Physical address of the module. +* 8 +----------------+ +* | size | Size of the module in bytes. +* 16 +----------------+ +* | cmdline_paddr | Physical address of the command line, +* | | a zero-terminated ASCII string. +* 24 +----------------+ +* | reserved | +* 32 +----------------+ +* +* The address and sizes are always a 64bit little endian unsigned integer. +* +* NB: Xen on x86 will always try to place all the data below the 4GiB +* boundary. +*/ +#define XEN_HVM_START_MAGIC_VALUE 0x336ec578 + +/* +* C representation of the x86/HVM start info layout. +* +* The canonical definition of this layout is above, this is just a way to +* represent the layout described there using C types. +*/ +struct hvm_start_info { +uint32_t magic;/* Contains the magic value 0x336ec578 */ +/* ("xEn3" with the 0x80 bit of the "E" set).*/ +uint32_t version;/* Version of this structure. */ +uint32_t flags;/* SIF_xxx flags. */ +uint32_t nr_modules;/* Number of modules passed to the kernel. */ +uint64_t modlist_paddr;/* Physical address of an array of */ +/* hvm_modlist_entry. */ +uint64_t cmdline_paddr;/* Physical address of the command line. */ +uint64_t rsdp_paddr;/* Physical address of the RSDP ACPI data */ +/* structure. */ +}; + +struct hvm_modlist_entry { +uint64_t paddr;/* Physical address of the module. */ +uint64_t size;/* Size of the module in bytes. */ +uint64_t cmdline_paddr;/* Physical address of the command line. */ +uint64_t reserved; +}; + +#endif /* __XEN_PUBLIC_ARCH_X86_HVM_START_INFO_H__ */ include/xen/elfnote.h +11
-1@@ -200,9 +200,19 @@#define XEN_ELFNOTE_SUPPORTED_FEATURES 17/* +* Physical entry point into the kernel. +* +* 32bit entry point into the kernel. When requested to launch the +* guest kernel in a HVM container, Xen will use this entry point to +* launch the guest in 32bit protected mode with paging disabled. +* Ignored otherwise. +*/ +#define XEN_ELFNOTE_PHYS32_ENTRY 18 + +/* * The number of the highest elfnote defined. */ -#define XEN_ELFNOTE_MAX XEN_ELFNOTE_SUPPORTED_FEATURES +#define XEN_ELFNOTE_MAX XEN_ELFNOTE_PHYS32_ENTRY/* * System information exported through crash notes. Signature · 1 line
2.6.6
Signature · 1 line
Samuel
Quoted 2 lines
[Linux] c'est une philosophie un art de vivre, un état intérieur, une sorte de fluide qui nous entoure et nous pénètre.
Fais tourner stp !
-+- Guillaume in Guide du linuxien pervers - "Tous drogués j'vous dis !"
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Juergen Gross
maintainerPATCH 2/22 mini-os: make dump_regs() work in early boot
In reply to Juergen Grossdump_regs() will result in page fault in early boot as there is no current thread pointer. Handle this case.
--- arch/x86/traps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/traps.c +1 -1
@@ -32,7 +32,7 @@ void machine_check(void);void dump_regs (struct pt_regs *regs) { -printk ("Thread: %s\n" , current->name); +printk ("Thread: %s\n" , current ? current->name :"*NONE*" );#ifdef __i386__printk ("EIP: %lx, EFLAGS %lx.\n" , regs->eip, regs->eflags); printk("EBX: %08lx ECX: %08lx EDX: %08lx\n",
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 02/22] mini-os: make dump_regs() work in early boot
Quoted 4 lines · Juergen Gross, on Tue 23 Aug 2016 17:15:48 +0200, wrote:
dump_regs()will result in page fault in early boot as there is no current thread pointer. Handle this case.Signed-off-by Juergen Gross <[email protected]>
Quoted 20 lines
--- arch/x86/traps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/x86/traps.c +1
-1@@ -32,7 +32,7 @@ void machine_check(void);void dump_regs (struct pt_regs *regs) { -printk ("Thread: %s\n" , current->name); +printk ("Thread: %s\n" , current ? current->name :"*NONE*" );#ifdef __i386__printk ("EIP: %lx, EFLAGS %lx.\n" , regs->eip, regs->eflags); printk("EBX: %08lx ECX: %08lx EDX: %08lx\n",Signature · 1 line
2.6.6
Signature · 1 line
Samuel
Quoted 2 lines
Subject: pb fvwm95-2 comment l'installer le compiler??? Merci d'avance
je te conseille d'être un peu plus précis dans l'exposé de ton pb... -+- EJ in guide du linuxien pervers :"Les modéros sont sympas !" -+-
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Juergen Gross
maintainerPATCH 3/22 mini-os: add CONFIG_PARAVIRT
In reply to Juergen GrossAdd a new config macro CONFIG_PARAVIRT which defaults to be defined on x86. This is the first step for supporting a HVMlite Mini-OS.
Doing this via CONFIG_PARAVIRT instead of something like CONFIG_HVMLITE was chosen as the arm port can then drop some dummy routines needed for para-virtualization only.
Add include/paravirt.h for furute support of paravirt specific handling.
--- Config.mk | 6 ++++++ include/paravirt.h | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 include/paravirt.h
Config.mk +6 -0
@@ -153,6 +153,11 @@ LDFLAGS-$(clang) += -plugin LLVMgold.so endif # Configuration defaults +ifeq ($(TARGET_ARCH_FAM),x86) +CONFIG_PARAVIRT ?= y +else +CONFIG_PARAVIRT ?= n +endif CONFIG_START_NETWORK ?= y CONFIG_SPARSE_BSS ?= y CONFIG_QEMU_XS_ARGS ?= n
@@ -172,6 +177,7 @@ CONFIG_LWIP ?= $(lwip) CONFIG_BALLOON ?= n # Export config items as compiler directives +DEFINES-$(CONFIG_PARAVIRT) += -DCONFIG_PARAVIRT DEFINES-$(CONFIG_START_NETWORK) += -DCONFIG_START_NETWORK DEFINES-$(CONFIG_SPARSE_BSS) += -DCONFIG_SPARSE_BSS DEFINES-$(CONFIG_QEMU_XS_ARGS) += -DCONFIG_QEMU_XS_ARGS
include/paravirt.h new file +33 -0
@@ -0,0 +1,33 @@ +/* -*- 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 _PARAVIRT_H +#define _PARAVIRT_H + +#if defined(CONFIG_PARAVIRT ) + +#else + +#endif + +#endif /* _PARAVIRT_H */
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 03/22] mini-os: add CONFIG_PARAVIRT
Quoted 9 lines · Juergen Gross, on Tue 23 Aug 2016 17:15:49 +0200, wrote:
Add a new config macro
CONFIG_PARAVIRTwhich defaults to be defined on x86. This is the first step for supporting a HVMlite Mini-OS.Doing this via
CONFIG_PARAVIRTinstead of something likeCONFIG_HVMLITEwas chosen as the arm port can then drop some dummy routines needed for para-virtualization only.Add
include/paravirt.hfor furute support of paravirt specific handling.
future*
Quoted 1 line
Signed-off-by Juergen Gross <[email protected]>
Quoted 72 lines
--- Config.mk | 6 ++++++ include/paravirt.h | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 include/paravirt.hConfig.mk +6
-0@@ -153,6 +153,11 @@ LDFLAGS-$(clang) += -plugin LLVMgold.so endif # Configuration defaults +ifeq ($(TARGET_ARCH_FAM),x86) +CONFIG_PARAVIRT ?= y +else +CONFIG_PARAVIRT ?= n +endif CONFIG_START_NETWORK ?= y CONFIG_SPARSE_BSS ?= y CONFIG_QEMU_XS_ARGS ?= n@@ -172,6 +177,7 @@ CONFIG_LWIP ?= $(lwip) CONFIG_BALLOON ?= n # Export config items as compiler directives +DEFINES-$(CONFIG_PARAVIRT) += -DCONFIG_PARAVIRT DEFINES-$(CONFIG_START_NETWORK) += -DCONFIG_START_NETWORK DEFINES-$(CONFIG_SPARSE_BSS) += -DCONFIG_SPARSE_BSS DEFINES-$(CONFIG_QEMU_XS_ARGS) += -DCONFIG_QEMU_XS_ARGSinclude/paravirt.h new file +33
-0@@ -0,0 +1,33 @@ +/* -*- 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 _PARAVIRT_H +#define _PARAVIRT_H + +#if defined(CONFIG_PARAVIRT ) + +#else + +#endif + +#endif /* _PARAVIRT_H */ Signature · 1 line
2.6.6
Signature · 9 lines
Samuel Pour un père, autant mourir que de faire plein de calculs et pas s'occuper de son fils -+- y sur #ens-mim - sombres histoires de zombies -+- _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Juergen Gross
maintainerPATCH 4/22 mini-os: make some memory management related macros usable from assembler
In reply to Juergen GrossEspecially page table entry definitions are currently not usable from assembler sources on x86 as the constants are defined with ULL suffix. Change this by adding the suffix only when the header is included from a C source.
Hide some C prototypes when in assembler environment.
--- include/x86/arch_mm.h | 56 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 22 deletions(-)
include/x86/arch_mm.h +34 -22
@@ -29,11 +29,16 @@#include <xen/xen.h> #if defined(__i386__)#include <xen/arch-x86_32.h> +#define __CONST (x) x ## ULL#elif defined(__x86_64__)#include <xen/arch-x86_64.h> +#define __CONST (x) x ## UL#else #error "Unsupported architecture"#endif +#define CONST (x) __CONST(x) +#else +#define CONST (x) x#endif /*
@@ -81,14 +86,16 @@#define PRIpte "016llx"#ifndef __ASSEMBLY__typedef uint64_t pgentry_t ; +#else +#define PTE (val) .long val; .long 0#endif -#define MAX_MEM_SIZE 0x3f000000UL -#define VIRT_KERNEL_AREA 0x3f000000UL -#define VIRT_DEMAND_AREA 0x40000000UL -#define VIRT_HEAP_AREA 0xb0000000UL +#define MAX_MEM_SIZE CONST(0x3f000000) +#define VIRT_KERNEL_AREA CONST(0x3f000000) +#define VIRT_DEMAND_AREA CONST(0x40000000) +#define VIRT_HEAP_AREA CONST(0xb0000000) -#define DEMAND_MAP_PAGES 0x6ffffUL +#define DEMAND_MAP_PAGES CONST(0x6ffff)#define HEAP_PAGES_MAX ((HYPERVISOR_VIRT_START - VIRT_HEAP_AREA) / \ PAGE_SIZE - 1)
@@ -115,15 +122,17 @@ typedef uint64_t pgentry_t;#define PRIpte "016lx"#ifndef __ASSEMBLY__typedef unsigned long pgentry_t ; +#else +#define PTE (val) .quad val#endif -#define MAX_MEM_SIZE (512ULL << 30) -#define VIRT_KERNEL_AREA 0x0000008000000000UL -#define VIRT_DEMAND_AREA 0x0000100000000000UL -#define VIRT_HEAP_AREA 0x0000200000000000UL +#define MAX_MEM_SIZE (CONST(512) << 30) +#define VIRT_KERNEL_AREA CONST(0x0000008000000000) +#define VIRT_DEMAND_AREA CONST(0x0000100000000000) +#define VIRT_HEAP_AREA CONST(0x0000200000000000) -#define DEMAND_MAP_PAGES 0x8000000UL -#define HEAP_PAGES_MAX 0x8000000UL +#define DEMAND_MAP_PAGES CONST(0x8000000) +#define HEAP_PAGES_MAX CONST(0x8000000)#endif
@@ -147,16 +156,16 @@ typedef unsigned long pgentry_t; (((_a) >> L4_PAGETABLE_SHIFT) & (L4_PAGETABLE_ENTRIES - 1))#endif -#define _PAGE_PRESENT 0x001ULL -#define _PAGE_RW 0x002ULL -#define _PAGE_USER 0x004ULL -#define _PAGE_PWT 0x008ULL -#define _PAGE_PCD 0x010ULL -#define _PAGE_ACCESSED 0x020ULL -#define _PAGE_DIRTY 0x040ULL -#define _PAGE_PAT 0x080ULL -#define _PAGE_PSE 0x080ULL -#define _PAGE_GLOBAL 0x100ULL +#define _PAGE_PRESENT CONST(0x001) +#define _PAGE_RW CONST(0x002) +#define _PAGE_USER CONST(0x004) +#define _PAGE_PWT CONST(0x008) +#define _PAGE_PCD CONST(0x010) +#define _PAGE_ACCESSED CONST(0x020) +#define _PAGE_DIRTY CONST(0x040) +#define _PAGE_PAT CONST(0x080) +#define _PAGE_PSE CONST(0x080) +#define _PAGE_GLOBAL CONST(0x100)#if defined(__i386__)#define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED)
@@ -191,12 +200,14 @@ typedef unsigned long pgentry_t;#define L3_P2M_IDX (pfn) (((pfn) >> L2_P2M_SHIFT) & P2M_MASK)#define INVALID_P2M_ENTRY (~0UL) +#ifndef __ASSEMBLY__void p2m_chk_pfn (unsigned long pfn);static inline unsigned long p2m_pages (unsigned long pages) {return (pages +P2M_ENTRIES -1 ) >>L1_P2M_SHIFT ; } +#endif #include "arch_limits.h" #define PAGE_SIZE __PAGE_SIZE
@@ -239,7 +250,6 @@ static __inline__ paddr_t machine_to_phys(maddr_t machine) phys = (phys <<PAGE_SHIFT ) | (machine & ~PAGE_MASK );return phys; } -#endif #define VIRT_START ((unsigned long)&_text)
@@ -288,4 +298,6 @@ static __inline__ paddr_t machine_to_phys(maddr_t machine)pgentry_t *need_pgt (unsigned long addr); +#endif +#endif /* _ARCH_MM_H_ */
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 04/22] mini-os: make some memory management related macros usable from assembler
Quoted 8 lines · Juergen Gross, on Tue 23 Aug 2016 17:15:50 +0200, wrote:
Especially page table entry definitions are currently not usable from assembler sources on x86 as the constants are defined with ULL suffix. Change this by adding the suffix only when the header is included from a C source.
Hide some C prototypes when in assembler environment.
Signed-off-by Juergen Gross <[email protected]>
Quoted 131 lines
--- include/x86/arch_mm.h | 56 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 22 deletions(-)include/x86/arch_mm.h +34
-22@@ -29,11 +29,16 @@#include <xen/xen.h> #if defined(__i386__)#include <xen/arch-x86_32.h> +#define __CONST (x) x ## ULL#elif defined(__x86_64__)#include <xen/arch-x86_64.h> +#define __CONST (x) x ## UL#else #error "Unsupported architecture"#endif +#define CONST (x) __CONST(x) +#else +#define CONST (x) x#endif /* @@ -81,14 +86,16 @@#define PRIpte "016llx"#ifndef __ASSEMBLY__typedef uint64_t pgentry_t ; +#else +#define PTE (val) .long val; .long 0#endif -#define MAX_MEM_SIZE 0x3f000000UL -#define VIRT_KERNEL_AREA 0x3f000000UL -#define VIRT_DEMAND_AREA 0x40000000UL -#define VIRT_HEAP_AREA 0xb0000000UL +#define MAX_MEM_SIZE CONST(0x3f000000) +#define VIRT_KERNEL_AREA CONST(0x3f000000) +#define VIRT_DEMAND_AREA CONST(0x40000000) +#define VIRT_HEAP_AREA CONST(0xb0000000) -#define DEMAND_MAP_PAGES 0x6ffffUL +#define DEMAND_MAP_PAGES CONST(0x6ffff)#define HEAP_PAGES_MAX ((HYPERVISOR_VIRT_START - VIRT_HEAP_AREA) / \ PAGE_SIZE - 1)@@ -115,15 +122,17 @@ typedef uint64_t pgentry_t;#define PRIpte "016lx"#ifndef __ASSEMBLY__typedef unsigned long pgentry_t ; +#else +#define PTE (val) .quad val#endif -#define MAX_MEM_SIZE (512ULL << 30) -#define VIRT_KERNEL_AREA 0x0000008000000000UL -#define VIRT_DEMAND_AREA 0x0000100000000000UL -#define VIRT_HEAP_AREA 0x0000200000000000UL +#define MAX_MEM_SIZE (CONST(512) << 30) +#define VIRT_KERNEL_AREA CONST(0x0000008000000000) +#define VIRT_DEMAND_AREA CONST(0x0000100000000000) +#define VIRT_HEAP_AREA CONST(0x0000200000000000) -#define DEMAND_MAP_PAGES 0x8000000UL -#define HEAP_PAGES_MAX 0x8000000UL +#define DEMAND_MAP_PAGES CONST(0x8000000) +#define HEAP_PAGES_MAX CONST(0x8000000)#endif @@ -147,16 +156,16 @@ typedef unsigned long pgentry_t; (((_a) >> L4_PAGETABLE_SHIFT) & (L4_PAGETABLE_ENTRIES - 1))#endif -#define _PAGE_PRESENT 0x001ULL -#define _PAGE_RW 0x002ULL -#define _PAGE_USER 0x004ULL -#define _PAGE_PWT 0x008ULL -#define _PAGE_PCD 0x010ULL -#define _PAGE_ACCESSED 0x020ULL -#define _PAGE_DIRTY 0x040ULL -#define _PAGE_PAT 0x080ULL -#define _PAGE_PSE 0x080ULL -#define _PAGE_GLOBAL 0x100ULL +#define _PAGE_PRESENT CONST(0x001) +#define _PAGE_RW CONST(0x002) +#define _PAGE_USER CONST(0x004) +#define _PAGE_PWT CONST(0x008) +#define _PAGE_PCD CONST(0x010) +#define _PAGE_ACCESSED CONST(0x020) +#define _PAGE_DIRTY CONST(0x040) +#define _PAGE_PAT CONST(0x080) +#define _PAGE_PSE CONST(0x080) +#define _PAGE_GLOBAL CONST(0x100)#if defined(__i386__)#define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED)@@ -191,12 +200,14 @@ typedef unsigned long pgentry_t;#define L3_P2M_IDX (pfn) (((pfn) >> L2_P2M_SHIFT) & P2M_MASK)#define INVALID_P2M_ENTRY (~0UL) +#ifndef __ASSEMBLY__void p2m_chk_pfn (unsigned long pfn);static inline unsigned long p2m_pages (unsigned long pages) {return (pages +P2M_ENTRIES -1 ) >>L1_P2M_SHIFT ; } +#endif #include "arch_limits.h" #define PAGE_SIZE __PAGE_SIZE@@ -239,7 +250,6 @@ static __inline__ paddr_t machine_to_phys(maddr_t machine) phys = (phys <<PAGE_SHIFT ) | (machine & ~PAGE_MASK );return phys; } -#endif #define VIRT_START ((unsigned long)&_text)@@ -288,4 +298,6 @@ static __inline__ paddr_t machine_to_phys(maddr_t machine)pgentry_t *need_pgt (unsigned long addr); +#endif +#endif /* _ARCH_MM_H_ */ Signature · 1 line
2.6.6
Signature · 8 lines
Samuel I am the "ILOVEGNU" signature virus. Just copy me to your signature. This email was infected under the terms of the GNU General Public License. _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Juergen Gross
maintainerPATCH 5/22 mini-os: add boot code for HVMlite support
In reply to Juergen GrossA HVMlite domain is always starting in 32 bit mode. Add the appropriate boot code to arch/x86 for the non-paravirtualized case.
For this boot code to become active we need to suppress the pv related elfnotes and add an appropriate elfnote for HVMlite.
As the HVMlite boot code is more or less the same for 32- and 64-bit Mini-OS #include the new code from x86_[32|64].S in order to avoid error prone code duplication. The specific parts of 32- or 64-bit code are added to x86_[32|64].S
This enables Mini-OS to start the boot process in HVMlite mode until it enters C code. This is working for 32- and for 64-bit mode.
--- Makefile | 2 +- arch/x86/arch.mk | 4 + arch/x86/mm.c | 31 +++++ arch/x86/setup.c | 4 +- arch/x86/x86_32.S | 31 ++++- arch/x86/x86_64.S | 35 ++++- arch/x86/x86_hvm.S | 77 +++++++++++ include/compiler.h | 1 + include/x86/desc.h | 366 +++++++++++++++++++++++++++++++++++++++++++++++++++++ include/x86/os.h | 5 + minios.mk | 2 +- 11 files changed, 544 insertions(+), 14 deletions(-) create mode 100644 arch/x86/x86_hvm.S create mode 100644 include/x86/desc.h
Makefile +1 -1
@@ -24,7 +24,7 @@ include minios.mk LDLIBS := APP_LDLIBS := LDARCHLIB := -L$(OBJ_DIR)/$(TARGET_ARCH_DIR) -l$(ARCH_LIB_NAME) -LDFLAGS_FINAL := -T $(TARGET_ARCH_DIR)/minios-$(MINIOS_TARGET_ARCH).lds +LDFLAGS_FINAL := -T $(TARGET_ARCH_DIR)/minios-$(MINIOS_TARGET_ARCH).lds $(ARCH_LDFLAGS_FINAL) # Prefix for global API names. All other symbols are localised before # linking with EXTRA_OBJS.
arch/x86/arch.mk +4 -0
@@ -20,3 +20,7 @@ EXTRA_INC += $(TARGET_ARCH_FAM)/$(MINIOS_TARGET_ARCH) EXTRA_SRC += arch/$(EXTRA_INC) endif +ifeq ($(CONFIG_PARAVIRT),n) +ARCH_LDFLAGS_FINAL := --oformat=elf32-i386 +ARCH_AS_DEPS += x86_hvm.S +endif
arch/x86/mm.c +31 -0
@@ -56,6 +56,37 @@ unsigned long mfn_zero;extern char stack[];extern void page_walk (unsigned long va); +#ifndef CONFIG_PARAVIRT +#include <mini-os/desc.h> +user_desc gdt[NR_GDT_ENTRIES ] = +{ + [GDTE_CS64_DPL0 ] =INIT_GDTE_SYM (0 ,0xfffff ,COMMON ,CODE ,DPL0 ,R ,L ), + [GDTE_CS32_DPL0 ] =INIT_GDTE_SYM (0 ,0xfffff ,COMMON ,CODE ,DPL0 ,R ,D ), + [GDTE_DS32_DPL0 ] =INIT_GDTE_SYM (0 ,0xfffff ,COMMON ,DATA ,DPL0 ,B ,W ), + + [GDTE_CS64_DPL3 ] =INIT_GDTE_SYM (0 ,0xfffff ,COMMON ,CODE ,DPL3 ,R ,L ), + [GDTE_CS32_DPL3 ] =INIT_GDTE_SYM (0 ,0xfffff ,COMMON ,CODE ,DPL3 ,R ,D ), + [GDTE_DS32_DPL3 ] =INIT_GDTE_SYM (0 ,0xfffff ,COMMON ,DATA ,DPL3 ,B ,W ), + +/* [GDTE_TSS] */ +/* [GDTE_TSS + 1] */ +}; + +desc_ptr gdt_ptr = +{ + .limit =sizeof (gdt) -1 , + .base = (unsigned long )&gdt, +}; + +gate_desc idt[256 ] = { }; + +desc_ptr idt_ptr = +{ + .limit =sizeof (idt) -1 , + .base = (unsigned long )&idt, +}; +#endif +/* * Make pt_pfn a new 'level' page table frame and hook it into the page * table at offset in previous level MFN (pref_l_mfn). pt_pfn is a guest
arch/x86/setup.c +3 -1
@@ -94,9 +94,10 @@ static inline void sse_init(void) {* INITIAL C ENTRY POINT. */ void -arch_init (start_info_t *si) +arch_init (void *par) {static char hello[] ="Bootstrapping...\n" ; +start_info_t *si; (void )HYPERVISOR_console_io (CONSOLEIO_write,strlen (hello), hello);
@@ -111,6 +112,7 @@ arch_init(start_info_t *si)/* Copy the start_info struct to a globally-accessible area. */ /* WARN: don't do printk before here, it uses information from shared_info. Use xprintk instead. */ + si = par;memcpy (&start_info, si,sizeof (*si));/* print out some useful information */
arch/x86/x86_32.S +26 -5
@@ -1,20 +1,31 @@ #include <mini-os/os.h> #include <mini-os/x86/arch_limits.h> #include <mini-os/asm_macros.h> +#include <mini-os/arch_mm.h> +#include <mini-os/desc.h> +#include <xen/arch-x86_32.h> #include <xen/elfnote.h> #include <xen/arch-x86_32.h> +#ifdef CONFIG_PARAVIRT ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS, .asciz "Mini-OS") ELFNOTE(Xen, XEN_ELFNOTE_LOADER, .asciz "generic") ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, _WORD hypercall_page) ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION, .asciz "xen-3.0") ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE, .asciz "yes") +.text -.globl _start, shared_info, hypercall_page +.globl _start _start: - cld lss stack_start,%esp +#else + +#include "x86_hvm.S" + movl stack_start,%esp + +#endif + cld andl $(~(__STACK_SIZE-1)), %esp push %esi call arch_init
@@ -22,14 +33,15 @@ _start: stack_start: .long stack+(2*__STACK_SIZE), __KERNEL_SS +.globl shared_info, hypercall_page /* Unpleasant -- the PTE that maps this page is actually overwritten */ /* to map the real shared-info page! :-) */ - .org 0x1000 + .align __PAGE_SIZE shared_info: - .org 0x2000 + .fill __PAGE_SIZE,1,0 hypercall_page: - .org 0x3000 + .fill __PAGE_SIZE,1,0 ES = 0x20 ORIG_EAX = 0x24
@@ -300,3 +312,12 @@ ENTRY(__arch_switch_threads) popl %ebx popl %ebp ret + +#ifndef CONFIG_PARAVIRT +.data +.globl page_table_base + .align __PAGE_SIZE +page_table_base: + PTE(page_table_l2 + L3_PROT) + .align __PAGE_SIZE, 0 +#endif
arch/x86/x86_64.S +29 -6
@@ -1,19 +1,29 @@ #include <mini-os/os.h> #include <mini-os/x86/arch_limits.h> #include <mini-os/asm_macros.h> +#include <mini-os/arch_mm.h> +#include <mini-os/desc.h> +#include <xen/features.h> #include <xen/elfnote.h> #include <xen/features.h> +#define ENTRY(X) .globl X ; X : + +#ifdef CONFIG_PARAVIRT ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS, .asciz "Mini-OS") ELFNOTE(Xen, XEN_ELFNOTE_LOADER, .asciz "generic") ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, _WORD hypercall_page) ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION, .asciz "xen-3.0") +.text -#define ENTRY(X) .globl X ; X : -.globl _start, shared_info, hypercall_page - +.globl _start _start: +#else + +#include "x86_hvm.S" + +#endif cld movq stack_start(%rip),%rsp andq $(~(__STACK_SIZE-1)), %rsp
@@ -23,14 +33,15 @@ _start: stack_start: .quad stack+(2*__STACK_SIZE) +.globl shared_info, hypercall_page /* Unpleasant -- the PTE that maps this page is actually overwritten */ /* to map the real shared-info page! :-) */ - .org 0x1000 + .align __PAGE_SIZE shared_info: - .org 0x2000 + .fill __PAGE_SIZE,1,0 hypercall_page: - .org 0x3000 + .fill __PAGE_SIZE,1,0 #define XEN_GET_VCPU_INFO(reg) movq HYPERVISOR_shared_info,reg
@@ -378,3 +389,15 @@ ENTRY(__arch_switch_threads) popq %rbx popq %rbp ret + +#ifndef CONFIG_PARAVIRT +.data +.globl page_table_base + .align __PAGE_SIZE +page_table_l3: + PTE(page_table_l2 + L3_PROT) + .align __PAGE_SIZE, 0 +page_table_base: + PTE(page_table_l3 + L4_PROT) + .align __PAGE_SIZE, 0 +#endif
arch/x86/x86_hvm.S new file +77 -0
77 lines not on this page · raw message
include/compiler.h +1 -0
@@ -6,5 +6,6 @@#endif #define unlikely (x) __builtin_expect(!!(x),0)#define likely (x) __builtin_expect(!!(x),1) +#define __packed __attribute__((__packed__))#endif /* __MINIOS_COMPILER_H_ */
include/x86/desc.h new file +366 -0
366 lines not on this page · raw message
include/x86/os.h +5 -0
@@ -24,7 +24,12 @@#endif #include <xen/xen.h> +#define MSR_EFER 0xc0000080 +#define _EFER_LME 8/* Long mode enable */ +#define X86_CR0_PG 0x80000000/* Paging */ +#define X86_CR4_PAE 0x00000020/* enable physical address extensions */ +#define X86_CR4_OSFXSR 0x00000200/* enable fast FPU save and restore */ #define __KERNEL_CS FLAT_KERNEL_CS#define __KERNEL_DS FLAT_KERNEL_DS
minios.mk +1 -1
@@ -68,7 +68,7 @@ HEAD_OBJ := $(OBJ_DIR)/$(TARGET_ARCH_DIR)/$(HEAD_ARCH_OBJ) $(OBJ_DIR)/%.o: %.c $(HDRS) Makefile $(EXTRA_DEPS) $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ -$(OBJ_DIR)/%.o: %.S $(HDRS) Makefile $(EXTRA_DEPS) +$(OBJ_DIR)/%.o: %.S $(HDRS) Makefile $(EXTRA_DEPS) $(ARCH_AS_DEPS) $(CC) $(ASFLAGS) $(CPPFLAGS) -c $< -o $@
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 05/22] mini-os: add boot code for HVMlite support
Hello,
It looks good, there is just:
Quoted 1 line · Juergen Gross, on Tue 23 Aug 2016 17:15:51 +0200, wrote:
+ .macro PTES prot, addr, incr, idx, end
Please document what prot, addr, incr, idx, end represent precisely.
Quoted 17 lines
arch/x86/x86_hvm.S new file +10
-0+ .ifgt \end-\idx-32 + PTES \prot, \addr, \incr, \idx, "(\idx+32)" + PTES \prot, "(\addr+32*\incr)", \incr, "(\idx+32)", \end + .else + PTE(\addr + \prot) + .if \end-\idx-1 + PTES \prot, "(\addr+\incr)", \incr, "(\idx+1)", \end + .endif + .endif + .endminclude/x86/desc.h new file +0
-0
include/x86/desc.h line 3
Quoted 3 lines
include/x86/desc.h new file +3
-0@@ -0,0 +1,366 @@ +/* -*- Mode:C; c-basic-offset:4; tab-width:4 -*- +* +* (C) 2016 - Juergen Gross, SUSE Linux GmbH
Was this whole file imported from somewhere, or written from scratch?
Samuel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Juergen Gross
maintainerRe: [PATCH 05/22] mini-os: add boot code for HVMlite support
Quoted 8 lines · Samuel Thibault
Hello,
It looks good, there is just:
Quoted 1 line · Juergen Gross, on Tue 23 Aug 2016 17:15:51 +0200, wrote:
+ .macro PTES prot, addr, incr, idx, end
Please document what prot, addr, incr, idx, end represent precisely.
Okay.
Quoted 12 lines
Quoted 11 lines
arch/x86/x86_hvm.S new file +10
-0+ .ifgt \end-\idx-32 + PTES \prot, \addr, \incr, \idx, "(\idx+32)" + PTES \prot, "(\addr+32*\incr)", \incr, "(\idx+32)", \end + .else + PTE(\addr + \prot) + .if \end-\idx-1 + PTES \prot, "(\addr+\incr)", \incr, "(\idx+1)", \end + .endif + .endif + .endm
Quoted 11 lines
include/x86/desc.h line 3
Quoted 9 lines
include/x86/desc.h new file +3
-0@@ -0,0 +1,366 @@ +/* -*- Mode:C; c-basic-offset:4; tab-width:4 -*- +* +* (C) 2016 - Juergen Gross, SUSE Linux GmbH Was this whole file imported from somewhere, or written from scratch?
It is a modified variant of a similar file in:
http://xenbits.xen.org/gitweb/?p=people/andrewcoop/xen-test-framework.git
I'll add a comment telling so.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Juergen Gross
maintainerPATCH 6/22 mini-os: setup hypercall page for HVMlite
In reply to Juergen GrossWhen running in HVMlite mode we need to setup the hypercall page by ourself.
--- arch/x86/events.c | 4 ++-- arch/x86/setup.c | 26 ++++++++++++++++++++++++++ include/x86/os.h | 22 +++++++++++++++++----- 3 files changed, 45 insertions(+), 7 deletions(-)
arch/x86/events.c +2 -2
@@ -16,7 +16,7 @@ void arch_init_events(void) {#if defined(__x86_64__) asmvolatile ("movl %0,%%fs ; movl %0,%%gs" ::"r" (0 )); -wrmsrl (0xc0000101 , &cpu0_pda);/* 0xc0000101 is MSR_GS_BASE */ +wrmsrl (0xc0000101 , (uint64_t )&cpu0_pda);/* 0xc0000101 is MSR_GS_BASE */ cpu0_pda.irqcount =-1 ; cpu0_pda.irqstackptr = (void *) (((unsigned long )irqstack +2 *STACK_SIZE ) & ~(STACK_SIZE -1 ));
@@ -30,6 +30,6 @@ void arch_unbind_ports(void)void arch_fini_events (void ) {#if defined(__x86_64__) -wrmsrl (0xc0000101 ,NULL );/* 0xc0000101 is MSR_GS_BASE */ +wrmsrl (0xc0000101 ,0 );/* 0xc0000101 is MSR_GS_BASE */ #endif }
arch/x86/setup.c +26 -0
@@ -30,6 +30,7 @@#include <mini-os/lib.h> /* for printk, memcpy */ #include <mini-os/kernel.h> #include <xen/xen.h> +#include <xen/arch-x86/cpuid.h> /* * Shared page for communicating with the hypervisor.
@@ -89,6 +90,30 @@ static inline void sse_init(void) {#define sse_init ()#endif +#ifdef CONFIG_PARAVIRT +#define hpc_init () +#else +static void hpc_init (void ) +{ +uint32_t eax, ebx, ecx, edx, base; + +for ( base =XEN_CPUID_FIRST_LEAF ; + base <XEN_CPUID_FIRST_LEAF +0x10000 ; base +=0x100 ) + { +cpuid (base, &eax, &ebx, &ecx, &edx); + +if ( (ebx ==XEN_CPUID_SIGNATURE_EBX ) && + (ecx ==XEN_CPUID_SIGNATURE_ECX ) && + (edx ==XEN_CPUID_SIGNATURE_EDX ) && + ((eax - base) >=2 ) ) +break ; + } + +cpuid (base +2 , &eax, &ebx, &ecx, &edx); +wrmsrl (ebx, (unsigned long )&hypercall_page); +barrier (); +} +#endif /* * INITIAL C ENTRY POINT.
@@ -99,6 +124,7 @@ arch_init(void *par)static char hello[] ="Bootstrapping...\n" ;start_info_t *si; +hpc_init (); (void )HYPERVISOR_console_io (CONSOLEIO_write,strlen (hello), hello);trap_init ();
include/x86/os.h +17 -5
@@ -440,17 +440,20 @@ static __inline__ unsigned long __ffs(unsigned long word) (val) = ((unsigned long )__a) | (((unsigned long )__d)<<32 ); \ } while(0) +#else /* ifdef __x86_64__ */ +#error "Unsupported architecture" +#endif + #define wrmsr(msr,val1,val2) \ __asm__ __volatile__("wrmsr" \ : /* no outputs */ \ : "c" (msr), "a" (val1), "d" (val2)) -#define wrmsrl (msr,val) wrmsr(msr,(uint32_t)((uint64_t)(val)),((uint64_t)(val))>>32) +static inline void wrmsrl (unsigned msr,uint64_t val) +{ +wrmsr (msr, (uint32_t )(val &0xffffffffULL ), (uint32_t )(val >>32 )); +} - -#else /* ifdef __x86_64__ */ -#error "Unsupported architecture" -#endif #endif /* ifdef __INSIDE_MINIOS */ /********************* common i386 and x86_64 ****************************/
@@ -571,6 +574,15 @@ HYPERVISOR_xsm_op( return _hypercall1(int, xsm_op, op); } +static inline void cpuid (uint32_t leaf, +uint32_t *eax,uint32_t *ebx, +uint32_t *ecx,uint32_t *edx) +{ + asmvolatile ("cpuid" + :"=a" (*eax),"=b" (*ebx),"=c" (*ecx),"=d" (*edx) + :"0" (leaf)); +} +#undef ADDR#endif /* not assembly */
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 06/22] mini-os: setup hypercall page for HVMlite
hello,
Quoted 16 lines · Juergen Gross, on Tue 23 Aug 2016 17:15:52 +0200, wrote:
When running in HVMlite mode we need to setup the hypercall page by ourself.
Signed-off-by Juergen Gross <[email protected]>---
include/x86/os.h +4
-1+#else /* ifdef __x86_64__ */ +#error "Unsupported architecture" +#endif + #define wrmsr(msr,val1,val2) \ __asm__ __volatile__("wrmsr" \ : /* no outputs */ \ : "c" (msr), "a" (val1), "d" (val2)) -#define wrmsrl (msr,val) wrmsr(msr,(uint32_t)((uint64_t)(val)),((uint64_t)(val))>>32)
include/x86/os.h static __inline__ unsigned long __ffs(unsigned long word) · line 457
Quoted 10 lines
include/x86/os.h +4
-4+static inline void wrmsrl (unsigned msr,uint64_t val) +{ +wrmsr (msr, (uint32_t )(val &0xffffffffULL ), (uint32_t )(val >>32 )); +} - -#else /* ifdef __x86_64__ */ -#error "Unsupported architecture" -#endif #endif /* ifdef __INSIDE_MINIOS */
Then please move it after
Quoted 1 line
/********************* common i386 and
x86_64****************************/
This line :)
Apart from that,
Samuel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Juergen Gross
maintainerRe: [PATCH 06/22] mini-os: setup hypercall page for HVMlite
Quoted 32 lines · Samuel Thibault
hello,
Quoted 16 lines · Juergen Gross, on Tue 23 Aug 2016 17:15:52 +0200, wrote:
When running in HVMlite mode we need to setup the hypercall page by ourself.
Signed-off-by Juergen Gross <[email protected]>---
include/x86/os.h +4
-1+#else /* ifdef __x86_64__ */ +#error "Unsupported architecture" +#endif + #define wrmsr(msr,val1,val2) \ __asm__ __volatile__("wrmsr" \ : /* no outputs */ \ : "c" (msr), "a" (val1), "d" (val2)) -#define wrmsrl (msr,val) wrmsr(msr,(uint32_t)((uint64_t)(val)),((uint64_t)(val))>>32)include/x86/os.h static __inline__ unsigned long __ffs(unsigned long word) · line 457
Quoted 10 lines
include/x86/os.h +4
-4+static inline void wrmsrl (unsigned msr,uint64_t val) +{ +wrmsr (msr, (uint32_t )(val &0xffffffffULL ), (uint32_t )(val >>32 )); +} - -#else /* ifdef __x86_64__ */ -#error "Unsupported architecture" -#endif #endif /* ifdef __INSIDE_MINIOS */ Then please move it after
Quoted 3 lines
Quoted 1 line
/********************* common i386 and
x86_64****************************/This line :)
Okay.
Quoted 4 lines
Apart from that,
Reviewed-by Samuel Thibault <[email protected]>
Thanks,
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Juergen Gross
maintainerPATCH 7/22 mini-os: support hvm_op hypercall
In reply to Juergen GrossSupport the HYPERVISOR_hvm_op() hypercall which is needed for HVMlite. Add convenience functions hvm_get_parameter() and hvm_set_parameter().
--- arch/arm/setup.c | 15 --------------- hypervisor.c | 27 +++++++++++++++++++++++++++ include/hypervisor.h | 5 +++++ include/x86/x86_32/hypercall-x86_32.h | 6 ++++++ include/x86/x86_64/hypercall-x86_64.h | 6 ++++++ 5 files changed, 44 insertions(+), 15 deletions(-)
arch/arm/setup.c +0 -15
@@ -25,21 +25,6 @@ extern char shared_info_page[PAGE_SIZE];void *device_tree; -static int hvm_get_parameter (int idx,uint64_t *value) -{ -struct xen_hvm_param xhv; -int ret; - - xhv.domid =DOMID_SELF ; - xhv.index = idx; - ret =HYPERVISOR_hvm_op (HVMOP_get_param, &xhv); -if (ret <0 ) { -BUG (); - } - *value = xhv.value; -return ret; -} -static void get_console (void ) {uint64_t v =-1 ;
hypervisor.c +27 -0
@@ -36,6 +36,33 @@int in_callback; +#ifndef CONFIG_PARAVIRT +int hvm_get_parameter (int idx,uint64_t *value) +{ +struct xen_hvm_param xhv; +int ret; + + xhv.domid =DOMID_SELF ; + xhv.index = idx; + ret =HYPERVISOR_hvm_op (HVMOP_get_param, &xhv); +if ( ret <0 ) +BUG (); + + *value = xhv.value; +return ret; +} + +int hvm_set_parameter (int idx,uint64_t value) +{ +struct xen_hvm_param xhv; + + xhv.domid =DOMID_SELF ; + xhv.index = idx; + xhv.value = value; +return HYPERVISOR_hvm_op (HVMOP_set_param, &xhv); +} +#endif +void do_hypervisor_callback (struct pt_regs *regs) {unsigned long l1, l2, l1i, l2i;
include/hypervisor.h +5 -0
@@ -23,6 +23,7 @@#else #error "Unsupported architecture"#endif +#include <xen/hvm/hvm_op.h> #include <mini-os/traps.h> /*
@@ -37,6 +38,10 @@ extern union start_info_union start_info_union;#define start_info (start_info_union.start_info)/* hypervisor.c */ +#ifndef CONFIG_PARAVIRT +int hvm_get_parameter (int idx,uint64_t *value); +int hvm_set_parameter (int idx,uint64_t value); +#endif void force_evtchn_callback (void );void do_hypervisor_callback (struct pt_regs *regs);void mask_evtchn (uint32_t port);
include/x86/x86_32/hypercall-x86_32.h +6 -0
@@ -324,6 +324,12 @@ HYPERVISOR_domctl(return _hypercall1 (int, domctl, op); } +static inline unsigned long +HYPERVISOR_hvm_op (int op,void *arg) +{ + return _hypercall2(unsigned long, hvm_op, op, arg); +} +#endif /* __HYPERCALL_X86_32_H__ */ /*
include/x86/x86_64/hypercall-x86_64.h +6 -0
@@ -331,6 +331,12 @@ HYPERVISOR_domctl(return _hypercall1 (int, domctl, op); } +static inline unsigned long +HYPERVISOR_hvm_op (int op,void *arg) +{ + return _hypercall2(unsigned long, hvm_op, op, arg); +} +#endif /* __HYPERCALL_X86_64_H__ */ /*
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 07/22] mini-os: support hvm_op hypercall
Quoted 4 lines · Juergen Gross, on Tue 23 Aug 2016 17:15:53 +0200, wrote:
Support the
HYPERVISOR_hvm_op()hypercall which is needed for HVMlite. Add convenience functionshvm_get_parameter()andhvm_set_parameter().Signed-off-by Juergen Gross <[email protected]>
Quoted 132 lines
--- arch/arm/setup.c | 15 --------------- hypervisor.c | 27 +++++++++++++++++++++++++++ include/hypervisor.h | 5 +++++ include/x86/x86_32/hypercall-x86_32.h | 6 ++++++ include/x86/x86_64/hypercall-x86_64.h | 6 ++++++ 5 files changed, 44 insertions(+), 15 deletions(-)arch/arm/setup.c +0
-15@@ -25,21 +25,6 @@ extern char shared_info_page[PAGE_SIZE];void *device_tree; -static int hvm_get_parameter (int idx,uint64_t *value) -{ -struct xen_hvm_param xhv; -int ret; - - xhv.domid =DOMID_SELF ; - xhv.index = idx; - ret =HYPERVISOR_hvm_op (HVMOP_get_param, &xhv); -if (ret <0 ) { -BUG (); - } - *value = xhv.value; -return ret; -} -static void get_console (void ) {uint64_t v =-1 ;hypervisor.c +27
-0@@ -36,6 +36,33 @@int in_callback; +#ifndef CONFIG_PARAVIRT +int hvm_get_parameter (int idx,uint64_t *value) +{ +struct xen_hvm_param xhv; +int ret; + + xhv.domid =DOMID_SELF ; + xhv.index = idx; + ret =HYPERVISOR_hvm_op (HVMOP_get_param, &xhv); +if ( ret <0 ) +BUG (); + + *value = xhv.value; +return ret; +} + +int hvm_set_parameter (int idx,uint64_t value) +{ +struct xen_hvm_param xhv; + + xhv.domid =DOMID_SELF ; + xhv.index = idx; + xhv.value = value; +return HYPERVISOR_hvm_op (HVMOP_set_param, &xhv); +} +#endif +void do_hypervisor_callback (struct pt_regs *regs) {unsigned long l1, l2, l1i, l2i;include/hypervisor.h +5
-0@@ -23,6 +23,7 @@#else #error "Unsupported architecture"#endif +#include <xen/hvm/hvm_op.h> #include <mini-os/traps.h> /* @@ -37,6 +38,10 @@ extern union start_info_union start_info_union;#define start_info (start_info_union.start_info)/* hypervisor.c */ +#ifndef CONFIG_PARAVIRT +int hvm_get_parameter (int idx,uint64_t *value); +int hvm_set_parameter (int idx,uint64_t value); +#endif void force_evtchn_callback (void );void do_hypervisor_callback (struct pt_regs *regs);void mask_evtchn (uint32_t port);include/x86/x86_32/hypercall-x86_32.h +6
-0@@ -324,6 +324,12 @@ HYPERVISOR_domctl(return _hypercall1 (int, domctl, op); } +static inline unsigned long +HYPERVISOR_hvm_op (int op,void *arg) +{ + return _hypercall2(unsigned long, hvm_op, op, arg); +} +#endif /* __HYPERCALL_X86_32_H__ */ /* include/x86/x86_64/hypercall-x86_64.h +6
-0@@ -331,6 +331,12 @@ HYPERVISOR_domctl(return _hypercall1 (int, domctl, op); } +static inline unsigned long +HYPERVISOR_hvm_op (int op,void *arg) +{ + return _hypercall2(unsigned long, hvm_op, op, arg); +} +#endif /* __HYPERCALL_X86_64_H__ */ /* Signature · 1 line
2.6.6
Signature · 10 lines
Samuel
«Le monochrome, c'est pour ceux qui s'intéressent (encore) au contenu.
Usenet dans ces conditions, c'est comme le web avec lynx, on prend
trop conscience du vide, c'est déprimant.»
-+- JLC in Guide du linuxien pervers : "Coup de cafard..." -+-
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-develJuergen Gross
maintainerPATCH 8/22 mini-os: initialize trap handling for HVMlite
In reply to Juergen GrossTrap handling for HVMlite domains requires an initialized IDT.
--- arch/x86/setup.c | 15 ---------- arch/x86/traps.c | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ arch/x86/x86_64.S | 4 +++ include/x86/os.h | 1 + 4 files changed, 93 insertions(+), 15 deletions(-)
arch/x86/setup.c +0 -15
@@ -52,10 +52,6 @@ char stack[2*STACK_SIZE];extern char shared_info[PAGE_SIZE ]; -/* Assembler interface fns in entry.S. */ -void hypervisor_callback (void ); -void failsafe_callback (void ); -#if defined(__x86_64__)#define __pte (x) ((pte_t) { (x) } )#else
@@ -162,17 +158,6 @@ arch_init(void *par)/* Grab the shared_info pointer and put it in a safe place. */ HYPERVISOR_shared_info =map_shared_info (start_info.shared_info); -/* Set up event and failsafe callback addresses. */ -#ifdef __i386__ -HYPERVISOR_set_callbacks ( - __KERNEL_CS, (unsigned long )hypervisor_callback, - __KERNEL_CS, (unsigned long )failsafe_callback); -#else -HYPERVISOR_set_callbacks ( - (unsigned long )hypervisor_callback, - (unsigned long )failsafe_callback,0 ); -#endif -start_kernel (); }
arch/x86/traps.c +88 -0
113 lines not on this page · raw message
arch/x86/x86_64.S +4 -0
@@ -130,18 +130,22 @@ KERNEL_CS_MASK = 0xfc .endm .macro HYPERVISOR_IRET flag +#ifdef CONFIG_PARAVIRT testl $NMI_MASK,2*8(%rsp) jnz 2f +#endif /* Direct iret to kernel space. Correct CS and SS. */ orb $3,1*8(%rsp) orb $3,4*8(%rsp) iretq +#ifdef CONFIG_PARAVIRT 2: /* Slow iret via hypervisor. */ andl $~NMI_MASK, 16(%rsp) pushq $\flag jmp hypercall_page + (__HYPERVISOR_iret * 32) +#endif .endm
include/x86/os.h +1 -0
@@ -56,6 +56,7 @@#define TRAP_machine_check 18#define TRAP_simd_error 19#define TRAP_deferred_nmi 31 +#define TRAP_xen_callback 32/* Everything below this point is not included by assembler (.S) files. */ #ifndef __ASSEMBLY__
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 08/22] mini-os: initialize trap handling for HVMlite
Quoted 3 lines · Juergen Gross, on Tue 23 Aug 2016 17:15:54 +0200, wrote:
Trap handling for HVMlite domains requires an initialized IDT.
Signed-off-by Juergen Gross <[email protected]>
Quoted 202 lines
--- arch/x86/setup.c | 15 ---------- arch/x86/traps.c | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ arch/x86/x86_64.S | 4 +++ include/x86/os.h | 1 + 4 files changed, 93 insertions(+), 15 deletions(-)arch/x86/setup.c +0
-15@@ -52,10 +52,6 @@ char stack[2*STACK_SIZE];extern char shared_info[PAGE_SIZE ]; -/* Assembler interface fns in entry.S. */ -void hypervisor_callback (void ); -void failsafe_callback (void ); -#if defined(__x86_64__)#define __pte (x) ((pte_t) { (x) } )#else @@ -162,17 +158,6 @@ arch_init(void *par)/* Grab the shared_info pointer and put it in a safe place. */ HYPERVISOR_shared_info =map_shared_info (start_info.shared_info); -/* Set up event and failsafe callback addresses. */ -#ifdef __i386__ -HYPERVISOR_set_callbacks ( - __KERNEL_CS, (unsigned long )hypervisor_callback, - __KERNEL_CS, (unsigned long )failsafe_callback); -#else -HYPERVISOR_set_callbacks ( - (unsigned long )hypervisor_callback, - (unsigned long )failsafe_callback,0 ); -#endif -start_kernel (); }arch/x86/traps.c +88
-0@@ -1,10 +1,12 @@#include <mini-os/os.h> #include <mini-os/traps.h> +#include <mini-os/desc.h> #include <mini-os/hypervisor.h> #include <mini-os/mm.h> #include <mini-os/lib.h> #include <mini-os/sched.h> +#include <xen/hvm/params.h> /* * These are assembler stubs in entry.S. @@ -293,6 +295,11 @@ void do_spurious_interrupt_bug(struct pt_regs * regs) { } +/* Assembler interface fns in entry.S. */ +void hypervisor_callback (void ); +void failsafe_callback (void ); + +#ifdef CONFIG_PARAVIRT /* * Submit a virtual IDT to teh hypervisor. This consists of tuples * (interrupt vector, privilege ring, CS:EIP of handler). @@ -325,9 +332,90 @@ static trap_info_t trap_table[] = { void trap_init(void) { HYPERVISOR_set_trap_table(trap_table); + +#ifdef __i386__ + HYPERVISOR_set_callbacks( + __KERNEL_CS, (unsigned long)hypervisor_callback, + __KERNEL_CS, (unsigned long)failsafe_callback); +#else + HYPERVISOR_set_callbacks( + (unsigned long)hypervisor_callback, + (unsigned long)failsafe_callback, 0); +#endif } void trap_fini(void) { HYPERVISOR_set_trap_table(NULL); } +#else + +#define INTR_STACK_SIZE PAGE_SIZE +static uint8_t intr_stack[INTR_STACK_SIZE] __attribute__((aligned(16))); + +hw_tss tss __attribute__((aligned(16))) = +{ +#if defined(__i386__) + .esp0 = (unsigned long)&intr_stack[INTR_STACK_SIZE], + .ss0 = __KERN_DS, +#elif defined(__x86_64__) + .rsp0 = (unsigned long)&intr_stack[INTR_STACK_SIZE], +#endif + .iopb = X86_TSS_INVALID_IO_BITMAP, +}; + +static void setup_gate(unsigned int entry, void *addr, unsigned int dpl) +{ + idt[entry].offset0 = (unsigned long)addr & 0xffff; + idt[entry].selector = __KERN_CS; + idt[entry]._r0 = 0; + idt[entry].type = 14; + idt[entry].s = 0; + idt[entry].dpl = dpl; + idt[entry].p = 1; + idt[entry].offset1 = ((unsigned long)addr >> 16) & 0xffff; +#if defined(__x86_64__) + idt[entry].ist = 0; + idt[entry].offset2 = ((unsigned long)addr >> 32) & 0xffffffffu; + idt[entry]._r1 = 0; +#endif +} + +void trap_init(void) +{ + setup_gate(TRAP_divide_error, ÷_error, 0); + setup_gate(TRAP_debug, &debug, 0); + setup_gate(TRAP_int3, &int3, 3); + setup_gate(TRAP_overflow, &overflow, 3); + setup_gate(TRAP_bounds, &bounds, 0); + setup_gate(TRAP_invalid_op, &invalid_op, 0); + setup_gate(TRAP_no_device, &device_not_available, 0); + setup_gate(TRAP_copro_seg, &coprocessor_segment_overrun, 0); + setup_gate(TRAP_invalid_tss, &invalid_TSS, 0); + setup_gate(TRAP_no_segment, &segment_not_present, 0); + setup_gate(TRAP_stack_error, &stack_segment, 0); + setup_gate(TRAP_gp_fault, &general_protection, 0); + setup_gate(TRAP_page_fault, &page_fault, 0); + setup_gate(TRAP_spurious_int, &spurious_interrupt_bug, 0); + setup_gate(TRAP_copro_error, &coprocessor_error, 0); + setup_gate(TRAP_alignment_check, &alignment_check, 0); + setup_gate(TRAP_simd_error, &simd_coprocessor_error, 0); + setup_gate(TRAP_xen_callback, hypervisor_callback, 0); + + asm volatile ("lidt idt_ptr"); + + gdt[GDTE_TSS] = (typeof(*gdt))INIT_GDTE((unsigned long)&tss, 0x67, 0x89); + asm volatile ("ltr %w0" :: "rm" (GDTE_TSS * 8)); + + if ( hvm_set_parameter(HVM_PARAM_CALLBACK_IRQ, + (2ULL << 56) | TRAP_xen_callback) ) + { + xprintk("Request for Xen HVM callback vector failed\n"); + do_exit(); + } +} + +void trap_fini(void) +{ +} +#endifarch/x86/x86_64.S +4
-0@@ -130,18 +130,22 @@ KERNEL_CS_MASK = 0xfc .endm .macro HYPERVISOR_IRET flag +#ifdef CONFIG_PARAVIRT testl $NMI_MASK,2*8(%rsp) jnz 2f +#endif /* Direct iret to kernel space. Correct CS and SS. */ orb $3,1*8(%rsp) orb $3,4*8(%rsp) iretq +#ifdef CONFIG_PARAVIRT 2: /* Slow iret via hypervisor. */ andl $~NMI_MASK, 16(%rsp) pushq $\flag jmp hypercall_page + (__HYPERVISOR_iret * 32) +#endif .endminclude/x86/os.h +1
-0@@ -56,6 +56,7 @@#define TRAP_machine_check 18#define TRAP_simd_error 19#define TRAP_deferred_nmi 31 +#define TRAP_xen_callback 32/* Everything below this point is not included by assembler (.S) files. */ #ifndef __ASSEMBLY__Signature · 1 line
2.6.6
Signature · 10 lines
Samuel RM> Mauvais OS, changer d'OS (c)(r)(tm) J'ai windows 98 et comment faire pour changer l'os de windows 98? Dans ajout et suppression du programme et il ne parle pas d'os. -+- DN in : GNU -+- L'O.S. est las, hélas, c'est là qu'est l'os -+- _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Juergen Gross
maintainerPATCH 9/22 mini-os: support HVMlite traps
In reply to Juergen GrossTrap handling in HVMlite domain is different from pv one.
--- arch/x86/traps.c | 2 -- arch/x86/x86_32.S | 19 ++++++++++++++-- arch/x86/x86_64.S | 22 +++++++++++++++++- include/x86/os.h | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 4 files changed, 101 insertions(+), 9 deletions(-)
arch/x86/traps.c +0 -2
@@ -191,8 +191,6 @@ static void dump_mem(unsigned long addr) }printk ("\n" ); } -#define read_cr2 () \ - (HYPERVISOR_shared_info->vcpu_info[smp_processor_id()].arch.cr2)static int handling_pg_fault =0 ;
arch/x86/x86_32.S +17 -2
@@ -8,6 +8,9 @@ #include <xen/arch-x86_32.h> #ifdef CONFIG_PARAVIRT + +#define KERNEL_DS __KERNEL_DS + ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS, .asciz "Mini-OS") ELFNOTE(Xen, XEN_ELFNOTE_LOADER, .asciz "generic") ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, _WORD hypercall_page)
@@ -21,6 +24,8 @@ _start: lss stack_start,%esp #else +#define KERNEL_DS __KERN_DS + #include "x86_hvm.S" movl stack_start,%esp
@@ -61,7 +66,7 @@ CS = 0x2C pushl %edx; \ pushl %ecx; \ pushl %ebx; \ - movl $(__KERNEL_DS),%edx; \ + movl $(KERNEL_DS),%edx; \ movl %edx,%ds; \ movl %edx,%es;
@@ -98,7 +103,7 @@ do_exception: movl ORIG_EAX(%esp), %edx # get the error code movl %eax, ORIG_EAX(%esp) movl %ecx, ES(%esp) - movl $(__KERNEL_DS), %ecx + movl $(KERNEL_DS), %ecx movl %ecx, %ds movl %ecx, %es movl %esp,%eax # pt_regs pointer
@@ -112,6 +117,7 @@ ret_from_exception: addl $8,%esp RESTORE_ALL +#ifdef CONFIG_PARAVIRT # A note on the "critical region" in our callback handler. # We want to avoid stacking callback handlers due to events occurring # during handling of the last event. To do this, we keep events disabled
@@ -189,6 +195,15 @@ critical_fixup_table: .byte 0x28 # iret .byte 0x00,0x00,0x00,0x00 # movb $1,1(%esi) .byte 0x00,0x00 # jmp 11b + +#else + +ENTRY(hypervisor_callback) + pushl $0 + pushl $do_hypervisor_callback + jmp do_exception + +#endif # Hypervisor uses this for application faults while it executes. ENTRY(failsafe_callback)
arch/x86/x86_64.S +21 -1
@@ -78,9 +78,11 @@ KERNEL_CS_MASK = 0xfc /* Macros */ .macro zeroentry sym +#ifdef CONFIG_PARAVIRT movq (%rsp),%rcx movq 8(%rsp),%r11 addq $0x10,%rsp /* skip rcx and r11 */ +#endif pushq $0 /* push error code/oldrax */ pushq %rax /* push real oldrax to the rdi slot */ leaq \sym(%rip),%rax
@@ -88,9 +90,11 @@ KERNEL_CS_MASK = 0xfc .endm .macro errorentry sym +#ifdef CONFIG_PARAVIRT movq (%rsp),%rcx movq 8(%rsp),%r11 addq $0x10,%rsp /* rsp points to the error code */ +#endif pushq %rax leaq \sym(%rip),%rax jmp error_entry
@@ -133,11 +137,11 @@ KERNEL_CS_MASK = 0xfc #ifdef CONFIG_PARAVIRT testl $NMI_MASK,2*8(%rsp) jnz 2f -#endif /* Direct iret to kernel space. Correct CS and SS. */ orb $3,1*8(%rsp) orb $3,4*8(%rsp) +#endif iretq #ifdef CONFIG_PARAVIRT
@@ -182,6 +186,7 @@ error_call_handler: jmp error_exit +#ifdef CONFIG_PARAVIRT /* * Xen event (virtual interrupt) entry point. */
@@ -285,11 +290,26 @@ critical_region_fixup: andb $KERNEL_CS_MASK,CS(%rsp) # CS might have changed jmp 11b +#else +error_exit: + RESTORE_REST + RESTORE_ALL + HYPERVISOR_IRET 0 +/* + * Xen event (virtual interrupt) entry point. + */ +ENTRY(hypervisor_callback) + zeroentry do_hypervisor_callback + + +#endif ENTRY(failsafe_callback) +#ifdef CONFIG_PARAVIRT popq %rcx popq %r11 +#endif iretq
include/x86/os.h +63 -4
96 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
Re: [PATCH 09/22] mini-os: support HVMlite traps
Quoted 3 lines · Juergen Gross, on Tue 23 Aug 2016 17:15:55 +0200, wrote:
Trap handling in HVMlite domain is different from pv one.
Signed-off-by Juergen Gross <[email protected]>
Quoted 268 lines
--- arch/x86/traps.c | 2 -- arch/x86/x86_32.S | 19 ++++++++++++++-- arch/x86/x86_64.S | 22 +++++++++++++++++- include/x86/os.h | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 4 files changed, 101 insertions(+), 9 deletions(-)arch/x86/traps.c +0
-2@@ -191,8 +191,6 @@ static void dump_mem(unsigned long addr) }printk ("\n" ); } -#define read_cr2 () \ - (HYPERVISOR_shared_info->vcpu_info[smp_processor_id()].arch.cr2)static int handling_pg_fault =0 ;arch/x86/x86_32.S +17
-2@@ -8,6 +8,9 @@ #include <xen/arch-x86_32.h> #ifdef CONFIG_PARAVIRT + +#define KERNEL_DS __KERNEL_DS + ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS, .asciz "Mini-OS") ELFNOTE(Xen, XEN_ELFNOTE_LOADER, .asciz "generic") ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, _WORD hypercall_page)@@ -21,6 +24,8 @@ _start: lss stack_start,%esp #else +#define KERNEL_DS __KERN_DS + #include "x86_hvm.S" movl stack_start,%esp@@ -61,7 +66,7 @@ CS = 0x2C pushl %edx; \ pushl %ecx; \ pushl %ebx; \ - movl $(__KERNEL_DS),%edx; \ + movl $(KERNEL_DS),%edx; \ movl %edx,%ds; \ movl %edx,%es;@@ -98,7 +103,7 @@ do_exception: movl ORIG_EAX(%esp), %edx # get the error code movl %eax, ORIG_EAX(%esp) movl %ecx, ES(%esp) - movl $(__KERNEL_DS), %ecx + movl $(KERNEL_DS), %ecx movl %ecx, %ds movl %ecx, %es movl %esp,%eax # pt_regs pointer@@ -112,6 +117,7 @@ ret_from_exception: addl $8,%esp RESTORE_ALL +#ifdef CONFIG_PARAVIRT # A note on the "critical region" in our callback handler. # We want to avoid stacking callback handlers due to events occurring # during handling of the last event. To do this, we keep events disabled@@ -189,6 +195,15 @@ critical_fixup_table: .byte 0x28 # iret .byte 0x00,0x00,0x00,0x00 # movb $1,1(%esi) .byte 0x00,0x00 # jmp 11b + +#else + +ENTRY(hypervisor_callback) + pushl $0 + pushl $do_hypervisor_callback + jmp do_exception + +#endif # Hypervisor uses this for application faults while it executes. ENTRY(failsafe_callback)arch/x86/x86_64.S +21
-1@@ -78,9 +78,11 @@ KERNEL_CS_MASK = 0xfc /* Macros */ .macro zeroentry sym +#ifdef CONFIG_PARAVIRT movq (%rsp),%rcx movq 8(%rsp),%r11 addq $0x10,%rsp /* skip rcx and r11 */ +#endif pushq $0 /* push error code/oldrax */ pushq %rax /* push real oldrax to the rdi slot */ leaq \sym(%rip),%rax@@ -88,9 +90,11 @@ KERNEL_CS_MASK = 0xfc .endm .macro errorentry sym +#ifdef CONFIG_PARAVIRT movq (%rsp),%rcx movq 8(%rsp),%r11 addq $0x10,%rsp /* rsp points to the error code */ +#endif pushq %rax leaq \sym(%rip),%rax jmp error_entry@@ -133,11 +137,11 @@ KERNEL_CS_MASK = 0xfc #ifdef CONFIG_PARAVIRT testl $NMI_MASK,2*8(%rsp) jnz 2f -#endif /* Direct iret to kernel space. Correct CS and SS. */ orb $3,1*8(%rsp) orb $3,4*8(%rsp) +#endif iretq #ifdef CONFIG_PARAVIRT@@ -182,6 +186,7 @@ error_call_handler: jmp error_exit +#ifdef CONFIG_PARAVIRT /* * Xen event (virtual interrupt) entry point. */@@ -285,11 +290,26 @@ critical_region_fixup: andb $KERNEL_CS_MASK,CS(%rsp) # CS might have changed jmp 11b +#else +error_exit: + RESTORE_REST + RESTORE_ALL + HYPERVISOR_IRET 0 +/* + * Xen event (virtual interrupt) entry point. + */ +ENTRY(hypervisor_callback) + zeroentry do_hypervisor_callback + + +#endif ENTRY(failsafe_callback) +#ifdef CONFIG_PARAVIRT popq %rcx popq %r11 +#endif iretqinclude/x86/os.h +63
-4@@ -31,6 +31,8 @@#define X86_CR4_PAE 0x00000020/* enable physical address extensions */ #define X86_CR4_OSFXSR 0x00000200/* enable fast FPU save and restore */ +#define X86_EFLAGS_IF 0x00000200 +#define __KERNEL_CS FLAT_KERNEL_CS#define __KERNEL_DS FLAT_KERNEL_DS#define __KERNEL_SS FLAT_KERNEL_SS@@ -70,7 +72,7 @@ void arch_fini(void); - +#ifdef CONFIG_PARAVIRT /* * The use of 'barrier' in the following reflects their use as local-lock @@ -129,15 +131,57 @@ do { \barrier (); \ } while (0) +#define irqs_disabled () \ + HYPERVISOR_shared_info->vcpu_info[smp_processor_id()].evtchn_upcall_mask + +#else + +#if defined(__i386__) +#define __SZ "l" +#define __REG "e" +#else +#define __SZ "q" +#define __REG "r" +#endif + +#define __cli () asm volatile ( "cli" : : : "memory" ) +#define __sti () asm volatile ( "sti" : : : "memory" ) + +#define __save_flags (x) \ +do { \ + unsigned long __f; \ + asm volatile ( "pushf" __SZ " ; pop" __SZ " %0" : "=g" (__f)); \ + x = (__f & X86_EFLAGS_IF) ? 1 : 0; \ +} while (0) + +#define __restore_flags (x) \ +do { \ + if (x) __sti(); \ + else __cli(); \ +} while (0) + +#define __save_and_cli (x) \ +do { \ + __save_flags(x); \ + __cli(); \ +} while (0) + +static inline int irqs_disabled (void ) +{ +int flag; + +__save_flags (flag); +return !flag; +} + +#endif +#define local_irq_save (x) __save_and_cli(x)#define local_irq_restore (x) __restore_flags(x)#define local_save_flags (x) __save_flags(x)#define local_irq_disable () __cli()#define local_irq_enable () __sti() -#define irqs_disabled () \ - HYPERVISOR_shared_info->vcpu_info[smp_processor_id()].evtchn_upcall_mask -/* This is a barrier for the compiler only, NOT the processor! */ #define barrier () __asm__ __volatile__("": : :"memory")@@ -586,5 +630,20 @@ static inline void cpuid(uint32_t leaf,#undef ADDR +#ifdef CONFIG_PARAVIRT +static inline unsigned long read_cr2 (void ) +{ +return HYPERVISOR_shared_info->vcpu_info[smp_processor_id ()].arch.cr2; +} +#else +static inline unsigned long read_cr2 (void ) +{ +unsigned long cr2; + + asmvolatile ("mov %%cr2,%0\n\t" :"=r" (cr2) ); +return cr2; +} +#endif +#endif /* not assembly */ #endif /* _OS_H_ */ Signature · 1 line
2.6.6
Signature · 10 lines
Samuel Tu as lu les docs. Tu es devenu un informaticien. Que tu le veuilles ou non. Lire la doc, c'est le Premier et Unique Commandement de l'informaticien. -+- TP in: Guide du Linuxien pervers - "L'évangile selon St Thomas" _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Juergen Gross
maintainerPATCH 10/22 mini-os: make p2m related code depend on CONFIG_PARAVIRT
In reply to Juergen GrossAll handling related to p2m is needed for paravirtualized environment only. So put all functions operating on p2m list in #ifdef CONFIG_PARAVIRT sections. Add a paravirt.h header defining dummy functions for non-paravirtualized environments. Instead of using references to start_info use dedicated variables initialized from start_info on boot.
--- arch/arm/balloon.c | 5 --- arch/arm/mm.c | 4 --- arch/x86/balloon.c | 13 ++++++++ arch/x86/mm.c | 67 +++++++++++++++++++++++++++++---------- arch/x86/setup.c | 6 ++-- arch/x86/traps.c | 6 ++-- balloon.c | 1 + include/arm/arch_mm.h | 3 -- include/balloon.h | 3 -- include/mm.h | 2 +- include/paravirt.h | 48 ++++++++++++++++++++++++++++ include/x86/arch_mm.h | 40 +++++------------------ include/xen/arch-x86/xen-x86_32.h | 2 ++ include/xen/arch-x86/xen-x86_64.h | 2 ++ mm.c | 1 + 15 files changed, 133 insertions(+), 70 deletions(-)
arch/arm/balloon.c +0 -5
@@ -27,11 +27,6 @@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) { }
arch/arm/mm.c +0 -4
@@ -72,10 +72,6 @@ void arch_init_mm(unsigned long *start_pfn_p, unsigned long *max_pfn_p) *max_pfn_p =to_phys (new_device_tree) >>PAGE_SHIFT ; } -void arch_init_p2m (unsigned long max_pfn) -{ -} -void arch_init_demand_mapping_area (void ) { }
arch/x86/balloon.c +13 -0
@@ -26,11 +26,13 @@#include <mini-os/errno.h> #include <mini-os/lib.h> #include <mini-os/mm.h> +#include <mini-os/paravirt.h> #ifdef CONFIG_BALLOON unsigned long virt_kernel_area_end = VIRT_KERNEL_AREA; +#ifdef CONFIG_PARAVIRT static void p2m_invalidate(unsigned long *list, unsigned long start_idx) { unsigned long idx;
@@ -143,5 +145,16 @@ void arch_pfn_add(unsigned long pfn, unsigned long mfn)do_exit (); } } +#else +void arch_pfn_add (unsigned long pfn,unsigned long mfn) +{ +pgentry_t *pgt; + + pgt =need_pgt ((unsigned long )pfn_to_virt (pfn)); +ASSERT (pgt); +if ( !(*pgt & _PAGE_PSE) ) + *pgt = (pgentry_t)(mfn <<PAGE_SHIFT ) | _PAGE_PRESENT | _PAGE_RW; +} +#endif #endif
arch/x86/mm.c +51 -16
160 lines not on this page · raw message
arch/x86/setup.c +3 -3
@@ -131,6 +131,9 @@ arch_init(void *par)/* Initialize SSE */ sse_init (); +/* Setup memory management info from start_info. */ +arch_mm_preinit (par); +/* Copy the start_info struct to a globally-accessible area. */ /* WARN: don't do printk before here, it uses information from shared_info. Use xprintk instead. */
@@ -152,9 +155,6 @@ arch_init(void *par) si->cmd_line ? (const char *)si->cmd_line : "NULL");printk (" stack: %p-%p\n" , stack, stack +sizeof (stack)); -/* set up minimal memory infos */ - phys_to_machine_mapping = (unsigned long *)start_info.mfn_list; -/* Grab the shared_info pointer and put it in a safe place. */ HYPERVISOR_shared_info =map_shared_info (start_info.shared_info);
arch/x86/traps.c +3 -3
@@ -97,9 +97,9 @@ DO_ERROR(18, "machine check", machine_check)void page_walk (unsigned long virt_address) { -pgentry_t *tab = (pgentry_t *)start_info.pt_base, page; +pgentry_t *tab = pt_base, page;unsigned long addr = virt_address; -printk ("Pagetable walk from virt %lx, base %lx:\n" , virt_address, start_info.pt_base); +printk ("Pagetable walk from virt %lx, base %p:\n" , virt_address, pt_base);#if defined(__x86_64__) page = tab[l4_table_offset (addr)];
@@ -119,7 +119,7 @@ void page_walk(unsigned long virt_address) }static int handle_cow (unsigned long addr) { -pgentry_t *tab = (pgentry_t *)start_info.pt_base, page; +pgentry_t *tab = pt_base, page;unsigned long new_page;int rc;
balloon.c +1 -0
@@ -25,6 +25,7 @@#include <mini-os/balloon.h> #include <mini-os/errno.h> #include <mini-os/lib.h> +#include <mini-os/paravirt.h> #include <xen/xen.h> #include <xen/memory.h>
include/arm/arch_mm.h +0 -3
@@ -29,9 +29,6 @@ extern uint32_t physical_address_offset; /* Add this to a virtual address to get#define mfn_to_virt (_mfn) (to_virt(PFN_PHYS(_mfn)))#define pfn_to_virt (_pfn) (to_virt(PFN_PHYS(_pfn))) -#define mfn_to_pfn (x) (x) -#define pfn_to_mfn (x) (x) -#define virtual_to_mfn (_virt) virt_to_mfn(_virt)// FIXME
include/balloon.h +0 -3
@@ -39,16 +39,13 @@ 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);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) {
include/mm.h +1 -1
@@ -36,6 +36,7 @@#endif #include <xen/xen.h> +#include <mini-os/paravirt.h> #include <mini-os/arch_limits.h> #include <mini-os/arch_mm.h>
@@ -67,7 +68,6 @@ static __inline__ int get_order(unsigned long size)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);unsigned long allocate_ondemand (unsigned long n,unsigned long alignment);/* map f[i*stride]+i*increment for i in 0..n-1, aligned on alignment pages */
include/paravirt.h +48 -0
55 lines not on this page · raw message
include/x86/arch_mm.h +8 -32
@@ -184,31 +184,6 @@ typedef unsigned long pgentry_t;#define IO_PROT (L1_PROT)#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) - -#ifndef __ASSEMBLY__ -void p2m_chk_pfn (unsigned long pfn); - -static inline unsigned long p2m_pages (unsigned long pages) -{ -return (pages +P2M_ENTRIES -1 ) >>L1_P2M_SHIFT ; -} -#endif -#include "arch_limits.h" #define PAGE_SIZE __PAGE_SIZE#define PAGE_SHIFT __PAGE_SHIFT
@@ -232,10 +207,14 @@ typedef unsigned long paddr_t;typedef unsigned long maddr_t ;#endif +extern pgentry_t *pt_base; +#ifdef CONFIG_PARAVIRT extern unsigned long *phys_to_machine_mapping; +#else +extern pgentry_t page_table_base[]; +#endif extern char _text, _etext, _erodata, _edata, _end;extern unsigned long mfn_zero; -#define pfn_to_mfn (_pfn) (phys_to_machine_mapping[(_pfn)])static __inline__maddr_t phys_to_machine (paddr_t phys) {maddr_t machine =pfn_to_mfn (phys >>PAGE_SHIFT );
@@ -243,7 +222,6 @@ static __inline__ maddr_t phys_to_machine(paddr_t phys)return machine; } -#define mfn_to_pfn (_mfn) (machine_to_phys_mapping[(_mfn)])static __inline__paddr_t machine_to_phys (maddr_t machine) {paddr_t phys =mfn_to_pfn (machine >>PAGE_SHIFT );
@@ -267,13 +245,10 @@ static __inline__ paddr_t machine_to_phys(maddr_t machine)#define pte_to_mfn (_pte) (((_pte) & (PADDR_MASK&PAGE_MASK)) >> L1_PAGETABLE_SHIFT)#define pte_to_virt (_pte) to_virt(mfn_to_pfn(pte_to_mfn(_pte)) << PAGE_SHIFT) - -#define PT_BASE ((pgentry_t *)start_info.pt_base) -#ifdef __x86_64__ -#define virtual_to_l3 (_virt) ((pgentry_t *)pte_to_virt(PT_BASE[l4_table_offset(_virt)])) +#define virtual_to_l3 (_virt) ((pgentry_t *)pte_to_virt(pt_base[l4_table_offset(_virt)]))#else -#define virtual_to_l3 (_virt) PT_BASE +#define virtual_to_l3 (_virt) pt_base#endif #define virtual_to_l2 (_virt) ({ \
@@ -297,6 +272,7 @@ static __inline__ paddr_t machine_to_phys(maddr_t machine)#define do_map_zero (start, n) do_map_frames(start, &mfn_zero, n, 0, 0, DOMID_SELF, NULL, L1_PROT_RO)pgentry_t *need_pgt (unsigned long addr); +void arch_mm_preinit (void *p);#endif
include/xen/arch-x86/xen-x86_32.h +2 -0
@@ -55,6 +55,7 @@#define FLAT_USER_DS FLAT_RING3_DS#define FLAT_USER_SS FLAT_RING3_SS +#ifdef CONFIG_PARAVIRT #define __HYPERVISOR_VIRT_START_PAE 0xF5800000#define __MACH2PHYS_VIRT_START_PAE 0xF5800000#define __MACH2PHYS_VIRT_END_PAE 0xF6800000
@@ -90,6 +91,7 @@#ifndef machine_to_phys_mapping#define machine_to_phys_mapping ((unsigned long *)MACH2PHYS_VIRT_START)#endif +#endif /* 32-/64-bit invariability for control interfaces (domctl/sysctl). */ #if defined(__XEN__) || defined(__XEN_TOOLS__)
include/xen/arch-x86/xen-x86_64.h +2 -0
@@ -70,6 +70,7 @@#define FLAT_USER_SS32 FLAT_RING3_SS32#define FLAT_USER_SS FLAT_USER_SS64 +#ifdef CONFIG_PARAVIRT #define __HYPERVISOR_VIRT_START 0xFFFF800000000000#define __HYPERVISOR_VIRT_END 0xFFFF880000000000#define __MACH2PHYS_VIRT_START 0xFFFF800000000000
@@ -86,6 +87,7 @@#ifndef machine_to_phys_mapping#define machine_to_phys_mapping ((unsigned long *)HYPERVISOR_VIRT_START)#endif +#endif /* * int HYPERVISOR_set_segment_base(unsigned int which, unsigned long base)
mm.c +1 -0
@@ -39,6 +39,7 @@#include <xen/memory.h> #include <mini-os/mm.h> #include <mini-os/balloon.h> +#include <mini-os/paravirt.h> #include <mini-os/types.h> #include <mini-os/lib.h> #include <mini-os/xmalloc.h>
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 10/22] mini-os: make p2m related code depend on CONFIG_PARAVIRT
Quoted 8 lines · Juergen Gross, on Tue 23 Aug 2016 17:15:56 +0200, wrote:
All handling related to p2m is needed for paravirtualized environment only. So put all functions operating on p2m list in #ifdef
CONFIG_PARAVIRTsections. Add aparavirt.hheader defining dummy functions for non-paravirtualized environments. Instead of using references tostart_infouse dedicated variables initialized fromstart_infoon boot.Signed-off-by Juergen Gross <[email protected]>
Quoted 578 lines
--- arch/arm/balloon.c | 5 --- arch/arm/mm.c | 4 --- arch/x86/balloon.c | 13 ++++++++ arch/x86/mm.c | 67 +++++++++++++++++++++++++++++---------- arch/x86/setup.c | 6 ++-- arch/x86/traps.c | 6 ++-- balloon.c | 1 + include/arm/arch_mm.h | 3 -- include/balloon.h | 3 -- include/mm.h | 2 +- include/paravirt.h | 48 ++++++++++++++++++++++++++++ include/x86/arch_mm.h | 40 +++++------------------ include/xen/arch-x86/xen-x86_32.h | 2 ++ include/xen/arch-x86/xen-x86_64.h | 2 ++ mm.c | 1 + 15 files changed, 133 insertions(+), 70 deletions(-)arch/arm/balloon.c +0
-5@@ -27,11 +27,6 @@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) { }arch/arm/mm.c +0
-4@@ -72,10 +72,6 @@ void arch_init_mm(unsigned long *start_pfn_p, unsigned long *max_pfn_p) *max_pfn_p =to_phys (new_device_tree) >>PAGE_SHIFT ; } -void arch_init_p2m (unsigned long max_pfn) -{ -} -void arch_init_demand_mapping_area (void ) { }arch/x86/balloon.c +13
-0@@ -26,11 +26,13 @@#include <mini-os/errno.h> #include <mini-os/lib.h> #include <mini-os/mm.h> +#include <mini-os/paravirt.h> #ifdef CONFIG_BALLOON unsigned long virt_kernel_area_end = VIRT_KERNEL_AREA; +#ifdef CONFIG_PARAVIRT static void p2m_invalidate(unsigned long *list, unsigned long start_idx) { unsigned long idx;@@ -143,5 +145,16 @@ void arch_pfn_add(unsigned long pfn, unsigned long mfn)do_exit (); } } +#else +void arch_pfn_add (unsigned long pfn,unsigned long mfn) +{ +pgentry_t *pgt; + + pgt =need_pgt ((unsigned long )pfn_to_virt (pfn)); +ASSERT (pgt); +if ( !(*pgt & _PAGE_PSE) ) + *pgt = (pgentry_t)(mfn <<PAGE_SHIFT ) | _PAGE_PRESENT | _PAGE_RW; +} +#endif #endif arch/x86/mm.c +51
-16@@ -39,6 +39,7 @@#include <mini-os/hypervisor.h> #include <mini-os/balloon.h> #include <mini-os/mm.h> +#include <mini-os/paravirt.h> #include <mini-os/types.h> #include <mini-os/lib.h> #include <mini-os/xmalloc.h> @@ -53,10 +54,24 @@unsigned long *phys_to_machine_mapping;unsigned long mfn_zero; +pgentry_t *pt_base; +static unsigned long first_free_pfn; +static unsigned long last_free_pfn; +extern char stack[];extern void page_walk (unsigned long va); -#ifndef CONFIG_PARAVIRT +#ifdef CONFIG_PARAVIRT +void arch_mm_preinit (void *p) +{ +start_info_t *si = p; + + phys_to_machine_mapping = (unsigned long *)si->mfn_list; + pt_base = (pgentry_t *)si->pt_base; + first_free_pfn =PFN_UP (to_phys (pt_base)) + si->nr_pt_frames; + last_free_pfn = si->nr_pages; +} +#else #include <mini-os/desc.h> user_desc gdt[NR_GDT_ENTRIES ] = {@@ -85,6 +100,22 @@ desc_ptr idt_ptr = .limit = sizeof(idt) - 1, .base = (unsigned long)&idt, }; + +void arch_mm_preinit (void *p) +{ +long ret; +domid_t domid =DOMID_SELF ; + + pt_base = page_table_base; + first_free_pfn =PFN_UP (to_phys (&_end)); + ret =HYPERVISOR_memory_op (XENMEM_current_reservation, &domid); +if ( ret <0 ) + { +xprintk ("could not get memory size\n" ); +do_exit (); + } + last_free_pfn = ret; +}#endif /* @@ -95,7 +126,7 @@ desc_ptr idt_ptr =static void new_pt_frame (unsigned long *pt_pfn,unsigned long prev_l_mfn,unsigned long offset,unsigned long level) { -pgentry_t *tab = (pgentry_t *)start_info.pt_base; +pgentry_t *tab = pt_base;unsigned long pt_page = (unsigned long )pfn_to_virt (*pt_pfn);pgentry_t prot_e, prot_t;mmu_update_t mmu_updates[1 ];@@ -172,8 +203,8 @@ static void build_pagetable(unsigned long *start_pfn, unsigned long *max_pfn)unsigned long start_address, end_address;unsigned long pfn_to_map, pt_pfn = *start_pfn;static mmu_update_t mmu_updates[L1_PAGETABLE_ENTRIES +1 ]; -pgentry_t *tab = (pgentry_t *)start_info.pt_base, page; -unsigned long pt_mfn =pfn_to_mfn (virt_to_pfn (start_info.pt_base)); +pgentry_t *tab = pt_base, page; +unsigned long pt_mfn =pfn_to_mfn (virt_to_pfn (pt_base));unsigned long offset;int count =0 ;int rc;@@ -182,6 +213,7 @@ static void build_pagetable(unsigned long *start_pfn, unsigned long *max_pfn)mapped, start the loop at the very beginning. */ pfn_to_map = *start_pfn; +#ifdef CONFIG_PARAVIRT if ( *max_pfn >=virt_to_pfn (HYPERVISOR_VIRT_START ) ) { printk("WARNING: Mini-OS trying to use Xen virtual space. "@@ -193,6 +225,7 @@ static void build_pagetable(unsigned long *start_pfn, unsigned long *max_pfn) ((unsigned long )pfn_to_virt (*max_pfn) - (unsigned long)&_text)>>20); } +#endif start_address = (unsigned long )pfn_to_virt (pfn_to_map); end_address = (unsigned long )pfn_to_virt (*max_pfn);@@ -202,8 +235,8 @@ static void build_pagetable(unsigned long *start_pfn, unsigned long *max_pfn)while ( start_address < end_address ) { - tab = (pgentry_t *)start_info.pt_base; - pt_mfn =pfn_to_mfn (virt_to_pfn (start_info.pt_base)); + tab = pt_base; + pt_mfn =pfn_to_mfn (virt_to_pfn (pt_base));#if defined(__x86_64__) offset =l4_table_offset (start_address);@@ -270,8 +303,8 @@ static void set_readonly(void *text, void *etext) ((unsigned long ) text +PAGE_SIZE -1 ) &PAGE_MASK ;unsigned long end_address = (unsigned long ) etext;static mmu_update_t mmu_updates[L1_PAGETABLE_ENTRIES +1 ]; -pgentry_t *tab = (pgentry_t *)start_info.pt_base, page; -unsigned long mfn =pfn_to_mfn (virt_to_pfn (start_info.pt_base)); +pgentry_t *tab = pt_base, page; +unsigned long mfn =pfn_to_mfn (virt_to_pfn (pt_base));unsigned long offset;int count =0 ;int rc;@@ -280,8 +313,8 @@ static void set_readonly(void *text, void *etext)while ( start_address +PAGE_SIZE <= end_address ) { - tab = (pgentry_t *)start_info.pt_base; - mfn =pfn_to_mfn (virt_to_pfn (start_info.pt_base)); + tab = pt_base; + mfn =pfn_to_mfn (virt_to_pfn (pt_base));#if defined(__x86_64__) offset =l4_table_offset (start_address);@@ -343,8 +376,8 @@ static pgentry_t *get_pgt(unsigned long va)pgentry_t *tab;unsigned offset; - tab = (pgentry_t *)start_info.pt_base; - mfn =virt_to_mfn (start_info.pt_base); + tab = pt_base; + mfn =virt_to_mfn (pt_base);#if defined(__x86_64__) offset =l4_table_offset (va);@@ -379,8 +412,8 @@ pgentry_t *need_pgt(unsigned long va)unsigned long pt_pfn;unsigned offset; - tab = (pgentry_t *)start_info.pt_base; - pt_mfn =virt_to_mfn (start_info.pt_base); + tab = pt_base; + pt_mfn =virt_to_mfn (pt_base);#if defined(__x86_64__) offset =l4_table_offset (va);@@ -639,6 +672,7 @@ static void clear_bootstrap(void)printk ("Unable to unmap NULL page. rc=%d\n" , rc); } +#ifdef CONFIG_PARAVIRT void p2m_chk_pfn (unsigned long pfn) {if ( (pfn >>L3_P2M_SHIFT ) >0 )@@ -670,6 +704,7 @@ void arch_init_p2m(unsigned long max_pfn) arch_remap_p2m(max_pfn); } +#endif void arch_init_mm (unsigned long * start_pfn_p,unsigned long * max_pfn_p) {@@ -683,8 +718,8 @@ void arch_init_mm(unsigned long* start_pfn_p, unsigned long* max_pfn_p)printk (" _end: %p(VA)\n" , &_end);/* 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; + start_pfn = first_free_pfn; + max_pfn = last_free_pfn;if ( max_pfn >=MAX_MEM_SIZE /PAGE_SIZE ) max_pfn =MAX_MEM_SIZE /PAGE_SIZE -1 ;arch/x86/setup.c +3
-3@@ -131,6 +131,9 @@ arch_init(void *par)/* Initialize SSE */ sse_init (); +/* Setup memory management info from start_info. */ +arch_mm_preinit (par); +/* Copy the start_info struct to a globally-accessible area. */ /* WARN: don't do printk before here, it uses information from shared_info. Use xprintk instead. */ @@ -152,9 +155,6 @@ arch_init(void *par) si->cmd_line ? (const char *)si->cmd_line : "NULL");printk (" stack: %p-%p\n" , stack, stack +sizeof (stack)); -/* set up minimal memory infos */ - phys_to_machine_mapping = (unsigned long *)start_info.mfn_list; -/* Grab the shared_info pointer and put it in a safe place. */ HYPERVISOR_shared_info =map_shared_info (start_info.shared_info);arch/x86/traps.c +3
-3@@ -97,9 +97,9 @@ DO_ERROR(18, "machine check", machine_check)void page_walk (unsigned long virt_address) { -pgentry_t *tab = (pgentry_t *)start_info.pt_base, page; +pgentry_t *tab = pt_base, page;unsigned long addr = virt_address; -printk ("Pagetable walk from virt %lx, base %lx:\n" , virt_address, start_info.pt_base); +printk ("Pagetable walk from virt %lx, base %p:\n" , virt_address, pt_base);#if defined(__x86_64__) page = tab[l4_table_offset (addr)];@@ -119,7 +119,7 @@ void page_walk(unsigned long virt_address) }static int handle_cow (unsigned long addr) { -pgentry_t *tab = (pgentry_t *)start_info.pt_base, page; +pgentry_t *tab = pt_base, page;unsigned long new_page;int rc;balloon.c +1
-0@@ -25,6 +25,7 @@#include <mini-os/balloon.h> #include <mini-os/errno.h> #include <mini-os/lib.h> +#include <mini-os/paravirt.h> #include <xen/xen.h> #include <xen/memory.h> include/arm/arch_mm.h +0
-3@@ -29,9 +29,6 @@ extern uint32_t physical_address_offset; /* Add this to a virtual address to get#define mfn_to_virt (_mfn) (to_virt(PFN_PHYS(_mfn)))#define pfn_to_virt (_pfn) (to_virt(PFN_PHYS(_pfn))) -#define mfn_to_pfn (x) (x) -#define pfn_to_mfn (x) (x) -#define virtual_to_mfn (_virt) virt_to_mfn(_virt)// FIXME include/balloon.h +0
-3@@ -39,16 +39,13 @@ 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);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) {include/mm.h +1
-1@@ -36,6 +36,7 @@#endif #include <xen/xen.h> +#include <mini-os/paravirt.h> #include <mini-os/arch_limits.h> #include <mini-os/arch_mm.h> @@ -67,7 +68,6 @@ static __inline__ int get_order(unsigned long size)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);unsigned long allocate_ondemand (unsigned long n,unsigned long alignment);/* map f[i*stride]+i*increment for i in 0..n-1, aligned on alignment pages */ include/paravirt.h +48
-0@@ -26,7 +26,55 @@#if defined(CONFIG_PARAVIRT ) +#define mfn_to_pfn (_mfn) (machine_to_phys_mapping[(_mfn)]) +#define pfn_to_mfn (_pfn) (phys_to_machine_mapping[(_pfn)]) + +/* 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) + +void p2m_chk_pfn (unsigned long pfn); + +static inline unsigned long p2m_pages (unsigned long pages) +{ +return (pages +P2M_ENTRIES -1 ) >>L1_P2M_SHIFT ; +} + +void arch_init_p2m (unsigned long max_pfn_p); + +#else + +#define mfn_to_pfn (_mfn) ((unsigned long)(_mfn)) +#define pfn_to_mfn (_pfn) ((unsigned long)(_pfn)) + +static inline void arch_init_p2m (unsigned long max_pfn_p) { } + +#endif + +#if defined(CONFIG_PARAVIRT ) && defined(CONFIG_BALLOON ) + +void arch_remap_p2m (unsigned long max_pfn); +int arch_expand_p2m (unsigned long max_pfn); + +#else + +static inline void arch_remap_p2m (unsigned long max_pfn) { } +static inline int arch_expand_p2m (unsigned long max_pfn) +{ +return 0 ; +}#endif include/x86/arch_mm.h +8
-32@@ -184,31 +184,6 @@ typedef unsigned long pgentry_t;#define IO_PROT (L1_PROT)#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) - -#ifndef __ASSEMBLY__ -void p2m_chk_pfn (unsigned long pfn); - -static inline unsigned long p2m_pages (unsigned long pages) -{ -return (pages +P2M_ENTRIES -1 ) >>L1_P2M_SHIFT ; -} -#endif -#include "arch_limits.h" #define PAGE_SIZE __PAGE_SIZE#define PAGE_SHIFT __PAGE_SHIFT@@ -232,10 +207,14 @@ typedef unsigned long paddr_t;typedef unsigned long maddr_t ;#endif +extern pgentry_t *pt_base; +#ifdef CONFIG_PARAVIRT extern unsigned long *phys_to_machine_mapping; +#else +extern pgentry_t page_table_base[]; +#endif extern char _text, _etext, _erodata, _edata, _end;extern unsigned long mfn_zero; -#define pfn_to_mfn (_pfn) (phys_to_machine_mapping[(_pfn)])static __inline__maddr_t phys_to_machine (paddr_t phys) {maddr_t machine =pfn_to_mfn (phys >>PAGE_SHIFT );@@ -243,7 +222,6 @@ static __inline__ maddr_t phys_to_machine(paddr_t phys)return machine; } -#define mfn_to_pfn (_mfn) (machine_to_phys_mapping[(_mfn)])static __inline__paddr_t machine_to_phys (maddr_t machine) {paddr_t phys =mfn_to_pfn (machine >>PAGE_SHIFT );@@ -267,13 +245,10 @@ static __inline__ paddr_t machine_to_phys(maddr_t machine)#define pte_to_mfn (_pte) (((_pte) & (PADDR_MASK&PAGE_MASK)) >> L1_PAGETABLE_SHIFT)#define pte_to_virt (_pte) to_virt(mfn_to_pfn(pte_to_mfn(_pte)) << PAGE_SHIFT) - -#define PT_BASE ((pgentry_t *)start_info.pt_base) -#ifdef __x86_64__ -#define virtual_to_l3 (_virt) ((pgentry_t *)pte_to_virt(PT_BASE[l4_table_offset(_virt)])) +#define virtual_to_l3 (_virt) ((pgentry_t *)pte_to_virt(pt_base[l4_table_offset(_virt)]))#else -#define virtual_to_l3 (_virt) PT_BASE +#define virtual_to_l3 (_virt) pt_base#endif #define virtual_to_l2 (_virt) ({ \@@ -297,6 +272,7 @@ static __inline__ paddr_t machine_to_phys(maddr_t machine)#define do_map_zero (start, n) do_map_frames(start, &mfn_zero, n, 0, 0, DOMID_SELF, NULL, L1_PROT_RO)pgentry_t *need_pgt (unsigned long addr); +void arch_mm_preinit (void *p);#endif include/xen/arch-x86/xen-x86_32.h +2
-0@@ -55,6 +55,7 @@#define FLAT_USER_DS FLAT_RING3_DS#define FLAT_USER_SS FLAT_RING3_SS +#ifdef CONFIG_PARAVIRT #define __HYPERVISOR_VIRT_START_PAE 0xF5800000#define __MACH2PHYS_VIRT_START_PAE 0xF5800000#define __MACH2PHYS_VIRT_END_PAE 0xF6800000@@ -90,6 +91,7 @@#ifndef machine_to_phys_mapping#define machine_to_phys_mapping ((unsigned long *)MACH2PHYS_VIRT_START)#endif +#endif /* 32-/64-bit invariability for control interfaces (domctl/sysctl). */ #if defined(__XEN__) || defined(__XEN_TOOLS__)include/xen/arch-x86/xen-x86_64.h +2
-0@@ -70,6 +70,7 @@#define FLAT_USER_SS32 FLAT_RING3_SS32#define FLAT_USER_SS FLAT_USER_SS64 +#ifdef CONFIG_PARAVIRT #define __HYPERVISOR_VIRT_START 0xFFFF800000000000#define __HYPERVISOR_VIRT_END 0xFFFF880000000000#define __MACH2PHYS_VIRT_START 0xFFFF800000000000@@ -86,6 +87,7 @@#ifndef machine_to_phys_mapping#define machine_to_phys_mapping ((unsigned long *)HYPERVISOR_VIRT_START)#endif +#endif /* * int HYPERVISOR_set_segment_base(unsigned int which, unsigned long base) mm.c +1
-0@@ -39,6 +39,7 @@#include <xen/memory.h> #include <mini-os/mm.h> #include <mini-os/balloon.h> +#include <mini-os/paravirt.h> #include <mini-os/types.h> #include <mini-os/lib.h> #include <mini-os/xmalloc.h> Signature · 1 line
2.6.6
Signature · 9 lines
Samuel <y> t1 faich <y> les programmes ils segfaultent jamais quand on veut -+- #ens-mim en plein débogage -+- _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Juergen Gross
maintainerPATCH 11/22 mini-os: add static page tables for virtual kernel area for HVMlite
In reply to Juergen GrossIn HVMlite mode we need the virtual kernel area for mapping of the console and xenbus ring pages as especially on 32 bit architecture their pfns might be above the supported maximum memory size.
Add the page tables needed for doing the mapping.
--- arch/x86/mm.c | 11 +++++++++++ arch/x86/x86_64.S | 7 +++++++ 2 files changed, 18 insertions(+)
arch/x86/mm.c +11 -0
@@ -733,6 +733,17 @@ void arch_init_mm(unsigned long* start_pfn_p, unsigned long* max_pfn_p) *start_pfn_p = start_pfn; *max_pfn_p = max_pfn; + +#ifndef CONFIG_PARAVIRT +#ifdef __x86_64__ +BUILD_BUG_ON (l4_table_offset (VIRT_KERNEL_AREA ) !=1 || +l3_table_offset (VIRT_KERNEL_AREA ) !=0 || +l2_table_offset (VIRT_KERNEL_AREA ) !=0 ); +#else +BUILD_BUG_ON (l3_table_offset (VIRT_KERNEL_AREA ) !=0 || +l2_table_offset (VIRT_KERNEL_AREA ) ==0 ); +#endif +#endif }grant_entry_t *arch_init_gnttab (int nr_grant_frames)
arch/x86/x86_64.S +7 -0
@@ -418,10 +418,17 @@ ENTRY(__arch_switch_threads) .data .globl page_table_base .align __PAGE_SIZE +page_table_virt_l2: + PTE(page_table_virt_l1 + L2_PROT) + .align __PAGE_SIZE, 0 +page_table_virt_l3: + PTE(page_table_virt_l2 + L3_PROT) + .align __PAGE_SIZE, 0 page_table_l3: PTE(page_table_l2 + L3_PROT) .align __PAGE_SIZE, 0 page_table_base: PTE(page_table_l3 + L4_PROT) + PTE(page_table_virt_l3 + L4_PROT) .align __PAGE_SIZE, 0 #endif
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 11/22] mini-os: add static page tables for virtual kernel area for HVMlite
Quoted 7 lines · Juergen Gross, on Tue 23 Aug 2016 17:15:57 +0200, wrote:
In HVMlite mode we need the virtual kernel area for mapping of the console and xenbus ring pages as especially on 32 bit architecture their pfns might be above the supported maximum memory size.
Add the page tables needed for doing the mapping.
Signed-off-by Juergen Gross <[email protected]>
Quoted 52 lines
--- arch/x86/mm.c | 11 +++++++++++ arch/x86/x86_64.S | 7 +++++++ 2 files changed, 18 insertions(+)arch/x86/mm.c +11
-0@@ -733,6 +733,17 @@ void arch_init_mm(unsigned long* start_pfn_p, unsigned long* max_pfn_p) *start_pfn_p = start_pfn; *max_pfn_p = max_pfn; + +#ifndef CONFIG_PARAVIRT +#ifdef __x86_64__ +BUILD_BUG_ON (l4_table_offset (VIRT_KERNEL_AREA ) !=1 || +l3_table_offset (VIRT_KERNEL_AREA ) !=0 || +l2_table_offset (VIRT_KERNEL_AREA ) !=0 ); +#else +BUILD_BUG_ON (l3_table_offset (VIRT_KERNEL_AREA ) !=0 || +l2_table_offset (VIRT_KERNEL_AREA ) ==0 ); +#endif +#endif }grant_entry_t *arch_init_gnttab (int nr_grant_frames)arch/x86/x86_64.S +7
-0@@ -418,10 +418,17 @@ ENTRY(__arch_switch_threads) .data .globl page_table_base .align __PAGE_SIZE +page_table_virt_l2: + PTE(page_table_virt_l1 + L2_PROT) + .align __PAGE_SIZE, 0 +page_table_virt_l3: + PTE(page_table_virt_l2 + L3_PROT) + .align __PAGE_SIZE, 0 page_table_l3: PTE(page_table_l2 + L3_PROT) .align __PAGE_SIZE, 0 page_table_base: PTE(page_table_l3 + L4_PROT) + PTE(page_table_virt_l3 + L4_PROT) .align __PAGE_SIZE, 0 #endifSignature · 1 line
2.6.6
Signature · 8 lines
Samuel <A> sauf que le firewall bloque tout sauf internet -+- ben ouais, il bloque ipx/spx ! -+- _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Juergen Gross
maintainerPATCH 12/22 mini-os: add x86 native page table handling
In reply to Juergen GrossFor support of HVMlite don't use mmu_update hypercalls, but write the page table entries directly.
--- arch/x86/mm.c | 147 +++++++++++++++++++++++++++++++++++++------------- arch/x86/traps.c | 10 ++++ include/x86/arch_mm.h | 4 ++ include/x86/os.h | 9 ++++ 4 files changed, 132 insertions(+), 38 deletions(-)
arch/x86/mm.c +109 -38
@@ -123,16 +123,25 @@ void arch_mm_preinit(void *p)* table at offset in previous level MFN (pref_l_mfn). pt_pfn is a guest * PFN. */ +static pgentry_t pt_prot[PAGETABLE_LEVELS ] = { +L1_PROT , +L2_PROT , +L3_PROT , +#if defined(__x86_64__) +L4_PROT , +#endif +}; +static void new_pt_frame (unsigned long *pt_pfn,unsigned long prev_l_mfn,unsigned long offset,unsigned long level) { -pgentry_t *tab = pt_base; +pgentry_t *tab;unsigned long pt_page = (unsigned long )pfn_to_virt (*pt_pfn); -pgentry_t prot_e, prot_t; +#ifdef CONFIG_PARAVIRT mmu_update_t mmu_updates[1 ];int rc; +#endif - prot_e = prot_t =0 ;DEBUG ("Allocating new L%d pt frame for pfn=%lx, " "prev_l_mfn=%lx, offset=%lx" , level, *pt_pfn, prev_l_mfn, offset);
@@ -140,30 +149,12 @@ static void new_pt_frame(unsigned long *pt_pfn, unsigned long prev_l_mfn,/* We need to clear the page, otherwise we might fail to map it as a page table page */ memset ((void *) pt_page,0 ,PAGE_SIZE ); - -switch ( level ) - { -case L1_FRAME : - prot_e =L1_PROT ; - prot_t =L2_PROT ; -break ; -case L2_FRAME : - prot_e =L2_PROT ; - prot_t =L3_PROT ; -break ; -#if defined(__x86_64__) -case L3_FRAME : - prot_e =L3_PROT ; - prot_t =L4_PROT ; -break ; -#endif -default : -printk ("new_pt_frame() called with invalid level number %lu\n" , level); -do_exit (); -break ; - } +ASSERT (level >=1 && level <=PAGETABLE_LEVELS ); + +#ifdef CONFIG_PARAVIRT /* Make PFN a page table page */ + tab = pt_base;#if defined(__x86_64__) tab =pte_to_virt (tab[l4_table_offset (pt_page)]);#endif
@@ -172,7 +163,7 @@ static void new_pt_frame(unsigned long *pt_pfn, unsigned long prev_l_mfn, mmu_updates[0 ].ptr = (tab[l2_table_offset (pt_page)] &PAGE_MASK ) +sizeof (pgentry_t) *l1_table_offset (pt_page); mmu_updates[0 ].val = (pgentry_t )pfn_to_mfn (*pt_pfn) <<PAGE_SHIFT | - (prot_e & ~_PAGE_RW); + (pt_prot[level -1 ] & ~_PAGE_RW);if ( (rc =HYPERVISOR_mmu_update (mmu_updates,1 ,NULL ,DOMID_SELF )) <0 ) {
@@ -184,13 +175,18 @@ static void new_pt_frame(unsigned long *pt_pfn, unsigned long prev_l_mfn,/* Hook the new page table page into the hierarchy */ mmu_updates[0 ].ptr = ((pgentry_t )prev_l_mfn <<PAGE_SHIFT ) +sizeof (pgentry_t) * offset; - mmu_updates[0 ].val = (pgentry_t )pfn_to_mfn (*pt_pfn) <<PAGE_SHIFT | prot_t; + mmu_updates[0 ].val = (pgentry_t )pfn_to_mfn (*pt_pfn) <<PAGE_SHIFT | + pt_prot[level];if ( (rc =HYPERVISOR_mmu_update (mmu_updates,1 ,NULL ,DOMID_SELF )) <0 ) {printk ("ERROR: mmu_update failed with rc=%d\n" , rc);do_exit (); } +#else + tab =mfn_to_virt (prev_l_mfn); + tab[offset] = (*pt_pfn <<PAGE_SHIFT ) | pt_prot[level]; +#endif *pt_pfn +=1 ; }
@@ -202,12 +198,14 @@ static void build_pagetable(unsigned long *start_pfn, unsigned long *max_pfn) {unsigned long start_address, end_address;unsigned long pfn_to_map, pt_pfn = *start_pfn; -static mmu_update_t mmu_updates[L1_PAGETABLE_ENTRIES +1 ];pgentry_t *tab = pt_base, page;unsigned long pt_mfn =pfn_to_mfn (virt_to_pfn (pt_base));unsigned long offset; +#ifdef CONFIG_PARAVIRT +static mmu_update_t mmu_updates[L1_PAGETABLE_ENTRIES +1 ];int count =0 ;int rc; +#endif /* Be conservative: even if we know there will be more pages already mapped, start the loop at the very beginning. */
@@ -225,6 +223,10 @@ static void build_pagetable(unsigned long *start_pfn, unsigned long *max_pfn) ((unsigned long )pfn_to_virt (*max_pfn) - (unsigned long)&_text)>>20); } +#else +/* Round up to next 2MB boundary as we are using 2MB pages on HVMlite. */ + pfn_to_map = (pfn_to_map +L1_PAGETABLE_ENTRIES -1 ) & + ~(L1_PAGETABLE_ENTRIES -1 );#endif start_address = (unsigned long )pfn_to_virt (pfn_to_map);
@@ -257,6 +259,7 @@ static void build_pagetable(unsigned long *start_pfn, unsigned long *max_pfn) pt_mfn =pte_to_mfn (page); tab =to_virt (mfn_to_pfn (pt_mfn) <<PAGE_SHIFT ); offset =l2_table_offset (start_address); +#ifdef CONFIG_PARAVIRT /* Need new L1 pt frame */ if ( !(tab[offset] & _PAGE_PRESENT) )new_pt_frame (&pt_pfn, pt_mfn, offset,L1_FRAME );
@@ -288,6 +291,12 @@ static void build_pagetable(unsigned long *start_pfn, unsigned long *max_pfn) count = 0; } start_address +=PAGE_SIZE ; +#else +if ( !(tab[offset] & _PAGE_PRESENT) ) + tab[offset] = (pgentry_t )pfn_to_map <<PAGE_SHIFT | +L2_PROT | _PAGE_PSE; + start_address +=1UL <<L2_PAGETABLE_SHIFT ; +#endif } *start_pfn = pt_pfn;
@@ -302,16 +311,19 @@ static void set_readonly(void *text, void *etext)unsigned long start_address = ((unsigned long ) text +PAGE_SIZE -1 ) &PAGE_MASK ;unsigned long end_address = (unsigned long ) etext; -static mmu_update_t mmu_updates[L1_PAGETABLE_ENTRIES +1 ];pgentry_t *tab = pt_base, page;unsigned long mfn =pfn_to_mfn (virt_to_pfn (pt_base));unsigned long offset; +unsigned long page_size =PAGE_SIZE ; +#ifdef CONFIG_PARAVIRT +static mmu_update_t mmu_updates[L1_PAGETABLE_ENTRIES +1 ];int count =0 ;int rc; +#endif printk ("setting %p-%p readonly\n" , text, etext); -while ( start_address +PAGE_SIZE <= end_address ) +while ( start_address + page_size <= end_address ) { tab = pt_base; mfn =pfn_to_mfn (virt_to_pfn (pt_base));
@@ -327,26 +339,34 @@ static void set_readonly(void *text, void *etext) mfn =pte_to_mfn (page); tab =to_virt (mfn_to_pfn (mfn) <<PAGE_SHIFT ); offset =l2_table_offset (start_address); - page = tab[offset]; - mfn =pte_to_mfn (page); - tab =to_virt (mfn_to_pfn (mfn) <<PAGE_SHIFT ); +if ( !(tab[offset] & _PAGE_PSE) ) + { + page = tab[offset]; + mfn =pte_to_mfn (page); + tab =to_virt (mfn_to_pfn (mfn) <<PAGE_SHIFT ); - offset =l1_table_offset (start_address); + offset =l1_table_offset (start_address); + }if ( start_address != (unsigned long )&shared_info ) { +#ifdef CONFIG_PARAVIRT mmu_updates[count].ptr = ((pgentry_t )mfn <<PAGE_SHIFT ) +sizeof (pgentry_t) * offset; mmu_updates[count].val = tab[offset] & ~_PAGE_RW; count++; +#else + tab[offset] &= ~_PAGE_RW; +#endif }else printk ("skipped %lx\n" , start_address); - start_address +=PAGE_SIZE ; + start_address += page_size; +#ifdef CONFIG_PARAVIRT if ( count ==L1_PAGETABLE_ENTRIES || - start_address +PAGE_SIZE > end_address ) + start_address + page_size > end_address ) { rc =HYPERVISOR_mmu_update (mmu_updates, count,NULL ,DOMID_SELF );if ( rc <0 )
@@ -356,8 +376,13 @@ static void set_readonly(void *text, void *etext) } count =0 ; } +#else +if ( start_address == (1UL <<L2_PAGETABLE_SHIFT ) ) + page_size =1UL <<L2_PAGETABLE_SHIFT ; +#endif } +#ifdef CONFIG_PARAVIRT { mmuext_op_t op = { .cmd = MMUEXT_TLB_FLUSH_ALL,
@@ -365,6 +390,9 @@ static void set_readonly(void *text, void *etext)int count; HYPERVISOR_mmuext_op(&op, 1, &count, DOMID_SELF); } +#else +write_cr3 ((unsigned long )pt_base); +#endif }/*
@@ -394,6 +422,8 @@ static pgentry_t *get_pgt(unsigned long va) offset =l2_table_offset (va);if ( !(tab[offset] & _PAGE_PRESENT) )return NULL ; +if ( tab[offset] & _PAGE_PSE ) +return &tab[offset]; mfn =pte_to_mfn (tab[offset]); tab =mfn_to_virt (mfn); offset =l1_table_offset (va);
@@ -448,6 +478,9 @@ pgentry_t *need_pgt(unsigned long va)new_pt_frame (&pt_pfn, pt_mfn, offset,L1_FRAME ); }ASSERT (tab[offset] & _PAGE_PRESENT); +if ( tab[offset] & _PAGE_PSE ) +return &tab[offset]; + pt_mfn =pte_to_mfn (tab[offset]); tab =mfn_to_virt (pt_mfn);
@@ -524,8 +557,6 @@ int do_map_frames(unsigned long va, {pgentry_t *pgt =NULL ;unsigned long done =0 ; -unsigned long i; -int rc;if ( !mfns ) {
@@ -539,6 +570,9 @@ int do_map_frames(unsigned long va,memset (err,0x00 , n *sizeof (int ));while ( done < n ) { +#ifdef CONFIG_PARAVIRT +unsigned long i; +int rc;unsigned long todo;if ( err )
@@ -578,6 +612,17 @@ int do_map_frames(unsigned long va, } } done += todo; +#else +if ( !pgt || !(va &L1_MASK ) ) + pgt =need_pgt (va & ~L1_MASK ); +if ( !pgt ) +return -ENOMEM ; + +ASSERT (!(*pgt & _PAGE_PSE)); + pgt[l1_table_offset (va)] = (pgentry_t) + (((mfns[done * stride] + done * incr) <<PAGE_SHIFT ) | prot); + done++; +#endif }return 0 ;
@@ -609,16 +654,21 @@ void *map_frames_ex(const unsigned long *mfns, unsigned long n,#define UNMAP_BATCH ((STACK_SIZE / 2) / sizeof(multicall_entry_t))int unmap_frames (unsigned long va,unsigned long num_frames) { +#ifdef CONFIG_PARAVIRT int n =UNMAP_BATCH ;multicall_entry_t call[n];int ret;int i; +#else +pgentry_t *pgt; +#endif ASSERT (!((unsigned long )va & ~PAGE_MASK ));DEBUG ("va=%p, num=0x%lx\n" , va, num_frames);while ( num_frames ) { +#ifdef CONFIG_PARAVIRT if ( n > num_frames ) n = num_frames;
@@ -653,6 +703,17 @@ int unmap_frames(unsigned long va, unsigned long num_frames) } } num_frames -= n; +#else + pgt =get_pgt (va); +if ( pgt ) + { +ASSERT (!(*pgt & _PAGE_PSE)); + *pgt =0 ; +invlpg (va); + } + va +=PAGE_SIZE ; + num_frames--; +#endif }return 0 ; }
@@ -662,14 +723,24 @@ int unmap_frames(unsigned long va, unsigned long num_frames)*/ static void clear_bootstrap (void ) { +#ifdef CONFIG_PARAVIRT pte_t nullpte = { };int rc; +#else +pgentry_t *pgt; +#endif /* Use first page as the CoW zero page */ memset (&_text,0 ,PAGE_SIZE ); mfn_zero =virt_to_mfn ((unsigned long ) &_text); +#ifdef CONFIG_PARAVIRT if ( (rc =HYPERVISOR_update_va_mapping (0 , nullpte,UVMF_INVLPG )) )printk ("Unable to unmap NULL page. rc=%d\n" , rc); +#else + pgt =get_pgt ((unsigned long )&_text); + *pgt =0 ; +invlpg ((unsigned long )&_text); +#endif }#ifdef CONFIG_PARAVIRT
arch/x86/traps.c +10 -0
@@ -121,7 +121,9 @@ void page_walk(unsigned long virt_address)static int handle_cow (unsigned long addr) {pgentry_t *tab = pt_base, page;unsigned long new_page; +#ifdef CONFIG_PARAVIRT int rc; +#endif #if defined(__x86_64__) page = tab[l4_table_offset (addr)];
@@ -137,6 +139,8 @@ static int handle_cow(unsigned long addr) { page = tab[l2_table_offset (addr)];if (!(page & _PAGE_PRESENT))return 0 ; +if ( page & _PAGE_PSE ) +return 0 ; tab =pte_to_virt (page); page = tab[l1_table_offset (addr)];
@@ -149,12 +153,18 @@ static int handle_cow(unsigned long addr) { new_page =alloc_pages (0 );memset ((void *) new_page,0 ,PAGE_SIZE ); +#ifdef CONFIG_PARAVIRT rc =HYPERVISOR_update_va_mapping (addr &PAGE_MASK ,__pte (virt_to_mach (new_page) |L1_PROT ),UVMF_INVLPG );if (!rc)return 1 ;printk ("Map zero page to %lx failed: %d.\n" , addr, rc);return 0 ; +#else + tab[l1_table_offset (addr)] =virt_to_mach (new_page) |L1_PROT ; +invlpg (addr); +return 1 ; +#endif }static void do_stack_walk (unsigned long frame_base)
include/x86/arch_mm.h +4 -0
@@ -78,6 +78,8 @@#define L2_PAGETABLE_ENTRIES 512#define L3_PAGETABLE_ENTRIES 4 +#define PAGETABLE_LEVELS 3 +#define PADDR_BITS 44#define PADDR_MASK ((1ULL << PADDR_BITS)-1)
@@ -110,6 +112,8 @@ typedef uint64_t pgentry_t;#define L3_PAGETABLE_ENTRIES 512#define L4_PAGETABLE_ENTRIES 512 +#define PAGETABLE_LEVELS 4 +/* These are page-table limitations. Current CPUs support only 40-bit phys. */ #define PADDR_BITS 52#define VADDR_BITS 48
include/x86/os.h +9 -0
@@ -206,6 +206,15 @@ static inline int irqs_disabled(void)*/ typedef struct {volatile int counter; }atomic_t ; +static inline void write_cr3 (unsigned long cr3) +{ + asmvolatile ("mov %0, %%cr3" : :"r" (cr3) :"memory" ); +} + +static inline void invlpg (unsigned long va) +{ + asmvolatile ("invlpg %0" : :"m" (*(const char *)(va)) :"memory" ); +}/************************** i386 *******************************/ #ifdef __INSIDE_MINIOS__
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 12/22] mini-os: add x86 native page table handling
Quoted 4 lines · Juergen Gross, on Tue 23 Aug 2016 17:15:58 +0200, wrote:
For support of HVMlite don't use
mmu_updatehypercalls, but write the page table entries directly.Signed-off-by Juergen Gross <[email protected]>
Quoted 447 lines
--- arch/x86/mm.c | 147 +++++++++++++++++++++++++++++++++++++------------- arch/x86/traps.c | 10 ++++ include/x86/arch_mm.h | 4 ++ include/x86/os.h | 9 ++++ 4 files changed, 132 insertions(+), 38 deletions(-)arch/x86/mm.c +109
-38@@ -123,16 +123,25 @@ void arch_mm_preinit(void *p)* table at offset in previous level MFN (pref_l_mfn). pt_pfn is a guest * PFN. */ +static pgentry_t pt_prot[PAGETABLE_LEVELS ] = { +L1_PROT , +L2_PROT , +L3_PROT , +#if defined(__x86_64__) +L4_PROT , +#endif +}; +static void new_pt_frame (unsigned long *pt_pfn,unsigned long prev_l_mfn,unsigned long offset,unsigned long level) { -pgentry_t *tab = pt_base; +pgentry_t *tab;unsigned long pt_page = (unsigned long )pfn_to_virt (*pt_pfn); -pgentry_t prot_e, prot_t; +#ifdef CONFIG_PARAVIRT mmu_update_t mmu_updates[1 ];int rc; +#endif - prot_e = prot_t =0 ;DEBUG ("Allocating new L%d pt frame for pfn=%lx, " "prev_l_mfn=%lx, offset=%lx" , level, *pt_pfn, prev_l_mfn, offset);@@ -140,30 +149,12 @@ static void new_pt_frame(unsigned long *pt_pfn, unsigned long prev_l_mfn,/* We need to clear the page, otherwise we might fail to map it as a page table page */ memset ((void *) pt_page,0 ,PAGE_SIZE ); - -switch ( level ) - { -case L1_FRAME : - prot_e =L1_PROT ; - prot_t =L2_PROT ; -break ; -case L2_FRAME : - prot_e =L2_PROT ; - prot_t =L3_PROT ; -break ; -#if defined(__x86_64__) -case L3_FRAME : - prot_e =L3_PROT ; - prot_t =L4_PROT ; -break ; -#endif -default : -printk ("new_pt_frame() called with invalid level number %lu\n" , level); -do_exit (); -break ; - } +ASSERT (level >=1 && level <=PAGETABLE_LEVELS ); + +#ifdef CONFIG_PARAVIRT /* Make PFN a page table page */ + tab = pt_base;#if defined(__x86_64__) tab =pte_to_virt (tab[l4_table_offset (pt_page)]);#endif @@ -172,7 +163,7 @@ static void new_pt_frame(unsigned long *pt_pfn, unsigned long prev_l_mfn, mmu_updates[0 ].ptr = (tab[l2_table_offset (pt_page)] &PAGE_MASK ) +sizeof (pgentry_t) *l1_table_offset (pt_page); mmu_updates[0 ].val = (pgentry_t )pfn_to_mfn (*pt_pfn) <<PAGE_SHIFT | - (prot_e & ~_PAGE_RW); + (pt_prot[level -1 ] & ~_PAGE_RW);if ( (rc =HYPERVISOR_mmu_update (mmu_updates,1 ,NULL ,DOMID_SELF )) <0 ) {@@ -184,13 +175,18 @@ static void new_pt_frame(unsigned long *pt_pfn, unsigned long prev_l_mfn,/* Hook the new page table page into the hierarchy */ mmu_updates[0 ].ptr = ((pgentry_t )prev_l_mfn <<PAGE_SHIFT ) +sizeof (pgentry_t) * offset; - mmu_updates[0 ].val = (pgentry_t )pfn_to_mfn (*pt_pfn) <<PAGE_SHIFT | prot_t; + mmu_updates[0 ].val = (pgentry_t )pfn_to_mfn (*pt_pfn) <<PAGE_SHIFT | + pt_prot[level];if ( (rc =HYPERVISOR_mmu_update (mmu_updates,1 ,NULL ,DOMID_SELF )) <0 ) {printk ("ERROR: mmu_update failed with rc=%d\n" , rc);do_exit (); } +#else + tab =mfn_to_virt (prev_l_mfn); + tab[offset] = (*pt_pfn <<PAGE_SHIFT ) | pt_prot[level]; +#endif *pt_pfn +=1 ; }@@ -202,12 +198,14 @@ static void build_pagetable(unsigned long *start_pfn, unsigned long *max_pfn) {unsigned long start_address, end_address;unsigned long pfn_to_map, pt_pfn = *start_pfn; -static mmu_update_t mmu_updates[L1_PAGETABLE_ENTRIES +1 ];pgentry_t *tab = pt_base, page;unsigned long pt_mfn =pfn_to_mfn (virt_to_pfn (pt_base));unsigned long offset; +#ifdef CONFIG_PARAVIRT +static mmu_update_t mmu_updates[L1_PAGETABLE_ENTRIES +1 ];int count =0 ;int rc; +#endif /* Be conservative: even if we know there will be more pages already mapped, start the loop at the very beginning. */ @@ -225,6 +223,10 @@ static void build_pagetable(unsigned long *start_pfn, unsigned long *max_pfn) ((unsigned long )pfn_to_virt (*max_pfn) - (unsigned long)&_text)>>20); } +#else +/* Round up to next 2MB boundary as we are using 2MB pages on HVMlite. */ + pfn_to_map = (pfn_to_map +L1_PAGETABLE_ENTRIES -1 ) & + ~(L1_PAGETABLE_ENTRIES -1 );#endif start_address = (unsigned long )pfn_to_virt (pfn_to_map);@@ -257,6 +259,7 @@ static void build_pagetable(unsigned long *start_pfn, unsigned long *max_pfn) pt_mfn =pte_to_mfn (page); tab =to_virt (mfn_to_pfn (pt_mfn) <<PAGE_SHIFT ); offset =l2_table_offset (start_address); +#ifdef CONFIG_PARAVIRT /* Need new L1 pt frame */ if ( !(tab[offset] & _PAGE_PRESENT) )new_pt_frame (&pt_pfn, pt_mfn, offset,L1_FRAME );@@ -288,6 +291,12 @@ static void build_pagetable(unsigned long *start_pfn, unsigned long *max_pfn) count = 0; } start_address +=PAGE_SIZE ; +#else +if ( !(tab[offset] & _PAGE_PRESENT) ) + tab[offset] = (pgentry_t )pfn_to_map <<PAGE_SHIFT | +L2_PROT | _PAGE_PSE; + start_address +=1UL <<L2_PAGETABLE_SHIFT ; +#endif } *start_pfn = pt_pfn;@@ -302,16 +311,19 @@ static void set_readonly(void *text, void *etext)unsigned long start_address = ((unsigned long ) text +PAGE_SIZE -1 ) &PAGE_MASK ;unsigned long end_address = (unsigned long ) etext; -static mmu_update_t mmu_updates[L1_PAGETABLE_ENTRIES +1 ];pgentry_t *tab = pt_base, page;unsigned long mfn =pfn_to_mfn (virt_to_pfn (pt_base));unsigned long offset; +unsigned long page_size =PAGE_SIZE ; +#ifdef CONFIG_PARAVIRT +static mmu_update_t mmu_updates[L1_PAGETABLE_ENTRIES +1 ];int count =0 ;int rc; +#endif printk ("setting %p-%p readonly\n" , text, etext); -while ( start_address +PAGE_SIZE <= end_address ) +while ( start_address + page_size <= end_address ) { tab = pt_base; mfn =pfn_to_mfn (virt_to_pfn (pt_base));@@ -327,26 +339,34 @@ static void set_readonly(void *text, void *etext) mfn =pte_to_mfn (page); tab =to_virt (mfn_to_pfn (mfn) <<PAGE_SHIFT ); offset =l2_table_offset (start_address); - page = tab[offset]; - mfn =pte_to_mfn (page); - tab =to_virt (mfn_to_pfn (mfn) <<PAGE_SHIFT ); +if ( !(tab[offset] & _PAGE_PSE) ) + { + page = tab[offset]; + mfn =pte_to_mfn (page); + tab =to_virt (mfn_to_pfn (mfn) <<PAGE_SHIFT ); - offset =l1_table_offset (start_address); + offset =l1_table_offset (start_address); + }if ( start_address != (unsigned long )&shared_info ) { +#ifdef CONFIG_PARAVIRT mmu_updates[count].ptr = ((pgentry_t )mfn <<PAGE_SHIFT ) +sizeof (pgentry_t) * offset; mmu_updates[count].val = tab[offset] & ~_PAGE_RW; count++; +#else + tab[offset] &= ~_PAGE_RW; +#endif }else printk ("skipped %lx\n" , start_address); - start_address +=PAGE_SIZE ; + start_address += page_size; +#ifdef CONFIG_PARAVIRT if ( count ==L1_PAGETABLE_ENTRIES || - start_address +PAGE_SIZE > end_address ) + start_address + page_size > end_address ) { rc =HYPERVISOR_mmu_update (mmu_updates, count,NULL ,DOMID_SELF );if ( rc <0 )@@ -356,8 +376,13 @@ static void set_readonly(void *text, void *etext) } count =0 ; } +#else +if ( start_address == (1UL <<L2_PAGETABLE_SHIFT ) ) + page_size =1UL <<L2_PAGETABLE_SHIFT ; +#endif } +#ifdef CONFIG_PARAVIRT { mmuext_op_t op = { .cmd = MMUEXT_TLB_FLUSH_ALL,@@ -365,6 +390,9 @@ static void set_readonly(void *text, void *etext)int count; HYPERVISOR_mmuext_op(&op, 1, &count, DOMID_SELF); } +#else +write_cr3 ((unsigned long )pt_base); +#endif }/* @@ -394,6 +422,8 @@ static pgentry_t *get_pgt(unsigned long va) offset =l2_table_offset (va);if ( !(tab[offset] & _PAGE_PRESENT) )return NULL ; +if ( tab[offset] & _PAGE_PSE ) +return &tab[offset]; mfn =pte_to_mfn (tab[offset]); tab =mfn_to_virt (mfn); offset =l1_table_offset (va);@@ -448,6 +478,9 @@ pgentry_t *need_pgt(unsigned long va)new_pt_frame (&pt_pfn, pt_mfn, offset,L1_FRAME ); }ASSERT (tab[offset] & _PAGE_PRESENT); +if ( tab[offset] & _PAGE_PSE ) +return &tab[offset]; + pt_mfn =pte_to_mfn (tab[offset]); tab =mfn_to_virt (pt_mfn);@@ -524,8 +557,6 @@ int do_map_frames(unsigned long va, {pgentry_t *pgt =NULL ;unsigned long done =0 ; -unsigned long i; -int rc;if ( !mfns ) {@@ -539,6 +570,9 @@ int do_map_frames(unsigned long va,memset (err,0x00 , n *sizeof (int ));while ( done < n ) { +#ifdef CONFIG_PARAVIRT +unsigned long i; +int rc;unsigned long todo;if ( err )@@ -578,6 +612,17 @@ int do_map_frames(unsigned long va, } } done += todo; +#else +if ( !pgt || !(va &L1_MASK ) ) + pgt =need_pgt (va & ~L1_MASK ); +if ( !pgt ) +return -ENOMEM ; + +ASSERT (!(*pgt & _PAGE_PSE)); + pgt[l1_table_offset (va)] = (pgentry_t) + (((mfns[done * stride] + done * incr) <<PAGE_SHIFT ) | prot); + done++; +#endif }return 0 ;@@ -609,16 +654,21 @@ void *map_frames_ex(const unsigned long *mfns, unsigned long n,#define UNMAP_BATCH ((STACK_SIZE / 2) / sizeof(multicall_entry_t))int unmap_frames (unsigned long va,unsigned long num_frames) { +#ifdef CONFIG_PARAVIRT int n =UNMAP_BATCH ;multicall_entry_t call[n];int ret;int i; +#else +pgentry_t *pgt; +#endif ASSERT (!((unsigned long )va & ~PAGE_MASK ));DEBUG ("va=%p, num=0x%lx\n" , va, num_frames);while ( num_frames ) { +#ifdef CONFIG_PARAVIRT if ( n > num_frames ) n = num_frames;@@ -653,6 +703,17 @@ int unmap_frames(unsigned long va, unsigned long num_frames) } } num_frames -= n; +#else + pgt =get_pgt (va); +if ( pgt ) + { +ASSERT (!(*pgt & _PAGE_PSE)); + *pgt =0 ; +invlpg (va); + } + va +=PAGE_SIZE ; + num_frames--; +#endif }return 0 ; }@@ -662,14 +723,24 @@ int unmap_frames(unsigned long va, unsigned long num_frames)*/ static void clear_bootstrap (void ) { +#ifdef CONFIG_PARAVIRT pte_t nullpte = { };int rc; +#else +pgentry_t *pgt; +#endif /* Use first page as the CoW zero page */ memset (&_text,0 ,PAGE_SIZE ); mfn_zero =virt_to_mfn ((unsigned long ) &_text); +#ifdef CONFIG_PARAVIRT if ( (rc =HYPERVISOR_update_va_mapping (0 , nullpte,UVMF_INVLPG )) )printk ("Unable to unmap NULL page. rc=%d\n" , rc); +#else + pgt =get_pgt ((unsigned long )&_text); + *pgt =0 ; +invlpg ((unsigned long )&_text); +#endif }#ifdef CONFIG_PARAVIRT arch/x86/traps.c +10
-0@@ -121,7 +121,9 @@ void page_walk(unsigned long virt_address)static int handle_cow (unsigned long addr) {pgentry_t *tab = pt_base, page;unsigned long new_page; +#ifdef CONFIG_PARAVIRT int rc; +#endif #if defined(__x86_64__) page = tab[l4_table_offset (addr)];@@ -137,6 +139,8 @@ static int handle_cow(unsigned long addr) { page = tab[l2_table_offset (addr)];if (!(page & _PAGE_PRESENT))return 0 ; +if ( page & _PAGE_PSE ) +return 0 ; tab =pte_to_virt (page); page = tab[l1_table_offset (addr)];@@ -149,12 +153,18 @@ static int handle_cow(unsigned long addr) { new_page =alloc_pages (0 );memset ((void *) new_page,0 ,PAGE_SIZE ); +#ifdef CONFIG_PARAVIRT rc =HYPERVISOR_update_va_mapping (addr &PAGE_MASK ,__pte (virt_to_mach (new_page) |L1_PROT ),UVMF_INVLPG );if (!rc)return 1 ;printk ("Map zero page to %lx failed: %d.\n" , addr, rc);return 0 ; +#else + tab[l1_table_offset (addr)] =virt_to_mach (new_page) |L1_PROT ; +invlpg (addr); +return 1 ; +#endif }static void do_stack_walk (unsigned long frame_base)include/x86/arch_mm.h +4
-0@@ -78,6 +78,8 @@#define L2_PAGETABLE_ENTRIES 512#define L3_PAGETABLE_ENTRIES 4 +#define PAGETABLE_LEVELS 3 +#define PADDR_BITS 44#define PADDR_MASK ((1ULL << PADDR_BITS)-1)@@ -110,6 +112,8 @@ typedef uint64_t pgentry_t;#define L3_PAGETABLE_ENTRIES 512#define L4_PAGETABLE_ENTRIES 512 +#define PAGETABLE_LEVELS 4 +/* These are page-table limitations. Current CPUs support only 40-bit phys. */ #define PADDR_BITS 52#define VADDR_BITS 48include/x86/os.h +9
-0@@ -206,6 +206,15 @@ static inline int irqs_disabled(void)*/ typedef struct {volatile int counter; }atomic_t ; +static inline void write_cr3 (unsigned long cr3) +{ + asmvolatile ("mov %0, %%cr3" : :"r" (cr3) :"memory" ); +} + +static inline void invlpg (unsigned long va) +{ + asmvolatile ("invlpg %0" : :"m" (*(const char *)(va)) :"memory" ); +}/************************** i386 *******************************/ #ifdef __INSIDE_MINIOS__Signature · 1 line
2.6.6
Signature · 13 lines
Samuel /* Amuse the user. */ printk( " \\|/ ____ \\|/\n" " \"@'/ ,. \\`@\"\n" " /_| \\__/ |_\\\n" " \\__U_/\n"); (From linux/arch/sparc/kernel/traps.c:die_if_kernel()) _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Juergen Gross
maintainerPATCH 13/22 mini-os: correct wrong calculation of alloc bitmap size
In reply to Juergen GrossWhen remapping the page allocator's bitmap for the ballooning support the calculation of the needed size is wrong. This doesn't really matter today as nothing is allocated after that bitmap, but it should be corrected nevertheless.
--- balloon.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
balloon.c +2 -2
@@ -52,7 +52,7 @@ void mm_alloc_bitmap_remap(void) {unsigned long i; -if ( mm_alloc_bitmap_size >= ((nr_max_pages +1 ) >> (PAGE_SHIFT +3 )) ) +if ( mm_alloc_bitmap_size >= ((nr_max_pages +1 ) >>3 ) )return ;for ( i =0 ; i < mm_alloc_bitmap_size; i +=PAGE_SIZE )
@@ -62,7 +62,7 @@ void mm_alloc_bitmap_remap(void) } mm_alloc_bitmap = (unsigned long *)virt_kernel_area_end; - virt_kernel_area_end +=round_pgup ((nr_max_pages +1 ) >> (PAGE_SHIFT +3 )); + virt_kernel_area_end +=round_pgup ((nr_max_pages +1 ) >>3 );ASSERT (virt_kernel_area_end <=VIRT_DEMAND_AREA ); }
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 13/22] mini-os: correct wrong calculation of alloc bitmap size
Quoted 4 lines · Juergen Gross, on Tue 23 Aug 2016 17:15:59 +0200, wrote:
When remapping the page allocator's bitmap for the ballooning support the calculation of the needed size is wrong. This doesn't really matter today as nothing is allocated after that bitmap, but it should be corrected nevertheless.
Oops, indeed!
Quoted 1 line
Signed-off-by Juergen Gross <[email protected]>
Quoted 29 lines
--- balloon.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)balloon.c +2
-2@@ -52,7 +52,7 @@ void mm_alloc_bitmap_remap(void) {unsigned long i; -if ( mm_alloc_bitmap_size >= ((nr_max_pages +1 ) >> (PAGE_SHIFT +3 )) ) +if ( mm_alloc_bitmap_size >= ((nr_max_pages +1 ) >>3 ) )return ;for ( i =0 ; i < mm_alloc_bitmap_size; i +=PAGE_SIZE )@@ -62,7 +62,7 @@ void mm_alloc_bitmap_remap(void) } mm_alloc_bitmap = (unsigned long *)virt_kernel_area_end; - virt_kernel_area_end +=round_pgup ((nr_max_pages +1 ) >> (PAGE_SHIFT +3 )); + virt_kernel_area_end +=round_pgup ((nr_max_pages +1 ) >>3 );ASSERT (virt_kernel_area_end <=VIRT_DEMAND_AREA ); }Signature · 1 line
2.6.6
Signature · 14 lines
Samuel /* * [...] Note that 120 sec is defined in the protocol as the maximum * possible RTT. I guess we'll have to use something other than TCP * to talk to the University of Mars. * PAWS allows us longer timeouts and large windows, so once implemented * ftp to mars will work nicely. */ (from /usr/src/linux/net/inet/tcp.c, concerning RTT [retransmission timeout]) _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Juergen Gross
maintainerPATCH 14/22 mini-os: add map_frame_virt() function
In reply to Juergen GrossAdd a function map_frame_virt() to map a given frame and return its virtual address.
On arm we just use the frame physical address, while on x86 we take a page from the virtual kernel area. For this purpose make this area available even in case of undefined CONFIG_BALLOON.
--- arch/arm/balloon.c | 2 -- arch/arm/mm.c | 5 +++++ arch/x86/balloon.c | 13 ++++--------- arch/x86/mm.c | 23 +++++++++++++++++++++++ balloon.c | 9 ++++----- include/balloon.h | 1 - include/mm.h | 1 + include/x86/arch_mm.h | 1 + 8 files changed, 38 insertions(+), 17 deletions(-)
arch/arm/balloon.c +0 -2
@@ -25,8 +25,6 @@#ifdef CONFIG_BALLOON -unsigned long virt_kernel_area_end;/* TODO: find a virtual area */ -void arch_pfn_add (unsigned long pfn,unsigned long mfn) { }
arch/arm/mm.c +5 -0
@@ -141,3 +141,8 @@ grant_entry_t *arch_init_gnttab(int nr_grant_frames)return to_virt (gnttab_table); } + +unsigned long map_frame_virt (unsigned long mfn) +{ +return mfn_to_virt (mfn); +}
arch/x86/balloon.c +4 -9
@@ -29,9 +29,6 @@#include <mini-os/paravirt.h> #ifdef CONFIG_BALLOON - -unsigned long virt_kernel_area_end = VIRT_KERNEL_AREA; - #ifdef CONFIG_PARAVIRT static void p2m_invalidate(unsigned long *list, unsigned long start_idx) {
@@ -53,7 +50,7 @@ static inline unsigned long *p2m_to_virt(unsigned long p2m)void arch_remap_p2m (unsigned long max_pfn) { -unsigned long pfn; +unsigned long pfn, new_p2m;unsigned long *l3_list, *l2_list, *l1_list; l3_list =p2m_l3list ();
@@ -67,17 +64,15 @@ void arch_remap_p2m(unsigned long max_pfn)if (p2m_pages (nr_max_pages) <=p2m_pages (max_pfn) )return ; + new_p2m =alloc_virt_kernel (p2m_pages (nr_max_pages));for ( pfn =0 ; pfn < max_pfn; pfn +=P2M_ENTRIES ) { -map_frame_rw (virt_kernel_area_end +PAGE_SIZE * (pfn /P2M_ENTRIES ), +map_frame_rw (new_p2m +PAGE_SIZE * (pfn /P2M_ENTRIES ),virt_to_mfn (phys_to_machine_mapping + pfn)); } - phys_to_machine_mapping = (unsigned long *)virt_kernel_area_end; + phys_to_machine_mapping = (unsigned long *)new_p2m;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 ); }int arch_expand_p2m (unsigned long max_pfn)
arch/x86/mm.c +23 -0
@@ -57,6 +57,7 @@ unsigned long mfn_zero;pgentry_t *pt_base;static unsigned long first_free_pfn;static unsigned long last_free_pfn; +static unsigned long virt_kernel_area_end =VIRT_KERNEL_AREA ;extern char stack[];extern void page_walk (unsigned long va);
@@ -829,3 +830,25 @@ grant_entry_t *arch_init_gnttab(int nr_grant_frames)HYPERVISOR_grant_table_op (GNTTABOP_setup_table, &setup,1 );return map_frames (frames, nr_grant_frames); } + +unsigned long alloc_virt_kernel (unsigned n_pages) +{ +unsigned long addr; + + addr = virt_kernel_area_end; + virt_kernel_area_end +=PAGE_SIZE * n_pages; +ASSERT (virt_kernel_area_end <=VIRT_DEMAND_AREA ); + +return addr; +} + +unsigned long map_frame_virt (unsigned long mfn) +{ +unsigned long addr; + + addr =alloc_virt_kernel (1 ); +if (map_frame_rw (addr, mfn) ) +return 0 ; + +return addr; +}
balloon.c +4 -5
@@ -50,20 +50,19 @@ void get_max_pages(void)void mm_alloc_bitmap_remap (void ) { -unsigned long i; +unsigned long i, new_bitmap;if ( mm_alloc_bitmap_size >= ((nr_max_pages +1 ) >>3 ) )return ; + new_bitmap =alloc_virt_kernel (PFN_UP ((nr_max_pages +1 ) >>3 ));for ( i =0 ; i < mm_alloc_bitmap_size; i +=PAGE_SIZE ) { -map_frame_rw (virt_kernel_area_end + i, +map_frame_rw (new_bitmap + i,virt_to_mfn ((unsigned long )(mm_alloc_bitmap) + i)); } - mm_alloc_bitmap = (unsigned long *)virt_kernel_area_end; - virt_kernel_area_end +=round_pgup ((nr_max_pages +1 ) >>3 ); -ASSERT (virt_kernel_area_end <=VIRT_DEMAND_AREA ); + mm_alloc_bitmap = (unsigned long *)new_bitmap; }#define N_BALLOON_FRAMES 64
include/balloon.h +0 -1
@@ -33,7 +33,6 @@#define BALLOON_EMERGENCY_PAGES 64extern unsigned long nr_max_pages; -extern unsigned long virt_kernel_area_end;extern unsigned long nr_mem_pages;void get_max_pages (void );
include/mm.h +1 -0
@@ -79,6 +79,7 @@ int do_map_frames(unsigned long addr, 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); +unsigned long map_frame_virt (unsigned long mfn);#ifdef HAVE_LIBC extern unsigned long heap, brk, heap_mapped, heap_end;#endif
include/x86/arch_mm.h +1 -0
@@ -277,6 +277,7 @@ static __inline__ paddr_t machine_to_phys(maddr_t machine)pgentry_t *need_pgt (unsigned long addr);void arch_mm_preinit (void *p); +unsigned long alloc_virt_kernel (unsigned n_pages);#endif
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 14/22] mini-os: add map_frame_virt() function
Quoted 8 lines · Juergen Gross, on Tue 23 Aug 2016 17:16:00 +0200, wrote:
Add a function
map_frame_virt()to map a given frame and return its virtual address.On arm we just use the frame physical address, while on x86 we take a page from the virtual kernel area. For this purpose make this area available even in case of undefined
CONFIG_BALLOON.Signed-off-by Juergen Gross <[email protected]>
Quoted 187 lines
--- arch/arm/balloon.c | 2 -- arch/arm/mm.c | 5 +++++ arch/x86/balloon.c | 13 ++++--------- arch/x86/mm.c | 23 +++++++++++++++++++++++ balloon.c | 9 ++++----- include/balloon.h | 1 - include/mm.h | 1 + include/x86/arch_mm.h | 1 + 8 files changed, 38 insertions(+), 17 deletions(-)arch/arm/balloon.c +0
-2@@ -25,8 +25,6 @@#ifdef CONFIG_BALLOON -unsigned long virt_kernel_area_end;/* TODO: find a virtual area */ -void arch_pfn_add (unsigned long pfn,unsigned long mfn) { }arch/arm/mm.c +5
-0@@ -141,3 +141,8 @@ grant_entry_t *arch_init_gnttab(int nr_grant_frames)return to_virt (gnttab_table); } + +unsigned long map_frame_virt (unsigned long mfn) +{ +return mfn_to_virt (mfn); +}arch/x86/balloon.c +4
-9@@ -29,9 +29,6 @@#include <mini-os/paravirt.h> #ifdef CONFIG_BALLOON - -unsigned long virt_kernel_area_end = VIRT_KERNEL_AREA; - #ifdef CONFIG_PARAVIRT static void p2m_invalidate(unsigned long *list, unsigned long start_idx) {@@ -53,7 +50,7 @@ static inline unsigned long *p2m_to_virt(unsigned long p2m)void arch_remap_p2m (unsigned long max_pfn) { -unsigned long pfn; +unsigned long pfn, new_p2m;unsigned long *l3_list, *l2_list, *l1_list; l3_list =p2m_l3list ();@@ -67,17 +64,15 @@ void arch_remap_p2m(unsigned long max_pfn)if (p2m_pages (nr_max_pages) <=p2m_pages (max_pfn) )return ; + new_p2m =alloc_virt_kernel (p2m_pages (nr_max_pages));for ( pfn =0 ; pfn < max_pfn; pfn +=P2M_ENTRIES ) { -map_frame_rw (virt_kernel_area_end +PAGE_SIZE * (pfn /P2M_ENTRIES ), +map_frame_rw (new_p2m +PAGE_SIZE * (pfn /P2M_ENTRIES ),virt_to_mfn (phys_to_machine_mapping + pfn)); } - phys_to_machine_mapping = (unsigned long *)virt_kernel_area_end; + phys_to_machine_mapping = (unsigned long *)new_p2m;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 ); }int arch_expand_p2m (unsigned long max_pfn)arch/x86/mm.c +23
-0@@ -57,6 +57,7 @@ unsigned long mfn_zero;pgentry_t *pt_base;static unsigned long first_free_pfn;static unsigned long last_free_pfn; +static unsigned long virt_kernel_area_end =VIRT_KERNEL_AREA ;extern char stack[];extern void page_walk (unsigned long va);@@ -829,3 +830,25 @@ grant_entry_t *arch_init_gnttab(int nr_grant_frames)HYPERVISOR_grant_table_op (GNTTABOP_setup_table, &setup,1 );return map_frames (frames, nr_grant_frames); } + +unsigned long alloc_virt_kernel (unsigned n_pages) +{ +unsigned long addr; + + addr = virt_kernel_area_end; + virt_kernel_area_end +=PAGE_SIZE * n_pages; +ASSERT (virt_kernel_area_end <=VIRT_DEMAND_AREA ); + +return addr; +} + +unsigned long map_frame_virt (unsigned long mfn) +{ +unsigned long addr; + + addr =alloc_virt_kernel (1 ); +if (map_frame_rw (addr, mfn) ) +return 0 ; + +return addr; +}balloon.c +4
-5@@ -50,20 +50,19 @@ void get_max_pages(void)void mm_alloc_bitmap_remap (void ) { -unsigned long i; +unsigned long i, new_bitmap;if ( mm_alloc_bitmap_size >= ((nr_max_pages +1 ) >>3 ) )return ; + new_bitmap =alloc_virt_kernel (PFN_UP ((nr_max_pages +1 ) >>3 ));for ( i =0 ; i < mm_alloc_bitmap_size; i +=PAGE_SIZE ) { -map_frame_rw (virt_kernel_area_end + i, +map_frame_rw (new_bitmap + i,virt_to_mfn ((unsigned long )(mm_alloc_bitmap) + i)); } - mm_alloc_bitmap = (unsigned long *)virt_kernel_area_end; - virt_kernel_area_end +=round_pgup ((nr_max_pages +1 ) >>3 ); -ASSERT (virt_kernel_area_end <=VIRT_DEMAND_AREA ); + mm_alloc_bitmap = (unsigned long *)new_bitmap; }#define N_BALLOON_FRAMES 64include/balloon.h +0
-1@@ -33,7 +33,6 @@#define BALLOON_EMERGENCY_PAGES 64extern unsigned long nr_max_pages; -extern unsigned long virt_kernel_area_end;extern unsigned long nr_mem_pages;void get_max_pages (void );include/mm.h +1
-0@@ -79,6 +79,7 @@ int do_map_frames(unsigned long addr, 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); +unsigned long map_frame_virt (unsigned long mfn);#ifdef HAVE_LIBC extern unsigned long heap, brk, heap_mapped, heap_end;#endif include/x86/arch_mm.h +1
-0@@ -277,6 +277,7 @@ static __inline__ paddr_t machine_to_phys(maddr_t machine)pgentry_t *need_pgt (unsigned long addr);void arch_mm_preinit (void *p); +unsigned long alloc_virt_kernel (unsigned n_pages);#endif Signature · 1 line
2.6.6
Signature · 11 lines
Samuel After watching my newly-retired dad spend two weeks learning how to make a new folder, it became obvious that "intuitive" mostly means "what the writer or speaker of intuitive likes". (Bruce Ediger, [email protected], in comp.os.linux.misc, on X the intuitiveness of a Mac interface.) _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Juergen Gross
maintainerPATCH 15/22 mini-os: setup console interface parameters
In reply to Juergen GrossIn order to support HVMlite we need to get the ring page and event channel from the hypervisor via hypercalls. Move the already existing get_console() function from arm specific coding to console/xencons_ring.c and provide a similar paravirtualized function.
--- arch/arm/setup.c | 16 +--------------- arch/x86/setup.c | 1 + console/xencons_ring.c | 38 ++++++++++++++++++++++++++++++-------- events.c | 2 +- include/console.h | 3 ++- 5 files changed, 35 insertions(+), 25 deletions(-)
arch/arm/setup.c +1 -15
@@ -25,20 +25,6 @@ extern char shared_info_page[PAGE_SIZE];void *device_tree; -static void get_console (void ) -{ -uint64_t v =-1 ; - -hvm_get_parameter (HVM_PARAM_CONSOLE_EVTCHN , &v); - start_info.console.domU.evtchn = v; - -hvm_get_parameter (HVM_PARAM_CONSOLE_PFN , &v); - start_info.console.domU.mfn = v; - -printk ("Console is on port %d\n" , start_info.console.domU.evtchn); -printk ("Console ring is at mfn %lx\n" , (unsigned long ) start_info.console.domU.mfn); -} -void get_xenbus (void ) {uint64_t value;
@@ -85,7 +71,7 @@ void arch_init(void *dtb_pointer, uint32_t physical_offset) HYPERVISOR_shared_info = (struct shared_info *)shared_info_page;/* Fill in start_info */ -get_console (); +get_console (NULL );get_xenbus ();gic_init ();
arch/x86/setup.c +1 -0
@@ -137,6 +137,7 @@ arch_init(void *par)/* Copy the start_info struct to a globally-accessible area. */ /* WARN: don't do printk before here, it uses information from shared_info. Use xprintk instead. */ +get_console (par); si = par;memcpy (&start_info, si,sizeof (*si));
console/xencons_ring.c +30 -8
@@ -9,27 +9,49 @@#include <xen/io/console.h> #include <xen/io/protocols.h> #include <xen/io/ring.h> +#include <xen/hvm/params.h> #include <mini-os/xmalloc.h> #include <mini-os/gnttab.h> #include "console.h" DECLARE_WAIT_QUEUE_HEAD (console_queue); +static struct xencons_interface *console_ring; +uint32_t console_evtchn; + +#ifdef CONFIG_PARAVIRT +void get_console (void *p) +{ +start_info_t *si = p; + + console_ring =mfn_to_virt (si->console.domU.mfn); + console_evtchn = si->console.domU.evtchn; +} +#else +void get_console (void *p) +{ +uint64_t v =-1 ; + +hvm_get_parameter (HVM_PARAM_CONSOLE_EVTCHN , &v); + console_evtchn = v; + +hvm_get_parameter (HVM_PARAM_CONSOLE_PFN , &v); + console_ring = (struct xencons_interface *)map_frame_virt (v); +} +#endif +static inline void notify_daemon (struct consfront_dev *dev) {/* Use evtchn: this is called early, before irq is set up. */ if (!dev) -notify_remote_via_evtchn (start_info.console.domU.evtchn); +notify_remote_via_evtchn (console_evtchn);else notify_remote_via_evtchn (dev->evtchn); }static inline struct xencons_interface *xencons_interface (void ) { -if (start_info.console.domU.evtchn) -return mfn_to_virt (start_info.console.domU.mfn); -else -return NULL ; +return console_evtchn ? console_ring :NULL ; }int xencons_ring_send_no_notify (struct consfront_dev *dev,const char *data,unsigned len)
@@ -158,7 +180,7 @@ struct consfront_dev *xencons_ring_init(void)int err;struct consfront_dev *dev; -if (!start_info.console.domU.evtchn) +if (!console_evtchn)return 0 ; dev =malloc (sizeof (struct consfront_dev ));
@@ -171,8 +193,8 @@ struct consfront_dev *xencons_ring_init(void)#ifdef HAVE_LIBC dev->fd =-1 ;#endif - dev->evtchn = start_info.console.domU.evtchn; - dev->ring = (struct xencons_interface *)mfn_to_virt (start_info.console.domU.mfn); + dev->evtchn = console_evtchn; + dev->ring =xencons_interface (); err =bind_evtchn (dev->evtchn, console_handle_input, dev);if (err <=0 ) {
events.c +1 -1
@@ -46,7 +46,7 @@ void unbind_all_ports(void)for ( i =0 ; i <NR_EVS ; i++ ) { -if ( i == start_info.console.domU.evtchn || +if ( i == console_evtchn || i == start_info.store_evtchn)continue ;
include/console.h +2 -1
@@ -61,7 +61,7 @@ struct consfront_dev {#endif }; - +extern uint32_t console_evtchn;void int direct,const char *fmt,va_list args);void printk (const char *fmt, ...) __attribute__ ((format (printf,1 ,2 )));
@@ -72,6 +72,7 @@ void xprintk(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));void xencons_rx (char *buf,unsigned len,struct pt_regs *regs);void xencons_tx (void ); +void get_console (void *p);void init_console (void );void console_print (struct consfront_dev *dev,char *data,int length);void fini_console (struct consfront_dev *dev);
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 15/22] mini-os: setup console interface parameters
Quoted 6 lines · Juergen Gross, on Tue 23 Aug 2016 17:16:01 +0200, wrote:
In order to support HVMlite we need to get the ring page and event channel from the hypervisor via hypercalls. Move the already existing
get_console()function from arm specific coding toconsole/xencons_ring.cand provide a similar paravirtualized function.Signed-off-by Juergen Gross <[email protected]>
Quoted 170 lines
--- arch/arm/setup.c | 16 +--------------- arch/x86/setup.c | 1 + console/xencons_ring.c | 38 ++++++++++++++++++++++++++++++-------- events.c | 2 +- include/console.h | 3 ++- 5 files changed, 35 insertions(+), 25 deletions(-)arch/arm/setup.c +1
-15@@ -25,20 +25,6 @@ extern char shared_info_page[PAGE_SIZE];void *device_tree; -static void get_console (void ) -{ -uint64_t v =-1 ; - -hvm_get_parameter (HVM_PARAM_CONSOLE_EVTCHN , &v); - start_info.console.domU.evtchn = v; - -hvm_get_parameter (HVM_PARAM_CONSOLE_PFN , &v); - start_info.console.domU.mfn = v; - -printk ("Console is on port %d\n" , start_info.console.domU.evtchn); -printk ("Console ring is at mfn %lx\n" , (unsigned long ) start_info.console.domU.mfn); -} -void get_xenbus (void ) {uint64_t value;@@ -85,7 +71,7 @@ void arch_init(void *dtb_pointer, uint32_t physical_offset) HYPERVISOR_shared_info = (struct shared_info *)shared_info_page;/* Fill in start_info */ -get_console (); +get_console (NULL );get_xenbus ();gic_init ();arch/x86/setup.c +1
-0@@ -137,6 +137,7 @@ arch_init(void *par)/* Copy the start_info struct to a globally-accessible area. */ /* WARN: don't do printk before here, it uses information from shared_info. Use xprintk instead. */ +get_console (par); si = par;memcpy (&start_info, si,sizeof (*si));console/xencons_ring.c +30
-8@@ -9,27 +9,49 @@#include <xen/io/console.h> #include <xen/io/protocols.h> #include <xen/io/ring.h> +#include <xen/hvm/params.h> #include <mini-os/xmalloc.h> #include <mini-os/gnttab.h> #include "console.h" DECLARE_WAIT_QUEUE_HEAD (console_queue); +static struct xencons_interface *console_ring; +uint32_t console_evtchn; + +#ifdef CONFIG_PARAVIRT +void get_console (void *p) +{ +start_info_t *si = p; + + console_ring =mfn_to_virt (si->console.domU.mfn); + console_evtchn = si->console.domU.evtchn; +} +#else +void get_console (void *p) +{ +uint64_t v =-1 ; + +hvm_get_parameter (HVM_PARAM_CONSOLE_EVTCHN , &v); + console_evtchn = v; + +hvm_get_parameter (HVM_PARAM_CONSOLE_PFN , &v); + console_ring = (struct xencons_interface *)map_frame_virt (v); +} +#endif +static inline void notify_daemon (struct consfront_dev *dev) {/* Use evtchn: this is called early, before irq is set up. */ if (!dev) -notify_remote_via_evtchn (start_info.console.domU.evtchn); +notify_remote_via_evtchn (console_evtchn);else notify_remote_via_evtchn (dev->evtchn); }static inline struct xencons_interface *xencons_interface (void ) { -if (start_info.console.domU.evtchn) -return mfn_to_virt (start_info.console.domU.mfn); -else -return NULL ; +return console_evtchn ? console_ring :NULL ; }int xencons_ring_send_no_notify (struct consfront_dev *dev,const char *data,unsigned len)@@ -158,7 +180,7 @@ struct consfront_dev *xencons_ring_init(void)int err;struct consfront_dev *dev; -if (!start_info.console.domU.evtchn) +if (!console_evtchn)return 0 ; dev =malloc (sizeof (struct consfront_dev ));@@ -171,8 +193,8 @@ struct consfront_dev *xencons_ring_init(void)#ifdef HAVE_LIBC dev->fd =-1 ;#endif - dev->evtchn = start_info.console.domU.evtchn; - dev->ring = (struct xencons_interface *)mfn_to_virt (start_info.console.domU.mfn); + dev->evtchn = console_evtchn; + dev->ring =xencons_interface (); err =bind_evtchn (dev->evtchn, console_handle_input, dev);if (err <=0 ) {events.c +1
-1@@ -46,7 +46,7 @@ void unbind_all_ports(void)for ( i =0 ; i <NR_EVS ; i++ ) { -if ( i == start_info.console.domU.evtchn || +if ( i == console_evtchn || i == start_info.store_evtchn)continue ;include/console.h +2
-1@@ -61,7 +61,7 @@ struct consfront_dev {#endif }; - +extern uint32_t console_evtchn;void int direct,const char *fmt,va_list args);void printk (const char *fmt, ...) __attribute__ ((format (printf,1 ,2 )));@@ -72,6 +72,7 @@ void xprintk(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));void xencons_rx (char *buf,unsigned len,struct pt_regs *regs);void xencons_tx (void ); +void get_console (void *p);void init_console (void );void console_print (struct consfront_dev *dev,char *data,int length);void fini_console (struct consfront_dev *dev);Signature · 1 line
2.6.6
Signature · 13 lines
Samuel /* Amuse the user. */ printk( " \\|/ ____ \\|/\n" " \"@'/ ,. \\`@\"\n" " /_| \\__/ |_\\\n" " \\__U_/\n"); (From linux/arch/sparc/kernel/traps.c:die_if_kernel()) _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Juergen Gross
maintainerPATCH 16/22 mini-os: setup xenbus interface parameters
In reply to Juergen GrossIn order to support HVMlite we need to get the ring page and event channel from the hypervisor via hypercalls. Move the already existing get_xenbus() function from arm specific coding to xenbus/xenbus.c and provide a similar paravirtualized function.
--- arch/arm/setup.c | 16 +--------------- arch/x86/setup.c | 1 + events.c | 3 +-- include/xenbus.h | 3 +++ xenbus/xenbus.c | 40 +++++++++++++++++++++++++++++++--------- 5 files changed, 37 insertions(+), 26 deletions(-)
arch/arm/setup.c +1 -15
@@ -25,20 +25,6 @@ extern char shared_info_page[PAGE_SIZE];void *device_tree; -void get_xenbus (void ) -{ -uint64_t value; - -if (hvm_get_parameter (HVM_PARAM_STORE_EVTCHN , &value)) -BUG (); - - start_info.store_evtchn = (int )value; - -if (hvm_get_parameter (HVM_PARAM_STORE_PFN , &value)) -BUG (); - start_info.store_mfn = (unsigned long )value; -} -/* * INITIAL C ENTRY POINT. */
@@ -72,7 +58,7 @@ void arch_init(void *dtb_pointer, uint32_t physical_offset)/* Fill in start_info */ get_console (NULL ); -get_xenbus (); +get_xenbus (NULL );gic_init ();
arch/x86/setup.c +1 -0
@@ -138,6 +138,7 @@ arch_init(void *par)/* WARN: don't do printk before here, it uses information from shared_info. Use xprintk instead. */ get_console (par); +get_xenbus (par); si = par;memcpy (&start_info, si,sizeof (*si));
events.c +1 -2
@@ -46,8 +46,7 @@ void unbind_all_ports(void)for ( i =0 ; i <NR_EVS ; i++ ) { -if ( i == console_evtchn || - i == start_info.store_evtchn) +if ( i == console_evtchn || i == xenbus_evtchn )continue ;if (test_and_clear_bit (i, bound_ports) )
include/xenbus.h +3 -0
@@ -29,6 +29,9 @@ struct xenbus_event { };typedef struct xenbus_event *xenbus_event_queue ; +extern uint32_t xenbus_evtchn; + +void get_xenbus (void *p);char *xenbus_watch_path_token (xenbus_transaction_t xbt,const char *path,const char *token,xenbus_event_queue *events);char *xenbus_unwatch_path_token (xenbus_transaction_t xbt,const char *path,const char *token);extern struct wait_queue_head xenbus_watch_queue;
xenbus/xenbus.c +31 -9
@@ -26,6 +26,7 @@#include <mini-os/sched.h> #include <mini-os/wait.h> #include <xen/io/xs_wire.h> +#include <xen/hvm/params.h> #include <mini-os/spinlock.h> #include <mini-os/xmalloc.h>
@@ -62,6 +63,31 @@ struct xenbus_req_info#define NR_REQS 32static struct xenbus_req_info req_info[NR_REQS ]; +uint32_t xenbus_evtchn; + +#ifdef CONFIG_PARAVIRT +void get_xenbus (void *p) +{ +start_info_t *si = p; + + xenbus_evtchn = si->store_evtchn; + xenstore_buf =mfn_to_virt (si->store_mfn); +} +#else +void get_xenbus (void *p) +{ +uint64_t v; + +if (hvm_get_parameter (HVM_PARAM_STORE_EVTCHN , &v) ) +BUG (); + xenbus_evtchn = v; + +if (hvm_get_parameter (HVM_PARAM_STORE_PFN , &v) ) +BUG (); + xenstore_buf = (struct xenstore_domain_interface *)map_frame_virt (v); +} +#endif + static void memcpy_from_ring(const void *Ring, void *Dest, int off,
@@ -269,7 +295,7 @@ static void xenbus_thread_func(void *ign) }wmb (); -notify_remote_via_evtchn (start_info.store_evtchn); +notify_remote_via_evtchn (xenbus_evtchn); } } }
@@ -335,15 +361,11 @@ void init_xenbus(void) {int err;DEBUG ("init_xenbus called.\n" ); - xenstore_buf =mfn_to_virt (start_info.store_mfn);create_thread ("xenstore" , xenbus_thread_func,NULL );DEBUG ("buf at %p.\n" , xenstore_buf); - err =bind_evtchn (start_info.store_evtchn, - xenbus_evtchn_handler, -NULL ); -unmask_evtchn (start_info.store_evtchn); -printk ("xenbus initialised on irq %d mfn %#llx\n" , - err, (unsigned long long ) start_info.store_mfn); + err =bind_evtchn (xenbus_evtchn, xenbus_evtchn_handler,NULL ); +unmask_evtchn (xenbus_evtchn); +printk ("xenbus initialised on irq %d\n" , err); }void fini_xenbus (void )
@@ -425,7 +447,7 @@ static void xb_write(int type, int req_id, xenbus_transaction_t trans_id, xenstore_buf->req_prod += len;/* Send evtchn to notify remote */ -notify_remote_via_evtchn (start_info.store_evtchn); +notify_remote_via_evtchn (xenbus_evtchn); }/* Send a mesasge to xenbus, in the same fashion as xb_write, and
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 16/22] mini-os: setup xenbus interface parameters
Quoted 6 lines · Juergen Gross, on Tue 23 Aug 2016 17:16:02 +0200, wrote:
In order to support HVMlite we need to get the ring page and event channel from the hypervisor via hypercalls. Move the already existing
get_xenbus()function from arm specific coding toxenbus/xenbus.cand provide a similar paravirtualized function.Signed-off-by Juergen Gross <[email protected]>
Quoted 166 lines
--- arch/arm/setup.c | 16 +--------------- arch/x86/setup.c | 1 + events.c | 3 +-- include/xenbus.h | 3 +++ xenbus/xenbus.c | 40 +++++++++++++++++++++++++++++++--------- 5 files changed, 37 insertions(+), 26 deletions(-)arch/arm/setup.c +1
-15@@ -25,20 +25,6 @@ extern char shared_info_page[PAGE_SIZE];void *device_tree; -void get_xenbus (void ) -{ -uint64_t value; - -if (hvm_get_parameter (HVM_PARAM_STORE_EVTCHN , &value)) -BUG (); - - start_info.store_evtchn = (int )value; - -if (hvm_get_parameter (HVM_PARAM_STORE_PFN , &value)) -BUG (); - start_info.store_mfn = (unsigned long )value; -} -/* * INITIAL C ENTRY POINT. */ @@ -72,7 +58,7 @@ void arch_init(void *dtb_pointer, uint32_t physical_offset)/* Fill in start_info */ get_console (NULL ); -get_xenbus (); +get_xenbus (NULL );gic_init ();arch/x86/setup.c +1
-0@@ -138,6 +138,7 @@ arch_init(void *par)/* WARN: don't do printk before here, it uses information from shared_info. Use xprintk instead. */ get_console (par); +get_xenbus (par); si = par;memcpy (&start_info, si,sizeof (*si));events.c +1
-2@@ -46,8 +46,7 @@ void unbind_all_ports(void)for ( i =0 ; i <NR_EVS ; i++ ) { -if ( i == console_evtchn || - i == start_info.store_evtchn) +if ( i == console_evtchn || i == xenbus_evtchn )continue ;if (test_and_clear_bit (i, bound_ports) )include/xenbus.h +3
-0@@ -29,6 +29,9 @@ struct xenbus_event { };typedef struct xenbus_event *xenbus_event_queue ; +extern uint32_t xenbus_evtchn; + +void get_xenbus (void *p);char *xenbus_watch_path_token (xenbus_transaction_t xbt,const char *path,const char *token,xenbus_event_queue *events);char *xenbus_unwatch_path_token (xenbus_transaction_t xbt,const char *path,const char *token);extern struct wait_queue_head xenbus_watch_queue;xenbus/xenbus.c +31
-9@@ -26,6 +26,7 @@#include <mini-os/sched.h> #include <mini-os/wait.h> #include <xen/io/xs_wire.h> +#include <xen/hvm/params.h> #include <mini-os/spinlock.h> #include <mini-os/xmalloc.h> @@ -62,6 +63,31 @@ struct xenbus_req_info#define NR_REQS 32static struct xenbus_req_info req_info[NR_REQS ]; +uint32_t xenbus_evtchn; + +#ifdef CONFIG_PARAVIRT +void get_xenbus (void *p) +{ +start_info_t *si = p; + + xenbus_evtchn = si->store_evtchn; + xenstore_buf =mfn_to_virt (si->store_mfn); +} +#else +void get_xenbus (void *p) +{ +uint64_t v; + +if (hvm_get_parameter (HVM_PARAM_STORE_EVTCHN , &v) ) +BUG (); + xenbus_evtchn = v; + +if (hvm_get_parameter (HVM_PARAM_STORE_PFN , &v) ) +BUG (); + xenstore_buf = (struct xenstore_domain_interface *)map_frame_virt (v); +} +#endif + static void memcpy_from_ring(const void *Ring, void *Dest, int off,@@ -269,7 +295,7 @@ static void xenbus_thread_func(void *ign) }wmb (); -notify_remote_via_evtchn (start_info.store_evtchn); +notify_remote_via_evtchn (xenbus_evtchn); } } }@@ -335,15 +361,11 @@ void init_xenbus(void) {int err;DEBUG ("init_xenbus called.\n" ); - xenstore_buf =mfn_to_virt (start_info.store_mfn);create_thread ("xenstore" , xenbus_thread_func,NULL );DEBUG ("buf at %p.\n" , xenstore_buf); - err =bind_evtchn (start_info.store_evtchn, - xenbus_evtchn_handler, -NULL ); -unmask_evtchn (start_info.store_evtchn); -printk ("xenbus initialised on irq %d mfn %#llx\n" , - err, (unsigned long long ) start_info.store_mfn); + err =bind_evtchn (xenbus_evtchn, xenbus_evtchn_handler,NULL ); +unmask_evtchn (xenbus_evtchn); +printk ("xenbus initialised on irq %d\n" , err); }void fini_xenbus (void )@@ -425,7 +447,7 @@ static void xb_write(int type, int req_id, xenbus_transaction_t trans_id, xenstore_buf->req_prod += len;/* Send evtchn to notify remote */ -notify_remote_via_evtchn (start_info.store_evtchn); +notify_remote_via_evtchn (xenbus_evtchn); }/* Send a mesasge to xenbus, in the same fashion as xb_write, and Signature · 1 line
2.6.6
Signature · 8 lines
Samuel "...[Linux's] capacity to talk via any medium except smoke signals." (By Dr. Greg Wettstein, Roger Maris Cancer Center) _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Juergen Gross
maintainerPATCH 17/22 mini-os: add get_cmdline() function
In reply to Juergen GrossThe command line parameters are passed in start_info structure for pv, but via hvm_start_info for HVMlite. Add a generic function to fill a local cmdline variable with the command line string.
--- arch/x86/setup.c | 20 ++++++++++++++++++-- include/kernel.h | 3 +++ kernel.c | 1 + main.c | 5 +++-- 4 files changed, 25 insertions(+), 4 deletions(-)
arch/x86/setup.c +18 -2
@@ -31,6 +31,7 @@#include <mini-os/kernel.h> #include <xen/xen.h> #include <xen/arch-x86/cpuid.h> +#include <xen/arch-x86/hvm/start_info.h> /* * Shared page for communicating with the hypervisor.
@@ -88,6 +89,13 @@ static inline void sse_init(void) {#ifdef CONFIG_PARAVIRT #define hpc_init () + +static void get_cmdline (void *p) +{ +start_info_t *si = p; + +strncpy (cmdline, (char *)si->cmd_line,MAX_CMDLINE_SIZE -1 ); +}#else static void hpc_init (void ) {
@@ -109,6 +117,14 @@ static void hpc_init(void)wrmsrl (ebx, (unsigned long )&hypercall_page); barrier(); } + +static void get_cmdline (void *p) +{ +struct hvm_start_info *si = p; + +if ( si->cmdline_paddr ) +strncpy (cmdline,to_virt (si->cmdline_paddr),MAX_CMDLINE_SIZE -1 ); +}#endif /*
@@ -139,6 +155,7 @@ arch_init(void *par)shared_info. Use xprintk instead. */ get_console (par);get_xenbus (par); +get_cmdline (par); si = par;memcpy (&start_info, si,sizeof (*si));
@@ -153,8 +170,7 @@ arch_init(void *par)printk (" mod_start: 0x%lx(VA)\n" , si->mod_start);printk (" mod_len: %lu\n" , si->mod_len);printk (" flags: 0x%x\n" , (unsigned int )si->flags); -printk (" cmd_line: %s\n" , - si->cmd_line ? (const char *)si->cmd_line :"NULL" ); +printk (" cmd_line: %s\n" , cmdline);printk (" stack: %p-%p\n" , stack, stack +sizeof (stack));/* Grab the shared_info pointer and put it in a safe place. */
include/kernel.h +3 -0
@@ -1,6 +1,9 @@#ifndef _KERNEL_H_#define _KERNEL_H_ +#define MAX_CMDLINE_SIZE 1024 +extern char cmdline[MAX_CMDLINE_SIZE ]; +void start_kernel (void );void do_exit (void ) __attribute__((noreturn));void arch_do_exit (void );
kernel.c +1 -0
@@ -48,6 +48,7 @@#include <xen/version.h> uint8_t xen_features[XENFEAT_NR_SUBMAPS *32 ]; +char cmdline[MAX_CMDLINE_SIZE ];void setup_xen_features (void ) {
main.c +3 -2
@@ -6,6 +6,7 @@#ifdef HAVE_LIBC #include <os.h> +#include <kernel.h> #include <sched.h> #include <console.h> #include <netfront.h>
@@ -134,7 +135,7 @@ static void call_main(void *p)#define PARSE_ARGS_COUNT (ARGS ) PARSE_ARGS(ARGS, argc++, c++, )#define PARSE_ARGS_STORE (ARGS ) PARSE_ARGS(ARGS, argv[argc++] = c, memmove(c, c + 1, strlen(c + 1) + 1), *c++ = 0) -PARSE_ARGS_COUNT ((char *)start_info.cmd_line); +PARSE_ARGS_COUNT (cmdline);#ifdef CONFIG_QEMU_XS_ARGS PARSE_ARGS_COUNT (domargs);#endif
@@ -143,7 +144,7 @@ static void call_main(void *p) argv[0 ] ="main" ; argc =1 ; - PARSE_ARGS_STORE((char*)start_info.cmd_line) + PARSE_ARGS_STORE(cmdline)#ifdef CONFIG_QEMU_XS_ARGS PARSE_ARGS_STORE(domargs)#endif
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [Minios-devel] [PATCH 17/22] mini-os: add get_cmdline() function
Quoted 5 lines · Juergen Gross, on Tue 23 Aug 2016 17:16:03 +0200, wrote:
The command line parameters are passed in
start_infostructure for pv, but viahvm_start_infofor HVMlite. Add a generic function to fill a local cmdline variable with the command line string.Signed-off-by Juergen Gross <[email protected]>
Quoted 130 lines
--- arch/x86/setup.c | 20 ++++++++++++++++++-- include/kernel.h | 3 +++ kernel.c | 1 + main.c | 5 +++-- 4 files changed, 25 insertions(+), 4 deletions(-)arch/x86/setup.c +18
-2@@ -31,6 +31,7 @@#include <mini-os/kernel.h> #include <xen/xen.h> #include <xen/arch-x86/cpuid.h> +#include <xen/arch-x86/hvm/start_info.h> /* * Shared page for communicating with the hypervisor. @@ -88,6 +89,13 @@ static inline void sse_init(void) {#ifdef CONFIG_PARAVIRT #define hpc_init () + +static void get_cmdline (void *p) +{ +start_info_t *si = p; + +strncpy (cmdline, (char *)si->cmd_line,MAX_CMDLINE_SIZE -1 ); +}#else static void hpc_init (void ) {@@ -109,6 +117,14 @@ static void hpc_init(void)wrmsrl (ebx, (unsigned long )&hypercall_page); barrier(); } + +static void get_cmdline (void *p) +{ +struct hvm_start_info *si = p; + +if ( si->cmdline_paddr ) +strncpy (cmdline,to_virt (si->cmdline_paddr),MAX_CMDLINE_SIZE -1 ); +}#endif /* @@ -139,6 +155,7 @@ arch_init(void *par)shared_info. Use xprintk instead. */ get_console (par);get_xenbus (par); +get_cmdline (par); si = par;memcpy (&start_info, si,sizeof (*si));@@ -153,8 +170,7 @@ arch_init(void *par)printk (" mod_start: 0x%lx(VA)\n" , si->mod_start);printk (" mod_len: %lu\n" , si->mod_len);printk (" flags: 0x%x\n" , (unsigned int )si->flags); -printk (" cmd_line: %s\n" , - si->cmd_line ? (const char *)si->cmd_line :"NULL" ); +printk (" cmd_line: %s\n" , cmdline);printk (" stack: %p-%p\n" , stack, stack +sizeof (stack));/* Grab the shared_info pointer and put it in a safe place. */ include/kernel.h +3
-0@@ -1,6 +1,9 @@#ifndef _KERNEL_H_#define _KERNEL_H_ +#define MAX_CMDLINE_SIZE 1024 +extern char cmdline[MAX_CMDLINE_SIZE ]; +void start_kernel (void );void do_exit (void ) __attribute__((noreturn));void arch_do_exit (void );kernel.c +1
-0@@ -48,6 +48,7 @@#include <xen/version.h> uint8_t xen_features[XENFEAT_NR_SUBMAPS *32 ]; +char cmdline[MAX_CMDLINE_SIZE ];void setup_xen_features (void ) {main.c +3
-2@@ -6,6 +6,7 @@#ifdef HAVE_LIBC #include <os.h> +#include <kernel.h> #include <sched.h> #include <console.h> #include <netfront.h> @@ -134,7 +135,7 @@ static void call_main(void *p)#define PARSE_ARGS_COUNT (ARGS ) PARSE_ARGS(ARGS, argc++, c++, )#define PARSE_ARGS_STORE (ARGS ) PARSE_ARGS(ARGS, argv[argc++] = c, memmove(c, c + 1, strlen(c + 1) + 1), *c++ = 0) -PARSE_ARGS_COUNT ((char *)start_info.cmd_line); +PARSE_ARGS_COUNT (cmdline);#ifdef CONFIG_QEMU_XS_ARGS PARSE_ARGS_COUNT (domargs);#endif @@ -143,7 +144,7 @@ static void call_main(void *p) argv[0 ] ="main" ; argc =1 ; - PARSE_ARGS_STORE((char*)start_info.cmd_line) + PARSE_ARGS_STORE(cmdline)#ifdef CONFIG_QEMU_XS_ARGS PARSE_ARGS_STORE(domargs)#endif Signature · 7 lines
2.6.6 _______________________________________________ Minios-devel mailing list [email protected] https://lists.xenproject.org/cgi-bin/mailman/listinfo/minios-devel
Signature · 8 lines
Samuel <T> csp.tar.gz: ascii text -+- #ens-mim - vive les browsers qui prennent des initiatives à la con -+- _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Juergen Gross
maintainerPATCH 18/22 mini-os: map shared info page for HVMlite
In reply to Juergen GrossAdd a service function to map the shared info page on a non-paravirtualized system. The code is already existing on ARM side, just move it to hypervisor.c.
--- arch/arm/arm32.S | 4 ++-- arch/arm/setup.c | 11 +---------- arch/x86/setup.c | 38 ++++++++++++++++++++------------------ hypervisor.c | 17 +++++++++++++++++ include/hypervisor.h | 1 + 5 files changed, 41 insertions(+), 30 deletions(-)
arch/arm/arm32.S +2 -2
@@ -151,8 +151,8 @@ stage2: .pushsection .bss @ Note: calling arch_init zeroes out this region. .align 12 -.globl shared_info_page -shared_info_page: +.globl shared_info +shared_info: .fill (1024), 4, 0x0 .align 3
arch/arm/setup.c +1 -10
@@ -21,8 +21,6 @@ union start_info_union start_info_union;*/ shared_info_t *HYPERVISOR_shared_info; -extern char shared_info_page[PAGE_SIZE ]; -void *device_tree;/*
@@ -30,7 +28,6 @@ void *device_tree;*/ void arch_init (void *dtb_pointer,uint32_t physical_offset) { -struct xen_add_to_physmap xatp;int r;memset (&__bss_start,0 , &_end - &__bss_start);
@@ -48,13 +45,7 @@ void arch_init(void *dtb_pointer, uint32_t physical_offset) device_tree = dtb_pointer;/* Map shared_info page */ - xatp.domid =DOMID_SELF ; - xatp.idx =0 ; - xatp.space = XENMAPSPACE_shared_info; - xatp.gpfn =virt_to_pfn (shared_info_page); -if (HYPERVISOR_memory_op (XENMEM_add_to_physmap, &xatp) !=0 ) -BUG (); - HYPERVISOR_shared_info = (struct shared_info *)shared_info_page; + HYPERVISOR_shared_info =map_shared_info (NULL );/* Fill in start_info */ get_console (NULL );
arch/x86/setup.c +20 -18
@@ -60,20 +60,6 @@ extern char shared_info[PAGE_SIZE]; ((pte_t) {(unsigned long)(_x), (unsigned long)(_x>>32)}); })#endif -static -shared_info_t *map_shared_info (unsigned long pa) -{ -int rc; - -if ( (rc =HYPERVISOR_update_va_mapping ( - (unsigned long )shared_info,__pte (pa |7 ),UVMF_INVLPG )) ) - { -printk ("Failed to map shared_info!! rc=%d\n" , rc); -do_exit (); - } -return (shared_info_t *)shared_info; -} -static inline void fpu_init (void ) { asmvolatile ("fninit" ); }
@@ -90,6 +76,21 @@ static inline void sse_init(void) {#ifdef CONFIG_PARAVIRT #define hpc_init () +shared_info_t *map_shared_info (void *p) +{ +int rc; +start_info_t *si = p; +unsigned long pa = si->shared_info; + +if ( (rc =HYPERVISOR_update_va_mapping ((unsigned long )shared_info, +__pte (pa |7 ),UVMF_INVLPG )) ) + { +printk ("Failed to map shared_info!! rc=%d\n" , rc); +do_exit (); + } +return (shared_info_t *)shared_info; +} +static void get_cmdline (void *p) {start_info_t *si = p;
@@ -156,6 +157,10 @@ arch_init(void *par)get_console (par);get_xenbus (par);get_cmdline (par); + +/* Grab the shared_info pointer and put it in a safe place. */ + HYPERVISOR_shared_info =map_shared_info (par); + si = par;memcpy (&start_info, si,sizeof (*si));
@@ -163,7 +168,7 @@ arch_init(void *par)printk ("Xen Minimal OS!\n" );printk (" start_info: %p(VA)\n" , si);printk (" nr_pages: 0x%lx\n" , si->nr_pages); -printk (" shared_inf: 0x%08lx(MA)\n" , si->shared_info); +printk (" shared_inf: %p(VA)\n" , HYPERVISOR_shared_info);printk (" pt_base: %p(VA)\n" , (void *)si->pt_base);printk ("nr_pt_frames: 0x%lx\n" , si->nr_pt_frames);printk (" mfn_list: %p(VA)\n" , (void *)si->mfn_list);
@@ -173,9 +178,6 @@ arch_init(void *par)printk (" cmd_line: %s\n" , cmdline);printk (" stack: %p-%p\n" , stack, stack +sizeof (stack)); -/* Grab the shared_info pointer and put it in a safe place. */ - HYPERVISOR_shared_info =map_shared_info (start_info.shared_info); -start_kernel (); }
hypervisor.c +17 -0
@@ -29,6 +29,7 @@#include <mini-os/lib.h> #include <mini-os/hypervisor.h> #include <mini-os/events.h> +#include <xen/memory.h> #define active_evtchns (cpu,sh,idx) \ ((sh)->evtchn_pending[idx] & \
@@ -37,6 +38,8 @@int in_callback;#ifndef CONFIG_PARAVIRT +extern shared_info_t shared_info; +int hvm_get_parameter (int idx,uint64_t *value) {struct xen_hvm_param xhv;
@@ -61,6 +64,20 @@ int hvm_set_parameter(int idx, uint64_t value) xhv.value = value; return HYPERVISOR_hvm_op(HVMOP_set_param, &xhv); } + +shared_info_t *map_shared_info (void *p) +{ +struct xen_add_to_physmap xatp; + + xatp.domid =DOMID_SELF ; + xatp.idx =0 ; + xatp.space = XENMAPSPACE_shared_info; + xatp.gpfn =virt_to_pfn (&shared_info); +if (HYPERVISOR_memory_op (XENMEM_add_to_physmap, &xatp) !=0 ) +BUG (); + +return &shared_info; +}#endif void do_hypervisor_callback (struct pt_regs *regs)
include/hypervisor.h +1 -0
@@ -42,6 +42,7 @@ extern union start_info_union start_info_union;int hvm_get_parameter (int idx,uint64_t *value);int hvm_set_parameter (int idx,uint64_t value);#endif +shared_info_t *map_shared_info (void *p);void force_evtchn_callback (void );void do_hypervisor_callback (struct pt_regs *regs);void mask_evtchn (uint32_t port);
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 18/22] mini-os: map shared info page for HVMlite
Quoted 5 lines · Juergen Gross, on Tue 23 Aug 2016 17:16:04 +0200, wrote:
Add a service function to map the shared info page on a non-paravirtualized system. The code is already existing on ARM side, just move it to
hypervisor.c.Signed-off-by Juergen Gross <[email protected]>
Quoted 193 lines
--- arch/arm/arm32.S | 4 ++-- arch/arm/setup.c | 11 +---------- arch/x86/setup.c | 38 ++++++++++++++++++++------------------ hypervisor.c | 17 +++++++++++++++++ include/hypervisor.h | 1 + 5 files changed, 41 insertions(+), 30 deletions(-)arch/arm/arm32.S +2
-2@@ -151,8 +151,8 @@ stage2: .pushsection .bss @ Note: calling arch_init zeroes out this region. .align 12 -.globl shared_info_page -shared_info_page: +.globl shared_info +shared_info: .fill (1024), 4, 0x0 .align 3arch/arm/setup.c +1
-10@@ -21,8 +21,6 @@ union start_info_union start_info_union;*/ shared_info_t *HYPERVISOR_shared_info; -extern char shared_info_page[PAGE_SIZE ]; -void *device_tree;/* @@ -30,7 +28,6 @@ void *device_tree;*/ void arch_init (void *dtb_pointer,uint32_t physical_offset) { -struct xen_add_to_physmap xatp;int r;memset (&__bss_start,0 , &_end - &__bss_start);@@ -48,13 +45,7 @@ void arch_init(void *dtb_pointer, uint32_t physical_offset) device_tree = dtb_pointer;/* Map shared_info page */ - xatp.domid =DOMID_SELF ; - xatp.idx =0 ; - xatp.space = XENMAPSPACE_shared_info; - xatp.gpfn =virt_to_pfn (shared_info_page); -if (HYPERVISOR_memory_op (XENMEM_add_to_physmap, &xatp) !=0 ) -BUG (); - HYPERVISOR_shared_info = (struct shared_info *)shared_info_page; + HYPERVISOR_shared_info =map_shared_info (NULL );/* Fill in start_info */ get_console (NULL );arch/x86/setup.c +20
-18@@ -60,20 +60,6 @@ extern char shared_info[PAGE_SIZE]; ((pte_t) {(unsigned long)(_x), (unsigned long)(_x>>32)}); })#endif -static -shared_info_t *map_shared_info (unsigned long pa) -{ -int rc; - -if ( (rc =HYPERVISOR_update_va_mapping ( - (unsigned long )shared_info,__pte (pa |7 ),UVMF_INVLPG )) ) - { -printk ("Failed to map shared_info!! rc=%d\n" , rc); -do_exit (); - } -return (shared_info_t *)shared_info; -} -static inline void fpu_init (void ) { asmvolatile ("fninit" ); }@@ -90,6 +76,21 @@ static inline void sse_init(void) {#ifdef CONFIG_PARAVIRT #define hpc_init () +shared_info_t *map_shared_info (void *p) +{ +int rc; +start_info_t *si = p; +unsigned long pa = si->shared_info; + +if ( (rc =HYPERVISOR_update_va_mapping ((unsigned long )shared_info, +__pte (pa |7 ),UVMF_INVLPG )) ) + { +printk ("Failed to map shared_info!! rc=%d\n" , rc); +do_exit (); + } +return (shared_info_t *)shared_info; +} +static void get_cmdline (void *p) {start_info_t *si = p;@@ -156,6 +157,10 @@ arch_init(void *par)get_console (par);get_xenbus (par);get_cmdline (par); + +/* Grab the shared_info pointer and put it in a safe place. */ + HYPERVISOR_shared_info =map_shared_info (par); + si = par;memcpy (&start_info, si,sizeof (*si));@@ -163,7 +168,7 @@ arch_init(void *par)printk ("Xen Minimal OS!\n" );printk (" start_info: %p(VA)\n" , si);printk (" nr_pages: 0x%lx\n" , si->nr_pages); -printk (" shared_inf: 0x%08lx(MA)\n" , si->shared_info); +printk (" shared_inf: %p(VA)\n" , HYPERVISOR_shared_info);printk (" pt_base: %p(VA)\n" , (void *)si->pt_base);printk ("nr_pt_frames: 0x%lx\n" , si->nr_pt_frames);printk (" mfn_list: %p(VA)\n" , (void *)si->mfn_list);@@ -173,9 +178,6 @@ arch_init(void *par)printk (" cmd_line: %s\n" , cmdline);printk (" stack: %p-%p\n" , stack, stack +sizeof (stack)); -/* Grab the shared_info pointer and put it in a safe place. */ - HYPERVISOR_shared_info =map_shared_info (start_info.shared_info); -start_kernel (); }hypervisor.c +17
-0@@ -29,6 +29,7 @@#include <mini-os/lib.h> #include <mini-os/hypervisor.h> #include <mini-os/events.h> +#include <xen/memory.h> #define active_evtchns (cpu,sh,idx) \ ((sh)->evtchn_pending[idx] & \@@ -37,6 +38,8 @@int in_callback;#ifndef CONFIG_PARAVIRT +extern shared_info_t shared_info; +int hvm_get_parameter (int idx,uint64_t *value) {struct xen_hvm_param xhv;@@ -61,6 +64,20 @@ int hvm_set_parameter(int idx, uint64_t value) xhv.value = value; return HYPERVISOR_hvm_op(HVMOP_set_param, &xhv); } + +shared_info_t *map_shared_info (void *p) +{ +struct xen_add_to_physmap xatp; + + xatp.domid =DOMID_SELF ; + xatp.idx =0 ; + xatp.space = XENMAPSPACE_shared_info; + xatp.gpfn =virt_to_pfn (&shared_info); +if (HYPERVISOR_memory_op (XENMEM_add_to_physmap, &xatp) !=0 ) +BUG (); + +return &shared_info; +}#endif void do_hypervisor_callback (struct pt_regs *regs)include/hypervisor.h +1
-0@@ -42,6 +42,7 @@ extern union start_info_union start_info_union;int hvm_get_parameter (int idx,uint64_t *value);int hvm_set_parameter (int idx,uint64_t value);#endif +shared_info_t *map_shared_info (void *p);void force_evtchn_callback (void );void do_hypervisor_callback (struct pt_regs *regs);void mask_evtchn (uint32_t port);Signature · 1 line
2.6.6
Signature · 9 lines
Samuel <m> bouhouhouh, b il m'a abandonné. Tout ca parce que je regardais plus mon emacs que lui ! <m> s/lui/ses messages irc/ -+- #ens-mim esseulé -+- _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Juergen Gross
maintainerPATCH 19/22 mini-os: remove using start_info in architecture independent code
In reply to Juergen GrossThe start_info structure should be used only in case of CONFIG_PARAVIRT defined. Remove it from being used in other places. Especially the usage as parameter for applications linked to the kernel is no good idea.
--- arch/arm/setup.c | 8 -------- arch/x86/setup.c | 8 -------- daytime.c | 2 +- include/hypervisor.h | 11 ----------- kernel.c | 6 +++--- main.c | 6 +++--- test.c | 20 ++++++++++---------- 7 files changed, 17 insertions(+), 44 deletions(-)
arch/arm/setup.c +0 -8
@@ -9,13 +9,6 @@#include <libfdt.h> /* -* This structure contains start-of-day info, such as pagetable base pointer, -* address of the shared_info structure, and things like that. -* On x86, the hypervisor passes it to us. On ARM, we fill it in ourselves. -*/ -union start_info_union start_info_union; - -/* * Shared page for communicating with the hypervisor. * Events flags go here, for example. */
@@ -47,7 +40,6 @@ void arch_init(void *dtb_pointer, uint32_t physical_offset)/* Map shared_info page */ HYPERVISOR_shared_info =map_shared_info (NULL ); -/* Fill in start_info */ get_console (NULL );get_xenbus (NULL );
arch/x86/setup.c +0 -8
@@ -40,12 +40,6 @@shared_info_t *HYPERVISOR_shared_info;/* -* This structure contains start-of-day info, such as pagetable base pointer, -* address of the shared_info structure, and things like that. -*/ -union start_info_union start_info_union; - -/* * Just allocate the kernel stack here. SS:ESP is set up to point here * in head.S. */
@@ -151,7 +145,6 @@ arch_init(void *par)/* Setup memory management info from start_info. */ arch_mm_preinit (par); -/* Copy the start_info struct to a globally-accessible area. */ /* WARN: don't do printk before here, it uses information from shared_info. Use xprintk instead. */ get_console (par);
@@ -162,7 +155,6 @@ arch_init(void *par) HYPERVISOR_shared_info =map_shared_info (par); si = par; -memcpy (&start_info, si,sizeof (*si));/* print out some useful information */ printk ("Xen Minimal OS!\n" );
daytime.c +1 -1
@@ -60,7 +60,7 @@ void run_server(void *p) } -int app_main (start_info_t *si) +int app_main (void *p) {create_thread ("server" , run_server,NULL );return 0 ;
include/hypervisor.h +0 -11
@@ -26,17 +26,6 @@#include <xen/hvm/hvm_op.h> #include <mini-os/traps.h> -/* -* a placeholder for the start of day information passed up from the hypervisor -*/ -union start_info_union -{ -start_info_t start_info; -char padding[512 ]; -}; -extern union start_info_union start_info_union; -#define start_info (start_info_union.start_info) -/* hypervisor.c */ #ifndef CONFIG_PARAVIRT int hvm_get_parameter (int idx,uint64_t *value);
kernel.c +3 -3
@@ -110,9 +110,9 @@ static void shutdown_thread(void *p)/* This should be overridden by the application we are linked against. */ -__attribute__((weak))int app_main (start_info_t *si) +__attribute__((weak))int app_main (void *p) { -printk ("kernel.c: dummy main: start_info=%p\n" , si); +printk ("kernel.c: dummy main: par=%p\n" , p);return 0 ; }
@@ -149,7 +149,7 @@ void start_kernel(void)#endif /* Call (possibly overridden) app_main() */ -app_main (&start_info); +app_main (NULL );/* Everything initialised, start idle thread */ run_idle_thread ();
main.c +3 -3
@@ -185,10 +185,10 @@ void _exit(int ret) do_exit(); } -int app_main (start_info_t *si) +int app_main (void *p) { -printk ("main.c: dummy main: start_info=%p\n" , si); - main_thread =create_thread ("main" , call_main, si); +printk ("main.c: dummy main: par=%p\n" , p); + main_thread =create_thread ("main" , call_main, p);return 0 ; }#endif
test.c +10 -10
@@ -552,28 +552,28 @@ static void shutdown_thread(void *p) }#endif -int app_main (start_info_t *si) +int app_main (void *p) { -printk ("Test main: start_info=%p\n" , si); +printk ("Test main: par=%p\n" , p);#ifdef CONFIG_XENBUS -create_thread ("xenbus_tester" , xenbus_tester, si); +create_thread ("xenbus_tester" , xenbus_tester, p);#endif -create_thread ("periodic_thread" , periodic_thread, si); +create_thread ("periodic_thread" , periodic_thread, p);#ifdef CONFIG_NETFRONT -create_thread ("netfront" , netfront_thread, si); +create_thread ("netfront" , netfront_thread, p);#endif #ifdef CONFIG_BLKFRONT -create_thread ("blkfront" , blkfront_thread, si); +create_thread ("blkfront" , blkfront_thread, p);#endif #if defined(CONFIG_FBFRONT ) && defined(CONFIG_KBDFRONT ) -create_thread ("fbfront" , fbfront_thread, si); -create_thread ("kbdfront" , kbdfront_thread, si); +create_thread ("fbfront" , fbfront_thread, p); +create_thread ("kbdfront" , kbdfront_thread, p);#endif #ifdef CONFIG_PCIFRONT -create_thread ("pcifront" , pcifront_thread, si); +create_thread ("pcifront" , pcifront_thread, p);#endif #ifdef CONFIG_XENBUS -create_thread ("shutdown" , shutdown_thread, si); +create_thread ("shutdown" , shutdown_thread, p);#endif return 0 ; }
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 19/22] mini-os: remove using start_info in architecture independent code
Quoted 6 lines · Juergen Gross, on Tue 23 Aug 2016 17:16:05 +0200, wrote:
The
start_infostructure should be used only in case ofCONFIG_PARAVIRTdefined. Remove it from being used in other places. Especially the usage as parameter for applications linked to the kernel is no good idea.Signed-off-by Juergen Gross <[email protected]>
Quoted 193 lines
--- arch/arm/setup.c | 8 -------- arch/x86/setup.c | 8 -------- daytime.c | 2 +- include/hypervisor.h | 11 ----------- kernel.c | 6 +++--- main.c | 6 +++--- test.c | 20 ++++++++++---------- 7 files changed, 17 insertions(+), 44 deletions(-)arch/arm/setup.c +0
-8@@ -9,13 +9,6 @@#include <libfdt.h> /* -* This structure contains start-of-day info, such as pagetable base pointer, -* address of the shared_info structure, and things like that. -* On x86, the hypervisor passes it to us. On ARM, we fill it in ourselves. -*/ -union start_info_union start_info_union; - -/* * Shared page for communicating with the hypervisor. * Events flags go here, for example. */ @@ -47,7 +40,6 @@ void arch_init(void *dtb_pointer, uint32_t physical_offset)/* Map shared_info page */ HYPERVISOR_shared_info =map_shared_info (NULL ); -/* Fill in start_info */ get_console (NULL );get_xenbus (NULL );arch/x86/setup.c +0
-8@@ -40,12 +40,6 @@shared_info_t *HYPERVISOR_shared_info;/* -* This structure contains start-of-day info, such as pagetable base pointer, -* address of the shared_info structure, and things like that. -*/ -union start_info_union start_info_union; - -/* * Just allocate the kernel stack here. SS:ESP is set up to point here * in head.S. */ @@ -151,7 +145,6 @@ arch_init(void *par)/* Setup memory management info from start_info. */ arch_mm_preinit (par); -/* Copy the start_info struct to a globally-accessible area. */ /* WARN: don't do printk before here, it uses information from shared_info. Use xprintk instead. */ get_console (par);@@ -162,7 +155,6 @@ arch_init(void *par) HYPERVISOR_shared_info =map_shared_info (par); si = par; -memcpy (&start_info, si,sizeof (*si));/* print out some useful information */ printk ("Xen Minimal OS!\n" );daytime.c +1
-1@@ -60,7 +60,7 @@ void run_server(void *p) } -int app_main (start_info_t *si) +int app_main (void *p) {create_thread ("server" , run_server,NULL );return 0 ;include/hypervisor.h +0
-11@@ -26,17 +26,6 @@#include <xen/hvm/hvm_op.h> #include <mini-os/traps.h> -/* -* a placeholder for the start of day information passed up from the hypervisor -*/ -union start_info_union -{ -start_info_t start_info; -char padding[512 ]; -}; -extern union start_info_union start_info_union; -#define start_info (start_info_union.start_info) -/* hypervisor.c */ #ifndef CONFIG_PARAVIRT int hvm_get_parameter (int idx,uint64_t *value);kernel.c +3
-3@@ -110,9 +110,9 @@ static void shutdown_thread(void *p)/* This should be overridden by the application we are linked against. */ -__attribute__((weak))int app_main (start_info_t *si) +__attribute__((weak))int app_main (void *p) { -printk ("kernel.c: dummy main: start_info=%p\n" , si); +printk ("kernel.c: dummy main: par=%p\n" , p);return 0 ; }@@ -149,7 +149,7 @@ void start_kernel(void)#endif /* Call (possibly overridden) app_main() */ -app_main (&start_info); +app_main (NULL );/* Everything initialised, start idle thread */ run_idle_thread ();main.c +3
-3@@ -185,10 +185,10 @@ void _exit(int ret) do_exit(); } -int app_main (start_info_t *si) +int app_main (void *p) { -printk ("main.c: dummy main: start_info=%p\n" , si); - main_thread =create_thread ("main" , call_main, si); +printk ("main.c: dummy main: par=%p\n" , p); + main_thread =create_thread ("main" , call_main, p);return 0 ; }#endif test.c +10
-10@@ -552,28 +552,28 @@ static void shutdown_thread(void *p) }#endif -int app_main (start_info_t *si) +int app_main (void *p) { -printk ("Test main: start_info=%p\n" , si); +printk ("Test main: par=%p\n" , p);#ifdef CONFIG_XENBUS -create_thread ("xenbus_tester" , xenbus_tester, si); +create_thread ("xenbus_tester" , xenbus_tester, p);#endif -create_thread ("periodic_thread" , periodic_thread, si); +create_thread ("periodic_thread" , periodic_thread, p);#ifdef CONFIG_NETFRONT -create_thread ("netfront" , netfront_thread, si); +create_thread ("netfront" , netfront_thread, p);#endif #ifdef CONFIG_BLKFRONT -create_thread ("blkfront" , blkfront_thread, si); +create_thread ("blkfront" , blkfront_thread, p);#endif #if defined(CONFIG_FBFRONT ) && defined(CONFIG_KBDFRONT ) -create_thread ("fbfront" , fbfront_thread, si); -create_thread ("kbdfront" , kbdfront_thread, si); +create_thread ("fbfront" , fbfront_thread, p); +create_thread ("kbdfront" , kbdfront_thread, p);#endif #ifdef CONFIG_PCIFRONT -create_thread ("pcifront" , pcifront_thread, si); +create_thread ("pcifront" , pcifront_thread, p);#endif #ifdef CONFIG_XENBUS -create_thread ("shutdown" , shutdown_thread, si); +create_thread ("shutdown" , shutdown_thread, p);#endif return 0 ; }Signature · 1 line
2.6.6
Signature · 14 lines
Samuel Now, it we had this sort of thing: yield -a for yield to all traffic yield -t for yield to trucks yield -f for yield to people walking (yield foot) yield -d t* for yield on days starting with t ...you'd have a lot of dead people at intersections, and traffic jams you wouldn't believe... (Discussion in comp.os.linux.misc on the intuitiveness of commands.) _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Juergen Gross
maintainerPATCH 20/22 mini-os: print start of day messages depending on domain type
In reply to Juergen GrossSelect what to print in arch_init() depending on the domain type.
--- arch/x86/setup.c | 47 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 15 deletions(-)
arch/x86/setup.c +32 -15
@@ -91,6 +91,24 @@ static void get_cmdline(void *p)strncpy (cmdline, (char *)si->cmd_line,MAX_CMDLINE_SIZE -1 ); } + +static void print_start_of_day (void *p) +{ +start_info_t *si = p; + +printk ("Xen Minimal OS (pv)!\n" ); +printk (" start_info: %p(VA)\n" , si); +printk (" nr_pages: 0x%lx\n" , si->nr_pages); +printk (" shared_inf: 0x%08lx(MA)\n" , si->shared_info); +printk (" pt_base: %p(VA)\n" , (void *)si->pt_base); +printk ("nr_pt_frames: 0x%lx\n" , si->nr_pt_frames); +printk (" mfn_list: %p(VA)\n" , (void *)si->mfn_list); +printk (" mod_start: 0x%lx(VA)\n" , si->mod_start); +printk (" mod_len: %lu\n" , si->mod_len); +printk (" flags: 0x%x\n" , (unsigned int )si->flags); +printk (" cmd_line: %s\n" , cmdline); +printk (" stack: %p-%p\n" , stack, stack +sizeof (stack)); +}#else static void hpc_init (void ) {
@@ -120,6 +138,19 @@ static void get_cmdline(void *p)if ( si->cmdline_paddr ) strncpy(cmdline, to_virt(si->cmdline_paddr), MAX_CMDLINE_SIZE - 1); } + +static void print_start_of_day (void *p) +{ +struct hvm_start_info *si = p; + +printk ("Xen Minimal OS (hvm)!\n" ); +printk (" start_info: %p(VA)\n" , si); +printk (" shared_inf: %p(VA)\n" , HYPERVISOR_shared_info); +printk (" modlist: 0x%lx(PA)\n" , (unsigned long )si->modlist_paddr); +printk (" flags: 0x%x\n" , (unsigned int )si->flags); +printk (" cmd_line: %s\n" , cmdline); +printk (" stack: %p-%p\n" , stack, stack +sizeof (stack)); +}#endif /*
@@ -129,7 +160,6 @@ void arch_init(void *par) {static char hello[] ="Bootstrapping...\n" ; -start_info_t *si;hpc_init (); (void )HYPERVISOR_console_io (CONSOLEIO_write,strlen (hello), hello);
@@ -154,21 +184,8 @@ arch_init(void *par)/* Grab the shared_info pointer and put it in a safe place. */ HYPERVISOR_shared_info =map_shared_info (par); - si = par; -/* print out some useful information */ -printk ("Xen Minimal OS!\n" ); -printk (" start_info: %p(VA)\n" , si); -printk (" nr_pages: 0x%lx\n" , si->nr_pages); -printk (" shared_inf: %p(VA)\n" , HYPERVISOR_shared_info); -printk (" pt_base: %p(VA)\n" , (void *)si->pt_base); -printk ("nr_pt_frames: 0x%lx\n" , si->nr_pt_frames); -printk (" mfn_list: %p(VA)\n" , (void *)si->mfn_list); -printk (" mod_start: 0x%lx(VA)\n" , si->mod_start); -printk (" mod_len: %lu\n" , si->mod_len); -printk (" flags: 0x%x\n" , (unsigned int )si->flags); -printk (" cmd_line: %s\n" , cmdline); -printk (" stack: %p-%p\n" , stack, stack +sizeof (stack)); +print_start_of_day (par);start_kernel (); }
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 20/22] mini-os: print start of day messages depending on domain type
arch/x86/setup.c static void get_cmdline(void *p) · line 149
Quoted 4 lines · Juergen Gross, on Tue 23 Aug 2016 17:16:06 +0200, wrote:
arch/x86/setup.c +4
-0+printk ("Xen Minimal OS (hvm)!\n" ); +printk (" start_info: %p(VA)\n" , si); +printk (" shared_inf: %p(VA)\n" , HYPERVISOR_shared_info); +printk (" modlist: 0x%lx(PA)\n" , (unsigned long )si->modlist_paddr);
It would be useful to also print nr_modules.
arch/x86/setup.c static void get_cmdline(void *p) · line 110
Quoted 3 lines
arch/x86/setup.c +3
-0+printk (" flags: 0x%x\n" , (unsigned int )si->flags); +printk (" cmd_line: %s\n" , cmdline); +printk (" stack: %p-%p\n" , stack, stack +sizeof (stack));
Apart from that,
Samuel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Juergen Gross
maintainerRe: [PATCH 20/22] mini-os: print start of day messages depending on domain type
Quoted 7 lines · Samuel Thibault
arch/x86/setup.c static void get_cmdline(void *p) · line 149
Quoted 4 lines · Juergen Gross, on Tue 23 Aug 2016 17:16:06 +0200, wrote:
arch/x86/setup.c +4
-0+printk ("Xen Minimal OS (hvm)!\n" ); +printk (" start_info: %p(VA)\n" , si); +printk (" shared_inf: %p(VA)\n" , HYPERVISOR_shared_info); +printk (" modlist: 0x%lx(PA)\n" , (unsigned long )si->modlist_paddr);It would be useful to also print
nr_modules.
Okay, I'll add it.
Quoted 8 lines
arch/x86/setup.c static void get_cmdline(void *p) · line 110
Quoted 4 lines
arch/x86/setup.c +3
-0+printk (" flags: 0x%x\n" , (unsigned int )si->flags); +printk (" cmd_line: %s\n" , cmdline); +printk (" stack: %p-%p\n" , stack, stack +sizeof (stack));Apart from that,
Reviewed-by Samuel Thibault <[email protected]>
Thanks,
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Juergen Gross
maintainerPATCH 21/22 mini-os: get physical memory map
In reply to Juergen GrossOn HVMlite we have to look at the physical memory map to know which memory frames are usable.
In order to make life easier we define a dummy memory map for other domain types (pv and arm) which has just one entry with a maximum memory size.
--- arch/arm/mm.c | 8 ++++++ arch/x86/mm.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++ arch/x86/setup.c | 1 + include/e820.h | 48 +++++++++++++++++++++++++++++++ include/x86/arch_mm.h | 4 +++ mm.c | 79 ++++++++++++++++++++++++++++++++------------------- 6 files changed, 183 insertions(+), 29 deletions(-) create mode 100644 include/e820.h
arch/arm/mm.c +8 -0
@@ -7,6 +7,14 @@#include <lib.h> uint32_t physical_address_offset; +struct e820entry e820_map[1 ] = { + { + .addr =0 , + .size =ULONG_MAX -1 , + .type =E820_RAM + } +}; +unsigned e820_entries =1 ;unsigned long allocate_ondemand (unsigned long n,unsigned long alignment) {
arch/x86/mm.c +72 -0
100 lines not on this page · raw message
arch/x86/setup.c +1 -0
@@ -150,6 +150,7 @@ static void print_start_of_day(void *p)printk (" flags: 0x%x\n" , (unsigned int )si->flags);printk (" cmd_line: %s\n" , cmdline);printk (" stack: %p-%p\n" , stack, stack +sizeof (stack)); + arch_print_memmap(); }#endif
include/e820.h new file +48 -0
48 lines not on this page · raw message
include/x86/arch_mm.h +4 -0
@@ -279,6 +279,10 @@ pgentry_t *need_pgt(unsigned long addr);void arch_mm_preinit (void *p);unsigned long alloc_virt_kernel (unsigned n_pages); +#ifndef CONFIG_PARAVIRT +void arch_print_memmap (void ); +#endif +#endif #endif /* _ARCH_MM_H_ */
mm.c +50 -29
113 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
Re: [PATCH 21/22] mini-os: get physical memory map
Quoted 8 lines · Juergen Gross, on Tue 23 Aug 2016 17:16:07 +0200, wrote:
On HVMlite we have to look at the physical memory map to know which memory frames are usable.
In order to make life easier we define a dummy memory map for other domain types (pv and arm) which has just one entry with a maximum memory size.
Signed-off-by Juergen Gross <[email protected]>
Quoted 342 lines
--- arch/arm/mm.c | 8 ++++++ arch/x86/mm.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++ arch/x86/setup.c | 1 + include/e820.h | 48 +++++++++++++++++++++++++++++++ include/x86/arch_mm.h | 4 +++ mm.c | 79 ++++++++++++++++++++++++++++++++------------------- 6 files changed, 183 insertions(+), 29 deletions(-) create mode 100644 include/e820.harch/arm/mm.c +8
-0@@ -7,6 +7,14 @@#include <lib.h> uint32_t physical_address_offset; +struct e820entry e820_map[1 ] = { + { + .addr =0 , + .size =ULONG_MAX -1 , + .type =E820_RAM + } +}; +unsigned e820_entries =1 ;unsigned long allocate_ondemand (unsigned long n,unsigned long alignment) {arch/x86/mm.c +72
-0@@ -43,6 +43,7 @@#include <mini-os/types.h> #include <mini-os/lib.h> #include <mini-os/xmalloc.h> +#include <mini-os/e820.h> #include <xen/memory.h> #ifdef MM_DEBUG @@ -63,6 +64,15 @@ extern char stack[];extern void page_walk (unsigned long va);#ifdef CONFIG_PARAVIRT +struct e820entry e820_map[1 ] = { + { + .addr =0 , + .size =ULONG_MAX -1 , + .type =E820_RAM + } +}; +unsigned e820_entries =1 ; +void arch_mm_preinit (void *p) {start_info_t *si = p;@@ -102,10 +112,25 @@ desc_ptr idt_ptr = .base = (unsigned long)&idt, }; +struct e820entry e820_map[E820_MAX ]; +unsigned e820_entries; + +static char *e820_types[E820_TYPES ] = { + [E820_RAM ] ="RAM" , + [E820_RESERVED ] ="Reserved" , + [E820_ACPI ] ="ACPI" , + [E820_NVS ] ="NVS" , + [E820_UNUSABLE ] ="Unusable" , + [E820_PMEM ] ="PMEM" +}; +void arch_mm_preinit (void *p) {long ret;domid_t domid =DOMID_SELF ; +struct xen_memory_map memmap; +int i; +unsigned long pfn, max =0 ; pt_base = page_table_base; first_free_pfn =PFN_UP (to_phys (&_end));@@ -116,6 +141,53 @@ void arch_mm_preinit(void *p) do_exit(); } last_free_pfn = ret; + + memmap.nr_entries =E820_MAX ; +set_xen_guest_handle (memmap.buffer, e820_map); + ret =HYPERVISOR_memory_op (XENMEM_memory_map, &memmap); +if ( ret <0 ) + { +xprintk ("could not get memory map\n" ); +do_exit (); + } + e820_entries = memmap.nr_entries; + +for ( i =0 ; i < e820_entries; i++ ) + { +if ( e820_map[i].type !=E820_RAM ) +continue ; + pfn = (e820_map[i].addr + e820_map[i].size) >>PAGE_SHIFT ; +if ( pfn > max ) + max = pfn; + } + +if ( max < last_free_pfn ) + last_free_pfn = max; +} + +void arch_print_memmap (void ) +{ +int i; +unsigned long from, to; +char *type; +char buf[12 ]; + +printk ("Memory map:\n" ); +for ( i =0 ; i < e820_entries; i++ ) + { +if ( e820_map[i].type >=E820_TYPES || !e820_types[e820_map[i].type] ) + { +snprintf (buf,sizeof (buf),"%8x" , e820_map[i].type); + type = buf; + } +else + { + type = e820_types[e820_map[i].type]; + } + from = e820_map[i].addr; + to = from + e820_map[i].size -1 ; +printk ("%012lx-%012lx: %s\n" , from, to, type); + } }#endif arch/x86/setup.c +1
-0@@ -150,6 +150,7 @@ static void print_start_of_day(void *p)printk (" flags: 0x%x\n" , (unsigned int )si->flags);printk (" cmd_line: %s\n" , cmdline);printk (" stack: %p-%p\n" , stack, stack +sizeof (stack)); + arch_print_memmap(); }#endif include/e820.h new file +48
-0@@ -0,0 +1,48 @@ +/* -*- 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 __E820_HEADER +#define __E820_HEADER + +/* PC BIOS standard E820 types and structure. */ +#define E820_RAM 1 +#define E820_RESERVED 2 +#define E820_ACPI 3 +#define E820_NVS 4 +#define E820_UNUSABLE 5 +#define E820_PMEM 7 +#define E820_TYPES 8 + +struct __packed e820entry { +uint64_t addr; +uint64_t size; +uint32_t type; +}; + +/* Maximum number of entries. */ +#define E820_MAX 128 + +extern struct e820entry e820_map[]; +extern unsigned e820_entries; + +#endif /*__E820_HEADER*/ include/x86/arch_mm.h +4
-0@@ -279,6 +279,10 @@ pgentry_t *need_pgt(unsigned long addr);void arch_mm_preinit (void *p);unsigned long alloc_virt_kernel (unsigned n_pages); +#ifndef CONFIG_PARAVIRT +void arch_print_memmap (void ); +#endif +#endif #endif /* _ARCH_MM_H_ */ mm.c +50
-29@@ -43,6 +43,7 @@#include <mini-os/types.h> #include <mini-os/lib.h> #include <mini-os/xmalloc.h> +#include <mini-os/e820.h> /********************* * ALLOCATION BITMAP @@ -147,10 +148,14 @@ static chunk_head_t free_tail[FREELIST_SIZE];*/ static void init_page_allocator (unsigned long min,unsigned long max) { -int i; +int i, m;unsigned long range; +unsigned long r_min, r_max;chunk_head_t *ch;chunk_tail_t *ct; + +printk ("MM: Initialise page allocator for %lx(%lx)-%lx(%lx)\n" , + (u_long )to_virt (min), min, (u_long )to_virt (max), max);for ( i =0 ; i <FREELIST_SIZE ; i++ ) { free_head[i] = &free_tail[i];@@ -166,38 +171,57 @@ static void init_page_allocator(unsigned long min, unsigned long max) mm_alloc_bitmap_size =round_pgup (mm_alloc_bitmap_size); mm_alloc_bitmap = (unsigned long *)to_virt (min); min += mm_alloc_bitmap_size; - range = max - min;/* All allocated by default. */ memset (mm_alloc_bitmap, ~0 , mm_alloc_bitmap_size); -/* Free up the memory we've been given to play with. */ -map_free (PHYS_PFN (min), range>>PAGE_SHIFT ); -/* The buddy lists are addressed in high memory. */ - min = (unsigned long )to_virt (min); - max = (unsigned long )to_virt (max); - -while ( range !=0 ) +for ( m =0 ; m < e820_entries; m++ ) { -/* -* Next chunk is limited by alignment of min, but also -* must not be bigger than remaining range. -*/ -for ( i =PAGE_SHIFT ; (1UL <<(i+1 )) <= range; i++ ) -if ( min & (1UL <<i) )break ; +if ( e820_map[m].type !=E820_RAM ) +continue ; +if ( e820_map[m].addr + e820_map[m].size >=ULONG_MAX ) +BUG (); + r_min = e820_map[m].addr; + r_max = r_min + e820_map[m].size; +if ( r_max <= min || r_min >= max ) +continue ; +if ( r_min < min ) + r_min = min; +if ( r_max > max ) + r_max = max; - ch = (chunk_head_t *)min; - min += (1UL <<i); - range -= (1UL <<i); - ct = (chunk_tail_t *)min-1 ; - i -=PAGE_SHIFT ; - ch->level = i; - ch->next = free_head[i]; - ch->pprev = &free_head[i]; - ch->next->pprev = &ch->next; - free_head[i] = ch; - ct->level = i; +printk (" Adding memory range %lx-%lx\n" , r_min, r_max); + +/* The buddy lists are addressed in high memory. */ + r_min = (unsigned long )to_virt (r_min); + r_max = (unsigned long )to_virt (r_max); + range = r_max - r_min; + +/* Free up the memory we've been given to play with. */ +map_free (PHYS_PFN (r_min), range >>PAGE_SHIFT ); + +while ( range !=0 ) + { +/* +* Next chunk is limited by alignment of min, but also +* must not be bigger than remaining range. +*/ +for ( i =PAGE_SHIFT ; (1UL << (i +1 )) <= range; i++ ) +if ( r_min & (1UL << i) )break ; + + ch = (chunk_head_t *)r_min; + r_min +=1UL << i; + range -=1UL << i; + ct = (chunk_tail_t *)r_min -1 ; + i -=PAGE_SHIFT ; + ch->level = i; + ch->next = free_head[i]; + ch->pprev = &free_head[i]; + ch->next->pprev = &ch->next; + free_head[i] = ch; + ct->level = i; + } }mm_alloc_bitmap_remap ();@@ -377,9 +401,6 @@ void init_mm(void)/* * now we can initialise the page allocator */ -printk ("MM: Initialise page allocator for %lx(%lx)-%lx(%lx)\n" , - (u_long )to_virt (PFN_PHYS (start_pfn)), (u_long )PFN_PHYS (start_pfn), - (u_long )to_virt (PFN_PHYS (max_pfn)), (u_long )PFN_PHYS (max_pfn));init_page_allocator (PFN_PHYS (start_pfn),PFN_PHYS (max_pfn));printk ("MM: done\n" );Signature · 1 line
2.6.6
Signature · 10 lines
Samuel Les roots ne sont plus ce qu'ils étaient...Maintenant il sont dioxinés, c'est de la m... ! Avant on les élevaient avec du bon unix mais ça été remplacé par des farines industrielles nouvelles technologies (NT). -+- JdK in NPC : Exigez un root élevé sous la mère ! -+- _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Juergen Gross
maintainerPATCH 22/22 mini-os: support idle for HVMlite
In reply to Juergen GrossInstead of calling HYPERVISOR_sched_op(SCHEDOP_block, 0) we need to use the "hlt" instruction with interrupts enabled to switch to idle when running as HVMlite domain.
This requires to setup a new timer in the timer handler as there is no guarantee the original timer event we are waiting for won't fire between enabling interrupts and calling "hlt".
--- arch/x86/time.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
arch/x86/time.c +7 -4
@@ -212,17 +212,20 @@ void block_domain(s_time_t until)if (monotonic_clock () < until) {HYPERVISOR_set_timer_op (until); +#ifdef CONFIG_PARAVIRT HYPERVISOR_sched_op (SCHEDOP_block,0 ); +#else +local_irq_enable (); + asmvolatile ("hlt" : : :"memory" ); +#endif local_irq_disable (); +HYPERVISOR_set_timer_op (0 ); } } - -/* -* Just a dummy -*/ static void timer_handler (evtchn_port_t ev,struct pt_regs *regs,void *ign) { +HYPERVISOR_set_timer_op (monotonic_clock () +MILLISECS (1 )); }
Signature · 7 lines
2.6.6 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 22/22] mini-os: support idle for HVMlite
Quoted 9 lines · Juergen Gross, on Tue 23 Aug 2016 17:16:08 +0200, wrote:
Instead of calling
HYPERVISOR_sched_op(SCHEDOP_block, 0)we need to use the "hlt" instruction with interrupts enabled to switch to idle when running as HVMlite domain.This requires to setup a new timer in the timer handler as there is no guarantee the original timer event we are waiting for won't fire between enabling interrupts and calling "hlt".
Signed-off-by Juergen Gross <[email protected]>
Quoted 36 lines
--- arch/x86/time.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)arch/x86/time.c +7
-4@@ -212,17 +212,20 @@ void block_domain(s_time_t until)if (monotonic_clock () < until) {HYPERVISOR_set_timer_op (until); +#ifdef CONFIG_PARAVIRT HYPERVISOR_sched_op (SCHEDOP_block,0 ); +#else +local_irq_enable (); + asmvolatile ("hlt" : : :"memory" ); +#endif local_irq_disable (); +HYPERVISOR_set_timer_op (0 ); } } - -/* -* Just a dummy -*/ static void timer_handler (evtchn_port_t ev,struct pt_regs *regs,void *ign) { +HYPERVISOR_set_timer_op (monotonic_clock () +MILLISECS (1 )); }Signature · 1 line
2.6.6
Signature · 10 lines
Samuel Linux, c'est simple : ça s'adresse à une machine qui est parfois un peu maraboutée mais qui d'habitude n'a pas d'états d'âme. Sur Usenet y'a plein d'humains et de primates, et ça devient vraiment gore par moment. -+- TP in : Guide du linuxien pervers - "Le linuxien a-t-il une âme ?" -+- _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel