[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH RFC v1 54/74] xen/pvshim: set correct domid value
From: Roger Pau Monne <roger.pau@xxxxxxxxxx> If domid is not provided by L0 set domid to 1 by default. Since the domain created is no longer the hardware domain add a hook to the domain shutdown path in order to forward shutdown operations to the L0 hypervisor. Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx> Signed-off-by: Sergey Dyasli <sergey.dyasli@xxxxxxxxxx> --- xen/arch/x86/dom0_build.c | 2 +- xen/arch/x86/guest/xen.c | 5 +++++ xen/arch/x86/pv/shim.c | 19 +++++++++++++++++++ xen/arch/x86/setup.c | 12 +++++++----- xen/common/domain.c | 7 +++++++ xen/include/asm-x86/guest/xen.h | 6 ++++++ xen/include/asm-x86/pv/shim.h | 10 ++++++++++ 7 files changed, 55 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c index 357fd87f39..1c5853690a 100644 --- a/xen/arch/x86/dom0_build.c +++ b/xen/arch/x86/dom0_build.c @@ -473,7 +473,7 @@ int __init construct_dom0(struct domain *d, const module_t *image, int rc; /* Sanity! */ - BUG_ON(d->domain_id != 0); + BUG_ON(!pv_shim && d->domain_id != 0); BUG_ON(d->vcpu[0] == NULL); BUG_ON(d->vcpu[0]->is_initialised); diff --git a/xen/arch/x86/guest/xen.c b/xen/arch/x86/guest/xen.c index b7743e646d..a9de20708c 100644 --- a/xen/arch/x86/guest/xen.c +++ b/xen/arch/x86/guest/xen.c @@ -335,6 +335,11 @@ const unsigned long *__init hypervisor_reserved_pages(unsigned int *size) return reserved_pages; } +uint32_t hypervisor_cpuid_base(void) +{ + return xen_cpuid_base; +} + /* * Local variables: * mode: C diff --git a/xen/arch/x86/pv/shim.c b/xen/arch/x86/pv/shim.c index 5e7e46632b..d318f07d08 100644 --- a/xen/arch/x86/pv/shim.c +++ b/xen/arch/x86/pv/shim.c @@ -20,6 +20,7 @@ */ #include <xen/hypercall.h> #include <xen/init.h> +#include <xen/shutdown.h> #include <xen/types.h> #include <asm/apic.h> @@ -94,6 +95,24 @@ void __init pv_shim_setup_dom(struct domain *d, l4_pgentry_t *l4start, #undef SET_AND_MAP_PARAM } +void pv_shim_shutdown(uint8_t reason) +{ + /* XXX: handle suspend */ + xen_hypercall_shutdown(reason); +} + +domid_t get_dom0_domid(void) +{ + uint32_t eax, ebx, ecx, edx; + + if ( !pv_shim ) + return 0; + + cpuid(hypervisor_cpuid_base() + 1, &eax, &ebx, &ecx, &edx); + + return ebx ?: 1; +} + /* * Local variables: * mode: C diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 9b45a4fd94..34d746395b 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -104,6 +104,8 @@ unsigned long __read_mostly mmu_cr4_features = XEN_MINIMAL_CR4; #define SMEP_HVM_ONLY (-1) static s8 __initdata opt_smep = 1; +static struct domain *__initdata dom0; + static int __init parse_smep_param(const char *s) { if ( !*s ) @@ -576,11 +578,11 @@ static void noinline init_done(void) system_state = SYS_STATE_active; + domain_unpause_by_systemcontroller(dom0); + /* MUST be done prior to removing .init data. */ unregister_init_virtual_region(); - domain_unpause_by_systemcontroller(hardware_domain); - /* Zero the .init code and data. */ for ( va = __init_begin; va < _p(__init_end); va += PAGE_SIZE ) clear_page(va); @@ -659,7 +661,6 @@ void __init noreturn __start_xen(unsigned long mbi_p) unsigned long nr_pages, raw_max_page, modules_headroom, *module_map; int i, j, e820_warn = 0, bytes = 0; bool acpi_boot_table_init_done = false, relocated = false; - struct domain *dom0; struct ns16550_defaults ns16550 = { .data_bits = 8, .parity = 'n', @@ -1617,11 +1618,12 @@ void __init noreturn __start_xen(unsigned long mbi_p) } /* Create initial domain 0. */ - dom0 = domain_create(0, domcr_flags, 0, &config); + dom0 = domain_create(get_dom0_domid(), domcr_flags, 0, &config); if ( IS_ERR(dom0) || (alloc_dom0_vcpu0(dom0) == NULL) ) panic("Error creating domain 0"); - dom0->is_privileged = 1; + if ( !pv_shim ) + dom0->is_privileged = 1; dom0->target = NULL; /* Grab the DOM0 command line. */ diff --git a/xen/common/domain.c b/xen/common/domain.c index 7af8d12512..edbf1a2ba9 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -42,6 +42,7 @@ #include <xen/trace.h> #include <xen/tmem.h> #include <asm/setup.h> +#include <asm/guest.h> /* Linux config option: propageted to domain0 */ /* xen_processor_pmbits: xen control Cx, Px, ... */ @@ -697,6 +698,12 @@ void domain_shutdown(struct domain *d, u8 reason) { struct vcpu *v; + if ( pv_shim ) + { + pv_shim_shutdown(reason); + return; + } + spin_lock(&d->shutdown_lock); if ( d->shutdown_code == SHUTDOWN_CODE_INVALID ) diff --git a/xen/include/asm-x86/guest/xen.h b/xen/include/asm-x86/guest/xen.h index 898156d42e..94f781c30f 100644 --- a/xen/include/asm-x86/guest/xen.h +++ b/xen/include/asm-x86/guest/xen.h @@ -39,6 +39,7 @@ int hypervisor_free_unused_page(mfn_t mfn); void hypervisor_fixup_e820(struct e820map *e820); void hypervisor_init_memory(void); const unsigned long *hypervisor_reserved_pages(unsigned int *size); +uint32_t hypervisor_cpuid_base(void); #else @@ -85,6 +86,11 @@ static inline const unsigned long *hypervisor_reserved_pages(unsigned int *size) ASSERT_UNREACHABLE(); return NULL; }; +static inline uint32_t hypervisor_cpuid_base(void) +{ + ASSERT_UNREACHABLE(); + return 0; +}; #endif /* CONFIG_XEN_GUEST */ #endif /* __X86_GUEST_XEN_H__ */ diff --git a/xen/include/asm-x86/pv/shim.h b/xen/include/asm-x86/pv/shim.h index b0c361cba1..8d4e8d2ae1 100644 --- a/xen/include/asm-x86/pv/shim.h +++ b/xen/include/asm-x86/pv/shim.h @@ -35,6 +35,8 @@ void pv_shim_setup_dom(struct domain *d, l4_pgentry_t *l4start, unsigned long va_start, unsigned long store_va, unsigned long console_va, unsigned long vphysmap, start_info_t *si); +void pv_shim_shutdown(uint8_t reason); +domid_t get_dom0_domid(void); #else @@ -47,6 +49,14 @@ static inline void pv_shim_setup_dom(struct domain *d, l4_pgentry_t *l4start, { ASSERT_UNREACHABLE(); } +static inline void pv_shim_shutdown(uint8_t reason) +{ + ASSERT_UNREACHABLE(); +} +static inline domid_t get_dom0_domid(void) +{ + return 0; +} #endif -- 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |