All of lore.kernel.org
 help / color / mirror / Atom feed
* [RESEND PATCH 0/2] arm/arm64: kvm: Disable branch profiling in HYP code
@ 2017-10-20 11:34 ` Julien Thierry
  0 siblings, 0 replies; 9+ messages in thread
From: Julien Thierry @ 2017-10-20 11:34 UTC (permalink / raw)
  To: linux-arm-kernel, kvmarm; +Cc: marc.zyngier, Julien Thierry

[Resending for Christoffer and adding kvmarm to recipients]

Hi,

When enabling branch profiling, a lockup occurs at boot time, after
displaying: "kvm [1]: Hyp mode initialized successfully"

The issue is caused by the Hyp code getting instrumented and trying to
access unmapped code or data, which happens when trying to initialize EL2.

So it also seems like KVM is misleadingly announcing it was initialized and
yet gets stuck during initialization.

* First patch deals with printing the initialization message once KVM has
  fully initialized Hyp mode
* Second patch actually disables branch profiling instrumentation in Hyp
  code

Cheers,

Julien Thierry (2):
  arm/arm64: kvm: Move initialization completion message
  arm/arm64: kvm: Disable branch profiling in HYP code

 arch/arm/kvm/hyp/Makefile   |  2 +-
 arch/arm64/kvm/hyp/Makefile |  2 +-
 virt/kvm/arm/arm.c          | 31 ++++++++++++++-----------------
 3 files changed, 16 insertions(+), 19 deletions(-)

--
1.9.1

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

* [RESEND PATCH 0/2] arm/arm64: kvm: Disable branch profiling in HYP code
@ 2017-10-20 11:34 ` Julien Thierry
  0 siblings, 0 replies; 9+ messages in thread
From: Julien Thierry @ 2017-10-20 11:34 UTC (permalink / raw)
  To: linux-arm-kernel

[Resending for Christoffer and adding kvmarm to recipients]

Hi,

When enabling branch profiling, a lockup occurs at boot time, after
displaying: "kvm [1]: Hyp mode initialized successfully"

The issue is caused by the Hyp code getting instrumented and trying to
access unmapped code or data, which happens when trying to initialize EL2.

So it also seems like KVM is misleadingly announcing it was initialized and
yet gets stuck during initialization.

* First patch deals with printing the initialization message once KVM has
  fully initialized Hyp mode
* Second patch actually disables branch profiling instrumentation in Hyp
  code

Cheers,

Julien Thierry (2):
  arm/arm64: kvm: Move initialization completion message
  arm/arm64: kvm: Disable branch profiling in HYP code

 arch/arm/kvm/hyp/Makefile   |  2 +-
 arch/arm64/kvm/hyp/Makefile |  2 +-
 virt/kvm/arm/arm.c          | 31 ++++++++++++++-----------------
 3 files changed, 16 insertions(+), 19 deletions(-)

--
1.9.1

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

* [RESEND PATCH 1/2] arm/arm64: kvm: Move initialization completion message
  2017-10-20 11:34 ` Julien Thierry
@ 2017-10-20 11:34   ` Julien Thierry
  -1 siblings, 0 replies; 9+ messages in thread
From: Julien Thierry @ 2017-10-20 11:34 UTC (permalink / raw)
  To: linux-arm-kernel, kvmarm; +Cc: marc.zyngier, Julien Thierry

KVM is being a bit too optimistic, Hyp mode is said to be initialized
when Hyp segments have only been mapped.

Notify KVM's successful initialization only once it is really fully
initialized.

Signed-off-by: Julien Thierry <julien.thierry@arm.com>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Cc: Christoffer Dall <christoffer.dall@linaro.org>
---
 virt/kvm/arm/arm.c | 31 ++++++++++++++-----------------
 1 file changed, 14 insertions(+), 17 deletions(-)

diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c
index b9f68e4..95cba07 100644
--- a/virt/kvm/arm/arm.c
+++ b/virt/kvm/arm/arm.c
@@ -1326,21 +1326,12 @@ static void teardown_hyp_mode(void)
 {
 	int cpu;

-	if (is_kernel_in_hyp_mode())
-		return;
-
 	free_hyp_pgds();
 	for_each_possible_cpu(cpu)
 		free_page(per_cpu(kvm_arm_hyp_stack_page, cpu));
 	hyp_cpu_pm_exit();
 }

-static int init_vhe_mode(void)
-{
-	kvm_info("VHE mode initialized successfully\n");
-	return 0;
-}
-
 /**
  * Inits Hyp-mode on all online CPUs
  */
