diff mbox series

[v4,11/18] KVM: arm64: Stub implementation of non-protected nVHE HYP stack unwinder

Message ID 20220715061027.1612149-12-kaleshsingh@google.com (mailing list archive)
State New, archived
Headers show
Series KVM nVHE Hypervisor stack unwinder | expand

Commit Message

Kalesh Singh July 15, 2022, 6:10 a.m. UTC
Add stub implementations of non-protected nVHE stack unwinder, for
building. These are implemented later in this series.

Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
---
 arch/arm64/include/asm/stacktrace/nvhe.h | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

Comments

Marc Zyngier July 18, 2022, 7:30 a.m. UTC | #1
On Fri, 15 Jul 2022 07:10:20 +0100,
Kalesh Singh <kaleshsingh@google.com> wrote:
> 
> Add stub implementations of non-protected nVHE stack unwinder, for
> building. These are implemented later in this series.
> 
> Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
> ---
>  arch/arm64/include/asm/stacktrace/nvhe.h | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
> 
> diff --git a/arch/arm64/include/asm/stacktrace/nvhe.h b/arch/arm64/include/asm/stacktrace/nvhe.h
> index 1eac4e57f2ae..36cf7858ddd8 100644
> --- a/arch/arm64/include/asm/stacktrace/nvhe.h
> +++ b/arch/arm64/include/asm/stacktrace/nvhe.h
> @@ -8,6 +8,12 @@
>   *      the HYP memory. The stack is unwinded in EL2 and dumped to a shared
>   *      buffer where the host can read and print the stacktrace.
>   *
> + *   2) Non-protected nVHE mode - the host can directly access the
> + *      HYP stack pages and unwind the HYP stack in EL1. This saves having
> + *      to allocate shared buffers for the host to read the unwinded
> + *      stacktrace.
> + *
> + *
>   * Copyright (C) 2022 Google LLC
>   */
>  #ifndef __ASM_STACKTRACE_NVHE_H
> @@ -53,5 +59,21 @@ static int notrace unwind_next(struct unwind_state *state)
>  NOKPROBE_SYMBOL(unwind_next);
>  #endif	/* CONFIG_PROTECTED_NVHE_STACKTRACE */
>  
> +/*
> + * Non-protected nVHE HYP stack unwinder
> + */
> +#else	/* !__KVM_NVHE_HYPERVISOR__ */

I don't get this path. This either represents the VHE hypervisor or
the kernel proper. Which one is it?

> +static inline bool on_overflow_stack(unsigned long sp, unsigned long size,
> +				     struct stack_info *info)
> +{
> +	return false;
> +}
> +
> +static int notrace unwind_next(struct unwind_state *state)
> +{
> +	return 0;
> +}
> +NOKPROBE_SYMBOL(unwind_next);
> +
>  #endif	/* __KVM_NVHE_HYPERVISOR__ */
>  #endif	/* __ASM_STACKTRACE_NVHE_H */

Thanks,

	M.
Kalesh Singh July 18, 2022, 4:51 p.m. UTC | #2
On Mon, Jul 18, 2022 at 12:31 AM Marc Zyngier <maz@kernel.org> wrote:
>
> On Fri, 15 Jul 2022 07:10:20 +0100,
> Kalesh Singh <kaleshsingh@google.com> wrote:
> >
> > Add stub implementations of non-protected nVHE stack unwinder, for
> > building. These are implemented later in this series.
> >
> > Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
> > ---
> >  arch/arm64/include/asm/stacktrace/nvhe.h | 22 ++++++++++++++++++++++
> >  1 file changed, 22 insertions(+)
> >
> > diff --git a/arch/arm64/include/asm/stacktrace/nvhe.h b/arch/arm64/include/asm/stacktrace/nvhe.h
> > index 1eac4e57f2ae..36cf7858ddd8 100644
> > --- a/arch/arm64/include/asm/stacktrace/nvhe.h
> > +++ b/arch/arm64/include/asm/stacktrace/nvhe.h
> > @@ -8,6 +8,12 @@
> >   *      the HYP memory. The stack is unwinded in EL2 and dumped to a shared
> >   *      buffer where the host can read and print the stacktrace.
> >   *
> > + *   2) Non-protected nVHE mode - the host can directly access the
> > + *      HYP stack pages and unwind the HYP stack in EL1. This saves having
> > + *      to allocate shared buffers for the host to read the unwinded
> > + *      stacktrace.
> > + *
> > + *
> >   * Copyright (C) 2022 Google LLC
> >   */
> >  #ifndef __ASM_STACKTRACE_NVHE_H
> > @@ -53,5 +59,21 @@ static int notrace unwind_next(struct unwind_state *state)
> >  NOKPROBE_SYMBOL(unwind_next);
> >  #endif       /* CONFIG_PROTECTED_NVHE_STACKTRACE */
> >
> > +/*
> > + * Non-protected nVHE HYP stack unwinder
> > + */
> > +#else        /* !__KVM_NVHE_HYPERVISOR__ */
>
> I don't get this path. This either represents the VHE hypervisor or
> the kernel proper. Which one is it?

Hi Marc. This is run from kernel proper context. And it's the
unwinding for conventional nVHE (non-protected). The unwinding is done
from the host kernel in EL1.

