All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] KVM/arm64: sys_reg_table_init() small improvements
@ 2022-04-25 16:39 ` Alexandru Elisei
  0 siblings, 0 replies; 16+ messages in thread
From: Alexandru Elisei @ 2022-04-25 16:39 UTC (permalink / raw)
  To: maz, james.morse, suzuki.poulose, linux-arm-kernel, kvmarm

These are two small improvements to how KVM handles an out-of-order
sys_reg_desc table. These should only affect KVM developers, as the end
user should never see an error caused by an unsorted sys_reg_desc table.

Alexandru Elisei (2):
  KVM/arm64: Don't BUG_ON() if emulated register table is unsorted
  KVM/arm64: Print emulated register table name when it is unsorted

 arch/arm64/include/asm/kvm_host.h |  2 +-
 arch/arm64/kvm/arm.c              |  7 ++++--
 arch/arm64/kvm/sys_regs.c         | 37 ++++++++++++++++++-------------
 3 files changed, 28 insertions(+), 18 deletions(-)

-- 
2.36.0

_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 0/2] KVM/arm64: sys_reg_table_init() small improvements
@ 2022-04-25 16:39 ` Alexandru Elisei
  0 siblings, 0 replies; 16+ messages in thread
From: Alexandru Elisei @ 2022-04-25 16:39 UTC (permalink / raw)
  To: maz, james.morse, suzuki.poulose, linux-arm-kernel, kvmarm

These are two small improvements to how KVM handles an out-of-order
sys_reg_desc table. These should only affect KVM developers, as the end
user should never see an error caused by an unsorted sys_reg_desc table.

Alexandru Elisei (2):
  KVM/arm64: Don't BUG_ON() if emulated register table is unsorted
  KVM/arm64: Print emulated register table name when it is unsorted

 arch/arm64/include/asm/kvm_host.h |  2 +-
 arch/arm64/kvm/arm.c              |  7 ++++--
 arch/arm64/kvm/sys_regs.c         | 37 ++++++++++++++++++-------------
 3 files changed, 28 insertions(+), 18 deletions(-)

-- 
2.36.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 1/2] KVM/arm64: Don't BUG_ON() if emulated register table is unsorted
  2022-04-25 16:39 ` Alexandru Elisei
@ 2022-04-25 16:39   ` Alexandru Elisei
  -1 siblings, 0 replies; 16+ messages in thread
From: Alexandru Elisei @ 2022-04-25 16:39 UTC (permalink / raw)
  To: maz, james.morse, suzuki.poulose, linux-arm-kernel, kvmarm

To emulate a register access, KVM uses a table of registers sorted by
register encoding to speed up queries using binary search.

When Linux boots, KVM checks that the table is sorted and uses a BUG_ON()
statement to let the user know if it's not. The unfortunate side effect is
that an unsorted sysreg table brings down the whole kernel, not just KVM,
even though the rest of the kernel can function just fine without KVM. To
make matters worse, on machines which lack a serial console, the user is
left pondering why the machine is taking so long to boot.

Improve this situation by returning an error from kvm_arch_init() if the
sysreg tables are not in the correct order. The machine is still very much
usable for the user, with the exception of virtualization, who can now
easily determine what went wrong.

A minor typo has also been corrected in the check_sysreg_table() function.

Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
---
 arch/arm64/include/asm/kvm_host.h |  2 +-
 arch/arm64/kvm/arm.c              |  7 +++++--
 arch/arm64/kvm/sys_regs.c         | 33 ++++++++++++++++++-------------
 3 files changed, 25 insertions(+), 17 deletions(-)

diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
index 94a27a7520f4..39ca91cc1f01 100644
--- a/arch/arm64/include/asm/kvm_host.h
+++ b/arch/arm64/include/asm/kvm_host.h
@@ -686,7 +686,7 @@ int kvm_handle_sys_reg(struct kvm_vcpu *vcpu);
 
 void kvm_reset_sys_regs(struct kvm_vcpu *vcpu);
 
-void kvm_sys_reg_table_init(void);
+int kvm_sys_reg_table_init(void);
 
 /* MMIO helpers */
 void kvm_mmio_write_buf(void *buf, unsigned int len, unsigned long data);
diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c
index 523bc934fe2f..8bc38754ac02 100644
--- a/arch/arm64/kvm/arm.c
+++ b/arch/arm64/kvm/arm.c
@@ -1761,8 +1761,6 @@ static int init_subsystems(void)
 
 	kvm_register_perf_callbacks(NULL);
 
-	kvm_sys_reg_table_init();
-
 out:
 	if (err || !is_protected_kvm_enabled())
 		on_each_cpu(_kvm_arch_hardware_disable, NULL, 1);
@@ -2089,6 +2087,11 @@ int kvm_arch_init(void *opaque)
 		return -ENODEV;
 	}
 
+	if (kvm_sys_reg_table_init()) {
+		kvm_info("Error initializing system register tables");
+		return -EINVAL;
+	}
+
 	in_hyp_mode = is_kernel_in_hyp_mode();
 
 	if (cpus_have_final_cap(ARM64_WORKAROUND_DEVICE_LOAD_ACQUIRE) ||
diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
index 7b45c040cc27..57302048afd0 100644
--- a/arch/arm64/kvm/sys_regs.c
+++ b/arch/arm64/kvm/sys_regs.c
@@ -2187,25 +2187,24 @@ static const struct sys_reg_desc cp15_64_regs[] = {
 	{ SYS_DESC(SYS_AARCH32_CNTP_CVAL),    access_arch_timer },
 };
 
-static int check_sysreg_table(const struct sys_reg_desc *table, unsigned int n,
-			      bool is_32)
+static bool check_sysreg_table(const struct sys_reg_desc *table, unsigned int n,
+			       bool is_32)
 {
 	unsigned int i;
 
 	for (i = 0; i < n; i++) {
 		if (!is_32 && table[i].reg && !table[i].reset) {
-			kvm_err("sys_reg table %p entry %d has lacks reset\n",
-				table, i);
-			return 1;
+			kvm_err("sys_reg table %p entry %d lacks reset\n", table, i);
+			return false;
 		}
 
 		if (i && cmp_sys_reg(&table[i-1], &table[i]) >= 0) {
 			kvm_err("sys_reg table %p out of order (%d)\n", table, i - 1);
-			return 1;
+			return false;
 		}
 	}
 
-	return 0;
+	return true;
 }
 
 int kvm_handle_cp14_load_store(struct kvm_vcpu *vcpu)
@@ -2860,18 +2859,22 @@ int kvm_arm_copy_sys_reg_indices(struct kvm_vcpu *vcpu, u64 __user *uindices)
 	return write_demux_regids(uindices);
 }
 
