Minimal build for RISCV
v2 cover Minimal build for RISCV
Hi all,
This series introduces a minimal build for RISCV. It is based on Bobby's previous work from last year[0]. I have worked to rebase onto current Xen, as well as update the various header files borrowed from Linux.
This series provides the patches necessary to get a minimal build working. The build is "minimal" in the sense that 1) it uses a minimal config and 2) files, functions, and variables are included if and only if they are required for a successful build based on the config. It doesn't run at all, as the functions just have stub implementations.
My hope is that this can serve as a useful example for future ports as well as inform the community of exactly what is imposed by common code onto new architectures.
The first 3 patches are mods to non-RISCV bits that enable building a config with:
!CONFIG_HAS_NS16550
!CONFIG_HAS_PASSTHROUGH
!CONFIG_GRANT_TABLE
respectively. The fourth patch adds the RISCV files, and the last patch adds a docker container for doing the build. To build from the docker container (after creating it locally), you can run the following:
$ make XEN_TARGET_ARCH=riscv64 SUBSYSTEMS=xen
The sources taken from Linux are documented in arch/riscv/README.sources. There were also some files copied from arm:
asm-arm/softirq.h
asm-arm/random.h
asm-arm/nospec.h
asm-arm/numa.h
asm-arm/p2m.h
asm-arm/delay.h
asm-arm/debugger.h
asm-arm/desc.h
asm-arm/guest_access.h
asm-arm/hardirq.h
lib/find_next_bit.c
I imagine some of these will want some consolidation, but I put them under the respective RISCV directories for now.
[0] https://lore.kernel.org/xen-devel/[email protected]/
Thanks,
Connor
--
Changes since v1:
- Dropped "xen/sched: Fix build when NR_CPUS == 1" since this was
fixed for 4.15
- Moved #ifdef-ary around iommu_enabled to iommu.h
- Moved struct grant_table declaration above ifdef CONFIG_GRANT_TABLE instead of defining an empty struct when !CONFIG_GRANT_TABLE
Connor Davis (5):
xen/char: Default HAS_NS16550 to y only for X86 and ARM xen/common: Guard iommu symbols with CONFIG_HAS_PASSTHROUGH
xen: Fix build when !CONFIG_GRANT_TABLE
xen: Add files needed for minimal riscv build
automation: add container for riscv64 builds
automation/build/archlinux/riscv64.dockerfile | 33 ++ automation/scripts/containerize | 1 + config/riscv64.mk | 7 + xen/Makefile | 8 +- xen/arch/riscv/Kconfig | 54 +++ xen/arch/riscv/Kconfig.debug | 0 xen/arch/riscv/Makefile | 57 +++ xen/arch/riscv/README.source | 19 + xen/arch/riscv/Rules.mk | 13 + xen/arch/riscv/arch.mk | 7 + xen/arch/riscv/configs/riscv64_defconfig | 12 + xen/arch/riscv/delay.c | 16 + xen/arch/riscv/domain.c | 144 +++++++ xen/arch/riscv/domctl.c | 36 ++ xen/arch/riscv/guestcopy.c | 57 +++ xen/arch/riscv/head.S | 6 + xen/arch/riscv/irq.c | 78 ++++ xen/arch/riscv/lib/Makefile | 1 + xen/arch/riscv/lib/find_next_bit.c | 284 +++++++++++++ xen/arch/riscv/mm.c | 93 +++++ xen/arch/riscv/p2m.c | 144 +++++++ xen/arch/riscv/percpu.c | 17 + xen/arch/riscv/platforms/Kconfig | 31 ++ xen/arch/riscv/riscv64/asm-offsets.c | 31 ++ xen/arch/riscv/setup.c | 27 ++ xen/arch/riscv/shutdown.c | 28 ++ xen/arch/riscv/smp.c | 35 ++ xen/arch/riscv/smpboot.c | 34 ++ xen/arch/riscv/sysctl.c | 33 ++ xen/arch/riscv/time.c | 35 ++ xen/arch/riscv/traps.c | 35 ++ xen/arch/riscv/vm_event.c | 39 ++ xen/arch/riscv/xen.lds.S | 113 ++++++ xen/common/memory.c | 10 + xen/drivers/char/Kconfig | 2 +- xen/include/asm-riscv/altp2m.h | 39 ++ xen/include/asm-riscv/asm.h | 77 ++++ xen/include/asm-riscv/asm_defns.h | 24 ++ xen/include/asm-riscv/atomic.h | 204 ++++++++++ xen/include/asm-riscv/bitops.h | 331 +++++++++++++++ xen/include/asm-riscv/bug.h | 54 +++ xen/include/asm-riscv/byteorder.h | 16 + xen/include/asm-riscv/cache.h | 24 ++ xen/include/asm-riscv/cmpxchg.h | 382 ++++++++++++++++++ xen/include/asm-riscv/compiler_types.h | 32 ++ xen/include/asm-riscv/config.h | 110 +++++ xen/include/asm-riscv/cpufeature.h | 17 + xen/include/asm-riscv/csr.h | 219 ++++++++++ xen/include/asm-riscv/current.h | 47 +++ xen/include/asm-riscv/debugger.h | 15 + xen/include/asm-riscv/delay.h | 17 + xen/include/asm-riscv/desc.h | 12 + xen/include/asm-riscv/device.h | 15 + xen/include/asm-riscv/div64.h | 23 ++ xen/include/asm-riscv/domain.h | 50 +++ xen/include/asm-riscv/event.h | 42 ++ xen/include/asm-riscv/fence.h | 12 + xen/include/asm-riscv/flushtlb.h | 34 ++ xen/include/asm-riscv/grant_table.h | 12 + xen/include/asm-riscv/guest_access.h | 41 ++ xen/include/asm-riscv/guest_atomics.h | 60 +++ xen/include/asm-riscv/hardirq.h | 27 ++ xen/include/asm-riscv/hypercall.h | 12 + xen/include/asm-riscv/init.h | 42 ++ xen/include/asm-riscv/io.h | 283 +++++++++++++ xen/include/asm-riscv/iocap.h | 13 + xen/include/asm-riscv/iommu.h | 46 +++ xen/include/asm-riscv/irq.h | 58 +++ xen/include/asm-riscv/mem_access.h | 4 + xen/include/asm-riscv/mm.h | 246 +++++++++++ xen/include/asm-riscv/monitor.h | 65 +++ xen/include/asm-riscv/nospec.h | 25 ++ xen/include/asm-riscv/numa.h | 41 ++ xen/include/asm-riscv/p2m.h | 218 ++++++++++ xen/include/asm-riscv/page-bits.h | 11 + xen/include/asm-riscv/page.h | 73 ++++ xen/include/asm-riscv/paging.h | 15 + xen/include/asm-riscv/pci.h | 31 ++ xen/include/asm-riscv/percpu.h | 33 ++ xen/include/asm-riscv/processor.h | 59 +++ xen/include/asm-riscv/random.h | 9 + xen/include/asm-riscv/regs.h | 23 ++ xen/include/asm-riscv/setup.h | 14 + xen/include/asm-riscv/smp.h | 46 +++ xen/include/asm-riscv/softirq.h | 16 + xen/include/asm-riscv/spinlock.h | 12 + xen/include/asm-riscv/string.h | 28 ++ xen/include/asm-riscv/sysregs.h | 16 + xen/include/asm-riscv/system.h | 99 +++++ xen/include/asm-riscv/time.h | 31 ++ xen/include/asm-riscv/trace.h | 12 + xen/include/asm-riscv/types.h | 60 +++ xen/include/asm-riscv/vm_event.h | 60 +++ xen/include/asm-riscv/xenoprof.h | 12 + xen/include/public/arch-riscv.h | 134 ++++++ xen/include/public/arch-riscv/hvm/save.h | 39 ++ xen/include/public/hvm/save.h | 2 + xen/include/public/pmu.h | 2 + xen/include/public/xen.h | 2 + xen/include/xen/domain.h | 1 + xen/include/xen/grant_table.h | 3 +- xen/include/xen/iommu.h | 8 +- 102 files changed, 5375 insertions(+), 5 deletions(-) create mode 100644 automation/build/archlinux/riscv64.dockerfile create mode 100644 config/riscv64.mk create mode 100644 xen/arch/riscv/Kconfig create mode 100644 xen/arch/riscv/Kconfig.debug create mode 100644 xen/arch/riscv/Makefile create mode 100644 xen/arch/riscv/README.source create mode 100644 xen/arch/riscv/Rules.mk create mode 100644 xen/arch/riscv/arch.mk create mode 100644 xen/arch/riscv/configs/riscv64_defconfig 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/head.S 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/riscv64/asm-offsets.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/asm-riscv/altp2m.h create mode 100644 xen/include/asm-riscv/asm.h create mode 100644 xen/include/asm-riscv/asm_defns.h create mode 100644 xen/include/asm-riscv/atomic.h create mode 100644 xen/include/asm-riscv/bitops.h create mode 100644 xen/include/asm-riscv/bug.h create mode 100644 xen/include/asm-riscv/byteorder.h create mode 100644 xen/include/asm-riscv/cache.h create mode 100644 xen/include/asm-riscv/cmpxchg.h create mode 100644 xen/include/asm-riscv/compiler_types.h create mode 100644 xen/include/asm-riscv/config.h create mode 100644 xen/include/asm-riscv/cpufeature.h create mode 100644 xen/include/asm-riscv/csr.h create mode 100644 xen/include/asm-riscv/current.h create mode 100644 xen/include/asm-riscv/debugger.h create mode 100644 xen/include/asm-riscv/delay.h create mode 100644 xen/include/asm-riscv/desc.h create mode 100644 xen/include/asm-riscv/device.h create mode 100644 xen/include/asm-riscv/div64.h create mode 100644 xen/include/asm-riscv/domain.h create mode 100644 xen/include/asm-riscv/event.h create mode 100644 xen/include/asm-riscv/fence.h create mode 100644 xen/include/asm-riscv/flushtlb.h create mode 100644 xen/include/asm-riscv/grant_table.h create mode 100644 xen/include/asm-riscv/guest_access.h create mode 100644 xen/include/asm-riscv/guest_atomics.h create mode 100644 xen/include/asm-riscv/hardirq.h create mode 100644 xen/include/asm-riscv/hypercall.h create mode 100644 xen/include/asm-riscv/init.h create mode 100644 xen/include/asm-riscv/io.h create mode 100644 xen/include/asm-riscv/iocap.h create mode 100644 xen/include/asm-riscv/iommu.h create mode 100644 xen/include/asm-riscv/irq.h create mode 100644 xen/include/asm-riscv/mem_access.h create mode 100644 xen/include/asm-riscv/mm.h create mode 100644 xen/include/asm-riscv/monitor.h create mode 100644 xen/include/asm-riscv/nospec.h create mode 100644 xen/include/asm-riscv/numa.h create mode 100644 xen/include/asm-riscv/p2m.h create mode 100644 xen/include/asm-riscv/page-bits.h create mode 100644 xen/include/asm-riscv/page.h create mode 100644 xen/include/asm-riscv/paging.h create mode 100644 xen/include/asm-riscv/pci.h create mode 100644 xen/include/asm-riscv/percpu.h create mode 100644 xen/include/asm-riscv/processor.h create mode 100644 xen/include/asm-riscv/random.h create mode 100644 xen/include/asm-riscv/regs.h create mode 100644 xen/include/asm-riscv/setup.h create mode 100644 xen/include/asm-riscv/smp.h create mode 100644 xen/include/asm-riscv/softirq.h create mode 100644 xen/include/asm-riscv/spinlock.h create mode 100644 xen/include/asm-riscv/string.h create mode 100644 xen/include/asm-riscv/sysregs.h create mode 100644 xen/include/asm-riscv/system.h create mode 100644 xen/include/asm-riscv/time.h create mode 100644 xen/include/asm-riscv/trace.h create mode 100644 xen/include/asm-riscv/types.h create mode 100644 xen/include/asm-riscv/vm_event.h create mode 100644 xen/include/asm-riscv/xenoprof.h create mode 100644 xen/include/public/arch-riscv.h create mode 100644 xen/include/public/arch-riscv/hvm/save.h
Signature · 1 line
2.31.1
PATCH v2 1/5 xen/char: Default HAS_NS16550 to y only for X86 and ARM
Defaulting to yes only for X86 and ARM reduces the requirements for a minimal build when porting new architectures.
--- xen/drivers/char/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/drivers/char/Kconfig +1 -1
@@ -1,6 +1,6 @@ config HAS_NS16550 bool "NS16550 UART driver" if ARM - default y + default y if (ARM || X86) help This selects the 16550-series UART support. For most systems, say Y.
Signature · 1 line
2.31.1
Re: [PATCH v2 1/5] xen/char: Default HAS_NS16550 to y only for X86 and ARM
Quoted 13 lines · Connor Davis
Defaulting to yes only for X86 and ARM reduces the requirements for a minimal build when porting new architectures.
Signed-off-by Connor Davis <[email protected]>--- xen/drivers/char/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)xen/drivers/char/Kconfig +0
-0
xen/drivers/char/Kconfig line 5
Quoted 6 lines
xen/drivers/char/Kconfig +1
-1@@ -1,6 +1,6 @@ config HAS_NS16550 bool "NS16550 UART driver" if ARM - default y + default y if (ARM || X86) help This selects the 16550-series UART support. For most systems, say Y.
Are you sure this is necessary? I've been working on something else recently, but did you confirm this with a full build?
If you observe the line directly above that one, _if_ARM_. I'm pretty sure this driver will refuse to show up in a RISC-V build.
Signature · 4 lines
(\___(\___(\______ --=> 8-) EHM <=-- ______/)___/)___/) \BS ( | [email protected] PGP 87145445 | ) / \_CS\ | _____ -O #include <stddisclaimer.h> O- _____ | / _/ 8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445
Re: [PATCH v2 1/5] xen/char: Default HAS_NS16550 to y only for X86 and ARM
Quoted 23 lines · Elliott Mitchell
Quoted 13 lines · Connor Davis
Defaulting to yes only for X86 and ARM reduces the requirements for a minimal build when porting new architectures.
Signed-off-by Connor Davis <[email protected]>--- xen/drivers/char/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)xen/drivers/char/Kconfig +0
-0xen/drivers/char/Kconfig line 5
Quoted 6 lines
xen/drivers/char/Kconfig +1
-1@@ -1,6 +1,6 @@ config HAS_NS16550 bool "NS16550 UART driver" if ARM - default y + default y if (ARM || X86) help This selects the 16550-series UART support. For most systems, say Y.Are you sure this is necessary? I've been working on something else recently, but did you confirm this with a full build?
Quoted 3 lines
If you observe the line directly above that one,
_if_ARM_. I'm pretty sure this driver will refuse to show up in a RISC-V build.
It isn't visible in Kconfig, true, but it will still be built because of
the unconditional "default y"
Thanks,
Connor
PATCH v2 2/5 xen/common: Guard iommu symbols with CONFIG_HAS_PASSTHROUGH
In reply to Connor DavisThe variables iommu_enabled and iommu_dont_flush_iotlb are defined in drivers/passthrough/iommu.c and are referenced in common code, which causes the link to fail when !CONFIG_HAS_PASSTHROUGH.
Guard references to these variables in common code so that xen builds when !CONFIG_HAS_PASSTHROUGH.
--- xen/common/memory.c | 10 ++++++++++ xen/include/xen/iommu.h | 8 +++++++- 2 files changed, 17 insertions(+), 1 deletion(-)
xen/common/memory.c +10 -0
@@ -294,7 +294,9 @@ int guest_remove_page(struct domain *d, unsigned long gmfn)p2m_type_t p2mt;#endif mfn_t mfn; +#ifdef CONFIG_HAS_PASSTHROUGH bool *dont_flush_p, dont_flush; +#endif int rc;#ifdef CONFIG_X86
@@ -385,13 +387,17 @@ int guest_remove_page(struct domain *d, unsigned long gmfn)* Since we're likely to free the page below, we need to suspend * xenmem_add_to_physmap()'s suppressing of IOMMU TLB flushes. */ +#ifdef CONFIG_HAS_PASSTHROUGH dont_flush_p = &this_cpu (iommu_dont_flush_iotlb); dont_flush = *dont_flush_p; *dont_flush_p = false; +#endif rc =guest_physmap_remove_page (d,_gfn (gmfn), mfn,0 ); +#ifdef CONFIG_HAS_PASSTHROUGH *dont_flush_p = dont_flush; +#endif /* * With the lack of an IOMMU on some platforms, domains with DMA-capable
@@ -839,11 +845,13 @@ int xenmem_add_to_physmap(struct domain *d, struct xen_add_to_physmap *xatp, xatp->gpfn += start; xatp->size -= start; +#ifdef CONFIG_HAS_PASSTHROUGH if (is_iommu_enabled (d) ) {this_cpu (iommu_dont_flush_iotlb) =1 ; extra.ppage = &pages[0 ]; } +#endif while ( xatp->size > done ) {
@@ -868,6 +876,7 @@ int xenmem_add_to_physmap(struct domain *d, struct xen_add_to_physmap *xatp, } } +#ifdef CONFIG_HAS_PASSTHROUGH if (is_iommu_enabled (d) ) {int ret;
@@ -894,6 +903,7 @@ int xenmem_add_to_physmap(struct domain *d, struct xen_add_to_physmap *xatp,if (unlikely (ret) && rc >=0 ) rc = ret; } +#endif return rc; }
xen/include/xen/iommu.h +7 -1
@@ -51,9 +51,15 @@ static inline bool_t dfn_eq(dfn_t x, dfn_t y)return dfn_x (x) ==dfn_x (y); } -extern bool_t iommu_enable, iommu_enabled; +extern bool_t iommu_enable;extern bool force_iommu, iommu_quarantine, iommu_verbose; +#ifdef CONFIG_HAS_PASSTHROUGH +extern bool_t iommu_enabled; +#else +#define iommu_enabled false +#endif +#ifdef CONFIG_X86 extern enum __packed iommu_intremap {/*
Signature · 1 line
2.31.1
PATCH v2 3/5 xen: Fix build when !CONFIG_GRANT_TABLE
In reply to Connor DavisMove struct grant_table; in grant_table.h above ifdef CONFIG_GRANT_TABLE. This fixes the following:
/build/xen/include/xen/grant_table.h:84:50: error: 'struct grant_table' declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
84 | static inline int mem_sharing_gref_to_gfn(struct grant_table *gt,
|
--- xen/include/xen/grant_table.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
xen/include/xen/grant_table.h +2 -1
@@ -28,9 +28,10 @@#include <public/grant_table.h> #include <asm/grant_table.h> -#ifdef CONFIG_GRANT_TABLE struct grant_table ; +#ifdef CONFIG_GRANT_TABLE +extern unsigned int opt_max_grant_frames;/* Create/destroy per-domain grant table context. */
Signature · 1 line
2.31.1
PATCH v2 4/5 xen: Add files needed for minimal riscv build
In reply to Connor DavisAdd the minimum code required to get xen to build with XEN_TARGET_ARCH=riscv64. It is minimal in the sense that every file and function added is required for a successful build, given the .config generated from riscv64_defconfig. The function implementations are just stubs; actual implmentations will need to be added later.
--- config/riscv64.mk | 7 + xen/Makefile | 8 +- xen/arch/riscv/Kconfig | 54 ++++ xen/arch/riscv/Kconfig.debug | 0 xen/arch/riscv/Makefile | 57 ++++ xen/arch/riscv/README.source | 19 ++ xen/arch/riscv/Rules.mk | 13 + xen/arch/riscv/arch.mk | 7 + xen/arch/riscv/configs/riscv64_defconfig | 12 + xen/arch/riscv/delay.c | 16 + xen/arch/riscv/domain.c | 144 +++++++++ xen/arch/riscv/domctl.c | 36 +++ xen/arch/riscv/guestcopy.c | 57 ++++ xen/arch/riscv/head.S | 6 + xen/arch/riscv/irq.c | 78 +++++ xen/arch/riscv/lib/Makefile | 1 + xen/arch/riscv/lib/find_next_bit.c | 284 +++++++++++++++++ xen/arch/riscv/mm.c | 93 ++++++ xen/arch/riscv/p2m.c | 144 +++++++++ xen/arch/riscv/percpu.c | 17 + xen/arch/riscv/platforms/Kconfig | 31 ++ xen/arch/riscv/riscv64/asm-offsets.c | 31 ++ xen/arch/riscv/setup.c | 27 ++ xen/arch/riscv/shutdown.c | 28 ++ xen/arch/riscv/smp.c | 35 +++ xen/arch/riscv/smpboot.c | 34 ++ xen/arch/riscv/sysctl.c | 33 ++ xen/arch/riscv/time.c | 35 +++ xen/arch/riscv/traps.c | 35 +++ xen/arch/riscv/vm_event.c | 39 +++ xen/arch/riscv/xen.lds.S | 113 +++++++ xen/include/asm-riscv/altp2m.h | 39 +++ xen/include/asm-riscv/asm.h | 77 +++++ xen/include/asm-riscv/asm_defns.h | 24 ++ xen/include/asm-riscv/atomic.h | 204 ++++++++++++ xen/include/asm-riscv/bitops.h | 331 ++++++++++++++++++++ xen/include/asm-riscv/bug.h | 54 ++++ xen/include/asm-riscv/byteorder.h | 16 + xen/include/asm-riscv/cache.h | 24 ++ xen/include/asm-riscv/cmpxchg.h | 382 +++++++++++++++++++++++ xen/include/asm-riscv/compiler_types.h | 32 ++ xen/include/asm-riscv/config.h | 110 +++++++ xen/include/asm-riscv/cpufeature.h | 17 + xen/include/asm-riscv/csr.h | 219 +++++++++++++ xen/include/asm-riscv/current.h | 47 +++ xen/include/asm-riscv/debugger.h | 15 + xen/include/asm-riscv/delay.h | 17 + xen/include/asm-riscv/desc.h | 12 + xen/include/asm-riscv/device.h | 15 + xen/include/asm-riscv/div64.h | 23 ++ xen/include/asm-riscv/domain.h | 50 +++ xen/include/asm-riscv/event.h | 42 +++ xen/include/asm-riscv/fence.h | 12 + xen/include/asm-riscv/flushtlb.h | 34 ++ xen/include/asm-riscv/grant_table.h | 12 + xen/include/asm-riscv/guest_access.h | 41 +++ xen/include/asm-riscv/guest_atomics.h | 60 ++++ xen/include/asm-riscv/hardirq.h | 27 ++ xen/include/asm-riscv/hypercall.h | 12 + xen/include/asm-riscv/init.h | 42 +++ xen/include/asm-riscv/io.h | 283 +++++++++++++++++ xen/include/asm-riscv/iocap.h | 13 + xen/include/asm-riscv/iommu.h | 46 +++ xen/include/asm-riscv/irq.h | 58 ++++ xen/include/asm-riscv/mem_access.h | 4 + xen/include/asm-riscv/mm.h | 246 +++++++++++++++ xen/include/asm-riscv/monitor.h | 65 ++++ xen/include/asm-riscv/nospec.h | 25 ++ xen/include/asm-riscv/numa.h | 41 +++ xen/include/asm-riscv/p2m.h | 218 +++++++++++++ xen/include/asm-riscv/page-bits.h | 11 + xen/include/asm-riscv/page.h | 73 +++++ xen/include/asm-riscv/paging.h | 15 + xen/include/asm-riscv/pci.h | 31 ++ xen/include/asm-riscv/percpu.h | 33 ++ xen/include/asm-riscv/processor.h | 59 ++++ xen/include/asm-riscv/random.h | 9 + xen/include/asm-riscv/regs.h | 23 ++ xen/include/asm-riscv/setup.h | 14 + xen/include/asm-riscv/smp.h | 46 +++ xen/include/asm-riscv/softirq.h | 16 + xen/include/asm-riscv/spinlock.h | 12 + xen/include/asm-riscv/string.h | 28 ++ xen/include/asm-riscv/sysregs.h | 16 + xen/include/asm-riscv/system.h | 99 ++++++ xen/include/asm-riscv/time.h | 31 ++ xen/include/asm-riscv/trace.h | 12 + xen/include/asm-riscv/types.h | 60 ++++ xen/include/asm-riscv/vm_event.h | 60 ++++ xen/include/asm-riscv/xenoprof.h | 12 + xen/include/public/arch-riscv.h | 134 ++++++++ xen/include/public/arch-riscv/hvm/save.h | 39 +++ xen/include/public/hvm/save.h | 2 + xen/include/public/pmu.h | 2 + xen/include/public/xen.h | 2 + xen/include/xen/domain.h | 1 + 96 files changed, 5321 insertions(+), 2 deletions(-) create mode 100644 config/riscv64.mk create mode 100644 xen/arch/riscv/Kconfig create mode 100644 xen/arch/riscv/Kconfig.debug create mode 100644 xen/arch/riscv/Makefile create mode 100644 xen/arch/riscv/README.source create mode 100644 xen/arch/riscv/Rules.mk create mode 100644 xen/arch/riscv/arch.mk create mode 100644 xen/arch/riscv/configs/riscv64_defconfig 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/head.S 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/riscv64/asm-offsets.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/asm-riscv/altp2m.h create mode 100644 xen/include/asm-riscv/asm.h create mode 100644 xen/include/asm-riscv/asm_defns.h create mode 100644 xen/include/asm-riscv/atomic.h create mode 100644 xen/include/asm-riscv/bitops.h create mode 100644 xen/include/asm-riscv/bug.h create mode 100644 xen/include/asm-riscv/byteorder.h create mode 100644 xen/include/asm-riscv/cache.h create mode 100644 xen/include/asm-riscv/cmpxchg.h create mode 100644 xen/include/asm-riscv/compiler_types.h create mode 100644 xen/include/asm-riscv/config.h create mode 100644 xen/include/asm-riscv/cpufeature.h create mode 100644 xen/include/asm-riscv/csr.h create mode 100644 xen/include/asm-riscv/current.h create mode 100644 xen/include/asm-riscv/debugger.h create mode 100644 xen/include/asm-riscv/delay.h create mode 100644 xen/include/asm-riscv/desc.h create mode 100644 xen/include/asm-riscv/device.h create mode 100644 xen/include/asm-riscv/div64.h create mode 100644 xen/include/asm-riscv/domain.h create mode 100644 xen/include/asm-riscv/event.h create mode 100644 xen/include/asm-riscv/fence.h create mode 100644 xen/include/asm-riscv/flushtlb.h create mode 100644 xen/include/asm-riscv/grant_table.h create mode 100644 xen/include/asm-riscv/guest_access.h create mode 100644 xen/include/asm-riscv/guest_atomics.h create mode 100644 xen/include/asm-riscv/hardirq.h create mode 100644 xen/include/asm-riscv/hypercall.h create mode 100644 xen/include/asm-riscv/init.h create mode 100644 xen/include/asm-riscv/io.h create mode 100644 xen/include/asm-riscv/iocap.h create mode 100644 xen/include/asm-riscv/iommu.h create mode 100644 xen/include/asm-riscv/irq.h create mode 100644 xen/include/asm-riscv/mem_access.h create mode 100644 xen/include/asm-riscv/mm.h create mode 100644 xen/include/asm-riscv/monitor.h create mode 100644 xen/include/asm-riscv/nospec.h create mode 100644 xen/include/asm-riscv/numa.h create mode 100644 xen/include/asm-riscv/p2m.h create mode 100644 xen/include/asm-riscv/page-bits.h create mode 100644 xen/include/asm-riscv/page.h create mode 100644 xen/include/asm-riscv/paging.h create mode 100644 xen/include/asm-riscv/pci.h create mode 100644 xen/include/asm-riscv/percpu.h create mode 100644 xen/include/asm-riscv/processor.h create mode 100644 xen/include/asm-riscv/random.h create mode 100644 xen/include/asm-riscv/regs.h create mode 100644 xen/include/asm-riscv/setup.h create mode 100644 xen/include/asm-riscv/smp.h create mode 100644 xen/include/asm-riscv/softirq.h create mode 100644 xen/include/asm-riscv/spinlock.h create mode 100644 xen/include/asm-riscv/string.h create mode 100644 xen/include/asm-riscv/sysregs.h create mode 100644 xen/include/asm-riscv/system.h create mode 100644 xen/include/asm-riscv/time.h create mode 100644 xen/include/asm-riscv/trace.h create mode 100644 xen/include/asm-riscv/types.h create mode 100644 xen/include/asm-riscv/vm_event.h create mode 100644 xen/include/asm-riscv/xenoprof.h create mode 100644 xen/include/public/arch-riscv.h create mode 100644 xen/include/public/arch-riscv/hvm/save.h
config/riscv64.mk new file +7 -0
@@ -0,0 +1,7 @@ +CONFIG_RISCV := y +CONFIG_RISCV_64 := y +CONFIG_RISCV_$(XEN_OS) := y + +CONFIG_XEN_INSTALL_SUFFIX := + +CFLAGS +=
xen/Makefile +6 -2
@@ -26,7 +26,9 @@ MAKEFLAGS += -rR EFI_MOUNTPOINT ?= $(BOOT_DIR)/efi ARCH=$(XEN_TARGET_ARCH) -SRCARCH=$(shell echo $(ARCH) | sed -e 's/x86.*/x86/' -e s'/arm\(32\|64\)/arm/g') +SRCARCH=$(shell echo $(ARCH) | \ + sed -e 's/x86.*/x86/' -e s'/arm\(32\|64\)/arm/g' \ + -e s'/riscv.*/riscv/g') # Don't break if the build process wasn't called from the top level # we need XEN_TARGET_ARCH to generate the proper config
@@ -35,7 +37,8 @@ include $(XEN_ROOT)/Config.mk # Set ARCH/SUBARCH appropriately. export TARGET_SUBARCH := $(XEN_TARGET_ARCH) export TARGET_ARCH := $(shell echo $(XEN_TARGET_ARCH) | \ - sed -e 's/x86.*/x86/' -e s'/arm\(32\|64\)/arm/g') + sed -e 's/x86.*/x86/' -e s'/arm\(32\|64\)/arm/g' \ + -e s'/riscv.*/riscv/g') # Allow someone to change their config file export KCONFIG_CONFIG ?= .config
@@ -335,6 +338,7 @@ _clean: delete-unfresh-files $(MAKE) $(clean) xsm $(MAKE) $(clean) crypto $(MAKE) $(clean) arch/arm + $(MAKE) $(clean) arch/riscv $(MAKE) $(clean) arch/x86 $(MAKE) $(clean) test $(MAKE) -f $(BASEDIR)/tools/kconfig/Makefile.kconfig ARCH=$(ARCH) SRCARCH=$(SRCARCH) clean
xen/arch/riscv/Kconfig new file +54 -0
54 lines not on this page · raw message
xen/arch/riscv/Kconfig.debug new file +0 -0
xen/arch/riscv/Makefile new file +57 -0
57 lines not on this page · raw message
xen/arch/riscv/README.source new file +19 -0
@@ -0,0 +1,19 @@ +External RISCV Sources +====================== +This documents the files copied from other projects for use in the +RISCV code of Xen. + +Linux (commit f40ddce88593, Feb. 14 2021) +========================================= +The following files were copied from arch/riscv/include/asm to +xen/include/asm-riscv: + +asm.h -> asm.h +atomic.h -> atomic.h +bitops.h -> bitops.h +csr.h -> csr.h +{mmio,io}.h -> io.h +fence.h -> fence.h +cmpxchg.h -> cmpxchg.h +compiler_types.h -> compiler_types.h +timex.h -> time.h
xen/arch/riscv/Rules.mk new file +13 -0
@@ -0,0 +1,13 @@ +######################################## +# RISCV-specific definitions + +ifeq ($(CONFIG_RISCV_64),y) + c_flags += -mabi=lp64 + a_flags += -mabi=lp64 +endif + +riscv-march-$(CONFIG_RISCV_ISA_RV64IMA) := rv64ima +riscv-march-$(CONFIG_RISCV_ISA_C) := $(riscv-march-y)c + +c_flags += -march=$(riscv-march-y) -mstrict-align -mcmodel=medany +a_flags += -march=$(riscv-march-y) -mstrict-align -mcmodel=medany
xen/arch/riscv/arch.mk new file +7 -0
@@ -0,0 +1,7 @@ +######################################## +# riscv-specific definitions + +CFLAGS += -I$(BASEDIR)/include + +$(call cc-options-add,CFLAGS,CC,$(EMBEDDED_EXTRA_CFLAGS)) +$(call cc-option-add,CFLAGS,CC,-Wnested-externs)
xen/arch/riscv/configs/riscv64_defconfig new file +12 -0
@@ -0,0 +1,12 @@ +# CONFIG_SCHED_CREDIT is not set +# CONFIG_SCHED_RTDS is not set +# CONFIG_SCHED_NULL is not set +# CONFIG_SCHED_ARINC653 is not set +# CONFIG_TRACEBUFFER is not set +# CONFIG_DEBUG is not set +# CONFIG_DEBUG_INFO is not set +# CONFIG_HYPFS is not set +# CONFIG_GRANT_TABLE is not set +# CONFIG_SPECULATIVE_HARDEN_ARRAY is not set + +CONFIG_EXPERT=y
xen/arch/riscv/delay.c new file +16 -0
@@ -0,0 +1,16 @@ +/* +* 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 of the License, 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. +*/ + +void udelay (unsigned long usecs) +{ +} +EXPORT_SYMBOL (udelay);
xen/arch/riscv/domain.c new file +144 -0
144 lines not on this page · raw message
xen/arch/riscv/domctl.c new file +36 -0
@@ -0,0 +1,36 @@ +/****************************************************************************** +* Arch-specific domctl.c +* +* Copyright (c) 2012, Citrix Systems +*/ + +#include <xen/errno.h> +#include <xen/guest_access.h> +#include <xen/hypercall.h> +#include <xen/sched.h> +#include <public/domctl.h> + +void arch_get_domain_info (const struct domain *d, +struct xen_domctl_getdomaininfo *info) +{ +} + +long arch_do_domctl (struct xen_domctl *domctl,struct domain *d, +XEN_GUEST_HANDLE_PARAM (xen_domctl_t) u_domctl) +{ +return -EOPNOTSUPP ; +} + +void arch_get_info_guest (struct vcpu *v,vcpu_guest_context_u c) +{ +} + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* tab-width: 4 +* indent-tabs-mode: nil +* End: +*/
xen/arch/riscv/guestcopy.c new file +57 -0
57 lines not on this page · raw message
xen/arch/riscv/head.S new file +6 -0
@@ -0,0 +1,6 @@ +#include <asm/config.h> + + .text + +ENTRY(start) + j start
xen/arch/riscv/irq.c new file +78 -0
78 lines not on this page · raw message
xen/arch/riscv/lib/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-y += find_next_bit.o
xen/arch/riscv/lib/find_next_bit.c new file +284 -0
284 lines not on this page · raw message
xen/arch/riscv/mm.c new file +93 -0
93 lines not on this page · raw message
xen/arch/riscv/p2m.c new file +144 -0
144 lines not on this page · raw message
xen/arch/riscv/percpu.c new file +17 -0
@@ -0,0 +1,17 @@ +/* +* 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 of the License, 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. +*/ + +#include <xen/percpu.h> +#include <xen/cpu.h> +#include <xen/init.h> + +unsigned long __per_cpu_offset[NR_CPUS ];
xen/arch/riscv/platforms/Kconfig new file +31 -0
@@ -0,0 +1,31 @@ +choice + prompt "Platform Support" + default ALL_PLAT + ---help--- + Choose which hardware platform to enable in Xen. + + If unsure, choose ALL_PLAT. + +config ALL_PLAT + bool "All Platforms" + ---help--- + Enable support for all available hardware platforms. It doesn't + automatically select any of the related drivers. + +config QEMU + bool "QEMU RISC-V virt machine support" + depends on RISCV + select HAS_NS16550 + ---help--- + Enable all the required drivers for QEMU RISC-V virt emulated + machine. + +endchoice + +config ALL64_PLAT + bool + default (ALL_PLAT && RISCV_64) + +config ALL32_PLAT + bool + default (ALL_PLAT && RISCV_32)
xen/arch/riscv/riscv64/asm-offsets.c new file +31 -0
@@ -0,0 +1,31 @@ +/* +* Copyright (C) 2012 Regents of the University of California +* Copyright (C) 2017 SiFive +* +* 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. +*/ + +#define COMPILE_OFFSETS + +#include <asm/init.h> + +#define DEFINE(_sym, _val) \ + asm volatile ("\n.ascii\"==>#define " #_sym " %0 /* " #_val " */<==\"" \ + : : "i" (_val) ) +#define BLANK () \ + asm volatile ( "\n.ascii\"==><==\"" : : ) +#define OFFSET (_sym, _str, _mem) \ + DEFINE(_sym, offsetof(_str, _mem)); + +void asm_offsets (void ) +{ +BLANK (); + OFFSET(INITINFO_stack, struct init_info, stack); +}
xen/arch/riscv/setup.c new file +27 -0
@@ -0,0 +1,27 @@ +/* +* 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 of the License, 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. +*/ + +#include <xen/types.h> +#include <public/version.h> + +void arch_get_xen_caps (xen_capabilities_info_t *info) +{ +} + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
xen/arch/riscv/shutdown.c new file +28 -0
@@ -0,0 +1,28 @@ +/* +* 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 of the License, 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. +*/ + +void machine_halt (void ) +{ +} + +void machine_restart (unsigned int delay_millisecs) +{ +} + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
xen/arch/riscv/smp.c new file +35 -0
@@ -0,0 +1,35 @@ +/* +* 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 of the License, 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. +*/ + +#include <xen/cpumask.h> +#include <asm/smp.h> + +void arch_flush_tlb_mask (const cpumask_t *mask) +{ +} + +void smp_send_event_check_mask (const cpumask_t *mask) +{ +} + +void smp_send_call_function_mask (const cpumask_t *mask) +{ +} + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
xen/arch/riscv/smpboot.c new file +34 -0
@@ -0,0 +1,34 @@ +/* +* Dummy smpboot support +* +* 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 of the License, 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. +*/ +#include <xen/cpu.h> +#include <xen/cpumask.h> +#include <xen/errno.h> +#include <xen/init.h> +#include <xen/sched.h> +#include <xen/smp.h> +#include <xen/nodemask.h> + +cpumask_t cpu_online_map; +cpumask_t cpu_present_map; +cpumask_t cpu_possible_map; + +DEFINE_PER_CPU(unsigned int, cpu_id); +DEFINE_PER_CPU_READ_MOSTLY (cpumask_var_t, cpu_sibling_mask); +DEFINE_PER_CPU_READ_MOSTLY (cpumask_var_t, cpu_core_mask); + +/* Fake one node for now. See also include/asm-arm/numa.h */ +nodemask_t __read_mostly node_online_map = { { [0 ] =1UL } }; + +/* Boot cpu data */ +struct init_info init_data = {};
xen/arch/riscv/sysctl.c new file +33 -0
@@ -0,0 +1,33 @@ +/****************************************************************************** +* Arch-specific sysctl.c +* +* System management operations. For use by node control stack. +* +* Copyright (c) 2012, Citrix Systems +*/ + +#include <xen/types.h> +#include <xen/lib.h> +#include <xen/errno.h> +#include <xen/hypercall.h> +#include <public/sysctl.h> + +void arch_do_physinfo (struct xen_sysctl_physinfo *pi) +{ +} + +long arch_do_sysctl (struct xen_sysctl *sysctl, +XEN_GUEST_HANDLE_PARAM (xen_sysctl_t) u_sysctl) +{ +return -EOPNOTSUPP ; +} + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* tab-width: 4 +* indent-tabs-mode: nil +* End: +*/
xen/arch/riscv/time.c new file +35 -0
@@ -0,0 +1,35 @@ +/* +* 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 of the License, 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. +*/ + +#include <xen/sched.h> +#include <xen/time.h> + +unsigned long __read_mostly cpu_khz;/* CPU clock frequency in kHz. */ + +s_time_t get_s_time (void ) +{ +return 0 ; +} + +/* VCPU PV timers. */ +void send_timer_event (struct vcpu *v) +{ +} + +void domain_set_time_offset (struct domain *d,int64_t time_offset_seconds) +{ +} + +int reprogram_timer (s_time_t timeout) +{ +return 0 ; +}
xen/arch/riscv/traps.c new file +35 -0
@@ -0,0 +1,35 @@ +/* +* RISC-V Trap handlers +* +* 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 of the License, 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. +*/ + +#include <public/xen.h> +#include <xen/multicall.h> +#include <xen/sched.h> +#include <asm/processor.h> + +void show_execution_state (const struct cpu_user_regs *regs) +{ +} + +void vcpu_show_execution_state (struct vcpu *v) +{ +} + +void arch_hypercall_tasklet_result (struct vcpu *v,long res) +{ +} + +enum mc_disposition arch_do_multicall_call (struct mc_state *state) +{ +return mc_continue; +}
xen/arch/riscv/vm_event.c new file +39 -0
@@ -0,0 +1,39 @@ +/* +* Architecture-specific vm_event handling routines +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public +* License v2 as published by the Free Software Foundation. +* +* 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 along with this program; If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <xen/sched.h> +#include <asm/vm_event.h> + +void vm_event_fill_regs (vm_event_request_t *req) +{ +} + +void vm_event_set_registers (struct vcpu *v,vm_event_response_t *rsp) +{ +} + +void vm_event_monitor_next_interrupt (struct vcpu *v) +{ +} + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
xen/arch/riscv/xen.lds.S new file +113 -0
113 lines not on this page · raw message
xen/include/asm-riscv/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/include/asm-riscv/asm.h new file +77 -0
77 lines not on this page · raw message
xen/include/asm-riscv/asm_defns.h new file +24 -0
@@ -0,0 +1,24 @@ +#ifndef __RISCV_ASM_DEFNS_H__ +#define __RISCV_ASM_DEFNS_H__ + +#ifndef COMPILE_OFFSETS +/* NB. Auto-generated from arch/.../asm-offsets.c */ +#include <asm/asm-offsets.h> +#endif +#include <asm/processor.h> + +#define ASM_INT (label, val) \ + .p2align 2; \ +label: .long (val); \ + .size label, . - label; \ + .type label, @object + +#endif /* __RISCV_ASM_DEFNS_H__ */ +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
xen/include/asm-riscv/atomic.h new file +204 -0
204 lines not on this page · raw message
xen/include/asm-riscv/bitops.h new file +331 -0
331 lines not on this page · raw message
xen/include/asm-riscv/bug.h new file +54 -0
54 lines not on this page · raw message
xen/include/asm-riscv/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/include/asm-riscv/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 +* Copyright (C) 2021 Connor Davis <[email protected]> +* +* 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 CONFIG_RISCV_L1_CACHE_SHIFT +#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT) + +#define __read_mostly __section(".data.read_mostly") + +#endif /* _ASM_RISCV_CACHE_H */
xen/include/asm-riscv/cmpxchg.h new file +382 -0
382 lines not on this page · raw message
xen/include/asm-riscv/compiler_types.h new file +32 -0
@@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __LINUX_COMPILER_TYPES_H +#define __LINUX_COMPILER_TYPES_H + +/* +* __unqual_scalar_typeof(x) - Declare an unqualified scalar type, leaving +* non-scalar types unchanged. +*/ +/* +* Prefer C11 _Generic for better compile-times and simpler code. Note: 'char' +* is not type-compatible with 'signed char', and we define a separate case. +*/ +#define __scalar_type_to_expr_cases (type) \ + unsigned type: (unsigned type)0, \ + signed type: (signed type)0 + +#define __unqual_scalar_typeof (x) typeof( \ + _Generic((x), \ + char: (char)0, \ + __scalar_type_to_expr_cases(char), \ + __scalar_type_to_expr_cases(short), \ + __scalar_type_to_expr_cases(int), \ + __scalar_type_to_expr_cases(long), \ + __scalar_type_to_expr_cases(long long), \ + default: (x))) + +/* Is this type a native word size -- useful for atomic operations */ +#define __native_word (t) \ + (sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || \ + sizeof(t) == sizeof(int) || sizeof(t) == sizeof(long)) + +#endif /* __LINUX_COMPILER_TYPES_H */
xen/include/asm-riscv/config.h new file +110 -0
110 lines not on this page · raw message
xen/include/asm-riscv/cpufeature.h new file +17 -0
@@ -0,0 +1,17 @@ +#ifndef __ASM_RISCV_CPUFEATURE_H +#define __ASM_RISCV_CPUFEATURE_H + +static inline int cpu_nr_siblings (unsigned int cpu) +{ +return 1 ; +} + +#endif +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
xen/include/asm-riscv/csr.h new file +219 -0
178 lines not on this page · raw message
xen/include/asm-riscv/current.h new file +47 -0
47 lines not on this page · raw message
xen/include/asm-riscv/debugger.h new file +15 -0
Lines of this file are not shown. View the raw message.
xen/include/asm-riscv/delay.h new file +17 -0
Lines of this file are not shown. View the raw message.
xen/include/asm-riscv/device.h new file +15 -0
Lines of this file are not shown. View the raw message.
xen/include/asm-riscv/div64.h new file +23 -0
Lines of this file are not shown. View the raw message.
xen/include/asm-riscv/domain.h new file +50 -0
50 lines not on this page · raw message
xen/include/asm-riscv/event.h new file +42 -0
42 lines not on this page · raw message
xen/include/asm-riscv/fence.h new file +12 -0
Lines of this file are not shown. View the raw message.
xen/include/asm-riscv/flushtlb.h new file +34 -0
Lines of this file are not shown. View the raw message.
xen/include/asm-riscv/grant_table.h new file +12 -0
Lines of this file are not shown. View the raw message.
xen/include/asm-riscv/guest_access.h new file +41 -0
41 lines not on this page · raw message
xen/include/asm-riscv/guest_atomics.h new file +60 -0
60 lines not on this page · raw message
xen/include/asm-riscv/hardirq.h new file +27 -0
Lines of this file are not shown. View the raw message.
xen/include/asm-riscv/hypercall.h new file +12 -0
Lines of this file are not shown. View the raw message.
xen/include/asm-riscv/init.h new file +42 -0
42 lines not on this page · raw message
xen/include/asm-riscv/io.h new file +283 -0
283 lines not on this page · raw message
xen/include/asm-riscv/iocap.h new file +13 -0
Lines of this file are not shown. View the raw message.
xen/include/asm-riscv/iommu.h new file +46 -0
46 lines not on this page · raw message
xen/include/asm-riscv/irq.h new file +58 -0
58 lines not on this page · raw message
xen/include/asm-riscv/mem_access.h new file +4 -0
Lines of this file are not shown. View the raw message.
xen/include/asm-riscv/mm.h new file +246 -0
246 lines not on this page · raw message
xen/include/asm-riscv/monitor.h new file +65 -0
65 lines not on this page · raw message
xen/include/asm-riscv/nospec.h new file +25 -0
Lines of this file are not shown. View the raw message.
xen/include/asm-riscv/numa.h new file +41 -0
41 lines not on this page · raw message
xen/include/asm-riscv/p2m.h new file +218 -0
218 lines not on this page · raw message
xen/include/asm-riscv/page-bits.h new file +11 -0
Lines of this file are not shown. View the raw message.
xen/include/asm-riscv/page.h new file +73 -0
73 lines not on this page · raw message
xen/include/asm-riscv/paging.h new file +15 -0
Lines of this file are not shown. View the raw message.
xen/include/asm-riscv/percpu.h new file +33 -0
Lines of this file are not shown. View the raw message.
xen/include/asm-riscv/processor.h new file +59 -0
59 lines not on this page · raw message
xen/include/asm-riscv/random.h new file +9 -0
Lines of this file are not shown. View the raw message.
xen/include/asm-riscv/setup.h new file +14 -0
Lines of this file are not shown. View the raw message.
xen/include/asm-riscv/smp.h new file +46 -0
46 lines not on this page · raw message
xen/include/asm-riscv/softirq.h new file +16 -0
Lines of this file are not shown. View the raw message.
xen/include/asm-riscv/spinlock.h new file +12 -0
Lines of this file are not shown. View the raw message.
xen/include/asm-riscv/string.h new file +28 -0
Lines of this file are not shown. View the raw message.
xen/include/asm-riscv/sysregs.h new file +16 -0
Lines of this file are not shown. View the raw message.
xen/include/asm-riscv/system.h new file +99 -0
99 lines not on this page · raw message
xen/include/asm-riscv/trace.h new file +12 -0
Lines of this file are not shown. View the raw message.
xen/include/asm-riscv/types.h new file +60 -0
60 lines not on this page · raw message
xen/include/asm-riscv/vm_event.h new file +60 -0
60 lines not on this page · raw message
xen/include/asm-riscv/xenoprof.h new file +12 -0
Lines of this file are not shown. View the raw message.
xen/include/public/arch-riscv.h new file +134 -0
134 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.31.1
Part of the diff is not shown here. View the raw message.
Re: [PATCH v2 4/5] xen: Add files needed for minimal riscv build
Hi Connor,
Quoted 5 lines · Connor Davis
Add the minimum code required to get xen to build with XEN_TARGET_ARCH=riscv64. It is minimal in the sense that every file and function added is required for a successful build, given the .config generated from
riscv64_defconfig. The function implementations are just stubs; actual implmentations will need to be added later.
Thank you for the contribution. This is quite a large patch to review. Could you consider to split in smaller one (I think Stefano suggested one per header file or group of headers)? This would help to review and find whether some bits can be moved in common.
I would be happy to help moving some of the pieces.
Quoted 12 lines
Signed-off-by Connor Davis <[email protected]>--- config/riscv64.mk | 7 + xen/Makefile | 8 +- xen/arch/riscv/Kconfig | 54 ++++ xen/arch/riscv/Kconfig.debug | 0 xen/arch/riscv/Makefile | 57 ++++ xen/arch/riscv/README.source | 19 ++ xen/arch/riscv/Rules.mk | 13 + xen/arch/riscv/arch.mk | 7 + xen/arch/riscv/configs/riscv64_defconfig | 12 +
Quoted 8 lines
xen/arch/riscv/delay.c | 16 + xen/arch/riscv/domain.c | 144 +++++++++ xen/arch/riscv/domctl.c | 36 +++ xen/arch/riscv/guestcopy.c | 57 ++++ xen/arch/riscv/head.S | 6 + xen/arch/riscv/irq.c | 78 +++++ xen/arch/riscv/lib/Makefile | 1 + xen/arch/riscv/lib/find_next_bit.c | 284 +++++++++++++++++
I quickly skimmed through the code and I think some of the file can be made common such as this one.
[...]
xen/include/xen/domain.h void arch_vcpu_destroy(struct vcpu *v); · line 63
Quoted 9 lines
xen/include/xen/domain.h +1
-0@@ -60,6 +60,7 @@ void arch_vcpu_destroy(struct vcpu *v);int map_vcpu_info (struct vcpu *v,unsigned long gfn,unsigned offset);void unmap_vcpu_info (struct vcpu *v); +struct xen_domctl_createdomain ;
This is needed because?
xen/include/xen/domain.h void arch_vcpu_destroy(struct vcpu *v); · line 66
Quoted 4 lines
xen/include/xen/domain.h +0
-0int arch_domain_create (struct domain *d,struct xen_domctl_createdomain *config);
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v2 4/5] xen: Add files needed for minimal riscv build
Quoted 11 lines · Julien Grall
Hi Connor,
Quoted 5 lines · Connor Davis
Add the minimum code required to get xen to build with XEN_TARGET_ARCH=riscv64. It is minimal in the sense that every file and function added is required for a successful build, given the .config generated from
riscv64_defconfig. The function implementations are just stubs; actual implmentations will need to be added later.Thank you for the contribution. This is quite a large patch to review. Could you consider to split in smaller one (I think Stefano suggested one per header file or group of headers)? This would help to review and find whether some bits can be moved in common.
Ok yes I will work on that.
Quoted 2 lines
I would be happy to help moving some of the pieces.
Great!
Quoted 21 lines
Quoted 12 lines
Signed-off-by Connor Davis <[email protected]>---
config/riscv64.mk | 7 + xen/Makefile | 8 +- xen/arch/riscv/Kconfig | 54 ++++ xen/arch/riscv/Kconfig.debug | 0 xen/arch/riscv/Makefile | 57 ++++ xen/arch/riscv/README.source | 19 ++ xen/arch/riscv/Rules.mk | 13 + xen/arch/riscv/arch.mk | 7 + xen/arch/riscv/configs/riscv64_defconfig | 12 +Quoted 8 lines
xen/arch/riscv/delay.c | 16 + xen/arch/riscv/domain.c | 144 +++++++++ xen/arch/riscv/domctl.c | 36 +++ xen/arch/riscv/guestcopy.c | 57 ++++ xen/arch/riscv/head.S | 6 + xen/arch/riscv/irq.c | 78 +++++ xen/arch/riscv/lib/Makefile | 1 + xen/arch/riscv/lib/find_next_bit.c | 284 +++++++++++++++++
Quoted 1 line
I quickly skimmed through the code and I think some of the file can be made common such as this one.
Yep there is quite a bit of overlap from ARM
Quoted 14 lines
[...]
xen/include/xen/domain.h void arch_vcpu_destroy(struct vcpu *v); · line 62
Quoted 8 lines
xen/include/xen/domain.h +0
-0@@ -60,6 +60,7 @@ void arch_vcpu_destroy(struct vcpu *v); int map_vcpu_info(struct vcpu *v, unsigned long gfn, unsigned offset); void unmap_vcpu_info(struct vcpu *v); +struct xen_domctl_createdomain;This is needed because?
The build was failing without it. With the one commit-per-file approach we can probably avoid this.
Thanks,
Connor
PATCH v2 5/5 automation: add container for riscv64 builds
In reply to Connor DavisAdd a container for cross-compiling xen to riscv64. This just includes the cross-compiler and necessary packages for building xen itself (packages for tools, stubdoms, etc., can be added later).
To build xen in the container run the following:
$ make XEN_TARGET_ARCH=riscv64 SUBSYSTEMS=xen
--- automation/build/archlinux/riscv64.dockerfile | 33 +++++++++++++++++++ automation/scripts/containerize | 1 + 2 files changed, 34 insertions(+) create mode 100644 automation/build/archlinux/riscv64.dockerfile
automation/build/archlinux/riscv64.dockerfile new file +33 -0
@@ -0,0 +1,33 @@ +FROM archlinux +LABEL maintainer.name="The Xen Project" \ + maintainer.email="[email protected]" + +# Packages needed for the build +RUN pacman --noconfirm --needed -Syu \ + base-devel \ + gcc \ + git + +# Packages needed for QEMU +RUN pacman --noconfirm --needed -Syu \ + pixman \ + python \ + sh + +# There is a regression in GDB that causes an assertion error +# when setting breakpoints, use this commit until it is fixed! +RUN git clone --recursive -j$(nproc) --progress https://github.com/riscv/riscv-gnu-toolchain && \ + cd riscv-gnu-toolchain/riscv-gdb && \ + git checkout 1dd588507782591478882a891f64945af9e2b86c && \ + cd .. && \ + ./configure --prefix=/opt/riscv && \ + make linux -j$(nproc) && \ + rm -R /riscv-gnu-toolchain + +# Add compiler path +ENV PATH=/opt/riscv/bin/:${PATH} +ENV CROSS_COMPILE=riscv64-unknown-linux-gnu- + +RUN useradd --create-home user +USER user +WORKDIR /build
automation/scripts/containerize +1 -0
@@ -26,6 +26,7 @@ BASE="registry.gitlab.com/xen-project/xen" case "_${CONTAINER}" in _alpine) CONTAINER="${BASE}/alpine:3.12" ;; _archlinux|_arch) CONTAINER="${BASE}/archlinux:current" ;; + _riscv64) CONTAINER="${BASE}/archlinux:riscv64" ;; _centos7) CONTAINER="${BASE}/centos:7" ;; _centos72) CONTAINER="${BASE}/centos:7.2" ;; _fedora) CONTAINER="${BASE}/fedora:29";;
Signature · 1 line
2.31.1
Quoted 46 lines · Connor Davis
Hi all,
This series introduces a minimal build for RISCV. It is based on Bobby's previous work from last year[0]. I have worked to rebase onto current Xen, as well as update the various header files borrowed from Linux.
This series provides the patches necessary to get a minimal build working. The build is "minimal" in the sense that 1) it uses a minimal config and 2) files, functions, and variables are included if and only if they are required for a successful build based on the config. It doesn't run at all, as the functions just have stub implementations.
My hope is that this can serve as a useful example for future ports as well as inform the community of exactly what is imposed by common code onto new architectures.
The first 3 patches are mods to non-RISCV bits that enable building a config with:
!CONFIG_HAS_NS16550
!CONFIG_HAS_PASSTHROUGH
!CONFIG_GRANT_TABLErespectively. The fourth patch adds the RISCV files, and the last patch adds a docker container for doing the build. To build from the docker container (after creating it locally), you can run the following:
$ make XEN_TARGET_ARCH=riscv64 SUBSYSTEMS=xenThe sources taken from Linux are documented in
arch/riscv/README.sources. There were also some files copied from arm:
asm-arm/softirq.h
asm-arm/random.h
asm-arm/nospec.h
asm-arm/numa.h
asm-arm/p2m.h
asm-arm/delay.h
asm-arm/debugger.h
asm-arm/desc.h
asm-arm/guest_access.h
asm-arm/hardirq.h
lib/find_next_bit.c
Quoted 2 lines
I imagine some of these will want some consolidation, but I put them under the respective RISCV directories for now.
Awesome!
Do you have a public branch I could pull these from to try out?
Alistair
Quoted 221 lines
[0] https://lore.kernel.org/xen-devel/[email protected]/
Thanks,
Connor--
Changes since v1:
- Dropped "xen/sched: Fix build whenNR_CPUS== 1" since this wasfixed for 4.15- Moved #ifdef-ary around
iommu_enabledtoiommu.h
- Moved structgrant_tabledeclaration above ifdefCONFIG_GRANT_TABLEinstead of defining an empty struct when !CONFIG_GRANT_TABLEConnor Davis (5):
xen/char: DefaultHAS_NS16550to y only for X86 and ARM xen/common: Guard iommu symbols withCONFIG_HAS_PASSTHROUGH
xen: Fix build when !CONFIG_GRANT_TABLE
xen: Add files needed for minimal riscv build
automation: add container for riscv64 buildsautomation/build/archlinux/riscv64.dockerfile | 33 ++ automation/scripts/containerize | 1 + config/riscv64.mk | 7 + xen/Makefile | 8 +- xen/arch/riscv/Kconfig | 54 +++ xen/arch/riscv/Kconfig.debug | 0 xen/arch/riscv/Makefile | 57 +++ xen/arch/riscv/README.source | 19 + xen/arch/riscv/Rules.mk | 13 + xen/arch/riscv/arch.mk | 7 + xen/arch/riscv/configs/riscv64_defconfig | 12 + xen/arch/riscv/delay.c | 16 + xen/arch/riscv/domain.c | 144 +++++++ xen/arch/riscv/domctl.c | 36 ++ xen/arch/riscv/guestcopy.c | 57 +++ xen/arch/riscv/head.S | 6 + xen/arch/riscv/irq.c | 78 ++++ xen/arch/riscv/lib/Makefile | 1 + xen/arch/riscv/lib/find_next_bit.c | 284 +++++++++++++ xen/arch/riscv/mm.c | 93 +++++ xen/arch/riscv/p2m.c | 144 +++++++ xen/arch/riscv/percpu.c | 17 + xen/arch/riscv/platforms/Kconfig | 31 ++ xen/arch/riscv/riscv64/asm-offsets.c | 31 ++ xen/arch/riscv/setup.c | 27 ++ xen/arch/riscv/shutdown.c | 28 ++ xen/arch/riscv/smp.c | 35 ++ xen/arch/riscv/smpboot.c | 34 ++ xen/arch/riscv/sysctl.c | 33 ++ xen/arch/riscv/time.c | 35 ++ xen/arch/riscv/traps.c | 35 ++ xen/arch/riscv/vm_event.c | 39 ++ xen/arch/riscv/xen.lds.S | 113 ++++++ xen/common/memory.c | 10 + xen/drivers/char/Kconfig | 2 +- xen/include/asm-riscv/altp2m.h | 39 ++ xen/include/asm-riscv/asm.h | 77 ++++ xen/include/asm-riscv/asm_defns.h | 24 ++ xen/include/asm-riscv/atomic.h | 204 ++++++++++ xen/include/asm-riscv/bitops.h | 331 +++++++++++++++ xen/include/asm-riscv/bug.h | 54 +++ xen/include/asm-riscv/byteorder.h | 16 + xen/include/asm-riscv/cache.h | 24 ++ xen/include/asm-riscv/cmpxchg.h | 382 ++++++++++++++++++ xen/include/asm-riscv/compiler_types.h | 32 ++ xen/include/asm-riscv/config.h | 110 +++++ xen/include/asm-riscv/cpufeature.h | 17 + xen/include/asm-riscv/csr.h | 219 ++++++++++ xen/include/asm-riscv/current.h | 47 +++ xen/include/asm-riscv/debugger.h | 15 + xen/include/asm-riscv/delay.h | 17 + xen/include/asm-riscv/desc.h | 12 + xen/include/asm-riscv/device.h | 15 + xen/include/asm-riscv/div64.h | 23 ++ xen/include/asm-riscv/domain.h | 50 +++ xen/include/asm-riscv/event.h | 42 ++ xen/include/asm-riscv/fence.h | 12 + xen/include/asm-riscv/flushtlb.h | 34 ++ xen/include/asm-riscv/grant_table.h | 12 + xen/include/asm-riscv/guest_access.h | 41 ++ xen/include/asm-riscv/guest_atomics.h | 60 +++ xen/include/asm-riscv/hardirq.h | 27 ++ xen/include/asm-riscv/hypercall.h | 12 + xen/include/asm-riscv/init.h | 42 ++ xen/include/asm-riscv/io.h | 283 +++++++++++++ xen/include/asm-riscv/iocap.h | 13 + xen/include/asm-riscv/iommu.h | 46 +++ xen/include/asm-riscv/irq.h | 58 +++ xen/include/asm-riscv/mem_access.h | 4 + xen/include/asm-riscv/mm.h | 246 +++++++++++ xen/include/asm-riscv/monitor.h | 65 +++ xen/include/asm-riscv/nospec.h | 25 ++ xen/include/asm-riscv/numa.h | 41 ++ xen/include/asm-riscv/p2m.h | 218 ++++++++++ xen/include/asm-riscv/page-bits.h | 11 + xen/include/asm-riscv/page.h | 73 ++++ xen/include/asm-riscv/paging.h | 15 + xen/include/asm-riscv/pci.h | 31 ++ xen/include/asm-riscv/percpu.h | 33 ++ xen/include/asm-riscv/processor.h | 59 +++ xen/include/asm-riscv/random.h | 9 + xen/include/asm-riscv/regs.h | 23 ++ xen/include/asm-riscv/setup.h | 14 + xen/include/asm-riscv/smp.h | 46 +++ xen/include/asm-riscv/softirq.h | 16 + xen/include/asm-riscv/spinlock.h | 12 + xen/include/asm-riscv/string.h | 28 ++ xen/include/asm-riscv/sysregs.h | 16 + xen/include/asm-riscv/system.h | 99 +++++ xen/include/asm-riscv/time.h | 31 ++ xen/include/asm-riscv/trace.h | 12 + xen/include/asm-riscv/types.h | 60 +++ xen/include/asm-riscv/vm_event.h | 60 +++ xen/include/asm-riscv/xenoprof.h | 12 + xen/include/public/arch-riscv.h | 134 ++++++ xen/include/public/arch-riscv/hvm/save.h | 39 ++ xen/include/public/hvm/save.h | 2 + xen/include/public/pmu.h | 2 + xen/include/public/xen.h | 2 + xen/include/xen/domain.h | 1 + xen/include/xen/grant_table.h | 3 +- xen/include/xen/iommu.h | 8 +- 102 files changed, 5375 insertions(+), 5 deletions(-) create mode 100644 automation/build/archlinux/riscv64.dockerfile create mode 100644 config/riscv64.mk create mode 100644 xen/arch/riscv/Kconfig create mode 100644 xen/arch/riscv/Kconfig.debug create mode 100644 xen/arch/riscv/Makefile create mode 100644 xen/arch/riscv/README.source create mode 100644 xen/arch/riscv/Rules.mk create mode 100644 xen/arch/riscv/arch.mk create mode 100644 xen/arch/riscv/configs/riscv64_defconfig 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/head.S 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/riscv64/asm-offsets.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/asm-riscv/altp2m.h create mode 100644 xen/include/asm-riscv/asm.h create mode 100644 xen/include/asm-riscv/asm_defns.h create mode 100644 xen/include/asm-riscv/atomic.h create mode 100644 xen/include/asm-riscv/bitops.h create mode 100644 xen/include/asm-riscv/bug.h create mode 100644 xen/include/asm-riscv/byteorder.h create mode 100644 xen/include/asm-riscv/cache.h create mode 100644 xen/include/asm-riscv/cmpxchg.h create mode 100644 xen/include/asm-riscv/compiler_types.h create mode 100644 xen/include/asm-riscv/config.h create mode 100644 xen/include/asm-riscv/cpufeature.h create mode 100644 xen/include/asm-riscv/csr.h create mode 100644 xen/include/asm-riscv/current.h create mode 100644 xen/include/asm-riscv/debugger.h create mode 100644 xen/include/asm-riscv/delay.h create mode 100644 xen/include/asm-riscv/desc.h create mode 100644 xen/include/asm-riscv/device.h create mode 100644 xen/include/asm-riscv/div64.h create mode 100644 xen/include/asm-riscv/domain.h create mode 100644 xen/include/asm-riscv/event.h create mode 100644 xen/include/asm-riscv/fence.h create mode 100644 xen/include/asm-riscv/flushtlb.h create mode 100644 xen/include/asm-riscv/grant_table.h create mode 100644 xen/include/asm-riscv/guest_access.h create mode 100644 xen/include/asm-riscv/guest_atomics.h create mode 100644 xen/include/asm-riscv/hardirq.h create mode 100644 xen/include/asm-riscv/hypercall.h create mode 100644 xen/include/asm-riscv/init.h create mode 100644 xen/include/asm-riscv/io.h create mode 100644 xen/include/asm-riscv/iocap.h create mode 100644 xen/include/asm-riscv/iommu.h create mode 100644 xen/include/asm-riscv/irq.h create mode 100644 xen/include/asm-riscv/mem_access.h create mode 100644 xen/include/asm-riscv/mm.h create mode 100644 xen/include/asm-riscv/monitor.h create mode 100644 xen/include/asm-riscv/nospec.h create mode 100644 xen/include/asm-riscv/numa.h create mode 100644 xen/include/asm-riscv/p2m.h create mode 100644 xen/include/asm-riscv/page-bits.h create mode 100644 xen/include/asm-riscv/page.h create mode 100644 xen/include/asm-riscv/paging.h create mode 100644 xen/include/asm-riscv/pci.h create mode 100644 xen/include/asm-riscv/percpu.h create mode 100644 xen/include/asm-riscv/processor.h create mode 100644 xen/include/asm-riscv/random.h create mode 100644 xen/include/asm-riscv/regs.h create mode 100644 xen/include/asm-riscv/setup.h create mode 100644 xen/include/asm-riscv/smp.h create mode 100644 xen/include/asm-riscv/softirq.h create mode 100644 xen/include/asm-riscv/spinlock.h create mode 100644 xen/include/asm-riscv/string.h create mode 100644 xen/include/asm-riscv/sysregs.h create mode 100644 xen/include/asm-riscv/system.h create mode 100644 xen/include/asm-riscv/time.h create mode 100644 xen/include/asm-riscv/trace.h create mode 100644 xen/include/asm-riscv/types.h create mode 100644 xen/include/asm-riscv/vm_event.h create mode 100644 xen/include/asm-riscv/xenoprof.h create mode 100644 xen/include/public/arch-riscv.h create mode 100644 xen/include/public/arch-riscv/hvm/save.h--
2.31.1
Quoted 46 lines · Alistair Francis
Quoted 45 lines · Connor Davis
Hi all,
This series introduces a minimal build for RISCV. It is based on Bobby's previous work from last year[0]. I have worked to rebase onto current Xen, as well as update the various header files borrowed from Linux.
This series provides the patches necessary to get a minimal build working. The build is "minimal" in the sense that 1) it uses a minimal config and 2) files, functions, and variables are included if and only if they are required for a successful build based on the config. It doesn't run at all, as the functions just have stub implementations.
My hope is that this can serve as a useful example for future ports as well as inform the community of exactly what is imposed by common code onto new architectures.
The first 3 patches are mods to non-RISCV bits that enable building a config with:
!CONFIG_HAS_NS16550 !CONFIG_HAS_PASSTHROUGH !CONFIG_GRANT_TABLErespectively. The fourth patch adds the RISCV files, and the last patch adds a docker container for doing the build. To build from the docker container (after creating it locally), you can run the following:
$ make XEN_TARGET_ARCH=riscv64 SUBSYSTEMS=xenThe sources taken from Linux are documented in
arch/riscv/README.sources. There were also some files copied from arm:asm-arm/softirq.h asm-arm/random.h asm-arm/nospec.h asm-arm/numa.h asm-arm/p2m.h asm-arm/delay.h asm-arm/debugger.h asm-arm/desc.h asm-arm/guest_access.h asm-arm/hardirq.h lib/find_next_bit.c
Quoted 7 lines
Quoted 2 lines
I imagine some of these will want some consolidation, but I put them under the respective RISCV directories for now.
Awesome!
Do you have a public branch I could pull these from to try out?
Alistair
Yes you can find the latest here: https://gitlab.com/connojd/xen/-/commits/riscv-build
Thanks,
Connor