[PATCH v2 09/14] arm64: Enable memory encrypt for Realms

Emanuele Rocca emanuele.rocca at arm.com
Thu Apr 25 11:16:28 PDT 2024


Hi,

On 2024-04-25 05:29, Suzuki K Poulose wrote:
> Emmanuele reports that these need to be exported as well, something
> like:
> 
> 
> diff --git a/arch/arm64/mm/pageattr.c b/arch/arm64/mm/pageattr.c
> index 229b6d9990f5..de3843ce2aea 100644
> --- a/arch/arm64/mm/pageattr.c
> +++ b/arch/arm64/mm/pageattr.c
> @@ -228,11 +228,13 @@ int set_memory_encrypted(unsigned long addr, int
> numpages)
>  {
>         return __set_memory_encrypted(addr, numpages, true);
>  }
> +EXPORT_SYMBOL_GPL(set_memory_encrypted);
> 
>  int set_memory_decrypted(unsigned long addr, int numpages)
>  {
>         return __set_memory_encrypted(addr, numpages, false);
>  }
> +EXPORT_SYMBOL_GPL(set_memory_decrypted);
> 
>  #ifdef CONFIG_DEBUG_PAGEALLOC
>  void __kernel_map_pages(struct page *page, int numpages, int enable

Indeed, without exporting the symbols I was getting this build failure:

 ERROR: modpost: "set_memory_encrypted" [drivers/hv/hv_vmbus.ko] undefined!
 ERROR: modpost: "set_memory_decrypted" [drivers/hv/hv_vmbus.ko] undefined!

I can now build 6.9-rc1 w/ CCA guest patches if I apply Suzuki's
changes:

1) move set_memory_encrypted/decrypted from asm/mem_encrypt.h to
   asm/set_memory.h
2) export both symbols in mm/pageattr.c

See diff below.

Thanks,
  Emanuele

diff --git a/arch/arm64/include/asm/mem_encrypt.h b/arch/arm64/include/asm/mem_encrypt.h
index 7381f9585321..e47265cd180a 100644
--- a/arch/arm64/include/asm/mem_encrypt.h
+++ b/arch/arm64/include/asm/mem_encrypt.h
@@ -14,6 +14,4 @@ static inline bool force_dma_unencrypted(struct device *dev)
        return is_realm_world();
 }

-int set_memory_encrypted(unsigned long addr, int numpages);
-int set_memory_decrypted(unsigned long addr, int numpages);
 #endif
diff --git a/arch/arm64/include/asm/set_memory.h b/arch/arm64/include/asm/set_memory.h
index 0f740b781187..9561b90fb43c 100644
--- a/arch/arm64/include/asm/set_memory.h
+++ b/arch/arm64/include/asm/set_memory.h
@@ -14,4 +14,6 @@ int set_direct_map_invalid_noflush(struct page *page);
 int set_direct_map_default_noflush(struct page *page);
 bool kernel_page_present(struct page *page);

+int set_memory_encrypted(unsigned long addr, int numpages);
+int set_memory_decrypted(unsigned long addr, int numpages);
 #endif /* _ASM_ARM64_SET_MEMORY_H */
diff --git a/arch/arm64/mm/pageattr.c b/arch/arm64/mm/pageattr.c
index 229b6d9990f5..de3843ce2aea 100644
--- a/arch/arm64/mm/pageattr.c
+++ b/arch/arm64/mm/pageattr.c
@@ -228,11 +228,13 @@ int set_memory_encrypted(unsigned long addr, int numpages)
 {
        return __set_memory_encrypted(addr, numpages, true);
 }
+EXPORT_SYMBOL_GPL(set_memory_encrypted);

 int set_memory_decrypted(unsigned long addr, int numpages)
 {
        return __set_memory_encrypted(addr, numpages, false);
 }
+EXPORT_SYMBOL_GPL(set_memory_decrypted);

 #ifdef CONFIG_DEBUG_PAGEALLOC
 void __kernel_map_pages(struct page *page, int numpages, int enable)



More information about the linux-arm-kernel mailing list