-void kvm_sys_reg_table_init(void)
+int kvm_sys_reg_table_init(void)
 {
+	bool valid = true;
 	unsigned int i;
 	struct sys_reg_desc clidr;
 
 	/* Make sure tables are unique and in order. */
-	BUG_ON(check_sysreg_table(sys_reg_descs, ARRAY_SIZE(sys_reg_descs), false));
-	BUG_ON(check_sysreg_table(cp14_regs, ARRAY_SIZE(cp14_regs), true));
-	BUG_ON(check_sysreg_table(cp14_64_regs, ARRAY_SIZE(cp14_64_regs), true));
-	BUG_ON(check_sysreg_table(cp15_regs, ARRAY_SIZE(cp15_regs), true));
-	BUG_ON(check_sysreg_table(cp15_64_regs, ARRAY_SIZE(cp15_64_regs), true));
-	BUG_ON(check_sysreg_table(invariant_sys_regs, ARRAY_SIZE(invariant_sys_regs), false));
+	valid &= check_sysreg_table(sys_reg_descs, ARRAY_SIZE(sys_reg_descs), false);
+	valid &= check_sysreg_table(cp14_regs, ARRAY_SIZE(cp14_regs), true);
+	valid &= check_sysreg_table(cp14_64_regs, ARRAY_SIZE(cp14_64_regs), true);
+	valid &= check_sysreg_table(cp15_regs, ARRAY_SIZE(cp15_regs), true);
+	valid &= check_sysreg_table(cp15_64_regs, ARRAY_SIZE(cp15_64_regs), true);
+	valid &= check_sysreg_table(invariant_sys_regs, ARRAY_SIZE(invariant_sys_regs), false);
+
+	if (!valid)
+		return -EINVAL;
 
 	/* We abuse the reset function to overwrite the table itself. */
 	for (i = 0; i < ARRAY_SIZE(invariant_sys_regs); i++)
@@ -2894,4 +2897,6 @@ void kvm_sys_reg_table_init(void)
 			break;
 	/* Clear all higher bits. */
 	cache_levels &= (1 << (i*3))-1;
+
+	return 0;
 }
-- 
2.36.0

_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 1/2] KVM/arm64: Don't BUG_ON() if emulated register table is unsorted
@ 2022-04-25 16:39   ` Alexandru Elisei
  0 siblings, 0 replies; 16+ messages in thread
From: Alexandru Elisei @ 2022-04-25 16:39 UTC (permalink / raw)
  To: maz, james.morse, suzuki.poulose, linux-arm-kernel, kvmarm

To emulate a register access, KVM uses a table of registers sorted by
register encoding to speed up queries using binary search.

When Linux boots, KVM checks that the table is sorted and uses a BUG_ON()
statement to let the user know if it's not. The unfortunate side effect is
that an unsorted sysreg table brings down the whole kernel, not just KVM,
even though the rest of the kernel can function just fine without KVM. To
make matters worse, on machines which lack a serial console, the user is
left pondering why the machine is taking so long to boot.

Improve this situation by returning an error from kvm_arch_init() if the
sysreg tables are not in the correct order. The machine is still very much
usable for the user, with the exception of virtualization, who can now
easily determine what went wrong.

A minor typo has also been corrected in the check_sysreg_table() function.

Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
---
 arch/arm64/include/asm/kvm_host.h |  2 +-
 arch/arm64/kvm/arm.c              |  7 +++++--
 arch/arm64/kvm/sys_regs.c         | 33 ++++++++++++++++++-------------
 3 files changed, 25 insertions(+), 17 deletions(-)

diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
index 94a27a7520f4..39ca91cc1f01 100644
--- a/arch/arm64/include/asm/kvm_host.h
+++ b/arch/arm64/include/asm/kvm_host.h
@@ -686,7 +686,7 @@ int kvm_handle_sys_reg(struct kvm_vcpu *vcpu);
 
 void kvm_reset_sys_regs(struct kvm_vcpu *vcpu);
 
-void kvm_sys_reg_table_init(void);
+int kvm_sys_reg_table_init(void);
 
 /* MMIO helpers */
 void kvm_mmio_write_buf(void *buf, unsigned int len, unsigned long data);
diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c
index 523bc934fe2f..8bc38754ac02 100644
--- a/arch/arm64/kvm/arm.c
+++ b/arch/arm64/kvm/arm.c
@@ -1761,8 +1761,6 @@ static int init_subsystems(void)
 
 	kvm_register_perf_callbacks(NULL);
 
-	kvm_sys_reg_table_init();
-
 out:
 	if (err || !is_protected_kvm_enabled())
 		on_each_cpu(_kvm_arch_hardware_disable, NULL, 1);
@@ -2089,6 +2087,11 @@ int kvm_arch_init(void *opaque)
 		return -ENODEV;
 	}
 
+	if (kvm_sys_reg_table_init()) {
+		kvm_info("Error initializing system register tables");
+		return -EINVAL;
+	}
+
 	in_hyp_mode = is_kernel_in_hyp_mode();
 
 	if (cpus_have_final_cap(ARM64_WORKAROUND_DEVICE_LOAD_ACQUIRE) ||
diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
index 7b45c040cc27..57302048afd0 100644
--- a/arch/arm64/kvm/sys_regs.c
+++ b/arch/arm64/kvm/sys_regs.c
@@ -2187,25 +2187,24 @@ static const struct sys_reg_desc cp15_64_regs[] = {
 	{ SYS_DESC(SYS_AARCH32_CNTP_CVAL),    access_arch_timer },
 };
 
-static int check_sysreg_table(const struct sys_reg_desc *table, unsigned int n,
-			      bool is_32)
+static bool check_sysreg_table(const struct sys_reg_desc *table, unsigned int n,
+			       bool is_32)
 {
 	unsigned int i;
 
 	for (i = 0; i < n; i++) {
 		if (!is_32 && table[i].reg && !table[i].reset) {
-			kvm_err("sys_reg table %p entry %d has lacks reset\n",
-				table, i);
-			return 1;
+			kvm_err("sys_reg table %p entry %d lacks reset\n", table, i);
+			return false;
 		}
 
 		if (i && cmp_sys_reg(&table[i-1], &table[i]) >= 0) {
 			kvm_err("sys_reg table %p out of order (%d)\n", table, i - 1);
-			return 1;
+			return false;
 		}
 	}
 
-	return 0;
+	return true;
 }
 
 int kvm_handle_cp14_load_store(struct kvm_vcpu *vcpu)
@@ -2860,18 +2859,22 @@ int kvm_arm_copy_sys_reg_indices(struct kvm_vcpu *vcpu, u64 __user *uindices)
 	return write_demux_regids(uindices);
 }
 
-void kvm_sys_reg_table_init(void)
+int kvm_sys_reg_table_init(void)
 {
+	bool valid = true;
 	unsigned int i;
 	struct sys_reg_desc clidr;
 
 	/* Make sure tables are unique and in order. */
-	BUG_ON(check_sysreg_table(sys_reg_descs, ARRAY_SIZE(sys_reg_descs), false));
-	BUG_ON(check_sysreg_table(cp14_regs, ARRAY_SIZE(cp14_regs), true));
-	BUG_ON(check_sysreg_table(cp14_64_regs, ARRAY_SIZE(cp14_64_regs), true));
-	BUG_ON(check_sysreg_table(cp15_regs, ARRAY_SIZE(cp15_regs), true));
-	BUG_ON(check_sysreg_table(cp15_64_regs, ARRAY_SIZE(cp15_64_regs), true));
-	BUG_ON(check_sysreg_table(invariant_sys_regs, ARRAY_SIZE(invariant_sys_regs), false));
+	valid &= check_sysreg_table(sys_reg_descs, ARRAY_SIZE(sys_reg_descs), false);
+	valid &= check_sysreg_table(cp14_regs, ARRAY_SIZE(cp14_regs), true);
+	valid &= check_sysreg_table(cp14_64_regs, ARRAY_SIZE(cp14_64_regs), true);
+	valid &= check_sysreg_table(cp15_regs, ARRAY_SIZE(cp15_regs), true);
+	valid &= check_sysreg_table(cp15_64_regs, ARRAY_SIZE(cp15_64_regs), true);
+	valid &= check_sysreg_table(invariant_sys_regs, ARRAY_SIZE(invariant_sys_regs), false);
+
+	if (!valid)
+		return -EINVAL;
 
 	/* We abuse the reset function to overwrite the table itself. */
 	for (i = 0; i < ARRAY_SIZE(invariant_sys_regs); i++)
@@ -2894,4 +2897,6 @@ void kvm_sys_reg_table_init(void)
 			break;
 	/* Clear all higher bits. */
 	cache_levels &= (1 << (i*3))-1;
+
+	return 0;
 }
-- 
2.36.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 2/2] KVM/arm64: Print emulated register table name when it is unsorted
  2022-04-25 16:39 ` Alexandru Elisei
@ 2022-04-25 16:39   ` Alexandru Elisei
  -1 siblings, 0 replies; 16+ messages in thread
From: Alexandru Elisei @ 2022-04-25 16:39 UTC (permalink / raw)
  To: maz, james.morse, suzuki.poulose, linux-arm-kernel, kvmarm

When a sysreg table entry is out-of-order, KVM attempts to print the
address of the table:

[    0.143881] kvm [1]: sys_reg table (____ptrval____) out of order (0)

Printing the name of the table instead of a pointer is more helpful in this
case:

[    0.143881] kvm [1]: sys_reg table sys_reg_descs out of order (0)

Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
---
 arch/arm64/kvm/sys_regs.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
index 57302048afd0..7b62a2daf056 100644
--- a/arch/arm64/kvm/sys_regs.c
+++ b/arch/arm64/kvm/sys_regs.c
@@ -2188,18 +2188,18 @@ static const struct sys_reg_desc cp15_64_regs[] = {
 };
 
 static bool check_sysreg_table(const struct sys_reg_desc *table, unsigned int n,
-			       bool is_32)
+			       const char *table_name, bool is_32)
 {
 	unsigned int i;
 
 	for (i = 0; i < n; i++) {
 		if (!is_32 && table[i].reg && !table[i].reset) {
-			kvm_err("sys_reg table %p entry %d lacks reset\n", table, i);
+			kvm_err("sys_reg table %s entry %d lacks reset\n", table_name, i);
 			return false;
 		}
 
 		if (i && cmp_sys_reg(&table[i-1], &table[i]) >= 0) {
-			kvm_err("sys_reg table %p out of order (%d)\n", table, i - 1);
+			kvm_err("sys_reg table %s out of order (%d)\n", table_name, i - 1);
 			return false;
 		}
 	}
@@ -2866,12 +2866,14 @@ int kvm_sys_reg_table_init(void)
 	struct sys_reg_desc clidr;
 
 	/* Make sure tables are unique and in order. */
-	valid &= check_sysreg_table(sys_reg_descs, ARRAY_SIZE(sys_reg_descs), false);
-	valid &= check_sysreg_table(cp14_regs, ARRAY_SIZE(cp14_regs), true);
-	valid &= check_sysreg_table(cp14_64_regs, ARRAY_SIZE(cp14_64_regs), true);
-	valid &= check_sysreg_table(cp15_regs, ARRAY_SIZE(cp15_regs), true);
-	valid &= check_sysreg_table(cp15_64_regs, ARRAY_SIZE(cp15_64_regs), true);
-	valid &= check_sysreg_table(invariant_sys_regs, ARRAY_SIZE(invariant_sys_regs), false);
+	valid &= check_sysreg_table(sys_reg_descs, ARRAY_SIZE(sys_reg_descs),
+				    "sys_reg_descs", false);
+	valid &= check_sysreg_table(cp14_regs, ARRAY_SIZE(cp14_regs), "cp14_regs", true);
+	valid &= check_sysreg_table(cp14_64_regs, ARRAY_SIZE(cp14_64_regs), "cp14_64_regs", true);
+	valid &= check_sysreg_table(cp15_regs, ARRAY_SIZE(cp15_regs), "cp15_regs", true);
+	valid &= check_sysreg_table(cp15_64_regs, ARRAY_SIZE(cp15_64_regs), "cp15_64_regs", true);
+	valid &= check_sysreg_table(invariant_sys_regs, ARRAY_SIZE(invariant_sys_regs),
+				    "invariant_sys_regs", false);
 
 	if (!valid)
 		return -EINVAL;
-- 
2.36.0

_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 2/2] KVM/arm64: Print emulated register table name when it is unsorted
@ 2022-04-25 16:39   ` Alexandru Elisei
  0 siblings, 0 replies; 16+ messages in thread
From: Alexandru Elisei @ 2022-04-25 16:39 UTC (permalink / raw)
  To: maz, james.morse, suzuki.poulose, linux-arm-kernel, kvmarm

When a sysreg table entry is out-of-order, KVM attempts to print the
address of the table:

[    0.143881] kvm [1]: sys_reg table (____ptrval____) out of order (0)

Printing the name of the table instead of a pointer is more helpful in this
case:

[    0.143881] kvm [1]: sys_reg table sys_reg_descs out of order (0)

Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
---
 arch/arm64/kvm/sys_regs.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
index 57302048afd0..7b62a2daf056 100644
--- a/arch/arm64/kvm/sys_regs.c
+++ b/arch/arm64/kvm/sys_regs.c
@@ -2188,18 +2188,18 @@ static const struct sys_reg_desc cp15_64_regs[] = {
 };
 
 static bool check_sysreg_table(const struct sys_reg_desc *table, unsigned int n,
-			       bool is_32)
+			       const char *table_name, bool is_32)
 {
 	unsigned int i;
 
 	for (i = 0; i < n; i++) {
 		if (!is_32 && table[i].reg && !table[i].reset) {
-			kvm_err("sys_reg table %p entry %d lacks reset\n", table, i);
+			kvm_err("sys_reg table %s entry %d lacks reset\n", table_name, i);
 			return false;
 		}
 
 		if (i && cmp_sys_reg(&table[i-1], &table[i]) >= 0) {
-			kvm_err("sys_reg table %p out of order (%d)\n", table, i - 1);
+			kvm_err("sys_reg table %s out of order (%d)\n", table_name, i - 1);
 			return false;
 		}
 	}
@@ -2866,12 +2866,14 @@ int kvm_sys_reg_table_init(void)
 	struct sys_reg_desc clidr;
 
 	/* Make sure tables are unique and in order. */
-	valid &= check_sysreg_table(sys_reg_descs, ARRAY_SIZE(sys_reg_descs), false);
-	valid &= check_sysreg_table(cp14_regs, ARRAY_SIZE(cp14_regs), true);
-	valid &= check_sysreg_table(cp14_64_regs, ARRAY_SIZE(cp14_64_regs), true);
-	valid &= check_sysreg_table(cp15_regs, ARRAY_SIZE(cp15_regs), true);
-	valid &= check_sysreg_table(cp15_64_regs, ARRAY_SIZE(cp15_64_regs), true);
-	valid &= check_sysreg_table(invariant_sys_regs, ARRAY_SIZE(invariant_sys_regs), false);
+	valid &= check_sysreg_table(sys_reg_descs, ARRAY_SIZE(sys_reg_descs),
+				    "sys_reg_descs", false);
+	valid &= check_sysreg_table(cp14_regs, ARRAY_SIZE(cp14_regs), "cp14_regs", true);
+	valid &= check_sysreg_table(cp14_64_regs, ARRAY_SIZE(cp14_64_regs), "cp14_64_regs", true);
+	valid &= check_sysreg_table(cp15_regs, ARRAY_SIZE(cp15_regs), "cp15_regs", true);
+	valid &= check_sysreg_table(cp15_64_regs, ARRAY_SIZE(cp15_64_regs), "cp15_64_regs", true);
+	valid &= check_sysreg_table(invariant_sys_regs, ARRAY_SIZE(invariant_sys_regs),
+				    "invariant_sys_regs", false);
 
 	if (!valid)
 		return -EINVAL;
-- 
2.36.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 2/2] KVM/arm64: Print sysreg table name when table is not sorted
  2022-04-25 16:39 ` Alexandru Elisei
@ 2022-04-25 16:39   ` Alexandru Elisei
  -1 siblings, 0 replies; 16+ messages in thread
From: Alexandru Elisei @ 2022-04-25 16:39 UTC (permalink / raw)
  To: maz, james.morse, suzuki.poulose, linux-arm-kernel, kvmarm

When a sysreg table entry is out-of-order, KVM attempts to print the
address of the table:

[    0.143881] kvm [1]: sys_reg table (____ptrval____) out of order (0)

Printing the name of the table instead of a pointer is more helpful in this
case:

[    0.143881] kvm [1]: sys_reg table sys_reg_descs out of order (0)

Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
---
 arch/arm64/kvm/sys_regs.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
index 57302048afd0..7b62a2daf056 100644
--- a/arch/arm64/kvm/sys_regs.c
+++ b/arch/arm64/kvm/sys_regs.c
@@ -2188,18 +2188,18 @@ static const struct sys_reg_desc cp15_64_regs[] = {
 };
 
 static bool check_sysreg_table(const struct sys_reg_desc *table, unsigned int n,
-			       bool is_32)
+			       const char *table_name, bool is_32)
 {
 	unsigned int i;
 
 	for (i = 0; i < n; i++) {
 		if (!is_32 && table[i].reg && !table[i].reset) {
-			kvm_err("sys_reg table %p entry %d lacks reset\n", table, i);
+			kvm_err("sys_reg table %s entry %d lacks reset\n", table_name, i);
 			return false;
 		}
 
 		if (i && cmp_sys_reg(&table[i-1], &table[i]) >= 0) {
-			kvm_err("sys_reg table %p out of order (%d)\n", table, i - 1);
+			kvm_err("sys_reg table %s out of order (%d)\n", table_name, i - 1);
 			return false;
 		}
 	}
@@ -2866,12 +2866,14 @@ int kvm_sys_reg_table_init(void)
 	struct sys_reg_desc clidr;
 
 	/* Make sure tables are unique and in order. */
-	valid &= check_sysreg_table(sys_reg_descs, ARRAY_SIZE(sys_reg_descs), false);
-	valid &= check_sysreg_table(cp14_regs, ARRAY_SIZE(cp14_regs), true);
-	valid &= check_sysreg_table(cp14_64_regs, ARRAY_SIZE(cp14_64_regs), true);
-	valid &= check_sysreg_table(cp15_regs, ARRAY_SIZE(cp15_regs), true);
-	valid &= check_sysreg_table(cp15_64_regs, ARRAY_SIZE(cp15_64_regs), true);
-	valid &= check_sysreg_table(invariant_sys_regs, ARRAY_SIZE(invariant_sys_regs), false);
+	valid &= check_sysreg_table(sys_reg_descs, ARRAY_SIZE(sys_reg_descs),
+				    "sys_reg_descs", false);
+	valid &= check_sysreg_table(cp14_regs, ARRAY_SIZE(cp14_regs), "cp14_regs", true);
+	valid &= check_sysreg_table(cp14_64_regs, ARRAY_SIZE(cp14_64_regs), "cp14_64_regs", true);
+	valid &= check_sysreg_table(cp15_regs, ARRAY_SIZE(cp15_regs), "cp15_regs", true);
+	valid &= check_sysreg_table(cp15_64_regs, ARRAY_SIZE(cp15_64_regs), "cp15_64_regs", true);
+	valid &= check_sysreg_table(invariant_sys_regs, ARRAY_SIZE(invariant_sys_regs),
+				    "invariant_sys_regs", false);
 
 	if (!valid)
 		return -EINVAL;
-- 
2.36.0

_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 2/2] KVM/arm64: Print sysreg table name when table is not sorted
@ 2022-04-25 16:39   ` Alexandru Elisei
  0 siblings, 0 replies; 16+ messages in thread
From: Alexandru Elisei @ 2022-04-25 16:39 UTC (permalink / raw)
  To: maz, james.morse, suzuki.poulose, linux-arm-kernel, kvmarm

When a sysreg table entry is out-of-order, KVM attempts to print the
address of the table:

[    0.143881] kvm [1]: sys_reg table (____ptrval____) out of order (0)

Printing the name of the table instead of a pointer is more helpful in this
case:

[    0.143881] kvm [1]: sys_reg table sys_reg_descs out of order (0)

Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
---
 arch/arm64/kvm/sys_regs.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
index 57302048afd0..7b62a2daf056 100644
--- a/arch/arm64/kvm/sys_regs.c
+++ b/arch/arm64/kvm/sys_regs.c
@@ -2188,18 +2188,18 @@ static const struct sys_reg_desc cp15_64_regs[] = {
 };
 
 static bool check_sysreg_table(const struct sys_reg_desc *table, unsigned int n,
-			       bool is_32)
+			       const char *table_name, bool is_32)
 {
 	unsigned int i;
 
 	for (i = 0; i < n; i++) {
 		if (!is_32 && table[i].reg && !table[i].reset) {
-			kvm_err("sys_reg table %p entry %d lacks reset\n", table, i);
+			kvm_err("sys_reg table %s entry %d lacks reset\n", table_name, i);
 			return false;
 		}
 
 		if (i && cmp_sys_reg(&table[i-1], &table[i]) >= 0) {
-			kvm_err("sys_reg table %p out of order (%d)\n", table, i - 1);
+			kvm_err("sys_reg table %s out of order (%d)\n", table_name, i - 1);
 			return false;
 		}
 	}
@@ -2866,12 +2866,14 @@ int kvm_sys_reg_table_init(void)
 	struct sys_reg_desc clidr;
 
 	/* Make sure tables are unique and in order. */
-	valid &= check_sysreg_table(sys_reg_descs, ARRAY_SIZE(sys_reg_descs), false);
-	valid &= check_sysreg_table(cp14_regs, ARRAY_SIZE(cp14_regs), true);
-	valid &= check_sysreg_table(cp14_64_regs, ARRAY_SIZE(cp14_64_regs), true);
-	valid &= check_sysreg_table(cp15_regs, ARRAY_SIZE(cp15_regs), true);
-	valid &= check_sysreg_table(cp15_64_regs, ARRAY_SIZE(cp15_64_regs), true);
-	valid &= check_sysreg_table(invariant_sys_regs, ARRAY_SIZE(invariant_sys_regs), false);
+	valid &= check_sysreg_table(sys_reg_descs, ARRAY_SIZE(sys_reg_descs),
+				    "sys_reg_descs", false);
+	valid &= check_sysreg_table(cp14_regs, ARRAY_SIZE(cp14_regs), "cp14_regs", true);
+	valid &= check_sysreg_table(cp14_64_regs, ARRAY_SIZE(cp14_64_regs), "cp14_64_regs", true);
+	valid &= check_sysreg_table(cp15_regs, ARRAY_SIZE(cp15_regs), "cp15_regs", true);
+	valid &= check_sysreg_table(cp15_64_regs, ARRAY_SIZE(cp15_64_regs), "cp15_64_regs", true);
+	valid &= check_sysreg_table(invariant_sys_regs, ARRAY_SIZE(invariant_sys_regs),
+				    "invariant_sys_regs", false);
 
 	if (!valid)
 		return -EINVAL;
-- 
2.36.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH 2/2] KVM/arm64: Print sysreg table name when table is not sorted
  2022-04-25 16:39   ` Alexandru Elisei
@ 2022-04-26  9:04     ` Alexandru Elisei
  -1 siblings, 0 replies; 16+ messages in thread
From: Alexandru Elisei @ 2022-04-26  9:04 UTC (permalink / raw)
  To: maz, james.morse, suzuki.poulose, linux-arm-kernel, kvmarm

Hi,

Err.. this is a work-in-progress version of patch #2 ("KVM/arm64: Print
emulated register table name when it is unsorted").  I sent it by mistake
because I forgot to clean the patch directory before sending the series.

I'll resend the series without this patch.

Thanks,
Alex

On Mon, Apr 25, 2022 at 05:39:04PM +0100, Alexandru Elisei wrote:
> When a sysreg table entry is out-of-order, KVM attempts to print the
> address of the table:
> 
> [    0.143881] kvm [1]: sys_reg table (____ptrval____) out of order (0)
> 
> Printing the name of the table instead of a pointer is more helpful in this
> case:
> 
> [    0.143881] kvm [1]: sys_reg table sys_reg_descs out of order (0)
> 
> Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
> ---
>  arch/arm64/kvm/sys_regs.c | 20 +++++++++++---------
>  1 file changed, 11 insertions(+), 9 deletions(-)
> 
> diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
> index 57302048afd0..7b62a2daf056 100644
> --- a/arch/arm64/kvm/sys_regs.c
> +++ b/arch/arm64/kvm/sys_regs.c
> @@ -2188,18 +2188,18 @@ static const struct sys_reg_desc cp15_64_regs[] = {
>  };
>  
>  static bool check_sysreg_table(const struct sys_reg_desc *table, unsigned int n,
> -			       bool is_32)
> +			       const char *table_name, bool is_32)
>  {
>  	unsigned int i;
>  
>  	for (i = 0; i < n; i++) {
>  		if (!is_32 && table[i].reg && !table[i].reset) {
> -			kvm_err("sys_reg table %p entry %d lacks reset\n", table, i);
> +			kvm_err("sys_reg table %s entry %d lacks reset\n", table_name, i);
>  			return false;
>  		}
>  
>  		if (i && cmp_sys_reg(&table[i-1], &table[i]) >= 0) {
> -			kvm_err("sys_reg table %p out of order (%d)\n", table, i - 1);
> +			kvm_err("sys_reg table %s out of order (%d)\n", table_name, i - 1);
>  			return false;
>  		}
>  	}
> @@ -2866,12 +2866,14 @@ int kvm_sys_reg_table_init(void)
>  	struct sys_reg_desc clidr;
>  
>  	/* Make sure tables are unique and in order. */
> -	valid &= check_sysreg_table(sys_reg_descs, ARRAY_SIZE(sys_reg_descs), false);
> -	valid &= check_sysreg_table(cp14_regs, ARRAY_SIZE(cp14_regs), true);
> -	valid &= check_sysreg_table(cp14_64_regs, ARRAY_SIZE(cp14_64_regs), true);
> -	valid &= check_sysreg_table(cp15_regs, ARRAY_SIZE(cp15_regs), true);
> -	valid &= check_sysreg_table(cp15_64_regs, ARRAY_SIZE(cp15_64_regs), true);
> -	valid &= check_sysreg_table(invariant_sys_regs, ARRAY_SIZE(invariant_sys_regs), false);
> +	valid &= check_sysreg_table(sys_reg_descs, ARRAY_SIZE(sys_reg_descs),
> +				    "sys_reg_descs", false);
> +	valid &= check_sysreg_table(cp14_regs, ARRAY_SIZE(cp14_regs), "cp14_regs", true);
> +	valid &= check_sysreg_table(cp14_64_regs, ARRAY_SIZE(cp14_64_regs), "cp14_64_regs", true);
> +	valid &= check_sysreg_table(cp15_regs, ARRAY_SIZE(cp15_regs), "cp15_regs", true);
> +	valid &= check_sysreg_table(cp15_64_regs, ARRAY_SIZE(cp15_64_regs), "cp15_64_regs", true);
> +	valid &= check_sysreg_table(invariant_sys_regs, ARRAY_SIZE(invariant_sys_regs),
> +				    "invariant_sys_regs", false);
>  
>  	if (!valid)
>  		return -EINVAL;
> -- 
> 2.36.0
> 
> _______________________________________________
> kvmarm mailing list
> kvmarm@lists.cs.columbia.edu
> https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 2/2] KVM/arm64: Print sysreg table name when table is not sorted
@ 2022-04-26  9:04     ` Alexandru Elisei
  0 siblings, 0 replies; 16+ messages in thread
From: Alexandru Elisei @ 2022-04-26  9:04 UTC (permalink / raw)
  To: maz, james.morse, suzuki.poulose, linux-arm-kernel, kvmarm

Hi,

Err.. this is a work-in-progress version of patch #2 ("KVM/arm64: Print
emulated register table name when it is unsorted").  I sent it by mistake
because I forgot to clean the patch directory before sending the series.

I'll resend the series without this patch.

