All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Alexandru Elisei <alexandru.elisei@arm.com>
Cc: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2] KVM: arm64: Initialize VCPU mdcr_el2 before loading it
Date: Wed, 31 Mar 2021 16:35:21 +0100	[thread overview]
Message-ID: <8735wbqqti.wl-maz@kernel.org> (raw)
In-Reply-To: <d146cd29-7e0e-02d9-66fe-a6bbcf55725a@arm.com>

On Wed, 31 Mar 2021 16:25:46 +0100,
Alexandru Elisei <alexandru.elisei@arm.com> wrote:
> 
> Hi Marc,
> 
> On 3/30/21 9:07 PM, Marc Zyngier wrote:

[...]

> > I think it would be absolutely fine to make the slow path of
> > kvm_vcpu_first_run_init() run with preempt disabled. This happens so
> > rarely that that it isn't worth thinking about it.
> 
> It looks to me like it's a bit too heavy-handed to run the entire
> function kvm_vcpu_first_run_init() with preemption disabled just for
> __this_cpu_read() in kvm_arm_setup_mdcr_el2(). Not because of the
> performance cost (it's negligible, as it's called exactly once in
> the VCPU lifetime), but because it's not obvious why it is needed.
> 
> I tried this:
> 
> @@ -580,7 +580,9 @@ static int kvm_vcpu_first_run_init(struct kvm_vcpu *vcpu)
>  
>         vcpu->arch.has_run_once = true;
>  
> -       kvm_arm_vcpu_init_debug(vcpu);
> +       preempt_disable();
> +       kvm_arm_setup_mdcr_el2(vcpu);
> +       preempt_enable();
>  
>         if (likely(irqchip_in_kernel(kvm))) {
>                 /*
> 
> and it still looks a bit off to me because preemption needs to be
> disabled because of an implementation detail in
> kvm_arm_setup_mdcr_el2(), as the function operates on the VCPU
> struct and preemption can be enabled for that.
> 
> I was thinking something like this:
> 
> @@ -119,7 +119,9 @@ static void kvm_arm_setup_mdcr_el2(struct kvm_vcpu *vcpu, u32
> host_mdcr)
>   */
>  void kvm_arm_vcpu_init_debug(struct kvm_vcpu *vcpu)
>  {
> -       kvm_arm_setup_mdcr_el2(vcpu, this_cpu_read(mdcr_el2));
> +       preempt_disable();
> +       kvm_arm_setup_mdcr_el2(vcpu);
> +       preempt_enable();
>  }
>  
>  /**
> 
> What do you think?

I'm fine with it either way, so pick you favourite!

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

WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <maz@kernel.org>
To: Alexandru Elisei <alexandru.elisei@arm.com>
Cc: linux-arm-kernel@lists.infradead.org,
	kvmarm@lists.cs.columbia.edu, james.morse@arm.com,
	julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com
Subject: Re: [PATCH v2] KVM: arm64: Initialize VCPU mdcr_el2 before loading it
Date: Wed, 31 Mar 2021 16:35:21 +0100	[thread overview]
Message-ID: <8735wbqqti.wl-maz@kernel.org> (raw)
In-Reply-To: <d146cd29-7e0e-02d9-66fe-a6bbcf55725a@arm.com>

On Wed, 31 Mar 2021 16:25:46 +0100,
Alexandru Elisei <alexandru.elisei@arm.com> wrote:
> 
> Hi Marc,
> 
> On 3/30/21 9:07 PM, Marc Zyngier wrote:

[...]

> > I think it would be absolutely fine to make the slow path of
> > kvm_vcpu_first_run_init() run with preempt disabled. This happens so
> > rarely that that it isn't worth thinking about it.
> 
> It looks to me like it's a bit too heavy-handed to run the entire
> function kvm_vcpu_first_run_init() with preemption disabled just for
> __this_cpu_read() in kvm_arm_setup_mdcr_el2(). Not because of the
> performance cost (it's negligible, as it's called exactly once in
> the VCPU lifetime), but because it's not obvious why it is needed.
> 
> I tried this:
> 
> @@ -580,7 +580,9 @@ static int kvm_vcpu_first_run_init(struct kvm_vcpu *vcpu)
>  
>         vcpu->arch.has_run_once = true;
>  
> -       kvm_arm_vcpu_init_debug(vcpu);
> +       preempt_disable();
> +       kvm_arm_setup_mdcr_el2(vcpu);
> +       preempt_enable();
>  
>         if (likely(irqchip_in_kernel(kvm))) {
>                 /*
> 
> and it still looks a bit off to me because preemption needs to be
> disabled because of an implementation detail in
> kvm_arm_setup_mdcr_el2(), as the function operates on the VCPU
> struct and preemption can be enabled for that.
> 
> I was thinking something like this:
> 
> @@ -119,7 +119,9 @@ static void kvm_arm_setup_mdcr_el2(struct kvm_vcpu *vcpu, u32
> host_mdcr)
>   */
>  void kvm_arm_vcpu_init_debug(struct kvm_vcpu *vcpu)
>  {
> -       kvm_arm_setup_mdcr_el2(vcpu, this_cpu_read(mdcr_el2));
> +       preempt_disable();
> +       kvm_arm_setup_mdcr_el2(vcpu);
> +       preempt_enable();
>  }
>  
>  /**
> 
> What do you think?

I'm fine with it either way, so pick you favourite!

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

  reply	other threads:[~2021-03-31 15:35 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-23 18:00 [PATCH v2] KVM: arm64: Initialize VCPU mdcr_el2 before loading it Alexandru Elisei
2021-03-23 18:00 ` Alexandru Elisei
2021-03-30  9:55 ` Marc Zyngier
2021-03-30  9:55   ` Marc Zyngier
2021-03-30 17:13   ` Alexandru Elisei
2021-03-30 17:13     ` Alexandru Elisei
2021-03-30 17:49     ` Alexandru Elisei
2021-03-30 17:49       ` Alexandru Elisei
2021-03-30 19:57       ` Marc Zyngier
2021-03-30 19:57         ` Marc Zyngier
2021-03-31 10:48         ` Alexandru Elisei
2021-03-31 10:48           ` Alexandru Elisei
2021-04-01 13:55         ` Alexandru Elisei
2021-04-01 13:55           ` Alexandru Elisei
2021-04-01 15:22           ` Marc Zyngier
2021-04-01 15:22             ` Marc Zyngier
2021-03-30 20:07     ` Marc Zyngier
2021-03-30 20:07       ` Marc Zyngier
2021-03-31 15:25       ` Alexandru Elisei
2021-03-31 15:25         ` Alexandru Elisei
2021-03-31 15:35         ` Marc Zyngier [this message]
2021-03-31 15:35           ` Marc Zyngier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8735wbqqti.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=alexandru.elisei@arm.com \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.