Minimal build for RISCV
v3 cover Minimal build for RISCV
Hi all,
This series introduces a minimal build for RISCV. It is based on Bobby's previous work from last year[0] rebased onto current Xen.
This series provides the patches necessary to get a minimal build working. The build is "minimal" in the sense that it only supports building TARGET=head.o. The arch/riscv/head.S is just a simple while(1).
The first 3 patches are mods to non-RISCV bits that enable building a config with:
!CONFIG_HAS_NS16550
!CONFIG_HAS_PASSTHROUGH
!CONFIG_GRANT_TABLE
respectively. The fourth patch adds the make/Kconfig boilerplate alongside head.S and asm-riscv/config.h (head.S references ENTRY that is defined in asm-riscv/config.h).
The last adds a docker container for doing the build. To build from the docker container (after creating it locally), you can run the following:
$ make XEN_TARGET_ARCH=riscv64 SUBSYSTEMS=xen -C xen TARGET=head.o
--
Changes since v2:
- Reduced number of riscv files added to ease review
Changes since v1:
- Dropped "xen/sched: Fix build when NR_CPUS == 1" since this was
fixed for 4.15
- Moved #ifdef-ary around iommu_enabled to iommu.h
- Moved struct grant_table declaration above ifdef CONFIG_GRANT_TABLE instead of defining an empty struct when !CONFIG_GRANT_TABLE
Connor Davis (5):
xen/char: Default HAS_NS16550 to y only for X86 and ARM xen/common: Guard iommu symbols with CONFIG_HAS_PASSTHROUGH
xen: Fix build when !CONFIG_GRANT_TABLE
xen: Add files needed for minimal riscv build
automation: Add container for riscv64 builds
automation/build/archlinux/riscv64.dockerfile | 33 ++++++ automation/scripts/containerize | 1 + config/riscv64.mk | 5 + xen/Makefile | 8 +- xen/arch/riscv/Kconfig | 52 +++++++++ xen/arch/riscv/Kconfig.debug | 0 xen/arch/riscv/Makefile | 0 xen/arch/riscv/Rules.mk | 0 xen/arch/riscv/arch.mk | 16 +++ xen/arch/riscv/asm-offsets.c | 0 xen/arch/riscv/configs/riscv64_defconfig | 12 ++ xen/arch/riscv/head.S | 6 + xen/common/memory.c | 10 ++ xen/drivers/char/Kconfig | 2 +- xen/include/asm-riscv/config.h | 110 ++++++++++++++++++ xen/include/xen/grant_table.h | 3 +- xen/include/xen/iommu.h | 8 +- 17 files changed, 261 insertions(+), 5 deletions(-) create mode 100644 automation/build/archlinux/riscv64.dockerfile create mode 100644 config/riscv64.mk create mode 100644 xen/arch/riscv/Kconfig create mode 100644 xen/arch/riscv/Kconfig.debug create mode 100644 xen/arch/riscv/Makefile create mode 100644 xen/arch/riscv/Rules.mk create mode 100644 xen/arch/riscv/arch.mk create mode 100644 xen/arch/riscv/asm-offsets.c create mode 100644 xen/arch/riscv/configs/riscv64_defconfig create mode 100644 xen/arch/riscv/head.S create mode 100644 xen/include/asm-riscv/config.h
Signature · 1 line
2.31.1
PATCH v3 1/5 xen/char: Default HAS_NS16550 to y only for X86 and ARM
Defaulting to yes only for X86 and ARM reduces the requirements for a minimal build when porting new architectures.
--- xen/drivers/char/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/drivers/char/Kconfig +1 -1
@@ -1,6 +1,6 @@ config HAS_NS16550 bool "NS16550 UART driver" if ARM - default y + default y if (ARM || X86) help This selects the 16550-series UART support. For most systems, say Y.
Signature · 1 line
2.31.1
Re: [PATCH v3 1/5] xen/char: Default HAS_NS16550 to y only for X86 and ARM
Quoted 5 lines · Connor Davis
Defaulting to yes only for X86 and ARM reduces the requirements for a minimal build when porting new architectures.
Signed-off-by Connor Davis <[email protected]>
Alistair
Quoted 19 lines
--- xen/drivers/char/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)xen/drivers/char/Kconfig +1
-2@@ -1,6 +1,6 @@ config HAS_NS16550 bool "NS16550 UART driver" if ARM - default y + default y if (ARM || X86) help This selects the 16550-series UART support. For most systems, say Y. --2.31.1
Re: [PATCH v3 1/5] xen/char: Default HAS_NS16550 to y only for X86 and ARM
In reply to Connor DavisQuoted 2 lines · Connor Davis
Defaulting to yes only for X86 and ARM reduces the requirements for a minimal build when porting new architectures.
While I agree with the statement, ...
xen/drivers/char/Kconfig line 3
Quoted 7 lines
xen/drivers/char/Kconfig +1
-1@@ -1,6 +1,6 @@ config HAS_NS16550 bool "NS16550 UART driver" if ARM - default y + default y if (ARM || X86)
... this approach doesn't scale very well. You would likely have been hesitant to add a, say, 12-way || here if we had this many architectures already. I think you instead want
config HAS_NS16550
bool "NS16550 UART driver" if ARM
+ default n if RISCV
default y
which then can be adjusted back by another one line change once the driver code actually builds.
Jan
Re: [PATCH v3 1/5] xen/char: Default HAS_NS16550 to y only for X86 and ARM
Quoted 16 lines · Jan Beulich
xen/drivers/char/Kconfig line 3
Quoted 7 lines
xen/drivers/char/Kconfig +1
-1@@ -1,6 +1,6 @@ config HAS_NS16550 bool "NS16550 UART driver" if ARM - default y + default y if (ARM || X86)... this approach doesn't scale very well. You would likely have been hesitant to add a, say, 12-way || here if we had this many architectures already. I think you instead want
config
HAS_NS16550
bool "NS16550 UART driver" if ARM(quoted diff) +1
-0+ default n if RISCV default y
Quoted 4 lines
which then can be adjusted back by another one line change once the driver code actually builds.
Jan
Agreed, I will update this in the next version.
Thanks,
Connor
PATCH v3 2/5 xen/common: Guard iommu symbols with CONFIG_HAS_PASSTHROUGH
In reply to Connor DavisThe variables iommu_enabled and iommu_dont_flush_iotlb are defined in drivers/passthrough/iommu.c and are referenced in common code, which causes the link to fail when !CONFIG_HAS_PASSTHROUGH.
Guard references to these variables in common code so that xen builds when !CONFIG_HAS_PASSTHROUGH.
--- xen/common/memory.c | 10 ++++++++++ xen/include/xen/iommu.h | 8 +++++++- 2 files changed, 17 insertions(+), 1 deletion(-)
xen/common/memory.c +10 -0
@@ -294,7 +294,9 @@ int guest_remove_page(struct domain *d, unsigned long gmfn)p2m_type_t p2mt;#endif mfn_t mfn; +#ifdef CONFIG_HAS_PASSTHROUGH bool *dont_flush_p, dont_flush; +#endif int rc;#ifdef CONFIG_X86
@@ -385,13 +387,17 @@ int guest_remove_page(struct domain *d, unsigned long gmfn)* Since we're likely to free the page below, we need to suspend * xenmem_add_to_physmap()'s suppressing of IOMMU TLB flushes. */ +#ifdef CONFIG_HAS_PASSTHROUGH dont_flush_p = &this_cpu (iommu_dont_flush_iotlb); dont_flush = *dont_flush_p; *dont_flush_p = false; +#endif rc =guest_physmap_remove_page (d,_gfn (gmfn), mfn,0 ); +#ifdef CONFIG_HAS_PASSTHROUGH *dont_flush_p = dont_flush; +#endif /* * With the lack of an IOMMU on some platforms, domains with DMA-capable
@@ -839,11 +845,13 @@ int xenmem_add_to_physmap(struct domain *d, struct xen_add_to_physmap *xatp, xatp->gpfn += start; xatp->size -= start; +#ifdef CONFIG_HAS_PASSTHROUGH if (is_iommu_enabled (d) ) {this_cpu (iommu_dont_flush_iotlb) =1 ; extra.ppage = &pages[0 ]; } +#endif while ( xatp->size > done ) {
@@ -868,6 +876,7 @@ int xenmem_add_to_physmap(struct domain *d, struct xen_add_to_physmap *xatp, } } +#ifdef CONFIG_HAS_PASSTHROUGH if (is_iommu_enabled (d) ) {int ret;
@@ -894,6 +903,7 @@ int xenmem_add_to_physmap(struct domain *d, struct xen_add_to_physmap *xatp,if (unlikely (ret) && rc >=0 ) rc = ret; } +#endif return rc; }
xen/include/xen/iommu.h +7 -1
@@ -51,9 +51,15 @@ static inline bool_t dfn_eq(dfn_t x, dfn_t y)return dfn_x (x) ==dfn_x (y); } -extern bool_t iommu_enable, iommu_enabled; +extern bool_t iommu_enable;extern bool force_iommu, iommu_quarantine, iommu_verbose; +#ifdef CONFIG_HAS_PASSTHROUGH +extern bool_t iommu_enabled; +#else +#define iommu_enabled false +#endif +#ifdef CONFIG_X86 extern enum __packed iommu_intremap {/*
Signature · 1 line
2.31.1
Re: [PATCH v3 2/5] xen/common: Guard iommu symbols with CONFIG_HAS_PASSTHROUGH
Quoted 53 lines · Connor Davis
xen/common/memory.c +9
-0@@ -294,7 +294,9 @@ int guest_remove_page(struct domain *d, unsigned long gmfn)p2m_type_t p2mt;#endif mfn_t mfn; +#ifdef CONFIG_HAS_PASSTHROUGH bool *dont_flush_p, dont_flush; +#endif int rc;#ifdef CONFIG_X86 @@ -385,13 +387,17 @@ int guest_remove_page(struct domain *d, unsigned long gmfn)* Since we're likely to free the page below, we need to suspend * xenmem_add_to_physmap()'s suppressing of IOMMU TLB flushes. */ +#ifdef CONFIG_HAS_PASSTHROUGH dont_flush_p = &this_cpu (iommu_dont_flush_iotlb); dont_flush = *dont_flush_p; *dont_flush_p = false; +#endif rc =guest_physmap_remove_page (d,_gfn (gmfn), mfn,0 ); +#ifdef CONFIG_HAS_PASSTHROUGH *dont_flush_p = dont_flush; +#endif /* * With the lack of an IOMMU on some platforms, domains with DMA-capable @@ -839,11 +845,13 @@ int xenmem_add_to_physmap(struct domain *d, struct xen_add_to_physmap *xatp, xatp->gpfn += start; xatp->size -= start; +#ifdef CONFIG_HAS_PASSTHROUGH if (is_iommu_enabled (d) ) {this_cpu (iommu_dont_flush_iotlb) =1 ; extra.ppage = &pages[0 ]; } +#endif while ( xatp->size > done ) {@@ -868,6 +876,7 @@ int xenmem_add_to_physmap(struct domain *d, struct xen_add_to_physmap *xatp, } } +#ifdef CONFIG_HAS_PASSTHROUGH if (is_iommu_enabled (d) ) {int ret;
xen/common/memory.c int xenmem_add_to_physmap(struct domain *d, struct xen_add_to_physmap *xatp, · line 909
Quoted 7 lines
xen/common/memory.c +1
-0@@ -894,6 +903,7 @@ int xenmem_add_to_physmap(struct domain *d, struct xen_add_to_physmap *xatp,if (unlikely (ret) && rc >=0 ) rc = ret; } +#endif return rc; }
I wonder whether all of these wouldn't better become CONFIG_X86:
ISTR Julien indicating that he doesn't see the override getting used on Arm. (Julien, please correct me if I'm misremembering.)
xen/include/xen/iommu.h static inline bool_t dfn_eq(dfn_t x, dfn_t y) · line 58
Quoted 12 lines
xen/include/xen/iommu.h +3
-1@@ -51,9 +51,15 @@ static inline bool_t dfn_eq(dfn_t x, dfn_t y)return dfn_x (x) ==dfn_x (y); } -extern bool_t iommu_enable, iommu_enabled; +extern bool_t iommu_enable;extern bool force_iommu, iommu_quarantine, iommu_verbose; +#ifdef CONFIG_HAS_PASSTHROUGH +extern bool_t iommu_enabled;
Just bool please, like is already the case for the line in context above. We're in the process of phasing out bool_t.
Jan
Re: [PATCH v3 2/5] xen/common: Guard iommu symbols with CONFIG_HAS_PASSTHROUGH
Quoted 71 lines · Jan Beulich
Quoted 53 lines · Connor Davis
xen/common/memory.c +9
-0@@ -294,7 +294,9 @@ int guest_remove_page(struct domain *d, unsigned long gmfn)p2m_type_t p2mt;#endif mfn_t mfn; +#ifdef CONFIG_HAS_PASSTHROUGH bool *dont_flush_p, dont_flush; +#endif int rc;#ifdef CONFIG_X86 @@ -385,13 +387,17 @@ int guest_remove_page(struct domain *d, unsigned long gmfn)* Since we're likely to free the page below, we need to suspend * xenmem_add_to_physmap()'s suppressing of IOMMU TLB flushes. */ +#ifdef CONFIG_HAS_PASSTHROUGH dont_flush_p = &this_cpu (iommu_dont_flush_iotlb); dont_flush = *dont_flush_p; *dont_flush_p = false; +#endif rc =guest_physmap_remove_page (d,_gfn (gmfn), mfn,0 ); +#ifdef CONFIG_HAS_PASSTHROUGH *dont_flush_p = dont_flush; +#endif /* * With the lack of an IOMMU on some platforms, domains with DMA-capable @@ -839,11 +845,13 @@ int xenmem_add_to_physmap(struct domain *d, struct xen_add_to_physmap *xatp, xatp->gpfn += start; xatp->size -= start; +#ifdef CONFIG_HAS_PASSTHROUGH if (is_iommu_enabled (d) ) {this_cpu (iommu_dont_flush_iotlb) =1 ; extra.ppage = &pages[0 ]; } +#endif while ( xatp->size > done ) {@@ -868,6 +876,7 @@ int xenmem_add_to_physmap(struct domain *d, struct xen_add_to_physmap *xatp, } } +#ifdef CONFIG_HAS_PASSTHROUGH if (is_iommu_enabled (d) ) {int ret;xen/common/memory.c int xenmem_add_to_physmap(struct domain *d, struct xen_add_to_physmap *xatp, · line 909
Quoted 7 lines
xen/common/memory.c +1
-0@@ -894,6 +903,7 @@ int xenmem_add_to_physmap(struct domain *d, struct xen_add_to_physmap *xatp,if (unlikely (ret) && rc >=0 ) rc = ret; } +#endif return rc; }I wonder whether all of these wouldn't better become
CONFIG_X86:
ISTR Julien indicating that he doesn't see the override getting used on Arm. (Julien, please correct me if I'm misremembering.)Quoted 6 lines
xen/include/xen/iommu.h +0
-0@@ -51,9 +51,15 @@ static inline bool_t dfn_eq(dfn_t x, dfn_t y)return dfn_x (x) ==dfn_x (y); }
Quoted 8 lines
xen/include/xen/iommu.h static inline bool_t dfn_eq(dfn_t x, dfn_t y) · line 58
Quoted 6 lines
xen/include/xen/iommu.h +3
-1-extern bool_t iommu_enable, iommu_enabled; +extern bool_t iommu_enable;extern bool force_iommu, iommu_quarantine, iommu_verbose; +#ifdef CONFIG_HAS_PASSTHROUGH +extern bool_t iommu_enabled;Just bool please, like is already the case for the line in context above. We're in the process of phasing out
bool_t.
Got it, thanks.
Quoted 2 lines
Jan
Thanks,
Connor
Re: [PATCH v3 2/5] xen/common: Guard iommu symbols with CONFIG_HAS_PASSTHROUGH
In reply to Jan BeulichHi Jan,
Quoted 59 lines · Jan Beulich
Quoted 58 lines · Connor Davis
xen/common/memory.c +10
-0@@ -294,7 +294,9 @@ int guest_remove_page(struct domain *d, unsigned long gmfn)p2m_type_t p2mt;#endif mfn_t mfn; +#ifdef CONFIG_HAS_PASSTHROUGH bool *dont_flush_p, dont_flush; +#endif int rc;#ifdef CONFIG_X86 @@ -385,13 +387,17 @@ int guest_remove_page(struct domain *d, unsigned long gmfn)* Since we're likely to free the page below, we need to suspend * xenmem_add_to_physmap()'s suppressing of IOMMU TLB flushes. */ +#ifdef CONFIG_HAS_PASSTHROUGH dont_flush_p = &this_cpu (iommu_dont_flush_iotlb); dont_flush = *dont_flush_p; *dont_flush_p = false; +#endif rc =guest_physmap_remove_page (d,_gfn (gmfn), mfn,0 ); +#ifdef CONFIG_HAS_PASSTHROUGH *dont_flush_p = dont_flush; +#endif /* * With the lack of an IOMMU on some platforms, domains with DMA-capable @@ -839,11 +845,13 @@ int xenmem_add_to_physmap(struct domain *d, struct xen_add_to_physmap *xatp, xatp->gpfn += start; xatp->size -= start; +#ifdef CONFIG_HAS_PASSTHROUGH if (is_iommu_enabled (d) ) {this_cpu (iommu_dont_flush_iotlb) =1 ; extra.ppage = &pages[0 ]; } +#endif while ( xatp->size > done ) {@@ -868,6 +876,7 @@ int xenmem_add_to_physmap(struct domain *d, struct xen_add_to_physmap *xatp, } } +#ifdef CONFIG_HAS_PASSTHROUGH if (is_iommu_enabled (d) ) {int ret;@@ -894,6 +903,7 @@ int xenmem_add_to_physmap(struct domain *d, struct xen_add_to_physmap *xatp,if (unlikely (ret) && rc >=0 ) rc = ret; } +#endif
Quoted 6 lines
xen/common/memory.c int xenmem_add_to_physmap(struct domain *d, struct xen_add_to_physmap *xatp, · line 909
Quoted 2 lines
xen/common/memory.c +0
-0return rc; }I wonder whether all of these wouldn't better become
CONFIG_X86:
ISTR Julien indicating that he doesn't see the override getting used on Arm. (Julien, please correct me if I'm misremembering.)
Right, so far, I haven't been in favor to introduce it because:
1) The P2M code may free some memory. So you can't always ignore the
flush (I think this is wrong for the upper layer to know when this can happen).
2) It is unclear what happen if the IOMMU TLBs and the PT contains
different mappings (I received conflicted advice).
So it is better to always flush and as early as possible.
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v3 2/5] xen/common: Guard iommu symbols with CONFIG_HAS_PASSTHROUGH
Quoted 66 lines · Julien Grall
Hi Jan,
Quoted 54 lines · Jan Beulich
Quoted 53 lines · Connor Davis
xen/common/memory.c +4
-0@@ -294,7 +294,9 @@ int guest_remove_page(struct domain *d, unsigned long gmfn) p2m_type_t p2mt; #endif mfn_t mfn; +#ifdef CONFIG_HAS_PASSTHROUGH bool *dont_flush_p, dont_flush; +#endif int rc; #ifdef CONFIG_X86@@ -385,13 +387,17 @@ int guest_remove_page(struct domain *d,unsigned long gmfn) * Since we're likely to free the page below, we need to suspend * xenmem_add_to_physmap()'s suppressing of IOMMU TLB flushes. */ +#ifdef CONFIG_HAS_PASSTHROUGH dont_flush_p = &this_cpu(iommu_dont_flush_iotlb); dont_flush = *dont_flush_p; *dont_flush_p = false; +#endif rc = guest_physmap_remove_page(d, _gfn(gmfn), mfn, 0);+#ifdef
CONFIG_HAS_PASSTHROUGH
*dont_flush_p=dont_flush;
+#endif
/*
* With the lack of an IOMMU on some platforms, domains with DMA-capablexen/common/memory.c +0
-0@@ -839,11 +845,13 @@ int xenmem_add_to_physmap(struct domain *d,struct xen_add_to_physmap *xatp, xatp->gpfn += start; xatp->size -= start;+#ifdef
CONFIG_HAS_PASSTHROUGH
if (is_iommu_enabled(d))
{
this_cpu(iommu_dont_flush_iotlb)= 1;
extra.ppage = &pages[0];
}
+#endif
while (xatp->size> done )
{xen/common/memory.c +0
-0@@ -868,6 +876,7 @@ int xenmem_add_to_physmap(struct domain *d, struct xen_add_to_physmap *xatp, } }+#ifdef
CONFIG_HAS_PASSTHROUGH
if (is_iommu_enabled(d))
{
int ret;xen/common/memory.c +0
-0@@ -894,6 +903,7 @@ int xenmem_add_to_physmap(struct domain *d,struct xen_add_to_physmap *xatp, if ( unlikely(ret) && rc >= 0 ) rc = ret;Quoted 8 lines
xen/common/memory.c int xenmem_add_to_physmap(struct domain *d, struct xen_add_to_physmap *xatp, · line 909
Quoted 4 lines
xen/common/memory.c +1
-0} +#endif return rc; }I wonder whether all of these wouldn't better become
CONFIG_X86:
ISTR Julien indicating that he doesn't see the override getting used on Arm. (Julien, please correct me if I'm misremembering.)
Quoted 5 lines
Right, so far, I haven't been in favor to introduce it because:
1) The P2M code may free some memory. So you can't always ignore the flush (I think this is wrong for the upper layer to know when this can happen).
2) It is unclear what happen if the IOMMU TLBs and the PT contains different mappings (I received conflicted advice).So it is better to always flush and as early as possible.
So keep it as is or switch to CONFIG_X86?
Thanks,
Connor
Re: [PATCH v3 2/5] xen/common: Guard iommu symbols with CONFIG_HAS_PASSTHROUGH
Quoted 76 lines · Connor Davis
Quoted 74 lines · Julien Grall
Hi Jan,
Quoted 55 lines · Jan Beulich
Quoted 54 lines · Connor Davis
xen/common/memory.c +4
-0@@ -294,7 +294,9 @@ int guest_remove_page(struct domain *d, unsigned long gmfn) p2m_type_t p2mt; #endif mfn_t mfn; +#ifdef CONFIG_HAS_PASSTHROUGH bool *dont_flush_p, dont_flush; +#endif int rc; #ifdef CONFIG_X86@@ -385,13 +387,17 @@ int guest_remove_page(struct domain *d,unsigned long gmfn) * Since we're likely to free the page below, we need to suspend * xenmem_add_to_physmap()'s suppressing of IOMMU TLB flushes. */ +#ifdef CONFIG_HAS_PASSTHROUGH dont_flush_p = &this_cpu(iommu_dont_flush_iotlb); dont_flush = *dont_flush_p; *dont_flush_p = false; +#endif rc = guest_physmap_remove_page(d, _gfn(gmfn), mfn, 0);+#ifdef
CONFIG_HAS_PASSTHROUGH
*dont_flush_p=dont_flush;
+#endif
/*
* With the lack of an IOMMU on some platforms, domains with DMA-capablexen/common/memory.c +0
-0@@ -839,11 +845,13 @@ int xenmem_add_to_physmap(struct domain *d,struct xen_add_to_physmap *xatp, xatp->gpfn += start; xatp->size -= start;+#ifdef
CONFIG_HAS_PASSTHROUGH
if (is_iommu_enabled(d))
{
this_cpu(iommu_dont_flush_iotlb)= 1;
extra.ppage = &pages[0];
}
+#endif
while (xatp->size> done )
{xen/common/memory.c +0
-0@@ -868,6 +876,7 @@ int xenmem_add_to_physmap(struct domain *d, struct xen_add_to_physmap *xatp, } }+#ifdef
CONFIG_HAS_PASSTHROUGH
if (is_iommu_enabled(d))
{
int ret;xen/common/memory.c +0
-0@@ -894,6 +903,7 @@ int xenmem_add_to_physmap(struct domain *d,struct xen_add_to_physmap *xatp, if ( unlikely(ret) && rc >= 0 ) rc = ret;Quoted 8 lines
xen/common/memory.c int xenmem_add_to_physmap(struct domain *d, struct xen_add_to_physmap *xatp, · line 909
Quoted 4 lines
xen/common/memory.c +1
-0} +#endif return rc; }I wonder whether all of these wouldn't better become
CONFIG_X86:
ISTR Julien indicating that he doesn't see the override getting used on Arm. (Julien, please correct me if I'm misremembering.)Right, so far, I haven't been in favor to introduce it because:
1) The P2M code may free some memory. So you can't always ignore the flush (I think this is wrong for the upper layer to know when this can happen).
2) It is unclear what happen if the IOMMU TLBs and the PT contains different mappings (I received conflicted advice).
Quoted 3 lines
Quoted 1 line
So it is better to always flush and as early as possible.
So keep it as is or switch to
CONFIG_X86?
Please switch, unless anyone else voices a strong opinion towards keeping as is.
Jan
Re: [PATCH v3 2/5] xen/common: Guard iommu symbols with CONFIG_HAS_PASSTHROUGH
Quoted 77 lines · Jan Beulich
Quoted 76 lines · Connor Davis
Quoted 74 lines · Julien Grall
Hi Jan,
Quoted 55 lines · Jan Beulich
Quoted 54 lines · Connor Davis
xen/common/memory.c +5
-0@@ -294,7 +294,9 @@ int guest_remove_page(struct domain *d, unsigned long gmfn) p2m_type_t p2mt; #endif mfn_t mfn; +#ifdef CONFIG_HAS_PASSTHROUGH bool *dont_flush_p, dont_flush; +#endif int rc; #ifdef CONFIG_X86@@ -385,13 +387,17 @@ int guest_remove_page(struct domain *d,unsigned long gmfn) * Since we're likely to free the page below, we need to suspend * xenmem_add_to_physmap()'s suppressing of IOMMU TLB flushes. */ +#ifdef CONFIG_HAS_PASSTHROUGH dont_flush_p = &this_cpu(iommu_dont_flush_iotlb); dont_flush = *dont_flush_p; *dont_flush_p = false; +#endif rc = guest_physmap_remove_page(d, _gfn(gmfn), mfn, 0); +#ifdef CONFIG_HAS_PASSTHROUGH *dont_flush_p = dont_flush; +#endif /** With the lack of an IOMMU on some platforms, domains with DMA-capable
xen/common/memory.c +1
-0@@ -839,11 +845,13 @@ int xenmem_add_to_physmap(struct domain *d,struct xen_add_to_physmap *xatp, xatp->gpfn += start; xatp->size -= start; +#ifdef CONFIG_HAS_PASSTHROUGH if ( is_iommu_enabled(d) ) { this_cpu(iommu_dont_flush_iotlb) = 1; extra.ppage = &pages[0]; } +#endif while ( xatp->size > done ) {@@ -868,6 +876,7 @@ int xenmem_add_to_physmap(struct domain *d, struct xen_add_to_physmap *xatp, } } +#ifdef CONFIG_HAS_PASSTHROUGH if ( is_iommu_enabled(d) ) { int ret;@@ -894,6 +903,7 @@ int xenmem_add_to_physmap(struct domain *d,struct xen_add_to_physmap *xatp, if ( unlikely(ret) && rc >= 0 ) rc = ret;Quoted 8 lines
xen/common/memory.c int xenmem_add_to_physmap(struct domain *d, struct xen_add_to_physmap *xatp, · line 909
Quoted 4 lines
xen/common/memory.c +1
-0} +#endif return rc; }I wonder whether all of these wouldn't better become
CONFIG_X86:
ISTR Julien indicating that he doesn't see the override getting used on Arm. (Julien, please correct me if I'm misremembering.)Right, so far, I haven't been in favor to introduce it because:
1) The P2M code may free some memory. So you can't always ignore
the flush (I think this is wrong for the upper layer to know when this can happen).
2) It is unclear what happen if the IOMMU TLBs and the PT contains
different mappings (I received conflicted advice).
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
So it is better to always flush and as early as possible.
So keep it as is or switch to
CONFIG_X86?Please switch, unless anyone else voices a strong opinion towards keeping as is.
I would like to avoid adding more #ifdef CONFIG_X86 in the common code. Can we instead provide a wrapper for them?
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v3 2/5] xen/common: Guard iommu symbols with CONFIG_HAS_PASSTHROUGH
Quoted 82 lines · Julien Grall
Quoted 79 lines · Jan Beulich
Quoted 78 lines · Connor Davis
Quoted 75 lines · Julien Grall
Hi Jan,
Quoted 55 lines · Jan Beulich
Quoted 54 lines · Connor Davis
xen/common/memory.c +5
-0@@ -294,7 +294,9 @@ int guest_remove_page(struct domain *d, unsigned long gmfn) p2m_type_t p2mt; #endif mfn_t mfn; +#ifdef CONFIG_HAS_PASSTHROUGH bool *dont_flush_p, dont_flush; +#endif int rc; #ifdef CONFIG_X86@@ -385,13 +387,17 @@ int guest_remove_page(struct domain *d,unsigned long gmfn) * Since we're likely to free the page below, we need to suspend * xenmem_add_to_physmap()'s suppressing of IOMMU TLB flushes. */ +#ifdef CONFIG_HAS_PASSTHROUGH dont_flush_p = &this_cpu(iommu_dont_flush_iotlb); dont_flush = *dont_flush_p; *dont_flush_p = false; +#endif rc = guest_physmap_remove_page(d, _gfn(gmfn), mfn, 0); +#ifdef CONFIG_HAS_PASSTHROUGH *dont_flush_p = dont_flush; +#endif /** With the lack of an IOMMU on some platforms, domains with DMA-capable
xen/common/memory.c +1
-0@@ -839,11 +845,13 @@ int xenmem_add_to_physmap(struct domain *d,struct xen_add_to_physmap *xatp, xatp->gpfn += start; xatp->size -= start; +#ifdef CONFIG_HAS_PASSTHROUGH if ( is_iommu_enabled(d) ) { this_cpu(iommu_dont_flush_iotlb) = 1; extra.ppage = &pages[0]; } +#endif while ( xatp->size > done ) {@@ -868,6 +876,7 @@ int xenmem_add_to_physmap(struct domain *d, struct xen_add_to_physmap *xatp, } } +#ifdef CONFIG_HAS_PASSTHROUGH if ( is_iommu_enabled(d) ) { int ret;@@ -894,6 +903,7 @@ int xenmem_add_to_physmap(struct domain *d,struct xen_add_to_physmap *xatp, if ( unlikely(ret) && rc >= 0 ) rc = ret;Quoted 8 lines
xen/common/memory.c int xenmem_add_to_physmap(struct domain *d, struct xen_add_to_physmap *xatp, · line 909
Quoted 4 lines
xen/common/memory.c +1
-0} +#endif return rc; }I wonder whether all of these wouldn't better become
CONFIG_X86:
ISTR Julien indicating that he doesn't see the override getting used on Arm. (Julien, please correct me if I'm misremembering.)Right, so far, I haven't been in favor to introduce it because:
1) The P2M code may free some memory. So you can't always ignore
the flush (I think this is wrong for the upper layer to know when this can happen).
2) It is unclear what happen if the IOMMU TLBs and the PT contains
different mappings (I received conflicted advice).So it is better to always flush and as early as possible.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
So keep it as is or switch to
CONFIG_X86?Please switch, unless anyone else voices a strong opinion towards keeping as is.
I would like to avoid adding more #ifdef
CONFIG_X86in the common code. Can we instead provide a wrapper for them?
Doable, sure, but I don't know whether Connor is up to going this more extensive route.
Jan
Re: [PATCH v3 2/5] xen/common: Guard iommu symbols with CONFIG_HAS_PASSTHROUGH
Hi Jan,
Quoted 85 lines · Jan Beulich
Quoted 84 lines · Julien Grall
Quoted 81 lines · Jan Beulich
Quoted 79 lines · Connor Davis
Quoted 67 lines · Julien Grall
Hi Jan,
Quoted 55 lines · Jan Beulich
Quoted 54 lines · Connor Davis
xen/common/memory.c +5
-0@@ -294,7 +294,9 @@ int guest_remove_page(struct domain *d, unsigned long gmfn) p2m_type_t p2mt; #endif mfn_t mfn; +#ifdef CONFIG_HAS_PASSTHROUGH bool *dont_flush_p, dont_flush; +#endif int rc; #ifdef CONFIG_X86@@ -385,13 +387,17 @@ int guest_remove_page(struct domain *d,unsigned long gmfn) * Since we're likely to free the page below, we need to suspend * xenmem_add_to_physmap()'s suppressing of IOMMU TLB flushes. */ +#ifdef CONFIG_HAS_PASSTHROUGH dont_flush_p = &this_cpu(iommu_dont_flush_iotlb); dont_flush = *dont_flush_p; *dont_flush_p = false; +#endif rc = guest_physmap_remove_page(d, _gfn(gmfn), mfn, 0); +#ifdef CONFIG_HAS_PASSTHROUGH *dont_flush_p = dont_flush; +#endif /** With the lack of an IOMMU on some platforms, domains with DMA-capable
xen/common/memory.c +1
-0@@ -839,11 +845,13 @@ int xenmem_add_to_physmap(struct domain *d,struct xen_add_to_physmap *xatp, xatp->gpfn += start; xatp->size -= start; +#ifdef CONFIG_HAS_PASSTHROUGH if ( is_iommu_enabled(d) ) { this_cpu(iommu_dont_flush_iotlb) = 1; extra.ppage = &pages[0]; } +#endif while ( xatp->size > done ) {@@ -868,6 +876,7 @@ int xenmem_add_to_physmap(struct domain *d, struct xen_add_to_physmap *xatp, } } +#ifdef CONFIG_HAS_PASSTHROUGH if ( is_iommu_enabled(d) ) { int ret;@@ -894,6 +903,7 @@ int xenmem_add_to_physmap(struct domain *d,struct xen_add_to_physmap *xatp, if ( unlikely(ret) && rc >= 0 ) rc = ret;Quoted 8 lines
xen/common/memory.c int xenmem_add_to_physmap(struct domain *d, · line 909
Quoted 4 lines
xen/common/memory.c +1
-0} +#endif return rc; }I wonder whether all of these wouldn't better become
CONFIG_X86:
ISTR Julien indicating that he doesn't see the override getting used on Arm. (Julien, please correct me if I'm misremembering.)Quoted 8 lines
Right, so far, I haven't been in favor to introduce it because:
1) The P2M code may free some memory. So you can't always ignore
the flush (I think this is wrong for the upper layer to know when this can happen).
2) It is unclear what happen if the IOMMU TLBs and the PT contains
different mappings (I received conflicted advice).So it is better to always flush and as early as possible.
So keep it as is or switch to
CONFIG_X86?
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Please switch, unless anyone else voices a strong opinion towards keeping as is.
I would like to avoid adding more #ifdef
CONFIG_X86in the common code. Can we instead provide a wrapper for them?Doable, sure, but I don't know whether Connor is up to going this more extensive route.
That's a fair point. If that the case, then I prefer the #ifdef CONFIG_HAS_PASSTHROUGH version.
I can add an item in my todo list to introduce some helpers.
Cheers,
Signature · 1 line
Julien Grall
PATCH v3 3/5 xen: Fix build when !CONFIG_GRANT_TABLE
In reply to Connor DavisMove struct grant_table; in grant_table.h above ifdef CONFIG_GRANT_TABLE. This fixes the following:
/build/xen/include/xen/grant_table.h:84:50: error: 'struct grant_table' declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
84 | static inline int mem_sharing_gref_to_gfn(struct grant_table *gt,
|
--- xen/include/xen/grant_table.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
xen/include/xen/grant_table.h +2 -1
@@ -28,9 +28,10 @@#include <public/grant_table.h> #include <asm/grant_table.h> -#ifdef CONFIG_GRANT_TABLE struct grant_table ; +#ifdef CONFIG_GRANT_TABLE +extern unsigned int opt_max_grant_frames;/* Create/destroy per-domain grant table context. */
Signature · 1 line
2.31.1
Re: [PATCH v3 3/5] xen: Fix build when !CONFIG_GRANT_TABLE
Quoted 8 lines · Connor Davis
Move struct
grant_table; ingrant_table.habove ifdefCONFIG_GRANT_TABLE. This fixes the following:/build/xen/include/xen/grant_table.h:84:50: error: 'struct
grant_table' declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
84 | static inline int mem_sharing_gref_to_gfn(structgrant_table*gt,|
There must be more to this, as e.g. the PV shim does get built with !GRANT_TABLE. Nevertheless, ...
Quoted 1 line
Signed-off-by Connor Davis <[email protected]>
... since the potential of breaking the build is obvious enough,
Jan
Re: [PATCH v3 3/5] xen: Fix build when !CONFIG_GRANT_TABLE
Quoted 4 lines · Jan Beulich
Quoted 3 lines · Connor Davis
Move struct
grant_table; ingrant_table.habove ifdefCONFIG_GRANT_TABLE. This fixes the following:
Quoted 8 lines
Quoted 5 lines
/build/xen/include/xen/grant_table.h:84:50: error: 'struct
grant_table' declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
84 | static inline int mem_sharing_gref_to_gfn(structgrant_table*gt,
|There must be more to this, as e.g. the PV shim does get built with !GRANT_TABLE. Nevertheless, ...
You are right... you're comment made me realize I had only tested this
with XEN_TARGET_ARCH=riscv64. I will rework this.
Quoted 5 lines
Quoted 1 line
Signed-off-by Connor Davis <[email protected]>... since the potential of breaking the build is obvious enough,
Acked-by Jan Beulich <[email protected]>Jan
Thanks,
Connor
Re: [PATCH v3 3/5] xen: Fix build when !CONFIG_GRANT_TABLE
In reply to Jan BeulichQuoted 4 lines · Jan Beulich
Quoted 3 lines · Connor Davis
Move struct
grant_table; ingrant_table.habove ifdefCONFIG_GRANT_TABLE. This fixes the following:
Quoted 8 lines
Quoted 5 lines
/build/xen/include/xen/grant_table.h:84:50: error: 'struct
grant_table' declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
84 | static inline int mem_sharing_gref_to_gfn(structgrant_table*gt,
|There must be more to this, as e.g. the PV shim does get built with !GRANT_TABLE. Nevertheless, ...
Can you elaborate? I tested all defconfigs with and without grant tables
enabled on x86 and ARM and they all build fine.
Quoted 5 lines
Quoted 1 line
Signed-off-by Connor Davis <[email protected]>... since the potential of breaking the build is obvious enough,
Acked-by Jan Beulich <[email protected]>Jan
Thanks,
Connor
Re: [PATCH v3 3/5] xen: Fix build when !CONFIG_GRANT_TABLE
Quoted 11 lines · Connor Davis
Quoted 9 lines · Jan Beulich
Quoted 8 lines · Connor Davis
Move struct
grant_table; ingrant_table.habove ifdefCONFIG_GRANT_TABLE. This fixes the following:/build/xen/include/xen/grant_table.h:84:50: error: 'struct
grant_table' declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
84 | static inline int mem_sharing_gref_to_gfn(structgrant_table*gt,
|
Quoted 6 lines
Quoted 3 lines
There must be more to this, as e.g. the PV shim does get built with !GRANT_TABLE. Nevertheless, ...
Can you elaborate? I tested all defconfigs with and without grant tables
enabled on x86 and ARM and they all build fine.
I'm confused: Everything building fine supports my statement, so if more elaboration was needed, it would be you to make more precise the conditions upon which a build failure would occur. But this is largely moot now, since I did commit your change yesterday already, for, as said, the potential of breaking the build being obvious enough.
Jan
PATCH v3 4/5 xen: Add files needed for minimal riscv build
In reply to Connor DavisAdd arch-specific makefiles and configs needed to build for riscv64. Also add a minimal head.S that is a simple infinite loop. head.o can be built with
$ make XEN_TARGET_ARCH=riscv64 SUBSYSTEMS=xen -C xen TARGET=head.o
No other TARGET is supported at the moment.
--- config/riscv64.mk | 5 ++ xen/Makefile | 8 +- xen/arch/riscv/Kconfig | 52 +++++++++++ xen/arch/riscv/Kconfig.debug | 0 xen/arch/riscv/Makefile | 0 xen/arch/riscv/Rules.mk | 0 xen/arch/riscv/arch.mk | 16 ++++ xen/arch/riscv/asm-offsets.c | 0 xen/arch/riscv/configs/riscv64_defconfig | 12 +++ xen/arch/riscv/head.S | 6 ++ xen/include/asm-riscv/config.h | 110 +++++++++++++++++++++++ 11 files changed, 207 insertions(+), 2 deletions(-) create mode 100644 config/riscv64.mk create mode 100644 xen/arch/riscv/Kconfig create mode 100644 xen/arch/riscv/Kconfig.debug create mode 100644 xen/arch/riscv/Makefile create mode 100644 xen/arch/riscv/Rules.mk create mode 100644 xen/arch/riscv/arch.mk create mode 100644 xen/arch/riscv/asm-offsets.c create mode 100644 xen/arch/riscv/configs/riscv64_defconfig create mode 100644 xen/arch/riscv/head.S create mode 100644 xen/include/asm-riscv/config.h
config/riscv64.mk new file +5 -0
@@ -0,0 +1,5 @@ +CONFIG_RISCV := y +CONFIG_RISCV_64 := y +CONFIG_RISCV_$(XEN_OS) := y + +CONFIG_XEN_INSTALL_SUFFIX :=
xen/Makefile +6 -2
@@ -26,7 +26,9 @@ MAKEFLAGS += -rR EFI_MOUNTPOINT ?= $(BOOT_DIR)/efi ARCH=$(XEN_TARGET_ARCH) -SRCARCH=$(shell echo $(ARCH) | sed -e 's/x86.*/x86/' -e s'/arm\(32\|64\)/arm/g') +SRCARCH=$(shell echo $(ARCH) | \ + sed -e 's/x86.*/x86/' -e s'/arm\(32\|64\)/arm/g' \ + -e s'/riscv.*/riscv/g') # Don't break if the build process wasn't called from the top level # we need XEN_TARGET_ARCH to generate the proper config
@@ -35,7 +37,8 @@ include $(XEN_ROOT)/Config.mk # Set ARCH/SUBARCH appropriately. export TARGET_SUBARCH := $(XEN_TARGET_ARCH) export TARGET_ARCH := $(shell echo $(XEN_TARGET_ARCH) | \ - sed -e 's/x86.*/x86/' -e s'/arm\(32\|64\)/arm/g') + sed -e 's/x86.*/x86/' -e s'/arm\(32\|64\)/arm/g' \ + -e s'/riscv.*/riscv/g') # Allow someone to change their config file export KCONFIG_CONFIG ?= .config
@@ -335,6 +338,7 @@ _clean: delete-unfresh-files $(MAKE) $(clean) xsm $(MAKE) $(clean) crypto $(MAKE) $(clean) arch/arm + $(MAKE) $(clean) arch/riscv $(MAKE) $(clean) arch/x86 $(MAKE) $(clean) test $(MAKE) -f $(BASEDIR)/tools/kconfig/Makefile.kconfig ARCH=$(ARCH) SRCARCH=$(SRCARCH) clean
xen/arch/riscv/Kconfig new file +52 -0
52 lines not on this page · raw message
xen/arch/riscv/Kconfig.debug new file +0 -0
xen/arch/riscv/Makefile new file +0 -0
xen/arch/riscv/Rules.mk new file +0 -0
xen/arch/riscv/arch.mk new file +16 -0
@@ -0,0 +1,16 @@ +######################################## +# RISCV-specific definitions + +ifeq ($(CONFIG_RISCV_64),y) + CFLAGS += -mabi=lp64 +endif + +riscv-march-$(CONFIG_RISCV_ISA_RV64IMA) := rv64ima +riscv-march-$(CONFIG_RISCV_ISA_C) := $(riscv-march-y)c + +# Note that -mcmodel=medany is used so that Xen can be mapped +# into the upper half _or_ the lower half of the address space. +# -mcmodel=medlow would force Xen into the lower half. + +CFLAGS += -march=$(riscv-march-y) -mstrict-align -mcmodel=medany +CFLAGS += -I$(BASEDIR)/include
xen/arch/riscv/asm-offsets.c new file +0 -0
xen/arch/riscv/configs/riscv64_defconfig new file +12 -0
@@ -0,0 +1,12 @@ +# CONFIG_SCHED_CREDIT is not set +# CONFIG_SCHED_RTDS is not set +# CONFIG_SCHED_NULL is not set +# CONFIG_SCHED_ARINC653 is not set +# CONFIG_TRACEBUFFER is not set +# CONFIG_DEBUG is not set +# CONFIG_DEBUG_INFO is not set +# CONFIG_HYPFS is not set +# CONFIG_GRANT_TABLE is not set +# CONFIG_SPECULATIVE_HARDEN_ARRAY is not set + +CONFIG_EXPERT=y
xen/arch/riscv/head.S new file +6 -0
@@ -0,0 +1,6 @@ +#include <asm/config.h> + + .text + +ENTRY(start) + j start
xen/include/asm-riscv/config.h new file +110 -0
110 lines not on this page · raw message
Signature · 1 line
2.31.1
Re: [PATCH v3 4/5] xen: Add files needed for minimal riscv build
Quoted 6 lines · Connor Davis
Add arch-specific makefiles and configs needed to build for riscv64. Also add a minimal
head.Sthat is a simple infinite loop. head.o can be built with$ make XEN_TARGET_ARCH=riscv64 SUBSYSTEMS=xen -C xen TARGET=head.o
I recently realized that the Linux kernel build uses ARCH=riscv with 32 vs 64 being differentiated by Kconfig opts (and __riscv_xlen). I think riscv64 was inherited by arm64. This is something I'd like to eventually change the Xen build to (i.e., XEN_TARGET_ARCH=riscv make) would it be possible for us to get that in this series?
...
Quoted 15 lines
xen/include/asm-riscv/config.h new file +9
-0@@ -0,0 +1,110 @@ +/****************************************************************************** +* config.h +* +* A Linux-style configuration list. +*/ + +#ifndef __RISCV_CONFIG_H__ +#define __RISCV_CONFIG_H__ +
...
Quoted 22 lines
xen/include/asm-riscv/config.h new file +22
-0+ +#ifdef CONFIG_RISCV_64 + +/* +* RISC-V Layout: +* 0x0000000000000000 - 0x0000003fffffffff (256GB, L2 slots [0-255]) +* Unmapped +* 0x0000004000000000 - 0xffffffbfffffffff +* Inaccessible: sv39 only supports 39-bit sign-extended VAs. +* 0xffffffc000000000 - 0xffffffc0001fffff (2MB, L2 slot [256]) +* Unmapped +* 0xffffffc000200000 - 0xffffffc0003fffff (2MB, L2 slot [256]) +* Xen text, data, bss +* 0xffffffc000400000 - 0xffffffc0005fffff (2MB, L2 slot [256]) +* Fixmap: special-purpose 4K mapping slots +* 0xffffffc000600000 - 0xffffffc0009fffff (4MB, L2 slot [256]) +* Early boot mapping of FDT +* 0xffffffc000a00000 - 0xffffffc000bfffff (2MB, L2 slot [256]) +* Early relocation address, used when relocating Xen and later +* for livepatch vmap (if compiled in) +* 0xffffffc040000000 - 0xffffffc07fffffff (1GB, L2 slot [257]) +* VMAP: ioremap and early_ioremap
xen/include/asm-riscv/config.h line 85
Quoted 10 lines
xen/include/asm-riscv/config.h new file +10
-0+* 0xffffffc080000000 - 0xffffffc13fffffff (3GB, L2 slots [258..260]) +* Unmapped +* 0xffffffc140000000 - 0xffffffc1bfffffff (2GB, L2 slots [261..262]) +* Frametable: 48 bytes per page for 133GB of RAM +* 0xffffffc1c0000000 - 0xffffffe1bfffffff (128GB, L2 slots [263..390]) +* 1:1 direct mapping of RAM +* 0xffffffe1c0000000 - 0xffffffffffffffff (121GB, L2 slots [391..511]) +* Unmapped +*/ +
What is the benefit of moving the layout up to 0xffffffc000000000?
Signature · 2 lines
Bobby Eshleman SE at Vates SAS
Re: [PATCH v3 4/5] xen: Add files needed for minimal riscv build
Quoted 5 lines · Bob Eshleman
Quoted 4 lines · Connor Davis
Add arch-specific makefiles and configs needed to build for riscv64. Also add a minimal
head.Sthat is a simple infinite loop. head.o can be built with
Quoted 8 lines
Quoted 2 lines
$ make XEN_TARGET_ARCH=riscv64 SUBSYSTEMS=xen -C xen TARGET=head.oI recently realized that the Linux kernel build uses
ARCH=riscvwith 32 vs 64 being differentiated byKconfigopts (and__riscv_xlen). I thinkriscv64was inherited byarm64. This is something I'd like to eventually change the Xen build to (i.e.,XEN_TARGET_ARCH=riscv make) would it be possible for us to get that in this series?
Sure, I can do that
Quoted 43 lines
Quoted 16 lines
xen/include/asm-riscv/config.h new file +9
-0@@ -0,0 +1,110 @@ +/****************************************************************************** +* config.h +* +* A Linux-style configuration list. +*/ + +#ifndef __RISCV_CONFIG_H__ +#define __RISCV_CONFIG_H__ +...
Quoted 25 lines
xen/include/asm-riscv/config.h new file +25
-0+ +#ifdef CONFIG_RISCV_64 + +/* +* RISC-V Layout: +* 0x0000000000000000 - 0x0000003fffffffff (256GB, L2 slots [0-255]) +* Unmapped +* 0x0000004000000000 - 0xffffffbfffffffff +* Inaccessible: sv39 only supports 39-bit sign-extended VAs. +* 0xffffffc000000000 - 0xffffffc0001fffff (2MB, L2 slot [256]) +* Unmapped +* 0xffffffc000200000 - 0xffffffc0003fffff (2MB, L2 slot [256]) +* Xen text, data, bss +* 0xffffffc000400000 - 0xffffffc0005fffff (2MB, L2 slot [256]) +* Fixmap: special-purpose 4K mapping slots +* 0xffffffc000600000 - 0xffffffc0009fffff (4MB, L2 slot [256]) +* Early boot mapping of FDT +* 0xffffffc000a00000 - 0xffffffc000bfffff (2MB, L2 slot [256]) +* Early relocation address, used when relocating Xen and later +* for livepatch vmap (if compiled in) +* 0xffffffc040000000 - 0xffffffc07fffffff (1GB, L2 slot [257]) +* VMAP: ioremap and early_ioremap +* 0xffffffc080000000 - 0xffffffc13fffffff (3GB, L2 slots [258..260]) +* Unmapped +* 0xffffffc140000000 - 0xffffffc1bfffffff (2GB, L2 slots [261..262])
Quoted 8 lines
Quoted 7 lines
+ * Frametable: 48 bytes per page for 133GB of RAM
+ *0xffffffc1c0000000-0xffffffe1bfffffff(128GB, L2 slots [263..390])
+ * 1:1 direct mapping of RAM
+ *0xffffffe1c0000000-0xffffffffffffffff(121GB, L2 slots [391..511])
+ * Unmapped
+ */
+What is the benefit of moving the layout up to
0xffffffc000000000?
I thought it made the most sense to use the upper half since Xen is privileged
and privileged code is typically mapped in the upper half, at least on x86. I'm happy to
move it down if that would be preferred.
Thanks,
Connor
Re: [PATCH v3 4/5] xen: Add files needed for minimal riscv build
Quoted 38 lines · Connor Davis
Quoted 27 lines · Bob Eshleman
Quoted 25 lines · Connor Davis
xen/include/asm-riscv/config.h new file +25
-0+ +#ifdef CONFIG_RISCV_64 + +/* +* RISC-V Layout: +* 0x0000000000000000 - 0x0000003fffffffff (256GB, L2 slots [0-255]) +* Unmapped +* 0x0000004000000000 - 0xffffffbfffffffff +* Inaccessible: sv39 only supports 39-bit sign-extended VAs. +* 0xffffffc000000000 - 0xffffffc0001fffff (2MB, L2 slot [256]) +* Unmapped +* 0xffffffc000200000 - 0xffffffc0003fffff (2MB, L2 slot [256]) +* Xen text, data, bss +* 0xffffffc000400000 - 0xffffffc0005fffff (2MB, L2 slot [256]) +* Fixmap: special-purpose 4K mapping slots +* 0xffffffc000600000 - 0xffffffc0009fffff (4MB, L2 slot [256]) +* Early boot mapping of FDT +* 0xffffffc000a00000 - 0xffffffc000bfffff (2MB, L2 slot [256]) +* Early relocation address, used when relocating Xen and later +* for livepatch vmap (if compiled in) +* 0xffffffc040000000 - 0xffffffc07fffffff (1GB, L2 slot [257]) +* VMAP: ioremap and early_ioremap +* 0xffffffc080000000 - 0xffffffc13fffffff (3GB, L2 slots [258..260]) +* Unmapped +* 0xffffffc140000000 - 0xffffffc1bfffffff (2GB, L2 slots [261..262]) Quoted 8 lines
Quoted 7 lines
+ * Frametable: 48 bytes per page for 133GB of RAM
+ *0xffffffc1c0000000-0xffffffe1bfffffff(128GB, L2 slots [263..390])
+ * 1:1 direct mapping of RAM
+ *0xffffffe1c0000000-0xffffffffffffffff(121GB, L2 slots [391..511])
+ * Unmapped
+ */
+What is the benefit of moving the layout up to
0xffffffc000000000?
Quoted 7 lines
I thought it made the most sense to use the upper half since Xen is privileged
and privileged code is typically mapped in the upper half, at least on x86. I'm happy to
move it down if that would be preferred.
I do like the idea of following norms, but I think I prefer following the ARM norm over the x86 norm unless there is a technical reason not to. Just due to ARM and RISC-V having much more overlap than x86 and RISC-V. In this case, all things being equal, I'd prefer following the ARM model and use the lower half. I definitely like adding the note on the inaccessible region.
Thanks,
Signature · 2 lines
Bobby Eshleman SE at Vates SAS
Re: [PATCH v3 4/5] xen: Add files needed for minimal riscv build
Quoted 41 lines · Bob Eshleman
Quoted 40 lines · Connor Davis
Quoted 27 lines · Bob Eshleman
Quoted 25 lines · Connor Davis
xen/include/asm-riscv/config.h new file +25
-0+ +#ifdef CONFIG_RISCV_64 + +/* +* RISC-V Layout: +* 0x0000000000000000 - 0x0000003fffffffff (256GB, L2 slots [0-255]) +* Unmapped +* 0x0000004000000000 - 0xffffffbfffffffff +* Inaccessible: sv39 only supports 39-bit sign-extended VAs. +* 0xffffffc000000000 - 0xffffffc0001fffff (2MB, L2 slot [256]) +* Unmapped +* 0xffffffc000200000 - 0xffffffc0003fffff (2MB, L2 slot [256]) +* Xen text, data, bss +* 0xffffffc000400000 - 0xffffffc0005fffff (2MB, L2 slot [256]) +* Fixmap: special-purpose 4K mapping slots +* 0xffffffc000600000 - 0xffffffc0009fffff (4MB, L2 slot [256]) +* Early boot mapping of FDT +* 0xffffffc000a00000 - 0xffffffc000bfffff (2MB, L2 slot [256]) +* Early relocation address, used when relocating Xen and later +* for livepatch vmap (if compiled in) +* 0xffffffc040000000 - 0xffffffc07fffffff (1GB, L2 slot [257]) +* VMAP: ioremap and early_ioremap +* 0xffffffc080000000 - 0xffffffc13fffffff (3GB, L2 slots [258..260]) +* Unmapped +* 0xffffffc140000000 - 0xffffffc1bfffffff (2GB, L2 slots [261..262]) Quoted 8 lines
Quoted 7 lines
+ * Frametable: 48 bytes per page for 133GB of RAM
+ *0xffffffc1c0000000-0xffffffe1bfffffff(128GB, L2 slots [263..390])
+ * 1:1 direct mapping of RAM
+ *0xffffffe1c0000000-0xffffffffffffffff(121GB, L2 slots [391..511])
+ * Unmapped
+ */
+What is the benefit of moving the layout up to
0xffffffc000000000?I thought it made the most sense to use the upper half since Xen is privileged
and privileged code is typically mapped in the upper half, at least on x86. I'm happy to
Quoted 8 lines
Quoted 3 lines
move it down if that would be preferred.
I do like the idea of following norms, but I think I prefer following the ARM norm over the x86 norm unless there is a technical reason not to. Just due to ARM and RISC-V having much more overlap than x86 and RISC-V. In this case, all things being equal, I'd prefer following the ARM model and use the lower half. I definitely like adding the note on the inaccessible region.
Sounds good, I will move it down.
Thanks,
Connor
Re: [PATCH v3 4/5] xen: Add files needed for minimal riscv build
In reply to Connor Davisconfig/riscv64.mk line 3
Quoted 6 lines · Connor Davis
config/riscv64.mk new file +3
-0@@ -0,0 +1,5 @@ +CONFIG_RISCV := y +CONFIG_RISCV_64 := y +CONFIG_RISCV_$(XEN_OS) := y
I wonder whether the last one actually gets used anywhere, but I do realize that other architectures have similar definitions.
xen/Makefile MAKEFLAGS += -rR · line 31
Quoted 10 lines
xen/Makefile +3
-1@@ -26,7 +26,9 @@ MAKEFLAGS += -rR EFI_MOUNTPOINT ?= $(BOOT_DIR)/efi ARCH=$(XEN_TARGET_ARCH) -SRCARCH=$(shell echo $(ARCH) | sed -e 's/x86.*/x86/' -e s'/arm\(32\|64\)/arm/g') +SRCARCH=$(shell echo $(ARCH) | \ + sed -e 's/x86.*/x86/' -e s'/arm\(32\|64\)/arm/g' \ + -e s'/riscv.*/riscv/g')
I think in makefiles tab indentation would better be restricted to rules. While here it's a minor nit, ...
xen/Makefile include $(XEN_ROOT)/Config.mk · line 41
Quoted 7 lines
xen/Makefile +2
-1@@ -35,7 +37,8 @@ include $(XEN_ROOT)/Config.mk # Set ARCH/SUBARCH appropriately. export TARGET_SUBARCH := $(XEN_TARGET_ARCH) export TARGET_ARCH := $(shell echo $(XEN_TARGET_ARCH) | \ - sed -e 's/x86.*/x86/' -e s'/arm\(32\|64\)/arm/g') + sed -e 's/x86.*/x86/' -e s'/arm\(32\|64\)/arm/g' \ + -e s'/riscv.*/riscv/g')
... here you're actually introducing locally inconsistent indentation.
xen/arch/riscv/Kconfig line 2
Quoted 5 lines
xen/arch/riscv/Kconfig new file +2
-0@@ -0,0 +1,52 @@ +config 64BIT + bool
I'm afraid this is stale now - the option now lives in xen/arch/Kconfig, available to all architectures.
xen/arch/riscv/Kconfig line 6
Quoted 3 lines
xen/arch/riscv/Kconfig new file +3
-0+config RISCV_64 + bool + depends on 64BIT
Such a "depends on" is relatively pointless - they're more important to have when there is a prompt.
xen/arch/riscv/Kconfig line 13
Quoted 3 lines
xen/arch/riscv/Kconfig new file +3
-0+config ARCH_DEFCONFIG + string + default "arch/riscv/configs/riscv64_defconfig" if RISCV_64
For the RISCV_64 dependency to be really useful (at least with the command line kconfig), you want its selection to live above the use.
Quoted 8 lines
xen/arch/riscv/Kconfig new file +8
-0+menu "Architecture Features" + +source "arch/Kconfig" + +endmenu + +menu "ISA Selection" +
xen/arch/riscv/Kconfig line 32
Quoted 10 lines
xen/arch/riscv/Kconfig new file +10
-0+choice + prompt "Base ISA" + default RISCV_ISA_RV64IMA + help + This selects the base ISA extensions that Xen will target. + +config RISCV_ISA_RV64IMA + bool "RV64IMA" + select 64BIT + select RISCV_64
I think you want only the latter here, and the former done by RISCV_64 (or select the former here, and have "default y if 64BIT" at RISCV_64). That way, not every party wanting 64-bit has to select both.
Quoted 4 lines
xen/arch/riscv/Kconfig new file +4
-0+ help + Use the RV64I base ISA, plus the "M" and "A" extensions + for integer multiply/divide and atomic instructions, respectively. +
xen/arch/riscv/Kconfig line 46
Quoted 10 lines
xen/arch/riscv/Kconfig new file +10
-0+endchoice + +config RISCV_ISA_C + bool "Compressed extension" + help + Add "C" to the ISA subsets that the toolchain is allowed + to emit when building Xen, which results in compressed + instructions in the Xen binary. + + If unsure, say N.
For all of the above, please adjust indentation to be consistent with (the bulk of) what we have elsewhere.
xen/arch/riscv/arch.mk line 6
Quoted 9 lines
xen/arch/riscv/arch.mk new file +6
-0@@ -0,0 +1,16 @@ +######################################## +# RISCV-specific definitions + +ifeq ($(CONFIG_RISCV_64),y) + CFLAGS += -mabi=lp64 +endif
Wherever possible I think we should prefer the list approach:
CFLAGS-$(CONFIG_RISCV_64) += -mabi=lp64
Quoted 5 lines
xen/arch/riscv/configs/riscv64_defconfig new file +2
-0@@ -0,0 +1,12 @@ +# CONFIG_SCHED_CREDIT is not set +# CONFIG_SCHED_RTDS is not set
xen/arch/riscv/configs/riscv64_defconfig line 12
Quoted 10 lines
xen/arch/riscv/configs/riscv64_defconfig new file +10
-0+# CONFIG_SCHED_NULL is not set +# CONFIG_SCHED_ARINC653 is not set +# CONFIG_TRACEBUFFER is not set +# CONFIG_DEBUG is not set +# CONFIG_DEBUG_INFO is not set +# CONFIG_HYPFS is not set +# CONFIG_GRANT_TABLE is not set +# CONFIG_SPECULATIVE_HARDEN_ARRAY is not set + +CONFIG_EXPERT=y
These are rather odd defaults, more like for a special purpose config than a general purpose one. None of what you turn off here will guarantee to be off for people actually trying to build things, so it's not clear to me what the idea here is. As a specific remark, especially during bringup work I think it is quite important to not default DEBUG to off: You definitely want to see whether any assertions trigger.
xen/include/asm-riscv/config.h line 4
Quoted 7 lines
xen/include/asm-riscv/config.h new file +4
-0@@ -0,0 +1,110 @@ +/****************************************************************************** +* config.h +* +* A Linux-style configuration list.
May I suggest to not further replicate this now inapplicable comment? It was already somewhat bogus for Arm to clone from x86.
Quoted 12 lines
xen/include/asm-riscv/config.h new file +12
-0+*/ + +#ifndef __RISCV_CONFIG_H__ +#define __RISCV_CONFIG_H__ + +#if defined(CONFIG_RISCV_64 ) +# define LONG_BYTEORDER 3 +# define ELFSIZE 64 +#else +# error "Unsupported RISCV variant" +#endif +
xen/include/asm-riscv/config.h line 26
Quoted 10 lines
xen/include/asm-riscv/config.h new file +10
-0+#define BYTES_PER_LONG (1 << LONG_BYTEORDER) +#define BITS_PER_LONG (BYTES_PER_LONG << 3) +#define POINTER_ALIGN BYTES_PER_LONG + +#define BITS_PER_LLONG 64 + +/* xen_ulong_t is always 64 bits */ +#define BITS_PER_XEN_ULONG 64 + +#define CONFIG_RISCV 1
This duplicates a "real" Kconfig setting, doesn't it?
xen/include/asm-riscv/config.h line 39
Quoted 13 lines
xen/include/asm-riscv/config.h new file +13
-0+#define CONFIG_RISCV_L1_CACHE_SHIFT 6 + +#define CONFIG_PAGEALLOC_MAX_ORDER 18 +#define CONFIG_DOMU_MAX_ORDER 9 +#define CONFIG_HWDOM_MAX_ORDER 10 + +#define OPT_CONSOLE_STR "dtuart" + +#ifdef CONFIG_RISCV_64 +#define MAX_VIRT_CPUS 128u +#else +#error "Unsupported RISCV variant" +#endif
Could this be folded with the other similar construct further up?
Jan
Re: [PATCH v3 4/5] xen: Add files needed for minimal riscv build
Quoted 74 lines · Jan Beulich
config/riscv64.mk line 3
Quoted 6 lines · Connor Davis
config/riscv64.mk new file +3
-0@@ -0,0 +1,5 @@ +CONFIG_RISCV := y +CONFIG_RISCV_64 := y +CONFIG_RISCV_$(XEN_OS) := yI wonder whether the last one actually gets used anywhere, but I do realize that other architectures have similar definitions.
xen/Makefile MAKEFLAGS += -rR · line 31
Quoted 10 lines
xen/Makefile +3
-1@@ -26,7 +26,9 @@ MAKEFLAGS += -rR EFI_MOUNTPOINT ?= $(BOOT_DIR)/efi ARCH=$(XEN_TARGET_ARCH) -SRCARCH=$(shell echo $(ARCH) | sed -e 's/x86.*/x86/' -e s'/arm\(32\|64\)/arm/g') +SRCARCH=$(shell echo $(ARCH) | \ + sed -e 's/x86.*/x86/' -e s'/arm\(32\|64\)/arm/g' \ + -e s'/riscv.*/riscv/g')I think in makefiles tab indentation would better be restricted to rules. While here it's a minor nit, ...
xen/Makefile include $(XEN_ROOT)/Config.mk · line 41
Quoted 7 lines
xen/Makefile +2
-1@@ -35,7 +37,8 @@ include $(XEN_ROOT)/Config.mk # Set ARCH/SUBARCH appropriately. export TARGET_SUBARCH := $(XEN_TARGET_ARCH) export TARGET_ARCH := $(shell echo $(XEN_TARGET_ARCH) | \ - sed -e 's/x86.*/x86/' -e s'/arm\(32\|64\)/arm/g') + sed -e 's/x86.*/x86/' -e s'/arm\(32\|64\)/arm/g' \ + -e s'/riscv.*/riscv/g')... here you're actually introducing locally inconsistent indentation.
xen/arch/riscv/Kconfig line 2
Quoted 5 lines
xen/arch/riscv/Kconfig new file +2
-0@@ -0,0 +1,52 @@ +config 64BIT + boolI'm afraid this is stale now - the option now lives in xen/arch/Kconfig, available to all architectures.
xen/arch/riscv/Kconfig line 6
Quoted 3 lines
xen/arch/riscv/Kconfig new file +3
-0+config RISCV_64 + bool + depends on 64BITSuch a "depends on" is relatively pointless - they're more important to have when there is a prompt.
xen/arch/riscv/Kconfig line 13
Quoted 3 lines
xen/arch/riscv/Kconfig new file +3
-0+config ARCH_DEFCONFIG + string + default "arch/riscv/configs/riscv64_defconfig" if RISCV_64For the
RISCV_64dependency to be really useful (at least with the command line kconfig), you want its selection to live above the use.Quoted 8 lines
xen/arch/riscv/Kconfig new file +8
-0+menu "Architecture Features" + +source "arch/Kconfig" + +endmenu + +menu "ISA Selection" +xen/arch/riscv/Kconfig line 32
Quoted 10 lines
xen/arch/riscv/Kconfig new file +10
-0+choice + prompt "Base ISA" + default RISCV_ISA_RV64IMA + help + This selects the base ISA extensions that Xen will target. + +config RISCV_ISA_RV64IMA + bool "RV64IMA" + select 64BIT + select RISCV_64I think you want only the latter here, and the former done by
RISCV_64(or select the former here, and have "default y if 64BIT" atRISCV_64). That way, not every party wanting 64-bit has to select both.
Quoted 16 lines
Quoted 4 lines
xen/arch/riscv/Kconfig new file +4
-0+ help + Use the RV64I base ISA, plus the "M" and "A" extensions + for integer multiply/divide and atomic instructions, respectively. +xen/arch/riscv/Kconfig line 46
Quoted 10 lines
xen/arch/riscv/Kconfig new file +10
-0+endchoice + +config RISCV_ISA_C + bool "Compressed extension" + help + Add "C" to the ISA subsets that the toolchain is allowed + to emit when building Xen, which results in compressed + instructions in the Xen binary. + + If unsure, say N.For all of the above, please adjust indentation to be consistent with (the bulk of) what we have elsewhere.
Will do
Quoted 27 lines
xen/arch/riscv/arch.mk line 6
Quoted 9 lines
xen/arch/riscv/arch.mk new file +6
-0@@ -0,0 +1,16 @@ +######################################## +# RISCV-specific definitions + +ifeq ($(CONFIG_RISCV_64),y) + CFLAGS += -mabi=lp64 +endifWherever possible I think we should prefer the list approach:
CFLAGS-$(CONFIG_RISCV_64) += -mabi=lp64
Quoted 14 lines
xen/arch/riscv/configs/riscv64_defconfig new file +11
-0@@ -0,0 +1,12 @@ +# CONFIG_SCHED_CREDIT is not set +# CONFIG_SCHED_RTDS is not set +# CONFIG_SCHED_NULL is not set +# CONFIG_SCHED_ARINC653 is not set +# CONFIG_TRACEBUFFER is not set +# CONFIG_DEBUG is not set +# CONFIG_DEBUG_INFO is not set +# CONFIG_HYPFS is not set +# CONFIG_GRANT_TABLE is not set +# CONFIG_SPECULATIVE_HARDEN_ARRAY is not set +
Quoted 8 lines
xen/arch/riscv/configs/riscv64_defconfig line 12
Quoted 1 line
xen/arch/riscv/configs/riscv64_defconfig new file +1
-0+CONFIG_EXPERT=yThese are rather odd defaults, more like for a special purpose config than a general purpose one. None of what you turn off here will guarantee to be off for people actually trying to build things, so it's not clear to me what the idea here is. As a specific remark, especially during bringup work I think it is quite important to not default DEBUG to off: You definitely want to see whether any assertions trigger.
The idea was to turn off as much stuff as possible to get a minimal build (involving xen/common) working. Although now that we're focused on only a few files at a time, they could be enabled without adding any undue burden (at least for now).
Perhaps it would be best to rename the file to include "tiny" or something, and then add a normal defconfig once things are actually running?
At any rate, agreed on the DEBUG setting, I will enable that.
Quoted 9 lines
xen/include/asm-riscv/config.h line 4
Quoted 7 lines
xen/include/asm-riscv/config.h new file +4
-0@@ -0,0 +1,110 @@ +/****************************************************************************** +* config.h +* +* A Linux-style configuration list. May I suggest to not further replicate this now inapplicable comment? It was already somewhat bogus for Arm to clone from x86.
Sure thing.
Quoted 16 lines
Quoted 16 lines
xen/include/asm-riscv/config.h new file +15
-0+*/ + +#ifndef __RISCV_CONFIG_H__ +#define __RISCV_CONFIG_H__ + +#if defined(CONFIG_RISCV_64 ) +# define LONG_BYTEORDER 3 +# define ELFSIZE 64 +#else +# error "Unsupported RISCV variant" +#endif + +#define BYTES_PER_LONG (1 << LONG_BYTEORDER) +#define BITS_PER_LONG (BYTES_PER_LONG << 3) +#define POINTER_ALIGN BYTES_PER_LONG
Quoted 8 lines
xen/include/asm-riscv/config.h line 26
Quoted 7 lines
xen/include/asm-riscv/config.h new file +7
-0+ +#define BITS_PER_LLONG 64 + +/* xen_ulong_t is always 64 bits */ +#define BITS_PER_XEN_ULONG 64 + +#define CONFIG_RISCV 1This duplicates a "real"
Kconfigsetting, doesn't it?
Yes, will remove, thanks
Quoted 15 lines
Quoted 4 lines
xen/include/asm-riscv/config.h new file +3
-0+#define CONFIG_RISCV_L1_CACHE_SHIFT 6 + +#define CONFIG_PAGEALLOC_MAX_ORDER 18xen/include/asm-riscv/config.h line 39
Quoted 10 lines
xen/include/asm-riscv/config.h new file +10
-0+#define CONFIG_DOMU_MAX_ORDER 9 +#define CONFIG_HWDOM_MAX_ORDER 10 + +#define OPT_CONSOLE_STR "dtuart" + +#ifdef CONFIG_RISCV_64 +#define MAX_VIRT_CPUS 128u +#else +#error "Unsupported RISCV variant" +#endif Could this be folded with the other similar construct further up?
Yep, will do.
Thanks,
Connor
Re: [PATCH v3 4/5] xen: Add files needed for minimal riscv build
Quoted 24 lines · Connor Davis
Quoted 15 lines · Jan Beulich
Quoted 14 lines · Connor Davis
xen/arch/riscv/configs/riscv64_defconfig new file +11
-0@@ -0,0 +1,12 @@ +# CONFIG_SCHED_CREDIT is not set +# CONFIG_SCHED_RTDS is not set +# CONFIG_SCHED_NULL is not set +# CONFIG_SCHED_ARINC653 is not set +# CONFIG_TRACEBUFFER is not set +# CONFIG_DEBUG is not set +# CONFIG_DEBUG_INFO is not set +# CONFIG_HYPFS is not set +# CONFIG_GRANT_TABLE is not set +# CONFIG_SPECULATIVE_HARDEN_ARRAY is not set +Quoted 8 lines
xen/arch/riscv/configs/riscv64_defconfig line 12
Quoted 1 line
xen/arch/riscv/configs/riscv64_defconfig new file +1
-0+CONFIG_EXPERT=yThese are rather odd defaults, more like for a special purpose config than a general purpose one. None of what you turn off here will guarantee to be off for people actually trying to build things, so it's not clear to me what the idea here is. As a specific remark, especially during bringup work I think it is quite important to not default DEBUG to off: You definitely want to see whether any assertions trigger.
Quoted 7 lines
The idea was to turn off as much stuff as possible to get a minimal build (involving xen/common) working. Although now that we're focused on only a few files at a time, they could be enabled without adding any undue burden (at least for now).
Perhaps it would be best to rename the file to include "tiny" or something, and then add a normal defconfig once things are actually running?
Yes please.
Jan
PATCH v3 5/5 automation: Add container for riscv64 builds
In reply to Connor DavisAdd a container for cross-compiling xen to riscv64. This just includes the cross-compiler and necessary packages for building xen itself (packages for tools, stubdoms, etc., can be added later).
--- automation/build/archlinux/riscv64.dockerfile | 33 +++++++++++++++++++ automation/scripts/containerize | 1 + 2 files changed, 34 insertions(+) create mode 100644 automation/build/archlinux/riscv64.dockerfile
automation/build/archlinux/riscv64.dockerfile new file +33 -0
@@ -0,0 +1,33 @@ +FROM archlinux +LABEL maintainer.name="The Xen Project" \ + maintainer.email="[email protected]" + +# Packages needed for the build +RUN pacman --noconfirm --needed -Syu \ + base-devel \ + gcc \ + git + +# Packages needed for QEMU +RUN pacman --noconfirm --needed -Syu \ + pixman \ + python \ + sh + +# There is a regression in GDB that causes an assertion error +# when setting breakpoints, use this commit until it is fixed! +RUN git clone --recursive -j$(nproc) --progress https://github.com/riscv/riscv-gnu-toolchain && \ + cd riscv-gnu-toolchain/riscv-gdb && \ + git checkout 1dd588507782591478882a891f64945af9e2b86c && \ + cd .. && \ + ./configure --prefix=/opt/riscv && \ + make linux -j$(nproc) && \ + rm -R /riscv-gnu-toolchain + +# Add compiler path +ENV PATH=/opt/riscv/bin/:${PATH} +ENV CROSS_COMPILE=riscv64-unknown-linux-gnu- + +RUN useradd --create-home user +USER user +WORKDIR /build
automation/scripts/containerize +1 -0
@@ -26,6 +26,7 @@ BASE="registry.gitlab.com/xen-project/xen" case "_${CONTAINER}" in _alpine) CONTAINER="${BASE}/alpine:3.12" ;; _archlinux|_arch) CONTAINER="${BASE}/archlinux:current" ;; + _riscv64) CONTAINER="${BASE}/archlinux:riscv64" ;; _centos7) CONTAINER="${BASE}/centos:7" ;; _centos72) CONTAINER="${BASE}/centos:7.2" ;; _fedora) CONTAINER="${BASE}/fedora:29";;
Signature · 1 line
2.31.1
Re: [PATCH v3 5/5] automation: Add container for riscv64 builds
automation/build/archlinux/riscv64.dockerfile
Quoted 10 lines · Connor Davis
automation/build/archlinux/riscv64.dockerfile new file +10
-0+ +# There is a regression in GDB that causes an assertion error +# when setting breakpoints, use this commit until it is fixed! +RUN git clone --recursive -j$(nproc) --progress https://github.com/riscv/riscv-gnu-toolchain && \ + cd riscv-gnu-toolchain/riscv-gdb && \ + git checkout 1dd588507782591478882a891f64945af9e2b86c && \ + cd .. && \ + ./configure --prefix=/opt/riscv && \ + make linux -j$(nproc) && \ + rm -R /riscv-gnu-toolchai
What do you think about using the RISCV tool chain from the Arch repos now?
I've also discovered that the sym table error avoided by the commit pin can be worked around by removing already loaded symbols with file (no args) prior to calling file path/to/file to load new ones. So if people did still want to use the container for development, they could still use the gdb installed by pacman (with the symbols caveat).
Signature · 2 lines
Bobby Eshleman SE at Vates SAS
Re: [PATCH v3 5/5] automation: Add container for riscv64 builds
Quoted 13 lines · Bob Eshleman
automation/build/archlinux/riscv64.dockerfile
Quoted 10 lines · Connor Davis
automation/build/archlinux/riscv64.dockerfile new file +10
-0+ +# There is a regression in GDB that causes an assertion error +# when setting breakpoints, use this commit until it is fixed! +RUN git clone --recursive -j$(nproc) --progress https://github.com/riscv/riscv-gnu-toolchain && \ + cd riscv-gnu-toolchain/riscv-gdb && \ + git checkout 1dd588507782591478882a891f64945af9e2b86c && \ + cd .. && \ + ./configure --prefix=/opt/riscv && \ + make linux -j$(nproc) && \ + rm -R /riscv-gnu-toolchaiWhat do you think about using the RISCV tool chain from the Arch repos now?
That sounds much better, will update
Quoted 8 lines
I've also discovered that the sym table error avoided by the commit pin can be worked around by removing already loaded symbols with
file(no args) prior to callingfile path/to/fileto load new ones. So if people did still want to use the container for development, they could still use the gdb installed by pacman (with the symbols caveat).
Thanks,
Connor
FWIW: for project EVE, the timing on this is perfect -- I've just started a complete RISC-V port:
https://github.com/lf-edge/eve/pull/2083
Targeting KVM for now, but would be awesome to see at least some rudimentary RISC-V support land in Xen.
Connor, I'll be merging your changes into my patchset on EVE side ASAP -- just to start playing with it.
Thanks,
Roman.
Quoted 78 lines · Connor Davis
Hi all,
This series introduces a minimal build for RISCV. It is based on Bobby's previous work from last year[0] rebased onto current Xen.
This series provides the patches necessary to get a minimal build working. The build is "minimal" in the sense that it only supports building TARGET=head.o. The
arch/riscv/head.Sis just a simple while(1).The first 3 patches are mods to non-RISCV bits that enable building a config with:
!CONFIG_HAS_NS16550
!CONFIG_HAS_PASSTHROUGH
!CONFIG_GRANT_TABLErespectively. The fourth patch adds the make/Kconfig boilerplate alongside
head.Sandasm-riscv/config.h(head.Sreferences ENTRY that is defined inasm-riscv/config.h).The last adds a docker container for doing the build. To build from the docker container (after creating it locally), you can run the following:
$ make XEN_TARGET_ARCH=riscv64 SUBSYSTEMS=xen -C xen TARGET=head.o--
Changes since v2:
- Reduced number of riscv files added to ease reviewChanges since v1:
- Dropped "xen/sched: Fix build whenNR_CPUS== 1" since this wasfixed for 4.15- Moved #ifdef-ary around
iommu_enabledtoiommu.h
- Moved structgrant_tabledeclaration above ifdefCONFIG_GRANT_TABLEinstead of defining an empty struct when !CONFIG_GRANT_TABLEConnor Davis (5):
xen/char: DefaultHAS_NS16550to y only for X86 and ARM xen/common: Guard iommu symbols withCONFIG_HAS_PASSTHROUGH
xen: Fix build when !CONFIG_GRANT_TABLE
xen: Add files needed for minimal riscv build
automation: Add container for riscv64 buildsautomation/build/archlinux/riscv64.dockerfile | 33 ++++++ automation/scripts/containerize | 1 + config/riscv64.mk | 5 + xen/Makefile | 8 +- xen/arch/riscv/Kconfig | 52 +++++++++ xen/arch/riscv/Kconfig.debug | 0 xen/arch/riscv/Makefile | 0 xen/arch/riscv/Rules.mk | 0 xen/arch/riscv/arch.mk | 16 +++ xen/arch/riscv/asm-offsets.c | 0 xen/arch/riscv/configs/riscv64_defconfig | 12 ++ xen/arch/riscv/head.S | 6 + xen/common/memory.c | 10 ++ xen/drivers/char/Kconfig | 2 +- xen/include/asm-riscv/config.h | 110 ++++++++++++++++++ xen/include/xen/grant_table.h | 3 +- xen/include/xen/iommu.h | 8 +- 17 files changed, 261 insertions(+), 5 deletions(-) create mode 100644 automation/build/archlinux/riscv64.dockerfile create mode 100644 config/riscv64.mk create mode 100644 xen/arch/riscv/Kconfig create mode 100644 xen/arch/riscv/Kconfig.debug create mode 100644 xen/arch/riscv/Makefile create mode 100644 xen/arch/riscv/Rules.mk create mode 100644 xen/arch/riscv/arch.mk create mode 100644 xen/arch/riscv/asm-offsets.c create mode 100644 xen/arch/riscv/configs/riscv64_defconfig create mode 100644 xen/arch/riscv/head.S create mode 100644 xen/include/asm-riscv/config.h--
2.31.1