[PATCH v6 0/8] LoongArch: KVM: Enhancement with eiointc emulation

Bibo Mao posted 8 patches 3 months ago
arch/loongarch/include/asm/kvm_host.h |  12 +-
arch/loongarch/kvm/intc/eiointc.c     | 558 ++++----------------------
arch/loongarch/kvm/intc/ipi.c         |  28 +-
arch/loongarch/kvm/intc/pch_pic.c     |   4 +-
arch/loongarch/kvm/vcpu.c             |   8 +-
5 files changed, 102 insertions(+), 508 deletions(-)
[PATCH v6 0/8] LoongArch: KVM: Enhancement with eiointc emulation
Posted by Bibo Mao 3 months ago
This series add generic eiointc 8 bytes access interface, so that 1/2/4/8
bytes access can use the generic 8 bytes access interface. It reduce
about 500 lines redundant code and make eiointc emulation driver
simpler than ever.

---
v5 ... v6:
  1. Merge previous patch 5 & 6 into one, patch 7 & 10 into into one and
     patch 12 and patch 13 into one.
  2. Use sign extension with destination register for IOCSRRD.{B/H/W}
     kernel emulation.

v4 ... v5
  1. Rebase patch on latest kernel where bugfix of eiointc has been
     merged.
  2. Add generic eiointc 8 bytes access interface, 1/2/4/8 bytes access
     uses generic 8 bytes access interface.

v3 ... v4:
  1. Remove patch about enhancement and only keep bugfix relative
     patches.
  2. Remove INTC indication in the patch title.
  3. With access size, keep default case unchanged besides 1/2/4/8 since
     here all patches are bugfix
  4. Firstly check return value of copy_from_user() with error path,
     keep the same order with old patch in patch 4.

v2 ... v3:
  1. Add prefix INTC: in title of every patch.
  2. Fix array index overflow when emulate register EIOINTC_ENABLE
     writing operation.
  3. Add address alignment check with eiointc register access operation.

v1 ... v2:
  1. Add extra fix in patch 3 and patch 4, add num_cpu validation check
  2. Name of stat information keeps unchanged, only move it from VM stat
     to vCPU stat.
---
Bibo Mao (8):
  LoongArch: KVM: Use standard bitops API with eiointc
  LoongArch: KVM: Remove unused parameter len
  LoongArch: KVM: Add stat information with kernel irqchip
  LoongArch: KVM: Remove never called default case statement
  LoongArch: KVM: Use generic function loongarch_eiointc_read()
  LoongArch: KVM: Remove some unnecessary local variables
  LoongArch: KVM: Replace eiointc_enable_irq() with eiointc_update_irq()
  LoongArch: KVM: Add generic function loongarch_eiointc_write()

 arch/loongarch/include/asm/kvm_host.h |  12 +-
 arch/loongarch/kvm/intc/eiointc.c     | 558 ++++----------------------
 arch/loongarch/kvm/intc/ipi.c         |  28 +-
 arch/loongarch/kvm/intc/pch_pic.c     |   4 +-
 arch/loongarch/kvm/vcpu.c             |   8 +-
 5 files changed, 102 insertions(+), 508 deletions(-)


base-commit: 733923397fd95405a48f165c9b1fbc8c4b0a4681
-- 
2.39.3
Re: [PATCH v6 0/8] LoongArch: KVM: Enhancement with eiointc emulation
Posted by Huacai Chen 2 months, 3 weeks ago
Applied with some modifications. E.g., Patch6 removes offset, and
Patch8 adds it back, so I combine these two.

Since the code is a little different, it is better to test it again [1].

[1] https://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson.git/log/?h=loongarch-kvm



Huacai

