lkml.org 
[lkml]   [2020]   [May]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH RFCv2 4/9] kvm/arm64: Detach ESR operator from vCPU struct
On Fri, May 08, 2020 at 01:29:14PM +1000, Gavin Shan wrote:
> There are a set of inline functions defined in kvm_emulate.h. Those
> functions reads ESR from vCPU fault information struct and then operate
> on it. So it's tied with vCPU fault information and vCPU struct. It
> limits their usage scope.
>
> This detaches these functions from the vCPU struct. With this, the
> caller has flexibility on where the ESR is read. It shouldn't cause
> any functional changes.
>
> Signed-off-by: Gavin Shan <gshan@redhat.com>
> ---
> arch/arm64/include/asm/kvm_emulate.h | 83 +++++++++++-------------
> arch/arm64/kvm/handle_exit.c | 20 ++++--
> arch/arm64/kvm/hyp/switch.c | 24 ++++---
> arch/arm64/kvm/hyp/vgic-v2-cpuif-proxy.c | 7 +-
> arch/arm64/kvm/inject_fault.c | 4 +-
> arch/arm64/kvm/sys_regs.c | 12 ++--
> virt/kvm/arm/arm.c | 4 +-
> virt/kvm/arm/hyp/aarch32.c | 2 +-
> virt/kvm/arm/hyp/vgic-v3-sr.c | 5 +-
> virt/kvm/arm/mmio.c | 27 ++++----
> virt/kvm/arm/mmu.c | 22 ++++---
> 11 files changed, 112 insertions(+), 98 deletions(-)
>
> diff --git a/arch/arm64/include/asm/kvm_emulate.h b/arch/arm64/include/asm/kvm_emulate.h
> index bd1a69e7c104..2873bf6dc85e 100644
> --- a/arch/arm64/include/asm/kvm_emulate.h
> +++ b/arch/arm64/include/asm/kvm_emulate.h
> @@ -270,10 +270,8 @@ static __always_inline u32 kvm_vcpu_get_esr(const struct kvm_vcpu *vcpu)
> return vcpu->arch.fault.esr_el2;
> }
>
> -static __always_inline int kvm_vcpu_get_condition(const struct kvm_vcpu *vcpu)
> +static __always_inline int kvm_vcpu_get_condition(u32 esr)

Given the `vcpu` argument has been removed, it's odd to keep `vcpu` in the
name, rather than `esr`.

e.g. this would make more sense as something like esr_get_condition().

... and if we did something like that, we could move most of the
extraction functions into <asm/esr.h>, and share them with non-KVM code.

Otherwise, do you need to extract all of these for your use-case, or do
you only need a few of the helpers? If you only need a few, it might be
better to only factor those out for now, and keep the existing API in
place with wrappers, e.g. have:

| esr_get_condition(u32 esr) {
| ...
| }
|
| kvm_vcpu_get_condition(const struct kvm_vcpu *vcpu)
| {
| return esr_get_condition(kvm_vcpu_get_esr(vcpu));
| }

Thanks,
Mark.

\
 
 \ /
  Last update: 2020-05-26 12:52    [W:0.205 / U:2.492 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site