Re: [PATCH v2] KVM: arm64: Initialize VCPU mdcr_el2 before loading it

2021-04-01 Thread Marc Zyngier
On Thu, 01 Apr 2021 14:55:54 +0100, Alexandru Elisei wrote: [...] > Had another go at this, and as I was looking at the code, I realized that > conceptually, trapping debug registers access (MDCR_EL2.TDA) is tied to: > > - KVM_ARM64_DEBUG_DIRTY *not* being set (guest is debugging itself and

Re: [PATCH v2] KVM: arm64: Initialize VCPU mdcr_el2 before loading it

2021-04-01 Thread Alexandru Elisei
Hi Marc, On 3/30/21 8:57 PM, Marc Zyngier wrote: > On Tue, 30 Mar 2021 18:49:54 +0100, > Alexandru Elisei wrote: >> Hi Marc, >> >> On 3/30/21 6:13 PM, Alexandru Elisei wrote: >>> [..] > +} > + > /** > * kvm_arm_reset_debug_ptr - reset the debug ptr to point to the vcpu >

Re: [PATCH v2] KVM: arm64: Initialize VCPU mdcr_el2 before loading it

2021-03-31 Thread Marc Zyngier
On Wed, 31 Mar 2021 16:25:46 +0100, Alexandru Elisei 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

Re: [PATCH v2] KVM: arm64: Initialize VCPU mdcr_el2 before loading it

2021-03-31 Thread Alexandru Elisei
Hi Marc, On 3/30/21 9:07 PM, Marc Zyngier wrote: > On Tue, 30 Mar 2021 18:13:07 +0100, > Alexandru Elisei wrote: >> Hi Marc, >> >> Thanks for having a look! >> >> On 3/30/21 10:55 AM, Marc Zyngier wrote: >>> Hi Alex, >>> >>> On Tue, 23 Mar 2021 18:00:57 +, >>> Alexandru Elisei wrote:

Re: [PATCH v2] KVM: arm64: Initialize VCPU mdcr_el2 before loading it

2021-03-31 Thread Alexandru Elisei
Hi Marc, On 3/30/21 8:57 PM, Marc Zyngier wrote: > On Tue, 30 Mar 2021 18:49:54 +0100, > Alexandru Elisei wrote: >> Hi Marc, >> >> On 3/30/21 6:13 PM, Alexandru Elisei wrote: >>> [..] > +} > + > /** > * kvm_arm_reset_debug_ptr - reset the debug ptr to point to the vcpu >

Re: [PATCH v2] KVM: arm64: Initialize VCPU mdcr_el2 before loading it

2021-03-30 Thread Marc Zyngier
On Tue, 30 Mar 2021 18:13:07 +0100, Alexandru Elisei wrote: > > Hi Marc, > > Thanks for having a look! > > On 3/30/21 10:55 AM, Marc Zyngier wrote: > > Hi Alex, > > > > On Tue, 23 Mar 2021 18:00:57 +, > > Alexandru Elisei wrote: > >> When a VCPU is created, the kvm_vcpu struct is

Re: [PATCH v2] KVM: arm64: Initialize VCPU mdcr_el2 before loading it

2021-03-30 Thread Marc Zyngier
On Tue, 30 Mar 2021 18:49:54 +0100, Alexandru Elisei wrote: > > Hi Marc, > > On 3/30/21 6:13 PM, Alexandru Elisei wrote: > > [..] > >>> +} > >>> + > >>> /** > >>> * kvm_arm_reset_debug_ptr - reset the debug ptr to point to the vcpu > >>> state > >>> */ > >>> @@ -83,12 +137,7 @@ void

Re: [PATCH v2] KVM: arm64: Initialize VCPU mdcr_el2 before loading it

2021-03-30 Thread Alexandru Elisei
Hi Marc, On 3/30/21 6:13 PM, Alexandru Elisei wrote: > [..] >>> +} >>> + >>> /** >>> * kvm_arm_reset_debug_ptr - reset the debug ptr to point to the vcpu state >>> */ >>> @@ -83,12 +137,7 @@ void kvm_arm_reset_debug_ptr(struct kvm_vcpu *vcpu) >>> * @vcpu: the vcpu pointer >>> * >>> *

Re: [PATCH v2] KVM: arm64: Initialize VCPU mdcr_el2 before loading it

2021-03-30 Thread Alexandru Elisei
Hi Marc, Thanks for having a look! On 3/30/21 10:55 AM, Marc Zyngier wrote: > Hi Alex, > > On Tue, 23 Mar 2021 18:00:57 +, > Alexandru Elisei wrote: >> When a VCPU is created, the kvm_vcpu struct is initialized to zero in >> kvm_vm_ioctl_create_vcpu(). On VHE systems, the first time >>

Re: [PATCH v2] KVM: arm64: Initialize VCPU mdcr_el2 before loading it

2021-03-30 Thread Marc Zyngier
Hi Alex, On Tue, 23 Mar 2021 18:00:57 +, Alexandru Elisei wrote: > > When a VCPU is created, the kvm_vcpu struct is initialized to zero in > kvm_vm_ioctl_create_vcpu(). On VHE systems, the first time > vcpu.arch.mdcr_el2 is loaded on hardware is in vcpu_load(), before it is > set to a

[PATCH v2] KVM: arm64: Initialize VCPU mdcr_el2 before loading it

2021-03-23 Thread Alexandru Elisei
When a VCPU is created, the kvm_vcpu struct is initialized to zero in kvm_vm_ioctl_create_vcpu(). On VHE systems, the first time vcpu.arch.mdcr_el2 is loaded on hardware is in vcpu_load(), before it is set to a sensible value in kvm_arm_setup_debug() later in the run loop. The result is that KVM