On Wed, Jul 9, 2025 at 4:02 PM Bibo Mao <maobibo@loongson.cn> wrote:
>
> This series add generic eiointc 8 bytes access interface, so that 1/2/4/8
> bytes access can use the generic 8 bytes access interface. It reduce
> about 500 lines redundant code and make eiointc emulation driver
> simpler than ever.
>
> ---
> v5 ... v6:
>   1. Merge previous patch 5 & 6 into one, patch 7 & 10 into into one and
>      patch 12 and patch 13 into one.
>   2. Use sign extension with destination register for IOCSRRD.{B/H/W}
>      kernel emulation.
>
> v4 ... v5
>   1. Rebase patch on latest kernel where bugfix of eiointc has been
>      merged.
>   2. Add generic eiointc 8 bytes access interface, 1/2/4/8 bytes access
>      uses generic 8 bytes access interface.
>
> v3 ... v4:
>   1. Remove patch about enhancement and only keep bugfix relative
>      patches.
>   2. Remove INTC indication in the patch title.
>   3. With access size, keep default case unchanged besides 1/2/4/8 since
>      here all patches are bugfix
>   4. Firstly check return value of copy_from_user() with error path,
>      keep the same order with old patch in patch 4.
>
> v2 ... v3:
>   1. Add prefix INTC: in title of every patch.
>   2. Fix array index overflow when emulate register EIOINTC_ENABLE
>      writing operation.
>   3. Add address alignment check with eiointc register access operation.
>
> v1 ... v2:
>   1. Add extra fix in patch 3 and patch 4, add num_cpu validation check
>   2. Name of stat information keeps unchanged, only move it from VM stat
>      to vCPU stat.
> ---
> Bibo Mao (8):
>   LoongArch: KVM: Use standard bitops API with eiointc
>   LoongArch: KVM: Remove unused parameter len
>   LoongArch: KVM: Add stat information with kernel irqchip
>   LoongArch: KVM: Remove never called default case statement
>   LoongArch: KVM: Use generic function loongarch_eiointc_read()
>   LoongArch: KVM: Remove some unnecessary local variables
>   LoongArch: KVM: Replace eiointc_enable_irq() with eiointc_update_irq()
>   LoongArch: KVM: Add generic function loongarch_eiointc_write()
>
>  arch/loongarch/include/asm/kvm_host.h |  12 +-
>  arch/loongarch/kvm/intc/eiointc.c     | 558 ++++----------------------
>  arch/loongarch/kvm/intc/ipi.c         |  28 +-
>  arch/loongarch/kvm/intc/pch_pic.c     |   4 +-
>  arch/loongarch/kvm/vcpu.c             |   8 +-
>  5 files changed, 102 insertions(+), 508 deletions(-)
>
>
> base-commit: 733923397fd95405a48f165c9b1fbc8c4b0a4681
> --
> 2.39.3
>
Re: [PATCH v6 0/8] LoongArch: KVM: Enhancement with eiointc emulation
Posted by Bibo Mao 2 months, 3 weeks ago

On 2025/7/16 下午6:19, Huacai Chen wrote:
> Applied with some modifications. E.g., Patch6 removes offset, and
> Patch8 adds it back, so I combine these two.
> 
> Since the code is a little different, it is better to test it again [1].
> 
> [1] https://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson.git/log/?h=loongarch-kvm
It works well with basic VM operations.
Also looks good from code review side.

Regards
Bibo Mao
> 
> 
> 
> Huacai
> 
> On Wed, Jul 9, 2025 at 4:02 PM Bibo Mao <maobibo@loongson.cn> wrote:
>>
>> This series add generic eiointc 8 bytes access interface, so that 1/2/4/8
>> bytes access can use the generic 8 bytes access interface. It reduce
>> about 500 lines redundant code and make eiointc emulation driver
>> simpler than ever.
>>
>> ---
>> v5 ... v6:
>>    1. Merge previous patch 5 & 6 into one, patch 7 & 10 into into one and
>>       patch 12 and patch 13 into one.
>>    2. Use sign extension with destination register for IOCSRRD.{B/H/W}
>>       kernel emulation.
>>
>> v4 ... v5
>>    1. Rebase patch on latest kernel where bugfix of eiointc has been
>>       merged.
>>    2. Add generic eiointc 8 bytes access interface, 1/2/4/8 bytes access
>>       uses generic 8 bytes access interface.
>>
>> v3 ... v4:
>>    1. Remove patch about enhancement and only keep bugfix relative
>>       patches.
>>    2. Remove INTC indication in the patch title.
>>    3. With access size, keep default case unchanged besides 1/2/4/8 since
>>       here all patches are bugfix
>>    4. Firstly check return value of copy_from_user() with error path,
>>       keep the same order with old patch in patch 4.
>>
>> v2 ... v3:
>>    1. Add prefix INTC: in title of every patch.
>>    2. Fix array index overflow when emulate register EIOINTC_ENABLE
>>       writing operation.
>>    3. Add address alignment check with eiointc register access operation.
>>
>> v1 ... v2:
>>    1. Add extra fix in patch 3 and patch 4, add num_cpu validation check
>>    2. Name of stat information keeps unchanged, only move it from VM stat
>>       to vCPU stat.
>> ---
>> Bibo Mao (8):
>>    LoongArch: KVM: Use standard bitops API with eiointc
>>    LoongArch: KVM: Remove unused parameter len
>>    LoongArch: KVM: Add stat information with kernel irqchip
>>    LoongArch: KVM: Remove never called default case statement
>>    LoongArch: KVM: Use generic function loongarch_eiointc_read()
>>    LoongArch: KVM: Remove some unnecessary local variables
>>    LoongArch: KVM: Replace eiointc_enable_irq() with eiointc_update_irq()
>>    LoongArch: KVM: Add generic function loongarch_eiointc_write()
>>
>>   arch/loongarch/include/asm/kvm_host.h |  12 +-
>>   arch/loongarch/kvm/intc/eiointc.c     | 558 ++++----------------------
>>   arch/loongarch/kvm/intc/ipi.c         |  28 +-
>>   arch/loongarch/kvm/intc/pch_pic.c     |   4 +-
>>   arch/loongarch/kvm/vcpu.c             |   8 +-
>>   5 files changed, 102 insertions(+), 508 deletions(-)
>>
>>
>> base-commit: 733923397fd95405a48f165c9b1fbc8c4b0a4681
>> --
>> 2.39.3
>>