Skip to contentSkip to conversation

KVM: arm64: Fix hypervisor address symbolization

PATCH Applied Kalesh Singh 3 participants 6 messages Jul 15, 2022 – Jul 18, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM: arm64: Fix hypervisor address symbolization

With CONFIG_RANDOMIZE_BASE=y vmlinux addresses will resolve correctly from kallsyms. Fix this by adding the KASLR offset before printing the symbols.

Based on arm64 for-next/stacktrace.

Fixes 6ccf9cb557bd ("KVM: arm64: Symbolize the nVHE HYP addresses")
---
 arch/arm64/kvm/handle_exit.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/kvm/handle_exit.c +2 -2
index f66c0142b335..e43926ef2bc2 100644
@@ -347,10 +347,10 @@ void __noreturn __cold nvhe_hyp_panic_handler(u64 esr, u64 spsr,
 			kvm_err("nVHE hyp BUG at: %s:%u!\n", file, line);
 		else
 			kvm_err("nVHE hyp BUG at: [<%016llx>] %pB!\n", panic_addr,
-					(void *)panic_addr);
+					(void *)(panic_addr + kaslr_offset()));
 	} else {
 		kvm_err("nVHE hyp panic at: [<%016llx>] %pB!\n", panic_addr,
-				(void *)panic_addr);
+				(void *)(panic_addr + kaslr_offset()));
 	}
 
 	/*

base-commit: 82a592c13b0aeff94d84d54183dae0b26384c95f

Signature · 6 lines
2.37.0.170.g444d1eabd0-goog

_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
maintainer
#1 lore raw
Quoted 2 lines · Kalesh Singh

With CONFIG_RANDOMIZE_BASE=y vmlinux addresses will resolve correctly

I guess you mean *incorrectly* here, right?

Quoted 4 lines

from kallsyms. Fix this by adding the KASLR offset before printing the symbols.

Based on arm64 for-next/stacktrace.

In general, place these remarks after the '---' line, as they don't really make sense in the commit itself (which is likely to be merged on a different base anyway).

Quoted 16 lines
Fixes 6ccf9cb557bd ("KVM: arm64: Symbolize the nVHE HYP addresses")
---
 arch/arm64/kvm/handle_exit.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/kvm/handle_exit.c +0 -0
index f66c0142b335..e43926ef2bc2 100644
@@ -347,10 +347,10 @@ void __noreturn __cold nvhe_hyp_panic_handler(u64 esr, u64 spsr,
 			kvm_err("nVHE hyp BUG at: %s:%u!\n", file, line);
 		else

arch/arm64/kvm/handle_exit.c void __noreturn __cold nvhe_hyp_panic_handler(u64 esr, u64 spsr, · line 356

Quoted 10 lines
arch/arm64/kvm/handle_exit.c +2 -2
 			kvm_err("nVHE hyp BUG at: [<%016llx>] %pB!\n", panic_addr,
-					(void *)panic_addr);
+					(void *)(panic_addr + kaslr_offset()));
 	} else {
 		kvm_err("nVHE hyp panic at: [<%016llx>] %pB!\n", panic_addr,
-				(void *)panic_addr);
+				(void *)(panic_addr + kaslr_offset()));
 	}
 
 	/*

I'll fix the above as I apply the patch, no need to respin.

Thanks,

	M.
Signature · 5 lines
Without deviation from the norm, progress is not possible.
_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
#2 lore raw
Quoted 7 lines · Marc Zyngier
Quoted 2 lines · Kalesh Singh

With CONFIG_RANDOMIZE_BASE=y vmlinux addresses will resolve correctly

I guess you mean *incorrectly* here, right?

Yes, sorry. "INcorrectly" I meant to say.

Quoted 34 lines
Quoted 5 lines

from kallsyms. Fix this by adding the KASLR offset before printing the symbols.

Based on arm64 for-next/stacktrace.

In general, place these remarks after the '---' line, as they don't really make sense in the commit itself (which is likely to be merged on a different base anyway).

Quoted 24 lines
Fixes 6ccf9cb557bd ("KVM: arm64: Symbolize the nVHE HYP addresses")
---
 arch/arm64/kvm/handle_exit.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/kvm/handle_exit.c +2 -2
index f66c0142b335..e43926ef2bc2 100644
@@ -347,10 +347,10 @@ void __noreturn __cold nvhe_hyp_panic_handler(u64 esr, u64 spsr,
                      kvm_err("nVHE hyp BUG at: %s:%u!\n", file, line);
              else
                      kvm_err("nVHE hyp BUG at: [<%016llx>] %pB!\n", panic_addr,
-                                     (void *)panic_addr);
+                                     (void *)(panic_addr + kaslr_offset()));
      } else {
              kvm_err("nVHE hyp panic at: [<%016llx>] %pB!\n", panic_addr,
-                             (void *)panic_addr);
+                             (void *)(panic_addr + kaslr_offset()));
      }
 
Quoted 4 lines

arch/arm64/kvm/handle_exit.c void __noreturn __cold nvhe_hyp_panic_handler(u64 esr, u64 spsr, · line 356

Quoted 2 lines
arch/arm64/kvm/handle_exit.c +0 -0
      /*

I'll fix the above as I apply the patch, no need to respin.

Thanks Marc.

-- Kalesh

Quoted 7 lines

Thanks,

        M.

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

_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

maintainer Applied
#3 lore raw
In reply to Kalesh Singh
Quoted 5 lines · Kalesh Singh

With CONFIG_RANDOMIZE_BASE=y vmlinux addresses will resolve correctly from kallsyms. Fix this by adding the KASLR offset before printing the symbols.

Based on arm64 for-next/stacktrace.

Applied to next, thanks!

[1/1] KVM: arm64: Fix hypervisor address symbolization

      commit: ed6313a93fd11d2015ad17046f3c418bf6a8dab1

Cheers,

	M.
Signature · 6 lines
Marc Zyngier <[email protected]>

_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
#4 lore raw
In reply to Kalesh Singh

Hi Kalesh,

Quoted 11 lines · Kalesh Singh

With CONFIG_RANDOMIZE_BASE=y vmlinux addresses will resolve correctly from kallsyms. Fix this by adding the KASLR offset before printing the symbols.

Based on arm64 for-next/stacktrace.

Fixes 6ccf9cb557bd ("KVM: arm64: Symbolize the nVHE HYP addresses")

---

Even with this patch applied I still don't get symbolization unless I disable randomization, either by setting CONFIG_RANDOMIZE_BASE=n or pass nokaslr as a kernel parameter. I tried both and in either case it works.

Thanks,
/fuad

Quoted 21 lines
 arch/arm64/kvm/handle_exit.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/kvm/handle_exit.c +2 -2
index f66c0142b335..e43926ef2bc2 100644
@@ -347,10 +347,10 @@ void __noreturn __cold nvhe_hyp_panic_handler(u64 esr, u64 spsr,
                        kvm_err("nVHE hyp BUG at: %s:%u!\n", file, line);
                else
                        kvm_err("nVHE hyp BUG at: [<%016llx>] %pB!\n", panic_addr,
-                                       (void *)panic_addr);
+                                       (void *)(panic_addr + kaslr_offset()));
        } else {
                kvm_err("nVHE hyp panic at: [<%016llx>] %pB!\n", panic_addr,
-                               (void *)panic_addr);
+                               (void *)(panic_addr + kaslr_offset()));
        }
 
        /*
Quoted 4 lines

base-commit: 82a592c13b0aeff94d84d54183dae0b26384c95f --
2.37.0.170.g444d1eabd0-goog

_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

#5 lore raw
Quoted 16 lines · Fuad Tabba

Hi Kalesh,

Quoted 11 lines · Kalesh Singh

With CONFIG_RANDOMIZE_BASE=y vmlinux addresses will resolve correctly from kallsyms. Fix this by adding the KASLR offset before printing the symbols.

Based on arm64 for-next/stacktrace.

Fixes 6ccf9cb557bd ("KVM: arm64: Symbolize the nVHE HYP addresses")

---

Quoted 4 lines

Even with this patch applied I still don't get symbolization unless I disable randomization, either by setting CONFIG_RANDOMIZE_BASE=n or pass nokaslr as a kernel parameter. I tried both and in either case it works.

Hi Fuad,

Thanks for testing it. The fix only addressed the symbolization for the hyp panic address. I plan to fix the symbolization of stacktrace in the next version of this series.

--Kalesh

Quoted 24 lines

Thanks,
/fuad

Quoted 19 lines
 arch/arm64/kvm/handle_exit.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/kvm/handle_exit.c +2 -2
index f66c0142b335..e43926ef2bc2 100644
@@ -347,10 +347,10 @@ void __noreturn __cold nvhe_hyp_panic_handler(u64 esr, u64 spsr,
                        kvm_err("nVHE hyp BUG at: %s:%u!\n", file, line);
                else
                        kvm_err("nVHE hyp BUG at: [<%016llx>] %pB!\n", panic_addr,
-                                       (void *)panic_addr);
+                                       (void *)(panic_addr + kaslr_offset()));
        } else {
                kvm_err("nVHE hyp panic at: [<%016llx>] %pB!\n", panic_addr,
-                               (void *)panic_addr);
+                               (void *)(panic_addr + kaslr_offset()));
        }
 
Quoted 6 lines
Quoted 6 lines
arch/arm64/kvm/handle_exit.c +0 -0
        /*

base-commit: 82a592c13b0aeff94d84d54183dae0b26384c95f --
2.37.0.170.g444d1eabd0-goog

_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm