Skip to contentSkip to conversation

KVM: arm64: Fix definition of PAGE_HYP_DEVICE

PATCH Applied Will Deacon 2 participants 3 messages Jul 8, 2020

Subsystems (3)
lore
Share & tools
lore

Will Deacon

author maintainer
#0 lore raw

PATCH 1/1 KVM: arm64: Fix definition of PAGE_HYP_DEVICE

PAGE_HYP_DEVICE is intended to encode attribute bits for an EL2 stage-1 pte mapping a device. Unfortunately, it includes PROT_DEVICE_nGnRE which encodes attributes for EL1 stage-1 mappings such as UXN and nG, which are RES0 for EL2, and DBM which is meaningless as TCR_EL2.HD is not set.

Fix the definition of PAGE_HYP_DEVICE so that it doesn't set RES0 bits at EL2.

Cc Marc Zyngier <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc James Morse <[email protected]>

---
Marc -- I'm happy to take this as a fix via arm64 with your Ack. Please just let me know.

 arch/arm64/include/asm/pgtable-prot.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/include/asm/pgtable-prot.h +1 -1
index 2e7e0f452301..4d867c6446c4 100644
@@ -67,7 +67,7 @@ extern bool arm64_use_ng_mappings;
 #define PAGE_HYP		__pgprot(_HYP_PAGE_DEFAULT | PTE_HYP | PTE_HYP_XN)
 #define PAGE_HYP_EXEC		__pgprot(_HYP_PAGE_DEFAULT | PTE_HYP | PTE_RDONLY)
 #define PAGE_HYP_RO		__pgprot(_HYP_PAGE_DEFAULT | PTE_HYP | PTE_RDONLY | PTE_HYP_XN)
-#define PAGE_HYP_DEVICE		__pgprot(PROT_DEVICE_nGnRE | PTE_HYP)
+#define PAGE_HYP_DEVICE		__pgprot(_PROT_DEFAULT | PTE_ATTRINDX(MT_DEVICE_nGnRE) | PTE_HYP | PTE_HYP_XN)
 
 #define PAGE_S2_MEMATTR(attr)						\
 	({								\
Signature · 1 line
2.27.0.383.g050319c2ae-goog
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 13 lines · Will Deacon

PAGE_HYP_DEVICE is intended to encode attribute bits for an EL2 stage-1 pte mapping a device. Unfortunately, it includes PROT_DEVICE_nGnRE which encodes attributes for EL1 stage-1 mappings such as UXN and nG, which are RES0 for EL2, and DBM which is meaningless as TCR_EL2.HD is not set.

Fix the definition of PAGE_HYP_DEVICE so that it doesn't set RES0 bits at EL2.

Cc Marc Zyngier <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc James Morse <[email protected]>
Quoted 6 lines

---
Marc -- I'm happy to take this as a fix via arm64 with your Ack. Please just let me know.

 arch/arm64/include/asm/pgtable-prot.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Thanks for fixing this!

        M.
Signature · 1 line
Jazz is not dead. It just smells funny...
author maintainer Applied
#2 lore raw
In reply to Will Deacon
Quoted 7 lines · Will Deacon

PAGE_HYP_DEVICE is intended to encode attribute bits for an EL2 stage-1 pte mapping a device. Unfortunately, it includes PROT_DEVICE_nGnRE which encodes attributes for EL1 stage-1 mappings such as UXN and nG, which are RES0 for EL2, and DBM which is meaningless as TCR_EL2.HD is not set.

Fix the definition of PAGE_HYP_DEVICE so that it doesn't set RES0 bits at EL2.

Applied to arm64 (for-next/fixes), thanks!

[1/1] KVM: arm64: Fix definition of PAGE_HYP_DEVICE

      https://git.kernel.org/arm64/c/68cf617309b5

Cheers,

Signature · 5 lines
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev