Enable build of full Xen for RISC-V
PATCH 1/57 xen/riscv:introduce asm/byteorder.h
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/byteorder.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 xen/arch/riscv/include/asm/byteorder.h
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: +*/
Signature · 1 line
2.41.0
PATCH 2/57 xen/riscv: add public arch-riscv.h
In reply to Oleksii Kurochko--- xen/include/public/arch-riscv.h | 90 +++++++++++++++++++++++++++++++++ xen/include/public/xen.h | 2 + 2 files changed, 92 insertions(+) create mode 100644 xen/include/public/arch-riscv.h
xen/include/public/arch-riscv.h new file +90 -0
@@ -0,0 +1,90 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* Guest OS interface to RISC-V Xen. +* Initially based on the ARM implementation. +*/ + +#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; \ + 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. +*/ +#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); \ + _sxghr_tmp->q = 0; \ + _sxghr_tmp->p = (val); \ + } while ( 0 ) +#define set_xen_guest_handle (hnd, val) set_xen_guest_handle_raw(hnd, val) + +typedef uint64_t xen_pfn_t ; +#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 { +}; +typedef struct vcpu_guest_context vcpu_guest_context_t ; +DEFINE_XEN_GUEST_HANDLE (vcpu_guest_context_t); + +struct xen_arch_domainconfig { +}; + +#endif + +struct arch_vcpu_info { +}; +typedef struct arch_vcpu_info arch_vcpu_info_t ; + +struct arch_shared_info { +}; +typedef struct arch_shared_info arch_shared_info_t ; + +/* Maximum number of virtual CPUs in legacy multi-processor guests. */ +/* Only one. All other VCPUS must use VCPUOP_register_vcpu_info */ +#define XEN_LEGACY_MAX_VCPUS 1 + +#endif /* __ASSEMBLY__ */ + +#ifndef __ASSEMBLY__ +/* Stub definition of PMU structure */ +typedef struct xen_pmu_arch {uint8_t dummy; }xen_pmu_arch_t ; +#endif + +#endif /* __XEN_PUBLIC_ARCH_RISCV_H__ */ + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* tab-width: 4 +* indent-tabs-mode: nil +* End: +*/
xen/include/public/xen.h +2 -0
@@ -16,6 +16,8 @@#include "arch-x86/xen.h" #elif defined(__arm__) || defined (__aarch64__)#include "arch-arm.h" +#elif defined(__riscv) +#include "arch-riscv.h" #else #error "Unsupported architecture"#endif
Signature · 1 line
2.41.0
PATCH 3/57 xen/riscv: introduce spinlock.h
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/spinlock.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 xen/arch/riscv/include/asm/spinlock.h
xen/arch/riscv/include/asm/spinlock.h new file +13 -0
@@ -0,0 +1,13 @@ +#ifndef __ASM_RISCV_SPINLOCK_H +#define __ASM_RISCV_SPINLOCK_H + +#define arch_lock_acquire_barrier () smp_mb() +#define arch_lock_release_barrier () smp_mb() + +#define arch_lock_relax () cpu_relax() +#define arch_lock_signal () do { \ +} while(0) + +#define arch_lock_signal_wmb () arch_lock_signal() + +#endif /* __ASM_RISCV_SPINLOCK_H */
Signature · 1 line
2.41.0
PATCH 7/57 xen/riscv: introduce asm/cpufeature.h
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/cpufeature.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 xen/arch/riscv/include/asm/cpufeature.h
xen/arch/riscv/include/asm/cpufeature.h new file +22 -0
@@ -0,0 +1,22 @@ +#ifndef __ASM_RISCV_CPUFEATURE_H +#define __ASM_RISCV_CPUFEATURE_H + +#ifndef __ASSEMBLY__ + +static inline int cpu_nr_siblings (unsigned int cpu) +{ +return 1 ; +} + +#endif /* __ASSEMBLY__ */ + +#endif +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/ +
Signature · 1 line
2.41.0
PATCH 8/57 xen/riscv: introduce asm/device.h
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/device.h | 55 +++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 xen/arch/riscv/include/asm/device.h
xen/arch/riscv/include/asm/device.h new file +55 -0
@@ -0,0 +1,55 @@ +#ifndef __ASM_RISCV_DEVICE_H__ +#define __ASM_RISCV_DEVICE_H__ + +struct dt_device_node ; + +enum device_type +{ +DEV_DT , +DEV_PCI , +}; + +struct device { +enum device_type type; +#ifdef CONFIG_HAS_DEVICE_TREE +struct dt_device_node *of_node;/* Used by drivers imported from Linux */ +#endif +}; + +enum device_class +{ +DEVICE_SERIAL , +DEVICE_IOMMU , +DEVICE_GIC , +DEVICE_PCI_HOSTBRIDGE , +/* Use for error */ +DEVICE_UNKNOWN , +}; + +struct device_desc { +/* Device name */ +const char *name; +/* Device class */ +enum device_class class; +/* List of devices supported by this driver */ +const struct dt_device_match *dt_match; +/* +* Device initialization. +* +* -EAGAIN is used to indicate that device probing is deferred. +*/ +int (*init)(struct dt_device_node *dev,const void *data); +}; + +typedef struct device device_t ; + +#define DT_DEVICE_START (_name, _namestr, _class) \ +static const struct device_desc __dev_desc_##_name __used \ +__section(".dev.info") = { \ + .name = _namestr, \ + .class = _class, \ + +#define DT_DEVICE_END \ +}; + +#endif /* __ASM_RISCV_DEVICE_H__ */
Signature · 1 line
2.41.0
PATCH 10/57 xen/riscv: introduce asm/grant_table.h
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/grant_table.h | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 xen/arch/riscv/include/asm/grant_table.h
xen/arch/riscv/include/asm/grant_table.h new file +4 -0
@@ -0,0 +1,4 @@ +#ifndef __ASM_RISCV_GRANTTABLE_H__ +#define __ASM_RISCV_GRANTTABLE_H__ + +#endif /* __ASM_RISCV_GRANTTABLE_H__ */
Signature · 1 line
2.41.0
PATCH 11/57 xen/riscv: introduce asm/guest_atomics.h
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/guest_atomics.h | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 xen/arch/riscv/include/asm/guest_atomics.h
xen/arch/riscv/include/asm/guest_atomics.h new file +49 -0
@@ -0,0 +1,49 @@ +#ifndef __ASM_RISCV_GUEST_ATOMICS_H +#define __ASM_RISCV_GUEST_ATOMICS_H + +/* +* TODO: implement guest atomics +*/ + +#define guest_testop (name) \ +static inline int guest_##name(struct domain *d, int nr, volatile void *p) \ +{ \ + (void) d; \ + (void) nr; \ + (void) p; \ + \ + return 0; \ +} + +#define guest_bitop (name) \ +static inline void guest_##name(struct domain *d, int nr, volatile void *p) \ +{ \ + (void) d; \ + (void) nr; \ + (void) p; \ +} + +guest_bitop(set_bit) +guest_bitop(clear_bit) +guest_bitop(change_bit) + +#undef guest_bitop + +guest_testop(test_and_set_bit) +guest_testop(test_and_clear_bit) +guest_testop(test_and_change_bit) + +#undef guest_testop + + +#define guest_test_bit (d, nr, p) ((void)(d), test_bit(nr, p)) + +#endif /* __ASM_RISCV_GUEST_ATOMICS_H */ +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
Signature · 1 line
2.41.0
PATCH 14/57 xen/riscv: introduce asm/iommu.h
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/iommu.h | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 xen/arch/riscv/include/asm/iommu.h
xen/arch/riscv/include/asm/iommu.h new file +7 -0
@@ -0,0 +1,7 @@ +#ifndef __ASM_RISCV_IOMMU_H__ +#define __ASM_RISCV_IOMMU_H__ + +struct arch_iommu { +}; + +#endif /* __ASM_IOMMU_H__ */
Signature · 1 line
2.41.0
PATCH 6/57 xen/riscv: introduce paging.h
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/paging.h | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 xen/arch/riscv/include/asm/paging.h
xen/arch/riscv/include/asm/paging.h new file +7 -0
@@ -0,0 +1,7 @@ +#ifndef __ASM_RISCV_PAGING_H__ +#define __ASM_RISCV_PAGING_H__ + +#define paging_mode_translate (d) (1) +#define paging_mode_external (d) (1) + +#endif /* __ASM_RISCV_PAGING_H__ */
Signature · 1 line
2.41.0
PATCH 9/57 xen/riscv: introduce asm/event.h
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/event.h | 34 ++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 xen/arch/riscv/include/asm/event.h
xen/arch/riscv/include/asm/event.h new file +34 -0
@@ -0,0 +1,34 @@ +#ifndef __ASM_RISCV_EVENT_H__ +#define __ASM_RISCV_EVENT_H__ + +void vcpu_mark_events_pending (struct vcpu *v); + +static inline int vcpu_event_delivery_is_enabled (struct vcpu *v) +{ +return 0 ; +} + +static inline int local_events_need_delivery (void ) +{ +return 0 ; +} + +static inline void local_event_delivery_enable (void ) +{ +} + +/* No arch specific virq definition now. Default to global. */ +static inline bool arch_virq_is_global (unsigned int virq) +{ +return true; +} + +#endif +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
Signature · 1 line
2.41.0
PATCH 16/57 xen/riscv: introduce asm/nospec.h
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/nospec.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 xen/arch/riscv/include/asm/nospec.h
xen/arch/riscv/include/asm/nospec.h new file +25 -0
@@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ + +#ifndef _ASM_RISCV_NOSPEC_H +#define _ASM_RISCV_NOSPEC_H + +static inline bool evaluate_nospec (bool condition) +{ +return condition; +} + +static inline void block_speculation (void ) +{ +} + +#endif /* _ASM_RISCV_NOSPEC_H */ + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
Signature · 1 line
2.41.0
cover Enable build of full Xen for RISC-V
This patch series performs all of the additions necessary to drop the build overrides for RISCV and enable the full Xen build. Except in cases where compatibile implementations already exist (e.g. atomic.h and bitops.h), the newly added definitions are simple.
Also the patch series has open question described in the patch 57
Patch 56 is only needed for test purposes and will be removed.
Oleksii Kurochko (57):
xen/riscv:introduce asm/byteorder.h
xen/riscv: add public arch-riscv.h
xen/riscv: introduce spinlock.h
xen/riscv: introduce fence.h
xen/riscv: introduce arch-riscv/hvm/save.h
xen/riscv: introduce paging.h
xen/riscv: introduce asm/cpufeature.h
xen/riscv: introduce asm/device.h
xen/riscv: introduce asm/event.h
xen/riscv: introduce asm/grant_table.h
xen/riscv: introduce asm/guest_atomics.h
xen/riscv: introduce asm/hypercall.h
xen/riscv: introduce asm/iocap.h
xen/riscv: introduce asm/iommu.h
xen/riscv: introduce asm/mem_access.h
xen/riscv: introduce asm/nospec.h
xen/riscv: introduce asm/pci.h
xen/riscv: introduce asm/random.h
xen/riscv: introduce asm/setup.h
xen/riscv: introduce asm/system.h
xen/riscv: introduce asm/xenoprof.h
xen/riscv: introduce bitops.h
xen/riscv: introduce flushtlb.h
xen/riscv: introduce asm/percpu.h
xen/riscv: introduce asm/smp.h
xen/riscv: introduce asm/atomic.h
xen/riscv: introduce cmpxchg.h
xen/riscv: introduce asm/io.h
xen/riscv: introduce asm/hardirq.h
xen/riscv: introduce div64.h
xen/riscv: define bug frame tables in xen.lds.S xen/riscv: introduce bit operations
xen/riscv: introduce asm/altp2m.h
xen/riscv: introduce asm/delay.h
xen/riscv: introduce asm/domain.h
xen/riscv: introduce asm/guest_access.h
xen/riscv: introduce asm/irq.h
xen/riscv: introduce asm/monitor.h
xen/riscv: introduce asm/numa.h
xen/riscv: introduce asm/p2m.h
xen/riscv: introduce asm/regs.h
xen/riscv: introduce asm/softirq.h
xen/riscv: introduce asm/time.h
xen/riscv: introduce asm/vm_event.h
xen/riscv: add definition of __read_mostly
xen/riscv: define an address of frame table
xen/riscv: add required things to asm/current.h xen/riscv: add minimal stuff to asm/page.h to build full Xen xen/riscv: add minimal stuff to asm/processor.h to build full Xen xen/riscv: add minimal stuff to asm/smp.h to build full Xen
xen: add RISCV support for pmu.h
xen: add necessary headers to common to build full Xen for RISC-V xen/riscv: add minimal stuff to asm/mm.h to build full Xen xen/rirscv: add minimal amount of stubs to build full Xen xen/riscv: enable full Xen build
test only riscv
xxxen/riscv: WIP ( need advise )
automation/gitlab-ci/analyze.yaml | 16 - automation/gitlab-ci/build.yaml | 544 --------------------- automation/gitlab-ci/test.yaml | 308 ------------ xen/arch/riscv/Kconfig | 1 + xen/arch/riscv/Makefile | 18 +- xen/arch/riscv/arch.mk | 4 - xen/arch/riscv/configs/tiny64_defconfig | 19 +- xen/arch/riscv/early_printk.c | 168 ------- xen/arch/riscv/include/asm/altp2m.h | 28 ++ xen/arch/riscv/include/asm/asm_defns.h | 44 ++ xen/arch/riscv/include/asm/atomic.h | 375 ++++++++++++++ xen/arch/riscv/include/asm/bitops.h | 288 +++++++++++ xen/arch/riscv/include/asm/byteorder.h | 16 + xen/arch/riscv/include/asm/cache.h | 2 + xen/arch/riscv/include/asm/cmpxchg.h | 373 ++++++++++++++ xen/arch/riscv/include/asm/config.h | 21 + xen/arch/riscv/include/asm/cpufeature.h | 22 + xen/arch/riscv/include/asm/current.h | 17 + xen/arch/riscv/include/asm/delay.h | 17 + xen/arch/riscv/include/asm/device.h | 55 +++ xen/arch/riscv/include/asm/div64.h | 22 + xen/arch/riscv/include/asm/domain.h | 43 ++ xen/arch/riscv/include/asm/event.h | 34 ++ xen/arch/riscv/include/asm/fence.h | 12 + xen/arch/riscv/include/asm/flushtlb.h | 31 ++ xen/arch/riscv/include/asm/grant_table.h | 61 +++ xen/arch/riscv/include/asm/guest_access.h | 29 ++ xen/arch/riscv/include/asm/guest_atomics.h | 63 +++ xen/arch/riscv/include/asm/hardirq.h | 26 + xen/arch/riscv/include/asm/hypercall.h | 4 + xen/arch/riscv/include/asm/io.h | 132 +++++ xen/arch/riscv/include/asm/iocap.h | 16 + xen/arch/riscv/include/asm/iommu.h | 7 + xen/arch/riscv/include/asm/irq.h | 34 ++ xen/arch/riscv/include/asm/livepatch.h | 0 xen/arch/riscv/include/asm/mem_access.h | 4 + xen/arch/riscv/include/asm/mm.h | 270 +++++++++- xen/arch/riscv/include/asm/monitor.h | 53 ++ xen/arch/riscv/include/asm/nospec.h | 25 + xen/arch/riscv/include/asm/numa.h | 38 ++ xen/arch/riscv/include/asm/p2m.h | 129 +++++ xen/arch/riscv/include/asm/page.h | 37 ++ xen/arch/riscv/include/asm/paging.h | 7 + xen/arch/riscv/include/asm/pci.h | 7 + xen/arch/riscv/include/asm/percpu.h | 33 ++ xen/arch/riscv/include/asm/perfc_defn.h | 0 xen/arch/riscv/include/asm/processor.h | 15 + xen/arch/riscv/include/asm/random.h | 9 + xen/arch/riscv/include/asm/regs.h | 27 + xen/arch/riscv/include/asm/setup.h | 6 + xen/arch/riscv/include/asm/smp.h | 23 + xen/arch/riscv/include/asm/softirq.h | 16 + xen/arch/riscv/include/asm/spinlock.h | 13 + xen/arch/riscv/include/asm/system.h | 83 ++++ xen/arch/riscv/include/asm/time.h | 20 + xen/arch/riscv/include/asm/vm_event.h | 52 ++ xen/arch/riscv/include/asm/xenoprof.h | 4 + xen/arch/riscv/lib/Makefile | 1 + xen/arch/riscv/lib/find_next_bit.c | 278 +++++++++++ xen/arch/riscv/mm.c | 85 +++- xen/arch/riscv/setup.c | 9 +- xen/arch/riscv/stubs.c | 419 ++++++++++++++++ xen/arch/riscv/traps.c | 25 + xen/arch/riscv/xen.lds.S | 10 + xen/common/memory.c | 1 + xen/common/symbols.c | 1 + xen/include/public/arch-riscv.h | 90 ++++ xen/include/public/arch-riscv/hvm/save.h | 22 + 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/iommu.h | 1 + xen/include/xen/sched.h | 1 + 74 files changed, 3625 insertions(+), 1046 deletions(-) create mode 100644 xen/arch/riscv/include/asm/altp2m.h create mode 100644 xen/arch/riscv/include/asm/asm_defns.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/byteorder.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/delay.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/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/irq.h create mode 100644 xen/arch/riscv/include/asm/livepatch.h create mode 100644 xen/arch/riscv/include/asm/mem_access.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/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/perfc_defn.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/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/system.h create mode 100644 xen/arch/riscv/include/asm/time.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/lib/Makefile create mode 100644 xen/arch/riscv/lib/find_next_bit.c create mode 100644 xen/arch/riscv/stubs.c create mode 100644 xen/include/public/arch-riscv.h create mode 100644 xen/include/public/arch-riscv/hvm/save.h
Signature · 1 line
2.41.0
PATCH 4/57 xen/riscv: introduce fence.h
--- xen/arch/riscv/include/asm/fence.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 xen/arch/riscv/include/asm/fence.h
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 */
Signature · 1 line
2.41.0
PATCH 5/57 xen/riscv: introduce arch-riscv/hvm/save.h
In reply to Oleksii Kurochko--- xen/include/public/arch-riscv/hvm/save.h | 22 ++++++++++++++++++++++ xen/include/public/hvm/save.h | 2 ++ 2 files changed, 24 insertions(+) create mode 100644 xen/include/public/arch-riscv/hvm/save.h
xen/include/public/arch-riscv/hvm/save.h new file +22 -0
@@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Structure definitions for HVM state that is held by Xen and must +* be saved along with the domain's memory and device-model state. +* +* Copyright (c) 2012 Citrix Systems Ltd. +*/ + +#ifndef __XEN_PUBLIC_HVM_SAVE_RISCV_H__ +#define __XEN_PUBLIC_HVM_SAVE_RISCV_H__ + +#endif + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* tab-width: 4 +* indent-tabs-mode: nil +* End: +*/
xen/include/public/hvm/save.h +2 -0
@@ -89,6 +89,8 @@ DECLARE_HVM_SAVE_TYPE(END, 0, struct hvm_save_end);#include "../arch-x86/hvm/save.h" #elif defined(__arm__) || defined(__aarch64__)#include "../arch-arm/hvm/save.h" +#elif defined(__riscv) +#include "../arch-riscv/hvm/save.h" #else #error "unsupported architecture"#endif
Signature · 1 line
2.41.0
PATCH 12/57 xen/riscv: introduce asm/hypercall.h
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/hypercall.h | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 xen/arch/riscv/include/asm/hypercall.h
xen/arch/riscv/include/asm/hypercall.h new file +4 -0
@@ -0,0 +1,4 @@ +#ifndef __ASM_RISCV_HYPERCALL_H__ +#define __ASM_RISCV_HYPERCALL_H__ + +#endif /* __ASM_RISCV_HYPERCALL_H__ */
Signature · 1 line
2.41.0
PATCH 13/57 xen/riscv: introduce asm/iocap.h
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/iocap.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 xen/arch/riscv/include/asm/iocap.h
xen/arch/riscv/include/asm/iocap.h new file +16 -0
@@ -0,0 +1,16 @@ +#ifndef __ASM_RISCV_IOCAP_H__ +#define __ASM_RISCV_IOCAP_H__ + +#define cache_flush_permitted (d) \ + (!rangeset_is_empty((d)->iomem_caps)) + +#endif + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
Signature · 1 line
2.41.0
PATCH 17/57 xen/riscv: introduce asm/pci.h
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/pci.h | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 xen/arch/riscv/include/asm/pci.h
xen/arch/riscv/include/asm/pci.h new file +7 -0
@@ -0,0 +1,7 @@ +#ifndef __ASM_RISCV_PCI_H__ +#define __ASM_RISCV_PCI_H__ + +struct arch_pci_dev { +}; + +#endif /* __ASM_PCI_H__ */
Signature · 1 line
2.41.0
PATCH 15/57 xen/riscv: introduce asm/mem_access.h
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/mem_access.h | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 xen/arch/riscv/include/asm/mem_access.h
xen/arch/riscv/include/asm/mem_access.h new file +4 -0
@@ -0,0 +1,4 @@ +#ifndef __ASM_RISCV_MEM_ACCESS +#define __ASM_RISCV_MEM_ACCESS + +#endif
Signature · 1 line
2.41.0
PATCH 18/57 xen/riscv: introduce asm/random.h
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/random.h | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 xen/arch/riscv/include/asm/random.h
xen/arch/riscv/include/asm/random.h new file +9 -0
@@ -0,0 +1,9 @@ +#ifndef __ASM_RISCV_RANDOM_H__ +#define __ASM_RISCV_RANDOM_H__ + +static inline unsigned int arch_get_random (void ) +{ +return 0 ; +} + +#endif /* __ASM_RISCV_RANDOM_H__ */
Signature · 1 line
2.41.0
PATCH 35/57 xen/riscv: introduce asm/domain.h
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/domain.h | 43 +++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 xen/arch/riscv/include/asm/domain.h
xen/arch/riscv/include/asm/domain.h new file +43 -0
@@ -0,0 +1,43 @@ +#ifndef __ASM_RISCV_DOMAIN_H__ +#define __ASM_RISCV_DOMAIN_H__ + +#include <xen/xmalloc.h> +#include <public/hvm/params.h> + +struct hvm_domain +{ +uint64_t params[HVM_NR_PARAMS ]; +}; + +#define is_domain_direct_mapped (d) ((void)(d), 0) + +struct arch_vcpu_io { +}; + +struct arch_vcpu { +}; + +struct arch_domain { +struct hvm_domain hvm; +}; + +#include <xen/sched.h> + +static inline struct vcpu_guest_context *alloc_vcpu_guest_context (void ) +{ + return xmalloc(struct vcpu_guest_context); +} + +static inline void free_vcpu_guest_context (struct vcpu_guest_context *vgc) +{ +xfree (vgc); +} + +struct guest_memory_policy {}; +static inline void update_guest_memory_policy (struct vcpu *v, +struct guest_memory_policy *gmp) +{} + +static inline void arch_vcpu_block (struct vcpu *v) {} + +#endif /* __ASM_RISCV_DOMAIN_H__ */
Signature · 1 line
2.41.0
PATCH 52/57 xen: add necessary headers to common to build full Xen for RISC-V
In reply to Oleksii KurochkoMostly patch was taken from the PPC patch series so can be skipped during review:
--- xen/common/memory.c | 1 + xen/common/symbols.c | 1 + xen/include/xen/domain.h | 1 + xen/include/xen/iommu.h | 1 + xen/include/xen/sched.h | 1 + 5 files changed, 5 insertions(+)
xen/common/memory.c +1 -0
@@ -28,6 +28,7 @@#include <asm/current.h> #include <asm/hardirq.h> #include <asm/p2m.h> +#include <asm/page.h> #include <public/memory.h> #include <xsm/xsm.h>
xen/common/symbols.c +1 -0
@@ -19,6 +19,7 @@#include <xen/virtual_region.h> #include <public/platform.h> #include <xen/guest_access.h> +#include <xen/errno.h> #ifdef SYMBOLS_ORIGIN extern const unsigned int symbols_offsets[];
xen/include/xen/domain.h +1 -0
@@ -4,6 +4,7 @@#include <xen/types.h> +#include <public/domctl.h> #include <public/xen.h> #include <asm/domain.h> #include <asm/numa.h>
xen/include/xen/iommu.h +1 -0
@@ -24,6 +24,7 @@#include <xen/page-defs.h> #include <xen/pci.h> #include <xen/spinlock.h> +#include <xen/errno.h> #include <public/domctl.h> #include <public/hvm/ioreq.h> #include <asm/device.h>
xen/include/xen/sched.h +1 -0
@@ -21,6 +21,7 @@#include <xen/smp.h> #include <xen/perfc.h> #include <asm/atomic.h> +#include <asm/current.h> #include <xen/vpci.h> #include <xen/wait.h> #include <public/xen.h>
Signature · 1 line
2.41.0
PATCH 22/57 xen/riscv: introduce bitops.h
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/bitops.h | 288 ++++++++++++++++++++++++++++ 1 file changed, 288 insertions(+) create mode 100644 xen/arch/riscv/include/asm/bitops.h
xen/arch/riscv/include/asm/bitops.h new file +288 -0
@@ -0,0 +1,288 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (C) 2012 Regents of the University of California */ + +#ifndef _ASM_RISCV_BITOPS_H +#define _ASM_RISCV_BITOPS_H + +#include <asm/system.h> + +#define BITOP_BITS_PER_WORD 32 +#define BITOP_MASK (nr) (1UL << ((nr) % BITOP_BITS_PER_WORD)) +#define BITOP_WORD (nr) ((nr) / BITOP_BITS_PER_WORD) +#define BITS_PER_BYTE 8 + +#define __set_bit (n,p) set_bit(n,p) +#define __clear_bit (n,p) clear_bit(n,p) + +#define __AMO (op) "amo" #op ".w" + +#define __test_and_op_bit_ord (op, mod, nr, addr, ord) \ +({ \ + unsigned long __res, __mask; \ + __mask = BITOP_MASK(nr); \ + __asm__ __volatile__ ( \ + __AMO(op) #ord " %0, %2, %1" \ + : "=r" (__res), "+A" (addr[BITOP_WORD(nr)]) \ + : "r" (mod(__mask)) \ + : "memory"); \ + ((__res & __mask) != 0); \ +}) + +#define __op_bit_ord (op, mod, nr, addr, ord) \ + __asm__ __volatile__ ( \ + __AMO(op) #ord " zero, %1, %0" \ + : "+A" (addr[BITOP_WORD(nr)]) \ + : "r" (mod(BITOP_MASK(nr))) \ + : "memory"); + +#define __test_and_op_bit (op, mod, nr, addr) \ + __test_and_op_bit_ord(op, mod, nr, addr, .aqrl) + +#define __op_bit (op, mod, nr, addr) \ + __op_bit_ord(op, mod, nr, addr, ) + +/* Bitmask modifiers */ +#define __NOP (x) (x) +#define __NOT (x) (~(x)) + +/** +* __test_and_set_bit - Set a bit and return its old value +* @nr: Bit to set +* @addr: Address to count from +* +* This operation may be reordered on other architectures than x86. +*/ +static inline int __test_and_set_bit (int nr,volatile void *p) +{ +volatile uint32_t *addr = p; + +return __test_and_op_bit (or, __NOP, nr, addr); +} + +/** +* __test_and_clear_bit - Clear a bit and return its old value +* @nr: Bit to clear +* @addr: Address to count from +* +* This operation can be reordered on other architectures other than x86. +*/ +static inline int __test_and_clear_bit (int nr,volatile void *p) +{ +volatile uint32_t *addr = p; + +return __test_and_op_bit (and, __NOT, nr, addr); +} + +/** +* set_bit - Atomically set a bit in memory +* @nr: the bit to set +* @addr: the address to start counting from +* +* Note: there are no guarantees that this function will not be reordered +* on non x86 architectures, so if you are writing portable code, +* make sure not to rely on its reordering guarantees. +* +* Note that @nr may be almost arbitrarily large; this function is not +* restricted to acting on a single-word quantity. +*/ +static inline void set_bit (int nr,volatile void *p) +{ +volatile uint32_t *addr = p; + +__op_bit (or, __NOP, nr, addr); +} + +/** +* clear_bit - Clears a bit in memory +* @nr: Bit to clear +* @addr: Address to start counting from +* +* Note: there are no guarantees that this function will not be reordered +* on non x86 architectures, so if you are writing portable code, +* make sure not to rely on its reordering guarantees. +*/ +static inline void clear_bit (int nr,volatile void *p) +{ +volatile uint32_t *addr = p; + +__op_bit (and, __NOT, nr, addr); +} + +static inline int test_bit (int nr,const volatile void *p) +{ +const volatile uint32_t *addr = (const volatile uint32_t *)p; + +return 1UL & (addr[BITOP_WORD (nr)] >> (nr & (BITOP_BITS_PER_WORD -1 ))); +} + +#undef __test_and_op_bit +#undef __op_bit +#undef __NOP +#undef __NOT +#undef __AMO + +static inline int fls (unsigned int x) +{ +return generic_fls (x); +} + +static inline int flsl (unsigned long x) +{ +return generic_flsl (x); +} + +#define test_and_set_bit __test_and_set_bit +#define test_and_clear_bit __test_and_clear_bit + +/* Based on linux/include/asm-generic/bitops/find.h */ + +#ifndef find_next_bit +/** +* find_next_bit - find the next set bit in a memory region +* @addr: The address to base the search on +* @offset: The bitnumber to start searching at +* @size: The bitmap size in bits +*/ +extern unsigned long find_next_bit (const unsigned long *addr,unsigned long + size,unsigned long offset); +#endif + +#ifndef find_next_zero_bit +/** +* find_next_zero_bit - find the next cleared bit in a memory region +* @addr: The address to base the search on +* @offset: The bitnumber to start searching at +* @size: The bitmap size in bits +*/ +extern unsigned long find_next_zero_bit (const unsigned long *addr,unsigned +long size,unsigned long offset); +#endif + +/** +* find_first_bit - find the first set bit in a memory region +* @addr: The address to start the search at +* @size: The maximum size to search +* +* Returns the bit number of the first set bit. +*/ +extern unsigned long find_first_bit (const unsigned long *addr, +unsigned long size); + +/** +* find_first_zero_bit - find the first cleared bit in a memory region +* @addr: The address to start the search at +* @size: The maximum size to search +* +* Returns the bit number of the first cleared bit. +*/ +extern unsigned long find_first_zero_bit (const unsigned long *addr, +unsigned long size); + +#define ffs (x) ({ unsigned int __t = (x); fls(__t & -__t); }) + +/** +* ffs - find first bit in word. +* @word: The word to search +* +* Returns 0 if no bit exists, otherwise returns 1-indexed bit location. +*/ +static inline unsigned long __ffs (unsigned long word) +{ +int num =0 ; + +#if BITS_PER_LONG ==64 +if ((word &0xffffffff ) ==0 ) { + num +=32 ; + word >>=32 ; + } +#endif +if ((word &0xffff ) ==0 ) { + num +=16 ; + word >>=16 ; + } +if ((word &0xff ) ==0 ) { + num +=8 ; + word >>=8 ; + } +if ((word &0xf ) ==0 ) { + num +=4 ; + word >>=4 ; + } +if ((word &0x3 ) ==0 ) { + num +=2 ; + word >>=2 ; + } +if ((word &0x1 ) ==0 ) + num +=1 ; +return num; +} + +/** +* ffsl - find first bit in long. +* @word: The word to search +* +* Returns 0 if no bit exists, otherwise returns 1-indexed bit location. +*/ +static inline unsigned int ffsl (unsigned long word) +{ +int num =1 ; + +if (!word) +return 0 ; + +#if BITS_PER_LONG ==64 +if ((word &0xffffffff ) ==0 ) { + num +=32 ; + word >>=32 ; + } +#endif +if ((word &0xffff ) ==0 ) { + num +=16 ; + word >>=16 ; + } +if ((word &0xff ) ==0 ) { + num +=8 ; + word >>=8 ; + } +if ((word &0xf ) ==0 ) { + num +=4 ; + word >>=4 ; + } +if ((word &0x3 ) ==0 ) { + num +=2 ; + word >>=2 ; + } +if ((word &0x1 ) ==0 ) + num +=1 ; +return num; +} + +/* +* ffz - find first zero in word. +* @word: The word to search +* +* Undefined if no zero exists, so code should check against ~0UL first. +*/ +#define ffz (x) __ffs(~(x)) + +/** +* find_first_set_bit - find the first set bit in @word +* @word: the word to search +* +* Returns the bit-number of the first set bit (first bit being 0). +* The input must *not* be zero. +*/ +static inline unsigned int find_first_set_bit (unsigned long word) +{ +return ffsl (word) -1 ; +} + +/** +* hweightN - returns the hamming weight of a N-bit word +* @x: the word to weigh +* +* The Hamming Weight of a number is the total number of bits set in it. +*/ +#define hweight64 (x) generic_hweight64(x) + +#endif /* _ASM_RISCV_BITOPS_H */
Signature · 1 line
2.41.0
PATCH 44/57 xen/riscv: introduce asm/vm_event.h
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/vm_event.h | 52 +++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 xen/arch/riscv/include/asm/vm_event.h
xen/arch/riscv/include/asm/vm_event.h new file +52 -0
@@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* vm_event.h: architecture specific vm_event handling routines +* +* Copyright (c) 2015 Tamas K Lengyel ([email protected]) +*/ + +#ifndef __ASM_RISCV_VM_EVENT_H__ +#define __ASM_RISCV_VM_EVENT_H__ + +#include <xen/sched.h> +#include <xen/vm_event.h> +#include <public/domctl.h> + +static inline int vm_event_init_domain (struct domain *d) +{ +/* Nothing to do. */ +return 0 ; +} + +static inline void vm_event_cleanup_domain (struct domain *d) +{ +memset (&d->monitor,0 ,sizeof (d->monitor)); +} + +static inline void vm_event_toggle_singlestep (struct domain *d,struct vcpu *v, +vm_event_response_t *rsp) +{ +/* Not supported on RISCV. */ +} + +static inline +void vm_event_register_write_resume (struct vcpu *v,vm_event_response_t *rsp) +{ +/* Not supported on RISCV. */ +} + +static inline +void vm_event_emulate_check (struct vcpu *v,vm_event_response_t *rsp) +{ +/* Not supported on RISCV. */ +} + +static inline +void vm_event_sync_event (struct vcpu *v,bool value) +{ +/* Not supported on RISCV. */ +} + +void vm_event_reset_vmtrace (struct vcpu *v); + +#endif /* __ASM_RISCV_VM_EVENT_H__ */
Signature · 1 line
2.41.0
PATCH 48/57 xen/riscv: add minimal stuff to asm/page.h to build full Xen
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/page.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
xen/arch/riscv/include/asm/page.h +21 -0
@@ -6,6 +6,7 @@#ifndef __ASSEMBLY__#include <xen/const.h> +#include <xen/bug.h> #include <xen/types.h> #include <asm/mm.h>
@@ -32,6 +33,9 @@#define PTE_LEAF_DEFAULT (PTE_VALID | PTE_READABLE | PTE_WRITABLE)#define PTE_TABLE (PTE_VALID) +/* TODO */ +#define PAGE_HYPERVISOR 0 +/* Calculate the offsets into the pagetables for a given VA */ #define pt_linear_offset (lvl, va) ((va) >> XEN_PT_LEVEL_SHIFT(lvl))
@@ -46,6 +50,9 @@ typedef struct {#endif } pte_t; +#define pfn_to_paddr (pfn) ((paddr_t)(pfn) << PAGE_SHIFT) +#define paddr_to_pfn (pa) ((unsigned long)((pa) >> PAGE_SHIFT)) +static inline pte_t paddr_to_pte (paddr_t paddr,unsigned int permissions) {
@@ -62,6 +69,20 @@ static inline bool pte_is_valid(pte_t p)return p.pte &PTE_VALID ; } +static inline void invalidate_icache (void ) +{ +BUG (); +} + +#define clear_page (page) memset((void *)(page), 0, PAGE_SIZE) +#define copy_page (dp, sp) memcpy(dp, sp, PAGE_SIZE) + +/* TODO: Flush the dcache for an entire page. */ +static inline void flush_page_to_ram (unsigned long mfn,bool sync_icache) +{ +BUG (); +} +#endif /* __ASSEMBLY__ */ #endif /* _ASM_RISCV_PAGE_H */
Signature · 1 line
2.41.0
PATCH 54/57 xen/rirscv: add minimal amount of stubs to build full Xen
In reply to Oleksii Kurochko--- xen/arch/riscv/Kconfig | 1 + xen/arch/riscv/Makefile | 1 + xen/arch/riscv/early_printk.c | 168 ------------- xen/arch/riscv/mm.c | 52 +++- xen/arch/riscv/setup.c | 9 +- xen/arch/riscv/stubs.c | 437 ++++++++++++++++++++++++++++++++++ xen/arch/riscv/traps.c | 25 ++ 7 files changed, 523 insertions(+), 170 deletions(-) create mode 100644 xen/arch/riscv/stubs.c
xen/arch/riscv/Kconfig +1 -0
@@ -4,6 +4,7 @@ config RISCV config RISCV_64 def_bool y select 64BIT + select HAS_PDX config ARCH_DEFCONFIG string
xen/arch/riscv/Makefile +1 -0
@@ -5,6 +5,7 @@ obj-y += mm.o obj-$(CONFIG_RISCV_64) += riscv64/ obj-y += sbi.o obj-y += setup.o +obj-y += stubs.o obj-y += traps.o $(TARGET): $(TARGET)-syms
xen/arch/riscv/early_printk.c +0 -168
171 lines not on this page · raw message
xen/arch/riscv/mm.c +51 -1
69 lines not on this page · raw message
xen/arch/riscv/setup.c +8 -1
@@ -2,9 +2,16 @@#include <xen/compile.h> #include <xen/init.h> +#include <xen/mm.h> + +#include <public/version.h> #include <asm/early_printk.h> -#include <asm/mm.h> + +void arch_get_xen_caps (xen_capabilities_info_t *info) +{ +assert_failed ("need to be implemented" ); +}/* Xen stack for bringing up the first CPU. */ unsigned char __initdata cpu0_boot_stack[STACK_SIZE ]
xen/arch/riscv/stubs.c new file +437 -0
438 lines not on this page · raw message
xen/arch/riscv/traps.c +25 -0
@@ -4,6 +4,10 @@* * RISC-V Trap handlers */ + +#include <xen/lib.h> +#include <xen/sched.h> +#include <asm/processor.h> #include <asm/traps.h>
@@ -11,3 +15,24 @@ void do_trap(struct cpu_user_regs *cpu_regs) {die (); } + +void vcpu_show_execution_state (struct vcpu *v) +{ +assert_failed ("need to be implented" ); +} + +void show_execution_state (const struct cpu_user_regs *regs) +{ +printk ("implement show_execution_state(regs)\n" ); +} + +void arch_hypercall_tasklet_result (struct vcpu *v,long res) +{ +assert_failed ("need to be implented" ); +} + +enum mc_disposition arch_do_multicall_call (struct mc_state *state) +{ +assert_failed ("need to be implented" ); +return mc_continue; +}
Signature · 1 line
2.41.0
PATCH 38/57 xen/riscv: introduce asm/monitor.h
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/monitor.h | 53 ++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 xen/arch/riscv/include/asm/monitor.h
xen/arch/riscv/include/asm/monitor.h new file +53 -0
@@ -0,0 +1,53 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* include/asm-RISCV/monitor.h +* +* Arch-specific monitor_op domctl handler. +* +* Copyright (c) 2015 Tamas K Lengyel ([email protected]) +* Copyright (c) 2016, Bitdefender S.R.L. +* +*/ + +#ifndef __ASM_RISCV_MONITOR_H__ +#define __ASM_RISCV_MONITOR_H__ + +#include <xen/sched.h> +#include <public/domctl.h> + +static inline +void arch_monitor_allow_userspace (struct domain *d,bool allow_userspace) +{ +} + +static inline +int arch_monitor_domctl_op (struct domain *d,struct xen_domctl_monitor_op *mop) +{ +/* No arch-specific monitor ops on RISCV. */ +return -EOPNOTSUPP ; +} + +int arch_monitor_domctl_event (struct domain *d, +struct xen_domctl_monitor_op *mop); + +static inline +int arch_monitor_init_domain (struct domain *d) +{ +/* No arch-specific domain initialization on RISCV. */ +return 0 ; +} + +static inline +void arch_monitor_cleanup_domain (struct domain *d) +{ +/* No arch-specific domain cleanup on RISCV. */ +} + +static inline uint32_t arch_monitor_get_capabilities (struct domain *d) +{ +uint32_t capabilities =0 ; + +return capabilities; +} + +#endif /* __ASM_RISCV_MONITOR_H__ */
Signature · 1 line
2.41.0
PATCH 27/57 xen/riscv: introduce cmpxchg.h
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/cmpxchg.h | 373 +++++++++++++++++++++++++++ 1 file changed, 373 insertions(+) create mode 100644 xen/arch/riscv/include/asm/cmpxchg.h
xen/arch/riscv/include/asm/cmpxchg.h new file +373 -0
@@ -0,0 +1,373 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (C) 2014 Regents of the University of California */ + +#ifndef _ASM_RISCV_CMPXCHG_H +#define _ASM_RISCV_CMPXCHG_H + +#include <asm/system.h> +#include <asm/fence.h> +#include <xen/lib.h> + +#define __xchg_relaxed (ptr, new, size) \ +({ \ + __typeof__(ptr) __ptr = (ptr); \ + __typeof__(new) __new = (new); \ + __typeof__(*(ptr)) __ret; \ + switch (size) { \ + case 4: \ + __asm__ __volatile__ ( \ + " amoswap.w %0, %2, %1\n" \ + : "=r" (__ret), "+A" (*__ptr) \ + : "r" (__new) \ + : "memory"); \ + break; \ + case 8: \ + __asm__ __volatile__ ( \ + " amoswap.d %0, %2, %1\n" \ + : "=r" (__ret), "+A" (*__ptr) \ + : "r" (__new) \ + : "memory"); \ + break; \ + default: \ + ASSERT_UNREACHABLE(); \ + } \ + __ret; \ +}) + +#define xchg_relaxed (ptr, x) \ +({ \ + __typeof__(*(ptr)) _x_ = (x); \ + (__typeof__(*(ptr))) __xchg_relaxed((ptr), \ + _x_, sizeof(*(ptr))); \ +}) + +#define __xchg_acquire (ptr, new, size) \ +({ \ + __typeof__(ptr) __ptr = (ptr); \ + __typeof__(new) __new = (new); \ + __typeof__(*(ptr)) __ret; \ + switch (size) { \ + case 4: \ + __asm__ __volatile__ ( \ + " amoswap.w %0, %2, %1\n" \ + RISCV_ACQUIRE_BARRIER \ + : "=r" (__ret), "+A" (*__ptr) \ + : "r" (__new) \ + : "memory"); \ + break; \ + case 8: \ + __asm__ __volatile__ ( \ + " amoswap.d %0, %2, %1\n" \ + RISCV_ACQUIRE_BARRIER \ + : "=r" (__ret), "+A" (*__ptr) \ + : "r" (__new) \ + : "memory"); \ + break; \ + default: \ + ASSERT_UNREACHABLE(); \ + } \ + __ret; \ +}) + +#define xchg_acquire (ptr, x) \ +({ \ + __typeof__(*(ptr)) _x_ = (x); \ + (__typeof__(*(ptr))) __xchg_acquire((ptr), \ + _x_, sizeof(*(ptr))); \ +}) + +#define __xchg_release (ptr, new, size) \ +({ \ + __typeof__(ptr) __ptr = (ptr); \ + __typeof__(new) __new = (new); \ + __typeof__(*(ptr)) __ret; \ + switch (size) { \ + case 4: \ + __asm__ __volatile__ ( \ + RISCV_RELEASE_BARRIER \ + " amoswap.w %0, %2, %1\n" \ + : "=r" (__ret), "+A" (*__ptr) \ + : "r" (__new) \ + : "memory"); \ + break; \ + case 8: \ + __asm__ __volatile__ ( \ + RISCV_RELEASE_BARRIER \ + " amoswap.d %0, %2, %1\n" \ + : "=r" (__ret), "+A" (*__ptr) \ + : "r" (__new) \ + : "memory"); \ + break; \ + default: \ + ASSERT_UNREACHABLE(); \ + } \ + __ret; \ +}) + +#define xchg_release (ptr, x) \ +({ \ + __typeof__(*(ptr)) _x_ = (x); \ + (__typeof__(*(ptr))) __xchg_release((ptr), \ + _x_, sizeof(*(ptr))); \ +}) + +#define __xchg (ptr, new, size) \ +({ \ + __typeof__(ptr) __ptr = (ptr); \ + __typeof__(new) __new = (new); \ + __typeof__(*(ptr)) __ret; \ + switch (size) { \ + case 4: \ + __asm__ __volatile__ ( \ + " amoswap.w.aqrl %0, %2, %1\n" \ + : "=r" (__ret), "+A" (*__ptr) \ + : "r" (__new) \ + : "memory"); \ + break; \ + case 8: \ + __asm__ __volatile__ ( \ + " amoswap.d.aqrl %0, %2, %1\n" \ + : "=r" (__ret), "+A" (*__ptr) \ + : "r" (__new) \ + : "memory"); \ + break; \ + default: \ + __ret = 0; \ + ASSERT_UNREACHABLE(); \ + } \ + __ret; \ +}) + +#define xchg (ptr, x) \ +({ \ + __typeof__(*(ptr)) _x_ = (x); \ + (__typeof__(*(ptr))) __xchg((ptr), _x_, sizeof(*(ptr))); \ +}) + +#define xchg32 (ptr, x) \ +({ \ + BUILD_BUG_ON(sizeof(*(ptr)) != 4); \ + xchg((ptr), (x)); \ +}) + +#define xchg64 (ptr, x) \ +({ \ + BUILD_BUG_ON(sizeof(*(ptr)) != 8); \ + xchg((ptr), (x)); \ +}) + +/* +* Atomic compare and exchange. Compare OLD with MEM, if identical, +* store NEW in MEM. Return the initial value in MEM. Success is +* indicated by comparing RETURN with OLD. +*/ +#define __cmpxchg_relaxed (ptr, old, new, size) \ +({ \ + __typeof__(ptr) __ptr = (ptr); \ + __typeof__(*(ptr)) __old = (old); \ + __typeof__(*(ptr)) __new = (new); \ + __typeof__(*(ptr)) __ret; \ + register unsigned int __rc; \ + switch (size) { \ + case 4: \ + __asm__ __volatile__ ( \ + "0: lr.w %0, %2\n" \ + " bne %0, %z3, 1f\n" \ + " sc.w %1, %z4, %2\n" \ + " bnez %1, 0b\n" \ + "1:\n" \ + : "=&r" (__ret), "=&r" (__rc), "+A" (*__ptr) \ + : "rJ" (__old), "rJ" (__new) \ + : "memory"); \ + break; \ + case 8: \ + __asm__ __volatile__ ( \ + "0: lr.d %0, %2\n" \ + " bne %0, %z3, 1f\n" \ + " sc.d %1, %z4, %2\n" \ + " bnez %1, 0b\n" \ + "1:\n" \ + : "=&r" (__ret), "=&r" (__rc), "+A" (*__ptr) \ + : "rJ" (__old), "rJ" (__new) \ + : "memory"); \ + break; \ + default: \ + ASSERT_UNREACHABLE(); \ + } \ + __ret; \ +}) + +#define cmpxchg_relaxed (ptr, o, n) \ +({ \ + __typeof__(*(ptr)) _o_ = (o); \ + __typeof__(*(ptr)) _n_ = (n); \ + (__typeof__(*(ptr))) __cmpxchg_relaxed((ptr), \ + _o_, _n_, sizeof(*(ptr))); \ +}) + +#define __cmpxchg_acquire (ptr, old, new, size) \ +({ \ + __typeof__(ptr) __ptr = (ptr); \ + __typeof__(*(ptr)) __old = (old); \ + __typeof__(*(ptr)) __new = (new); \ + __typeof__(*(ptr)) __ret; \ + register unsigned int __rc; \ + switch (size) { \ + case 4: \ + __asm__ __volatile__ ( \ + "0: lr.w %0, %2\n" \ + " bne %0, %z3, 1f\n" \ + " sc.w %1, %z4, %2\n" \ + " bnez %1, 0b\n" \ + RISCV_ACQUIRE_BARRIER \ + "1:\n" \ + : "=&r" (__ret), "=&r" (__rc), "+A" (*__ptr) \ + : "rJ" (__old), "rJ" (__new) \ + : "memory"); \ + break; \ + case 8: \ + __asm__ __volatile__ ( \ + "0: lr.d %0, %2\n" \ + " bne %0, %z3, 1f\n" \ + " sc.d %1, %z4, %2\n" \ + " bnez %1, 0b\n" \ + RISCV_ACQUIRE_BARRIER \ + "1:\n" \ + : "=&r" (__ret), "=&r" (__rc), "+A" (*__ptr) \ + : "rJ" (__old), "rJ" (__new) \ + : "memory"); \ + break; \ + default: \ + ASSERT_UNREACHABLE(); \ + } \ + __ret; \ +}) + +#define cmpxchg_acquire (ptr, o, n) \ +({ \ + __typeof__(*(ptr)) _o_ = (o); \ + __typeof__(*(ptr)) _n_ = (n); \ + (__typeof__(*(ptr))) __cmpxchg_acquire((ptr), \ + _o_, _n_, sizeof(*(ptr))); \ +}) + +#define __cmpxchg_release (ptr, old, new, size) \ +({ \ + __typeof__(ptr) __ptr = (ptr); \ + __typeof__(*(ptr)) __old = (old); \ + __typeof__(*(ptr)) __new = (new); \ + __typeof__(*(ptr)) __ret; \ + register unsigned int __rc; \ + switch (size) { \ + case 4: \ + __asm__ __volatile__ ( \ + RISCV_RELEASE_BARRIER \ + "0: lr.w %0, %2\n" \ + " bne %0, %z3, 1f\n" \ + " sc.w %1, %z4, %2\n" \ + " bnez %1, 0b\n" \ + "1:\n" \ + : "=&r" (__ret), "=&r" (__rc), "+A" (*__ptr) \ + : "rJ" (__old), "rJ" (__new) \ + : "memory"); \ + break; \ + case 8: \ + __asm__ __volatile__ ( \ + RISCV_RELEASE_BARRIER \ + "0: lr.d %0, %2\n" \ + " bne %0, %z3, 1f\n" \ + " sc.d %1, %z4, %2\n" \ + " bnez %1, 0b\n" \ + "1:\n" \ + : "=&r" (__ret), "=&r" (__rc), "+A" (*__ptr) \ + : "rJ" (__old), "rJ" (__new) \ + : "memory"); \ + break; \ + default: \ + ASSERT_UNREACHABLE(); \ + } \ + __ret; \ +}) + +#define cmpxchg_release (ptr, o, n) \ +({ \ + __typeof__(*(ptr)) _o_ = (o); \ + __typeof__(*(ptr)) _n_ = (n); \ + (__typeof__(*(ptr))) __cmpxchg_release((ptr), \ + _o_, _n_, sizeof(*(ptr))); \ +}) + +#define __cmpxchg (ptr, old, new, size) \ +({ \ + __typeof__(ptr) __ptr = (ptr); \ + __typeof__(*(ptr)) __old = (__typeof__(*(ptr)))(old); \ + __typeof__(*(ptr)) __new = (__typeof__(*(ptr)))(new); \ + __typeof__(*(ptr)) __ret; \ + register unsigned int __rc; \ + switch (size) { \ + case 4: \ + __asm__ __volatile__ ( \ + "0: lr.w %0, %2\n" \ + " bne %0, %z3, 1f\n" \ + " sc.w.rl %1, %z4, %2\n" \ + " bnez %1, 0b\n" \ + " fence rw, rw\n" \ + "1:\n" \ + : "=&r" (__ret), "=&r" (__rc), "+A" (*__ptr) \ + : "rJ" (__old), "rJ" (__new) \ + : "memory"); \ + break; \ + case 8: \ + __asm__ __volatile__ ( \ + "0: lr.d %0, %2\n" \ + " bne %0, %z3, 1f\n" \ + " sc.d.rl %1, %z4, %2\n" \ + " bnez %1, 0b\n" \ + " fence rw, rw\n" \ + "1:\n" \ + : "=&r" (__ret), "=&r" (__rc), "+A" (*__ptr) \ + : "rJ" (__old), "rJ" (__new) \ + : "memory"); \ + break; \ + default: \ + ASSERT_UNREACHABLE(); \ + } \ + __ret; \ +}) + +#define cmpxchg (ptr, o, n) \ +({ \ + __typeof__(*(ptr)) _o_ = (o); \ + __typeof__(*(ptr)) _n_ = (n); \ + (__typeof__(*(ptr))) __cmpxchg((ptr), \ + _o_, _n_, sizeof(*(ptr))); \ +}) + +#define cmpxchg_local (ptr, o, n) \ + (__cmpxchg_relaxed((ptr), (o), (n), sizeof(*(ptr)))) + +#define cmpxchg32 (ptr, o, n) \ +({ \ + BUILD_BUG_ON(sizeof(*(ptr)) != 4); \ + cmpxchg((ptr), (o), (n)); \ +}) + +#define cmpxchg32_local (ptr, o, n) \ +({ \ + BUILD_BUG_ON(sizeof(*(ptr)) != 4); \ + cmpxchg_relaxed((ptr), (o), (n)) \ +}) + +#define cmpxchg64 (ptr, o, n) \ +({ \ + BUILD_BUG_ON(sizeof(*(ptr)) != 8); \ + cmpxchg((ptr), (o), (n)); \ +}) + +#define cmpxchg64_local (ptr, o, n) \ +({ \ + BUILD_BUG_ON(sizeof(*(ptr)) != 8); \ + cmpxchg_relaxed((ptr), (o), (n)); \ +}) + +#endif /* _ASM_RISCV_CMPXCHG_H */
Signature · 1 line
2.41.0
PATCH 40/57 xen/riscv: introduce asm/p2m.h
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/p2m.h | 105 +++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 xen/arch/riscv/include/asm/p2m.h
xen/arch/riscv/include/asm/p2m.h new file +105 -0
@@ -0,0 +1,105 @@ +#ifndef __ASM_RISCV_P2M_H__ +#define __ASM_RISCV_P2M_H__ + +#include <asm/page-bits.h> + +#define paddr_bits PADDR_BITS + +/* +* List of possible type for each page in the p2m entry. +* The number of available bit per page in the pte for this purpose is 4 bits. +* So it's possible to only have 16 fields. If we run out of value in the +* future, it's possible to use higher value for pseudo-type and don't store +* them in the p2m entry. +*/ +typedef enum { + p2m_invalid =0 ,/* Nothing mapped here */ + p2m_ram_rw,/* Normal read/write guest RAM */ + p2m_ram_ro,/* Read-only; writes are silently dropped */ + p2m_mmio_direct_dev,/* Read/write mapping of genuine Device MMIO area */ + p2m_mmio_direct_nc,/* Read/write mapping of genuine MMIO area non-cacheable */ + p2m_mmio_direct_c,/* Read/write mapping of genuine MMIO area cacheable */ + p2m_map_foreign_rw,/* Read/write RAM pages from foreign domain */ + p2m_map_foreign_ro,/* Read-only RAM pages from foreign domain */ + p2m_grant_map_rw,/* Read/write grant mapping */ + p2m_grant_map_ro,/* Read-only grant mapping */ +/* The types below are only used to decide the page attribute in the P2M */ + p2m_iommu_map_rw,/* Read/write iommu mapping */ + p2m_iommu_map_ro,/* Read-only iommu mapping */ + p2m_max_real_type,/* Types after this won't be store in the p2m */ +}p2m_type_t ; + +#include <xen/p2m-common.h> + +static inline int get_page_and_type (struct page_info *page, +struct domain *domain, +unsigned long type) +{ +BUG (); +return 1 ; +} + +/* Look up a GFN and take a reference count on the backing page. */ +typedef unsigned int p2m_query_t ; +#define P2M_ALLOC (1u<<0)/* Populate PoD and paged-out entries */ +#define P2M_UNSHARE (1u<<1)/* Break CoW sharing */ + +static inline struct page_info *get_page_from_gfn ( +struct domain *d,unsigned long gfn,p2m_type_t *t,p2m_query_t q) +{ +BUG (); +return NULL ; +} + +static inline void memory_type_changed (struct domain *d) +{ +BUG (); +} + + +static inline int guest_physmap_mark_populate_on_demand (struct domain *d,unsigned long gfn, +unsigned int order) +{ +BUG (); +return 1 ; +} + +static inline int guest_physmap_add_entry (struct domain *d, +gfn_t gfn, +mfn_t mfn, +unsigned long page_order, +p2m_type_t t) +{ +BUG (); +return 1 ; +} + +/* Untyped version for RAM only, for compatibility */ +static inline int __must_check +guest_physmap_add_page (struct domain *d,gfn_t gfn,mfn_t mfn, +unsigned int page_order) +{ +return guest_physmap_add_entry (d, gfn, mfn, page_order, p2m_ram_rw); +} + +static inline mfn_t gfn_to_mfn (struct domain *d,gfn_t gfn) +{ +BUG (); +return _mfn (0 ); +} + +static inline bool arch_acquire_resource_check (struct domain *d) +{ +/* +* The reference counting of foreign entries in set_foreign_p2m_entry() +* is supported on RISCV. +*/ +return true; +} + +static inline void p2m_altp2m_check (struct vcpu *v,uint16_t idx) +{ +/* Not supported on RISCV. */ +} + +#endif /* __ASM_RISCV_P2M_H__ */
Signature · 1 line
2.41.0
PATCH 50/57 xen/riscv: add minimal stuff to asm/smp.h to build full Xen
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/smp.h | 3 +++ 1 file changed, 3 insertions(+)
xen/arch/riscv/include/asm/smp.h +3 -0
@@ -17,4 +17,7 @@ DECLARE_PER_CPU(cpumask_var_t, cpu_core_mask);*/ #define park_offline_cpus false +/* TODO: need to be implemeted */ +#define smp_processor_id () (0) +#endif
Signature · 1 line
2.41.0
PATCH 41/57 xen/riscv: introduce asm/regs.h
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/regs.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 xen/arch/riscv/include/asm/regs.h
xen/arch/riscv/include/asm/regs.h new file +27 -0
@@ -0,0 +1,27 @@ +#ifndef __ARM_RISCV_REGS_H__ +#define __ARM_RISCV_REGS_H__ + +#ifndef __ASSEMBLY__ + +#include <xen/lib.h> +#include <asm/current.h> + +#define hyp_mode (r) (0) + +static inline bool guest_mode (const struct cpu_user_regs *r) +{ +BUG (); +} + +#endif + + +#endif /* __ARM_RISCV_REGS_H__ */ +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
Signature · 1 line
2.41.0
PATCH 47/57 xen/riscv: add required things to asm/current.h
In reply to Oleksii KurochkoAdd minimal requied things to be able to build full Xen.
--- xen/arch/riscv/include/asm/current.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
xen/arch/riscv/include/asm/current.h +17 -0
@@ -3,6 +3,21 @@#ifndef __ASM_CURRENT_H#define __ASM_CURRENT_H +#include <xen/percpu.h> + +#ifndef __ASSEMBLY__ + +struct vcpu ; + +/* Which VCPU is "current" on this PCPU. */ +DECLARE_PER_CPU(struct vcpu *, curr_vcpu); + +#define current (this_cpu(curr_vcpu)) +#define set_current (vcpu) do { current = (vcpu); } while (0) +#define get_cpu_current (cpu) (per_cpu(curr_vcpu, cpu)) + +#define guest_cpu_user_regs () (0) +#define switch_stack_and_jump (stack, fn) do { \ asm volatile ( \ "mv sp, %0\n" \
@@ -10,4 +25,6 @@unreachable (); \ } while ( false ) +#endif /* __ASSEMBLY__ */ +#endif /* __ASM_CURRENT_H */
Signature · 1 line
2.41.0
PATCH 36/57 xen/riscv: introduce asm/guest_access.h
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/guest_access.h | 29 +++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 xen/arch/riscv/include/asm/guest_access.h
xen/arch/riscv/include/asm/guest_access.h new file +29 -0
@@ -0,0 +1,29 @@ +#ifndef __ASM_RISCV_GUEST_ACCESS_H__ +#define __ASM_RISCV_GUEST_ACCESS_H__ + +#include <xen/mm.h> + +unsigned long raw_copy_to_guest (void *to,const void *from,unsigned len); +unsigned long raw_copy_from_guest (void *to,const void *from,unsigned len); + +#define __raw_copy_to_guest raw_copy_to_guest +#define __raw_copy_from_guest raw_copy_from_guest + +#define guest_handle_okay (hnd, nr) (1) +#define guest_handle_subrange_okay (hnd, first, last) (1) + +struct domain ; +unsigned long copy_to_guest_phys (struct domain *d, +paddr_t gpa, +void *buf, +unsigned int len); + +#endif /* __ASM_RISCV_GUEST_ACCESS_H__ */ +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
Signature · 1 line
2.41.0
PATCH 49/57 xen/riscv: add minimal stuff to asm/processor.h to build full Xen
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/processor.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
xen/arch/riscv/include/asm/processor.h +15 -0
@@ -12,6 +12,9 @@#ifndef __ASSEMBLY__ +/* TODO: need to be implemeted */ +#define get_processor_id () 0 +/* On stack VCPU state */ struct cpu_user_regs {
@@ -53,6 +56,18 @@ struct cpu_user_regsunsigned long pregs; }; +/* TODO: need to implement */ +#define cpu_to_core (_cpu) (0) +#define cpu_to_socket (_cpu) (0) + +static inline void cpu_relax (void ) +{ +int dummy; +/* In lieu of a halt instruction, induce a long-latency stall. */ + __asm__ __volatile__ ("div %0, %0, zero" :"=r" (dummy)); +barrier (); +} +static inline void wfi (void ) { __asm__ __volatile__ ("wfi" );
Signature · 1 line
2.41.0
PATCH 24/57 xen/riscv: introduce asm/percpu.h
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/percpu.h | 33 +++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 xen/arch/riscv/include/asm/percpu.h
xen/arch/riscv/include/asm/percpu.h new file +33 -0
@@ -0,0 +1,33 @@ +#ifndef __ASM_RISCV_PERCPU_H__ +#define __ASM_RISCV_PERCPU_H__ + +#ifndef __ASSEMBLY__ + +#include <xen/types.h> + +extern char __per_cpu_start[], __per_cpu_data_end[]; +extern unsigned long __per_cpu_offset[NR_CPUS ]; +void percpu_init_areas (void ); + +#define per_cpu (var, cpu) \ + (*RELOC_HIDE(&per_cpu__##var, __per_cpu_offset[cpu])) + +#define this_cpu (var) \ + (*RELOC_HIDE(&per_cpu__##var, __per_cpu_offset[get_processor_id()])) + +#define per_cpu_ptr (var, cpu) \ + (*RELOC_HIDE(var, __per_cpu_offset[cpu])) +#define this_cpu_ptr (var) \ + (*RELOC_HIDE(var, get_processor_id())) + +#endif + +#endif /* __ASM_RISCV_PERCPU_H__ */ +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
Signature · 1 line
2.41.0
PATCH 29/57 xen/riscv: introduce asm/hardirq.h
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/hardirq.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 xen/arch/riscv/include/asm/hardirq.h
xen/arch/riscv/include/asm/hardirq.h new file +26 -0
@@ -0,0 +1,26 @@ +#ifndef __ASM_RISCV_HARDIRQ_H +#define __ASM_RISCV_HARDIRQ_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_RISCV_HARDIRQ_H */ +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
Signature · 1 line
2.41.0
PATCH 51/57 xen: add RISCV support for pmu.h
In reply to Oleksii Kurochko--- xen/include/public/pmu.h | 2 ++ 1 file changed, 2 insertions(+)
xen/include/public/pmu.h +2 -0
@@ -11,6 +11,8 @@#include "arch-x86/pmu.h" #elif defined (__arm__) || defined (__aarch64__)#include "arch-arm.h" +#elif defined(__riscv) +#include "arch-riscv.h" #else #error "Unsupported architecture"#endif
Signature · 1 line
2.41.0
PATCH 28/57 xen/riscv: introduce asm/io.h
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/io.h | 132 ++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 xen/arch/riscv/include/asm/io.h
xen/arch/riscv/include/asm/io.h new file +132 -0
@@ -0,0 +1,132 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* {read,write}{b,w,l,q} based on arch/arm64/include/asm/io.h +* which was based on arch/arm/include/io.h +* +* Copyright (C) 1996-2000 Russell King +* Copyright (C) 2012 ARM Ltd. +* Copyright (C) 2014 Regents of the University of California +*/ + +#ifndef _ASM_RISCV_IO_H +#define _ASM_RISCV_IO_H + +#include <asm/byteorder.h> + +/* +* The RISC-V ISA doesn't yet specify how to query or modify PMAs, so we can't +* change the properties of memory regions. This should be fixed by the +* upcoming platform spec. +*/ +#define ioremap_nocache (addr, size) ioremap((addr), (size)) +#define ioremap_wc (addr, size) ioremap((addr), (size)) +#define ioremap_wt (addr, size) ioremap((addr), (size)) + +/* Generic IO read/write. These perform native-endian accesses. */ +#define __raw_writeb __raw_writeb +static inline void __raw_writeb (u8 val,volatile void __iomem *addr) +{ + asmvolatile ("sb %0, 0(%1)" : :"r" (val),"r" (addr)); +} + +#define __raw_writew __raw_writew +static inline void __raw_writew (u16 val,volatile void __iomem *addr) +{ + asmvolatile ("sh %0, 0(%1)" : :"r" (val),"r" (addr)); +} + +#define __raw_writel __raw_writel +static inline void __raw_writel (u32 val,volatile void __iomem *addr) +{ + asmvolatile ("sw %0, 0(%1)" : :"r" (val),"r" (addr)); +} + +#ifdef CONFIG_64BIT +#define __raw_writeq __raw_writeq +static inline void __raw_writeq (u64 val,volatile void __iomem *addr) +{ + asmvolatile ("sd %0, 0(%1)" : :"r" (val),"r" (addr)); +} +#endif + +#define __raw_readb __raw_readb +static inline u8 __raw_readb (const volatile void __iomem *addr) +{ +u8 val; + + asmvolatile ("lb %0, 0(%1)" :"=r" (val) :"r" (addr)); +return val; +} + +#define __raw_readw __raw_readw +static inline u16 __raw_readw (const volatile void __iomem *addr) +{ +u16 val; + + asmvolatile ("lh %0, 0(%1)" :"=r" (val) :"r" (addr)); +return val; +} + +#define __raw_readl __raw_readl +static inline u32 __raw_readl (const volatile void __iomem *addr) +{ +u32 val; + + asmvolatile ("lw %0, 0(%1)" :"=r" (val) :"r" (addr)); +return val; +} + +#ifdef CONFIG_64BIT +#define __raw_readq __raw_readq +static inline u64 __raw_readq (const volatile void __iomem *addr) +{ +u64 val; + + asmvolatile ("ld %0, 0(%1)" :"=r" (val) :"r" (addr)); +return val; +} +#endif + +/* +* Unordered I/O memory access primitives. These are even more relaxed than +* the relaxed versions, as they don't even order accesses between successive +* operations to the I/O regions. +*/ +#define readb_cpu (c) ({ u8 __r = __raw_readb(c); __r; }) +#define readw_cpu (c) ({ u16 __r = le16_to_cpu((__force __le16)__raw_readw(c)); __r; }) +#define readl_cpu (c) ({ u32 __r = le32_to_cpu((__force __le32)__raw_readl(c)); __r; }) + +#define writeb_cpu (v,c) ((void)__raw_writeb((v),(c))) +#define writew_cpu (v,c) ((void)__raw_writew((__force u16)cpu_to_le16(v),(c))) +#define writel_cpu (v,c) ((void)__raw_writel((__force u32)cpu_to_le32(v),(c))) + +#ifdef CONFIG_64BIT +#define readq_cpu (c) ({ u64 __r = le64_to_cpu((__force __le64)__raw_readq(c)); __r; }) +#define writeq_cpu (v,c) ((void)__raw_writeq((__force u64)cpu_to_le64(v),(c))) +#endif + +/* +* I/O memory access primitives. Reads are ordered relative to any +* following Normal memory access. Writes are ordered relative to any prior +* Normal memory access. The memory barriers here are necessary as RISC-V +* doesn't define any ordering between the memory space and the I/O space. +*/ +#define __io_br () do {} while (0) +#define __io_ar (v) __asm__ __volatile__ ("fence i,r" : : : "memory"); +#define __io_bw () __asm__ __volatile__ ("fence w,o" : : : "memory"); +#define __io_aw () do { } while (0) + +#define readb (c) ({ u8 __v; __io_br(); __v = readb_cpu(c); __io_ar(__v); __v; }) +#define readw (c) ({ u16 __v; __io_br(); __v = readw_cpu(c); __io_ar(__v); __v; }) +#define readl (c) ({ u32 __v; __io_br(); __v = readl_cpu(c); __io_ar(__v); __v; }) + +#define writeb (v,c) ({ __io_bw(); writeb_cpu((v),(c)); __io_aw(); }) +#define writew (v,c) ({ __io_bw(); writew_cpu((v),(c)); __io_aw(); }) +#define writel (v,c) ({ __io_bw(); writel_cpu((v),(c)); __io_aw(); }) + +#ifdef CONFIG_64BIT +#define readq (c) ({ u64 __v; __io_br(); __v = readq_cpu(c); __io_ar(__v); __v; }) +#define writeq (v,c) ({ __io_bw(); writeq_cpu((v),(c)); __io_aw(); }) +#endif + +#endif /* _ASM_RISCV_IO_H */
Signature · 1 line
2.41.0
PATCH 55/57 xen/riscv: enable full Xen build
In reply to Oleksii Kurochko--- xen/arch/riscv/Makefile | 16 +++++++++++++++- xen/arch/riscv/arch.mk | 4 ---- xen/arch/riscv/configs/tiny64_defconfig | 19 ++++++++++++++++++- xen/arch/riscv/stubs.c | 18 ------------------ 4 files changed, 33 insertions(+), 24 deletions(-)
xen/arch/riscv/Makefile +15 -1
@@ -12,10 +12,24 @@ $(TARGET): $(TARGET)-syms $(OBJCOPY) -O binary -S $< $@ $(TARGET)-syms: $(objtree)/prelink.o $(obj)/xen.lds - $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds -N $< $(build_id_linker) -o $@ + $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds -N $< \ + $(objtree)/common/symbols-dummy.o -o $(dot-target).0 + $(NM) -pa --format=sysv $(dot-target).0 \ + | $(objtree)/tools/symbols $(all_symbols) --sysv --sort \ + > $(dot-target).0.S + $(MAKE) $(build)=$(@D) $(dot-target).0.o + $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds -N $< \ + $(dot-target).0.o -o $(dot-target).1 + $(NM) -pa --format=sysv $(dot-target).1 \ + | $(objtree)/tools/symbols $(all_symbols) --sysv --sort \ + > $(dot-target).1.S + $(MAKE) $(build)=$(@D) $(dot-target).1.o + $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds -N $< $(build_id_linker) \ + $(dot-target).1.o -o $@ $(NM) -pa --format=sysv $@ \ | $(objtree)/tools/symbols --all-symbols --xensyms --sysv --sort \ > [email protected] + rm -f $(@D)/.$(@F).[0-9]* $(obj)/xen.lds: $(src)/xen.lds.S FORCE $(call if_changed_dep,cpp_lds_S)
xen/arch/riscv/arch.mk +0 -4
@@ -13,7 +13,3 @@ riscv-march-$(CONFIG_RISCV_ISA_C) := $(riscv-march-y)c # -mcmodel=medlow would force Xen into the lower half. CFLAGS += -march=$(riscv-march-y) -mstrict-align -mcmodel=medany - -# TODO: Drop override when more of the build is working -override ALL_OBJS-y = arch/$(SRCARCH)/built_in.o -override ALL_LIBS-y =
xen/arch/riscv/configs/tiny64_defconfig +18 -1
@@ -6,7 +6,24 @@ # CONFIG_HYPFS is not set # CONFIG_GRANT_TABLE is not set # CONFIG_SPECULATIVE_HARDEN_ARRAY is not set - +# CONFIG_ARGO is not set +# CONFIG_HYPFS_CONFIG is not set +# CONFIG_CORE_PARKING is not set +# CONFIG_DEBUG_TRACE is not set +# CONFIG_IOREQ_SERVER is not set +# CONFIG_CRASH_DEBUG is not setz +# CONFIG_KEXEC is not set +# CONFIG_LIVEPATCH is not set +# CONFIG_MEM_ACCESS is not set +# CONFIG_NUMA is not set +# CONFIG_PERF_COUNTERS is not set +# CONFIG_HAS_PMAP is not set +# CONFIG_TRACEBUFFER is not set +# CONFIG_XENOPROF is not set +# CONFIG_COMPAT is not set +# CONFIG_COVERAGE is not set +# CONFIG_UBSAN is not set +# CONFIG_NEEDS_LIBELF is not set CONFIG_RISCV_64=y CONFIG_DEBUG=y CONFIG_DEBUG_INFO=y
xen/arch/riscv/stubs.c +0 -18
@@ -417,21 +417,3 @@ int arch_get_paging_mempool_size(struct domain *d, uint64_t *size) {BUG (); } - -/* need for build until common code starts be buildable */ -unsigned long __read_mostly max_page; - -void printk (const char *fmt, ...) -{ -BUG (); -} - -void cf_check irq_actor_none(struct irq_desc *desc) -{ -BUG (); -} - -unsigned int cf_check irq_startup_none(struct irq_desc *desc) -{ -return 0 ; -}
Signature · 1 line
2.41.0
PATCH 34/57 xen/riscv: introduce asm/delay.h
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/delay.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 xen/arch/riscv/include/asm/delay.h
xen/arch/riscv/include/asm/delay.h new file +17 -0
@@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) 2009 Chen Liqin <[email protected]> +* Copyright (C) 2016 Regents of the University of California +*/ + +#ifndef _ASM_RISCV_DELAY_H +#define _ASM_RISCV_DELAY_H + +#include <xen/lib.h> + +static inline void udelay (unsigned long usecs) +{ +BUG (); +} + +#endif /* _ASM_RISCV_DELAY_H */
Signature · 1 line
2.41.0
PATCH 26/57 xen/riscv: introduce asm/atomic.h
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/atomic.h | 375 ++++++++++++++++++++++++++++ 1 file changed, 375 insertions(+) create mode 100644 xen/arch/riscv/include/asm/atomic.h
xen/arch/riscv/include/asm/atomic.h new file +375 -0
@@ -0,0 +1,375 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* Taken and modified from Linux. +* +* Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. +* Copyright (C) 2012 Regents of the University of California +* Copyright (C) 2017 SiFive +* Copyright (C) 2021 Vates SAS +*/ + +#ifndef _ASM_RISCV_ATOMIC_H +#define _ASM_RISCV_ATOMIC_H + +#include <xen/atomic.h> +#include <asm/cmpxchg.h> +#include <asm/fence.h> +#include <asm/io.h> +#include <asm/system.h> + +void __bad_atomic_size (void ); + +static always_inline void read_atomic_size(const volatile void *p, +void *res, +unsigned int size) +{ +switch ( size ) { +case 1 : *(uint8_t *)res =readb ((uint8_t *)p);break ; +case 2 : *(uint16_t *)res =readw ((uint16_t *)p);break ; +case 4 : *(uint32_t *)res =readl ((uint32_t *)p);break ; +case 8 : *(uint32_t *)res =readq ((uint64_t *)p);break ; +default :__bad_atomic_size ();break ; + } +} + +#define read_atomic (p) ({ \ + union { typeof(*p) val; char c[0]; } x_; \ + read_atomic_size(p, x_.c, sizeof(*p)); \ + x_.val; \ +}) + + +#define write_atomic (p, x) ({ \ + typeof(*p) __x = (x); \ + switch ( sizeof(*p) ) { \ + 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 */ +#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; \ + } \ +}) + +/* +* __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))) + +#define READ_ONCE (x) (*(const volatile __unqual_scalar_typeof(x) *)&(x)) +#define WRITE_ONCE (x, val) \ + do { \ + *(volatile typeof(x) *)&(x) = (val); \ + } while (0) + +#define __atomic_acquire_fence () \ + __asm__ __volatile__(RISCV_ACQUIRE_BARRIER "" ::: "memory") + +#define __atomic_release_fence () \ + __asm__ __volatile__(RISCV_RELEASE_BARRIER "" ::: "memory"); + +static inline int atomic_read (const atomic_t *v) +{ +return READ_ONCE (v->counter); +} + +static inline int _atomic_read (atomic_t v) +{ +return v.counter; +} + +static inline void atomic_set (atomic_t *v,int i) +{ +WRITE_ONCE (v->counter, i); +} + +static inline void _atomic_set (atomic_t *v,int i) +{ + v->counter = i; +} + +static inline int atomic_sub_and_test (int i,atomic_t *v) +{ +return atomic_sub_return (i, v) ==0 ; +} + +static inline void atomic_inc (atomic_t *v) +{ +atomic_add (1 , v); +} + +static inline int atomic_inc_return (atomic_t *v) +{ +return atomic_add_return (1 , v); +} + +static inline void atomic_dec (atomic_t *v) +{ +atomic_sub (1 , v); +} + +static inline int atomic_dec_return (atomic_t *v) +{ +return atomic_sub_return (1 , v); +} + + +static inline int atomic_dec_and_test (atomic_t *v) +{ +return atomic_sub_return (1 , v) ==0 ; +} + +static inline int atomic_add_negative (int i,atomic_t *v) +{ +return atomic_add_return (i, v) <0 ; +} + +static inline int atomic_inc_and_test (atomic_t *v) +{ +return atomic_add_return (1 , v) ==0 ; +} + +/* +* First, the atomic ops that have no ordering constraints and therefor don't +* have the AQ or RL bits set. These don't return anything, so there's only +* one version to worry about. +*/ +#define ATOMIC_OP (op, asm_op,I , asm_type, c_type, prefix) \ +static inline \ +void atomic##prefix##_##op(c_type i, atomic##prefix##_t *v) \ +{ \ + __asm__ __volatile__ ( \ + " amo" #asm_op "." #asm_type " zero, %1, %0" \ + : "+A" (v->counter) \ + : "r" (I) \ + : "memory"); \ +} \ + +#define ATOMIC_OPS (op, asm_op,I ) \ + ATOMIC_OP (op, asm_op, I, w, int, ) + +ATOMIC_OPS(add, add, i) +ATOMIC_OPS(sub, add, -i) +ATOMIC_OPS(and, and, i) +ATOMIC_OPS( or, or, i) +ATOMIC_OPS(xor, xor, i) + +#undef ATOMIC_OP +#undef ATOMIC_OPS + +/* +* Atomic ops that have ordered, relaxed, acquire, and release variants. +* There's two flavors of these: the arithmatic ops have both fetch and return +* versions, while the logical ops only have fetch versions. +*/ +#define ATOMIC_FETCH_OP (op, asm_op,I , asm_type, c_type, prefix) \ +static inline \ +c_type atomic##prefix##_fetch_##op##_relaxed(c_type i, \ + atomic##prefix##_t *v) \ +{ \ + register c_type ret; \ + __asm__ __volatile__ ( \ + " amo" #asm_op "." #asm_type " %1, %2, %0" \ + : "+A" (v->counter), "=r" (ret) \ + : "r" (I) \ + : "memory"); \ + return ret; \ +} \ +static inline \ +c_type atomic##prefix##_fetch_##op(c_type i, atomic##prefix##_t *v) \ +{ \ + register c_type ret; \ + __asm__ __volatile__ ( \ + " amo" #asm_op "." #asm_type ".aqrl %1, %2, %0" \ + : "+A" (v->counter), "=r" (ret) \ + : "r" (I) \ + : "memory"); \ + return ret; \ +} + +#define ATOMIC_OP_RETURN (op, asm_op, c_op,I , asm_type, c_type, prefix) \ +static inline \ +c_type atomic##prefix##_##op##_return_relaxed(c_type i, \ + atomic##prefix##_t *v) \ +{ \ + return atomic##prefix##_fetch_##op##_relaxed(i, v) c_op I; \ +} \ +static inline \ +c_type atomic##prefix##_##op##_return(c_type i, atomic##prefix##_t *v) \ +{ \ + return atomic##prefix##_fetch_##op(i, v) c_op I; \ +} + +#define ATOMIC_OPS (op, asm_op, c_op,I ) \ + ATOMIC_FETCH_OP( op, asm_op, I, w, int, ) \ + ATOMIC_OP_RETURN(op, asm_op, c_op, I, w, int, ) + +ATOMIC_OPS(add, add, +, i) +ATOMIC_OPS(sub, add, +, -i) + +#define atomic_add_return_relaxed atomic_add_return_relaxed +#define atomic_sub_return_relaxed atomic_sub_return_relaxed +#define atomic_add_return atomic_add_return +#define atomic_sub_return atomic_sub_return + +#define atomic_fetch_add_relaxed atomic_fetch_add_relaxed +#define atomic_fetch_sub_relaxed atomic_fetch_sub_relaxed +#define atomic_fetch_add atomic_fetch_add +#define atomic_fetch_sub atomic_fetch_sub + +#undef ATOMIC_OPS + +#define ATOMIC_OPS (op, asm_op,I ) \ + ATOMIC_FETCH_OP(op, asm_op, I, w, int, ) + +ATOMIC_OPS(and, and, i) +ATOMIC_OPS( or, or, i) +ATOMIC_OPS(xor, xor, i) + +#define atomic_fetch_and_relaxed atomic_fetch_and_relaxed +#define atomic_fetch_or_relaxed atomic_fetch_or_relaxed +#define atomic_fetch_xor_relaxed atomic_fetch_xor_relaxed +#define atomic_fetch_and atomic_fetch_and +#define atomic_fetch_or atomic_fetch_or +#define atomic_fetch_xor atomic_fetch_xor + +#undef ATOMIC_OPS + +#undef ATOMIC_FETCH_OP +#undef ATOMIC_OP_RETURN + +/* This is required to provide a full barrier on success. */ +static inline int atomic_add_unless (atomic_t *v,int a,int u) +{ +int prev, rc; + + __asm__ __volatile__ ( +"0: lr.w %[p], %[c]\n" +" beq %[p], %[u], 1f\n" +" add %[rc], %[p], %[a]\n" +" sc.w.rl %[rc], %[rc], %[c]\n" +" bnez %[rc], 0b\n" +" fence rw, rw\n" +"1:\n" + : [p]"=&r" (prev), [rc]"=&r" (rc), [c]"+A" (v->counter) + : [a]"r" (a), [u]"r" (u) + :"memory" ); +return prev; +} +#define atomic_fetch_add_unless atomic_fetch_add_unless + +/* +* atomic_{cmp,}xchg is required to have exactly the same ordering semantics as +* {cmp,}xchg and the operations that return, so they need a full barrier. +*/ +#define ATOMIC_OP (c_t, prefix, size) \ +static inline \ +c_t atomic##prefix##_xchg_relaxed(atomic##prefix##_t *v, c_t n) \ +{ \ + return __xchg_relaxed(&(v->counter), n, size); \ +} \ +static inline \ +c_t atomic##prefix##_xchg_acquire(atomic##prefix##_t *v, c_t n) \ +{ \ + return __xchg_acquire(&(v->counter), n, size); \ +} \ +static inline \ +c_t atomic##prefix##_xchg_release(atomic##prefix##_t *v, c_t n) \ +{ \ + return __xchg_release(&(v->counter), n, size); \ +} \ +static inline \ +c_t atomic##prefix##_xchg(atomic##prefix##_t *v, c_t n) \ +{ \ + return __xchg(&(v->counter), n, size); \ +} \ +static inline \ +c_t atomic##prefix##_cmpxchg_relaxed(atomic##prefix##_t *v, \ + c_t o, c_t n) \ +{ \ + return __cmpxchg_relaxed(&(v->counter), o, n, size); \ +} \ +static inline \ +c_t atomic##prefix##_cmpxchg_acquire(atomic##prefix##_t *v, \ + c_t o, c_t n) \ +{ \ + return __cmpxchg_acquire(&(v->counter), o, n, size); \ +} \ +static inline \ +c_t atomic##prefix##_cmpxchg_release(atomic##prefix##_t *v, \ + c_t o, c_t n) \ +{ \ + return __cmpxchg_release(&(v->counter), o, n, size); \ +} \ +static inline \ +c_t atomic##prefix##_cmpxchg(atomic##prefix##_t *v, c_t o, c_t n) \ +{ \ + return __cmpxchg(&(v->counter), o, n, size); \ +} + +#define ATOMIC_OPS () \ + ATOMIC_OP(int, , 4) + +ATOMIC_OPS() + +#define atomic_xchg_relaxed atomic_xchg_relaxed +#define atomic_xchg_acquire atomic_xchg_acquire +#define atomic_xchg_release atomic_xchg_release +#define atomic_xchg atomic_xchg +#define atomic_cmpxchg_relaxed atomic_cmpxchg_relaxed +#define atomic_cmpxchg_acquire atomic_cmpxchg_acquire +#define atomic_cmpxchg_release atomic_cmpxchg_release +#define atomic_cmpxchg atomic_cmpxchg + +#undef ATOMIC_OPS +#undef ATOMIC_OP + +static inline int atomic_sub_if_positive (atomic_t *v,int offset) +{ +int prev, rc; + + __asm__ __volatile__ ( +"0: lr.w %[p], %[c]\n" +" sub %[rc], %[p], %[o]\n" +" bltz %[rc], 1f\n" +" sc.w.rl %[rc], %[rc], %[c]\n" +" bnez %[rc], 0b\n" +" fence rw, rw\n" +"1:\n" + : [p]"=&r" (prev), [rc]"=&r" (rc), [c]"+A" (v->counter) + : [o]"r" (offset) + :"memory" ); +return prev - offset; +} + +#define atomic_dec_if_positive (v) atomic_sub_if_positive(v, 1) + +#endif /* _ASM_RISCV_ATOMIC_H */
Signature · 1 line
2.41.0
PATCH 33/57 xen/riscv: introduce asm/altp2m.h
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/altp2m.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 xen/arch/riscv/include/asm/altp2m.h
xen/arch/riscv/include/asm/altp2m.h new file +28 -0
@@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Alternate p2m +* +* Copyright (c) 2014, Intel Corporation. +*/ + +#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 */
Signature · 1 line
2.41.0
PATCH 31/57 xen/riscv: define bug frame tables in xen.lds.S
In reply to Oleksii Kurochko--- xen/arch/riscv/xen.lds.S | 10 ++++++++++ 1 file changed, 10 insertions(+)
xen/arch/riscv/xen.lds.S +10 -0
@@ -40,6 +40,16 @@ SECTIONS . = ALIGN(PAGE_SIZE); .rodata : { _srodata = .; /* Read-only data */ + /* Bug frames table */ + __start_bug_frames = .; + *(.bug_frames.0) + __stop_bug_frames_0 = .; + *(.bug_frames.1) + __stop_bug_frames_1 = .; + *(.bug_frames.2) + __stop_bug_frames_2 = .; + *(.bug_frames.3) + __stop_bug_frames_3 = .; *(.rodata) *(.rodata.*) *(.data.rel.ro)
Signature · 1 line
2.41.0
PATCH 19/57 xen/riscv: introduce asm/setup.h
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/setup.h | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 xen/arch/riscv/include/asm/setup.h
xen/arch/riscv/include/asm/setup.h new file +6 -0
@@ -0,0 +1,6 @@ +#ifndef __ASM_RISCV_SETUP_H__ +#define __ASM_RISCV_SETUP_H__ + +#define max_init_domid (0) + +#endif /* __ASM_RISCV_SETUP_H__ */
Signature · 1 line
2.41.0
PATCH 25/57 xen/riscv: introduce asm/smp.h
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/smp.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 xen/arch/riscv/include/asm/smp.h
xen/arch/riscv/include/asm/smp.h new file +20 -0
@@ -0,0 +1,20 @@ +#ifndef __ASM_RISCV_SMP_H +#define __ASM_RISCV_SMP_H + +#ifndef __ASSEMBLY__ +#include <xen/cpumask.h> +#include <xen/percpu.h> +#endif + +DECLARE_PER_CPU (cpumask_var_t, cpu_sibling_mask); +DECLARE_PER_CPU (cpumask_var_t, cpu_core_mask); + +#define cpu_is_offline (cpu) unlikely(!cpu_online(cpu)) + +/* +* Do we, for platform reasons, need to actually keep CPUs online when we +* would otherwise prefer them to be off? +*/ +#define park_offline_cpus false + +#endif
Signature · 1 line
2.41.0
PATCH 43/57 xen/riscv: introduce asm/time.h
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/time.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 xen/arch/riscv/include/asm/time.h
xen/arch/riscv/include/asm/time.h new file +20 -0
@@ -0,0 +1,20 @@ +#ifndef __ASM_RISCV_TIME_H__ +#define __ASM_RISCV_TIME_H__ + +#include <xen/lib.h> +#include <asm/csr.h> +#include <asm/processor.h> + +struct vcpu ; + +/* TODO: implement */ +static inline void force_update_vcpu_system_time (struct vcpu *v) {BUG (); } + +typedef unsigned long cycles_t ; + +static inline cycles_t get_cycles (void ) +{ +return csr_read (CSR_TIME ); +} + +#endif /* __ASM_RISCV_TIME_H__ */
Signature · 1 line
2.41.0
PATCH 21/57 xen/riscv: introduce asm/xenoprof.h
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/xenoprof.h | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 xen/arch/riscv/include/asm/xenoprof.h
xen/arch/riscv/include/asm/xenoprof.h new file +4 -0
@@ -0,0 +1,4 @@ +#ifndef __ASM_RISCV_XENOPROF_H__ +#define __ASM_RISCV_XENOPROF_H__ + +#endif /* __ASM_RISCV_XENOPROF_H__ */
Signature · 1 line
2.41.0
PATCH 23/57 xen/riscv: introduce flushtlb.h
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/flushtlb.h | 31 +++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 xen/arch/riscv/include/asm/flushtlb.h
xen/arch/riscv/include/asm/flushtlb.h new file +31 -0
@@ -0,0 +1,31 @@ +#ifndef __ASM_RISCV_FLUSHTLB_H__ +#define __ASM_RISCV_FLUSHTLB_H__ + +#include <xen/cpumask.h> + +/* +* Filter the given set of CPUs, removing those that definitely flushed their +* TLB since @page_timestamp. +*/ +/* XXX lazy implementation just doesn't clear anything.... */ +static inline void tlbflush_filter (cpumask_t *mask,uint32_t page_timestamp) {} + +#define tlbflush_current_time () (0) + +static inline void page_set_tlbflush_timestamp (struct page_info *page) +{ +BUG (); +} + +/* Flush specified CPUs' TLBs */ +void arch_flush_tlb_mask (const cpumask_t *mask); + +#endif /* __ASM_RISCV_FLUSHTLB_H__ */ +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
Signature · 1 line
2.41.0
PATCH 30/57 xen/riscv: introduce div64.h
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/div64.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 xen/arch/riscv/include/asm/div64.h
xen/arch/riscv/include/asm/div64.h new file +22 -0
@@ -0,0 +1,22 @@ +#ifndef __ASM_RISCV_DIV64 +#define __ASM_RISCV_DIV64 + +#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: +*/
Signature · 1 line
2.41.0
PATCH 53/57 xen/riscv: add minimal stuff to asm/mm.h to build full Xen
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/mm.h | 265 +++++++++++++++++++++++++++++++- 1 file changed, 263 insertions(+), 2 deletions(-)
xen/arch/riscv/include/asm/mm.h +263 -2
@@ -3,10 +3,271 @@#ifndef _ASM_RISCV_MM_H#define _ASM_RISCV_MM_H +#include <public/xen.h> +#include <xen/pdx.h> +#include <xen/types.h> + +#include <asm/page.h> #include <asm/page-bits.h> -#define pfn_to_paddr (pfn) ((paddr_t)(pfn) << PAGE_SHIFT) -#define paddr_to_pfn (pa) ((unsigned long)((pa) >> PAGE_SHIFT)) +#define paddr_to_pdx (pa) mfn_to_pdx(maddr_to_mfn(pa)) +#define gfn_to_gaddr (gfn) pfn_to_paddr(gfn_x(gfn)) +#define gaddr_to_gfn (ga) _gfn(paddr_to_pfn(ga)) +#define mfn_to_maddr (mfn) pfn_to_paddr(mfn_x(mfn)) +#define maddr_to_mfn (ma) _mfn(paddr_to_pfn(ma)) +#define vmap_to_mfn (va) maddr_to_mfn(virt_to_maddr((vaddr_t)va)) +#define vmap_to_page (va) mfn_to_page(vmap_to_mfn(va)) +#define paddr_to_pdx (pa) mfn_to_pdx(maddr_to_mfn(pa)) +#define gfn_to_gaddr (gfn) pfn_to_paddr(gfn_x(gfn)) +#define gaddr_to_gfn (ga) _gfn(paddr_to_pfn(ga)) +#define mfn_to_maddr (mfn) pfn_to_paddr(mfn_x(mfn)) +#define maddr_to_mfn (ma) _mfn(paddr_to_pfn(ma)) +#define vmap_to_mfn (va) maddr_to_mfn(virt_to_maddr((vaddr_t)va)) +#define vmap_to_page (va) mfn_to_page(vmap_to_mfn(va)) + +#define virt_to_maddr (va) ((paddr_t)((vaddr_t)(va) & PADDR_MASK)) +#define maddr_to_virt (pa) ((void *)((paddr_t)(pa) | XEN_VIRT_START)) + +/* Convert between Xen-heap virtual addresses and machine frame numbers. */ +#define __virt_to_mfn (va) (virt_to_maddr(va) >> PAGE_SHIFT) +#define __mfn_to_virt (mfn) (maddr_to_virt((paddr_t)(mfn) << PAGE_SHIFT)) + +/* Convert between Xen-heap virtual addresses and page-info structures. */ +static inline struct page_info *virt_to_page (const void *v) +{ +BUG (); +return NULL ; +} + +/* +* We define non-underscored wrappers for above conversion functions. +* These are overriden in various source files while underscored version +* remain intact. +*/ +#define virt_to_mfn (va) __virt_to_mfn(va) +#define mfn_to_virt (mfn) __mfn_to_virt(mfn) + +struct page_info +{ +/* Each frame can be threaded onto a doubly-linked list. */ +struct page_list_entry list; + +/* Reference count and various PGC_xxx flags and fields. */ +unsigned long count_info; + +/* Context-dependent fields follow... */ +union { +/* Page is in use: ((count_info & PGC_count_mask) != 0). */ +struct { +/* Type reference count and various PGT_xxx flags and fields. */ +unsigned long type_info; + } inuse; +/* Page is on a free list: ((count_info & PGC_count_mask) == 0). */ +union { +struct { +/* +* Index of the first *possibly* unscrubbed page in the buddy. +* One more bit than maximum possible order to accommodate +* INVALID_DIRTY_IDX. +*/ +#define INVALID_DIRTY_IDX ((1UL << (MAX_ORDER + 1)) - 1) +unsigned long first_dirty:MAX_ORDER +1 ; + +/* Do TLBs need flushing for safety before next page use? */ +bool need_tlbflush:1 ; + +#define BUDDY_NOT_SCRUBBING 0 +#define BUDDY_SCRUBBING 1 +#define BUDDY_SCRUB_ABORT 2 +unsigned long scrub_state:2 ; + }; + +unsigned long val; + } free; + + } u; + +union { +/* Page is in use, but not as a shadow. */ +struct { +/* Owner of this page (zero if page is anonymous). */ +struct domain *domain; + } inuse; + +/* Page is on a free list. */ +struct { +/* Order-size of the free chunk this page is the head of. */ +unsigned int order; + } free; + + } v; + +union { +/* +* Timestamp from 'TLB clock', used to avoid extra safety flushes. +* Only valid for: a) free pages, and b) pages with zero type count +*/ +u32 tlbflush_timestamp; + }; +u64 pad; +}; + +#define frame_table ((struct page_info *)FRAMETABLE_VIRT_START) + +/* PDX of the first page in the frame table. */ +extern unsigned long frametable_base_pdx; + +/* Convert between machine frame numbers and page-info structures. */ +#define mfn_to_page (mfn) \ + (frame_table + (mfn_to_pdx(mfn) - frametable_base_pdx)) +#define page_to_mfn (pg) \ + pdx_to_mfn((unsigned long)((pg) - frame_table) + frametable_base_pdx) + +static inline void *page_to_virt (const struct page_info *pg) +{ +return mfn_to_virt (mfn_x (page_to_mfn (pg))); +} + +/* +* Common code requires get_page_type and put_page_type. +* We don't care about typecounts so we just do the minimum to make it +* happy. +*/ +static inline int get_page_type (struct page_info *page,unsigned long type) +{ +return 1 ; +} + +static inline void put_page_type (struct page_info *page) +{ +return ; +} + +/* TODO */ +static inline bool get_page_nr (struct page_info *page,const struct domain *domain, +unsigned long nr) +{ +BUG (); +} +static inline void put_page_nr (struct page_info *page,unsigned long nr) +{ +BUG (); +} + +static inline void put_page_and_type (struct page_info *page) +{ +put_page_type (page); +put_page (page); +} + +/* +* RISCV does not have an M2P, but common code expects a handful of +* M2P-related defines and functions. Provide dummy versions of these. +*/ +#define INVALID_M2P_ENTRY (~0UL) +#define SHARED_M2P_ENTRY (~0UL - 1UL) +#define SHARED_M2P (_e) ((_e) == SHARED_M2P_ENTRY) + +/* Xen always owns P2M on PPC */ +#define set_gpfn_from_mfn (mfn, pfn) do { (void) (mfn), (void)(pfn); } while (0) +#define mfn_to_gfn (d, mfn) ((void)(d), _gfn(mfn_x(mfn))) + +#define PDX_GROUP_SHIFT (16 + 5) + +static inline unsigned long domain_get_maximum_gpfn (struct domain *d) +{ +BUG (); +return 0 ; +} + +static inline long arch_memory_op (int op,XEN_GUEST_HANDLE_PARAM (void ) arg) +{ +BUG (); +return 0 ; +} + +/* +* On RISCV, all the RAM is currently direct mapped in Xen. +* Hence return always true. +*/ +static inline bool arch_mfns_in_directmap (unsigned long mfn,unsigned long nr) +{ +return true; +} + +#define PG_shift (idx) (BITS_PER_LONG - (idx)) +#define PG_mask (x, idx) (x ## UL << PG_shift(idx)) + +#define PGT_none PG_mask(0, 1)/* no special uses of this page */ +#define PGT_writable_page PG_mask(1, 1)/* has writable mappings? */ +#define PGT_type_mask PG_mask(1, 1)/* Bits 31 or 63. */ + +/* Count of uses of this frame as its current type. */ +#define PGT_count_width PG_shift(2) +#define PGT_count_mask ((1UL<<PGT_count_width)-1) + +/* +* Page needs to be scrubbed. Since this bit can only be set on a page that is +* free (i.e. in PGC_state_free) we can reuse PGC_allocated bit. +*/ +#define _PGC_need_scrub _PGC_allocated +#define PGC_need_scrub PGC_allocated + +// /* Cleared when the owning guest 'frees' this page. */ +#define _PGC_allocated PG_shift(1) +#define PGC_allocated PG_mask(1, 1) +/* Page is Xen heap? */ +#define _PGC_xen_heap PG_shift(2) +#define PGC_xen_heap PG_mask(1, 2) +#ifdef CONFIG_STATIC_MEMORY +/* Page is static memory */ +#define _PGC_static PG_shift(3) +#define PGC_static PG_mask(1, 3) +#else +#define PGC_static 0 +#endif +/* ... */ +/* Page is broken? */ +#define _PGC_broken PG_shift(7) +#define PGC_broken PG_mask(1, 7) +/* Mutually-exclusive page states: { inuse, offlining, offlined, free }. */ +#define PGC_state PG_mask(3, 9) +#define PGC_state_inuse PG_mask(0, 9) +#define PGC_state_offlining PG_mask(1, 9) +#define PGC_state_offlined PG_mask(2, 9) +#define PGC_state_free PG_mask(3, 9) +// #define page_state_is(pg, st) (((pg)->count_info&PGC_state) == PGC_state_##st) + +/* Count of references to this frame. */ +#define PGC_count_width PG_shift(9) +#define PGC_count_mask ((1UL<<PGC_count_width)-1) + +#define page_state_is (pg, st) (((pg)->count_info&PGC_state) == PGC_state_##st) + +#define _PGC_extra PG_shift(10) +#define PGC_extra PG_mask(1, 10) + +#define is_xen_heap_page (page) ((page)->count_info & PGC_xen_heap) +#define is_xen_heap_mfn (mfn) \ + (mfn_valid(mfn) && is_xen_heap_page(mfn_to_page(mfn))) + +#define is_xen_fixed_mfn (mfn) \ + ((mfn_to_maddr(mfn) >= virt_to_maddr(&_start)) && \ + (mfn_to_maddr(mfn) <= virt_to_maddr((vaddr_t)_end - 1))) + +#define page_get_owner (_p) (_p)->v.inuse.domain +#define page_set_owner (_p,_d) ((_p)->v.inuse.domain = (_d)) + +/* TODO: implement */ +#define mfn_valid (mfn) ({ (void) (mfn); 0; }) +// #define max_page (0UL) + +#define mfn_to_gfn (d, mfn) ((void)(d), _gfn(mfn_x(mfn))) + +#define domain_set_alloc_bitsize (d) ((void)0) +#define domain_clamp_alloc_bitsize (d, b) (b) + +#define PFN_ORDER (_pfn) ((_pfn)->v.free.order)extern unsigned char cpu0_boot_stack[];
Signature · 1 line
2.41.0
PATCH 20/57 xen/riscv: introduce asm/system.h
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/system.h | 83 +++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 xen/arch/riscv/include/asm/system.h
xen/arch/riscv/include/asm/system.h new file +83 -0
@@ -0,0 +1,83 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef _ASM_RISCV_BARRIER_H +#define _ASM_RISCV_BARRIER_H + +#include <asm/csr.h> +// #include <xen/lib.h> + +#ifndef __ASSEMBLY__ + +#define RISCV_FENCE (p, s) \ + __asm__ __volatile__ ("fence " #p "," #s : : : "memory") + +/* These barriers need to enforce ordering on both devices or memory. */ +#define mb () RISCV_FENCE(iorw,iorw) +#define rmb () RISCV_FENCE(ir,ir) +#define wmb () RISCV_FENCE(ow,ow) + +/* These barriers do not need to enforce ordering on devices, just memory. */ +#define smp_mb () RISCV_FENCE(rw,rw) +#define smp_rmb () RISCV_FENCE(r,r) +#define smp_wmb () RISCV_FENCE(w,w) +#define smp_mb__before_atomic () smp_mb() +#define smp_mb__after_atomic () smp_mb() + +/* +#define __smp_store_release(p, v) \ +do { \ +compiletime_assert_atomic_type(*p); \ +RISCV_FENCE(rw,w); \ +WRITE_ONCE(*p, v); \ +} while (0) + +#define __smp_load_acquire(p) \ +({ \ +typeof(*p) ___p1 = READ_ONCE(*p); \ +compiletime_assert_atomic_type(*p); \ +RISCV_FENCE(r,rw); \ +___p1; \ +}) +*/ + +static inline unsigned long local_save_flags (void ) +{ +return csr_read (sstatus); +} + +static inline void local_irq_enable (void ) +{ +csr_set (sstatus,SSTATUS_SIE ); +} + +static inline void local_irq_disable (void ) +{ +csr_clear (sstatus,SSTATUS_SIE ); +} + +#define local_irq_save (x) \ +({ \ + x = csr_read_clear(CSR_SSTATUS, SSTATUS_SIE); \ + local_irq_disable(); \ +}) + +static inline void local_irq_restore (unsigned long flags) +{ +csr_set (CSR_SSTATUS , flags &SSTATUS_SIE ); +} + +static inline int local_irq_is_enabled (void ) +{ +unsigned long flags =local_save_flags (); + +return flags &SSTATUS_SIE ; +} + +#define arch_fetch_and_add (x, v) __sync_fetch_and_add(x, v) + +// extern struct vcpu *__context_switch(struct vcpu *prev, struct vcpu *next); + +#endif /* __ASSEMBLY__ */ + + +#endif /* _ASM_RISCV_BARRIER_H */
Signature · 1 line
2.41.0
PATCH 57/57 xxxen/riscv: WIP ( need advise )
In reply to Oleksii KurochkoThese changes are needed only to make GitLab CI happy is it doesn't take into account tiny64_defconfig where unnecessary configs are disabled.
I tried different approaches to deal with it:
1. Override EXTRA_XEN_CONFIG and EXTRA_FIXED_RANDCONFIG in the following way:
EXTRA_XEN_CONFIG:
CONFIG_1=n
CONFIG_2=n
...
2. Override in arch-specific KConfig:
CONFIG_1:
default nEach option doesn't work for me fully.
Could you please suggest other options or more correct way?
--- xen/arch/riscv/include/asm/asm_defns.h | 44 +++++++++++++++++ xen/arch/riscv/include/asm/grant_table.h | 57 ++++++++++++++++++++++ xen/arch/riscv/include/asm/guest_atomics.h | 16 +++++- xen/arch/riscv/include/asm/livepatch.h | 0 xen/arch/riscv/include/asm/mm.h | 5 ++ xen/arch/riscv/include/asm/p2m.h | 24 +++++++++ xen/arch/riscv/include/asm/page.h | 16 ++++++ xen/arch/riscv/include/asm/perfc_defn.h | 0 xen/arch/riscv/mm.c | 33 +++++++++++++ 9 files changed, 194 insertions(+), 1 deletion(-) create mode 100644 xen/arch/riscv/include/asm/asm_defns.h create mode 100644 xen/arch/riscv/include/asm/livepatch.h create mode 100644 xen/arch/riscv/include/asm/perfc_defn.h
xen/arch/riscv/include/asm/asm_defns.h new file +44 -0
@@ -0,0 +1,44 @@ +#ifndef __ARM_ASM_DEFNS_H__ +#define __ARM_ASM_DEFNS_H__ + +#ifndef COMPILE_OFFSETS +/* NB. Auto-generated from arch/.../asm-offsets.c */ +#include <asm/asm-offsets.h> +#endif +#include <asm/processor.h> + +/* Macros for generic assembly code */ +#if defined(CONFIG_RISCV_32 ) +# define __OP32 +# define ASM_REG (index) asm("r" # index) +#elif defined(CONFIG_RISCV_64 ) +# define __OP32 "w" +/* +* Clang < 8.0 doesn't support register alllocation using the syntax rN. +* See https://reviews.llvm.org/rL328829. +*/ +# define ASM_REG (index) asm("x" # index) +#else +# error "unknown ARM variant" +#endif + +#define RODATA_STR (label, msg) \ +.pushsection .rodata.str, "aMS", %progbits, 1 ; \ +label: .asciz msg; \ +.popsection + +#define ASM_INT (label, val) \ + .p2align 2; \ +label: .long (val); \ + .size label, . - label; \ + .type label, %object + +#endif /* __ARM_ASM_DEFNS_H__ */ +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
xen/arch/riscv/include/asm/grant_table.h +57 -0
62 lines not on this page · raw message
xen/arch/riscv/include/asm/guest_atomics.h +15 -1
@@ -35,9 +35,23 @@ guest_testop(test_and_change_bit)#undef guest_testop -#define guest_test_bit (d, nr, p) ((void)(d), test_bit(nr, p)) +#define guest_cmpxchg (d, ptr, o, n) \ + ((__typeof__(*(ptr)))__guest_cmpxchg(d, ptr, \ + (unsigned long)(o),\ + (unsigned long)(n),\ + sizeof (*(ptr)))) + +static always_inline unsigned long __guest_cmpxchg (struct domain *d, +volatile void *ptr, +unsigned long old, +unsigned long new, +unsigned int size) +{ +BUG (); +} +#endif /* __ASM_RISCV_GUEST_ATOMICS_H */ /* * Local variables:
xen/arch/riscv/include/asm/livepatch.h new file +0 -0
xen/arch/riscv/include/asm/mm.h +5 -0
@@ -276,4 +276,9 @@ void setup_initial_pagetables(void);void enable_mmu (void );void cont_after_mmu_is_enabled (void ); +static inline gfn_t page_get_xenheap_gfn (const struct page_info *p) +{ +BUG (); +} +#endif /* _ASM_RISCV_MM_H */
xen/arch/riscv/include/asm/p2m.h +24 -0
@@ -29,6 +29,28 @@ typedef enum { p2m_max_real_type,/* Types after this won't be store in the p2m */ } p2m_type_t; +/* We use bitmaps and mask to handle groups of types */ +#define p2m_to_mask (_t) (1UL << (_t)) + +/* RAM types, which map to real machine frames */ +#define P2M_RAM_TYPES (p2m_to_mask(p2m_ram_rw) | \ + p2m_to_mask(p2m_ram_ro)) + +/* Grant mapping types, which map to a real frame in another VM */ +#define P2M_GRANT_TYPES (p2m_to_mask(p2m_grant_map_rw) | \ + p2m_to_mask(p2m_grant_map_ro)) + +/* Foreign mappings types */ +#define P2M_FOREIGN_TYPES (p2m_to_mask(p2m_map_foreign_rw) | \ + p2m_to_mask(p2m_map_foreign_ro)) + +/* Useful predicates */ +#define p2m_is_ram (_t) (p2m_to_mask(_t) & P2M_RAM_TYPES) +#define p2m_is_foreign (_t) (p2m_to_mask(_t) & P2M_FOREIGN_TYPES) +#define p2m_is_any_ram (_t) (p2m_to_mask(_t) & \ + (P2M_RAM_TYPES | P2M_GRANT_TYPES | \ + P2M_FOREIGN_TYPES)) +#include <xen/p2m-common.h> static inline int get_page_and_type(struct page_info *page,
@@ -102,4 +124,6 @@ static inline void p2m_altp2m_check(struct vcpu *v, uint16_t idx) /* Not supported on RISCV. */ } +bool is_iomem_page (mfn_t mfn); +#endif /* __ASM_RISCV_P2M_H__ */
xen/arch/riscv/include/asm/page.h +16 -0
@@ -83,6 +83,22 @@ static inline void flush_page_to_ram(unsigned long mfn, bool sync_icache)BUG (); } +static inline int clean_dcache_va_range (const void *p,unsigned long size) +{ +BUG (); +} + +static inline int invalidate_dcache_va_range (const void *p,unsigned long size) +{ +BUG (); +} + +static inline int clean_and_invalidate_dcache_va_range + (const void *p,unsigned long size) +{ +BUG (); +} +#endif /* __ASSEMBLY__ */ #endif /* _ASM_RISCV_PAGE_H */
xen/arch/riscv/include/asm/perfc_defn.h new file +0 -0
xen/arch/riscv/mm.c +33 -0
@@ -323,3 +323,36 @@ int map_pages_to_xen(unsigned long virt,assert_failed (__func__);return -1 ; } + +bool is_iomem_page (mfn_t mfn) +{ +BUG (); +} + +int replace_grant_host_mapping (uint64_t gpaddr,mfn_t frame, +uint64_t new_gpaddr,unsigned int flags) +{ +BUG (); +} + +int create_grant_host_mapping (uint64_t gpaddr,mfn_t frame, +unsigned int flags,unsigned int cache_flags) +{ +BUG (); +} + +struct domain *page_get_owner_and_reference (struct page_info *page) +{ +BUG (); +} + +void share_xen_page_with_guest (struct page_info *page,struct domain *d, +enum XENSHARE_flags flags) +{ +BUG (); +} + +bool get_page (struct page_info *page,const struct domain *domain) +{ +BUG (); +}
Signature · 1 line
2.41.0
PATCH 39/57 xen/riscv: introduce asm/numa.h
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/numa.h | 38 +++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 xen/arch/riscv/include/asm/numa.h
xen/arch/riscv/include/asm/numa.h new file +38 -0
@@ -0,0 +1,38 @@ +#ifndef __ARCH_RISCV_NUMA_H +#define __ARCH_RISCV_NUMA_H + +#include <xen/mm.h> + +typedef u8 nodeid_t ; + +/* Fake one node for now. See also node_online_map. */ +#define cpu_to_node (cpu) 0 +#define node_to_cpumask (node) (cpu_online_map) + +/* +* TODO: make first_valid_mfn static when NUMA is supported on RISCV, this +* is required because the dummy helpers are using it. +*/ +extern mfn_t first_valid_mfn; + +/* XXX: implement NUMA support */ +#define node_spanned_pages (nid) (max_page - mfn_x(first_valid_mfn)) +#define node_start_pfn (nid) (mfn_x(first_valid_mfn)) +#define __node_distance (a, b) (20) + +static inline unsigned int arch_get_dma_bitsize (void ) +{ +return 32 ; +} + +#define arch_want_default_dmazone () (false) + +#endif /* __ARCH_RISCV_NUMA_H */ +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
Signature · 1 line
2.41.0
PATCH 56/57 test only riscv
In reply to Oleksii Kurochko--- automation/gitlab-ci/analyze.yaml | 16 - automation/gitlab-ci/build.yaml | 544 ------------------------------ automation/gitlab-ci/test.yaml | 308 ----------------- 3 files changed, 868 deletions(-)
automation/gitlab-ci/analyze.yaml +0 -16
@@ -20,22 +20,6 @@ codequality: gl-code-quality-report.json needs: [] -eclair-x86_64: - extends: .eclair-analysis - variables: - LOGFILE: "eclair-x86_64.log" - VARIANT: "X86_64" - RULESET: "Set1" - allow_failure: true - -eclair-ARM64: - extends: .eclair-analysis - variables: - LOGFILE: "eclair-ARM64.log" - VARIANT: "ARM64" - RULESET: "Set1" - allow_failure: true - .eclair-analysis:on-schedule: extends: .eclair-analysis rules:
automation/gitlab-ci/build.yaml +0 -544
553 lines not on this page · raw message
automation/gitlab-ci/test.yaml +0 -308
317 lines not on this page · raw message
Signature · 1 line
2.41.0
PATCH 42/57 xen/riscv: introduce asm/softirq.h
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/softirq.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 xen/arch/riscv/include/asm/softirq.h
xen/arch/riscv/include/asm/softirq.h new file +16 -0
@@ -0,0 +1,16 @@ +#ifndef __ASM_RISCV_SOFTIRQ_H__ +#define __ASM_RISCV_SOFTIRQ_H__ + +#define NR_ARCH_SOFTIRQS 0 + +#define arch_skip_send_event_check (cpu) 0 + +#endif /* __ASM_RISCV_SOFTIRQ_H__ */ +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
Signature · 1 line
2.41.0
PATCH 46/57 xen/riscv: define an address of frame table
In reply to Oleksii KurochkoAlso the patchs adds some helpful macros.
--- xen/arch/riscv/include/asm/config.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
xen/arch/riscv/include/asm/config.h +21 -0
@@ -77,12 +77,31 @@ name:#endif +#define VPN_BITS (9) +#define OFFSET_BITS (12) +#ifdef CONFIG_RISCV_64 + +#define SLOTN_ENTRY_BITS (HYP_PT_ROOT_LEVEL * VPN_BITS + OFFSET_BITS) +#define SLOTN (slot) (_AT(vaddr_t,slot) << SLOTN_ENTRY_BITS) +#define SLOTN_ENTRY_SIZE SLOTN(1) +#define XEN_VIRT_START 0xFFFFFFFFC0000000/* (_AC(-1, UL) + 1 - GB(1)) */ + +#define FRAMETABLE_VIRT_START SLOTN(196) +#define FRAMETABLE_SIZE GB(3) +#define FRAMETABLE_NR (FRAMETABLE_SIZE / sizeof(*frame_table)) +#define FRAMETABLE_VIRT_END (FRAMETABLE_VIRT_START + FRAMETABLE_SIZE - 1) + +#define VMAP_VIRT_START SLOTN(194) +#define VMAP_VIRT_SIZE GB(1) +#else #error "RV32 isn't supported"#endif +#define HYPERVISOR_VIRT_START XEN_VIRT_START +#define SMP_CACHE_BYTES (1 << 6)#define STACK_SIZE PAGE_SIZE
@@ -95,6 +114,8 @@#define RV_STAGE1_MODE SATP_MODE_SV32#endif +#define HYP_PT_ROOT_LEVEL (CONFIG_PAGING_LEVELS - 1) +#endif /* __RISCV_CONFIG_H__ */ /* * Local variables:
Signature · 1 line
2.41.0
PATCH 45/57 xen/riscv: add definition of __read_mostly
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/cache.h | 2 ++ 1 file changed, 2 insertions(+)
xen/arch/riscv/include/asm/cache.h +2 -0
@@ -3,4 +3,6 @@#ifndef _ASM_RISCV_CACHE_H#define _ASM_RISCV_CACHE_H +#define __read_mostly __section(".data.read_mostly") +#endif /* _ASM_RISCV_CACHE_H */
Signature · 1 line
2.41.0
PATCH 32/57 xen/riscv: introduce bit operations
In reply to Oleksii Kurochko--- xen/arch/riscv/Makefile | 1 + xen/arch/riscv/lib/Makefile | 1 + xen/arch/riscv/lib/find_next_bit.c | 278 +++++++++++++++++++++++++++++ 3 files changed, 280 insertions(+) create mode 100644 xen/arch/riscv/lib/Makefile create mode 100644 xen/arch/riscv/lib/find_next_bit.c
xen/arch/riscv/Makefile +1 -0
@@ -1,5 +1,6 @@ obj-$(CONFIG_EARLY_PRINTK) += early_printk.o obj-y += entry.o +obj-y += lib/ obj-y += mm.o obj-$(CONFIG_RISCV_64) += riscv64/ obj-y += sbi.o
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 +278 -0
278 lines not on this page · raw message
Signature · 1 line
2.41.0
PATCH 37/57 xen/riscv: introduce asm/irq.h
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/irq.h | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 xen/arch/riscv/include/asm/irq.h
xen/arch/riscv/include/asm/irq.h new file +34 -0
@@ -0,0 +1,34 @@ +#ifndef __ASM_RISCV_IRQ_H__ +#define __ASM_RISCV_IRQ_H__ + +#include <xen/lib.h> +#include <xen/device_tree.h> +#include <public/device_tree_defs.h> + +/* TODO */ +#define nr_irqs 0U +#define nr_static_irqs 0 +#define arch_hwdom_irqs (domid) 0U + +#define domain_pirq_to_irq (d, pirq) (pirq) + +#define arch_evtchn_bind_pirq (d, pirq) ((void)((d) + (pirq))) + +struct arch_pirq { +}; + +struct arch_irq_desc { +unsigned int type; +}; + +static inline void arch_move_irqs (struct vcpu *v) +{ +BUG (); +} + +static inline int platform_get_irq (const struct dt_device_node *device,int index) +{ +BUG (); +} + +#endif /* __ASM_RISCV_IRQ_H__ */
Signature · 1 line
2.41.0
Re: [PATCH v1 02/57] xen/riscv: add public arch-riscv.h
In reply to Oleksii KurochkoQuoted 18 lines · Oleksii Kurochko
xen/include/public/arch-riscv.h new file +15
-0@@ -0,0 +1,90 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* Guest OS interface to RISC-V Xen. +* Initially based on the ARM implementation. +*/ + +#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; } \
xen/include/public/arch-riscv.h line 25
Quoted 10 lines
xen/include/public/arch-riscv.h new file +10
-0+ __guest_handle_ ## name; \ + 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.
Nit: aarch{32,64}?
Quoted 4 lines
xen/include/public/arch-riscv.h new file +4
-0+*/ +#define __DEFINE_XEN_GUEST_HANDLE (name, type) \ + ___DEFINE_XEN_GUEST_HANDLE(name, type); \ + ___DEFINE_XEN_GUEST_HANDLE(const_##name, const type)
xen/include/public/arch-riscv.h line 39
Quoted 10 lines
xen/include/public/arch-riscv.h new file +10
-0+#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); \ + _sxghr_tmp->q = 0; \ + _sxghr_tmp->p = (val); \ + } while ( 0 )
While I realize you simply took this from Arm, in new code I think it would be helpful to avoid name space violations from the beginning. Hence no leading underscore please for macro local variables. Trailing underscores is what we mean to use instead.
It's also not really valid to use a gcc extension here, but I guess that's hard to avoid.
Quoted 8 lines
xen/include/public/arch-riscv.h new file +8
-0+#define set_xen_guest_handle (hnd, val) set_xen_guest_handle_raw(hnd, val) + +typedef uint64_t xen_pfn_t ; +#define PRI_xen_pfn PRIx64 +#define PRIu_xen_pfn PRIu64 + +typedef uint64_t xen_ulong_t ; +#define PRI_xen_ulong PRIx64
xen/include/public/arch-riscv.h line 57
Quoted 10 lines
xen/include/public/arch-riscv.h new file +10
-0+ +#if defined(__XEN__) || defined(__XEN_TOOLS__) + +struct vcpu_guest_context { +}; +typedef struct vcpu_guest_context vcpu_guest_context_t ; +DEFINE_XEN_GUEST_HANDLE (vcpu_guest_context_t); + +struct xen_arch_domainconfig { +};
While these are okay to remain empty, ...
xen/include/public/arch-riscv.h line 67
Quoted 9 lines
xen/include/public/arch-riscv.h new file +9
-0+#endif + +struct arch_vcpu_info { +}; +typedef struct arch_vcpu_info arch_vcpu_info_t ; + +struct arch_shared_info { +}; +typedef struct arch_shared_info arch_shared_info_t ;
... these two need to gain a "todo" marker so that we won't forget to at least add a placeholder entry if no real ones surface.
xen/include/public/arch-riscv.h line 70
Quoted 2 lines
xen/include/public/arch-riscv.h new file +2
-0+/* Maximum number of virtual CPUs in legacy multi-processor guests. */ +/* Only one. All other VCPUS must use VCPUOP_register_vcpu_info */
Nit: Style (missing full stop). And quite likely the two comments could be joined to a single one.
xen/include/public/arch-riscv.h line 75
Quoted 5 lines
xen/include/public/arch-riscv.h new file +5
-0+#define XEN_LEGACY_MAX_VCPUS 1 + +#endif /* __ASSEMBLY__ */ + +#ifndef __ASSEMBLY__
Why not continue the earlier !__ASSEMBLY__ section?
Jan
Re: [PATCH v1 02/57] xen/riscv: add public arch-riscv.h
Quoted 27 lines · Jan Beulich
Quoted 26 lines · Oleksii Kurochko
xen/include/public/arch-riscv.h new file +21
-0@@ -0,0 +1,90 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* Guest OS interface to RISC-V Xen. +* Initially based on the ARM implementation. +*/ + +#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; \ + 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
Quoted 8 lines
Quoted 6 lines
bytes
+ * aligned.
+ *XEN_GUEST_HANDLE_PARAMrepresents a guest pointer, when passed as an
+ * hypercall argument. It is 4 bytes on aarch32 and 8 bytes on aarch64.Nit: aarch{32,64}?
Thanks. It should be updated to RISC-V.
Quoted 23 lines
Quoted 7 lines
+ */
xen/include/public/arch-riscv.h new file +4
-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)xen/include/public/arch-riscv.h line 39
Quoted 9 lines
xen/include/public/arch-riscv.h new file +9
-0+#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); \ + _sxghr_tmp->q = 0; \ + _sxghr_tmp->p = (val); \ + } while ( 0 )While I realize you simply took this from Arm, in new code I think it would be helpful to avoid name space violations from the beginning. Hence no leading underscore please for macro local variables. Trailing
underscores is what we mean to use instead.
Quoted 2 lines
It's also not really valid to use a gcc extension here, but I guess that's hard to avoid.
Thank you. Understood. I'll make the update.
Quoted 23 lines
Quoted 10 lines
+#define
set_xen_guest_handle(hnd, val)set_xen_guest_handle_raw(hnd, val)xen/include/public/arch-riscv.h new file +7
-0+ +typedef uint64_t xen_pfn_t ; +#define PRI_xen_pfn PRIx64 +#define PRIu_xen_pfn PRIu64 + +typedef uint64_t xen_ulong_t ; +#define PRI_xen_ulong PRIx64xen/include/public/arch-riscv.h line 57
Quoted 10 lines
xen/include/public/arch-riscv.h new file +10
-0+ +#if defined(__XEN__) || defined(__XEN_TOOLS__) + +struct vcpu_guest_context { +}; +typedef struct vcpu_guest_context vcpu_guest_context_t ; +DEFINE_XEN_GUEST_HANDLE (vcpu_guest_context_t); + +struct xen_arch_domainconfig { +};While these are okay to remain empty, ...
Quoted 12 lines
xen/include/public/arch-riscv.h line 67
Quoted 9 lines
xen/include/public/arch-riscv.h new file +9
-0+#endif + +struct arch_vcpu_info { +}; +typedef struct arch_vcpu_info arch_vcpu_info_t ; + +struct arch_shared_info { +}; +typedef struct arch_shared_info arch_shared_info_t ;... these two need to gain a "todo" marker so that we won't forget to at least add a placeholder entry if no real ones surface.
I'll make the update. Thanks.
Quoted 8 lines
Quoted 4 lines
+/* Maximum number of virtual CPUs in legacy multi-processor guests. */
+/* Only one. All other VCPUS must useVCPUOP_register_vcpu_info*/Nit: Style (missing full stop). And quite likely the two comments could
be joined to a single one.
I'll take it into account.
Quoted 8 lines
xen/include/public/arch-riscv.h line 75
Quoted 6 lines
xen/include/public/arch-riscv.h new file +5
-0+#define XEN_LEGACY_MAX_VCPUS 1 + +#endif /* __ASSEMBLY__ */ + +#ifndef __ASSEMBLY__Why not continue the earlier !__ASSEMBLY__ section?
Sure, we can continue the earlier !__ASSEBLY__ section. I'll update this part.
~ Oleksii
Re: [PATCH v1 44/57] xen/riscv: introduce asm/vm_event.h
In reply to Oleksii KurochkoQuoted 6 lines · Oleksii Kurochko
Signed-off-by Oleksii Kurochko <[email protected]>--- xen/arch/riscv/include/asm/vm_event.h | 52 +++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 xen/arch/riscv/include/asm/vm_event.h
I don't think we ought to replicate this header for every arch when clearly the functions in them are only relevant for specific architectures. Would make more sense to me to just conditionalize the caller side to the specific archs where these functions are actually defined, which would largely just be CONFIG_X86.
Tamas
Re: [PATCH v1 45/57] xen/riscv: add definition of __read_mostly
In reply to Oleksii Kurochkoxen/arch/riscv/include/asm/cache.h line 6
Quoted 7 lines · Oleksii Kurochko
xen/arch/riscv/include/asm/cache.h +1
-0@@ -3,4 +3,6 @@#ifndef _ASM_RISCV_CACHE_H#define _ASM_RISCV_CACHE_H +#define __read_mostly __section(".data.read_mostly")
I did already post a patch eliminating the need for this. It's just that Andrew doesn't like the new placement of the construct, yet neither suggested a reasonable alternative nor showed willingness to accept the change as an intermediate step.
Jan
Re: [PATCH v1 45/57] xen/riscv: add definition of __read_mostly
Quoted 6 lines · Jan Beulich
I did already post a patch eliminating the need for this. It's just that
Andrew doesn't like the new placement of the construct, yet neither suggested a reasonable alternative nor showed willingness to accept the
change as an intermediate step.
Thanks for notifying me.
I'll check your patch.
~ Oleksii
Re: [PATCH v1 44/57] xen/riscv: introduce asm/vm_event.h
In reply to Tamas K LengyelQuoted 10 lines · Tamas K Lengyel
Quoted 7 lines · Oleksii Kurochko
Signed-off-by Oleksii Kurochko <[email protected]>---
xen/arch/riscv/include/asm/vm_event.h | 52
+++++++++++++++++++++++++++1 file changed, 52 insertions(+)create mode 100644
xen/arch/riscv/include/asm/vm_event.h
Quoted 5 lines
I don't think we ought to replicate this header for every arch when clearly the functions in them are only relevant for specific architectures. Would make more sense to me to just conditionalize the caller side to the specific archs where these functions are actually defined, which would largely just be
CONFIG_X86.
Thanks. I'll take it into account.
~ Oleksii
Re: [PATCH v1 57/57] xxxen/riscv: WIP ( need advise )
In reply to Oleksii KurochkoQuoted 15 lines · Oleksii Kurochko
These changes are needed only to make GitLab CI happy is it doesn't take into account
tiny64_defconfigwhere unnecessary configs are disabled.I tried different approaches to deal with it:
1. OverrideEXTRA_XEN_CONFIGandEXTRA_FIXED_RANDCONFIGin the following way:
EXTRA_XEN_CONFIG:
CONFIG_1=n
CONFIG_2=n
...
2. Override in arch-specific KConfig:
CONFIG_1:
default n
Quoted 4 lines
Each option doesn't work for me fully.
Could you please suggest other options or more correct way?
It looks like if to do unwanted configs for now as an invisible config in arch-specific KConfig it should work. Something like:
config GRANT_TABLE
bool
default n
I'll double-check tomorrow.
~ Oleksii
Quoted 331 lines
Signed-off-by Oleksii Kurochko <[email protected]>---
xen/arch/riscv/include/asm/asm_defns.h | 44 +++++++++++++++++ xen/arch/riscv/include/asm/grant_table.h | 57
++++++++++++++++++++++
xen/arch/riscv/include/asm/guest_atomics.h | 16 +++++- xen/arch/riscv/include/asm/livepatch.h | 0 xen/arch/riscv/include/asm/mm.h | 5 ++ xen/arch/riscv/include/asm/p2m.h | 24 +++++++++ xen/arch/riscv/include/asm/page.h | 16 ++++++ xen/arch/riscv/include/asm/perfc_defn.h | 0 xen/arch/riscv/mm.c | 33 +++++++++++++9 files changed, 194 insertions(+), 1 deletion(-)create mode 100644
xen/arch/riscv/include/asm/asm_defns.hcreate mode 100644xen/arch/riscv/include/asm/livepatch.hcreate mode 100644xen/arch/riscv/include/asm/perfc_defn.hxen/arch/riscv/include/asm/asm_defns.h new file +17
-0@@ -0,0 +1,44 @@ +#ifndef __ARM_ASM_DEFNS_H__ +#define __ARM_ASM_DEFNS_H__ + +#ifndef COMPILE_OFFSETS +/* NB. Auto-generated from arch/.../asm-offsets.c */ +#include <asm/asm-offsets.h> +#endif +#include <asm/processor.h> + +/* Macros for generic assembly code */ +#if defined(CONFIG_RISCV_32 ) +# define __OP32 +# define ASM_REG (index) asm("r" # index) +#elif defined(CONFIG_RISCV_64 ) +# define __OP32 "w" +/* +* Clang < 8.0 doesn't support register alllocation using the syntax rN.
+ * See https://reviews.llvm.org/rL328829.
+ */xen/arch/riscv/include/asm/asm_defns.h new file +25
-0+# define ASM_REG (index) asm("x" # index) +#else +# error "unknown ARM variant" +#endif + +#define RODATA_STR (label, msg) \ +.pushsection .rodata.str, "aMS", %progbits, 1 ; \ +label: .asciz msg; \ +.popsection + +#define ASM_INT (label, val) \ + .p2align 2; \ +label: .long (val); \ + .size label, . - label; \ + .type label, %object + +#endif /* __ARM_ASM_DEFNS_H__ */ +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/ xen/arch/riscv/include/asm/grant_table.h +0
-0@@ -1,4 +1,61 @@ #ifndef __ASM_RISCV_GRANTTABLE_H__ #define __ASM_RISCV_GRANTTABLE_H__xen/arch/riscv/include/asm/grant_table.h +7
-0+#define INITIAL_NR_GRANT_FRAMES 1U + +#define gnttab_shared_page (t, i) virt_to_page((t)->shared_raw[i]) + +#define gnttab_status_page (t, i) virt_to_page((t)->status[i]) + +#define gnttab_shared_gfn(d, t,i) \
+page_get_xenheap_gfn(gnttab_shared_page(t, i))xen/arch/riscv/include/asm/grant_table.h +2
-0+ +#define gnttab_status_gfn(d, t,i) \
+page_get_xenheap_gfn(gnttab_status_page(t, i))xen/arch/riscv/include/asm/grant_table.h +2
-0+ +#define gnttab_set_frame_gfn(gt, st, idx, gfn,mfn) \
+ (gfn_eq(gfn,
INVALID_GFN) \
+ ? guest_physmap_remove_page((gt)-Quoted 1 line
domain, \
+
gnttab_get_frame_gfn(gt, st, idx), \
+ mfn,
0) \
+ : 0)xen/arch/riscv/include/asm/grant_table.h +2
-0+ +#define gnttab_get_frame_gfn (gt, st, idx)({ \
+ (st) ? gnttab_status_gfn(NULL, gt,
idx) \
+ : gnttab_shared_gfn(NULL, gt,
idx); \xen/arch/riscv/include/asm/grant_table.h +6
-0+}) + +#define gnttab_need_iommu_mapping (d) \ + (is_domain_direct_mapped(d) && is_iommu_enabled(d)) + +static inline bool gnttab_release_host_mappings(const struct domain*d)
xen/arch/riscv/include/asm/grant_table.h +8
-0+{ + BUG(); +} + +static inline void gnttab_mark_dirty (struct domain *d,mfn_t mfn) +{ +#ifndef NDEBUG + printk_once(XENLOG_G_WARNING "gnttab_mark_dirty not implementedyet\n");
xen/arch/riscv/include/asm/grant_table.h +5
-0+#endif +} + +static inline void gnttab_clear_flags (struct domain *d, + unsigned int mask, uint16_t*addr)
xen/arch/riscv/include/asm/grant_table.h +6
-0+{ + BUG(); +} + +static inline bool gnttab_host_mapping_get_page_type(bool ro, + const structdomain *ld,
+ const struct domain *rd)xen/arch/riscv/include/asm/grant_table.h +6
-0+{ + return false; +} + +int create_grant_host_mapping (uint64_t gpaddr,mfn_t frame, + unsigned int flags, unsigned int
cache_flags);
+int replace_grant_host_mapping(uint64_t gpaddr,mfn_tframe, +uint64_tnew_gpaddr, unsigned int flags);
+
#endif /*__ASM_RISCV_GRANTTABLE_H__*/
\ No newline at end of filexen/arch/riscv/include/asm/guest_atomics.h +0
-0@@ -35,9 +35,23 @@ guest_testop(test_and_change_bit)
#undefguest_testop
-
#defineguest_test_bit(d, nr, p)((void)(d),test_bit(nr, p))xen/arch/riscv/include/asm/guest_atomics.h +8
-0+#define guest_cmpxchg (d, ptr, o, n) \ + ((__typeof__(*(ptr)))__guest_cmpxchg(d, ptr, \ + (unsigned long)(o),\ + (unsigned long)(n),\ + sizeof (*(ptr)))) + +static always_inline unsigned long __guest_cmpxchg (struct domain *d, + volatile void*ptr,
+ unsigned long old,
+ unsigned long new,
+ unsigned int size)xen/arch/riscv/include/asm/guest_atomics.h +4
-0+{ + BUG(); +} +#endif /*
__ASM_RISCV_GUEST_ATOMICS_H*/
/*
* Local variables:xen/arch/riscv/include/asm/livepatch.h new file +0
-0xen/arch/riscv/include/asm/mm.h +0
-0@@ -276,4 +276,9 @@ void setup_initial_pagetables(void); void enable_mmu(void); void cont_after_mmu_is_enabled(void);xen/arch/riscv/include/asm/mm.h +5
-0+static inline gfn_t page_get_xenheap_gfn (const struct page_info *p) +{ + BUG(); +} +#endif /*
_ASM_RISCV_MM_H*/xen/arch/riscv/include/asm/p2m.h +0
-0@@ -29,6 +29,28 @@ typedef enum {p2m_max_real_type, /* Types after this won't be store in the p2m */
}p2m_type_t;xen/arch/riscv/include/asm/p2m.h +22
-0+/* We use bitmaps and mask to handle groups of types */ +#define p2m_to_mask (_t) (1UL << (_t)) + +/* RAM types, which map to real machine frames */ +#define P2M_RAM_TYPES (p2m_to_mask(p2m_ram_rw) | \ + p2m_to_mask(p2m_ram_ro)) + +/* Grant mapping types, which map to a real frame in another VM */ +#define P2M_GRANT_TYPES (p2m_to_mask(p2m_grant_map_rw) | \ + p2m_to_mask(p2m_grant_map_ro)) + +/* Foreign mappings types */ +#define P2M_FOREIGN_TYPES (p2m_to_mask(p2m_map_foreign_rw) | \ + p2m_to_mask(p2m_map_foreign_ro)) + +/* Useful predicates */ +#define p2m_is_ram (_t) (p2m_to_mask(_t) & P2M_RAM_TYPES) +#define p2m_is_foreign (_t) (p2m_to_mask(_t) & P2M_FOREIGN_TYPES) +#define p2m_is_any_ram (_t) (p2m_to_mask(_t) & \ + (P2M_RAM_TYPES | P2M_GRANT_TYPES | \ + P2M_FOREIGN_TYPES)) +#include <
xen/p2m-common.h>
static inline int get_page_and_type(structpage_info*page,xen/arch/riscv/include/asm/p2m.h +0
-0@@ -102,4 +124,6 @@ static inline void p2m_altp2m_check(struct vcpu *v, uint16_t idx) /* Not supported on RISCV. */ }xen/arch/riscv/include/asm/p2m.h +2
-0+bool is_iomem_page (mfn_t mfn); +#endif /*
__ASM_RISCV_P2M_H__*/
\ No newline at end of filexen/arch/riscv/include/asm/page.h +0
-0@@ -83,6 +83,22 @@ static inline void flush_page_to_ram(unsigned long mfn, bool sync_icache) BUG(); }
+static inline intclean_dcache_va_range(const void *p, unsigned long size)xen/arch/riscv/include/asm/page.h +5
-0+{ + BUG(); +} + +static inline int invalidate_dcache_va_range(const void *p, unsignedlong size)
xen/arch/riscv/include/asm/page.h +10
-0+{ + BUG(); +} + +static inline int clean_and_invalidate_dcache_va_range + (const void *p, unsigned long size) +{ + BUG(); +} +#endif /*
__ASSEMBLY__*/
#endif /*_ASM_RISCV_PAGE_H*/xen/arch/riscv/include/asm/perfc_defn.h new file +0
-0xen/arch/riscv/mm.c +8
-0@@ -323,3 +323,36 @@ int map_pages_to_xen(unsigned long virt, assert_failed(__func__); return -1; } + +bool is_iomem_page (mfn_t mfn) +{ + BUG(); +} + +int replace_grant_host_mapping (uint64_t gpaddr,mfn_t frame, + uint64_t new_gpaddr, unsigned intflags)
xen/arch/riscv/mm.c +6
-0+{ + BUG(); +} + +int create_grant_host_mapping (uint64_t gpaddr,mfn_t frame, + unsigned int flags, unsigned int
cache_flags)xen/arch/riscv/mm.c +10
-0+{ + BUG(); +} + +struct domain *page_get_owner_and_reference (struct page_info *page) +{ + BUG(); +} + +void share_xen_page_with_guest(struct page_info *page, struct domain*d,
+ enumXENSHARE_flagsflags)xen/arch/riscv/mm.c +8
-0+{ + BUG(); +} + +bool get_page (struct page_info *page,const struct domain *domain) +{ + BUG(); +}
Quoted 59 lines · Oleksii Kurochko
This patch series performs all of the additions necessary to drop the build overrides for RISCV and enable the full Xen build. Except in cases where compatibile implementations already exist (e.g.
atomic.handbitops.h), the newly added definitions are simple.Also the patch series has open question described in the patch 57
Patch 56 is only needed for test purposes and will be removed.
Oleksii Kurochko (57):
xen/riscv:introduceasm/byteorder.h
xen/riscv: add publicarch-riscv.h
xen/riscv: introducespinlock.h
xen/riscv: introducefence.h
xen/riscv: introducearch-riscv/hvm/save.h
xen/riscv: introducepaging.h
xen/riscv: introduceasm/cpufeature.h
xen/riscv: introduceasm/device.h
xen/riscv: introduceasm/event.h
xen/riscv: introduceasm/grant_table.h
xen/riscv: introduceasm/guest_atomics.h
xen/riscv: introduceasm/hypercall.h
xen/riscv: introduceasm/iocap.h
xen/riscv: introduceasm/iommu.h
xen/riscv: introduceasm/mem_access.h
xen/riscv: introduceasm/nospec.h
xen/riscv: introduceasm/pci.h
xen/riscv: introduceasm/random.h
xen/riscv: introduceasm/setup.h
xen/riscv: introduceasm/system.h
xen/riscv: introduceasm/xenoprof.h
xen/riscv: introducebitops.h
xen/riscv: introduceflushtlb.h
xen/riscv: introduceasm/percpu.h
xen/riscv: introduceasm/smp.h
xen/riscv: introduceasm/atomic.h
xen/riscv: introducecmpxchg.h
xen/riscv: introduceasm/io.h
xen/riscv: introduceasm/hardirq.h
xen/riscv: introducediv64.h
xen/riscv: define bug frame tables inxen.lds.Sxen/riscv: introduce bit operations
xen/riscv: introduceasm/altp2m.h
xen/riscv: introduceasm/delay.h
xen/riscv: introduceasm/domain.h
xen/riscv: introduceasm/guest_access.h
xen/riscv: introduceasm/irq.h
xen/riscv: introduceasm/monitor.h
xen/riscv: introduceasm/numa.h
xen/riscv: introduceasm/p2m.h
xen/riscv: introduceasm/regs.h
xen/riscv: introduceasm/softirq.h
xen/riscv: introduceasm/time.h
xen/riscv: introduceasm/vm_event.h
xen/riscv: add definition of__read_mostly
xen/riscv: define an address of frame table
xen/riscv: add required things toasm/current.hxen/riscv: add minimal stuff toasm/page.hto build full Xen xen/riscv: add minimal stuff toasm/processor.hto build full Xen
Quoted 8 lines
xen/riscv: add minimal stuff to
asm/smp.hto build full Xen
xen: add RISCV support forpmu.h
xen: add necessary headers to common to build full Xen for RISC-V xen/riscv: add minimal stuff toasm/mm.hto build full Xen xen/rirscv: add minimal amount of stubs to build full Xen xen/riscv: enable full Xen build
test only riscv
xxxen/riscv: WIP ( need advise )
Just to clarify: With the later 29-patch series superseding fair parts of this, is there still any need to look at this (version of this) series in any detail?
Jan
Quoted 71 lines · Jan Beulich
Quoted 61 lines · Oleksii Kurochko
This patch series performs all of the additions necessary to drop the
build overrides for RISCV and enable the full Xen build. Except in cases
where compatibile implementations already exist (e.g.atomic.handbitops.h), the newly added definitions are simple.Also the patch series has open question described in the patch 57
Patch 56 is only needed for test purposes and will be removed.
Oleksii Kurochko (57):
xen/riscv:introduceasm/byteorder.h
xen/riscv: add publicarch-riscv.h
xen/riscv: introducespinlock.h
xen/riscv: introducefence.h
xen/riscv: introducearch-riscv/hvm/save.h
xen/riscv: introducepaging.h
xen/riscv: introduceasm/cpufeature.h
xen/riscv: introduceasm/device.h
xen/riscv: introduceasm/event.h
xen/riscv: introduceasm/grant_table.h
xen/riscv: introduceasm/guest_atomics.h
xen/riscv: introduceasm/hypercall.h
xen/riscv: introduceasm/iocap.h
xen/riscv: introduceasm/iommu.h
xen/riscv: introduceasm/mem_access.h
xen/riscv: introduceasm/nospec.h
xen/riscv: introduceasm/pci.h
xen/riscv: introduceasm/random.h
xen/riscv: introduceasm/setup.h
xen/riscv: introduceasm/system.h
xen/riscv: introduceasm/xenoprof.h
xen/riscv: introducebitops.h
xen/riscv: introduceflushtlb.h
xen/riscv: introduceasm/percpu.h
xen/riscv: introduceasm/smp.h
xen/riscv: introduceasm/atomic.h
xen/riscv: introducecmpxchg.h
xen/riscv: introduceasm/io.h
xen/riscv: introduceasm/hardirq.h
xen/riscv: introducediv64.h
xen/riscv: define bug frame tables inxen.lds.Sxen/riscv: introduce bit operations
xen/riscv: introduceasm/altp2m.h
xen/riscv: introduceasm/delay.h
xen/riscv: introduceasm/domain.h
xen/riscv: introduceasm/guest_access.h
xen/riscv: introduceasm/irq.h
xen/riscv: introduceasm/monitor.h
xen/riscv: introduceasm/numa.h
xen/riscv: introduceasm/p2m.h
xen/riscv: introduceasm/regs.h
xen/riscv: introduceasm/softirq.h
xen/riscv: introduceasm/time.h
xen/riscv: introduceasm/vm_event.h
xen/riscv: add definition of__read_mostly
xen/riscv: define an address of frame table
xen/riscv: add required things toasm/current.hxen/riscv: add minimal stuff toasm/page.hto build full Xen xen/riscv: add minimal stuff toasm/processor.hto build full XenQuoted 8 lines
xen/riscv: add minimal stuff to
asm/smp.hto build full Xen
xen: add RISCV support forpmu.h
xen: add necessary headers to common to build full Xen for RISC-V xen/riscv: add minimal stuff toasm/mm.hto build full Xen xen/rirscv: add minimal amount of stubs to build full Xen xen/riscv: enable full Xen build
test only riscv
xxxen/riscv: WIP ( need advise )
Quoted 5 lines
Just to clarify: With the later 29-patch series superseding fair parts of this,
is there still any need to look at this (version of this) series in any detail?
It depends on if headers mentioned in 29-patch series should be in asm- generic folder or in arch specific folder.
I think we can start look at 29-patch series and after it will be merged ( or finished in some way ) I'll resend this one patch series.
~ Oleksii