[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT PATCHv6 04/37] plat/kvm: Add Arm64 basic entry code
From: Wei Chen <Wei.Chen@xxxxxxx> QEMU/KVM can boot an Arm64 elf image without multiboot. In this case, we can plage _libkvmplat_entry to entry64.S directly as the vCPU reset entry. In this basic entry code, we just initialize the boot stack and prepare jumping to _libkvmplat_start. Signed-off-by: Wei Chen <Wei.Chen@xxxxxxx> --- arch/arm/Compiler.uk | 4 +++ arch/arm/Makefile.uk | 4 +++ include/uk/asm.h | 68 +++++++++++++++++++++++++++++++++++++++++ plat/kvm/Config.uk | 2 +- plat/kvm/Makefile.uk | 14 +++++++++ plat/kvm/arm/entry64.S | 69 ++++++++++++++++++++++++++++++++++++++++++ plat/kvm/arm/setup.c | 26 ++++++++++++++++ 7 files changed, 186 insertions(+), 1 deletion(-) create mode 100644 include/uk/asm.h create mode 100644 plat/kvm/arm/entry64.S create mode 100644 plat/kvm/arm/setup.c diff --git a/arch/arm/Compiler.uk b/arch/arm/Compiler.uk index 147f662..3fd0f3f 100644 --- a/arch/arm/Compiler.uk +++ b/arch/arm/Compiler.uk @@ -1,3 +1,7 @@ ifeq ($(CONFIG_UK_ARCH),arm) include $(CONFIG_UK_BASE)/arch/arm/arm/Compiler.uk endif + +ifeq ($(CONFIG_UK_ARCH),arm64) + include $(CONFIG_UK_BASE)/arch/arm/arm64/Compiler.uk +endif diff --git a/arch/arm/Makefile.uk b/arch/arm/Makefile.uk index e59b2a3..11d81fb 100644 --- a/arch/arm/Makefile.uk +++ b/arch/arm/Makefile.uk @@ -2,3 +2,7 @@ ifeq ($(CONFIG_UK_ARCH),arm) include $(CONFIG_UK_BASE)/arch/arm/arm/Makefile.uk endif + +ifeq ($(CONFIG_UK_ARCH),arm64) + include $(CONFIG_UK_BASE)/arch/arm/arm64/Makefile.uk +endif diff --git a/include/uk/asm.h b/include/uk/asm.h new file mode 100644 index 0000000..4be346f --- /dev/null +++ b/include/uk/asm.h @@ -0,0 +1,68 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ +/* + * Authors: Wei Chen <wei.chen@xxxxxxx> + * + * Copyright (c) 2018, Arm Ltd. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY. + */ +#ifndef __INLCUDE_UK_ASM_H__ +#define __INLCUDE_UK_ASM_H__ + +#ifdef __ASSEMBLY__ + +/* Linkage for ASM */ +#define __ALIGN .align 2 +#define __ALIGN_STR ".align 2" + +#define ENTRY(name) \ +.globl name; \ +__ALIGN; \ +name: + +#define GLOBAL(name) \ +.globl name; \ +name: + +#define END(name) \ +.size name, . - name + +#define ENDPROC(name) \ +.type name, %function; \ +END(name) + +#define _AC(X,Y) X +#define _AT(T,X) X + +#else +#define __AC(X,Y) (X##Y) +#define _AC(X,Y) __AC(X,Y) +#define _AT(T,X) ((T)(X)) +#endif + +#endif /* __INLCUDE_UK_ASM_H__ */ diff --git a/plat/kvm/Config.uk b/plat/kvm/Config.uk index 1042a04..4378c26 100644 --- a/plat/kvm/Config.uk +++ b/plat/kvm/Config.uk @@ -1,7 +1,7 @@ menuconfig PLAT_KVM bool "KVM guest" default n - depends on (ARCH_X86_64) + depends on (ARCH_X86_64 || ARCH_ARM_64) select LIBUKDEBUG select LIBUKALLOC select LIBUKTIMECONV diff --git a/plat/kvm/Makefile.uk b/plat/kvm/Makefile.uk index 7e5a865..9f2a01f 100644 --- a/plat/kvm/Makefile.uk +++ b/plat/kvm/Makefile.uk @@ -18,6 +18,10 @@ LIBKVMPLAT_ASINCLUDES-y += -I$(UK_PLAT_COMMON_BASE)/include LIBKVMPLAT_CINCLUDES-y += -I$(LIBKVMPLAT_BASE)/include LIBKVMPLAT_CINCLUDES-y += -I$(UK_PLAT_COMMON_BASE)/include +## +## Architecture library definitions for x86_64 +## +ifeq ($(CONFIG_ARCH_X86_64),y) LIBKVMPLAT_SRCS-$(CONFIG_ARCH_X86_64) += $(UK_PLAT_COMMON_BASE)/x86/trace.c|common LIBKVMPLAT_SRCS-$(CONFIG_ARCH_X86_64) += $(UK_PLAT_COMMON_BASE)/x86/traps.c|common LIBKVMPLAT_SRCS-$(CONFIG_ARCH_X86_64) += $(UK_PLAT_COMMON_BASE)/x86/cpu_native.c|common @@ -39,6 +43,16 @@ endif ifeq ($(findstring y,$(CONFIG_KVM_KERNEL_SERIAL_CONSOLE) $(CONFIG_KVM_DEBUG_SERIAL_CONSOLE)),y) LIBKVMPLAT_SRCS-$(CONFIG_ARCH_X86_64) += $(LIBKVMPLAT_BASE)/x86/serial_console.c endif +endif + +## +## Architecture library definitions for arm64 +## +ifeq ($(CONFIG_ARCH_ARM_64),y) +LIBKVMPLAT_SRCS-$(CONFIG_ARCH_ARM_64) += $(LIBKVMPLAT_BASE)/arm/entry64.S +LIBKVMPLAT_SRCS-$(CONFIG_ARCH_ARM_64) += $(LIBKVMPLAT_BASE)/arm/setup.c +endif + LIBKVMPLAT_SRCS-y += $(LIBKVMPLAT_BASE)/shutdown.c LIBKVMPLAT_SRCS-y += $(LIBKVMPLAT_BASE)/memory.c LIBKVMPLAT_SRCS-y += $(LIBKVMPLAT_BASE)/irq.c diff --git a/plat/kvm/arm/entry64.S b/plat/kvm/arm/entry64.S new file mode 100644 index 0000000..e723caf --- /dev/null +++ b/plat/kvm/arm/entry64.S @@ -0,0 +1,69 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ +/* + * Authors: Wei Chen <wei.chen@xxxxxxx> + * + * Copyright (c) 2018, Arm Ltd. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY. + */ +#include <uk/arch/limits.h> +#include <uk/asm.h> +#include <kvm-arm/mm.h> + +/* + * The registers used by _libkvmplat_start: + * x0 - FDT pointer + */ + +.text +ENTRY(_libkvmplat_entry) + /* Boot stack is placed after pagetable area temporarily */ + ldr x26, =_end + add x26, x26, #PAGE_TABLE_SIZE + add x27, x26, #__STACK_SIZE + + /* + * Clean the boot stack. As _end, PAGE_TABLE_SIZE and BOOT_STACK_SIZE + * are page_size alignment, the boot stack can be 64-bytes alignment + * too. Execute 4 stp consecutively without boundary check would be + * safe here. + */ +1: + stp xzr, xzr, [x26], #16 + stp xzr, xzr, [x26], #16 + stp xzr, xzr, [x26], #16 + stp xzr, xzr, [x26], #16 + cmp x26, x27 + b.lo 1b + + mov sp, x27 + + /* Load dtb address to x0 as a parameter */ + ldr x0, =_dtb + b _libkvmplat_start +END(_libkvmplat_entry) diff --git a/plat/kvm/arm/setup.c b/plat/kvm/arm/setup.c new file mode 100644 index 0000000..2fc4538 --- /dev/null +++ b/plat/kvm/arm/setup.c @@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: ISC */ +/* + * Authors: Wei Chen <Wei.Chen@xxxxxxx> + * + * Copyright (c) 2018 Arm Ltd. + * + * Permission to use, copy, modify, and/or distribute this software + * for any purpose with or without fee is hereby granted, provided + * that the above copyright notice and this permission notice appear + * in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL + * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE + * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS + * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ +#include <uk/assert.h> + +void _libkvmplat_start(void *dtb_pointer) +{ + UK_BUG(); +} -- 2.17.1 _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |