[PATCH v2 31/40] xen/mpu: disable FIXMAP in MPU system

Penny Zheng posted 41 patches 3 years ago
There is a newer version of this series
[PATCH v2 31/40] xen/mpu: disable FIXMAP in MPU system
Posted by Penny Zheng 3 years ago
FIXMAP in MMU system is used to do special-purpose 4K mapping, like
mapping early UART, temporarily mapping source codes for copy and paste
(copy_from_paddr), ect. As there is no VMSA in MPU system, we do not
support FIXMAP in MPU system.

We deine !CONFIG_HAS_FIXMAP to provide empty stubbers for MPU system

Signed-off-by: Penny Zheng <penny.zheng@arm.com>
Signed-off-by: Wei Chen <wei.chen@arm.com>
---
 xen/arch/arm/Kconfig              |  3 ++-
 xen/arch/arm/include/asm/fixmap.h | 28 +++++++++++++++++++++++++---
 xen/common/Kconfig                |  3 +++
 3 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig
index 9230c8b885..91491341c4 100644
--- a/xen/arch/arm/Kconfig
+++ b/xen/arch/arm/Kconfig
@@ -13,9 +13,10 @@ config ARM
 	def_bool y
 	select HAS_ALTERNATIVE if !ARM_V8R
 	select HAS_DEVICE_TREE
+	select HAS_FIXMAP if !ARM_V8R
 	select HAS_PASSTHROUGH
 	select HAS_PDX
-	select HAS_PMAP
+	select HAS_PMAP if !ARM_V8R
 	select IOMMU_FORCE_PT_SHARE
 	select HAS_VMAP if !ARM_V8R
 
diff --git a/xen/arch/arm/include/asm/fixmap.h b/xen/arch/arm/include/asm/fixmap.h
index d0c9a52c8c..f0f4eb57ac 100644
--- a/xen/arch/arm/include/asm/fixmap.h
+++ b/xen/arch/arm/include/asm/fixmap.h
@@ -4,9 +4,6 @@
 #ifndef __ASM_FIXMAP_H
 #define __ASM_FIXMAP_H
 
-#include <xen/acpi.h>
-#include <xen/pmap.h>
-
 /* Fixmap slots */
 #define FIXMAP_CONSOLE  0  /* The primary UART */
 #define FIXMAP_MISC     1  /* Ephemeral mappings of hardware */
@@ -22,6 +19,11 @@
 
 #ifndef __ASSEMBLY__
 
+#ifdef CONFIG_HAS_FIXMAP
+
+#include <xen/acpi.h>
+#include <xen/pmap.h>
+
 /*
  * Direct access to xen_fixmap[] should only happen when {set,
  * clear}_fixmap() is unusable (e.g. where we would end up to
@@ -43,6 +45,26 @@ static inline unsigned int virt_to_fix(vaddr_t vaddr)
     return ((vaddr - FIXADDR_START) >> PAGE_SHIFT);
 }
 
+#else /* !CONFIG_HAS_FIXMAP */
+
+static inline void set_fixmap(unsigned int map, mfn_t mfn,
+                              unsigned int attributes)
+{
+    ASSERT_UNREACHABLE();
+}
+
+static inline void clear_fixmap(unsigned int map)
+{
+    ASSERT_UNREACHABLE();
+}
+
+static inline unsigned int virt_to_fix(vaddr_t vaddr)
+{
+    ASSERT_UNREACHABLE();
+    return -EINVAL;
+}
+#endif /* !CONFIG_HAS_FIXMAP */
+
 #endif /* __ASSEMBLY__ */
 
 #endif /* __ASM_FIXMAP_H */
diff --git a/xen/common/Kconfig b/xen/common/Kconfig
index ba16366a4b..680dc6f59c 100644
--- a/xen/common/Kconfig
+++ b/xen/common/Kconfig
@@ -43,6 +43,9 @@ config HAS_EX_TABLE
 config HAS_FAST_MULTIPLY
 	bool
 
+config HAS_FIXMAP
+	bool
+
 config HAS_IOPORTS
 	bool
 
-- 
2.25.1
Re: [PATCH v2 31/40] xen/mpu: disable FIXMAP in MPU system
Posted by Jan Beulich 3 years ago
On 13.01.2023 06:29, Penny Zheng wrote:
> --- a/xen/arch/arm/Kconfig
> +++ b/xen/arch/arm/Kconfig
> @@ -13,9 +13,10 @@ config ARM
>  	def_bool y
>  	select HAS_ALTERNATIVE if !ARM_V8R
>  	select HAS_DEVICE_TREE
> +	select HAS_FIXMAP if !ARM_V8R
>  	select HAS_PASSTHROUGH
>  	select HAS_PDX
> -	select HAS_PMAP
> +	select HAS_PMAP if !ARM_V8R
>  	select IOMMU_FORCE_PT_SHARE
>  	select HAS_VMAP if !ARM_V8R

Thinking about it - wouldn't it make sense to fold HAS_VMAP and HAS_FIXMAP
into a single HAS_MMU?

Jan
Re: [PATCH v2 31/40] xen/mpu: disable FIXMAP in MPU system
Posted by Julien Grall 3 years ago
Hi,

On 13/01/2023 10:10, Jan Beulich wrote:
> On 13.01.2023 06:29, Penny Zheng wrote:
>> --- a/xen/arch/arm/Kconfig
>> +++ b/xen/arch/arm/Kconfig
>> @@ -13,9 +13,10 @@ config ARM
>>   	def_bool y
>>   	select HAS_ALTERNATIVE if !ARM_V8R
>>   	select HAS_DEVICE_TREE
>> +	select HAS_FIXMAP if !ARM_V8R
>>   	select HAS_PASSTHROUGH
>>   	select HAS_PDX
>> -	select HAS_PMAP
>> +	select HAS_PMAP if !ARM_V8R
>>   	select IOMMU_FORCE_PT_SHARE
>>   	select HAS_VMAP if !ARM_V8R
> 
> Thinking about it - wouldn't it make sense to fold HAS_VMAP and HAS_FIXMAP
> into a single HAS_MMU?

I think it would make sense.

Furthermore, this patch would be better towards the start of the series.

Cheers,

-- 
Julien Grall
Re: [PATCH v2 31/40] xen/mpu: disable FIXMAP in MPU system
Posted by Jan Beulich 3 years ago
On 13.01.2023 06:29, Penny Zheng wrote:
> --- a/xen/common/Kconfig
> +++ b/xen/common/Kconfig
> @@ -43,6 +43,9 @@ config HAS_EX_TABLE
>  config HAS_FAST_MULTIPLY
>  	bool
>  
> +config HAS_FIXMAP
> +	bool

I think it'll end up misleading if this option is not selected by x86
as well. So imo you either add that, or you move the option to an Arm-
specific Kconfig.

Jan