>
> > +static inline bool on_overflow_stack(unsigned long sp, unsigned long size,
> > +                                  struct stack_info *info)
> > +{
> > +     return false;
> > +}
> > +
> > +static int notrace unwind_next(struct unwind_state *state)
> > +{
> > +     return 0;
> > +}
> > +NOKPROBE_SYMBOL(unwind_next);
> > +
> >  #endif       /* __KVM_NVHE_HYPERVISOR__ */
> >  #endif       /* __ASM_STACKTRACE_NVHE_H */
>
> Thanks,
>
>         M.
>
> --
> Without deviation from the norm, progress is not possible.
>
> --
> To unsubscribe from this group and stop receiving emails from it, send an email to kernel-team+unsubscribe@android.com.
>
Marc Zyngier July 18, 2022, 4:57 p.m. UTC | #3
On 2022-07-18 17:51, Kalesh Singh wrote:
> On Mon, Jul 18, 2022 at 12:31 AM Marc Zyngier <maz@kernel.org> wrote:
>> 
>> On Fri, 15 Jul 2022 07:10:20 +0100,
>> Kalesh Singh <kaleshsingh@google.com> wrote:
>> >
>> > Add stub implementations of non-protected nVHE stack unwinder, for
>> > building. These are implemented later in this series.
>> >
>> > Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
>> > ---
>> >  arch/arm64/include/asm/stacktrace/nvhe.h | 22 ++++++++++++++++++++++
>> >  1 file changed, 22 insertions(+)
>> >
>> > diff --git a/arch/arm64/include/asm/stacktrace/nvhe.h b/arch/arm64/include/asm/stacktrace/nvhe.h
>> > index 1eac4e57f2ae..36cf7858ddd8 100644
>> > --- a/arch/arm64/include/asm/stacktrace/nvhe.h
>> > +++ b/arch/arm64/include/asm/stacktrace/nvhe.h
>> > @@ -8,6 +8,12 @@
>> >   *      the HYP memory. The stack is unwinded in EL2 and dumped to a shared
>> >   *      buffer where the host can read and print the stacktrace.
>> >   *
>> > + *   2) Non-protected nVHE mode - the host can directly access the
>> > + *      HYP stack pages and unwind the HYP stack in EL1. This saves having
>> > + *      to allocate shared buffers for the host to read the unwinded
>> > + *      stacktrace.
>> > + *
>> > + *
>> >   * Copyright (C) 2022 Google LLC
>> >   */
>> >  #ifndef __ASM_STACKTRACE_NVHE_H
>> > @@ -53,5 +59,21 @@ static int notrace unwind_next(struct unwind_state *state)
>> >  NOKPROBE_SYMBOL(unwind_next);
>> >  #endif       /* CONFIG_PROTECTED_NVHE_STACKTRACE */
>> >
>> > +/*
>> > + * Non-protected nVHE HYP stack unwinder
>> > + */
>> > +#else        /* !__KVM_NVHE_HYPERVISOR__ */
>> 
>> I don't get this path. This either represents the VHE hypervisor or
>> the kernel proper. Which one is it?
> 
> Hi Marc. This is run from kernel proper context. And it's the
> unwinding for conventional nVHE (non-protected). The unwinding is done
> from the host kernel in EL1.

This really deserves a comment here, as the one you currently
have is a bit misleading (and you probably want to move it
below the #else).

Thanks,

         M.
diff mbox series

Patch

diff --git a/arch/arm64/include/asm/stacktrace/nvhe.h b/arch/arm64/include/asm/stacktrace/nvhe.h
index 1eac4e57f2ae..36cf7858ddd8 100644
--- a/arch/arm64/include/asm/stacktrace/nvhe.h
+++ b/arch/arm64/include/asm/stacktrace/nvhe.h
@@ -8,6 +8,12 @@ 
  *      the HYP memory. The stack is unwinded in EL2 and dumped to a shared
  *      buffer where the host can read and print the stacktrace.
  *
+ *   2) Non-protected nVHE mode - the host can directly access the
+ *      HYP stack pages and unwind the HYP stack in EL1. This saves having
+ *      to allocate shared buffers for the host to read the unwinded
+ *      stacktrace.
+ *
+ *
  * Copyright (C) 2022 Google LLC
  */
 #ifndef __ASM_STACKTRACE_NVHE_H
@@ -53,5 +59,21 @@  static int notrace unwind_next(struct unwind_state *state)
 NOKPROBE_SYMBOL(unwind_next);
 #endif	/* CONFIG_PROTECTED_NVHE_STACKTRACE */
 
+/*
+ * Non-protected nVHE HYP stack unwinder
+ */
+#else	/* !__KVM_NVHE_HYPERVISOR__ */
+static inline bool on_overflow_stack(unsigned long sp, unsigned long size,
+				     struct stack_info *info)
+{
+	return false;
+}
+
+static int notrace unwind_next(struct unwind_state *state)
+{
+	return 0;
+}
+NOKPROBE_SYMBOL(unwind_next);
+
 #endif	/* __KVM_NVHE_HYPERVISOR__ */
 #endif	/* __ASM_STACKTRACE_NVHE_H */