@@ -1421,8 +1412,6 @@ static int init_hyp_mode(void)
 		}
 	}

-	kvm_info("Hyp mode initialized successfully\n");
-
 	return 0;

 out_err:
@@ -1456,6 +1445,7 @@ int kvm_arch_init(void *opaque)
 {
 	int err;
 	int ret, cpu;
+	bool in_hyp_mode;

 	if (!is_hyp_mode_available()) {
 		kvm_err("HYP mode not available\n");
@@ -1474,21 +1464,28 @@ int kvm_arch_init(void *opaque)
 	if (err)
 		return err;

-	if (is_kernel_in_hyp_mode())
-		err = init_vhe_mode();
-	else
+	in_hyp_mode = is_kernel_in_hyp_mode();
+
+	if (!in_hyp_mode) {
 		err = init_hyp_mode();
-	if (err)
-		goto out_err;
+		if (err)
+			goto out_err;
+	}

 	err = init_subsystems();
 	if (err)
 		goto out_hyp;

+	if (in_hyp_mode)
+		kvm_info("VHE mode initialized successfully\n");
+	else
+		kvm_info("Hyp mode initialized successfully\n");
+
 	return 0;

 out_hyp:
-	teardown_hyp_mode();
+	if (!in_hyp_mode)
+		teardown_hyp_mode();
 out_err:
 	teardown_common_resources();
 	return err;
--
1.9.1

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

* [RESEND PATCH 1/2] arm/arm64: kvm: Move initialization completion message
@ 2017-10-20 11:34   ` Julien Thierry
  0 siblings, 0 replies; 9+ messages in thread
From: Julien Thierry @ 2017-10-20 11:34 UTC (permalink / raw)
  To: linux-arm-kernel

KVM is being a bit too optimistic, Hyp mode is said to be initialized
when Hyp segments have only been mapped.

Notify KVM's successful initialization only once it is really fully
initialized.

Signed-off-by: Julien Thierry <julien.thierry@arm.com>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Cc: Christoffer Dall <christoffer.dall@linaro.org>
---
 virt/kvm/arm/arm.c | 31 ++++++++++++++-----------------
 1 file changed, 14 insertions(+), 17 deletions(-)

diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c
index b9f68e4..95cba07 100644
--- a/virt/kvm/arm/arm.c
+++ b/virt/kvm/arm/arm.c
@@ -1326,21 +1326,12 @@ static void teardown_hyp_mode(void)
 {
 	int cpu;

-	if (is_kernel_in_hyp_mode())
-		return;
-
 	free_hyp_pgds();
 	for_each_possible_cpu(cpu)
 		free_page(per_cpu(kvm_arm_hyp_stack_page, cpu));
 	hyp_cpu_pm_exit();
 }

-static int init_vhe_mode(void)
-{
-	kvm_info("VHE mode initialized successfully\n");
-	return 0;
-}
-
 /**
  * Inits Hyp-mode on all online CPUs
  */
@@ -1421,8 +1412,6 @@ static int init_hyp_mode(void)
 		}
 	}

-	kvm_info("Hyp mode initialized successfully\n");
-
 	return 0;

 out_err:
@@ -1456,6 +1445,7 @@ int kvm_arch_init(void *opaque)
 {
 	int err;
 	int ret, cpu;
+	bool in_hyp_mode;

 	if (!is_hyp_mode_available()) {
 		kvm_err("HYP mode not available\n");
@@ -1474,21 +1464,28 @@ int kvm_arch_init(void *opaque)
 	if (err)
 		return err;

-	if (is_kernel_in_hyp_mode())
-		err = init_vhe_mode();
-	else
+	in_hyp_mode = is_kernel_in_hyp_mode();
+
+	if (!in_hyp_mode) {
 		err = init_hyp_mode();
-	if (err)
-		goto out_err;
+		if (err)
+			goto out_err;
+	}

 	err = init_subsystems();
 	if (err)
 		goto out_hyp;

+	if (in_hyp_mode)
+		kvm_info("VHE mode initialized successfully\n");
+	else
+		kvm_info("Hyp mode initialized successfully\n");
+
 	return 0;

 out_hyp:
-	teardown_hyp_mode();
+	if (!in_hyp_mode)
+		teardown_hyp_mode();
 out_err:
 	teardown_common_resources();
 	return err;
--
1.9.1

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

* [RESEND PATCH 2/2] arm/arm64: kvm: Disable branch profiling in HYP code
  2017-10-20 11:34 ` Julien Thierry
  (?)
@ 2017-10-20 11:34   ` Julien Thierry
  -1 siblings, 0 replies; 9+ messages in thread
From: Julien Thierry @ 2017-10-20 11:34 UTC (permalink / raw)
  To: linux-arm-kernel, kvmarm
  Cc: marc.zyngier, christoffer.dall, Julien Thierry, Catalin Marinas,
	Will Deacon, Russell King, stable

When HYP code runs into branch profiling code, it attempts to jump to
unmapped memory, causing a HYP Panic.

Disable the branch profiling for code designed to run at HYP mode.

Signed-off-by: Julien Thierry <julien.thierry@arm.com>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Cc: Christoffer Dall <christoffer.dall@linaro.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: <stable@vger.kernel.org>
---
 arch/arm/kvm/hyp/Makefile   | 2 +-
 arch/arm64/kvm/hyp/Makefile | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/kvm/hyp/Makefile b/arch/arm/kvm/hyp/Makefile
index 8679405..92eab1d 100644
--- a/arch/arm/kvm/hyp/Makefile
+++ b/arch/arm/kvm/hyp/Makefile
@@ -2,7 +2,7 @@
 # Makefile for Kernel-based Virtual Machine module, HYP part
 #

-ccflags-y += -fno-stack-protector
+ccflags-y += -fno-stack-protector -DDISABLE_BRANCH_PROFILING

 KVM=../../../../virt/kvm

diff --git a/arch/arm64/kvm/hyp/Makefile b/arch/arm64/kvm/hyp/Makefile
index 14c4e3b..48b0354 100644
--- a/arch/arm64/kvm/hyp/Makefile
+++ b/arch/arm64/kvm/hyp/Makefile
@@ -2,7 +2,7 @@
 # Makefile for Kernel-based Virtual Machine module, HYP part
 #

-ccflags-y += -fno-stack-protector
+ccflags-y += -fno-stack-protector -DDISABLE_BRANCH_PROFILING

 KVM=../../../../virt/kvm

--
1.9.1

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

* [RESEND PATCH 2/2] arm/arm64: kvm: Disable branch profiling in HYP code
@ 2017-10-20 11:34   ` Julien Thierry
  0 siblings, 0 replies; 9+ messages in thread
From: Julien Thierry @ 2017-10-20 11:34 UTC (permalink / raw)
  To: linux-arm-kernel, kvmarm
  Cc: Julien Thierry, marc.zyngier, Catalin Marinas, Will Deacon,
	Russell King, stable

When HYP code runs into branch profiling code, it attempts to jump to
unmapped memory, causing a HYP Panic.

Disable the branch profiling for code designed to run at HYP mode.

Signed-off-by: Julien Thierry <julien.thierry@arm.com>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Cc: Christoffer Dall <christoffer.dall@linaro.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: <stable@vger.kernel.org>
---
 arch/arm/kvm/hyp/Makefile   | 2 +-
 arch/arm64/kvm/hyp/Makefile | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/kvm/hyp/Makefile b/arch/arm/kvm/hyp/Makefile
index 8679405..92eab1d 100644
--- a/arch/arm/kvm/hyp/Makefile
+++ b/arch/arm/kvm/hyp/Makefile
@@ -2,7 +2,7 @@
 # Makefile for Kernel-based Virtual Machine module, HYP part
 #

-ccflags-y += -fno-stack-protector
+ccflags-y += -fno-stack-protector -DDISABLE_BRANCH_PROFILING

 KVM=../../../../virt/kvm

diff --git a/arch/arm64/kvm/hyp/Makefile b/arch/arm64/kvm/hyp/Makefile
index 14c4e3b..48b0354 100644
--- a/arch/arm64/kvm/hyp/Makefile
+++ b/arch/arm64/kvm/hyp/Makefile
@@ -2,7 +2,7 @@
 # Makefile for Kernel-based Virtual Machine module, HYP part
 #

-ccflags-y += -fno-stack-protector
+ccflags-y += -fno-stack-protector -DDISABLE_BRANCH_PROFILING

 KVM=../../../../virt/kvm

--
1.9.1

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

* [RESEND PATCH 2/2] arm/arm64: kvm: Disable branch profiling in HYP code
@ 2017-10-20 11:34   ` Julien Thierry
  0 siblings, 0 replies; 9+ messages in thread
From: Julien Thierry @ 2017-10-20 11:34 UTC (permalink / raw)
  To: linux-arm-kernel

When HYP code runs into branch profiling code, it attempts to jump to
unmapped memory, causing a HYP Panic.

Disable the branch profiling for code designed to run at HYP mode.

Signed-off-by: Julien Thierry <julien.thierry@arm.com>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Cc: Christoffer Dall <christoffer.dall@linaro.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: <stable@vger.kernel.org>
---
 arch/arm/kvm/hyp/Makefile   | 2 +-
 arch/arm64/kvm/hyp/Makefile | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/kvm/hyp/Makefile b/arch/arm/kvm/hyp/Makefile
index 8679405..92eab1d 100644
--- a/arch/arm/kvm/hyp/Makefile
+++ b/arch/arm/kvm/hyp/Makefile
@@ -2,7 +2,7 @@
 # Makefile for Kernel-based Virtual Machine module, HYP part
 #

-ccflags-y += -fno-stack-protector
+ccflags-y += -fno-stack-protector -DDISABLE_BRANCH_PROFILING

 KVM=../../../../virt/kvm

diff --git a/arch/arm64/kvm/hyp/Makefile b/arch/arm64/kvm/hyp/Makefile
index 14c4e3b..48b0354 100644
--- a/arch/arm64/kvm/hyp/Makefile
+++ b/arch/arm64/kvm/hyp/Makefile
@@ -2,7 +2,7 @@
 # Makefile for Kernel-based Virtual Machine module, HYP part
 #

-ccflags-y += -fno-stack-protector
+ccflags-y += -fno-stack-protector -DDISABLE_BRANCH_PROFILING

 KVM=../../../../virt/kvm

--
1.9.1

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

* Re: [RESEND PATCH 0/2] arm/arm64: kvm: Disable branch profiling in HYP code
  2017-10-20 11:34 ` Julien Thierry
@ 2017-10-21 15:04   ` Christoffer Dall
  -1 siblings, 0 replies; 9+ messages in thread
From: Christoffer Dall @ 2017-10-21 15:04 UTC (permalink / raw)
  To: Julien Thierry; +Cc: marc.zyngier, kvmarm, linux-arm-kernel

On Fri, Oct 20, 2017 at 12:34:15PM +0100, Julien Thierry wrote:
> [Resending for Christoffer and adding kvmarm to recipients]
> 
> Hi,
> 
> When enabling branch profiling, a lockup occurs at boot time, after
> displaying: "kvm [1]: Hyp mode initialized successfully"
> 
> The issue is caused by the Hyp code getting instrumented and trying to
> access unmapped code or data, which happens when trying to initialize EL2.
> 
> So it also seems like KVM is misleadingly announcing it was initialized and
> yet gets stuck during initialization.
> 
> * First patch deals with printing the initialization message once KVM has
>   fully initialized Hyp mode
> * Second patch actually disables branch profiling instrumentation in Hyp
>   code

Applied, thanks.

-Christoffer

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

* [RESEND PATCH 0/2] arm/arm64: kvm: Disable branch profiling in HYP code
@ 2017-10-21 15:04   ` Christoffer Dall
  0 siblings, 0 replies; 9+ messages in thread
From: Christoffer Dall @ 2017-10-21 15:04 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Oct 20, 2017 at 12:34:15PM +0100, Julien Thierry wrote:
> [Resending for Christoffer and adding kvmarm to recipients]
> 
> Hi,
> 
> When enabling branch profiling, a lockup occurs at boot time, after
> displaying: "kvm [1]: Hyp mode initialized successfully"
> 
> The issue is caused by the Hyp code getting instrumented and trying to
> access unmapped code or data, which happens when trying to initialize EL2.
> 
> So it also seems like KVM is misleadingly announcing it was initialized and
> yet gets stuck during initialization.
> 
> * First patch deals with printing the initialization message once KVM has
>   fully initialized Hyp mode
> * Second patch actually disables branch profiling instrumentation in Hyp
>   code

Applied, thanks.

-Christoffer

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

end of thread, other threads:[~2017-10-21 15:04 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-20 11:34 [RESEND PATCH 0/2] arm/arm64: kvm: Disable branch profiling in HYP code Julien Thierry
2017-10-20 11:34 ` Julien Thierry
2017-10-20 11:34 ` [RESEND PATCH 1/2] arm/arm64: kvm: Move initialization completion message Julien Thierry
2017-10-20 11:34   ` Julien Thierry
2017-10-20 11:34 ` [RESEND PATCH 2/2] arm/arm64: kvm: Disable branch profiling in HYP code Julien Thierry
2017-10-20 11:34   ` Julien Thierry
2017-10-20 11:34   ` Julien Thierry
2017-10-21 15:04 ` [RESEND PATCH 0/2] " Christoffer Dall
2017-10-21 15:04   ` Christoffer Dall

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.