Thread (63 messages) 63 messages, 5 authors, 2021-09-14

Re: [PATCH v4 04/18] KVM: arm64: selftests: Introduce ARM64_SYS_KVM_REG

flat view

From: Andrew Jones <hidden>
Date: 2021-09-09 07:04:40
Also in: kvmarm, linux-arm-kernel, lkml

On Thu, Sep 09, 2021 at 01:38:04AM +0000, Raghavendra Rao Ananta wrote:
quoted hunk ↗ jump to hunk
With the inclusion of sysreg.h, that brings in system register
encodings, it would be redundant to re-define register encodings
again in processor.h to use it with ARM64_SYS_REG for the KVM
functions such as set_reg() or get_reg(). Hence, add helper macro,
ARM64_SYS_KVM_REG, that converts SYS_* definitions in sysreg.h
into ARM64_SYS_REG definitions.

Signed-off-by: Raghavendra Rao Ananta <redacted>
---
 .../selftests/kvm/include/aarch64/processor.h      | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
diff --git a/tools/testing/selftests/kvm/include/aarch64/processor.h b/tools/testing/selftests/kvm/include/aarch64/processor.h
index bed4ffa70905..ac8b63f8aab7 100644
--- a/tools/testing/selftests/kvm/include/aarch64/processor.h
+++ b/tools/testing/selftests/kvm/include/aarch64/processor.h
@@ -26,6 +26,20 @@
 
 #define ID_AA64DFR0_EL1         3, 0,  0, 5, 0
 
+/*
+ * ARM64_SYS_KVM_REG(sys_reg_id): Helper macro to convert
+ * SYS_* register definitions in sysreg.h to use in KVM
+ * calls such as get_reg() and set_reg().
+ */
+#define ARM64_SYS_KVM_REG(sys_reg_id)			\
+({							\
+	ARM64_SYS_REG(sys_reg_Op0(sys_reg_id),		\
+			sys_reg_Op1(sys_reg_id),	\
+			sys_reg_CRn(sys_reg_id),	\
+			sys_reg_CRm(sys_reg_id),	\
+			sys_reg_Op2(sys_reg_id));	\
+})

I don't think we need the ({ }), do we? Anyway,

Reviewed-by: Andrew Jones <redacted>

Thanks,
drew
+
 /*
  * Default MAIR
  *                  index   attribute
-- 
2.33.0.153.gba50c8fa24-goog
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help