Thanks,
Alex

On Mon, Apr 25, 2022 at 05:39:04PM +0100, Alexandru Elisei wrote:
> When a sysreg table entry is out-of-order, KVM attempts to print the
> address of the table:
> 
> [    0.143881] kvm [1]: sys_reg table (____ptrval____) out of order (0)
> 
> Printing the name of the table instead of a pointer is more helpful in this
> case:
> 
> [    0.143881] kvm [1]: sys_reg table sys_reg_descs out of order (0)
> 
> Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
> ---
>  arch/arm64/kvm/sys_regs.c | 20 +++++++++++---------
>  1 file changed, 11 insertions(+), 9 deletions(-)
> 
> diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
> index 57302048afd0..7b62a2daf056 100644
> --- a/arch/arm64/kvm/sys_regs.c
> +++ b/arch/arm64/kvm/sys_regs.c
> @@ -2188,18 +2188,18 @@ static const struct sys_reg_desc cp15_64_regs[] = {
>  };
>  
>  static bool check_sysreg_table(const struct sys_reg_desc *table, unsigned int n,
> -			       bool is_32)
> +			       const char *table_name, bool is_32)
>  {
>  	unsigned int i;
>  
>  	for (i = 0; i < n; i++) {
>  		if (!is_32 && table[i].reg && !table[i].reset) {
> -			kvm_err("sys_reg table %p entry %d lacks reset\n", table, i);
> +			kvm_err("sys_reg table %s entry %d lacks reset\n", table_name, i);
>  			return false;
>  		}
>  
>  		if (i && cmp_sys_reg(&table[i-1], &table[i]) >= 0) {
> -			kvm_err("sys_reg table %p out of order (%d)\n", table, i - 1);
> +			kvm_err("sys_reg table %s out of order (%d)\n", table_name, i - 1);
>  			return false;
>  		}
>  	}
> @@ -2866,12 +2866,14 @@ int kvm_sys_reg_table_init(void)
>  	struct sys_reg_desc clidr;
>  
>  	/* Make sure tables are unique and in order. */
> -	valid &= check_sysreg_table(sys_reg_descs, ARRAY_SIZE(sys_reg_descs), false);
> -	valid &= check_sysreg_table(cp14_regs, ARRAY_SIZE(cp14_regs), true);
> -	valid &= check_sysreg_table(cp14_64_regs, ARRAY_SIZE(cp14_64_regs), true);
> -	valid &= check_sysreg_table(cp15_regs, ARRAY_SIZE(cp15_regs), true);
> -	valid &= check_sysreg_table(cp15_64_regs, ARRAY_SIZE(cp15_64_regs), true);
> -	valid &= check_sysreg_table(invariant_sys_regs, ARRAY_SIZE(invariant_sys_regs), false);
> +	valid &= check_sysreg_table(sys_reg_descs, ARRAY_SIZE(sys_reg_descs),
> +				    "sys_reg_descs", false);
> +	valid &= check_sysreg_table(cp14_regs, ARRAY_SIZE(cp14_regs), "cp14_regs", true);
> +	valid &= check_sysreg_table(cp14_64_regs, ARRAY_SIZE(cp14_64_regs), "cp14_64_regs", true);
> +	valid &= check_sysreg_table(cp15_regs, ARRAY_SIZE(cp15_regs), "cp15_regs", true);
> +	valid &= check_sysreg_table(cp15_64_regs, ARRAY_SIZE(cp15_64_regs), "cp15_64_regs", true);
> +	valid &= check_sysreg_table(invariant_sys_regs, ARRAY_SIZE(invariant_sys_regs),
> +				    "invariant_sys_regs", false);
>  
>  	if (!valid)
>  		return -EINVAL;
> -- 
> 2.36.0
> 
> _______________________________________________
> kvmarm mailing list
> kvmarm@lists.cs.columbia.edu
> https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 2/2] KVM/arm64: Print emulated register table name when it is unsorted
  2022-04-25 16:39   ` Alexandru Elisei
@ 2022-04-26 21:18     ` Marc Zyngier
  -1 siblings, 0 replies; 16+ messages in thread
From: Marc Zyngier @ 2022-04-26 21:18 UTC (permalink / raw)
  To: Alexandru Elisei; +Cc: kvmarm, linux-arm-kernel

