diff mbox

[24/37] KVM: arm64: Prepare to handle traps on deferred EL0 sysregs

Message ID 20171012104141.26902-25-christoffer.dall@linaro.org (mailing list archive)
State New, archived
Headers show

Commit Message

Christoffer Dall Oct. 12, 2017, 10:41 a.m. UTC
We can trap access to ACTLR_EL1 which we can later defer to only
save/restore during vcpu_load and vcpu_put, so let's read the value
directly from the CPU when necessary.

Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
---
 arch/arm64/kvm/sys_regs_generic_v8.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Julien Thierry Nov. 15, 2017, 9:25 a.m. UTC | #1
On 12/10/17 11:41, Christoffer Dall wrote:
> We can trap access to ACTLR_EL1 which we can later defer to only
> save/restore during vcpu_load and vcpu_put, so let's read the value
> directly from the CPU when necessary.
> 
> Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
> ---
>   arch/arm64/kvm/sys_regs_generic_v8.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/kvm/sys_regs_generic_v8.c b/arch/arm64/kvm/sys_regs_generic_v8.c
> index 969ade1..348f227 100644
> --- a/arch/arm64/kvm/sys_regs_generic_v8.c
> +++ b/arch/arm64/kvm/sys_regs_generic_v8.c
> @@ -38,7 +38,10 @@ static bool access_actlr(struct kvm_vcpu *vcpu,
>   	if (p->is_write)
>   		return ignore_write(vcpu, p);
>   
> -	p->regval = vcpu_sys_reg(vcpu, ACTLR_EL1);
> +	if (vcpu->arch.sysregs_loaded_on_cpu)
> +		read_sysreg(actlr_el1);

Did you mean "p->regval = read_sysreg(actlr_el1);" ?

> +	else
> +		p->regval = vcpu_sys_reg(vcpu, ACTLR_EL1);
>   	return true;
>   }
>   
>
Christoffer Dall Dec. 3, 2017, 7:51 p.m. UTC | #2
On Wed, Nov 15, 2017 at 09:25:08AM +0000, Julien Thierry wrote:
> 
> 
> On 12/10/17 11:41, Christoffer Dall wrote:
> >We can trap access to ACTLR_EL1 which we can later defer to only
> >save/restore during vcpu_load and vcpu_put, so let's read the value
> >directly from the CPU when necessary.
> >
> >Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
> >---
> >  arch/arm64/kvm/sys_regs_generic_v8.c | 5 ++++-
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> >
> >diff --git a/arch/arm64/kvm/sys_regs_generic_v8.c b/arch/arm64/kvm/sys_regs_generic_v8.c
> >index 969ade1..348f227 100644
> >--- a/arch/arm64/kvm/sys_regs_generic_v8.c
> >+++ b/arch/arm64/kvm/sys_regs_generic_v8.c
> >@@ -38,7 +38,10 @@ static bool access_actlr(struct kvm_vcpu *vcpu,
> >  	if (p->is_write)
> >  		return ignore_write(vcpu, p);
> >-	p->regval = vcpu_sys_reg(vcpu, ACTLR_EL1);
> >+	if (vcpu->arch.sysregs_loaded_on_cpu)
> >+		read_sysreg(actlr_el1);
> 
> Did you mean "p->regval = read_sysreg(actlr_el1);" ?
> 
> >+	else
> >+		p->regval = vcpu_sys_reg(vcpu, ACTLR_EL1);
> >  	return true;
> >  }
> >
> 

Yes, most certainly.  Nice catch.

Thanks,
-Christoffer
diff mbox

Patch

diff --git a/arch/arm64/kvm/sys_regs_generic_v8.c b/arch/arm64/kvm/sys_regs_generic_v8.c
index 969ade1..348f227 100644
--- a/arch/arm64/kvm/sys_regs_generic_v8.c
+++ b/arch/arm64/kvm/sys_regs_generic_v8.c
@@ -38,7 +38,10 @@  static bool access_actlr(struct kvm_vcpu *vcpu,
 	if (p->is_write)
 		return ignore_write(vcpu, p);
 
-	p->regval = vcpu_sys_reg(vcpu, ACTLR_EL1);
+	if (vcpu->arch.sysregs_loaded_on_cpu)
+		read_sysreg(actlr_el1);
+	else
+		p->regval = vcpu_sys_reg(vcpu, ACTLR_EL1);
 	return true;
 }