xen/riscv: Add necessary files for RISC-V Xen build.
cover xen/riscv: Add necessary files for RISC-V Xen build.
Hello everyone,
My name is Xie Xun and I am a graduate student in computer science. I spend some time porting Xen to RISV-V based on Bobby's work. Now Xen can use device tree to initialize memory and load guest kernel. Timer interrupt is also enabled for both xen and guest kernel.
This patch series is the first part of the work. It only adds necessary files for a successful xen build. The only thing xen will do is printing a message.
There are some problems though. The first patch of this series is very large, but it seems most of the code is necessary for building xen. I am trying my best to remove some code but it still has more than 8000 lines of code.
Looking forward to your feedback.
Xen can be built with:
$ make XEN_TARGET_ARCH=riscv64 CROSS_COMPILE=riscv64-linux-gnu- tiny64_defconfig $ make XEN_TARGET_ARCH=riscv64 CROSS_COMPILE=riscv64-linux-gnu-
Run with Qemu:
$ qemu-system-riscv64 -machine virt -m 1G -kernel xen
Bobby and Alistair's patch:
https://lists.xenproject.org/archives/html/xen-devel/2020-01/msg01731.html
This patch series is based on Bobby's Repo:
https://gitlab.com/xen-on-risc-v/xen/-/tree/riscv-rebase
This patch series is available in:
https://github.com/xiexun162534/xen/tree/riscv-patch
My latest work:
https://github.com/xiexun162534/xen/tree/riscv-port
Xie Xun (6):
xen/riscv: Add necessary headers and definitions to build xen. xen/riscv: Add early page table setup code. xen/riscv: Add head.S
xen/riscv: Add sbi.c, sbi.h
xen/riscv: Add early_printk
xen/riscv: Print "xen start" in start_xen using early_printk.
xen/arch/riscv/Kconfig | 2 + xen/arch/riscv/Makefile | 53 ++ xen/arch/riscv/Rules.mk | 57 ++ xen/arch/riscv/delay.c | 14 + xen/arch/riscv/domain.c | 191 ++++ xen/arch/riscv/domctl.c | 52 ++ xen/arch/riscv/early_printk.c | 48 + xen/arch/riscv/guestcopy.c | 59 ++ xen/arch/riscv/include/asm/acpi.h | 9 + xen/arch/riscv/include/asm/altp2m.h | 39 + xen/arch/riscv/include/asm/asm.h | 76 ++ xen/arch/riscv/include/asm/atomic.h | 375 ++++++++ xen/arch/riscv/include/asm/bitops.h | 397 ++++++++ xen/arch/riscv/include/asm/bug.h | 67 ++ xen/arch/riscv/include/asm/byteorder.h | 16 + xen/arch/riscv/include/asm/cache.h | 24 + xen/arch/riscv/include/asm/cmpxchg.h | 382 ++++++++ xen/arch/riscv/include/asm/config.h | 149 ++- xen/arch/riscv/include/asm/cpufeature.h | 68 ++ xen/arch/riscv/include/asm/csr.h | 81 ++ xen/arch/riscv/include/asm/current.h | 41 + xen/arch/riscv/include/asm/debugger.h | 15 + xen/arch/riscv/include/asm/delay.h | 28 + xen/arch/riscv/include/asm/desc.h | 12 + xen/arch/riscv/include/asm/device.h | 93 ++ xen/arch/riscv/include/asm/div64.h | 23 + xen/arch/riscv/include/asm/domain.h | 80 ++ xen/arch/riscv/include/asm/early_printk.h | 10 + xen/arch/riscv/include/asm/event.h | 42 + xen/arch/riscv/include/asm/fence.h | 12 + xen/arch/riscv/include/asm/flushtlb.h | 56 ++ xen/arch/riscv/include/asm/grant_table.h | 93 ++ xen/arch/riscv/include/asm/guest_access.h | 125 +++ xen/arch/riscv/include/asm/guest_atomics.h | 62 ++ xen/arch/riscv/include/asm/hardirq.h | 27 + xen/arch/riscv/include/asm/hypercall.h | 12 + xen/arch/riscv/include/asm/init.h | 42 + xen/arch/riscv/include/asm/io.h | 283 ++++++ xen/arch/riscv/include/asm/iocap.h | 16 + xen/arch/riscv/include/asm/iommu.h | 46 + xen/arch/riscv/include/asm/iommu_fwspec.h | 68 ++ xen/arch/riscv/include/asm/irq.h | 62 ++ xen/arch/riscv/include/asm/mem_access.h | 35 + xen/arch/riscv/include/asm/mm.h | 320 +++++++ xen/arch/riscv/include/asm/monitor.h | 65 ++ xen/arch/riscv/include/asm/nospec.h | 25 + xen/arch/riscv/include/asm/numa.h | 41 + xen/arch/riscv/include/asm/p2m.h | 307 +++++++ xen/arch/riscv/include/asm/page-bits.h | 14 + xen/arch/riscv/include/asm/page.h | 319 +++++++ xen/arch/riscv/include/asm/paging.h | 16 + xen/arch/riscv/include/asm/pci.h | 31 + xen/arch/riscv/include/asm/percpu.h | 35 + xen/arch/riscv/include/asm/processor.h | 176 ++++ xen/arch/riscv/include/asm/random.h | 9 + xen/arch/riscv/include/asm/regs.h | 42 + xen/arch/riscv/include/asm/riscv_encoding.h | 960 ++++++++++++++++++++ xen/arch/riscv/include/asm/sbi.h | 275 ++++++ xen/arch/riscv/include/asm/setup.h | 23 + xen/arch/riscv/include/asm/smp.h | 69 ++ xen/arch/riscv/include/asm/softirq.h | 16 + xen/arch/riscv/include/asm/spinlock.h | 13 + xen/arch/riscv/include/asm/string.h | 28 + xen/arch/riscv/include/asm/system.h | 98 ++ xen/arch/riscv/include/asm/time.h | 81 ++ xen/arch/riscv/include/asm/trace.h | 12 + xen/arch/riscv/include/asm/traps.h | 30 + xen/arch/riscv/include/asm/types.h | 73 ++ xen/arch/riscv/include/asm/vm_event.h | 63 ++ xen/arch/riscv/include/asm/xenoprof.h | 12 + xen/arch/riscv/irq.c | 126 +++ xen/arch/riscv/lib/Makefile | 1 + xen/arch/riscv/lib/find_next_bit.c | 285 ++++++ xen/arch/riscv/mm.c | 633 +++++++++++++ xen/arch/riscv/p2m.c | 97 ++ xen/arch/riscv/percpu.c | 84 ++ xen/arch/riscv/platforms/Kconfig | 31 + xen/arch/riscv/riscv64/Makefile | 2 +- xen/arch/riscv/riscv64/asm-offsets.c | 39 + xen/arch/riscv/riscv64/head.S | 219 ++++- xen/arch/riscv/sbi.c | 483 ++++++++++ xen/arch/riscv/setup.c | 67 ++ xen/arch/riscv/shutdown.c | 24 + xen/arch/riscv/smp.c | 38 + xen/arch/riscv/smpboot.c | 78 ++ xen/arch/riscv/sysctl.c | 31 + xen/arch/riscv/time.c | 69 ++ xen/arch/riscv/traps.c | 87 ++ xen/arch/riscv/vm_event.c | 51 ++ xen/arch/riscv/xen.lds.S | 274 ++++++ xen/include/public/arch-riscv.h | 182 ++++ xen/include/public/arch-riscv/hvm/save.h | 39 + xen/include/public/hvm/save.h | 2 + xen/include/public/io/protocols.h | 3 + xen/include/public/pmu.h | 2 + xen/include/public/xen.h | 2 + 96 files changed, 9536 insertions(+), 8 deletions(-) create mode 100644 xen/arch/riscv/delay.c create mode 100644 xen/arch/riscv/domain.c create mode 100644 xen/arch/riscv/domctl.c create mode 100644 xen/arch/riscv/early_printk.c create mode 100644 xen/arch/riscv/guestcopy.c create mode 100644 xen/arch/riscv/include/asm/acpi.h create mode 100644 xen/arch/riscv/include/asm/altp2m.h create mode 100644 xen/arch/riscv/include/asm/asm.h create mode 100644 xen/arch/riscv/include/asm/atomic.h create mode 100644 xen/arch/riscv/include/asm/bitops.h create mode 100644 xen/arch/riscv/include/asm/bug.h create mode 100644 xen/arch/riscv/include/asm/byteorder.h create mode 100644 xen/arch/riscv/include/asm/cache.h create mode 100644 xen/arch/riscv/include/asm/cmpxchg.h create mode 100644 xen/arch/riscv/include/asm/cpufeature.h create mode 100644 xen/arch/riscv/include/asm/csr.h create mode 100644 xen/arch/riscv/include/asm/current.h create mode 100644 xen/arch/riscv/include/asm/debugger.h create mode 100644 xen/arch/riscv/include/asm/delay.h create mode 100644 xen/arch/riscv/include/asm/desc.h create mode 100644 xen/arch/riscv/include/asm/device.h create mode 100644 xen/arch/riscv/include/asm/div64.h create mode 100644 xen/arch/riscv/include/asm/domain.h create mode 100644 xen/arch/riscv/include/asm/early_printk.h create mode 100644 xen/arch/riscv/include/asm/event.h create mode 100644 xen/arch/riscv/include/asm/fence.h create mode 100644 xen/arch/riscv/include/asm/flushtlb.h create mode 100644 xen/arch/riscv/include/asm/grant_table.h create mode 100644 xen/arch/riscv/include/asm/guest_access.h create mode 100644 xen/arch/riscv/include/asm/guest_atomics.h create mode 100644 xen/arch/riscv/include/asm/hardirq.h create mode 100644 xen/arch/riscv/include/asm/hypercall.h create mode 100644 xen/arch/riscv/include/asm/init.h create mode 100644 xen/arch/riscv/include/asm/io.h create mode 100644 xen/arch/riscv/include/asm/iocap.h create mode 100644 xen/arch/riscv/include/asm/iommu.h create mode 100644 xen/arch/riscv/include/asm/iommu_fwspec.h create mode 100644 xen/arch/riscv/include/asm/irq.h create mode 100644 xen/arch/riscv/include/asm/mem_access.h create mode 100644 xen/arch/riscv/include/asm/mm.h create mode 100644 xen/arch/riscv/include/asm/monitor.h create mode 100644 xen/arch/riscv/include/asm/nospec.h create mode 100644 xen/arch/riscv/include/asm/numa.h create mode 100644 xen/arch/riscv/include/asm/p2m.h create mode 100644 xen/arch/riscv/include/asm/page-bits.h create mode 100644 xen/arch/riscv/include/asm/page.h create mode 100644 xen/arch/riscv/include/asm/paging.h create mode 100644 xen/arch/riscv/include/asm/pci.h create mode 100644 xen/arch/riscv/include/asm/percpu.h create mode 100644 xen/arch/riscv/include/asm/processor.h create mode 100644 xen/arch/riscv/include/asm/random.h create mode 100644 xen/arch/riscv/include/asm/regs.h create mode 100644 xen/arch/riscv/include/asm/riscv_encoding.h create mode 100644 xen/arch/riscv/include/asm/sbi.h create mode 100644 xen/arch/riscv/include/asm/setup.h create mode 100644 xen/arch/riscv/include/asm/smp.h create mode 100644 xen/arch/riscv/include/asm/softirq.h create mode 100644 xen/arch/riscv/include/asm/spinlock.h create mode 100644 xen/arch/riscv/include/asm/string.h create mode 100644 xen/arch/riscv/include/asm/system.h create mode 100644 xen/arch/riscv/include/asm/time.h create mode 100644 xen/arch/riscv/include/asm/trace.h create mode 100644 xen/arch/riscv/include/asm/traps.h create mode 100644 xen/arch/riscv/include/asm/types.h create mode 100644 xen/arch/riscv/include/asm/vm_event.h create mode 100644 xen/arch/riscv/include/asm/xenoprof.h create mode 100644 xen/arch/riscv/irq.c create mode 100644 xen/arch/riscv/lib/Makefile create mode 100644 xen/arch/riscv/lib/find_next_bit.c create mode 100644 xen/arch/riscv/mm.c create mode 100644 xen/arch/riscv/p2m.c create mode 100644 xen/arch/riscv/percpu.c create mode 100644 xen/arch/riscv/platforms/Kconfig create mode 100644 xen/arch/riscv/sbi.c create mode 100644 xen/arch/riscv/setup.c create mode 100644 xen/arch/riscv/shutdown.c create mode 100644 xen/arch/riscv/smp.c create mode 100644 xen/arch/riscv/smpboot.c create mode 100644 xen/arch/riscv/sysctl.c create mode 100644 xen/arch/riscv/time.c create mode 100644 xen/arch/riscv/traps.c create mode 100644 xen/arch/riscv/vm_event.c create mode 100644 xen/arch/riscv/xen.lds.S create mode 100644 xen/include/public/arch-riscv.h create mode 100644 xen/include/public/arch-riscv/hvm/save.h
Signature · 1 line
2.30.2
RFC PATCH 1/6 xen/riscv: Add necessary headers and definitions to build xen.
Target xen and xen-syms can be built with:
$ make XEN_TARGET_ARCH=riscv64 CROSS_COMPILE=riscv64-linux-gnu- tiny64_defconfig $ make XEN_TARGET_ARCH=riscv64 CROSS_COMPILE=riscv64-linux-gnu-
It can be tested with Qemu.
$ qemu-system-riscv64 -machine virt -m 1G -kernel xen
Xen will jump into an infinite loop and there will be no output.
--- xen/arch/riscv/Kconfig | 2 + xen/arch/riscv/Makefile | 51 ++ xen/arch/riscv/Rules.mk | 57 ++ xen/arch/riscv/delay.c | 14 + xen/arch/riscv/domain.c | 191 ++++ xen/arch/riscv/domctl.c | 52 ++ xen/arch/riscv/guestcopy.c | 59 ++ xen/arch/riscv/include/asm/acpi.h | 9 + xen/arch/riscv/include/asm/altp2m.h | 39 + xen/arch/riscv/include/asm/asm.h | 76 ++ xen/arch/riscv/include/asm/atomic.h | 375 ++++++++ xen/arch/riscv/include/asm/bitops.h | 397 ++++++++ xen/arch/riscv/include/asm/bug.h | 67 ++ xen/arch/riscv/include/asm/byteorder.h | 16 + xen/arch/riscv/include/asm/cache.h | 24 + xen/arch/riscv/include/asm/cmpxchg.h | 382 ++++++++ xen/arch/riscv/include/asm/config.h | 149 ++- xen/arch/riscv/include/asm/cpufeature.h | 68 ++ xen/arch/riscv/include/asm/csr.h | 81 ++ xen/arch/riscv/include/asm/current.h | 41 + xen/arch/riscv/include/asm/debugger.h | 15 + xen/arch/riscv/include/asm/delay.h | 28 + xen/arch/riscv/include/asm/desc.h | 12 + xen/arch/riscv/include/asm/device.h | 93 ++ xen/arch/riscv/include/asm/div64.h | 23 + xen/arch/riscv/include/asm/domain.h | 80 ++ xen/arch/riscv/include/asm/event.h | 42 + xen/arch/riscv/include/asm/fence.h | 12 + xen/arch/riscv/include/asm/flushtlb.h | 56 ++ xen/arch/riscv/include/asm/grant_table.h | 93 ++ xen/arch/riscv/include/asm/guest_access.h | 125 +++ xen/arch/riscv/include/asm/guest_atomics.h | 62 ++ xen/arch/riscv/include/asm/hardirq.h | 27 + xen/arch/riscv/include/asm/hypercall.h | 12 + xen/arch/riscv/include/asm/init.h | 42 + xen/arch/riscv/include/asm/io.h | 283 ++++++ xen/arch/riscv/include/asm/iocap.h | 16 + xen/arch/riscv/include/asm/iommu.h | 46 + xen/arch/riscv/include/asm/iommu_fwspec.h | 68 ++ xen/arch/riscv/include/asm/irq.h | 62 ++ xen/arch/riscv/include/asm/mem_access.h | 35 + xen/arch/riscv/include/asm/mm.h | 320 +++++++ xen/arch/riscv/include/asm/monitor.h | 65 ++ xen/arch/riscv/include/asm/nospec.h | 25 + xen/arch/riscv/include/asm/numa.h | 41 + xen/arch/riscv/include/asm/p2m.h | 307 +++++++ xen/arch/riscv/include/asm/page-bits.h | 14 + xen/arch/riscv/include/asm/page.h | 319 +++++++ xen/arch/riscv/include/asm/paging.h | 16 + xen/arch/riscv/include/asm/pci.h | 31 + xen/arch/riscv/include/asm/percpu.h | 35 + xen/arch/riscv/include/asm/processor.h | 176 ++++ xen/arch/riscv/include/asm/random.h | 9 + xen/arch/riscv/include/asm/regs.h | 42 + xen/arch/riscv/include/asm/riscv_encoding.h | 960 ++++++++++++++++++++ xen/arch/riscv/include/asm/setup.h | 23 + xen/arch/riscv/include/asm/smp.h | 69 ++ xen/arch/riscv/include/asm/softirq.h | 16 + xen/arch/riscv/include/asm/spinlock.h | 13 + xen/arch/riscv/include/asm/string.h | 28 + xen/arch/riscv/include/asm/system.h | 98 ++ xen/arch/riscv/include/asm/time.h | 81 ++ xen/arch/riscv/include/asm/trace.h | 12 + xen/arch/riscv/include/asm/traps.h | 30 + xen/arch/riscv/include/asm/types.h | 73 ++ xen/arch/riscv/include/asm/vm_event.h | 63 ++ xen/arch/riscv/include/asm/xenoprof.h | 12 + xen/arch/riscv/irq.c | 126 +++ xen/arch/riscv/lib/Makefile | 1 + xen/arch/riscv/lib/find_next_bit.c | 285 ++++++ xen/arch/riscv/mm.c | 409 +++++++++ xen/arch/riscv/p2m.c | 97 ++ xen/arch/riscv/percpu.c | 84 ++ xen/arch/riscv/platforms/Kconfig | 31 + xen/arch/riscv/riscv64/Makefile | 2 +- xen/arch/riscv/riscv64/asm-offsets.c | 39 + xen/arch/riscv/riscv64/head.S | 13 +- xen/arch/riscv/setup.c | 65 ++ xen/arch/riscv/shutdown.c | 24 + xen/arch/riscv/smp.c | 38 + xen/arch/riscv/smpboot.c | 78 ++ xen/arch/riscv/sysctl.c | 31 + xen/arch/riscv/time.c | 69 ++ xen/arch/riscv/traps.c | 87 ++ xen/arch/riscv/vm_event.c | 51 ++ xen/arch/riscv/xen.lds.S | 274 ++++++ xen/include/public/arch-riscv.h | 182 ++++ xen/include/public/arch-riscv/hvm/save.h | 39 + xen/include/public/hvm/save.h | 2 + xen/include/public/io/protocols.h | 3 + xen/include/public/pmu.h | 2 + xen/include/public/xen.h | 2 + 92 files changed, 8286 insertions(+), 8 deletions(-) create mode 100644 xen/arch/riscv/delay.c create mode 100644 xen/arch/riscv/domain.c create mode 100644 xen/arch/riscv/domctl.c create mode 100644 xen/arch/riscv/guestcopy.c create mode 100644 xen/arch/riscv/include/asm/acpi.h create mode 100644 xen/arch/riscv/include/asm/altp2m.h create mode 100644 xen/arch/riscv/include/asm/asm.h create mode 100644 xen/arch/riscv/include/asm/atomic.h create mode 100644 xen/arch/riscv/include/asm/bitops.h create mode 100644 xen/arch/riscv/include/asm/bug.h create mode 100644 xen/arch/riscv/include/asm/byteorder.h create mode 100644 xen/arch/riscv/include/asm/cache.h create mode 100644 xen/arch/riscv/include/asm/cmpxchg.h create mode 100644 xen/arch/riscv/include/asm/cpufeature.h create mode 100644 xen/arch/riscv/include/asm/csr.h create mode 100644 xen/arch/riscv/include/asm/current.h create mode 100644 xen/arch/riscv/include/asm/debugger.h create mode 100644 xen/arch/riscv/include/asm/delay.h create mode 100644 xen/arch/riscv/include/asm/desc.h create mode 100644 xen/arch/riscv/include/asm/device.h create mode 100644 xen/arch/riscv/include/asm/div64.h create mode 100644 xen/arch/riscv/include/asm/domain.h create mode 100644 xen/arch/riscv/include/asm/event.h create mode 100644 xen/arch/riscv/include/asm/fence.h create mode 100644 xen/arch/riscv/include/asm/flushtlb.h create mode 100644 xen/arch/riscv/include/asm/grant_table.h create mode 100644 xen/arch/riscv/include/asm/guest_access.h create mode 100644 xen/arch/riscv/include/asm/guest_atomics.h create mode 100644 xen/arch/riscv/include/asm/hardirq.h create mode 100644 xen/arch/riscv/include/asm/hypercall.h create mode 100644 xen/arch/riscv/include/asm/init.h create mode 100644 xen/arch/riscv/include/asm/io.h create mode 100644 xen/arch/riscv/include/asm/iocap.h create mode 100644 xen/arch/riscv/include/asm/iommu.h create mode 100644 xen/arch/riscv/include/asm/iommu_fwspec.h create mode 100644 xen/arch/riscv/include/asm/irq.h create mode 100644 xen/arch/riscv/include/asm/mem_access.h create mode 100644 xen/arch/riscv/include/asm/mm.h create mode 100644 xen/arch/riscv/include/asm/monitor.h create mode 100644 xen/arch/riscv/include/asm/nospec.h create mode 100644 xen/arch/riscv/include/asm/numa.h create mode 100644 xen/arch/riscv/include/asm/p2m.h create mode 100644 xen/arch/riscv/include/asm/page-bits.h create mode 100644 xen/arch/riscv/include/asm/page.h create mode 100644 xen/arch/riscv/include/asm/paging.h create mode 100644 xen/arch/riscv/include/asm/pci.h create mode 100644 xen/arch/riscv/include/asm/percpu.h create mode 100644 xen/arch/riscv/include/asm/processor.h create mode 100644 xen/arch/riscv/include/asm/random.h create mode 100644 xen/arch/riscv/include/asm/regs.h create mode 100644 xen/arch/riscv/include/asm/riscv_encoding.h create mode 100644 xen/arch/riscv/include/asm/setup.h create mode 100644 xen/arch/riscv/include/asm/smp.h create mode 100644 xen/arch/riscv/include/asm/softirq.h create mode 100644 xen/arch/riscv/include/asm/spinlock.h create mode 100644 xen/arch/riscv/include/asm/string.h create mode 100644 xen/arch/riscv/include/asm/system.h create mode 100644 xen/arch/riscv/include/asm/time.h create mode 100644 xen/arch/riscv/include/asm/trace.h create mode 100644 xen/arch/riscv/include/asm/traps.h create mode 100644 xen/arch/riscv/include/asm/types.h create mode 100644 xen/arch/riscv/include/asm/vm_event.h create mode 100644 xen/arch/riscv/include/asm/xenoprof.h create mode 100644 xen/arch/riscv/irq.c create mode 100644 xen/arch/riscv/lib/Makefile create mode 100644 xen/arch/riscv/lib/find_next_bit.c create mode 100644 xen/arch/riscv/mm.c create mode 100644 xen/arch/riscv/p2m.c create mode 100644 xen/arch/riscv/percpu.c create mode 100644 xen/arch/riscv/platforms/Kconfig create mode 100644 xen/arch/riscv/setup.c create mode 100644 xen/arch/riscv/shutdown.c create mode 100644 xen/arch/riscv/smp.c create mode 100644 xen/arch/riscv/smpboot.c create mode 100644 xen/arch/riscv/sysctl.c create mode 100644 xen/arch/riscv/time.c create mode 100644 xen/arch/riscv/traps.c create mode 100644 xen/arch/riscv/vm_event.c create mode 100644 xen/arch/riscv/xen.lds.S create mode 100644 xen/include/public/arch-riscv.h create mode 100644 xen/include/public/arch-riscv/hvm/save.h
xen/arch/riscv/Kconfig +2 -0
@@ -1,5 +1,7 @@ config RISCV def_bool y + select HAS_PDX + select HAS_DEVICE_TREE config RISCV_64 def_bool y
xen/arch/riscv/Makefile +51 -0
53 lines not on this page · raw message
xen/arch/riscv/Rules.mk +57 -0
57 lines not on this page · raw message
xen/arch/riscv/delay.c new file +14 -0
@@ -0,0 +1,14 @@ +void __delay (unsigned long cycles) +{ +} +EXPORT_SYMBOL (__delay); + +void udelay (unsigned long usecs) +{ +} +EXPORT_SYMBOL (udelay); + +void ndelay (unsigned long nsecs) +{ +} +EXPORT_SYMBOL (ndelay);
xen/arch/riscv/domain.c new file +191 -0
191 lines not on this page · raw message
xen/arch/riscv/domctl.c new file +52 -0
52 lines not on this page · raw message
xen/arch/riscv/guestcopy.c new file +59 -0
59 lines not on this page · raw message
xen/arch/riscv/include/asm/acpi.h new file +9 -0
@@ -0,0 +1,9 @@ +#ifndef _ASM_RISCV_ACPI_H +#define _ASM_RISCV_ACPI_H + +#include <asm/setup.h> + +extern bool acpi_disabled; + + +#endif /*_ASM_RISCV_ACPI_H*/
xen/arch/riscv/include/asm/altp2m.h new file +39 -0
@@ -0,0 +1,39 @@ +/* +* Alternate p2m +* +* Copyright (c) 2014, Intel Corporation. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program; If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef __ASM_RISCV_ALTP2M_H +#define __ASM_RISCV_ALTP2M_H + +#include <xen/sched.h> + +/* Alternate p2m on/off per domain */ +static inline bool altp2m_active (const struct domain *d) +{ +/* Not implemented on RISCV. */ +return false; +} + +/* Alternate p2m VCPU */ +static inline uint16_t altp2m_vcpu_idx (const struct vcpu *v) +{ +/* Not implemented on RISCV, should not be reached. */ +BUG (); +return 0 ; +} + +#endif /* __ASM_RISCV_ALTP2M_H */
xen/arch/riscv/include/asm/asm.h new file +76 -0
76 lines not on this page · raw message
xen/arch/riscv/include/asm/atomic.h new file +375 -0
375 lines not on this page · raw message
xen/arch/riscv/include/asm/bitops.h new file +397 -0
397 lines not on this page · raw message
xen/arch/riscv/include/asm/bug.h new file +67 -0
67 lines not on this page · raw message
xen/arch/riscv/include/asm/byteorder.h new file +16 -0
@@ -0,0 +1,16 @@ +#ifndef __ASM_RISCV_BYTEORDER_H__ +#define __ASM_RISCV_BYTEORDER_H__ + +#define __BYTEORDER_HAS_U64__ + +#include <xen/byteorder/little_endian.h> + +#endif /* __ASM_RISCV_BYTEORDER_H__ */ +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
xen/arch/riscv/include/asm/cache.h new file +24 -0
@@ -0,0 +1,24 @@ +/* +* Copyright (C) 2017 Chen Liqin <[email protected]> +* Copyright (C) 2012 Regents of the University of California +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation, version 2. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#ifndef _ASM_RISCV_CACHE_H +#define _ASM_RISCV_CACHE_H + +#define L1_CACHE_SHIFT 6 + +#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT) + +#define __read_mostly __section(".data.read_mostly") + +#endif /* _ASM_RISCV_CACHE_H */
xen/arch/riscv/include/asm/cmpxchg.h new file +382 -0
382 lines not on this page · raw message
xen/arch/riscv/include/asm/config.h +145 -4
165 lines not on this page · raw message
xen/arch/riscv/include/asm/cpufeature.h new file +68 -0
68 lines not on this page · raw message
xen/arch/riscv/include/asm/csr.h new file +81 -0
81 lines not on this page · raw message
xen/arch/riscv/include/asm/current.h new file +41 -0
41 lines not on this page · raw message
xen/arch/riscv/include/asm/debugger.h new file +15 -0
@@ -0,0 +1,15 @@ +#ifndef __RISCV_DEBUGGER_H__ +#define __RISCV_DEBUGGER_H__ + +#define debugger_trap_fatal (v, r) (0) +#define debugger_trap_immediate () ((void) 0) + +#endif /* __RISCV_DEBUGGER_H__ */ +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
xen/arch/riscv/include/asm/delay.h new file +28 -0
@@ -0,0 +1,28 @@ +/* +* Copyright (C) 2009 Chen Liqin <[email protected]> +* Copyright (C) 2016 Regents of the University of California +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation, version 2. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#ifndef _ASM_RISCV_DELAY_H +#define _ASM_RISCV_DELAY_H + +extern unsigned long riscv_timebase; + +#define udelay udelay +extern void udelay (unsigned long usecs); + +#define ndelay ndelay +extern void ndelay (unsigned long nsecs); + +extern void __delay (unsigned long cycles); + +#endif /* _ASM_RISCV_DELAY_H */
xen/arch/riscv/include/asm/desc.h new file +12 -0
@@ -0,0 +1,12 @@ +#ifndef __ARCH_DESC_H +#define __ARCH_DESC_H + +#endif /* __ARCH_DESC_H */ +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
xen/arch/riscv/include/asm/device.h new file +93 -0
93 lines not on this page · raw message
xen/arch/riscv/include/asm/div64.h new file +23 -0
@@ -0,0 +1,23 @@ +#ifndef __ASM_RISCV_DIV64 +#define __ASM_RISCV_DIV64 + +#include <asm/system.h> +#include <xen/types.h> + +# define do_div (n,base) ({ \ + uint32_t __base = (base); \ + uint32_t __rem; \ + __rem = ((uint64_t)(n)) % __base; \ + (n) = ((uint64_t)(n)) / __base; \ + __rem; \ + }) + +#endif +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
xen/arch/riscv/include/asm/domain.h new file +80 -0
80 lines not on this page · raw message
xen/arch/riscv/include/asm/event.h new file +42 -0
42 lines not on this page · raw message
xen/arch/riscv/include/asm/fence.h new file +12 -0
@@ -0,0 +1,12 @@ +#ifndef _ASM_RISCV_FENCE_H +#define _ASM_RISCV_FENCE_H + +#ifdef CONFIG_SMP +#define RISCV_ACQUIRE_BARRIER "\tfence r , rw\n" +#define RISCV_RELEASE_BARRIER "\tfence rw, w\n" +#else +#define RISCV_ACQUIRE_BARRIER +#define RISCV_RELEASE_BARRIER +#endif + +#endif /* _ASM_RISCV_FENCE_H */
xen/arch/riscv/include/asm/flushtlb.h new file +56 -0
56 lines not on this page · raw message
xen/arch/riscv/include/asm/grant_table.h new file +93 -0
93 lines not on this page · raw message
xen/arch/riscv/include/asm/guest_access.h new file +125 -0
125 lines not on this page · raw message
xen/arch/riscv/include/asm/guest_atomics.h new file +62 -0
62 lines not on this page · raw message
xen/arch/riscv/include/asm/hardirq.h new file +27 -0
@@ -0,0 +1,27 @@ +#ifndef __ASM_HARDIRQ_H +#define __ASM_HARDIRQ_H + +#include <xen/cache.h> +#include <xen/smp.h> + +typedef struct { +unsigned long __softirq_pending; +unsigned int __local_irq_count; +} __cacheline_aligned irq_cpustat_t; + +#include <xen/irq_cpustat.h> /* Standard mappings for irq_cpustat_t above */ + +#define in_irq () (local_irq_count(smp_processor_id()) != 0) + +#define irq_enter () (local_irq_count(smp_processor_id())++) +#define irq_exit () (local_irq_count(smp_processor_id())--) + +#endif /* __ASM_HARDIRQ_H */ +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
xen/arch/riscv/include/asm/hypercall.h new file +12 -0
@@ -0,0 +1,12 @@ +#ifndef __ASM_RISCV_HYPERCALL_H__ +#define __ASM_RISCV_HYPERCALL_H__ + +#endif /* __ASM_RISCV_HYPERCALL_H__ */ +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
xen/arch/riscv/include/asm/init.h new file +42 -0
42 lines not on this page · raw message
xen/arch/riscv/include/asm/io.h new file +283 -0
105 lines not on this page · raw message
xen/arch/riscv/include/asm/iocap.h new file +16 -0
Lines of this file are not shown. View the raw message.
xen/arch/riscv/include/asm/iommu.h new file +46 -0
46 lines not on this page · raw message
xen/arch/riscv/include/asm/iommu_fwspec.h new file +68 -0
68 lines not on this page · raw message
xen/arch/riscv/include/asm/irq.h new file +62 -0
62 lines not on this page · raw message
xen/arch/riscv/include/asm/mem_access.h new file +35 -0
Lines of this file are not shown. View the raw message.
xen/arch/riscv/include/asm/mm.h new file +320 -0
320 lines not on this page · raw message
xen/arch/riscv/include/asm/monitor.h new file +65 -0
65 lines not on this page · raw message
xen/arch/riscv/include/asm/nospec.h new file +25 -0
Lines of this file are not shown. View the raw message.
xen/arch/riscv/include/asm/numa.h new file +41 -0
41 lines not on this page · raw message
xen/arch/riscv/include/asm/p2m.h new file +307 -0
307 lines not on this page · raw message
xen/arch/riscv/include/asm/page-bits.h new file +14 -0
Lines of this file are not shown. View the raw message.
xen/arch/riscv/include/asm/page.h new file +319 -0
319 lines not on this page · raw message
xen/arch/riscv/include/asm/paging.h new file +16 -0
Lines of this file are not shown. View the raw message.
xen/arch/riscv/include/asm/pci.h new file +31 -0
Lines of this file are not shown. View the raw message.
xen/arch/riscv/include/asm/percpu.h new file +35 -0
Lines of this file are not shown. View the raw message.
xen/arch/riscv/include/asm/processor.h new file +176 -0
176 lines not on this page · raw message
xen/arch/riscv/include/asm/random.h new file +9 -0
Lines of this file are not shown. View the raw message.
xen/arch/riscv/include/asm/regs.h new file +42 -0
42 lines not on this page · raw message
xen/arch/riscv/include/asm/riscv_encoding.h new file +960 -0
960 lines not on this page · raw message
xen/arch/riscv/include/asm/setup.h new file +23 -0
Lines of this file are not shown. View the raw message.
xen/arch/riscv/include/asm/smp.h new file +69 -0
69 lines not on this page · raw message
xen/arch/riscv/include/asm/softirq.h new file +16 -0
Lines of this file are not shown. View the raw message.
xen/arch/riscv/include/asm/spinlock.h new file +13 -0
Lines of this file are not shown. View the raw message.
xen/arch/riscv/include/asm/string.h new file +28 -0
Lines of this file are not shown. View the raw message.
xen/arch/riscv/include/asm/system.h new file +98 -0
98 lines not on this page · raw message
xen/arch/riscv/include/asm/time.h new file +81 -0
81 lines not on this page · raw message
xen/arch/riscv/include/asm/trace.h new file +12 -0
Lines of this file are not shown. View the raw message.
xen/arch/riscv/include/asm/traps.h new file +30 -0
Lines of this file are not shown. View the raw message.
xen/arch/riscv/include/asm/types.h new file +73 -0
73 lines not on this page · raw message
xen/arch/riscv/include/asm/vm_event.h new file +63 -0
63 lines not on this page · raw message
xen/arch/riscv/include/asm/xenoprof.h new file +12 -0
Lines of this file are not shown. View the raw message.
xen/arch/riscv/irq.c new file +126 -0
126 lines not on this page · raw message
xen/arch/riscv/lib/find_next_bit.c new file +285 -0
285 lines not on this page · raw message
xen/arch/riscv/mm.c new file +409 -0
409 lines not on this page · raw message
xen/arch/riscv/p2m.c new file +97 -0
97 lines not on this page · raw message
xen/arch/riscv/percpu.c new file +84 -0
84 lines not on this page · raw message
xen/arch/riscv/platforms/Kconfig new file +31 -0
Lines of this file are not shown. View the raw message.
xen/arch/riscv/setup.c new file +65 -0
65 lines not on this page · raw message
xen/arch/riscv/smpboot.c new file +78 -0
78 lines not on this page · raw message
xen/arch/riscv/time.c new file +69 -0
69 lines not on this page · raw message
xen/arch/riscv/traps.c new file +87 -0
87 lines not on this page · raw message
xen/arch/riscv/vm_event.c new file +51 -0
51 lines not on this page · raw message
xen/arch/riscv/xen.lds.S new file +274 -0
274 lines not on this page · raw message
xen/include/public/arch-riscv.h new file +182 -0
182 lines not on this page · raw message
xen/include/public/arch-riscv/hvm/save.h new file +39 -0
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.30.2
Part of the diff is not shown here. View the raw message.
Re: [RFC PATCH 1/6] xen/riscv: Add necessary headers and definitions to build xen.
Quoted 18 lines · Xie Xun
xen/arch/riscv/xen.lds.S new file +15
-0@@ -0,0 +1,274 @@ +/** + * Copyright (c) 2018 Anup Patel. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License
xen/arch/riscv/xen.lds.S line 25
Quoted 10 lines
xen/arch/riscv/xen.lds.S new file +10
-0+ * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * @file linker.ld + * @author Anup Patel ([email protected]) + * @brief CPU specific linker script + */ + +#include <xen/cache.h> +#include <asm/percpu.h>
At the example of this - how up-to-date a code base was this written / re-based against? The Arm version of this file, which likely would be the closest reference, makes use of e.g. the recently introduced xen/xen.lds.h.
Quoted 40 lines
xen/include/public/arch-riscv.h new file +37
-0@@ -0,0 +1,182 @@ +/****************************************************************************** +* arch-riscv.h +* +* Guest OS interface to RISC-V Xen. +* Initially based on the ARM implementation +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to +* deal in the Software without restriction, including without limitation the +* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +* sell copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +* +* Copyright 2019 (C) Alistair Francis <[email protected]> +*/ + +#ifndef __XEN_PUBLIC_ARCH_RISCV_H__ +#define __XEN_PUBLIC_ARCH_RISCV_H__ + +#define int64_aligned_t int64_t __attribute__((aligned(8))) +#define uint64_aligned_t uint64_t __attribute__((aligned(8))) + +#ifndef __ASSEMBLY__ +#define ___DEFINE_XEN_GUEST_HANDLE (name, type) \ + typedef union { type *p; unsigned long q; } \ + __guest_handle_ ## name; \
xen/include/public/arch-riscv.h line 47
Quoted 10 lines
xen/include/public/arch-riscv.h new file +10
-0+ typedef union { type *p; uint64_aligned_t q; } \ + __guest_handle_64_ ## name + +/* +* XEN_GUEST_HANDLE represents a guest pointer, when passed as a field +* in a struct in memory. On RISCV is always 8 bytes sizes and 8 bytes +* aligned. +* XEN_GUEST_HANDLE_PARAM represents a guest pointer, when passed as an +* hypercall argument. It is 4 bytes on aarch32 and 8 bytes on aarch64. +*/
aarch{32,64}?
I understand that despite the base architecture having provisions for 128-bit mode, there's no intention to have provisions for this mode in the public interface? But perhaps at least #error on unsupported __riscv_xlen values?
xen/include/public/arch-riscv.h line 57
Quoted 10 lines
xen/include/public/arch-riscv.h new file +10
-0+#define __DEFINE_XEN_GUEST_HANDLE (name, type) \ + ___DEFINE_XEN_GUEST_HANDLE(name, type); \ + ___DEFINE_XEN_GUEST_HANDLE(const_##name, const type) +#define DEFINE_XEN_GUEST_HANDLE (name) __DEFINE_XEN_GUEST_HANDLE(name, name) +#define __XEN_GUEST_HANDLE (name) __guest_handle_64_ ## name +#define XEN_GUEST_HANDLE (name) __XEN_GUEST_HANDLE(name) +#define XEN_GUEST_HANDLE_PARAM (name) __guest_handle_ ## name +#define set_xen_guest_handle_raw (hnd, val) \ + do { \ + typeof(&(hnd)) _sxghr_tmp = &(hnd); \
Would be nice if new code could avoid cloning name space issues, like use of identifiers with leading underscores (which are reserved for use by file-scope objects/functions/macros).
Quoted 5 lines
xen/include/public/arch-riscv.h new file +5
-0+ _sxghr_tmp->q =0 ; \ + _sxghr_tmp->p = val; \ + } while ( 0 ) +#define set_xen_guest_handle (hnd, val) set_xen_guest_handle_raw(hnd, val) +
xen/include/public/arch-riscv.h line 72
Quoted 10 lines
xen/include/public/arch-riscv.h new file +10
-0+#if defined(__GNUC__) && !defined(__STRICT_ANSI__) +/* Anonymous union includes both 32- and 64-bit names (e.g., r0/x0). */ +# define __DECL_REG (n64, n32) union { \ + uint64_t n64; \ + uint32_t n32; \ + } +#else +/* Non-gcc sources must always use the proper 64-bit name (e.g., x0). */ +#define __DECL_REG (n64, n32) uint64_t n64 +#endif
What is this good for when ...
Quoted 41 lines
xen/include/public/arch-riscv.h new file +41
-0+struct vcpu_guest_core_regs +{ +unsigned long zero; +unsigned long ra; +unsigned long sp; +unsigned long gp; +unsigned long tp; +unsigned long t0; +unsigned long t1; +unsigned long t2; +unsigned long s0; +unsigned long s1; +unsigned long a0; +unsigned long a1; +unsigned long a2; +unsigned long a3; +unsigned long a4; +unsigned long a5; +unsigned long a6; +unsigned long a7; +unsigned long s2; +unsigned long s3; +unsigned long s4; +unsigned long s5; +unsigned long s6; +unsigned long s7; +unsigned long s8; +unsigned long s9; +unsigned long s10; +unsigned long s11; +unsigned long t3; +unsigned long t4; +unsigned long t5; +unsigned long t6; +unsigned long sepc; +unsigned long sstatus; +unsigned long hstatus; +unsigned long sp_exec; + +unsigned long hedeleg; +unsigned long hideleg;
xen/include/public/arch-riscv.h line 124
Quoted 10 lines
xen/include/public/arch-riscv.h new file +10
-0+unsigned long bsstatus; +unsigned long bsie; +unsigned long bstvec; +unsigned long bsscratch; +unsigned long bsepc; +unsigned long bscause; +unsigned long bstval; +unsigned long bsip; +unsigned long bsatp; +};
... you don't use it anywhere? The use of "unsigned long" here needs to be changed anyway, as you need to express both views (rv32 and rv64), unless you mean to never support 32-bit guests.
Quoted 4 lines
xen/include/public/arch-riscv.h new file +4
-0+typedef struct vcpu_guest_core_regs vcpu_guest_core_regs_t ; +DEFINE_XEN_GUEST_HANDLE (vcpu_guest_core_regs_t); + +typedef uint64_t xen_pfn_t ;
xen/include/public/arch-riscv.h line 138
Quoted 10 lines
xen/include/public/arch-riscv.h new file +10
-0+#define PRI_xen_pfn PRIx64 +#define PRIu_xen_pfn PRIu64 + +typedef uint64_t xen_ulong_t ; +#define PRI_xen_ulong PRIx64 + +#if defined(__XEN__) || defined(__XEN_TOOLS__) + +struct vcpu_guest_context { +};
At least struct vcpu_guest_core_regs should have an instance in here, shouldn't it?
Jan
Re: [RFC PATCH 1/6] xen/riscv: Add necessary headers and definitions to build xen.
In reply to Xie XunHi Xie,
Thank you for the contribution.
Quoted 10 lines · Xie Xun
Target xen and xen-syms can be built with:
$ make XEN_TARGET_ARCH=riscv64 CROSS_COMPILE=riscv64-linux-gnu- tiny64_defconfig $ make XEN_TARGET_ARCH=riscv64 CROSS_COMPILE=riscv64-linux-gnu-It can be tested with Qemu.
$ qemu-system-riscv64 -machine virt -m 1G -kernel xenXen will jump into an infinite loop and there will be no output.
I will answer here what you wrote in the cover letter:
"There are some problems though. The first patch of this series is very large, but it seems most of the code is necessary for building xen. I am trying my best to remove some code but it still has more than 8000 lines of code."
I think it would be beneficial to split this patch in smaller logical one even they don't build one by one. Briefly looking through the series, it looks like some code (such as the atomic) was imported from another project.
So you could move them in one (or multiple) separate patch.
Also, if you took code from other project, it would be good to specify where this coming from and what was the baseline. This will help to re-sync the code in the future.
Quoted 65 lines
Signed-off-by Xie Xun <[email protected]>--- xen/arch/riscv/Kconfig | 2 + xen/arch/riscv/Makefile | 51 ++ xen/arch/riscv/Rules.mk | 57 ++ xen/arch/riscv/delay.c | 14 + xen/arch/riscv/domain.c | 191 ++++ xen/arch/riscv/domctl.c | 52 ++ xen/arch/riscv/guestcopy.c | 59 ++ xen/arch/riscv/include/asm/acpi.h | 9 + xen/arch/riscv/include/asm/altp2m.h | 39 + xen/arch/riscv/include/asm/asm.h | 76 ++ xen/arch/riscv/include/asm/atomic.h | 375 ++++++++ xen/arch/riscv/include/asm/bitops.h | 397 ++++++++ xen/arch/riscv/include/asm/bug.h | 67 ++ xen/arch/riscv/include/asm/byteorder.h | 16 + xen/arch/riscv/include/asm/cache.h | 24 + xen/arch/riscv/include/asm/cmpxchg.h | 382 ++++++++ xen/arch/riscv/include/asm/config.h | 149 ++- xen/arch/riscv/include/asm/cpufeature.h | 68 ++ xen/arch/riscv/include/asm/csr.h | 81 ++ xen/arch/riscv/include/asm/current.h | 41 + xen/arch/riscv/include/asm/debugger.h | 15 + xen/arch/riscv/include/asm/delay.h | 28 + xen/arch/riscv/include/asm/desc.h | 12 + xen/arch/riscv/include/asm/device.h | 93 ++ xen/arch/riscv/include/asm/div64.h | 23 + xen/arch/riscv/include/asm/domain.h | 80 ++ xen/arch/riscv/include/asm/event.h | 42 + xen/arch/riscv/include/asm/fence.h | 12 + xen/arch/riscv/include/asm/flushtlb.h | 56 ++ xen/arch/riscv/include/asm/grant_table.h | 93 ++ xen/arch/riscv/include/asm/guest_access.h | 125 +++ xen/arch/riscv/include/asm/guest_atomics.h | 62 ++ xen/arch/riscv/include/asm/hardirq.h | 27 + xen/arch/riscv/include/asm/hypercall.h | 12 + xen/arch/riscv/include/asm/init.h | 42 + xen/arch/riscv/include/asm/io.h | 283 ++++++ xen/arch/riscv/include/asm/iocap.h | 16 + xen/arch/riscv/include/asm/iommu.h | 46 + xen/arch/riscv/include/asm/iommu_fwspec.h | 68 ++ xen/arch/riscv/include/asm/irq.h | 62 ++ xen/arch/riscv/include/asm/mem_access.h | 35 + xen/arch/riscv/include/asm/mm.h | 320 +++++++ xen/arch/riscv/include/asm/monitor.h | 65 ++ xen/arch/riscv/include/asm/nospec.h | 25 + xen/arch/riscv/include/asm/numa.h | 41 + xen/arch/riscv/include/asm/p2m.h | 307 +++++++ xen/arch/riscv/include/asm/page-bits.h | 14 + xen/arch/riscv/include/asm/page.h | 319 +++++++ xen/arch/riscv/include/asm/paging.h | 16 + xen/arch/riscv/include/asm/pci.h | 31 + xen/arch/riscv/include/asm/percpu.h | 35 + xen/arch/riscv/include/asm/processor.h | 176 ++++ xen/arch/riscv/include/asm/random.h | 9 + xen/arch/riscv/include/asm/regs.h | 42 + xen/arch/riscv/include/asm/riscv_encoding.h | 960 ++++++++++++++++++++ xen/arch/riscv/include/asm/setup.h | 23 + xen/arch/riscv/include/asm/smp.h | 69 ++ xen/arch/riscv/include/asm/softirq.h | 16 + xen/arch/riscv/include/asm/spinlock.h | 13 + xen/arch/riscv/include/asm/string.h | 28 + xen/arch/riscv/include/asm/system.h | 98 ++ xen/arch/riscv/include/asm/time.h | 81 ++
Quoted 8 lines
xen/arch/riscv/include/asm/trace.h | 12 + xen/arch/riscv/include/asm/traps.h | 30 + xen/arch/riscv/include/asm/types.h | 73 ++ xen/arch/riscv/include/asm/vm_event.h | 63 ++ xen/arch/riscv/include/asm/xenoprof.h | 12 + xen/arch/riscv/irq.c | 126 +++ xen/arch/riscv/lib/Makefile | 1 + xen/arch/riscv/lib/find_next_bit.c | 285 ++++++
This is a copy from the Arm version, right? If so, please move the Arm one in common/lib/ so you can re-use it.
Quoted 14 lines
xen/arch/riscv/mm.c | 409 +++++++++ xen/arch/riscv/p2m.c | 97 ++ xen/arch/riscv/percpu.c | 84 ++ xen/arch/riscv/platforms/Kconfig | 31 + xen/arch/riscv/riscv64/Makefile | 2 +- xen/arch/riscv/riscv64/asm-offsets.c | 39 + xen/arch/riscv/riscv64/head.S | 13 +- xen/arch/riscv/setup.c | 65 ++ xen/arch/riscv/shutdown.c | 24 + xen/arch/riscv/smp.c | 38 + xen/arch/riscv/smpboot.c | 78 ++ xen/arch/riscv/sysctl.c | 31 + xen/arch/riscv/time.c | 69 ++ xen/arch/riscv/traps.c | 87 ++
Quoted 8 lines
xen/arch/riscv/vm_event.c | 51 ++ xen/arch/riscv/xen.lds.S | 274 ++++++ xen/include/public/arch-riscv.h | 182 ++++ xen/include/public/arch-riscv/hvm/save.h | 39 + xen/include/public/hvm/save.h | 2 + xen/include/public/io/protocols.h | 3 + xen/include/public/pmu.h | 2 + xen/include/public/xen.h | 2 +
The public headers could be moved separately.
[...]
xen/arch/riscv/Kconfig line 4
Quoted 9 lines
xen/arch/riscv/Kconfig +2
-0@@ -1,5 +1,7 @@ config RISCV def_bool y + select HAS_PDX + select HAS_DEVICE_TREE
The indentation looks incorrect to me. Kconfig is using hard tab rather than soft tab.
[...]
Quoted 17 lines
xen/arch/riscv/Rules.mk +12
-0@@ -0,0 +1,57 @@ +######################################## +# riscv-specific definitions + +# +# If you change any of these configuration options then you must +# 'make clean' before rebuilding. +# + +CFLAGS += -I$(BASEDIR)/include + +$(call cc-options-add,CFLAGS,CC,$(EMBEDDED_EXTRA_CFLAGS)) +$(call cc-option-add,CFLAGS,CC,-Wnested-externs)
xen/arch/riscv/Rules.mk line 22
Quoted 10 lines
xen/arch/riscv/Rules.mk +10
-0+$(call cc-option-add,CFLAGS,CC,-mstrict-align) +$(call cc-option-add,CFLAGS,CC,-mtune=size) + +EARLY_PRINTK := n + +ifeq ($(CONFIG_DEBUG),y) + +# See docs/misc/arm/early-printk.txt for syntax + +EARLY_PRINTK := 8250,0x1c021000,2
Is the UART standardized in RISCv?
xen/arch/riscv/Rules.mk line 24
Quoted 2 lines
xen/arch/riscv/Rules.mk +2
-0+ +ifneq ($(EARLY_PRINTK_$(CONFIG_EARLY_PRINTK)),)
On Arm, we converted the early printk to Kconfig. I would recommend to do the same because otherwise the user would have to specify the option on most of "make" options.
This lead to quite a few errors on the Arm side.
xen/arch/riscv/delay.c line 1
Quoted 7 lines
xen/arch/riscv/delay.c new file +1
-0@@ -0,0 +1,14 @@ +void __delay (unsigned long cycles)
This doesn't seem to be used in the common code. How did you decide what was needed?
I am asking that because I think it would be good to avoid adding helpers that will never get used.
xen/arch/riscv/delay.c line 2
Quoted 1 line
xen/arch/riscv/delay.c new file +1
-0+{
I am assuming this is going to be implemented at some point. At minimum, I would recommend to add a TODO.
But I would also consider to add ASSERT_UNREACHABLE() so anyone can notice when you use a function that has to be implemented.
This is less a problem for function like delay. However...
Quoted 28 lines
xen/arch/riscv/delay.c new file +12
-0+} +EXPORT_SYMBOL (__delay); + +void udelay (unsigned long usecs) +{ +} +EXPORT_SYMBOL (udelay); + +void ndelay (unsigned long nsecs) +{ +} +EXPORT_SYMBOL (ndelay);xen/arch/riscv/domain.c new file +10
-0@@ -0,0 +1,191 @@ +#include <xen/errno.h> +#include <xen/init.h> +#include <xen/lib.h> +#include <xen/sched.h> +#include <xen/domain.h> +#include <xen/softirq.h> +#include <asm/traps.h> +#include <public/domctl.h> +#include <public/xen.h> +
xen/arch/riscv/domain.c line 20
Quoted 10 lines
xen/arch/riscv/domain.c new file +10
-0+DEFINE_PER_CPU(struct vcpu *, curr_vcpu); + +struct vcpu *alloc_dom0_vcpu0 (struct domain *dom0) +{ +return vcpu_create (dom0,0 ); +} + +void context_switch (struct vcpu *prev,struct vcpu *next) +{ +/* TODO */
... you may have hard time to debug some of those functions here.
Quoted 203 lines
xen/arch/riscv/domain.c new file +171
-0+} + +void idle_loop (void ) +{ +/* TODO */ +} + +void noreturnstartup_cpu_idle_loop (void ) +{ +struct vcpu *v = current; + +ASSERT (is_idle_vcpu (v)); + +reset_stack_and_jump (idle_loop); + +/* This function is noreturn */ +BUG (); +} + +void continue_running (struct vcpu *same) +{ +/* TODO */ +} + +void sync_local_execstate (void ) +{ +/* TODO */ +} + +void sync_vcpu_execstate (struct vcpu *v) +{ +/* TODO */ +} + +unsigned long hypercall_create_continuation ( +unsigned int op,const char *format, ...) +{ +/* TODO */ + +return 0 ; +} + +struct domain *alloc_domain_struct (void ) +{ +return NULL ; +} + +void free_domain_struct (struct domain *d) +{ +/* TODO */ +} + +void dump_pageframe_info (struct domain *d) +{ +/* TODO */ +} + +int arch_sanitise_domain_config (struct xen_domctl_createdomain *config) +{ +return 0 ; +} + + +int arch_domain_create (struct domain *d, +struct xen_domctl_createdomain *config, +unsigned int flags) +{ +return -ENOSYS ; +} + +void arch_domain_destroy (struct domain *d) +{ +/* TODO */ +} + +void arch_domain_shutdown (struct domain *d) +{ +/* TODO */ +} + +void arch_domain_pause (struct domain *d) +{ +/* TODO */ +} + +void arch_domain_unpause (struct domain *d) +{ +/* TODO */ +} + +int arch_domain_soft_reset (struct domain *d) +{ +/* TODO */ +return -ENOSYS ; +} + +void arch_domain_creation_finished (struct domain *d) +{ +/* TODO */ +} + +int domain_relinquish_resources (struct domain *d) +{ +/* TODO */ +return -ENOSYS ; +} + +void arch_dump_domain_info (struct domain *d) +{ +/* TODO */ +} + +long arch_do_vcpu_op (int cmd,struct vcpu *v,XEN_GUEST_HANDLE_PARAM (void ) arg) +{ +/* TODO */ +return -ENOSYS ; +} + +void arch_dump_vcpu_info (struct vcpu *v) +{ +/* TODO */ +} + +int arch_set_info_guest ( +struct vcpu *v,vcpu_guest_context_u c) +{ +/* TODO */ +return -ENOSYS ; +} + +/* taken from arm/domain.c */ +struct vcpu *alloc_vcpu_struct (const struct domain *d) +{ +return NULL ; +} + +void free_vcpu_struct (struct vcpu *v) +{ +/* TODO */ +} + +int arch_initialise_vcpu (struct vcpu *v,XEN_GUEST_HANDLE_PARAM (void ) arg) +{ +/* TODO */ +return -ENOSYS ; +} + +int arch_vcpu_reset (struct vcpu *v) +{ +/* TODO */ +return -ENOSYS ; +} + +int arch_vcpu_create (struct vcpu *v) +{ +return -ENOSYS ; +} + +void arch_vcpu_destroy (struct vcpu *v) +{ +/* TODO */ +} + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/ xen/arch/riscv/domctl.c new file +26
-0@@ -0,0 +1,52 @@ +/****************************************************************************** +* Arch-specific domctl.c +* +* Copyright (c) 2012, Citrix Systems +*/ + +#include <xen/errno.h> +#include <xen/guest_access.h> +#include <xen/hypercall.h> +#include <xen/iocap.h> +#include <xen/lib.h> +#include <xen/mm.h> +#include <xen/sched.h> +#include <xen/types.h> +#include <xsm/xsm.h> +#include <public/domctl.h> + +void arch_get_domain_info (const struct domain *d, +struct xen_domctl_getdomaininfo *info) +{ + info->flags |= XEN_DOMINF_hap; +} + +long arch_do_domctl (struct xen_domctl *domctl,struct domain *d, +XEN_GUEST_HANDLE_PARAM (xen_domctl_t) u_domctl) +{
xen/arch/riscv/domctl.c line 36
Quoted 10 lines
xen/arch/riscv/domctl.c new file +10
-0+/* TODO */ + +switch ( domctl->cmd ) { +case XEN_DOMCTL_cacheflush: +case XEN_DOMCTL_bind_pt_irq: +case XEN_DOMCTL_unbind_pt_irq: +case XEN_DOMCTL_vuart_op: +default : +return 0 ; + }
You are not implementing any of those domctl yet. So I think it would be better to print an error message (gprintk(XENLOG_ERR...) and return -ENOSYS.
Quoted 4 lines
xen/arch/riscv/domctl.c new file +4
-0+ +#define write_atomic (p, x) ({ \ + typeof(*p) __x = (x); \ + switch ( sizeof(*p) ) { \
xen/arch/riscv/domctl.c line 50
Quoted 10 lines
xen/arch/riscv/domctl.c new file +10
-0+case 1 :writeb ((uint8_t )__x, (uint8_t *) p);break ; \ +case 2 :writew ((uint16_t )__x, (uint16_t *) p);break ; \ +case 4 :writel ((uint32_t )__x, (uint32_t *) p);break ; \ +case 8 :writeq ((uint64_t )__x, (uint64_t *) p);break ; \ +default :__bad_atomic_size ();break ; \ + } \ + __x; \ +}) + +/* TODO: Fix this */
What's the problem?
xen/arch/riscv/domctl.c
Quoted 10 lines
xen/arch/riscv/domctl.c new file +10
-0+#define add_sized (p, x) ({ \ + typeof(*(p)) __x = (x); \ + switch ( sizeof(*(p)) ) \ + { \ + case 1: writeb(read_atomic(p) + __x, (uint8_t *)(p)); break; \ + case 2: writew(read_atomic(p) + __x, (uint16_t *)(p)); break; \ + case 4: writel(read_atomic(p) + __x, (uint32_t *)(p)); break; \ + default: __bad_atomic_size(); break; \ + } \ +})
Cheers,
Signature · 1 line
Julien Grall
RFC PATCH 2/6 xen/riscv: Add early page table setup code.
In reply to Xie XunThis code sets up initial page table.
--- xen/arch/riscv/mm.c | 224 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 224 insertions(+)
xen/arch/riscv/mm.c +224 -0
@@ -81,6 +81,17 @@ unsigned long xenheap_base_pdx __read_mostly;unsigned long frametable_virt_end__read_mostly ;unsigned long frametable_base_pdx; +/* +* xen_second_pagetable is indexed with the VPN[2] page table entry field +* xen_first_pagetable is accessed from the VPN[1] page table entry field +* xen_zeroeth_pagetable is accessed from the VPN[0] page table entry field +*/ +pte_t xen_second_pagetable[PAGE_ENTRIES] __attribute__((__aligned__(4096))); +static pte_t xen_first_pagetable[PAGE_ENTRIES] + __attribute__((__aligned__(4096))); +static pte_t xen_zeroeth_pagetable[PAGE_ENTRIES] + __attribute__((__aligned__(4096))); + static pte_t xen_fixmap[PAGE_ENTRIES] __attribute__((__aligned__(4096)));#define THIS_CPU_PGTABLE xen_second_pagetable
@@ -374,6 +385,219 @@ unsigned long get_upper_mfn_bound(void)return max_page -1 ; } +/* Set up leaf pages in a first-level page table. */ +void setup_megapages (pte_t *first_pagetable,unsigned long virtual_start, +unsigned long physical_start,unsigned long page_cnt) +{ +unsigned long frame_addr = physical_start; +unsigned long end = physical_start + (page_cnt <<PAGE_SHIFT ); +unsigned long vaddr = virtual_start; +unsigned long index; +pte_t *p; + +BUG_ON (!IS_ALIGNED (physical_start,FIRST_SIZE )); + +while ( frame_addr < end ) + { + index =pagetable_first_index (vaddr); + p = &first_pagetable[index]; + p->pte =paddr_to_megapage_ppn (frame_addr); + p->pte |=PTE_LEAF_DEFAULT ; + + frame_addr +=FIRST_SIZE ; + vaddr +=FIRST_SIZE ; + } +} + +#define resolve_early_addr (x) \ + ({ \ + unsigned long * __##x; \ + if ( load_addr_start <= x && x < load_addr_end ) \ + __##x = (unsigned long *)x; \ + else \ + __##x = (unsigned long *)(x + load_addr_start - linker_addr_start); \ + __##x; \ + }) + +void __init clear_pagetables (unsigned long load_addr_start, +unsigned long load_addr_end, +unsigned long linker_addr_start, +unsigned long linker_addr_end) +{ +unsigned long *p; +unsigned long page; +unsigned long i; + + page = (unsigned long )&xen_second_pagetable[0 ]; + + p =resolve_early_addr (page); +for ( i =0 ; i <ARRAY_SIZE (xen_second_pagetable); i++ ) + { + p[i] =0ULL ; + } + + page = (unsigned long )&xen_first_pagetable[0 ]; + p =resolve_early_addr (page); +for ( i =0 ; i <ARRAY_SIZE (xen_first_pagetable); i++ ) + { + p[i] =0ULL ; + } + + page = (unsigned long )&xen_zeroeth_pagetable[0 ]; + p =resolve_early_addr (page); +for ( i =0 ; i <ARRAY_SIZE (xen_zeroeth_pagetable); i++ ) + { + p[i] =0ULL ; + } +} + +void __attribute__((section (".entry" ))) +setup_initial_pagetables (pte_t *second,pte_t *first,pte_t *zeroeth, +unsigned long map_start,unsigned long map_end, +unsigned long pa_start) +{ +unsigned long page_addr; +unsigned long index2; +unsigned long index1; +unsigned long index0; + +/* align start addresses */ + map_start &=ZEROETH_MAP_MASK ; + pa_start &=ZEROETH_MAP_MASK ; + + page_addr = map_start; +while ( page_addr < map_end ) + { + index2 =pagetable_second_index (page_addr); + index1 =pagetable_first_index (page_addr); + index0 =pagetable_zeroeth_index (page_addr); + +/* Setup level2 table */ + second[index2] =paddr_to_pte ((unsigned long )first); + second[index2].pte |=PTE_TABLE ; + +/* Setup level1 table */ + first[index1] =paddr_to_pte ((unsigned long )zeroeth); + first[index1].pte |=PTE_TABLE ; + +/* Setup level0 table */ +if ( !pte_is_valid (&zeroeth[index0]) ) + { +/* Update level0 table */ + zeroeth[index0] =paddr_to_pte ((page_addr - map_start) + pa_start); + zeroeth[index0].pte |=PTE_LEAF_DEFAULT ; + } + +/* Point to next page */ + page_addr +=ZEROETH_SIZE ; + } +} + +/* +* WARNING: load_addr() and linker_addr() are to be called only when the MMU is +* disabled and only when executed by the primary CPU. They cannot refer to +* any global variable or functions. +*/ + +/* +* Convert an addressed layed out at link time to the address where it was loaded +* by the bootloader. +*/ +#define load_addr (linker_address) \ + ({ \ + unsigned long __linker_address = (unsigned long)(linker_address); \ + if ( linker_addr_start <= __linker_address && \ + __linker_address < linker_addr_end ) \ + { \ + __linker_address = \ + __linker_address - linker_addr_start + load_addr_start; \ + } \ + __linker_address; \ + }) + +/* Convert boot-time Xen address from where it was loaded by the boot loader to the address it was layed out +* at link-time. +*/ +#define linker_addr (load_address) \ + ({ \ + unsigned long __load_address = (unsigned long)(load_address); \ + if ( load_addr_start <= __load_address && \ + __load_address < load_addr_end ) \ + { \ + __load_address = \ + __load_address - load_addr_start + linker_addr_start; \ + } \ + __load_address; \ + }) + +/* +* _setup_initial_pagetables: +* +* 1) Build the page tables for Xen that map the following: +* 1.1) The physical location of Xen (where the bootloader loaded it) +* 1.2) The link-time location of Xen (where the linker expected Xen's +* addresses to be) +* 2) Load the page table into the SATP and enable the MMU +*/ +void __attribute__((section (".entry" ))) +_setup_initial_pagetables (unsigned long load_addr_start, +unsigned long load_addr_end, +unsigned long linker_addr_start, +unsigned long linker_addr_end) +{ +pte_t *second; +pte_t *first; +pte_t *zeroeth; + +clear_pagetables (load_addr_start, load_addr_end, + linker_addr_start, linker_addr_end); + +/* Get the addresses where the page tables were loaded */ + second = (pte_t *)load_addr (&xen_second_pagetable); + first = (pte_t *)load_addr (&xen_first_pagetable); + zeroeth = (pte_t *)load_addr (&xen_zeroeth_pagetable); + +/* +* Create a mapping of the load time address range to... the load time address range. +* This mapping is used at boot time only. +*/ +setup_initial_pagetables (second, first, zeroeth, load_addr_start, + load_addr_end, load_addr_start); + +/* +* Create a mapping from Xen's link-time addresses to where they were actually loaded. +* +* TODO: Protect regions accordingly (e.g., protect text and rodata from writes). +*/ +setup_initial_pagetables (second, first, zeroeth,linker_addr (&_text_start), +linker_addr (&_text_end),load_addr (&_text_start)); +setup_initial_pagetables (second, first, zeroeth,linker_addr (&_init_start), +linker_addr (&_init_end),load_addr (&_init_start)); +setup_initial_pagetables (second, first, zeroeth, +linker_addr (&_cpuinit_start), +linker_addr (&_cpuinit_end), +load_addr (&_cpuinit_start)); +setup_initial_pagetables (second, first, zeroeth, +linker_addr (&_spinlock_start), +linker_addr (&_spinlock_end), +load_addr (&_spinlock_start)); +setup_initial_pagetables (second, first, zeroeth, +linker_addr (&_rodata_start), +linker_addr (&_rodata_end), +load_addr (&_rodata_start)); +setup_initial_pagetables (second, first, zeroeth, linker_addr_start, + linker_addr_end, load_addr_start); + +/* Ensure page table writes precede loading the SATP */ + asmvolatile ("sfence.vma" ); + +/* Enable the MMU and load the new pagetable for Xen */ +csr_write (CSR_SATP , + (load_addr (xen_second_pagetable) >>PAGE_SHIFT ) |SATP_MODE_SV39 <<SATP_MODE_SHIFT ); + + phys_offset = load_addr_start - linker_addr_start; +} +/* * Map the table that pte points to. */
Signature · 1 line
2.30.2
RFC PATCH 3/6 xen/riscv: Add head.S
In reply to Xie Xunhead.S initializes bss, calls _setup_initial_pagetables to set up initial page tables, switch from load address to virtual address, and jump to C entry start_xen.
--- xen/arch/riscv/riscv64/head.S | 206 ++++++++++++++++++++++++++++++++++ 1 file changed, 206 insertions(+)
xen/arch/riscv/riscv64/head.S +206 -0
@@ -7,7 +7,213 @@ .section .text.header, "ax", %progbits ENTRY(start) + /* Mask all interrupts */ + csrw CSR_SIE, zero + + /* + * Disable FPU to detect illegal usage of + * floating point in kernel space + */ + li t0, SSTATUS_FS + csrc CSR_SSTATUS, t0 + + /* Save HART ID and DTB base */ + lla a6, _bootcpu_reg0 + REG_S a0, (a6) + lla a6, _bootcpu_reg1 + REG_S a1, (a6) + + /* + * Select CPU 0, hang the rest. + * TODO: support SMP + */ + lla a3, hart_lottery + li a2, 1 + amoadd.w a3, a2, (a3) + bnez a3, _start_hang + +_save_load_addresses: + /* Save load addresses + * a2 -> load start + * a3 -> load end + * a4 -> execution start + * a5 -> execution end + */ + lla a2, _start + lla a6, __exec_start + REG_L a4, (a6) + lla a6, __exec_end + REG_L a5, (a6) + sub a6, a5, a4 + add a3, a2, a6 + lla a6, _load_start + REG_S a2, (a6) + lla a6, _load_end + REG_S a3, (a6) + lla a6, _end + REG_S a3, (a6) + +_bss_zero_start: + /* Zero-out bss section */ + lla a6, __bss_start + REG_L a0, (a6) + sub a0, a0, a4 + add a0, a0, a2 + lla a6, __bss_end + REG_L a1, (a6) + sub a1, a1, a4 + add a1, a1, a2 +_bss_zero_loop: + REG_S zero, (a0) + add a0, a0, __SIZEOF_POINTER__ + blt a0, a1, _bss_zero_loop + + /* Setup temporary stack */ + lla a6, __hvc_stack_end + REG_L a0, (a6) + sub a0, a0, a4 + add sp, a0, a2 + + /* Setup hang for IRQ vector w/ virtual address */ + lla a6, __debug_irq_vector + REG_L a4, (a6) + csrw CSR_STVEC, a4 + + /* Setup initial page table */ + lla a6, _load_start + REG_L a0, (a6) + lla a6, _load_end + REG_L a1, (a6) + lla a6, __exec_start + REG_L a2, (a6) + lla a6, __exec_end + REG_L a3, (a6) + call _setup_initial_pagetables + + lla a0, _bootcpu_reg0 + REG_L a0, (a0) + +/* a0 must equal the hartid */ +_set_xen_tp: + /* Load pcpu_info[NR_CPUS] address */ + lla a6, pcpu_info + + /* Adjust by phys_offset so it doesn't require the identity map */ + lla a7, phys_offset + REG_L a7, (a7) + sub a6, a6, a7 + + /* Index into pcpu_info array with hartid */ + li a7, PCPUINFO_sizeof + mul a7, a7, a0 + add a6, a6, a7 + + /* Set tp = &pcpu_info[hartid] */ + add tp, a6, zero + + /* set processor id of pcpu_info[hartid].processor_id */ + REG_S a0, RISCV_PCPUINFO_OFFSET(processor_id)(tp) + + /* Move stack pointer */ + lla t0, phys_offset + REG_L t0, (t0) + sub sp, sp, t0 + + + j _start_secondary_nopen + + .align 3 +_start_lottery: + RISCV_PTR 0 + .align 3 +__start_secondary_pen_release: + RISCV_PTR start_secondary_pen_release + + /* + * Note: From this point primary CPU startup is same as secondary CPU + */ +_start_secondary_nopen: + /* Set trap vector to spin forever to help debug */ + //lla a6, _start_hang + //csrw CSR_STVEC, a6 + + /* Jump to final execution address */ + lla a6, __cpu_init + REG_L a0, (a6) + jalr a0 + + .align 4 _start_hang: wfi j _start_hang + + .align 3 +__phys_offset: + RISCV_PTR phys_offset +__pgtbl_root: + RISCV_PTR xen_second_pagetable +__exec_start: + RISCV_PTR _code_start +__exec_end: + RISCV_PTR _code_end +__bss_start: + RISCV_PTR _bss_start +__bss_end: + RISCV_PTR _bss_end +__debug_irq_vector: + RISCV_PTR _start_hang +__cpu_init: + RISCV_PTR _cpu_init + + /* + * Boot register 0 passed by bootloader + */ + .globl _bootcpu_reg0 +_bootcpu_reg0: + RISCV_PTR 0x0 + + /* + * Boot register 1 passed by bootloader + */ + .globl _boot_reg1 +_bootcpu_reg1: + RISCV_PTR 0x0 + + /* + * Load start address storage + */ + .globl _load_start +_load_start: + RISCV_PTR 0x0 + + /* + * Load end address storage + */ + .globl _load_end +_load_end: + RISCV_PTR 0x0 + + .globl _end +_end: + RISCV_PTR 0x0 + + /* + * Exception stacks. + */ +__hvc_stack_end: + RISCV_PTR _hvc_stack_end + + .align 3 + .globl _cpu_init +_cpu_init: + /* Jump to C code */ + lla a6, _bootcpu_reg1 + REG_L a0, (a6) + lla a6, phys_offset + REG_L a1, (a6) + + call start_xen + + /* Hang !!! */ + j _start_hang ENDPROC(start)
Signature · 1 line
2.30.2
RFC PATCH 4/6 xen/riscv: Add sbi.c, sbi.h
In reply to Xie Xun--- xen/arch/riscv/Makefile | 1 + xen/arch/riscv/include/asm/sbi.h | 275 ++++++++++++++++++ xen/arch/riscv/sbi.c | 483 +++++++++++++++++++++++++++++++ 3 files changed, 759 insertions(+) create mode 100644 xen/arch/riscv/include/asm/sbi.h create mode 100644 xen/arch/riscv/sbi.c
xen/arch/riscv/Makefile +1 -0
@@ -8,6 +8,7 @@ obj-y += irq.o obj-y += p2m.o obj-y += mm.o obj-y += percpu.o +obj-y += sbi.o obj-y += setup.o obj-y += shutdown.o obj-y += smp.o
xen/arch/riscv/include/asm/sbi.h new file +275 -0
275 lines not on this page · raw message
xen/arch/riscv/sbi.c new file +483 -0
483 lines not on this page · raw message
Signature · 1 line
2.30.2
Re: [RFC PATCH 4/6] xen/riscv: Add sbi.c, sbi.h
Quoted 1 line · Xie Xun
Signed-off-by Xie Xun <[email protected]>
Is this correct / complete, considering ....
xen/arch/riscv/include/asm/sbi.h line 4
Quoted 7 lines
xen/arch/riscv/include/asm/sbi.h new file +4
-0@@ -0,0 +1,275 @@ +/** +* Copyright (c) 2021 Vates SAS. +* +* Taken from xvisor, modified by Bobby Eshleman ([email protected]).
... this?
Jan
Re: [RFC PATCH 4/6] xen/riscv: Add sbi.c, sbi.h
Hi Jan,
Quoted 5 lines · Jan Beulich
Quoted 1 line · Xie Xun
Signed-off-by Xie Xun <[email protected]>Is this correct / complete, considering ....
Thank you for pointing out this problem.
I have read the submitting guide
https://wiki.xenproject.org/wiki/Submitting_Xen_Project_Patches#Signed-off-by
and it says that signed-off-by indicates I certify the patch under the "Developer's
Certificate of Origins".
And in the "Developer's Certificate of Origins":
(b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or
Because Xvisor is also distributed under GPL, i think it will be correct if it is
signed-off-by Bobby. The problem is that I did not modify this part of the code, so I want to know how to submit this patch in a correct way?
Thank you for replying.
Quoted 13 lines
xen/arch/riscv/include/asm/sbi.h line 4
Quoted 8 lines
xen/arch/riscv/include/asm/sbi.h new file +4
-0@@ -0,0 +1,275 @@ +/** +* Copyright (c) 2021 Vates SAS. +* +* Taken from xvisor, modified by Bobby Eshleman ([email protected]). ... this?
Jan
Re: [RFC PATCH 4/6] xen/riscv: Add sbi.c, sbi.h
Quoted 23 lines · Xie Xun
Quoted 4 lines · Jan Beulich
Quoted 1 line · Xie Xun
Signed-off-by Xie Xun <[email protected]>Is this correct / complete, considering ....
Thank you for pointing out this problem.
I have read the submitting guide
https://wiki.xenproject.org/wiki/Submitting_Xen_Project_Patches#Signed-off-byand it says that signed-off-by indicates I certify the patch under the "Developer's
Certificate of Origins".
And in the "Developer's Certificate of Origins":
(b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or
Quoted 4 lines
Because Xvisor is also distributed under GPL, i think it will be correct if it is
signed-off-by Bobby. The problem is that I did not modify this part of the code, so I want to know how to submit this patch in a correct way?
If you didn't alter this patch at all (or just minimally), then I guess first of all you want to set From: to Bob. Whether he has given his S-o-b of the code I don't know; hence my earlier question. If so, having his first and then yours is quite usual an arrangement.
Jan
RFC PATCH 5/6 xen/riscv: Add early_printk
In reply to Xie Xun--- xen/arch/riscv/Makefile | 1 + xen/arch/riscv/early_printk.c | 48 +++++++++++++++++++++++ xen/arch/riscv/include/asm/early_printk.h | 10 +++++ 3 files changed, 59 insertions(+) create mode 100644 xen/arch/riscv/early_printk.c create mode 100644 xen/arch/riscv/include/asm/early_printk.h
xen/arch/riscv/Makefile +1 -0
@@ -3,6 +3,7 @@ obj-y += lib/ obj-y += domctl.o obj-y += domain.o obj-y += delay.o +obj-y += early_printk.o obj-y += guestcopy.o obj-y += irq.o obj-y += p2m.o
xen/arch/riscv/early_printk.c new file +48 -0
48 lines not on this page · raw message
xen/arch/riscv/include/asm/early_printk.h new file +10 -0
@@ -0,0 +1,10 @@ +#ifndef __EARLY_PRINTK_H__ +#define __EARLY_PRINTK_H__ + +#include <xen/string.h> + +#define early_puts (s) _early_puts((s), strlen((s))) +void _early_puts (const char *s,size_t nr); +void early_printk (const char *fmt, ...); + +#endif /* __EARLY_PRINTK_H__ */
Signature · 1 line
2.30.2
Re: [RFC PATCH 5/6] xen/riscv: Add early_printk
xen/arch/riscv/early_printk.c
Quoted 27 lines · Xie Xun
Signed-off-by Xie Xun <[email protected]>--- xen/arch/riscv/Makefile | 1 + xen/arch/riscv/early_printk.c | 48 +++++++++++++++++++++++ xen/arch/riscv/include/asm/early_printk.h | 10 +++++ 3 files changed, 59 insertions(+) create mode 100644 xen/arch/riscv/early_printk.c create mode 100644 xen/arch/riscv/include/asm/early_printk.hxen/arch/riscv/Makefile +1
-0@@ -3,6 +3,7 @@ obj-y += lib/ obj-y += domctl.o obj-y += domain.o obj-y += delay.o +obj-y += early_printk.o obj-y += guestcopy.o obj-y += irq.o obj-y += p2m.oxen/arch/riscv/early_printk.c new file +0
-0
This should be named differently. This file should be called sbi_console_early_printk.c to better indicate that it's using the sbi_console
The SBI print functions are useful, but they have been marked as deprecated with no future replacement (see
https://github.com/riscv-non-isa/riscv-sbi-doc/blob/659950dc57f9840cf8242c1cff138c2ee67634bb/riscv-sbi.adoc#5-legacy-extensions-eids-0x00---0x0f)
For the initial port I think it's ok to use these, but this isn't a long term solution, we should aim to migrate to using the standard hardware UART.
I'm sure Xen already has a driver for the ns16550 UART so it might be worth just using that directly and not worrying with the sbi_console.
Alistair
Quoted 69 lines
xen/arch/riscv/early_printk.c new file +48
-0@@ -0,0 +1,48 @@ +/* +* RISC-V early printk using SBI +* +* Copyright (C) 2021 Bobby Eshleman <[email protected]> +*/ +#include <asm/sbi.h> +#include <asm/early_printk.h> +#include <xen/stdarg.h> +#include <xen/lib.h> + +void _early_puts (const char *s,size_t nr) +{ +while ( nr-- >0 ) + { +if (*s =='\n' ) +sbi_console_putchar ('\r' ); +sbi_console_putchar (*s); + s++; + } +} + +static void vprintk_early (const char *prefix,const char *fmt,va_list args) +{ +char buf[128 ]; +int sz; + +early_puts (prefix); + + sz =vscnprintf (buf,sizeof (buf), fmt, args); + +if ( sz <0 ) { +early_puts ("(XEN) vprintk_early error\n" ); +return ; + } + +if ( sz ==0 ) +return ; + +_early_puts (buf, sz); +} + +void early_printk (const char *fmt, ...) +{ +va_list args; +va_start (args, fmt); +vprintk_early ("(XEN) " , fmt, args); +va_end (args); +}xen/arch/riscv/include/asm/early_printk.h new file +10
-1@@ -0,0 +1,10 @@ +#ifndef __EARLY_PRINTK_H__ +#define __EARLY_PRINTK_H__ + +#include <xen/string.h> + +#define early_puts (s) _early_puts((s), strlen((s))) +void _early_puts (const char *s,size_t nr); +void early_printk (const char *fmt, ...); + +#endif /* __EARLY_PRINTK_H__ */ --2.30.2
Re: [RFC PATCH 5/6] xen/riscv: Add early_printk
Quoted 7 lines · Alistair Francis
xen/arch/riscv/early_printk.c
Quoted 2 lines · Xie Xun
xen/arch/riscv/early_printk.c new file +0
-0This should be named differently. This file should be called
sbi_console_early_printk.cto better indicate that it's using thesbi_console
To not go overboard with file name length, perhaps sbi-earlyprintk.c or sbi-early-printk.c would suffice? Or, if other variants are to appear, *-sbi.c?
Quoted 10 lines
The SBI print functions are useful, but they have been marked as deprecated with no future replacement (see
https://github.com/riscv-non-isa/riscv-sbi-doc/blob/659950dc57f9840cf8242c1cff138c2ee67634bb/riscv-sbi.adoc#5-legacy-extensions-eids-0x00---0x0f)For the initial port I think it's ok to use these, but this isn't a long term solution, we should aim to migrate to using the standard hardware UART.
I'm sure Xen already has a driver for the ns16550 UART so it might be worth just using that directly and not worrying with the
sbi_console.
Of course we have a driver for that, but depending on the device flavors in use on RISC-V it may require touching.
Jan
RFC PATCH 6/6 xen/riscv: Print "xen start" in start_xen using early_printk.
In reply to Xie Xun--- xen/arch/riscv/setup.c | 2 ++ 1 file changed, 2 insertions(+)
xen/arch/riscv/setup.c +2 -0
@@ -22,6 +22,7 @@#include <xen/lib.h> #include <xen/init.h> +#include <asm/early_printk.h> #include <asm/atomic.h> #include <public/version.h>
@@ -54,6 +55,7 @@ void arch_get_xen_caps(xen_capabilities_info_t *info)*/ void __init start_xen (paddr_t fdt_paddr,paddr_t boot_phys_offset) { +early_printk ("xen start\n" ); }/* * Local variables:
Signature · 1 line
2.30.2