On Mon, 25 Apr 2022 17:39:03 +0100,
Alexandru Elisei <alexandru.elisei@arm.com> wrote:
> 
> When a sysreg table entry is out-of-order, KVM attempts to print the
> address of the table:
> 
> [    0.143881] kvm [1]: sys_reg table (____ptrval____) out of order (0)
> 
> Printing the name of the table instead of a pointer is more helpful in this
> case:
> 
> [    0.143881] kvm [1]: sys_reg table sys_reg_descs out of order (0)
> 
> Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
> ---
>  arch/arm64/kvm/sys_regs.c | 20 +++++++++++---------
>  1 file changed, 11 insertions(+), 9 deletions(-)
> 
> diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
> index 57302048afd0..7b62a2daf056 100644
> --- a/arch/arm64/kvm/sys_regs.c
> +++ b/arch/arm64/kvm/sys_regs.c
> @@ -2188,18 +2188,18 @@ static const struct sys_reg_desc cp15_64_regs[] = {
>  };
>  
>  static bool check_sysreg_table(const struct sys_reg_desc *table, unsigned int n,
> -			       bool is_32)
> +			       const char *table_name, bool is_32)
>  {
>  	unsigned int i;
>  
>  	for (i = 0; i < n; i++) {
>  		if (!is_32 && table[i].reg && !table[i].reset) {
> -			kvm_err("sys_reg table %p entry %d lacks reset\n", table, i);
> +			kvm_err("sys_reg table %s entry %d lacks reset\n", table_name, i);

Instead of passing a table name, could we simply use something like
%pS? If this works, it would be a good indication of both what table
and what entry in that table is at fault.

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 2/2] KVM/arm64: Print emulated register table name when it is unsorted
@ 2022-04-26 21:18     ` Marc Zyngier
  0 siblings, 0 replies; 16+ messages in thread
From: Marc Zyngier @ 2022-04-26 21:18 UTC (permalink / raw)
  To: Alexandru Elisei; +Cc: james.morse, suzuki.poulose, linux-arm-kernel, kvmarm

On Mon, 25 Apr 2022 17:39:03 +0100,
Alexandru Elisei <alexandru.elisei@arm.com> wrote:
> 
> When a sysreg table entry is out-of-order, KVM attempts to print the
> address of the table:
> 
> [    0.143881] kvm [1]: sys_reg table (____ptrval____) out of order (0)
> 
> Printing the name of the table instead of a pointer is more helpful in this
> case:
> 
> [    0.143881] kvm [1]: sys_reg table sys_reg_descs out of order (0)
> 
> Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
> ---
>  arch/arm64/kvm/sys_regs.c | 20 +++++++++++---------
>  1 file changed, 11 insertions(+), 9 deletions(-)
> 
> diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
> index 57302048afd0..7b62a2daf056 100644
> --- a/arch/arm64/kvm/sys_regs.c
> +++ b/arch/arm64/kvm/sys_regs.c
> @@ -2188,18 +2188,18 @@ static const struct sys_reg_desc cp15_64_regs[] = {
>  };
>  
>  static bool check_sysreg_table(const struct sys_reg_desc *table, unsigned int n,
> -			       bool is_32)
> +			       const char *table_name, bool is_32)
>  {
>  	unsigned int i;
>  
>  	for (i = 0; i < n; i++) {
>  		if (!is_32 && table[i].reg && !table[i].reset) {
> -			kvm_err("sys_reg table %p entry %d lacks reset\n", table, i);
> +			kvm_err("sys_reg table %s entry %d lacks reset\n", table_name, i);

Instead of passing a table name, could we simply use something like
%pS? If this works, it would be a good indication of both what table
and what entry in that table is at fault.

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 2/2] KVM/arm64: Print emulated register table name when it is unsorted
  2022-04-26 21:18     ` Marc Zyngier
@ 2022-04-27 10:21       ` Alexandru Elisei
  -1 siblings, 0 replies; 16+ messages in thread
From: Alexandru Elisei @ 2022-04-27 10:21 UTC (permalink / raw)
  To: Marc Zyngier; +Cc: kvmarm, linux-arm-kernel

Hi,

On Tue, Apr 26, 2022 at 10:18:27PM +0100, Marc Zyngier wrote:
> On Mon, 25 Apr 2022 17:39:03 +0100,
> Alexandru Elisei <alexandru.elisei@arm.com> wrote:
> > 
> > When a sysreg table entry is out-of-order, KVM attempts to print the
> > address of the table:
> > 
> > [    0.143881] kvm [1]: sys_reg table (____ptrval____) out of order (0)
> > 
> > Printing the name of the table instead of a pointer is more helpful in this
> > case:
> > 
> > [    0.143881] kvm [1]: sys_reg table sys_reg_descs out of order (0)
> > 
> > Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
> > ---
> >  arch/arm64/kvm/sys_regs.c | 20 +++++++++++---------
> >  1 file changed, 11 insertions(+), 9 deletions(-)
> > 
> > diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
> > index 57302048afd0..7b62a2daf056 100644
> > --- a/arch/arm64/kvm/sys_regs.c
> > +++ b/arch/arm64/kvm/sys_regs.c
> > @@ -2188,18 +2188,18 @@ static const struct sys_reg_desc cp15_64_regs[] = {
> >  };
> >  
> >  static bool check_sysreg_table(const struct sys_reg_desc *table, unsigned int n,
> > -			       bool is_32)
> > +			       const char *table_name, bool is_32)
> >  {
> >  	unsigned int i;
> >  
> >  	for (i = 0; i < n; i++) {
> >  		if (!is_32 && table[i].reg && !table[i].reset) {
> > -			kvm_err("sys_reg table %p entry %d lacks reset\n", table, i);
> > +			kvm_err("sys_reg table %s entry %d lacks reset\n", table_name, i);
> 
> Instead of passing a table name, could we simply use something like
> %pS? If this works, it would be a good indication of both what table
> and what entry in that table is at fault.

With the change:

-                       kvm_err("sys_reg table %s out of order (%d)\n", table_name, i - 1);
+                       kvm_err("sys_reg table %pS out of order (%d)\n", &table[i - 1], i - 1);


this is what KVM prints with %pS if the second entry is out-of-order:

[    0.143698] kvm [1]: sys_reg table sys_reg_descs+0x50/0x7490 out of order (1)

There's redundant information now, the entry can be calculated from the
table offset, but printing the offset directly is certainly convenient.

I like it more than passing the table name, if you agree I'll send a v2
with this change.

Thanks,
Alex
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 2/2] KVM/arm64: Print emulated register table name when it is unsorted
@ 2022-04-27 10:21       ` Alexandru Elisei
  0 siblings, 0 replies; 16+ messages in thread
From: Alexandru Elisei @ 2022-04-27 10:21 UTC (permalink / raw)
  To: Marc Zyngier; +Cc: james.morse, suzuki.poulose, linux-arm-kernel, kvmarm

Hi,

On Tue, Apr 26, 2022 at 10:18:27PM +0100, Marc Zyngier wrote:
> On Mon, 25 Apr 2022 17:39:03 +0100,
> Alexandru Elisei <alexandru.elisei@arm.com> wrote:
> > 
> > When a sysreg table entry is out-of-order, KVM attempts to print the
> > address of the table:
> > 
> > [    0.143881] kvm [1]: sys_reg table (____ptrval____) out of order (0)
> > 
> > Printing the name of the table instead of a pointer is more helpful in this
> > case:
> > 
> > [    0.143881] kvm [1]: sys_reg table sys_reg_descs out of order (0)
> > 
> > Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
> > ---
> >  arch/arm64/kvm/sys_regs.c | 20 +++++++++++---------
> >  1 file changed, 11 insertions(+), 9 deletions(-)
> > 
> > diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
> > index 57302048afd0..7b62a2daf056 100644
> > --- a/arch/arm64/kvm/sys_regs.c
> > +++ b/arch/arm64/kvm/sys_regs.c
> > @@ -2188,18 +2188,18 @@ static const struct sys_reg_desc cp15_64_regs[] = {
> >  };
> >  
> >  static bool check_sysreg_table(const struct sys_reg_desc *table, unsigned int n,
> > -			       bool is_32)
> > +			       const char *table_name, bool is_32)
> >  {
> >  	unsigned int i;
> >  
> >  	for (i = 0; i < n; i++) {
> >  		if (!is_32 && table[i].reg && !table[i].reset) {
> > -			kvm_err("sys_reg table %p entry %d lacks reset\n", table, i);
> > +			kvm_err("sys_reg table %s entry %d lacks reset\n", table_name, i);
> 
> Instead of passing a table name, could we simply use something like
> %pS? If this works, it would be a good indication of both what table
> and what entry in that table is at fault.

With the change:

-                       kvm_err("sys_reg table %s out of order (%d)\n", table_name, i - 1);
+                       kvm_err("sys_reg table %pS out of order (%d)\n", &table[i - 1], i - 1);


this is what KVM prints with %pS if the second entry is out-of-order:

[    0.143698] kvm [1]: sys_reg table sys_reg_descs+0x50/0x7490 out of order (1)

There's redundant information now, the entry can be calculated from the
table offset, but printing the offset directly is certainly convenient.

I like it more than passing the table name, if you agree I'll send a v2
with this change.

Thanks,
Alex

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 2/2] KVM/arm64: Print emulated register table name when it is unsorted
  2022-04-27 10:21       ` Alexandru Elisei
@ 2022-04-27 20:56         ` Marc Zyngier
  -1 siblings, 0 replies; 16+ messages in thread
From: Marc Zyngier @ 2022-04-27 20:56 UTC (permalink / raw)
  To: Alexandru Elisei; +Cc: kvmarm, linux-arm-kernel

On Wed, 27 Apr 2022 11:21:52 +0100,
Alexandru Elisei <alexandru.elisei@arm.com> wrote:
> 
> Hi,
> 
> On Tue, Apr 26, 2022 at 10:18:27PM +0100, Marc Zyngier wrote:
> > On Mon, 25 Apr 2022 17:39:03 +0100,
> > Alexandru Elisei <alexandru.elisei@arm.com> wrote:
> > > 
> > > When a sysreg table entry is out-of-order, KVM attempts to print the
> > > address of the table:
> > > 
> > > [    0.143881] kvm [1]: sys_reg table (____ptrval____) out of order (0)
> > > 
> > > Printing the name of the table instead of a pointer is more helpful in this
> > > case:
> > > 
> > > [    0.143881] kvm [1]: sys_reg table sys_reg_descs out of order (0)
> > > 
> > > Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
> > > ---
> > >  arch/arm64/kvm/sys_regs.c | 20 +++++++++++---------
> > >  1 file changed, 11 insertions(+), 9 deletions(-)
> > > 
> > > diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
> > > index 57302048afd0..7b62a2daf056 100644
> > > --- a/arch/arm64/kvm/sys_regs.c
> > > +++ b/arch/arm64/kvm/sys_regs.c
> > > @@ -2188,18 +2188,18 @@ static const struct sys_reg_desc cp15_64_regs[] = {
> > >  };
> > >  
> > >  static bool check_sysreg_table(const struct sys_reg_desc *table, unsigned int n,
> > > -			       bool is_32)
> > > +			       const char *table_name, bool is_32)
> > >  {
> > >  	unsigned int i;
> > >  
> > >  	for (i = 0; i < n; i++) {
> > >  		if (!is_32 && table[i].reg && !table[i].reset) {
> > > -			kvm_err("sys_reg table %p entry %d lacks reset\n", table, i);
> > > +			kvm_err("sys_reg table %s entry %d lacks reset\n", table_name, i);
> > 
> > Instead of passing a table name, could we simply use something like
> > %pS? If this works, it would be a good indication of both what table
> > and what entry in that table is at fault.
> 
> With the change:
> 
> -                       kvm_err("sys_reg table %s out of order (%d)\n", table_name, i - 1);
> +                       kvm_err("sys_reg table %pS out of order (%d)\n", &table[i - 1], i - 1);
> 
> 
> this is what KVM prints with %pS if the second entry is out-of-order:
> 
> [    0.143698] kvm [1]: sys_reg table sys_reg_descs+0x50/0x7490 out of order (1)
> 
> There's redundant information now, the entry can be calculated from the
> table offset, but printing the offset directly is certainly convenient.
> 
> I like it more than passing the table name, if you agree I'll send a v2
> with this change.

Yup, seems like a valuable change.

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 2/2] KVM/arm64: Print emulated register table name when it is unsorted
@ 2022-04-27 20:56         ` Marc Zyngier
  0 siblings, 0 replies; 16+ messages in thread
From: Marc Zyngier @ 2022-04-27 20:56 UTC (permalink / raw)
  To: Alexandru Elisei; +Cc: james.morse, suzuki.poulose, linux-arm-kernel, kvmarm

On Wed, 27 Apr 2022 11:21:52 +0100,
Alexandru Elisei <alexandru.elisei@arm.com> wrote:
> 
> Hi,
> 
> On Tue, Apr 26, 2022 at 10:18:27PM +0100, Marc Zyngier wrote:
> > On Mon, 25 Apr 2022 17:39:03 +0100,
> > Alexandru Elisei <alexandru.elisei@arm.com> wrote:
> > > 
> > > When a sysreg table entry is out-of-order, KVM attempts to print the
> > > address of the table:
> > > 
> > > [    0.143881] kvm [1]: sys_reg table (____ptrval____) out of order (0)
> > > 
> > > Printing the name of the table instead of a pointer is more helpful in this
> > > case:
> > > 
> > > [    0.143881] kvm [1]: sys_reg table sys_reg_descs out of order (0)
> > > 
> > > Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
> > > ---
> > >  arch/arm64/kvm/sys_regs.c | 20 +++++++++++---------
> > >  1 file changed, 11 insertions(+), 9 deletions(-)
> > > 
> > > diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
> > > index 57302048afd0..7b62a2daf056 100644
> > > --- a/arch/arm64/kvm/sys_regs.c
> > > +++ b/arch/arm64/kvm/sys_regs.c
> > > @@ -2188,18 +2188,18 @@ static const struct sys_reg_desc cp15_64_regs[] = {
> > >  };
> > >  
> > >  static bool check_sysreg_table(const struct sys_reg_desc *table, unsigned int n,
> > > -			       bool is_32)
> > > +			       const char *table_name, bool is_32)
> > >  {
> > >  	unsigned int i;
> > >  
> > >  	for (i = 0; i < n; i++) {
> > >  		if (!is_32 && table[i].reg && !table[i].reset) {
> > > -			kvm_err("sys_reg table %p entry %d lacks reset\n", table, i);
> > > +			kvm_err("sys_reg table %s entry %d lacks reset\n", table_name, i);
> > 
> > Instead of passing a table name, could we simply use something like
> > %pS? If this works, it would be a good indication of both what table
> > and what entry in that table is at fault.
> 
> With the change:
> 
> -                       kvm_err("sys_reg table %s out of order (%d)\n", table_name, i - 1);
> +                       kvm_err("sys_reg table %pS out of order (%d)\n", &table[i - 1], i - 1);
> 
> 
> this is what KVM prints with %pS if the second entry is out-of-order:
> 
> [    0.143698] kvm [1]: sys_reg table sys_reg_descs+0x50/0x7490 out of order (1)
> 
> There's redundant information now, the entry can be calculated from the
> table offset, but printing the offset directly is certainly convenient.
> 
> I like it more than passing the table name, if you agree I'll send a v2
> with this change.

Yup, seems like a valuable change.

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2022-04-27 20:57 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-25 16:39 [PATCH 0/2] KVM/arm64: sys_reg_table_init() small improvements Alexandru Elisei
2022-04-25 16:39 ` Alexandru Elisei
2022-04-25 16:39 ` [PATCH 1/2] KVM/arm64: Don't BUG_ON() if emulated register table is unsorted Alexandru Elisei
2022-04-25 16:39   ` Alexandru Elisei
2022-04-25 16:39 ` [PATCH 2/2] KVM/arm64: Print emulated register table name when it " Alexandru Elisei
2022-04-25 16:39   ` Alexandru Elisei
2022-04-26 21:18   ` Marc Zyngier
2022-04-26 21:18     ` Marc Zyngier
2022-04-27 10:21     ` Alexandru Elisei
2022-04-27 10:21       ` Alexandru Elisei
2022-04-27 20:56       ` Marc Zyngier
2022-04-27 20:56         ` Marc Zyngier
2022-04-25 16:39 ` [PATCH 2/2] KVM/arm64: Print sysreg table name when table is not sorted Alexandru Elisei
2022-04-25 16:39   ` Alexandru Elisei
2022-04-26  9:04   ` Alexandru Elisei
2022-04-26  9:04     ` Alexandru Elisei

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.