Add new board: Xen guest for ARM64
Subsystems (6)
v2 cover Add new board: Xen guest for ARM64
From: Anastasiia Lukianenko <[email protected]>
This work introduces Xen [1] guest ARM64 board support in U-Boot with para-virtualized (PV) [2] block and serial drivers: xenguest_arm64.
This board is to be run as a virtual Xen guest with U-boot as its primary bootloader. The rationale behind introducing this board is a better and simpler decoupling of the guest from the initial privileged domain which starts a guest?s virtual machine: there are cross dependencies between the guest OS and initial privileged domain (Domain-0) such as Domain-0 needs guest's kernel and may need its device tree to boot it. These dependencies interfere if the kernel or guest OS needs to be updated, thus having a unified bootloader in Domain-0 allows resolving this:
1. U-boot boot scripts, which are stored on the guest?s virtual disk, are guest specific, so any change in the guest?s configuration can be handled by the guest itself.
2. Guest OS? kernel can be updated if OS? needs that without any help from Domain-0.
3. Using the Device Tree Overlay mechanism it is possible to customize the device tree entries yet at bootloader stage inside the guest itself, so the base device tree provided by Xen can be customized.
Xen support for U-boot was implemented by introducing a new Xen guest ARM64 board and porting essential drivers from MiniOS [3] as well as some of the work previously done by NXP [4]:
1. PV block device front driver with XenStore based device enumeration, new UCLASS_PVBLOCK;
2. PV serial console device front driver;
3. Xen hypervisor support with minimal set of the essential headers adapted from Linux kernel;
4. grant table support;
5. event channel support, without IRQ support, but polling;
6. xenbus support;
7. dynamic RAM size as defined in the device tree instead of statically defined values;
8. position-independent pre-relocation code is used as we cannot statically define any start addresses at compile time which is up to Xen to choose at run-time;
9. new defconfig introduced: xenguest_arm64_defconfig.
Please note, that due to the fact that para-virtualized serial driver requires some of the Xen functionality available late not all the printouts are available at the very start including U-Boot banner, memory size etc.
All the above was tested with block driver related commands (info/part/read/write), FAT and ext4 operations work properly, the Linux kernel can start.
Thank you in advance,
Anastasiia Lukianenko,
Oleksandr Andrushchenko
Changes since v1:
=================
1. Added test for new lib sscanf function
2. Fixed data cache maintenance process
3. Added more comments and explanations
4. Removed unnecessary code, which is not related to ARM64 architecture
5. Added board documentation
6. Coding style cleanup
7. Added MIT License
Anastasiia Lukianenko (7):
Add MIT License
xen: pvblock: Add initial support for para-virtualized block driver
xen: pvblock: Enumerate virtual block devices
xen: pvblock: Read XenStore configuration and initialize
xen: pvblock: Implement front-back protocol and do IO
xen: pvblock: Print found devices indices
doc: xen: Add Xen guest ARM64 board documentation
Andrii Anisov (2):
board: Introduce xenguest_arm64 board
lib: sscanf: add sscanf implementation
Oleksandr Andrushchenko (7):
xen: Add essential and required interface headers
xen: Port Xen hypervizor related code from mini-os
xen: Port Xen event channel driver from mini-os linux/compat.h: Add wait_event_timeout macro
xen: Port Xen bus driver from mini-os
xen: Port Xen grant table driver from mini-os
board: xen: De-initialize before jumping to Linux
Peng Fan (2):
Kconfig: Introduce CONFIG_XEN
serial: serial_xen: Add Xen PV serial driver
Kconfig | 18 + Licenses/README | 1 + Licenses/mit.txt | 20 + arch/arm/Kconfig | 9 + arch/arm/cpu/armv8/Makefile | 1 + arch/arm/cpu/armv8/xen/Makefile | 6 + arch/arm/cpu/armv8/xen/hypercall.S | 79 ++ arch/arm/cpu/armv8/xen/lowlevel_init.S | 33 + arch/arm/include/asm/io.h | 4 + arch/arm/include/asm/xen.h | 7 + arch/arm/include/asm/xen/hypercall.h | 22 + arch/arm/include/asm/xen/system.h | 88 +++ board/xen/xenguest_arm64/Kconfig | 12 + board/xen/xenguest_arm64/Makefile | 5 + board/xen/xenguest_arm64/xenguest_arm64.c | 202 +++++ cmd/Kconfig | 7 + cmd/Makefile | 1 + cmd/pvblock.c | 30 + common/board_r.c | 27 + configs/xenguest_arm64_defconfig | 60 ++ disk/part.c | 4 + doc/board/index.rst | 1 + doc/board/xen/index.rst | 9 + doc/board/xen/xenguest_arm64.rst | 81 ++ drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/block/blk-uclass.c | 2 + drivers/serial/Kconfig | 7 + drivers/serial/Makefile | 1 + drivers/serial/serial_xen.c | 182 +++++ drivers/xen/Kconfig | 10 + drivers/xen/Makefile | 10 + drivers/xen/events.c | 199 +++++ drivers/xen/gnttab.c | 216 ++++++ drivers/xen/hypervisor.c | 252 +++++++ drivers/xen/pvblock.c | 867 ++++++++++++++++++++++ drivers/xen/xenbus.c | 557 ++++++++++++++ include/blk.h | 1 + include/configs/xenguest_arm64.h | 52 ++ include/dm/uclass-id.h | 1 + include/linux/compat.h | 54 ++ include/pvblock.h | 17 + include/vsprintf.h | 8 + include/xen.h | 24 + include/xen/arm/interface.h | 88 +++ include/xen/events.h | 42 ++ include/xen/gnttab.h | 24 + include/xen/hvm.h | 27 + include/xen/interface/event_channel.h | 279 +++++++ include/xen/interface/grant_table.h | 565 ++++++++++++++ include/xen/interface/hvm/hvm_op.h | 55 ++ include/xen/interface/hvm/params.h | 116 +++ include/xen/interface/io/blkif.h | 701 +++++++++++++++++ include/xen/interface/io/console.h | 39 + include/xen/interface/io/protocols.h | 28 + include/xen/interface/io/ring.h | 462 ++++++++++++ include/xen/interface/io/xenbus.h | 64 ++ include/xen/interface/io/xs_wire.h | 134 ++++ include/xen/interface/memory.h | 332 +++++++++ include/xen/interface/sched.h | 171 +++++ include/xen/interface/xen.h | 208 ++++++ include/xen/xenbus.h | 116 +++ lib/Kconfig | 4 + lib/Makefile | 1 + lib/sscanf.c | 823 ++++++++++++++++++++ test/lib/Makefile | 1 + test/lib/sscanf.c | 174 +++++ 67 files changed, 7644 insertions(+) create mode 100644 Licenses/mit.txt create mode 100644 arch/arm/cpu/armv8/xen/Makefile create mode 100644 arch/arm/cpu/armv8/xen/hypercall.S create mode 100644 arch/arm/cpu/armv8/xen/lowlevel_init.S create mode 100644 arch/arm/include/asm/xen.h create mode 100644 arch/arm/include/asm/xen/hypercall.h create mode 100644 arch/arm/include/asm/xen/system.h create mode 100644 board/xen/xenguest_arm64/Kconfig create mode 100644 board/xen/xenguest_arm64/Makefile create mode 100644 board/xen/xenguest_arm64/xenguest_arm64.c create mode 100644 cmd/pvblock.c create mode 100644 configs/xenguest_arm64_defconfig create mode 100644 doc/board/xen/index.rst create mode 100644 doc/board/xen/xenguest_arm64.rst create mode 100644 drivers/serial/serial_xen.c create mode 100644 drivers/xen/Kconfig create mode 100644 drivers/xen/Makefile create mode 100644 drivers/xen/events.c create mode 100644 drivers/xen/gnttab.c create mode 100644 drivers/xen/hypervisor.c create mode 100644 drivers/xen/pvblock.c create mode 100644 drivers/xen/xenbus.c create mode 100644 include/configs/xenguest_arm64.h create mode 100644 include/pvblock.h create mode 100644 include/xen.h create mode 100644 include/xen/arm/interface.h create mode 100644 include/xen/events.h create mode 100644 include/xen/gnttab.h create mode 100644 include/xen/hvm.h create mode 100644 include/xen/interface/event_channel.h create mode 100644 include/xen/interface/grant_table.h create mode 100644 include/xen/interface/hvm/hvm_op.h create mode 100644 include/xen/interface/hvm/params.h create mode 100644 include/xen/interface/io/blkif.h create mode 100644 include/xen/interface/io/console.h create mode 100644 include/xen/interface/io/protocols.h create mode 100644 include/xen/interface/io/ring.h create mode 100644 include/xen/interface/io/xenbus.h create mode 100644 include/xen/interface/io/xs_wire.h create mode 100644 include/xen/interface/memory.h create mode 100644 include/xen/interface/sched.h create mode 100644 include/xen/interface/xen.h create mode 100644 include/xen/xenbus.h create mode 100644 lib/sscanf.c create mode 100644 test/lib/sscanf.c
Signature · 1 line
2.17.1
PATCH RESEND v2 1/18 Add MIT License
From: Anastasiia Lukianenko <[email protected]>
---
Changes since v1:
- this patch appeared in the second version of patch series for the correct assignment of licenses in the corresponding files.
Licenses/README | 1 + Licenses/mit.txt | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 Licenses/mit.txt
Licenses/README +1 -0
@@ -149,5 +149,6 @@ BSD 3-clause "New" or "Revised" License BSD-3-Clause Y bsd-3-clause.txt http:/ IBM PIBS (PowerPC Initialization and IBM-pibs ibm-pibs.txt Boot Software) license ISC License ISC Y isc.txt https://spdx.org/licenses/ISC +MIT License MIT Y mit.txt https://spdx.org/licenses/MIT.html SIL OPEN FONT LICENSE (OFL-1.1) OFL-1.1 Y OFL.txt https://spdx.org/licenses/OFL-1.1.html X11 License X11 x11.txt https://spdx.org/licenses/X11.html
Licenses/mit.txt new file +20 -0
@@ -0,0 +1,20 @@ +MIT License +Copyright (c) 2020 EPAM Systems Inc. + +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.
Signature · 1 line
2.17.1
PATCH RESEND v2 1/18 Add MIT License
Quoted 3 lines · Anastasiia Lukianenko
From: Anastasiia Lukianenko <[email protected]>
Signed-off-by Anastasiia Lukianenko <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200814/a0a8f9b4/attachment.sig>
PATCH RESEND v2 2/18 Kconfig: Introduce CONFIG_XEN
In reply to Anastasiia LukianenkoFrom: Peng Fan <[email protected]>
Introduce CONFIG_XEN to make U-Boot could be used as bootloader for a virtual machine.
Without bootloader, we could successfully boot up android on XEN, but we need need bootloader to support A/B, dm verify and etc.
---
Changes since v1:
- remove "default n" option
- add more detailes in "help" section
Kconfig | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
Kconfig +18 -0
@@ -105,6 +105,24 @@ config CC_COVERAGE config CC_HAS_ASM_INLINE def_bool $(success,echo 'void foo(void) { asm inline (""); }' | $(CC) -x c - -c -o /dev/null) +config XEN + bool "Select U-Boot be run as a bootloader for XEN Virtual Machine" + help + Enabling this option will make U-Boot be run as a bootloader + for XEN [1] Virtual Machine. + + Xen is a virtual machine monitor (VMM) or a type-1 hypervisor with support + for para-virtualization. Xen can organize the safe execution of several + virtual machines on the same physical system with performance close to + native. It is used as the basis for a number of different commercial and + open source applications, such as: server virtualization, Infrastructure + as a Service (IaaS), desktop virtualization, security applications, + embedded and hardware appliances. + Xen has a special VM called Domain-0 that runs the Dom0 kernel and allows + Xen to use the device drivers for the Domain-0 kernel by default. + + [1] - https://xenproject.org/ + config DISTRO_DEFAULTS bool "Select defaults suitable for booting general purpose Linux distributions" select AUTO_COMPLETE
Signature · 1 line
2.17.1
PATCH RESEND v2 2/18 Kconfig: Introduce CONFIG_XEN
Quoted 11 lines · Anastasiia Lukianenko
From: Peng Fan <[email protected]>
Introduce
CONFIG_XENto make U-Boot could be used as bootloader for a virtual machine.Without bootloader, we could successfully boot up android on XEN, but we need need bootloader to support A/B, dm verify and etc.
Signed-off-by Peng Fan <[email protected]>Signed-off-by Oleksandr Andrushchenko <[email protected]>Signed-off-by Anastasiia Lukianenko <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200814/e576c342/attachment.sig>
PATCH RESEND v2 3/18 xen: Add essential and required interface headers
In reply to Anastasiia LukianenkoFrom: Oleksandr Andrushchenko <[email protected]>
Add essential and required Xen interface headers only taken from the stable Linux kernel stable/linux-5.7.y at commit 66dfe4522160 Linux 5.7.5.
These are better suited for U-boot than the original headers from Xen as they are the stripped versions of the same.
At the same time use public protocols from Xen RELEASE-4.13.1, at commit 6278553325a9 update Xen version to 4.13.1
as those have more comments in them.
---
Changes since v1:
- update the commit message by the rule "commit <12+> ("commit header")"
include/xen/arm/interface.h | 88 ++++ include/xen/interface/event_channel.h | 279 ++++++++++ include/xen/interface/grant_table.h | 565 +++++++++++++++++++++ include/xen/interface/hvm/hvm_op.h | 55 ++ include/xen/interface/hvm/params.h | 116 +++++ include/xen/interface/io/blkif.h | 701 ++++++++++++++++++++++++++ include/xen/interface/io/console.h | 39 ++ include/xen/interface/io/protocols.h | 28 + include/xen/interface/io/ring.h | 462 +++++++++++++++++ include/xen/interface/io/xenbus.h | 64 +++ include/xen/interface/io/xs_wire.h | 134 +++++ include/xen/interface/memory.h | 332 ++++++++++++ include/xen/interface/sched.h | 171 +++++++ include/xen/interface/xen.h | 208 ++++++++ 14 files changed, 3242 insertions(+) create mode 100644 include/xen/arm/interface.h create mode 100644 include/xen/interface/event_channel.h create mode 100644 include/xen/interface/grant_table.h create mode 100644 include/xen/interface/hvm/hvm_op.h create mode 100644 include/xen/interface/hvm/params.h create mode 100644 include/xen/interface/io/blkif.h create mode 100644 include/xen/interface/io/console.h create mode 100644 include/xen/interface/io/protocols.h create mode 100644 include/xen/interface/io/ring.h create mode 100644 include/xen/interface/io/xenbus.h create mode 100644 include/xen/interface/io/xs_wire.h create mode 100644 include/xen/interface/memory.h create mode 100644 include/xen/interface/sched.h create mode 100644 include/xen/interface/xen.h
include/xen/arm/interface.h new file +88 -0
@@ -0,0 +1,88 @@ +/* SPDX-License-Identifier: GPL-2.0 +* +* Guest OS interface to ARM Xen. +* +* Stefano Stabellini <[email protected]>, Citrix, 2012 +*/ + +#ifndef _ASM_ARM_XEN_INTERFACE_H +#define _ASM_ARM_XEN_INTERFACE_H + +#ifndef __ASSEMBLY__ +#include <linux/types.h> +#endif + +#define uint64_aligned_t u64 __attribute__((aligned(8))) + +#define __DEFINE_GUEST_HANDLE (name, type) \ + typedef struct { union { type * p; uint64_aligned_t q; }; } \ + __guest_handle_ ## name + +#define DEFINE_GUEST_HANDLE_STRUCT (name) \ + __DEFINE_GUEST_HANDLE(name, struct name) +#define DEFINE_GUEST_HANDLE (name) __DEFINE_GUEST_HANDLE(name, name) +#define GUEST_HANDLE (name) __guest_handle_ ## name + +#define set_xen_guest_handle (hnd, val) \ + do { \ + if (sizeof(hnd) == 8) \ + *(u64 *)&(hnd) = 0; \ + (hnd).p = val; \ + } while (0) + +#define __HYPERVISOR_platform_op_raw __HYPERVISOR_platform_op + +#ifndef __ASSEMBLY__ +/* Explicitly size integers that represent pfns in the interface with +* Xen so that we can have one ABI that works for 32 and 64 bit guests. +* Note that this means that the xen_pfn_t type may be capable of +* representing pfn's which the guest cannot represent in its own pfn +* type. However since pfn space is controlled by the guest this is +* fine since it simply wouldn't be able to create any sure pfns in +* the first place. +*/ +typedef u64 xen_pfn_t ; +#define PRI_xen_pfn "llx" +typedef u64 xen_ulong_t ; +#define PRI_xen_ulong "llx" +typedef s64 xen_long_t ; +#define PRI_xen_long "llx" +/* Guest handles for primitive C types. */ +__DEFINE_GUEST_HANDLE(uchar, unsigned char); +__DEFINE_GUEST_HANDLE(uint, unsigned int); +DEFINE_GUEST_HANDLE (char); +DEFINE_GUEST_HANDLE (int); +DEFINE_GUEST_HANDLE (void); +DEFINE_GUEST_HANDLE (u64); +DEFINE_GUEST_HANDLE (u32); +DEFINE_GUEST_HANDLE (xen_pfn_t); +DEFINE_GUEST_HANDLE (xen_ulong_t); + +/* Maximum number of virtual CPUs in multi-processor guests. */ +#define MAX_VIRT_CPUS 1 + +struct arch_vcpu_info { }; +struct arch_shared_info { }; + +/* TODO: Move pvclock definitions some place arch independent */ +struct pvclock_vcpu_time_info { +u32 version; +u32 pad0; +u64 tsc_timestamp; +u64 system_time; +u32 tsc_to_system_mul; +s8 tsc_shift; +u8 flags; +u8 pad[2 ]; +} __attribute__((__packed__ ));/* 32 bytes */ + +/* It is OK to have a 12 bytes struct with no padding because it is packed */ +struct pvclock_wall_clock { +u32 version; +u32 sec; +u32 nsec; +u32 sec_hi; +} __attribute__((__packed__ )); +#endif + +#endif /* _ASM_ARM_XEN_INTERFACE_H */
include/xen/interface/event_channel.h new file +279 -0
279 lines not on this page · raw message
include/xen/interface/grant_table.h new file +565 -0
565 lines not on this page · raw message
include/xen/interface/hvm/hvm_op.h new file +55 -0
55 lines not on this page · raw message
include/xen/interface/hvm/params.h new file +116 -0
116 lines not on this page · raw message
include/xen/interface/io/blkif.h new file +701 -0
701 lines not on this page · raw message
include/xen/interface/io/console.h new file +39 -0
@@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: MIT +* +* console.h +* +* Console I/O interface for Xen guest OSes. +* +* Copyright (c) 2005, Keir Fraser +*/ + +#ifndef __XEN_PUBLIC_IO_CONSOLE_H__ +#define __XEN_PUBLIC_IO_CONSOLE_H__ + +typedef u32 XENCONS_RING_IDX ; + +#define MASK_XENCONS_IDX (idx, ring) ((idx) & (sizeof(ring) - 1)) + +struct xencons_interface { +char in[1024 ]; +char out[2048 ]; +XENCONS_RING_IDX in_cons, in_prod; +XENCONS_RING_IDX out_cons, out_prod; +}; + +#ifdef XEN_WANT_FLEX_CONSOLE_RING +#include "ring.h" +DEFINE_XEN_FLEX_RING (xencons); +#endif + +#endif /* __XEN_PUBLIC_IO_CONSOLE_H__ */ + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* tab-width: 4 +* indent-tabs-mode: nil +* End: +*/
include/xen/interface/io/protocols.h new file +28 -0
@@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: MIT +* +* protocols.h +* +* Copyright (c) 2008, Keir Fraser +* +* Xen protocols, which are used as ABI rules governing the format of all +* ring request and response structures. +*/ + +#ifndef __XEN_PROTOCOLS_H__ +#define __XEN_PROTOCOLS_H__ + +#define XEN_IO_PROTO_ABI_X86_32 "x86_32-abi" +#define XEN_IO_PROTO_ABI_X86_64 "x86_64-abi" +#define XEN_IO_PROTO_ABI_ARM "arm-abi" + +#if defined(__i386__) +# define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_X86_32 +#elif defined(__x86_64__) +# define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_X86_64 +#elif defined(__arm__) || defined(__aarch64__) +# define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_ARM +#else +# error arch fixup needed here +#endif + +#endif
include/xen/interface/io/ring.h new file +462 -0
462 lines not on this page · raw message
include/xen/interface/io/xenbus.h new file +64 -0
64 lines not on this page · raw message
include/xen/interface/io/xs_wire.h new file +134 -0
134 lines not on this page · raw message
include/xen/interface/memory.h new file +332 -0
332 lines not on this page · raw message
include/xen/interface/sched.h new file +171 -0
137 lines not on this page · raw message
include/xen/interface/xen.h new file +208 -0
208 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.17.1
Part of the diff is not shown here. View the raw message.
PATCH RESEND v2 3/18 xen: Add essential and required interface headers
Quoted 9 lines · Anastasiia Lukianenko
From: Oleksandr Andrushchenko <[email protected]>
Add essential and required Xen interface headers only taken from the stable Linux kernel stable/linux-5.7.y at commit
66dfe4522160Linux 5.7.5.These are better suited for U-boot than the original headers from Xen as they are the stripped versions of the same.
Quoted 7 lines
At the same time use public protocols from Xen RELEASE-4.13.1, at commit
6278553325a9update Xen version to 4.13.1
as those have more comments in them.Signed-off-by Oleksandr Andrushchenko <[email protected]>Signed-off-by Anastasiia Lukianenko <[email protected]>Acked-by Peng Fan <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200814/8bcb3b19/attachment.sig>
PATCH RESEND v2 4/18 board: Introduce xenguest_arm64 board
In reply to Anastasiia LukianenkoFrom: Andrii Anisov <[email protected]>
Introduce a minimal Xen guest board running as a virtual machine under Xen Project's hypervisor [1], [2].
Part of the code is ported from Xen mini-os and also uses work initially done by different authors from NXP: please see relevant files for their copyrights.
[1] https://xenbits.xen.org
[2] https://wiki.xenproject.org/
---
Changes since v1:
- the patch order changed to respect git bisect:
board: Introduce xenguest_arm64 board
xen: Add essential and required interface headers
Kconfig: Introduce CONFIG_XEN
arch/arm/Kconfig | 7 + arch/arm/cpu/armv8/Makefile | 1 + arch/arm/cpu/armv8/xen/Makefile | 6 + arch/arm/cpu/armv8/xen/hypercall.S | 79 +++++++++++ arch/arm/cpu/armv8/xen/lowlevel_init.S | 33 +++++ arch/arm/include/asm/xen.h | 7 + arch/arm/include/asm/xen/hypercall.h | 22 ++++ board/xen/xenguest_arm64/Kconfig | 12 ++ board/xen/xenguest_arm64/Makefile | 5 + board/xen/xenguest_arm64/xenguest_arm64.c | 152 ++++++++++++++++++++++ configs/xenguest_arm64_defconfig | 56 ++++++++ include/configs/xenguest_arm64.h | 44 +++++++ 12 files changed, 424 insertions(+) create mode 100644 arch/arm/cpu/armv8/xen/Makefile create mode 100644 arch/arm/cpu/armv8/xen/hypercall.S create mode 100644 arch/arm/cpu/armv8/xen/lowlevel_init.S create mode 100644 arch/arm/include/asm/xen.h create mode 100644 arch/arm/include/asm/xen/hypercall.h create mode 100644 board/xen/xenguest_arm64/Kconfig create mode 100644 board/xen/xenguest_arm64/Makefile create mode 100644 board/xen/xenguest_arm64/xenguest_arm64.c create mode 100644 configs/xenguest_arm64_defconfig create mode 100644 include/configs/xenguest_arm64.h
arch/arm/Kconfig +7 -0
@@ -1739,6 +1739,12 @@ config TARGET_PRESIDIO_ASIC bool "Support Cortina Presidio ASIC Platform" select ARM64 +config TARGET_XENGUEST_ARM64 + bool "Xen guest ARM64" + select ARM64 + select XEN + select OF_CONTROL + select LINUX_KERNEL_IMAGE_HEADER endchoice config ARCH_SUPPORT_TFABOOT
@@ -1939,6 +1945,7 @@ source "board/xilinx/Kconfig" source "board/xilinx/zynq/Kconfig" source "board/xilinx/zynqmp/Kconfig" source "board/phytium/durian/Kconfig" +source "board/xen/xenguest_arm64/Kconfig" source "arch/arm/Kconfig.debug"
arch/arm/cpu/armv8/Makefile +1 -0
@@ -39,3 +39,4 @@ obj-$(CONFIG_S32V234) += s32v234/ obj-$(CONFIG_TARGET_HIKEY) += hisilicon/ obj-$(CONFIG_ARMV8_PSCI) += psci.o obj-$(CONFIG_ARCH_SUNXI) += lowlevel_init.o +obj-$(CONFIG_XEN) += xen/
arch/arm/cpu/armv8/xen/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# (C) 2018 NXP +# (C) 2020 EPAM Systems Inc. + +obj-y += lowlevel_init.o hypercall.o
arch/arm/cpu/armv8/xen/hypercall.S new file +79 -0
79 lines not on this page · raw message
arch/arm/cpu/armv8/xen/lowlevel_init.S new file +33 -0
@@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: GPL-2.0+ + * + * (C) 2017 NXP + * (C) 2020 EPAM Systems Inc. + */ + +#include <config.h> + +.align 8 +.global rom_pointer +rom_pointer: + .space 32 + +/* + * Routine: save_boot_params (called after reset from start.S) + */ + +.global save_boot_params +save_boot_params: + /* The firmware provided ATAG/FDT address can be found in r2/x0 */ + adr x1, rom_pointer + stp x0, x2, [x1], #16 + stp x3, x4, [x1], #16 + + /* Returns */ + b save_boot_params_ret + +.global restore_boot_params +restore_boot_params: + adr x1, rom_pointer + ldp x0, x2, [x1], #16 + ldp x3, x4, [x1], #16 + ret
arch/arm/include/asm/xen.h new file +7 -0
@@ -0,0 +1,7 @@ +/* SPDX-License-Identifier: GPL-2.0+ +* +* (C) 2020 EPAM Systems Inc. +*/ + +extern unsigned long rom_pointer[]; +
arch/arm/include/asm/xen/hypercall.h new file +22 -0
@@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0 +* +* hypercall.h +* +* Linux-specific hypervisor handling. +* +* Stefano Stabellini <[email protected]>, Citrix, 2012 +*/ + +#ifndef _ASM_ARM_XEN_HYPERCALL_H +#define _ASM_ARM_XEN_HYPERCALL_H + +#include <xen/interface/xen.h> + +int HYPERVISOR_xen_version (int cmd,void *arg); +int HYPERVISOR_console_io (int cmd,int count,char *str); +int HYPERVISOR_grant_table_op (unsigned int cmd,void *uop,unsigned int count); +int HYPERVISOR_sched_op (int cmd,void *arg); +int HYPERVISOR_event_channel_op (int cmd,void *arg); +unsigned long HYPERVISOR_hvm_op (int op,void *arg); +int HYPERVISOR_memory_op (unsigned int cmd,void *arg); +#endif /* _ASM_ARM_XEN_HYPERCALL_H */
board/xen/xenguest_arm64/Kconfig new file +12 -0
@@ -0,0 +1,12 @@ +if TARGET_XENGUEST_ARM64 + +config SYS_BOARD + default "xenguest_arm64" + +config SYS_VENDOR + default "xen" + +config SYS_CONFIG_NAME + default "xenguest_arm64" + +endif
board/xen/xenguest_arm64/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# (C) Copyright 2020 EPAM Systems Inc. + +obj-y := xenguest_arm64.o
board/xen/xenguest_arm64/xenguest_arm64.c new file +152 -0
152 lines not on this page · raw message
configs/xenguest_arm64_defconfig new file +56 -0
56 lines not on this page · raw message
include/configs/xenguest_arm64.h new file +44 -0
44 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH RESEND v2 4/18 board: Introduce xenguest_arm64 board
Quoted 9 lines · Anastasiia Lukianenko
From: Andrii Anisov <[email protected]>
Introduce a minimal Xen guest board running as a virtual machine under Xen Project's hypervisor [1], [2].
Part of the code is ported from Xen mini-os and also uses work initially done by different authors from NXP: please see relevant files for their copyrights.
Quoted 6 lines
[1] https://xenbits.xen.org
[2] https://wiki.xenproject.org/Signed-off-by Andrii Anisov <[email protected]>Signed-off-by Oleksandr Andrushchenko <[email protected]>Signed-off-by Anastasiia Lukianenko <[email protected]>
So, first:
Applied to u-boot/master, thanks!
But as I go over the whole series, a few things to please follow up on:
- All of the xen-related drivers, etc, should be listed in MAINTAINERS, I added one for the board files.
- Do you really need atags?
- There is no "CONFIG_CMD_RUN".
- You define CONFIG_BOARD_EARLY_INIT_F and then provide an empty function. I think you can just drop both.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200814/d2d6a49a/attachment.sig>
PATCH RESEND v2 5/18 xen: Port Xen hypervisor related code from mini-os
In reply to Anastasiia LukianenkoFrom: Oleksandr Andrushchenko <[email protected]>
Port hypervisor related code from Mini-OS. This is referencing the code of Mini-OS from [1] by Huang Shijie and Volodymyr Babchuk which is for ARM64.
Update essential arch code to support required bit operations, memory barriers etc.
Copyright for the bits ported belong to at least the following authors, please see related files for details:
Copyright (c) 2002-2003, K A Fraser
Copyright (c) 2005, Grzegorz Milos, gm281 at cam.ac.uk,Intel Research Cambridge Copyright (c) 2014, Karim Allah Ahmed <[email protected]>
[1] - https://github.com/zyzii/mini-os.git
---
Changes since v1:
- s/hypervizor/hypervisor/
- update the commit message
- remove duplicated defined barriers
- remove x86 related code
- add more comments
- make hvm_get_parameter_maintain_dcache function safer
arch/arm/include/asm/io.h | 4 + arch/arm/include/asm/xen/system.h | 88 +++++++++++ common/board_r.c | 13 ++ drivers/Makefile | 1 + drivers/xen/Makefile | 5 + drivers/xen/hypervisor.c | 240 ++++++++++++++++++++++++++++++ include/xen.h | 15 ++ include/xen/hvm.h | 27 ++++ 8 files changed, 393 insertions(+) create mode 100644 arch/arm/include/asm/xen/system.h create mode 100644 drivers/xen/Makefile create mode 100644 drivers/xen/hypervisor.c create mode 100644 include/xen.h create mode 100644 include/xen/hvm.h
arch/arm/include/asm/io.h +4 -0
@@ -110,9 +110,13 @@ static inline void __raw_readsl(unsigned long addr, void *data, int longlen)* have some advantages to use them instead of the simple one here. */ #define mb () dsb() +#define rmb () dsb() +#define wmb () dsb()#define __iormb () dmb()#define __iowmb () dmb() +#define smp_processor_id () 0 +#define writeb (v,c) ({ u8 __v = v; __iowmb(); __arch_putb(__v,c); __v; })#define writew (v,c) ({ u16 __v = v; __iowmb(); __arch_putw(__v,c); __v; })#define writel (v,c) ({ u32 __v = v; __iowmb(); __arch_putl(__v,c); __v; })
arch/arm/include/asm/xen/system.h new file +88 -0
88 lines not on this page · raw message
common/board_r.c +13 -0
@@ -56,6 +56,9 @@#include <timer.h> #include <trace.h> #include <watchdog.h> +#ifdef CONFIG_XEN +#include <xen.h> +#endif #ifdef CONFIG_ADDR_MAP #include <asm/mmu.h> #endif
@@ -462,6 +465,13 @@ static int initr_mmc(void) }#endif +#ifdef CONFIG_XEN +static int initr_xen (void ) +{ +xen_init (); +return 0 ; +} +#endif /* * Tell if it's OK to load the environment early in boot. *
@@ -755,6 +765,9 @@ static init_fnc_t init_sequence_r[] = {#endif #ifdef CONFIG_MMC initr_mmc, +#endif +#ifdef CONFIG_XEN + initr_xen, #endif initr_env, #ifdef CONFIG_SYS_BOOTPARAMS_LEN
drivers/Makefile +1 -0
@@ -28,6 +28,7 @@ obj-$(CONFIG_$(SPL_)REMOTEPROC) += remoteproc/ obj-$(CONFIG_$(SPL_TPL_)TPM) += tpm/ obj-$(CONFIG_$(SPL_TPL_)ACPI_PMC) += power/acpi_pmc/ obj-$(CONFIG_$(SPL_)BOARD) += board/ +obj-$(CONFIG_XEN) += xen/ ifndef CONFIG_TPL_BUILD ifdef CONFIG_SPL_BUILD
drivers/xen/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# (C) Copyright 2020 EPAM Systems Inc. + +obj-y += hypervisor.o
drivers/xen/hypervisor.c new file +240 -0
240 lines not on this page · raw message
include/xen.h new file +15 -0
@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 +* +* (C) 2020, EPAM Systems Inc. +*/ +#ifndef __XEN_H__ +#define __XEN_H__ + +/** +* xen_init() - Xen initialization +* +* Map Xen memory pages. +*/ +void xen_init (void ); + +#endif /* __XEN_H__ */
include/xen/hvm.h new file +27 -0
@@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0 +* +* Simple wrappers around HVM functions +* +* Copyright (c) 2002-2003, K A Fraser +* Copyright (c) 2005, Grzegorz Milos, gm281 at cam.ac.uk,Intel Research Cambridge +* Copyright (c) 2020, EPAM Systems Inc. +*/ +#ifndef XEN_HVM_H__ +#define XEN_HVM_H__ + +#include <asm/xen/hypercall.h> +#include <xen/interface/hvm/params.h> +#include <xen/interface/xen.h> + +extern struct shared_info *HYPERVISOR_shared_info; + +int hvm_get_parameter (int idx,uint64_t *value); +int hvm_get_parameter_maintain_dcache (int idx,uint64_t *value); + +struct shared_info *map_shared_info (void *p); +void do_hypervisor_callback (struct pt_regs *regs); +void mask_evtchn (uint32_t port); +void unmask_evtchn (uint32_t port); +void clear_evtchn (uint32_t port); + +#endif /* XEN_HVM_H__ */
Signature · 1 line
2.17.1
PATCH RESEND v2 5/18 xen: Port Xen hypervisor related code from mini-os
Quoted 11 lines · Anastasiia Lukianenko
From: Oleksandr Andrushchenko <[email protected]>
Port hypervisor related code from Mini-OS. This is referencing the code of Mini-OS from [1] by Huang Shijie and Volodymyr Babchuk which is for ARM64.
Update essential arch code to support required bit operations, memory barriers etc.Copyright for the bits ported belong to at least the following authors, please see related files for details:
Quoted 8 lines
Copyright (c) 2002-2003, K A Fraser
Copyright (c) 2005, Grzegorz Milos, gm281 at cam.ac.uk,Intel Research Cambridge Copyright (c) 2014, Karim Allah Ahmed <[email protected]>[1] - https://github.com/zyzii/mini-os.git
Signed-off-by Oleksandr Andrushchenko <[email protected]>Signed-off-by Anastasiia Lukianenko <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200814/5103a559/attachment.sig>
PATCH RESEND v2 6/18 xen: Port Xen event channel driver from mini-os
In reply to Anastasiia LukianenkoFrom: Oleksandr Andrushchenko <[email protected]>
Make required updates to run on u-boot. Strip functionality not needed by U-boot.
---
Changes since v1:
- correct code style
- remove typedefs
- add comments
drivers/xen/Makefile | 1 + drivers/xen/events.c | 195 +++++++++++++++++++++++++++++++++++++++ drivers/xen/hypervisor.c | 6 +- include/xen.h | 2 +- include/xen/events.h | 42 +++++++++ 5 files changed, 242 insertions(+), 4 deletions(-) create mode 100644 drivers/xen/events.c create mode 100644 include/xen/events.h
drivers/xen/Makefile +1 -0
@@ -3,3 +3,4 @@ # (C) Copyright 2020 EPAM Systems Inc. obj-y += hypervisor.o +obj-y += events.o
drivers/xen/events.c new file +195 -0
195 lines not on this page · raw message
drivers/xen/hypervisor.c +3 -3
@@ -20,6 +20,7 @@#include <linux/bug.h> #include <xen/hvm.h> +#include <xen/events.h> #include <xen/interface/memory.h> #define active_evtchns (cpu, sh, idx) \
@@ -163,9 +164,7 @@ void do_hypervisor_callback(struct pt_regs *regs) l2 &= ~(1UL << l2i); port = (l1i * (sizeof (unsigned long ) *8 )) + l2i; -/* TODO: handle new event: do_event(port, regs); */ -/* Suppress -Wunused-but-set-variable */ - (void )(port); +do_event (port, regs); } }
@@ -236,5 +235,6 @@ void xen_init(void)debug ("%s\n" , __func__);map_shared_info (NULL ); +init_events (); }
include/xen.h +1 -1
@@ -8,7 +8,7 @@/** * xen_init() - Xen initialization * -* Map Xen memory pages. +* Map Xen memory pages, initialize event handler. */ void xen_init (void );
include/xen/events.h new file +42 -0
42 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH RESEND v2 6/18 xen: Port Xen event channel driver from mini-os
Quoted 7 lines · Anastasiia Lukianenko
From: Oleksandr Andrushchenko <[email protected]>
Make required updates to run on u-boot. Strip functionality not needed by U-boot.
Signed-off-by Oleksandr Andrushchenko <[email protected]>Signed-off-by Anastasiia Lukianenko <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200814/3e1eb2ff/attachment.sig>
PATCH RESEND v2 7/18 serial: serial_xen: Add Xen PV serial driver
In reply to Anastasiia LukianenkoFrom: Peng Fan <[email protected]>
Add support for Xen para-virtualized serial driver. This driver fully supports serial console for the virtual machine.
Please note that as the driver is initialized late, so no banner nor memory size is visible.
---
Changes since v1:
- move "CONFIG_DM=y" option to
[PATCH v2 04/18] board: Introduce xenguest_arm64 board
- correct return values in xen_serial_probe function
- add comments
- correct code style
arch/arm/Kconfig | 1 + board/xen/xenguest_arm64/xenguest_arm64.c | 31 +++- configs/xenguest_arm64_defconfig | 2 +- drivers/serial/Kconfig | 7 + drivers/serial/Makefile | 1 + drivers/serial/serial_xen.c | 182 ++++++++++++++++++++++ drivers/xen/events.c | 4 + 7 files changed, 220 insertions(+), 8 deletions(-) create mode 100644 drivers/serial/serial_xen.c
arch/arm/Kconfig +1 -0
@@ -1745,6 +1745,7 @@ config TARGET_XENGUEST_ARM64 select XEN select OF_CONTROL select LINUX_KERNEL_IMAGE_HEADER + select XEN_SERIAL endchoice config ARCH_SUPPORT_TFABOOT
board/xen/xenguest_arm64/xenguest_arm64.c +24 -7
@@ -17,9 +17,12 @@#include <asm/armv8/mmu.h> #include <asm/xen.h> #include <asm/xen/hypercall.h> +#include <asm/xen/system.h> #include <linux/compiler.h> +#include <xen/hvm.h> +DECLARE_GLOBAL_DATA_PTR ;int board_init (void )
@@ -56,9 +59,28 @@ static int get_next_memory_node(const void *blob, int mem)static int setup_mem_map (void ) { -int i, ret, mem, reg =0 ; +int i =0 , ret, mem, reg =0 ;struct fdt_resource res;const void *blob = gd->fdt_blob; +u64 gfn; + +/* +* Add "magic" region which is used by Xen to provide some essentials +* for the guest: we need console. +*/ + ret =hvm_get_parameter_maintain_dcache (HVM_PARAM_CONSOLE_PFN , &gfn); +if (ret <0 ) { +printf ("%s: Can't get HVM_PARAM_CONSOLE_PFN, ret %d\n" , + __func__, ret); +return -EINVAL ; + } + + xen_mem_map[i].virt =PFN_PHYS (gfn); + xen_mem_map[i].phys =PFN_PHYS (gfn); + xen_mem_map[i].size =PAGE_SIZE ; + xen_mem_map[i].attrs = (PTE_BLOCK_MEMTYPE (MT_NORMAL ) | +PTE_BLOCK_INNER_SHARE ); + i++; mem =get_next_memory_node (blob,-1 );if (mem <0 ) {
@@ -66,7 +88,7 @@ static int setup_mem_map(void)return -EINVAL ; } -for (i =0 ; i <MAX_MEM_MAP_REGIONS ; i++) { +for (; i <MAX_MEM_MAP_REGIONS ; i++) { ret =fdt_get_resource (blob, mem,"reg" , reg++, &res);if (ret == -FDT_ERR_NOTFOUND ) { reg =0 ;
@@ -145,8 +167,3 @@ int print_cpuinfo(void)return 0 ; } -__weak struct serial_device *default_serial_console (void ) -{ -return NULL ; -} -
configs/xenguest_arm64_defconfig +1 -1
@@ -49,7 +49,7 @@ CONFIG_CMD_UMS=n CONFIG_DM=y # CONFIG_MMC is not set -# CONFIG_DM_SERIAL is not set +CONFIG_DM_SERIAL=y # CONFIG_REQUIRE_SERIAL_CONSOLE is not set CONFIG_OF_BOARD=y
drivers/serial/Kconfig +7 -0
@@ -821,6 +821,13 @@ config MPC8XX_CONS depends on MPC8xx default y +config XEN_SERIAL + bool "XEN serial support" + depends on XEN + help + If built without DM support, then requires Xen + to be built with CONFIG_VERBOSE_DEBUG. + choice prompt "Console port" default 8xx_CONS_SMC1
drivers/serial/Makefile +1 -0
@@ -70,6 +70,7 @@ obj-$(CONFIG_OWL_SERIAL) += serial_owl.o obj-$(CONFIG_OMAP_SERIAL) += serial_omap.o obj-$(CONFIG_MTK_SERIAL) += serial_mtk.o obj-$(CONFIG_SIFIVE_SERIAL) += serial_sifive.o +obj-$(CONFIG_XEN_SERIAL) += serial_xen.o ifndef CONFIG_SPL_BUILD obj-$(CONFIG_USB_TTY) += usbtty.o
drivers/serial/serial_xen.c new file +182 -0
182 lines not on this page · raw message
drivers/xen/events.c +4 -0
@@ -23,6 +23,8 @@#include <xen/events.h> #include <xen/hvm.h> +extern u32 console_evtchn; +#define NR_EVS 1024/**
@@ -49,6 +51,8 @@ void unbind_all_ports(void)struct vcpu_info *vcpu_info = &s->vcpu_info[cpu];for (i =0 ; i <NR_EVS ; i++) { +if (i == console_evtchn) +continue ;if (test_and_clear_bit (i, bound_ports)) {printf ("port %d still bound!\n" , i);unbind_evtchn (i);
Signature · 1 line
2.17.1
PATCH RESEND v2 7/18 serial: serial_xen: Add Xen PV serial driver
Quoted 5 lines · Anastasiia Lukianenko
From: Peng Fan <[email protected]>
Add support for Xen para-virtualized serial driver. This driver fully supports serial console for the virtual machine.
Quoted 7 lines
Please note that as the driver is initialized late, so no banner nor memory size is visible.
Signed-off-by Peng Fan <[email protected]>Signed-off-by Oleksandr Andrushchenko <[email protected]>Signed-off-by Anastasiia Lukianenko <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200814/d1b2d972/attachment.sig>
PATCH RESEND v2 8/18 linux/compat.h: Add wait_event_timeout macro
In reply to Anastasiia LukianenkoFrom: Oleksandr Andrushchenko <[email protected]>
Add wait_event_timeout - sleep until a condition gets true or a timeout elapses.
This is a stripped version of the same from Linux kernel with the following u-boot specific modifications:
- no wait queues supported
- use u-boot timer to detect timeouts
- check for Ctrl-C pressed during wait
---
Changes since v1:
- add comment
- correct code style
include/linux/compat.h | 54 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+)
include/linux/compat.h +54 -0
@@ -1,12 +1,20 @@#ifndef _LINUX_COMPAT_H_#define _LINUX_COMPAT_H_ +#include <console.h> #include <log.h> #include <malloc.h> + +#include <asm/processor.h> +#include <linux/types.h> #include <linux/err.h> #include <linux/kernel.h> +#ifdef CONFIG_XEN +#include <xen/events.h> +#endif +struct unused {};typedef struct unused unused_t ;
@@ -122,6 +130,52 @@ static inline void kmem_cache_destroy(struct kmem_cache *cachep)#define add_wait_queue (...) do { } while (0)#define remove_wait_queue (...) do { } while (0) +#ifndef CONFIG_XEN +#define eventchn_poll () +#endif + +#define __wait_event_timeout(condition, timeout, ret) \ +({ \ + ulong __ret = ret; /* explicit shadow */ \ + ulong start = get_timer(0); \ + for (;;) { \ + eventchn_poll(); \ + if (condition) { \ + __ret = 1; \ + break; \ + } \ + if ((get_timer(start) > timeout) || ctrlc()) { \ + __ret = 0; \ + break; \ + } \ + cpu_relax(); \ + } \ + __ret; \ +}) + +/** +* wait_event_timeout() - Wait until the event occurs before the timeout. +* @wr_head: The wait queue to wait on. +* @condition: Expression for the event to wait for. +* @timeout: Maximum waiting time. +* +* We wait until the @condition evaluates to %true (succeed) or +* %false (@timeout elapsed). +* +* Return: +* 0 - if the @condition evaluated to %false after the @timeout elapsed +* 1 - if the @condition evaluated to %true +*/ +#define wait_event_timeout (wq_head, condition, timeout) \ +({ \ + ulong __ret; \ + if (condition) \ + __ret = 1; \ + else \ + __ret = __wait_event_timeout(condition, timeout, __ret);\ + __ret; \ +}) +#define KERNEL_VERSION (a,b,c) (((a) << 16) + ((b) << 8) + (c))/* This is also defined in ARMv8's mmu.h */
Signature · 1 line
2.17.1
PATCH RESEND v2 8/18 linux/compat.h: Add wait_event_timeout macro
Quoted 5 lines · Anastasiia Lukianenko
From: Oleksandr Andrushchenko <[email protected]>
Add
wait_event_timeout- sleep until a condition gets true or a timeout elapses.
Quoted 8 lines
This is a stripped version of the same from Linux kernel with the following u-boot specific modifications:
- no wait queues supported
- use u-boot timer to detect timeouts
- check for Ctrl-C pressed during waitSigned-off-by Oleksandr Andrushchenko <[email protected]>Signed-off-by Anastasiia Lukianenko <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200814/38aca401/attachment.sig>
PATCH RESEND v2 9/18 lib: sscanf: add sscanf implementation
In reply to Anastasiia LukianenkoFrom: Andrii Anisov <[email protected]>
Port sscanf implementation from mini-os and introduce new Kconfig option to enable it: CONFIG_SSCANF. Disable by default.
---
Changes since v1:
- provide a test in /tests/lib
- reduce the code size
- add comments
- correct code style
include/vsprintf.h | 8 + lib/Kconfig | 4 + lib/Makefile | 1 + lib/sscanf.c | 823 +++++++++++++++++++++++++++++++++++++++++++++ test/lib/Makefile | 1 + test/lib/sscanf.c | 174 ++++++++++ 6 files changed, 1011 insertions(+) create mode 100644 lib/sscanf.c create mode 100644 test/lib/sscanf.c
include/vsprintf.h +8 -0
@@ -234,4 +234,12 @@ char *strmhz(char *buf, unsigned long hz);*/ void str_to_upper (const char *in,char *out,size_t len); +/** +* sscanf - Unformat a buffer into a list of arguments +* @buf: input buffer +* @fmt: formatting of buffer +* @...: resulting arguments +*/ +int sscanf (const char *buf,const char *fmt, ...); +#endif
lib/Kconfig +4 -0
@@ -80,6 +80,10 @@ config SPL_SPRINTF config TPL_SPRINTF bool +config SSCANF + bool + default n + config STRTO bool default y
lib/Makefile +1 -0
@@ -123,6 +123,7 @@ else # Main U-Boot always uses the full printf support obj-y += vsprintf.o strto.o obj-$(CONFIG_OID_REGISTRY) += oid_registry.o +obj-$(CONFIG_SSCANF) += sscanf.o endif obj-y += date.o
lib/sscanf.c new file +823 -0
823 lines not on this page · raw message
test/lib/Makefile +1 -0
@@ -6,6 +6,7 @@ obj-y += cmd_ut_lib.o obj-$(CONFIG_EFI_SECURE_BOOT) += efi_image_region.o obj-y += hexdump.o obj-y += lmb.o +obj-y += sscanf.o obj-y += string.o obj-$(CONFIG_ERRNO_STR) += test_errno_str.o obj-$(CONFIG_UT_LIB_ASN1) += asn1.o
test/lib/sscanf.c new file +174 -0
174 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH RESEND v2 9/18 lib: sscanf: add sscanf implementation
Quoted 8 lines · Anastasiia Lukianenko
From: Andrii Anisov <[email protected]>
Port sscanf implementation from mini-os and introduce new
Kconfigoption to enable it:CONFIG_SSCANF. Disable by default.Signed-off-by Andrii Anisov <[email protected]>Signed-off-by Anastasiia Lukianenko <[email protected]>Signed-off-by Oleksandr Andrushchenko <[email protected]>
Applied to u-boot/master, thanks!
But please note:
ERROR: do not use assignment in if condition
#630: FILE: lib/sscanf.c:558:
+ if ((n = inr) < width) {
Is that really what you wanted?
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200814/24e7b149/attachment.sig>
PATCH RESEND v2 9/18 lib: sscanf: add sscanf implementation
In reply to Anastasiia Lukianenkolib/sscanf.c line 1
Quoted 3 lines · Anastasiia Lukianenko
+++
b/lib/sscanf.clib/sscanf.c new file +1
-0@@ -0,0 +1,823 @@ +// SPDX-License-Identifier: BSD-3-Clause
Hmm... Tom, can you point out to the possibility of using this code in U-Boot? Can we call it from the GPL only code or can it call GPL code (is malloc() GPL? Or what all these #include <linux/*.h> are doing there?
Signature · 2 lines
With Best Regards, Andy Shevchenko
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH RESEND v2 9/18 lib: sscanf: add sscanf implementation
Hi Andy
AFAIK Modified BSD (3-clause) is compatible with GPL according to FSF [1] so that you can release product under GPL with integrated BSD code.
[1] https://www.gnu.org/licenses/license-list.en.html#ModifiedBSD
Best regards,
-- Artem Mygaiev
On Sun, 16 Aug 2020 11:23:44 +0300 Andy Shevchenko <[email protected]> wrote:
On Thu, Aug 6, 2020 at 12:45 PM Anastasiia Lukianenko <[email protected]> wrote:
+++ b/lib/sscanf.c
@@ -0,0 +1,823 @@
+// SPDX-License-Identifier: BSD-3-Clause
Hmm... Tom, can you point out to the possibility of using this code in U-Boot? Can we call it from the GPL only code or can it call GPL code (is malloc() GPL? Or what all these #include <linux/*.h> are doing there?
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH RESEND v2 9/18 lib: sscanf: add sscanf implementation
Quoted 6 lines · Artem Mygaiev
Hi Andy
AFAIK Modified BSD (3-clause) is compatible with GPL according to FSF [1] so that you can release product under GPL with integrated BSD code.
[1] https://www.gnu.org/licenses/license-list.en.html#ModifiedBSD
Right. This is not our first BSD-3-Clause bit of code (and there's even a handful of pieces in the Linux kernel).
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200817/80c200eb/attachment.sig>
PATCH RESEND v2 10/18 xen: Port Xen bus driver from mini-os
In reply to Anastasiia LukianenkoFrom: Oleksandr Andrushchenko <[email protected]>
Make required updates to run on u-boot and strip test code.
---
Changes since v1:
- add comments
- correct code style
arch/arm/Kconfig | 1 + board/xen/xenguest_arm64/xenguest_arm64.c | 16 +- drivers/xen/Makefile | 1 + drivers/xen/hypervisor.c | 2 + drivers/xen/xenbus.c | 557 ++++++++++++++++++++++ include/xen.h | 2 +- include/xen/xenbus.h | 116 +++++ 7 files changed, 693 insertions(+), 2 deletions(-) create mode 100644 drivers/xen/xenbus.c create mode 100644 include/xen/xenbus.h
arch/arm/Kconfig +1 -0
@@ -1746,6 +1746,7 @@ config TARGET_XENGUEST_ARM64 select OF_CONTROL select LINUX_KERNEL_IMAGE_HEADER select XEN_SERIAL + select SSCANF endchoice config ARCH_SUPPORT_TFABOOT
board/xen/xenguest_arm64/xenguest_arm64.c +15 -1
@@ -66,7 +66,7 @@ static int setup_mem_map(void)/* * Add "magic" region which is used by Xen to provide some essentials -* for the guest: we need console. +* for the guest: we need console and xenstore. */ ret =hvm_get_parameter_maintain_dcache (HVM_PARAM_CONSOLE_PFN , &gfn);if (ret <0 ) {
@@ -82,6 +82,20 @@ static int setup_mem_map(void) PTE_BLOCK_INNER_SHARE); i++; + ret =hvm_get_parameter_maintain_dcache (HVM_PARAM_STORE_PFN , &gfn); +if (ret <0 ) { +printf ("%s: Can't get HVM_PARAM_STORE_PFN, ret %d\n" , + __func__, ret); +return -EINVAL ; + } + + xen_mem_map[i].virt =PFN_PHYS (gfn); + xen_mem_map[i].phys =PFN_PHYS (gfn); + xen_mem_map[i].size =PAGE_SIZE ; + xen_mem_map[i].attrs = (PTE_BLOCK_MEMTYPE (MT_NORMAL ) | +PTE_BLOCK_INNER_SHARE ); + i++; + mem =get_next_memory_node (blob,-1 );if (mem <0 ) {printf ("%s: Missing /memory node\n" , __func__);
drivers/xen/Makefile +1 -0
@@ -4,3 +4,4 @@ obj-y += hypervisor.o obj-y += events.o +obj-y += xenbus.o
drivers/xen/hypervisor.c +2 -0
@@ -21,6 +21,7 @@#include <xen/hvm.h> #include <xen/events.h> +#include <xen/xenbus.h> #include <xen/interface/memory.h> #define active_evtchns (cpu, sh, idx) \
@@ -236,5 +237,6 @@ void xen_init(void)map_shared_info (NULL );init_events (); +init_xenbus (); }
drivers/xen/xenbus.c new file +557 -0
557 lines not on this page · raw message
include/xen.h +1 -1
@@ -8,7 +8,7 @@/** * xen_init() - Xen initialization * -* Map Xen memory pages, initialize event handler. +* Map Xen memory pages, initialize event handler and xenbus. */ void xen_init (void );
include/xen/xenbus.h new file +116 -0
116 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH RESEND v2 10/18 xen: Port Xen bus driver from mini-os
Quoted 6 lines · Anastasiia Lukianenko
From: Oleksandr Andrushchenko <[email protected]>
Make required updates to run on u-boot and strip test code.
Signed-off-by Anastasiia Lukianenko <[email protected]>Signed-off-by Oleksandr Andrushchenko <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200814/7d4f4a73/attachment.sig>
PATCH RESEND v2 11/18 xen: Port Xen grant table driver from mini-os
In reply to Anastasiia LukianenkoFrom: Oleksandr Andrushchenko <[email protected]>
Make required updates to run on u-boot.
---
Changes since v1:
- remove gnttab_grant_transfer and gnttab_end_transfer functions as it is not possible to transfer grant on Arm
- remove HYPERVISOR_grant_table_op as it is not needed on Arm
- add comments
- correct code style
board/xen/xenguest_arm64/xenguest_arm64.c | 13 ++ drivers/xen/Makefile | 1 + drivers/xen/gnttab.c | 216 ++++++++++++++++++++++ drivers/xen/hypervisor.c | 2 + include/xen.h | 3 +- include/xen/gnttab.h | 24 +++ 6 files changed, 258 insertions(+), 1 deletion(-) create mode 100644 drivers/xen/gnttab.c create mode 100644 include/xen/gnttab.h
board/xen/xenguest_arm64/xenguest_arm64.c +13 -0
@@ -21,6 +21,7 @@#include <linux/compiler.h> +#include <xen/gnttab.h> #include <xen/hvm.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -63,6 +64,8 @@ static int setup_mem_map(void)struct fdt_resource res;const void *blob = gd->fdt_blob;u64 gfn; +phys_addr_t gnttab_base; +phys_size_t gnttab_sz;/* * Add "magic" region which is used by Xen to provide some essentials
@@ -96,6 +99,16 @@ static int setup_mem_map(void) PTE_BLOCK_INNER_SHARE); i++; +/* Get Xen's suggested physical page assignments for the grant table. */ +get_gnttab_base (&gnttab_base, &gnttab_sz); + + xen_mem_map[i].virt = gnttab_base; + xen_mem_map[i].phys = gnttab_base; + xen_mem_map[i].size = gnttab_sz; + xen_mem_map[i].attrs = (PTE_BLOCK_MEMTYPE (MT_NORMAL ) | +PTE_BLOCK_INNER_SHARE ); + i++; + mem =get_next_memory_node (blob,-1 );if (mem <0 ) {printf ("%s: Missing /memory node\n" , __func__);
drivers/xen/Makefile +1 -0
@@ -5,3 +5,4 @@ obj-y += hypervisor.o obj-y += events.o obj-y += xenbus.o +obj-y += gnttab.o
drivers/xen/gnttab.c new file +216 -0
216 lines not on this page · raw message
drivers/xen/hypervisor.c +2 -0
@@ -21,6 +21,7 @@#include <xen/hvm.h> #include <xen/events.h> +#include <xen/gnttab.h> #include <xen/xenbus.h> #include <xen/interface/memory.h>
@@ -238,5 +239,6 @@ void xen_init(void)map_shared_info (NULL );init_events ();init_xenbus (); +init_gnttab (); }
include/xen.h +2 -1
@@ -8,7 +8,8 @@/** * xen_init() - Xen initialization * -* Map Xen memory pages, initialize event handler and xenbus. +* Map Xen memory pages, initialize event handler and xenbus, +* setup the grant table. */ void xen_init (void );
include/xen/gnttab.h new file +24 -0
@@ -0,0 +1,24 @@ +/* +* SPDX-License-Identifier: GPL-2.0 +* +* (C) 2006, Steven Smith <[email protected]> +* (C) 2006, Grzegorz Milos <[email protected]> +* (C) 2020, EPAM Systems Inc. +*/ +#ifndef __GNTTAB_H__ +#define __GNTTAB_H__ + +#include <xen/interface/grant_table.h> + +void init_gnttab (void ); +void fini_gnttab (void ); + +grant_ref_t gnttab_alloc_and_grant (void **map); +grant_ref_t gnttab_grant_access (domid_t domid,unsigned long frame, +int readonly); +int gnttab_end_access (grant_ref_t ref); +const char *gnttabop_error (int16_t status); + +void get_gnttab_base (phys_addr_t *gnttab_base,phys_size_t *gnttab_sz); + +#endif /* !__GNTTAB_H__ */
Signature · 1 line
2.17.1
PATCH RESEND v2 11/18 xen: Port Xen grant table driver from mini-os
Quoted 6 lines · Anastasiia Lukianenko
From: Oleksandr Andrushchenko <[email protected]>
Make required updates to run on u-boot.
Signed-off-by Oleksandr Andrushchenko <[email protected]>Signed-off-by Anastasiia Lukianenko <[email protected]>
Applied to u-boot/master, thanks!
But please note:
ERROR: do not use assignment in if condition
#176: FILE: drivers/xen/gnttab.c:103:
+ if ((flags = nflags) & (GTF_reading | GTF_writing)) {
WARNING: Missing or malformed SPDX-License-Identifier tag in line 1 #329: FILE: include/xen/gnttab.h:1:
+/*
WARNING: Misplaced SPDX-License-Identifier tag - use line 1 instead #330: FILE: include/xen/gnttab.h:2:
+ * SPDX-License-Identifier: GPL-2.0
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200814/55e63b58/attachment.sig>
PATCH RESEND v2 12/18 xen: pvblock: Add initial support for para-virtualized block driver
In reply to Anastasiia LukianenkoFrom: Anastasiia Lukianenko <[email protected]>
Add initial infrastructure for Xen para-virtualized block device. This includes compile-time configuration and the skeleton for the future driver implementation.
Add new class UCLASS_PVBLOCK which is going to be a parent for virtual block devices.
Add new interface type IF_TYPE_PVBLOCK.
Implement basic driver setup by reading XenStore configuration.
---
Changes since v1:
- add comments
- correct code style
cmd/Kconfig | 7 ++ cmd/Makefile | 1 + cmd/pvblock.c | 30 ++++++++ common/board_r.c | 14 ++++ configs/xenguest_arm64_defconfig | 4 ++ disk/part.c | 4 ++ drivers/Kconfig | 2 + drivers/block/blk-uclass.c | 2 + drivers/xen/Kconfig | 10 +++ drivers/xen/Makefile | 2 + drivers/xen/pvblock.c | 120 +++++++++++++++++++++++++++++++ include/blk.h | 1 + include/configs/xenguest_arm64.h | 8 +++ include/dm/uclass-id.h | 1 + include/pvblock.h | 17 +++++ 15 files changed, 223 insertions(+) create mode 100644 cmd/pvblock.c create mode 100644 drivers/xen/Kconfig create mode 100644 drivers/xen/pvblock.c create mode 100644 include/pvblock.h
cmd/Kconfig +7 -0
@@ -1350,6 +1350,13 @@ config CMD_USB_MASS_STORAGE help USB mass storage support +config CMD_PVBLOCK + bool "Xen para-virtualized block device" + depends on XEN + select PVBLOCK + help + Xen para-virtualized block device support + config CMD_VIRTIO bool "virtio" depends on VIRTIO
cmd/Makefile +1 -0
@@ -171,6 +171,7 @@ obj-$(CONFIG_CMD_DFU) += dfu.o obj-$(CONFIG_CMD_GPT) += gpt.o obj-$(CONFIG_CMD_ETHSW) += ethsw.o obj-$(CONFIG_CMD_AXI) += axi.o +obj-$(CONFIG_CMD_PVBLOCK) += pvblock.o # Power obj-$(CONFIG_CMD_PMIC) += pmic.o
cmd/pvblock.c new file +30 -0
@@ -0,0 +1,30 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* (C) Copyright 2020 EPAM Systems Inc. +* +* XEN para-virtualized block device support +*/ + +#include <blk.h> +#include <common.h> +#include <command.h> + +/* Current I/O Device */ +static int pvblock_curr_device; + +int do_pvblock (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]) +{ +return blk_common_cmd (argc, argv,IF_TYPE_PVBLOCK , + &pvblock_curr_device); +} + +U_BOOT_CMD (pvblock,5 ,1 , do_pvblock, +"Xen para-virtualized block device" , +"info - show available block devices\n" +"pvblock device [dev] - show or set current device\n" +"pvblock part [dev] - print partition table of one or all devices\n" +"pvblock read addr blk# cnt\n" +"pvblock write addr blk# cnt - read/write `cnt'" +" blocks starting at block `blk#'\n" +" to/from memory address `addr'" ); +
common/board_r.c +14 -0
@@ -49,6 +49,7 @@#include <nand.h> #include <of_live.h> #include <onenand_uboot.h> +#include <pvblock.h> #include <scsi.h> #include <serial.h> #include <status_led.h>
@@ -472,6 +473,16 @@ static int initr_xen(void) return 0; }#endif + +#ifdef CONFIG_PVBLOCK +static int initr_pvblock (void ) +{ +puts ("PVBLOCK: " ); +pvblock_init (); +return 0 ; +} +#endif +/* * Tell if it's OK to load the environment early in boot. *
@@ -768,6 +779,9 @@ static init_fnc_t init_sequence_r[] = {#endif #ifdef CONFIG_XEN initr_xen, +#endif +#ifdef CONFIG_PVBLOCK + initr_pvblock, #endif initr_env, #ifdef CONFIG_SYS_BOOTPARAMS_LEN
configs/xenguest_arm64_defconfig +4 -0
@@ -14,6 +14,8 @@ CONFIG_CMD_BOOTD=n CONFIG_CMD_BOOTEFI=n CONFIG_CMD_BOOTEFI_HELLO_COMPILE=n CONFIG_CMD_ELF=n +CONFIG_CMD_EXT4=y +CONFIG_CMD_FAT=y CONFIG_CMD_GO=n CONFIG_CMD_RUN=n CONFIG_CMD_IMI=n
@@ -41,6 +43,8 @@ CONFIG_CMD_LZMADEC=n CONFIG_CMD_SAVEENV=n CONFIG_CMD_UMS=n +CONFIG_CMD_PVBLOCK=y + #CONFIG_USB=n # CONFIG_ISO_PARTITION is not set
disk/part.c +4 -0
@@ -149,6 +149,7 @@ void dev_print (struct blk_desc *dev_desc)case IF_TYPE_MMC :case IF_TYPE_USB :case IF_TYPE_NVME : +case IF_TYPE_PVBLOCK : printf ("Vendor: %s Rev: %s Prod: %s\n", dev_desc->vendor, dev_desc->revision,
@@ -288,6 +289,9 @@ static void print_part_header(const char *type, struct blk_desc *dev_desc)case IF_TYPE_NVME :puts ("NVMe" );break ; +case IF_TYPE_PVBLOCK : +puts ("PV BLOCK" ); +break ;case IF_TYPE_VIRTIO :puts ("VirtIO" );break ;
drivers/Kconfig +2 -0
@@ -134,6 +134,8 @@ source "drivers/w1-eeprom/Kconfig" source "drivers/watchdog/Kconfig" +source "drivers/xen/Kconfig" + config PHYS_TO_BUS bool "Custom physical to bus address mapping" help
drivers/block/blk-uclass.c +2 -0
@@ -28,6 +28,7 @@ static const char *if_typename_str[IF_TYPE_COUNT] = { [IF_TYPE_NVME] = "nvme", [IF_TYPE_EFI] = "efi", [IF_TYPE_VIRTIO] = "virtio", + [IF_TYPE_PVBLOCK] = "pvblock", };static enum uclass_id if_type_uclass_id[IF_TYPE_COUNT ] = {
@@ -43,6 +44,7 @@ static enum uclass_id if_type_uclass_id[IF_TYPE_COUNT] = { [IF_TYPE_NVME] = UCLASS_NVME, [IF_TYPE_EFI] = UCLASS_EFI, [IF_TYPE_VIRTIO] = UCLASS_VIRTIO, + [IF_TYPE_PVBLOCK] = UCLASS_PVBLOCK, };static enum if_type if_typename_to_iftype (const char *if_typename)
drivers/xen/Kconfig new file +10 -0
@@ -0,0 +1,10 @@ +config PVBLOCK + bool "Xen para-virtualized block device" + depends on DM + select BLK + select HAVE_BLOCK_DEVICE + help + This driver implements the front-end of the Xen virtual + block device driver. It communicates with a back-end driver + in another domain which drives the actual block device. +
drivers/xen/Makefile +2 -0
@@ -6,3 +6,5 @@ obj-y += hypervisor.o obj-y += events.o obj-y += xenbus.o obj-y += gnttab.o + +obj-$(CONFIG_PVBLOCK) += pvblock.o
drivers/xen/pvblock.c new file +120 -0
120 lines not on this page · raw message
include/blk.h +1 -0
@@ -33,6 +33,7 @@ enum if_type {IF_TYPE_HOST ,IF_TYPE_NVME ,IF_TYPE_EFI , +IF_TYPE_PVBLOCK ,IF_TYPE_VIRTIO , IF_TYPE_COUNT, /* Number of interface types */
include/configs/xenguest_arm64.h +8 -0
@@ -41,4 +41,12 @@#define CONFIG_CMDLINE_TAG 1#define CONFIG_INITRD_TAG 1 +#define CONFIG_CMD_RUN + +#undef CONFIG_EXTRA_ENV_SETTINGS +#define CONFIG_EXTRA_ENV_SETTINGS \ + "loadimage=ext4load pvblock 0 0x90000000 /boot/Image;\0" \ + "pvblockboot=run loadimage;" \ + "booti 0x90000000 - 0x88000000;\0" +#endif /* __XENGUEST_ARM64_H */
include/dm/uclass-id.h +1 -0
@@ -121,6 +121,7 @@ enum uclass_id {UCLASS_W1 ,/* Dallas 1-Wire bus */ UCLASS_W1_EEPROM ,/* one-wire EEPROMs */ UCLASS_WDT ,/* Watchdog Timer driver */ +UCLASS_PVBLOCK ,/* Xen virtual block device */ UCLASS_COUNT , UCLASS_INVALID = -1,
include/pvblock.h new file +17 -0
@@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0+ +* +* (C) 2020 EPAM Systems Inc. +*/ + +#ifndef _PVBLOCK_H +#define _PVBLOCK_H + +/** +* pvblock_init() - Initialize para-virtual block device class driver +* +* Bind PV block to UCLASS_ROOT device and probe all UCLASS_PVBLOCK +* virtual block devices. +*/ +void pvblock_init (void ); + +#endif /* _PVBLOCK_H */
Signature · 1 line
2.17.1
PATCH RESEND v2 12/18 xen: pvblock: Add initial support for para-virtualized block driver
Quoted 9 lines · Anastasiia Lukianenko
From: Anastasiia Lukianenko <[email protected]>
Add initial infrastructure for Xen para-virtualized block device. This includes compile-time configuration and the skeleton for the future driver implementation.
Add new classUCLASS_PVBLOCKwhich is going to be a parent for virtual block devices.
Add new interface typeIF_TYPE_PVBLOCK.
Quoted 5 lines
Implement basic driver setup by reading XenStore configuration.
Signed-off-by Andrii Anisov <[email protected]>Signed-off-by Anastasiia Lukianenko <[email protected]>Signed-off-by Oleksandr Andrushchenko <[email protected]>
Applied to u-boot/master, thanks!
But please note:
ERROR: do not use assignment in if condition
#281: FILE: drivers/xen/pvblock.c:260:
+ if ((err = xenbus_switch_state(XBT_NIL, nodename,
in a few places in the driver (these without more context are possibly OK, just bad style).
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200814/ac0ce79d/attachment.sig>
PATCH RESEND v2 13/18 xen: pvblock: Enumerate virtual block devices
In reply to Anastasiia LukianenkoFrom: Anastasiia Lukianenko <[email protected]>
Enumerate Xen virtual block devices found in XenStore and instantiate pvblock devices.
--- drivers/xen/pvblock.c | 112 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 110 insertions(+), 2 deletions(-)
drivers/xen/pvblock.c +110 -2
@@ -6,6 +6,10 @@#include <common.h> #include <dm.h> #include <dm/device-internal.h> +#include <malloc.h> +#include <part.h> + +#include <xen/xenbus.h> #define DRV_NAME "pvblock"#define DRV_NAME_BLK "pvblock_blk"
@@ -14,6 +18,10 @@ struct blkfront_dev {char dummy; }; +struct blkfront_platdata { +unsigned int devid; +}; +static int init_blkfront (unsigned int devid,struct blkfront_dev *dev) {return 0 ;
@@ -37,15 +45,40 @@ ulong pvblock_blk_write(struct udevice *udev, lbaint_t blknr, lbaint_t blkcnt,static int pvblock_blk_bind (struct udevice *udev) { +struct blk_desc *desc =dev_get_uclass_platdata (udev); +int devnum; + + desc->if_type =IF_TYPE_PVBLOCK ; +/* +* Initialize the devnum to -ENODEV. This is to make sure that +* blk_next_free_devnum() works as expected, since the default +* value 0 is a valid devnum. +*/ + desc->devnum = -ENODEV ; + devnum =blk_next_free_devnum (IF_TYPE_PVBLOCK ); +if (devnum <0 ) +return devnum; + desc->devnum = devnum; + desc->part_type =PART_TYPE_UNKNOWN ; + desc->bdev = udev; + +strncpy (desc->vendor,"Xen" ,sizeof (desc->vendor)); +strncpy (desc->revision,"1" ,sizeof (desc->revision)); +strncpy (desc->product,"Virtual disk" ,sizeof (desc->product)); +return 0 ; }static int pvblock_blk_probe (struct udevice *udev) {struct blkfront_dev *blk_dev =dev_get_priv (udev); -int ret; +struct blkfront_platdata *platdata =dev_get_platdata (udev); +int ret, devid; - ret =init_blkfront (0 , blk_dev); + devid = platdata->devid; +free (platdata); + + ret =init_blkfront (devid, blk_dev);if (ret <0 )return ret;return 0 ;
@@ -79,6 +112,68 @@ U_BOOT_DRIVER(pvblock_blk) = {* Para-virtual block device class *******************************************************************************/ +typedef int (*enum_vbd_callback )(struct udevice *parent,unsigned int devid); + +static int on_new_vbd (struct udevice *parent,unsigned int devid) +{ +struct driver_info info; +struct udevice *udev; +struct blkfront_platdata *platdata; +int ret; + +debug ("New " DRV_NAME_BLK ", device ID %d\n" , devid); + + platdata =malloc (sizeof (struct blkfront_platdata )); +if (!platdata) { +printf ("Failed to allocate platform data\n" ); +return -ENOMEM ; + } + + platdata->devid = devid; + + info.name =DRV_NAME_BLK ; + info.platdata = platdata; + + ret =device_bind_by_name (parent, false, &info, &udev); +if (ret <0 ) { +printf ("Failed to bind " DRV_NAME_BLK " to device with ID %d, ret: %d\n" , + devid, ret); +free (platdata); + } +return ret; +} + +static int xenbus_enumerate_vbd (struct udevice *udev,enum_vbd_callback clb) +{ +char **dirs, *msg; +int i, ret; + + msg =xenbus_ls (XBT_NIL ,"device/vbd" , &dirs); +if (msg) { +printf ("Failed to read device/vbd directory: %s\n" , msg); +free (msg); +return -ENODEV ; + } + +for (i =0 ; dirs[i]; i++) { +int devid; + +sscanf (dirs[i],"%d" , &devid); + ret =clb (udev, devid); +if (ret <0 ) + goto fail; + +free (dirs[i]); + } + ret =0 ; + +fail: +for (; dirs[i]; i++) +free (dirs[i]); +free (dirs); +return ret; +} +void pvblock_init (void ) {struct driver_info info;
@@ -105,6 +200,19 @@ void pvblock_init(void)static int pvblock_probe (struct udevice *udev) { +struct uclass *uc; +int ret; + +if (xenbus_enumerate_vbd (udev, on_new_vbd) <0 ) +return -ENODEV ; + + ret =uclass_get (UCLASS_BLK , &uc); +if (ret) +return ret; + uclass_foreach_dev_probe(UCLASS_BLK, udev) { +if (_ret) +return _ret; + };return 0 ; }
Signature · 1 line
2.17.1
PATCH RESEND v2 13/18 xen: pvblock: Enumerate virtual block devices
Quoted 8 lines · Anastasiia Lukianenko
From: Anastasiia Lukianenko <[email protected]>
Enumerate Xen virtual block devices found in XenStore and instantiate pvblock devices.
Signed-off-by Oleksandr Andrushchenko <[email protected]>Signed-off-by Anastasiia Lukianenko <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200814/972908f9/attachment.sig>
PATCH RESEND v2 14/18 xen: pvblock: Read XenStore configuration and initialize
In reply to Anastasiia LukianenkoFrom: Anastasiia Lukianenko <[email protected]>
Read essential virtual block device configuration data from XenStore, initialize front ring and event channel.
Update block device description with actual block size.
Use code for XenStore from mini-os.
---
Changes since v1:
- add comments
- correct code style
drivers/xen/pvblock.c | 285 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 284 insertions(+), 1 deletion(-)
drivers/xen/pvblock.c +284 -1
@@ -1,5 +1,6 @@// SPDX-License-Identifier: GPL-2.0+ /* +* (C) 2007-2008 Samuel Thibault. * (C) Copyright 2020 EPAM Systems Inc. */ #include <blk.h>
@@ -9,26 +10,302 @@#include <malloc.h> #include <part.h> +#include <asm/armv8/mmu.h> +#include <asm/io.h> +#include <asm/xen/system.h> + +#include <linux/compat.h> + +#include <xen/events.h> +#include <xen/gnttab.h> +#include <xen/hvm.h> #include <xen/xenbus.h> +#include <xen/interface/io/ring.h> +#include <xen/interface/io/blkif.h> +#include <xen/interface/io/protocols.h> +#define DRV_NAME "pvblock"#define DRV_NAME_BLK "pvblock_blk" +#define O_RDONLY 00 +#define O_RDWR 02 + +struct blkfront_info { +u64 sectors; +unsigned int sector_size; +int mode; +int info; +int barrier; +int flush; +}; + +/** +* struct blkfront_dev - Struct representing blkfront device +* @dom: Domain id +* @ring: Front_ring structure +* @ring_ref: The grant reference, allowing us to grant access +* to the ring to the other end/domain +* @evtchn: Event channel used to signal ring events +* @handle: Events handle +* @nodename: Device XenStore path in format "device/vbd/" + @devid +* @backend: Backend XenStore path +* @info: Private data +* @devid: Device id +*/ struct blkfront_dev { -char dummy; +domid_t dom; + +struct blkif_front_ring ring; +grant_ref_t ring_ref; +evtchn_port_t evtchn; +blkif_vdev_t handle; + +char *nodename; +char *backend; +struct blkfront_info info; +unsigned int devid; };struct blkfront_platdata {unsigned int devid; }; +static void free_blkfront (struct blkfront_dev *dev) +{ +mask_evtchn (dev->evtchn); +free (dev->backend); + +gnttab_end_access (dev->ring_ref); +free (dev->ring.sring); + +unbind_evtchn (dev->evtchn); + +free (dev->nodename); +free (dev); +} + +static void blkfront_handler (evtchn_port_t port,struct pt_regs *regs, +void *data) +{ +printf ("%s [Port %d] - event received\n" , __func__, port); +} +static int init_blkfront (unsigned int devid,struct blkfront_dev *dev) { +xenbus_transaction_t xbt; +char *err =NULL ; +char *message =NULL ; +struct blkif_sring *s; +int retry =0 ; +char *msg =NULL ; +char *c; +char nodename[32 ]; +char path[ARRAY_SIZE (nodename) +strlen ("/backend-id" ) +1 ]; + +sprintf (nodename,"device/vbd/%d" , devid); + +memset (dev,0 ,sizeof (*dev)); + dev->nodename =strdup (nodename); + dev->devid = devid; + +snprintf (path,sizeof (path),"%s/backend-id" , nodename); + dev->dom =xenbus_read_integer (path); +evtchn_alloc_unbound (dev->dom, blkfront_handler, dev, &dev->evtchn); + + s = (struct blkif_sring *)memalign (PAGE_SIZE ,PAGE_SIZE ); +if (!s) { +printf ("Failed to allocate shared ring\n" ); + goto error; + } + +SHARED_RING_INIT (s); +FRONT_RING_INIT (&dev->ring, s,PAGE_SIZE ); + + dev->ring_ref =gnttab_grant_access (dev->dom,virt_to_pfn (s),0 ); + +again: + err =xenbus_transaction_start (&xbt); +if (err) { +printf ("starting transaction\n" ); +free (err); + } + + err =xenbus_printf (xbt, nodename,"ring-ref" ,"%u" , dev->ring_ref); +if (err) { + message ="writing ring-ref" ; + goto abort_transaction; + } + err =xenbus_printf (xbt, nodename,"event-channel" ,"%u" , dev->evtchn); +if (err) { + message ="writing event-channel" ; + goto abort_transaction; + } + err =xenbus_printf (xbt, nodename,"protocol" ,"%s" , +XEN_IO_PROTO_ABI_NATIVE ); +if (err) { + message ="writing protocol" ; + goto abort_transaction; + } + +snprintf (path,sizeof (path),"%s/state" , nodename); + err =xenbus_switch_state (xbt, path, XenbusStateConnected); +if (err) { + message ="switching state" ; + goto abort_transaction; + } + + err =xenbus_transaction_end (xbt,0 , &retry); +free (err); +if (retry) { + goto again; +printf ("completing transaction\n" ); + } + + goto done; + +abort_transaction: +free (err); + err =xenbus_transaction_end (xbt,1 , &retry); +printf ("Abort transaction %s\n" , message); + goto error; + +done: +snprintf (path,sizeof (path),"%s/backend" , nodename); + msg =xenbus_read (XBT_NIL , path, &dev->backend); +if (msg) { +printf ("Error %s when reading the backend path %s\n" , + msg, path); + goto error; + } + + dev->handle =strtoul (strrchr (nodename,'/' ) +1 ,NULL ,0 ); + + { +XenbusState state; +char path[strlen (dev->backend) + +strlen ("/feature-flush-cache" ) +1 ]; + +snprintf (path,sizeof (path),"%s/mode" , dev->backend); + msg =xenbus_read (XBT_NIL , path, &c); +if (msg) { +printf ("Error %s when reading the mode\n" , msg); + goto error; + } +if (*c =='w' ) + dev->info.mode =O_RDWR ; +else + dev->info.mode =O_RDONLY ; +free (c); + +snprintf (path,sizeof (path),"%s/state" , dev->backend); + + msg =NULL ; + state =xenbus_read_integer (path); +while (!msg && state < XenbusStateConnected) + msg =xenbus_wait_for_state_change (path, &state); +if (msg || state != XenbusStateConnected) { +printf ("backend not available, state=%d\n" , state); + goto error; + } + +snprintf (path,sizeof (path),"%s/info" , dev->backend); + dev->info.info =xenbus_read_integer (path); + +snprintf (path,sizeof (path),"%s/sectors" , dev->backend); +/* +* FIXME: read_integer returns an int, so disk size +* limited to 1TB for now +*/ + dev->info.sectors =xenbus_read_integer (path); + +snprintf (path,sizeof (path),"%s/sector-size" , dev->backend); + dev->info.sector_size =xenbus_read_integer (path); + +snprintf (path,sizeof (path),"%s/feature-barrier" , + dev->backend); + dev->info.barrier =xenbus_read_integer (path); + +snprintf (path,sizeof (path),"%s/feature-flush-cache" , + dev->backend); + dev->info.flush =xenbus_read_integer (path); + } +unmask_evtchn (dev->evtchn); + +debug ("%llu sectors of %u bytes\n" , + dev->info.sectors, dev->info.sector_size); +return 0 ; + +error: +free (msg); +free (err); +free_blkfront (dev); +return -ENODEV ; }static void shutdown_blkfront (struct blkfront_dev *dev) { +char *err =NULL , *err2; +XenbusState state; + +char path[strlen (dev->backend) +strlen ("/state" ) +1 ]; +char nodename[strlen (dev->nodename) +strlen ("/event-channel" ) +1 ]; + +debug ("Close " DRV_NAME ", device ID %d\n" , dev->devid); + +snprintf (path,sizeof (path),"%s/state" , dev->backend); +snprintf (nodename,sizeof (nodename),"%s/state" , dev->nodename); + +if ((err =xenbus_switch_state (XBT_NIL , nodename, + XenbusStateClosing)) !=NULL ) { +printf ("%s: error changing state to %d: %s\n" , __func__, + XenbusStateClosing, err); + goto close; + } + + state =xenbus_read_integer (path); +while (!err && state < XenbusStateClosing) + err =xenbus_wait_for_state_change (path, &state); +free (err); + +if ((err =xenbus_switch_state (XBT_NIL , nodename, + XenbusStateClosed)) !=NULL ) { +printf ("%s: error changing state to %d: %s\n" , __func__, + XenbusStateClosed, err); + goto close; + } + + state =xenbus_read_integer (path); +while (state < XenbusStateClosed) { + err =xenbus_wait_for_state_change (path, &state); +free (err); + } + +if ((err =xenbus_switch_state (XBT_NIL , nodename, + XenbusStateInitialising)) !=NULL ) { +printf ("%s: error changing state to %d: %s\n" , __func__, + XenbusStateInitialising, err); + goto close; + } + + state =xenbus_read_integer (path); +while (!err && + (state < XenbusStateInitWait || state >= XenbusStateClosed)) + err =xenbus_wait_for_state_change (path, &state); + +close: +free (err); + +snprintf (nodename,sizeof (nodename),"%s/ring-ref" , dev->nodename); + err2 =xenbus_rm (XBT_NIL , nodename); +free (err2); +snprintf (nodename,sizeof (nodename),"%s/event-channel" , dev->nodename); + err2 =xenbus_rm (XBT_NIL , nodename); +free (err2); + +if (!err) +free_blkfront (dev); } ulong pvblock_blk_read(struct udevice *udev, lbaint_t blknr, lbaint_t blkcnt,
@@ -73,6 +350,7 @@ static int pvblock_blk_probe(struct udevice *udev) {struct blkfront_dev *blk_dev =dev_get_priv (udev);struct blkfront_platdata *platdata =dev_get_platdata (udev); +struct blk_desc *desc =dev_get_uclass_platdata (udev);int ret, devid; devid = platdata->devid;
@@ -81,6 +359,11 @@ static int pvblock_blk_probe(struct udevice *udev) ret =init_blkfront (devid, blk_dev);if (ret <0 )return ret; + + desc->blksz = blk_dev->info.sector_size; + desc->lba = blk_dev->info.sectors; + desc->log2blksz =LOG2 (blk_dev->info.sector_size); +return 0 ; }
Signature · 1 line
2.17.1
PATCH RESEND v2 14/18 xen: pvblock: Read XenStore configuration and initialize
Quoted 10 lines · Anastasiia Lukianenko
From: Anastasiia Lukianenko <[email protected]>
Read essential virtual block device configuration data from XenStore, initialize front ring and event channel.
Update block device description with actual block size.Use code for XenStore from mini-os.
Signed-off-by Oleksandr Andrushchenko <[email protected]>Signed-off-by Anastasiia Lukianenko <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200814/e61d3725/attachment.sig>
PATCH RESEND v2 15/18 xen: pvblock: Implement front-back protocol and do IO
In reply to Anastasiia LukianenkoFrom: Anastasiia Lukianenko <[email protected]>
Implement Xen para-virtual frontend to backend communication and actually read/write disk data.
This is based on mini-os implementation of the para-virtual block frontend driver.
---
Changes since v1:
- add comments
- correct code style
drivers/xen/events.c | 2 +- drivers/xen/pvblock.c | 358 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 348 insertions(+), 12 deletions(-)
drivers/xen/events.c +1 -1
@@ -107,7 +107,7 @@ void unbind_evtchn(evtchn_port_t port)int rc;if (ev_actions[port].handler == default_handler) -printf ("WARN: No handler for port %d when unbinding\n" , port); +debug ("Default handler for port %d when unbinding\n" , port);mask_evtchn (port);clear_evtchn (port);
drivers/xen/pvblock.c +347 -11
424 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH RESEND v2 15/18 xen: pvblock: Implement front-back protocol and do IO
Quoted 10 lines · Anastasiia Lukianenko
From: Anastasiia Lukianenko <[email protected]>
Implement Xen para-virtual frontend to backend communication and actually read/write disk data.
This is based on mini-os implementation of the para-virtual block frontend driver.
Signed-off-by Oleksandr Andrushchenko <[email protected]>Signed-off-by Anastasiia Lukianenko <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200814/e9f48723/attachment.sig>
PATCH RESEND v2 16/18 xen: pvblock: Print found devices indices
In reply to Anastasiia LukianenkoFrom: Anastasiia Lukianenko <[email protected]>
--- drivers/xen/pvblock.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
drivers/xen/pvblock.c +20 -0
@@ -793,6 +793,24 @@ fail:return ret; } +static void print_pvblock_devices (void ) +{ +struct udevice *udev; +bool first = true; +const char *class_name; + + class_name =uclass_get_name (UCLASS_PVBLOCK ); +for (blk_first_device (IF_TYPE_PVBLOCK , &udev); udev; +blk_next_device (&udev), first = false) { +struct blk_desc *desc =dev_get_uclass_platdata (udev); + +if (!first) +puts (", " ); +printf ("%s: %d" , class_name, desc->devnum); + } +printf ("\n" ); +} +void pvblock_init (void ) {struct driver_info info;
@@ -815,6 +833,8 @@ void pvblock_init(void)if (ret)return ;uclass_foreach_dev_probe (UCLASS_PVBLOCK , udev); + +print_pvblock_devices (); }static int pvblock_probe (struct udevice *udev)
Signature · 1 line
2.17.1
PATCH RESEND v2 16/18 xen: pvblock: Print found devices indices
Quoted 5 lines · Anastasiia Lukianenko
From: Anastasiia Lukianenko <[email protected]>
Signed-off-by Oleksandr Andrushchenko <[email protected]>Signed-off-by Anastasiia Lukianenko <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200814/25545bf4/attachment.sig>
PATCH RESEND v2 17/18 board: xen: De-initialize before jumping to Linux
In reply to Anastasiia LukianenkoFrom: Oleksandr Andrushchenko <[email protected]>
Free resources used by Xen board before jumping to Linux kernel.
---
Changes since v1:
- add comment
board/xen/xenguest_arm64/xenguest_arm64.c | 6 ++++++ drivers/xen/hypervisor.c | 8 ++++++++ include/xen.h | 8 ++++++++ 3 files changed, 22 insertions(+)
board/xen/xenguest_arm64/xenguest_arm64.c +6 -0
@@ -12,6 +12,7 @@#include <dm.h> #include <errno.h> #include <malloc.h> +#include <xen.h> #include <asm/io.h> #include <asm/armv8/mmu.h>
@@ -194,3 +195,8 @@ int print_cpuinfo(void)return 0 ; } +void board_cleanup_before_linux (void ) +{ +xen_fini (); +} +
drivers/xen/hypervisor.c +8 -0
@@ -242,3 +242,11 @@ void xen_init(void)init_gnttab (); } +void xen_fini (void ) +{ +debug ("%s\n" , __func__); + +fini_gnttab (); +fini_xenbus (); +fini_events (); +}
include/xen.h +8 -0
@@ -13,4 +13,12 @@*/ void xen_init (void ); +/** +* xen_fini() - Board cleanup before Linux kernel start +* +* Unmap Xen memory pages the specified guest's pseudophysical +* address space and unbind all event channels. +*/ +void xen_fini (void ); +#endif /* __XEN_H__ */
Signature · 1 line
2.17.1
PATCH RESEND v2 17/18 board: xen: De-initialize before jumping to Linux
Quoted 7 lines · Anastasiia Lukianenko
From: Oleksandr Andrushchenko <[email protected]>
Free resources used by Xen board before jumping to Linux kernel.
Signed-off-by Oleksandr Andrushchenko <[email protected]>Signed-off-by Anastasiia Lukianenko <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200814/04d4f600/attachment.sig>
PATCH RESEND v2 18/18 doc: xen: Add Xen guest ARM64 board documentation
In reply to Anastasiia LukianenkoFrom: Anastasiia Lukianenko <[email protected]>
---
Changes since v1:
- this patch appeared in the second version of patch series for describing new board specification
doc/board/index.rst | 1 + doc/board/xen/index.rst | 9 ++++ doc/board/xen/xenguest_arm64.rst | 81 ++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 doc/board/xen/index.rst create mode 100644 doc/board/xen/xenguest_arm64.rst
doc/board/index.rst +1 -0
@@ -22,4 +22,5 @@ Board-specific doc st/index tbs/index toradex/index + xen/index xilinx/index
doc/board/xen/index.rst new file +9 -0
@@ -0,0 +1,9 @@ +.. SPDX-License-Identifier: GPL-2.0+ + +XenGuestARM64 +============= + +.. toctree:: + :maxdepth: 2 + + xenguest_arm64
doc/board/xen/xenguest_arm64.rst new file +81 -0
81 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH RESEND v2 18/18 doc: xen: Add Xen guest ARM64 board documentation
Quoted 3 lines · Anastasiia Lukianenko
From: Anastasiia Lukianenko <[email protected]>
Signed-off-by Anastasiia Lukianenko <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200814/0c22dfdf/attachment.sig>
v2 cover Add new board: Xen guest for ARM64
In reply to Anastasiia LukianenkoPing
Quoted 205 lines · Anastasiia Lukianenko
From: Anastasiia Lukianenko <[email protected]>
This work introduces Xen [1] guest ARM64 board support in U-Boot with para-virtualized (PV) [2] block and serial drivers:
xenguest_arm64.This board is to be run as a virtual Xen guest with U-boot as its primary bootloader. The rationale behind introducing this board is a better and simpler decoupling of the guest from the initial privileged domain which starts a guest?s virtual machine: there are cross dependencies between the guest OS and initial privileged domain (Domain-0) such as Domain-0 needs guest's kernel and may need its device tree to boot it. These dependencies interfere if the kernel or guest OS needs to be updated, thus having a unified bootloader in Domain-0 allows resolving this:
1. U-boot boot scripts, which are stored on the guest?s virtual disk, are guest specific, so any change in the guest?s configuration can be handled by the guest itself.
2. Guest OS? kernel can be updated if OS? needs that without any help from Domain-0.
3. Using the Device Tree Overlay mechanism it is possible to customize the device tree entries yet at bootloader stage inside the guest itself, so the base device tree provided by Xen can be customized.Xen support for U-boot was implemented by introducing a new Xen guest ARM64 board and porting essential drivers from MiniOS [3] as well as some of the work previously done by NXP [4]:
1. PV block device front driver with XenStore based device enumeration, newUCLASS_PVBLOCK;
2. PV serial console device front driver;
3. Xen hypervisor support with minimal set of the essential headers adapted from Linux kernel;
4. grant table support;
5. event channel support, without IRQ support, but polling;
6. xenbus support;
7. dynamic RAM size as defined in the device tree instead of statically defined values;
8. position-independent pre-relocation code is used as we cannot statically define any start addresses at compile time which is up to Xen to choose at run-time;
9. new defconfig introduced:xenguest_arm64_defconfig.Please note, that due to the fact that para-virtualized serial driver requires some of the Xen functionality available late not all the printouts are available at the very start including U-Boot banner, memory size etc.
All the above was tested with block driver related commands (info/part/read/write), FAT and ext4 operations work properly, the Linux kernel can start.
Thank you in advance,
Anastasiia Lukianenko,
Oleksandr AndrushchenkoChanges since v1:
=================1. Added test for new lib sscanf function
2. Fixed data cache maintenance process
3. Added more comments and explanations
4. Removed unnecessary code, which is not related to ARM64 architecture
5. Added board documentation
6. Coding style cleanup
7. Added MIT LicenseAnastasiia Lukianenko (7):
Add MIT License
xen: pvblock: Add initial support for para-virtualized block driver
xen: pvblock: Enumerate virtual block devices
xen: pvblock: Read XenStore configuration and initialize
xen: pvblock: Implement front-back protocol and do IO
xen: pvblock: Print found devices indices
doc: xen: Add Xen guest ARM64 board documentationAndrii Anisov (2):
board: Introducexenguest_arm64board
lib: sscanf: add sscanf implementationOleksandr Andrushchenko (7):
xen: Add essential and required interface headers
xen: Port Xen hypervizor related code from mini-os
xen: Port Xen event channel driver from mini-oslinux/compat.h: Addwait_event_timeoutmacro
xen: Port Xen bus driver from mini-os
xen: Port Xen grant table driver from mini-os
board: xen: De-initialize before jumping to LinuxPeng Fan (2):
Kconfig: IntroduceCONFIG_XEN
serial:serial_xen: Add Xen PV serial driverKconfig | 18 + Licenses/README | 1 + Licenses/mit.txt | 20 + arch/arm/Kconfig | 9 + arch/arm/cpu/armv8/Makefile | 1 + arch/arm/cpu/armv8/xen/Makefile | 6 + arch/arm/cpu/armv8/xen/hypercall.S | 79 ++ arch/arm/cpu/armv8/xen/lowlevel_init.S | 33 + arch/arm/include/asm/io.h | 4 + arch/arm/include/asm/xen.h | 7 + arch/arm/include/asm/xen/hypercall.h | 22 + arch/arm/include/asm/xen/system.h | 88 +++ board/xen/xenguest_arm64/Kconfig | 12 + board/xen/xenguest_arm64/Makefile | 5 + board/xen/xenguest_arm64/xenguest_arm64.c | 202 +++++ cmd/Kconfig | 7 + cmd/Makefile | 1 + cmd/pvblock.c | 30 + common/board_r.c | 27 + configs/xenguest_arm64_defconfig | 60 ++ disk/part.c | 4 + doc/board/index.rst | 1 + doc/board/xen/index.rst | 9 + doc/board/xen/xenguest_arm64.rst | 81 ++ drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/block/blk-uclass.c | 2 + drivers/serial/Kconfig | 7 + drivers/serial/Makefile | 1 + drivers/serial/serial_xen.c | 182 +++++ drivers/xen/Kconfig | 10 + drivers/xen/Makefile | 10 + drivers/xen/events.c | 199 +++++ drivers/xen/gnttab.c | 216 ++++++ drivers/xen/hypervisor.c | 252 +++++++ drivers/xen/pvblock.c | 867 ++++++++++++++++++++++ drivers/xen/xenbus.c | 557 ++++++++++++++ include/blk.h | 1 + include/configs/xenguest_arm64.h | 52 ++ include/dm/uclass-id.h | 1 + include/linux/compat.h | 54 ++ include/pvblock.h | 17 + include/vsprintf.h | 8 + include/xen.h | 24 + include/xen/arm/interface.h | 88 +++ include/xen/events.h | 42 ++ include/xen/gnttab.h | 24 + include/xen/hvm.h | 27 + include/xen/interface/event_channel.h | 279 +++++++ include/xen/interface/grant_table.h | 565 ++++++++++++++ include/xen/interface/hvm/hvm_op.h | 55 ++ include/xen/interface/hvm/params.h | 116 +++ include/xen/interface/io/blkif.h | 701 +++++++++++++++++ include/xen/interface/io/console.h | 39 + include/xen/interface/io/protocols.h | 28 + include/xen/interface/io/ring.h | 462 ++++++++++++ include/xen/interface/io/xenbus.h | 64 ++ include/xen/interface/io/xs_wire.h | 134 ++++ include/xen/interface/memory.h | 332 +++++++++ include/xen/interface/sched.h | 171 +++++ include/xen/interface/xen.h | 208 ++++++ include/xen/xenbus.h | 116 +++ lib/Kconfig | 4 + lib/Makefile | 1 + lib/sscanf.c | 823 ++++++++++++++++++++ test/lib/Makefile | 1 + test/lib/sscanf.c | 174 +++++ 67 files changed, 7644 insertions(+)create mode 100644
Licenses/mit.txt
create mode 100644arch/arm/cpu/armv8/xen/Makefilecreate mode 100644arch/arm/cpu/armv8/xen/hypercall.Screate mode 100644arch/arm/cpu/armv8/xen/lowlevel_init.Screate mode 100644arch/arm/include/asm/xen.hcreate mode 100644arch/arm/include/asm/xen/hypercall.hcreate mode 100644arch/arm/include/asm/xen/system.hcreate mode 100644 board/xen/xenguest_arm64/Kconfig create mode 100644 board/xen/xenguest_arm64/Makefile create mode 100644board/xen/xenguest_arm64/xenguest_arm64.ccreate mode 100644cmd/pvblock.c
create mode 100644 configs/xenguest_arm64_defconfig create mode 100644doc/board/xen/index.rst
create mode 100644doc/board/xen/xenguest_arm64.rstcreate mode 100644drivers/serial/serial_xen.ccreate mode 100644drivers/xen/Kconfig
create mode 100644drivers/xen/Makefile
create mode 100644drivers/xen/events.c
create mode 100644drivers/xen/gnttab.c
create mode 100644drivers/xen/hypervisor.c
create mode 100644drivers/xen/pvblock.c
create mode 100644drivers/xen/xenbus.c
create mode 100644include/configs/xenguest_arm64.hcreate mode 100644include/pvblock.h
create mode 100644include/xen.h
create mode 100644include/xen/arm/interface.hcreate mode 100644include/xen/events.h
create mode 100644include/xen/gnttab.h
create mode 100644include/xen/hvm.h
create mode 100644include/xen/interface/event_channel.hcreate mode 100644include/xen/interface/grant_table.hcreate mode 100644include/xen/interface/hvm/hvm_op.hcreate mode 100644include/xen/interface/hvm/params.hcreate mode 100644include/xen/interface/io/blkif.hcreate mode 100644include/xen/interface/io/console.hcreate mode 100644include/xen/interface/io/protocols.hcreate mode 100644include/xen/interface/io/ring.hcreate mode 100644include/xen/interface/io/xenbus.hcreate mode 100644include/xen/interface/io/xs_wire.hcreate mode 100644include/xen/interface/memory.hcreate mode 100644include/xen/interface/sched.hcreate mode 100644include/xen/interface/xen.hcreate mode 100644include/xen/xenbus.h
create mode 100644lib/sscanf.c
create mode 100644test/lib/sscanf.c