diff mbox series

[5/5] MAINTAINERS: Update KVM/MIPS maintainers

Message ID 1596005919-29365-5-git-send-email-chenhc@lemote.com (mailing list archive)
State New, archived
Headers show
Series [1/5] PCI: Move PCI_VENDOR_ID_REDHAT definition to pci_ids.h | expand

Commit Message

Huacai Chen July 29, 2020, 6:58 a.m. UTC
James Hogan has become inactive for a long time and leaves KVM for MIPS
orphan. I'm working on KVM/Loongson and attempt to make it upstream both
in kernel and QEMU, while Aleksandar Markovic is already a maintainer of
QEMU/MIPS. We are both interested in QEMU/KVM/MIPS, and we have already
made some contributions in kernel and QEMU. If possible, we want to take
the KVM/MIPS maintainership.

Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Reviewed-by: Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>
Signed-off-by: Huacai Chen <chenhc@lemote.com>
---
 MAINTAINERS | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Yu Zhao June 16, 2023, 7:18 a.m. UTC | #1
On Tue, Jul 28, 2020 at 23:58:20PM -0700, Huacai Chen wrote:
> James Hogan has become inactive for a long time and leaves KVM for MIPS
> orphan. I'm working on KVM/Loongson and attempt to make it upstream both
> in kernel and QEMU, while Aleksandar Markovic is already a maintainer of
> QEMU/MIPS. We are both interested in QEMU/KVM/MIPS, and we have already
> made some contributions in kernel and QEMU. If possible, we want to take
> the KVM/MIPS maintainership.
>
> Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> Reviewed-by: Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>
> Signed-off-by: Huacai Chen <chenhc@lemote.com>
> ---
>  MAINTAINERS | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index bddc79a..5f9c2fd 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -9441,9 +9441,11 @@ F:	arch/arm64/kvm/
>  F:	include/kvm/arm_*
>
>  KERNEL VIRTUAL MACHINE FOR MIPS (KVM/mips)
> +M:	Huacai Chen <chenhc@lemote.com>
> +M:	Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>
>  L:	linux-mips@vger.kernel.org
>  L:	kvm@vger.kernel.org
> -S:	Orphan
> +S:	Maintained
>  F:	arch/mips/include/asm/kvm*
>  F:	arch/mips/include/uapi/asm/kvm*
>  F:	arch/mips/kvm/

Hi,

Is kvm/mips still maintained? Thanks.

I tried v6.4-rc6 and hit the following crash. It seems it has been broken since

  commit 45c7e8af4a5e3f0bea4ac209eea34118dd57ac64
  Author: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
  Date:   Mon Mar 1 16:29:57 2021 +0100
  
      MIPS: Remove KVM_TE support
      
      After removal of the guest part of KVM TE (trap and emulate), also remove
      the host part.

which deletes kvm_mips_commpage_init() and leaves vcpu->arch.cop0 NULL.

(Or probably I've missed something.)

  $ sudo qemu-system-mips64el -M accel=kvm -nographic
  CPU 2 Unable to handle kernel paging request at virtual address 0000000000000300, epc == ffffffff81148288, ra == ffffffff81148228
  Oops[#1]:
  CPU: 2 PID: 339 Comm: qemu-system-mip Not tainted 6.4.0-rc6-00049-g62d8779610bb #3
  $ 0   : 0000000000000000 0000000034109ce1 0000000000400004 ffffffff81b50200
  $ 4   : 8000000001d71c00 0000000000000001 0000000000000000 0000000000000000
  $ 8   : 000000a64082989c 000000000000001f 000000000000000a 0000000000000060
  $12   : ffffffff81935390 eb0ffdb582d1ed00 0000000000000001 0000000000000000
  $16   : 0000000000000000 8000000005193330 8000000005193330 80000000058b6000
  $20   : 80000000058b4a00 ffffffff81b5f110 0000000000000000 ffffffffffffffff
  $24   : 0000000000000001 ffffffff811331a0
  $28   : 80000000021e8000 80000000021ebc90 000000fff1369160 ffffffff81148228
  Hi    : 0000000000000000
  Lo    : 00000000083e6217
  epc   : ffffffff81148288 kvm_vz_vcpu_setup+0xa8/0x2d8
  ra    : ffffffff81148228 kvm_vz_vcpu_setup+0x48/0x2d8
  Status: 34109ce3	KX SX UX KERNEL EXL IE
  Cause : 0080000c (ExcCode 03)
  BadVA : 0000000000000300
  PrId  : 000d9602 (Cavium Octeon III)
  Modules linked in:
  Process qemu-system-mip (pid: 339, threadinfo=0000000029889cef, task=0000000070662173, tls=000000fff1371140)
  Stack : 8000000005193330 80000000058b4a00 80000000058b4000 ffffffff81142184
          80000000021ebcd8 eb0ffdb582d1ed00 ffffffff81b50000 ffffffff81b50000
          800000000537e000 0000000000000000 800000000537e920 8000000005193330
          ffffffff81c10000 ffffffff8113fd94 0000000000000cc0 000000000ffdc000
          000000ffdc000000 000000ffdc000010 0000000000000255 8000000003416700
          8000000005923ff8 0000000000000000 0000000000000000 0000000000000000
          8000000004775000 800000004d91dd68 0000000000000000 eb0ffdb582d1ed00
          0000000000000801 0000000000000255 ffffffff81b526a8 0000000000000001
          0000000000000001 ffffffff812c4b84 8000000002238180 0000000000000255
          0000000000000000 eb0ffdb582d1ed00 000000ffdc000010 8000000003717200
          ...
  Call Trace:
  [<ffffffff81148288>] kvm_vz_vcpu_setup+0xa8/0x2d8
  [<ffffffff81142184>] kvm_arch_vcpu_create+0x12c/0x1c0
  [<ffffffff8113fd94>] kvm_vm_ioctl+0x5e4/0xda0
  [<ffffffff812ef070>] sys_ioctl+0xb8/0x100
  [<ffffffff81125930>] syscall_common+0x34/0x58
  
  Code: 3c040040  24840004  00441025 <fe020300> 40626001  3c04ff80  00441024  3c048000  7c42f803
  
  ---[ end trace 0000000000000000 ]---
Huacai Chen June 16, 2023, 7:55 a.m. UTC | #2
Hi, Zhao,

On Fri, Jun 16, 2023 at 3:18 PM Yu Zhao <yuzhao@google.com> wrote:
>
> On Tue, Jul 28, 2020 at 23:58:20PM -0700, Huacai Chen wrote:
> > James Hogan has become inactive for a long time and leaves KVM for MIPS
> > orphan. I'm working on KVM/Loongson and attempt to make it upstream both
> > in kernel and QEMU, while Aleksandar Markovic is already a maintainer of
> > QEMU/MIPS. We are both interested in QEMU/KVM/MIPS, and we have already
> > made some contributions in kernel and QEMU. If possible, we want to take
> > the KVM/MIPS maintainership.
> >
> > Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> > Reviewed-by: Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>
> > Signed-off-by: Huacai Chen <chenhc@lemote.com>
> > ---
> >  MAINTAINERS | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index bddc79a..5f9c2fd 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -9441,9 +9441,11 @@ F:     arch/arm64/kvm/
> >  F:   include/kvm/arm_*
> >
> >  KERNEL VIRTUAL MACHINE FOR MIPS (KVM/mips)
> > +M:   Huacai Chen <chenhc@lemote.com>
> > +M:   Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>
> >  L:   linux-mips@vger.kernel.org
> >  L:   kvm@vger.kernel.org
> > -S:   Orphan
> > +S:   Maintained
> >  F:   arch/mips/include/asm/kvm*
> >  F:   arch/mips/include/uapi/asm/kvm*
> >  F:   arch/mips/kvm/
>
> Hi,
>
> Is kvm/mips still maintained? Thanks.
>
> I tried v6.4-rc6 and hit the following crash. It seems it has been broken since
>
>   commit 45c7e8af4a5e3f0bea4ac209eea34118dd57ac64
>   Author: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
>   Date:   Mon Mar 1 16:29:57 2021 +0100
>
>       MIPS: Remove KVM_TE support
>
>       After removal of the guest part of KVM TE (trap and emulate), also remove
>       the host part.
>
> which deletes kvm_mips_commpage_init() and leaves vcpu->arch.cop0 NULL.
I think your analysis is correct, are you interested in fixing it?

Huacai

>
> (Or probably I've missed something.)
>
>   $ sudo qemu-system-mips64el -M accel=kvm -nographic
>   CPU 2 Unable to handle kernel paging request at virtual address 0000000000000300, epc == ffffffff81148288, ra == ffffffff81148228
>   Oops[#1]:
>   CPU: 2 PID: 339 Comm: qemu-system-mip Not tainted 6.4.0-rc6-00049-g62d8779610bb #3
>   $ 0   : 0000000000000000 0000000034109ce1 0000000000400004 ffffffff81b50200
>   $ 4   : 8000000001d71c00 0000000000000001 0000000000000000 0000000000000000
>   $ 8   : 000000a64082989c 000000000000001f 000000000000000a 0000000000000060
>   $12   : ffffffff81935390 eb0ffdb582d1ed00 0000000000000001 0000000000000000
>   $16   : 0000000000000000 8000000005193330 8000000005193330 80000000058b6000
>   $20   : 80000000058b4a00 ffffffff81b5f110 0000000000000000 ffffffffffffffff
>   $24   : 0000000000000001 ffffffff811331a0
>   $28   : 80000000021e8000 80000000021ebc90 000000fff1369160 ffffffff81148228
>   Hi    : 0000000000000000
>   Lo    : 00000000083e6217
>   epc   : ffffffff81148288 kvm_vz_vcpu_setup+0xa8/0x2d8
>   ra    : ffffffff81148228 kvm_vz_vcpu_setup+0x48/0x2d8
>   Status: 34109ce3      KX SX UX KERNEL EXL IE
>   Cause : 0080000c (ExcCode 03)
>   BadVA : 0000000000000300
>   PrId  : 000d9602 (Cavium Octeon III)
>   Modules linked in:
>   Process qemu-system-mip (pid: 339, threadinfo=0000000029889cef, task=0000000070662173, tls=000000fff1371140)
>   Stack : 8000000005193330 80000000058b4a00 80000000058b4000 ffffffff81142184
>           80000000021ebcd8 eb0ffdb582d1ed00 ffffffff81b50000 ffffffff81b50000
>           800000000537e000 0000000000000000 800000000537e920 8000000005193330
>           ffffffff81c10000 ffffffff8113fd94 0000000000000cc0 000000000ffdc000
>           000000ffdc000000 000000ffdc000010 0000000000000255 8000000003416700
>           8000000005923ff8 0000000000000000 0000000000000000 0000000000000000
>           8000000004775000 800000004d91dd68 0000000000000000 eb0ffdb582d1ed00
>           0000000000000801 0000000000000255 ffffffff81b526a8 0000000000000001
>           0000000000000001 ffffffff812c4b84 8000000002238180 0000000000000255
>           0000000000000000 eb0ffdb582d1ed00 000000ffdc000010 8000000003717200
>           ...
>   Call Trace:
>   [<ffffffff81148288>] kvm_vz_vcpu_setup+0xa8/0x2d8
>   [<ffffffff81142184>] kvm_arch_vcpu_create+0x12c/0x1c0
>   [<ffffffff8113fd94>] kvm_vm_ioctl+0x5e4/0xda0
>   [<ffffffff812ef070>] sys_ioctl+0xb8/0x100
>   [<ffffffff81125930>] syscall_common+0x34/0x58
>
>   Code: 3c040040  24840004  00441025 <fe020300> 40626001  3c04ff80  00441024  3c048000  7c42f803
>
>   ---[ end trace 0000000000000000 ]---
Thomas Bogendoerfer June 16, 2023, 8:23 a.m. UTC | #3
On Fri, Jun 16, 2023 at 01:18:31AM -0600, Yu Zhao wrote:
> On Tue, Jul 28, 2020 at 23:58:20PM -0700, Huacai Chen wrote:
> > James Hogan has become inactive for a long time and leaves KVM for MIPS
> > orphan. I'm working on KVM/Loongson and attempt to make it upstream both
> > in kernel and QEMU, while Aleksandar Markovic is already a maintainer of
> > QEMU/MIPS. We are both interested in QEMU/KVM/MIPS, and we have already
> > made some contributions in kernel and QEMU. If possible, we want to take
> > the KVM/MIPS maintainership.
> >
> > Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> > Reviewed-by: Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>
> > Signed-off-by: Huacai Chen <chenhc@lemote.com>
> > ---
> >  MAINTAINERS | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index bddc79a..5f9c2fd 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -9441,9 +9441,11 @@ F:	arch/arm64/kvm/
> >  F:	include/kvm/arm_*
> >
> >  KERNEL VIRTUAL MACHINE FOR MIPS (KVM/mips)
> > +M:	Huacai Chen <chenhc@lemote.com>
> > +M:	Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>
> >  L:	linux-mips@vger.kernel.org
> >  L:	kvm@vger.kernel.org
> > -S:	Orphan
> > +S:	Maintained
> >  F:	arch/mips/include/asm/kvm*
> >  F:	arch/mips/include/uapi/asm/kvm*
> >  F:	arch/mips/kvm/
> 
> Hi,
> 
> Is kvm/mips still maintained? Thanks.
> 
> I tried v6.4-rc6 and hit the following crash. It seems it has been broken since
> 
>   commit 45c7e8af4a5e3f0bea4ac209eea34118dd57ac64
>   Author: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
>   Date:   Mon Mar 1 16:29:57 2021 +0100
>   
>       MIPS: Remove KVM_TE support

ok, I see what I missed when removing TE support, d'oh. Does the patch
below fix the issue for you ?

Thomas.

diff --git a/arch/mips/include/asm/kvm_host.h b/arch/mips/include/asm/kvm_host.h
index 957121a495f0..04cedf9f8811 100644
--- a/arch/mips/include/asm/kvm_host.h
+++ b/arch/mips/include/asm/kvm_host.h
@@ -317,7 +317,7 @@ struct kvm_vcpu_arch {
 	unsigned int aux_inuse;
 
 	/* COP0 State */
-	struct mips_coproc *cop0;
+	struct mips_coproc cop0;
 
 	/* Resume PC after MMIO completion */
 	unsigned long io_pc;
@@ -698,7 +698,7 @@ static inline bool kvm_mips_guest_can_have_fpu(struct kvm_vcpu_arch *vcpu)
 static inline bool kvm_mips_guest_has_fpu(struct kvm_vcpu_arch *vcpu)
 {
 	return kvm_mips_guest_can_have_fpu(vcpu) &&
-		kvm_read_c0_guest_config1(vcpu->cop0) & MIPS_CONF1_FP;
+		kvm_read_c0_guest_config1(&vcpu->cop0) & MIPS_CONF1_FP;
 }
 
 static inline bool kvm_mips_guest_can_have_msa(struct kvm_vcpu_arch *vcpu)
@@ -710,7 +710,7 @@ static inline bool kvm_mips_guest_can_have_msa(struct kvm_vcpu_arch *vcpu)
 static inline bool kvm_mips_guest_has_msa(struct kvm_vcpu_arch *vcpu)
 {
 	return kvm_mips_guest_can_have_msa(vcpu) &&
-		kvm_read_c0_guest_config3(vcpu->cop0) & MIPS_CONF3_MSA;
+		kvm_read_c0_guest_config3(&vcpu->cop0) & MIPS_CONF3_MSA;
 }
 
 struct kvm_mips_callbacks {
diff --git a/arch/mips/kvm/emulate.c b/arch/mips/kvm/emulate.c
index edaec93a1a1f..e64372b8f66a 100644
--- a/arch/mips/kvm/emulate.c
+++ b/arch/mips/kvm/emulate.c
@@ -312,7 +312,7 @@ int kvm_get_badinstrp(u32 *opc, struct kvm_vcpu *vcpu, u32 *out)
  */
 int kvm_mips_count_disabled(struct kvm_vcpu *vcpu)
 {
-	struct mips_coproc *cop0 = vcpu->arch.cop0;
+	struct mips_coproc *cop0 = &vcpu->arch.cop0;
 
 	return	(vcpu->arch.count_ctl & KVM_REG_MIPS_COUNT_CTL_DC) ||
 		(kvm_read_c0_guest_cause(cop0) & CAUSEF_DC);
@@ -384,7 +384,7 @@ static inline ktime_t kvm_mips_count_time(struct kvm_vcpu *vcpu)
  */
 static u32 kvm_mips_read_count_running(struct kvm_vcpu *vcpu, ktime_t now)
 {
-	struct mips_coproc *cop0 = vcpu->arch.cop0;
+	struct mips_coproc *cop0 = &vcpu->arch.cop0;
 	ktime_t expires, threshold;
 	u32 count, compare;
 	int running;
@@ -444,7 +444,7 @@ static u32 kvm_mips_read_count_running(struct kvm_vcpu *vcpu, ktime_t now)
  */
 u32 kvm_mips_read_count(struct kvm_vcpu *vcpu)
 {
-	struct mips_coproc *cop0 = vcpu->arch.cop0;
+	struct mips_coproc *cop0 = &vcpu->arch.cop0;
 
 	/* If count disabled just read static copy of count */
 	if (kvm_mips_count_disabled(vcpu))
@@ -502,7 +502,7 @@ ktime_t kvm_mips_freeze_hrtimer(struct kvm_vcpu *vcpu, u32 *count)
 static void kvm_mips_resume_hrtimer(struct kvm_vcpu *vcpu,
 				    ktime_t now, u32 count)
 {
-	struct mips_coproc *cop0 = vcpu->arch.cop0;
+	struct mips_coproc *cop0 = &vcpu->arch.cop0;
 	u32 compare;
 	u64 delta;
 	ktime_t expire;
@@ -603,7 +603,7 @@ int kvm_mips_restore_hrtimer(struct kvm_vcpu *vcpu, ktime_t before,
  */
 void kvm_mips_write_count(struct kvm_vcpu *vcpu, u32 count)
 {
-	struct mips_coproc *cop0 = vcpu->arch.cop0;
+	struct mips_coproc *cop0 = &vcpu->arch.cop0;
 	ktime_t now;
 
 	/* Calculate bias */
@@ -649,7 +649,7 @@ void kvm_mips_init_count(struct kvm_vcpu *vcpu, unsigned long count_hz)
  */
 int kvm_mips_set_count_hz(struct kvm_vcpu *vcpu, s64 count_hz)
 {
-	struct mips_coproc *cop0 = vcpu->arch.cop0;
+	struct mips_coproc *cop0 = &vcpu->arch.cop0;
 	int dc;
 	ktime_t now;
 	u32 count;
@@ -696,7 +696,7 @@ int kvm_mips_set_count_hz(struct kvm_vcpu *vcpu, s64 count_hz)
  */
 void kvm_mips_write_compare(struct kvm_vcpu *vcpu, u32 compare, bool ack)
 {
-	struct mips_coproc *cop0 = vcpu->arch.cop0;
+	struct mips_coproc *cop0 = &vcpu->arch.cop0;
 	int dc;
 	u32 old_compare = kvm_read_c0_guest_compare(cop0);
 	s32 delta = compare - old_compare;
@@ -779,7 +779,7 @@ void kvm_mips_write_compare(struct kvm_vcpu *vcpu, u32 compare, bool ack)
  */
 static ktime_t kvm_mips_count_disable(struct kvm_vcpu *vcpu)
 {
-	struct mips_coproc *cop0 = vcpu->arch.cop0;
+	struct mips_coproc *cop0 = &vcpu->arch.cop0;
 	u32 count;
 	ktime_t now;
 
@@ -806,7 +806,7 @@ static ktime_t kvm_mips_count_disable(struct kvm_vcpu *vcpu)
  */
 void kvm_mips_count_disable_cause(struct kvm_vcpu *vcpu)
 {
-	struct mips_coproc *cop0 = vcpu->arch.cop0;
+	struct mips_coproc *cop0 = &vcpu->arch.cop0;
 
 	kvm_set_c0_guest_cause(cop0, CAUSEF_DC);
 	if (!(vcpu->arch.count_ctl & KVM_REG_MIPS_COUNT_CTL_DC))
@@ -826,7 +826,7 @@ void kvm_mips_count_disable_cause(struct kvm_vcpu *vcpu)
  */
 void kvm_mips_count_enable_cause(struct kvm_vcpu *vcpu)
 {
-	struct mips_coproc *cop0 = vcpu->arch.cop0;
+	struct mips_coproc *cop0 = &vcpu->arch.cop0;
 	u32 count;
 
 	kvm_clear_c0_guest_cause(cop0, CAUSEF_DC);
@@ -852,7 +852,7 @@ void kvm_mips_count_enable_cause(struct kvm_vcpu *vcpu)
  */
 int kvm_mips_set_count_ctl(struct kvm_vcpu *vcpu, s64 count_ctl)
 {
-	struct mips_coproc *cop0 = vcpu->arch.cop0;
+	struct mips_coproc *cop0 = &vcpu->arch.cop0;
 	s64 changed = count_ctl ^ vcpu->arch.count_ctl;
 	s64 delta;
 	ktime_t expire, now;
diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c
index 884be4ef99dc..aa5583a7b05b 100644
--- a/arch/mips/kvm/mips.c
+++ b/arch/mips/kvm/mips.c
@@ -649,7 +649,7 @@ static int kvm_mips_copy_reg_indices(struct kvm_vcpu *vcpu, u64 __user *indices)
 static int kvm_mips_get_reg(struct kvm_vcpu *vcpu,
 			    const struct kvm_one_reg *reg)
 {
-	struct mips_coproc *cop0 = vcpu->arch.cop0;
+	struct mips_coproc *cop0 = &vcpu->arch.cop0;
 	struct mips_fpu_struct *fpu = &vcpu->arch.fpu;
 	int ret;
 	s64 v;
@@ -761,7 +761,7 @@ static int kvm_mips_get_reg(struct kvm_vcpu *vcpu,
 static int kvm_mips_set_reg(struct kvm_vcpu *vcpu,
 			    const struct kvm_one_reg *reg)
 {
-	struct mips_coproc *cop0 = vcpu->arch.cop0;
+	struct mips_coproc *cop0 = &vcpu->arch.cop0;
 	struct mips_fpu_struct *fpu = &vcpu->arch.fpu;
 	s64 v;
 	s64 vs[2];
@@ -1086,7 +1086,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
 int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu)
 {
 	return kvm_mips_pending_timer(vcpu) ||
-		kvm_read_c0_guest_cause(vcpu->arch.cop0) & C_TI;
+		kvm_read_c0_guest_cause(&vcpu->arch.cop0) & C_TI;
 }
 
 int kvm_arch_vcpu_dump_regs(struct kvm_vcpu *vcpu)
@@ -1110,7 +1110,7 @@ int kvm_arch_vcpu_dump_regs(struct kvm_vcpu *vcpu)
 	kvm_debug("\thi: 0x%08lx\n", vcpu->arch.hi);
 	kvm_debug("\tlo: 0x%08lx\n", vcpu->arch.lo);
 
-	cop0 = vcpu->arch.cop0;
+	cop0 = &vcpu->arch.cop0;
 	kvm_debug("\tStatus: 0x%08x, Cause: 0x%08x\n",
 		  kvm_read_c0_guest_status(cop0),
 		  kvm_read_c0_guest_cause(cop0));
@@ -1232,7 +1232,7 @@ static int __kvm_mips_handle_exit(struct kvm_vcpu *vcpu)
 
 	case EXCCODE_TLBS:
 		kvm_debug("TLB ST fault:  cause %#x, status %#x, PC: %p, BadVaddr: %#lx\n",
-			  cause, kvm_read_c0_guest_status(vcpu->arch.cop0), opc,
+			  cause, kvm_read_c0_guest_status(&vcpu->arch.cop0), opc,
 			  badvaddr);
 
 		++vcpu->stat.tlbmiss_st_exits;
@@ -1304,7 +1304,7 @@ static int __kvm_mips_handle_exit(struct kvm_vcpu *vcpu)
 		kvm_get_badinstr(opc, vcpu, &inst);
 		kvm_err("Exception Code: %d, not yet handled, @ PC: %p, inst: 0x%08x  BadVaddr: %#lx Status: %#x\n",
 			exccode, opc, inst, badvaddr,
-			kvm_read_c0_guest_status(vcpu->arch.cop0));
+			kvm_read_c0_guest_status(&vcpu->arch.cop0));
 		kvm_arch_vcpu_dump_regs(vcpu);
 		run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
 		ret = RESUME_HOST;
@@ -1377,7 +1377,7 @@ int noinstr kvm_mips_handle_exit(struct kvm_vcpu *vcpu)
 /* Enable FPU for guest and restore context */
 void kvm_own_fpu(struct kvm_vcpu *vcpu)
 {
-	struct mips_coproc *cop0 = vcpu->arch.cop0;
+	struct mips_coproc *cop0 = &vcpu->arch.cop0;
 	unsigned int sr, cfg5;
 
 	preempt_disable();
@@ -1421,7 +1421,7 @@ void kvm_own_fpu(struct kvm_vcpu *vcpu)
 /* Enable MSA for guest and restore context */
 void kvm_own_msa(struct kvm_vcpu *vcpu)
 {
-	struct mips_coproc *cop0 = vcpu->arch.cop0;
+	struct mips_coproc *cop0 = &vcpu->arch.cop0;
 	unsigned int sr, cfg5;
 
 	preempt_disable();
diff --git a/arch/mips/kvm/vz.c b/arch/mips/kvm/vz.c
index 3d21cbfa7443..99d5a71e4300 100644
--- a/arch/mips/kvm/vz.c
+++ b/arch/mips/kvm/vz.c
@@ -422,7 +422,7 @@ static void _kvm_vz_restore_htimer(struct kvm_vcpu *vcpu,
  */
 static void kvm_vz_restore_timer(struct kvm_vcpu *vcpu)
 {
-	struct mips_coproc *cop0 = vcpu->arch.cop0;
+	struct mips_coproc *cop0 = &vcpu->arch.cop0;
 	u32 cause, compare;
 
 	compare = kvm_read_sw_gc0_compare(cop0);
@@ -517,7 +517,7 @@ static void _kvm_vz_save_htimer(struct kvm_vcpu *vcpu,
  */
 static void kvm_vz_save_timer(struct kvm_vcpu *vcpu)
 {
-	struct mips_coproc *cop0 = vcpu->arch.cop0;
+	struct mips_coproc *cop0 = &vcpu->arch.cop0;
 	u32 gctl0, compare, cause;
 
 	gctl0 = read_c0_guestctl0();
@@ -863,7 +863,7 @@ static unsigned long mips_process_maar(unsigned int op, unsigned long val)
 
 static void kvm_write_maari(struct kvm_vcpu *vcpu, unsigned long val)
 {
-	struct mips_coproc *cop0 = vcpu->arch.cop0;
+	struct mips_coproc *cop0 = &vcpu->arch.cop0;
 
 	val &= MIPS_MAARI_INDEX;
 	if (val == MIPS_MAARI_INDEX)
@@ -876,7 +876,7 @@ static enum emulation_result kvm_vz_gpsi_cop0(union mips_instruction inst,
 					      u32 *opc, u32 cause,
 					      struct kvm_vcpu *vcpu)
 {
-	struct mips_coproc *cop0 = vcpu->arch.cop0;
+	struct mips_coproc *cop0 = &vcpu->arch.cop0;
 	enum emulation_result er = EMULATE_DONE;
 	u32 rt, rd, sel;
 	unsigned long curr_pc;
@@ -1911,7 +1911,7 @@ static int kvm_vz_get_one_reg(struct kvm_vcpu *vcpu,
 			      const struct kvm_one_reg *reg,
 			      s64 *v)
 {
-	struct mips_coproc *cop0 = vcpu->arch.cop0;
+	struct mips_coproc *cop0 = &vcpu->arch.cop0;
 	unsigned int idx;
 
 	switch (reg->id) {
@@ -2081,7 +2081,7 @@ static int kvm_vz_get_one_reg(struct kvm_vcpu *vcpu,
 	case KVM_REG_MIPS_CP0_MAARI:
 		if (!cpu_guest_has_maar || cpu_guest_has_dyn_maar)
 			return -EINVAL;
-		*v = kvm_read_sw_gc0_maari(vcpu->arch.cop0);
+		*v = kvm_read_sw_gc0_maari(&vcpu->arch.cop0);
 		break;
 #ifdef CONFIG_64BIT
 	case KVM_REG_MIPS_CP0_XCONTEXT:
@@ -2135,7 +2135,7 @@ static int kvm_vz_set_one_reg(struct kvm_vcpu *vcpu,
 			      const struct kvm_one_reg *reg,
 			      s64 v)
 {
-	struct mips_coproc *cop0 = vcpu->arch.cop0;
+	struct mips_coproc *cop0 = &vcpu->arch.cop0;
 	unsigned int idx;
 	int ret = 0;
 	unsigned int cur, change;
@@ -2562,7 +2562,7 @@ static void kvm_vz_vcpu_load_tlb(struct kvm_vcpu *vcpu, int cpu)
 
 static int kvm_vz_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
 {
-	struct mips_coproc *cop0 = vcpu->arch.cop0;
+	struct mips_coproc *cop0 = &vcpu->arch.cop0;
 	bool migrated, all;
 
 	/*
@@ -2704,7 +2704,7 @@ static int kvm_vz_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
 
 static int kvm_vz_vcpu_put(struct kvm_vcpu *vcpu, int cpu)
 {
-	struct mips_coproc *cop0 = vcpu->arch.cop0;
+	struct mips_coproc *cop0 = &vcpu->arch.cop0;
 
 	if (current->flags & PF_VCPU)
 		kvm_vz_vcpu_save_wired(vcpu);
@@ -3076,7 +3076,7 @@ static void kvm_vz_vcpu_uninit(struct kvm_vcpu *vcpu)
 
 static int kvm_vz_vcpu_setup(struct kvm_vcpu *vcpu)
 {
-	struct mips_coproc *cop0 = vcpu->arch.cop0;
+	struct mips_coproc *cop0 = &vcpu->arch.cop0;
 	unsigned long count_hz = 100*1000*1000; /* default to 100 MHz */
 
 	/*
Huacai Chen June 16, 2023, 8:31 a.m. UTC | #4
On Fri, Jun 16, 2023 at 4:23 PM Thomas Bogendoerfer
<tsbogend@alpha.franken.de> wrote:
>
> On Fri, Jun 16, 2023 at 01:18:31AM -0600, Yu Zhao wrote:
> > On Tue, Jul 28, 2020 at 23:58:20PM -0700, Huacai Chen wrote:
> > > James Hogan has become inactive for a long time and leaves KVM for MIPS
> > > orphan. I'm working on KVM/Loongson and attempt to make it upstream both
> > > in kernel and QEMU, while Aleksandar Markovic is already a maintainer of
> > > QEMU/MIPS. We are both interested in QEMU/KVM/MIPS, and we have already
> > > made some contributions in kernel and QEMU. If possible, we want to take
> > > the KVM/MIPS maintainership.
> > >
> > > Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> > > Reviewed-by: Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>
> > > Signed-off-by: Huacai Chen <chenhc@lemote.com>
> > > ---
> > >  MAINTAINERS | 4 +++-
> > >  1 file changed, 3 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/MAINTAINERS b/MAINTAINERS
> > > index bddc79a..5f9c2fd 100644
> > > --- a/MAINTAINERS
> > > +++ b/MAINTAINERS
> > > @@ -9441,9 +9441,11 @@ F:   arch/arm64/kvm/
> > >  F: include/kvm/arm_*
> > >
> > >  KERNEL VIRTUAL MACHINE FOR MIPS (KVM/mips)
> > > +M: Huacai Chen <chenhc@lemote.com>
> > > +M: Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>
> > >  L: linux-mips@vger.kernel.org
> > >  L: kvm@vger.kernel.org
> > > -S: Orphan
> > > +S: Maintained
> > >  F: arch/mips/include/asm/kvm*
> > >  F: arch/mips/include/uapi/asm/kvm*
> > >  F: arch/mips/kvm/
> >
> > Hi,
> >
> > Is kvm/mips still maintained? Thanks.
> >
> > I tried v6.4-rc6 and hit the following crash. It seems it has been broken since
> >
> >   commit 45c7e8af4a5e3f0bea4ac209eea34118dd57ac64
> >   Author: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
> >   Date:   Mon Mar 1 16:29:57 2021 +0100
> >
> >       MIPS: Remove KVM_TE support
>
> ok, I see what I missed when removing TE support, d'oh. Does the patch
> below fix the issue for you ?
>
> Thomas.
>
> diff --git a/arch/mips/include/asm/kvm_host.h b/arch/mips/include/asm/kvm_host.h
> index 957121a495f0..04cedf9f8811 100644
> --- a/arch/mips/include/asm/kvm_host.h
> +++ b/arch/mips/include/asm/kvm_host.h
> @@ -317,7 +317,7 @@ struct kvm_vcpu_arch {
>         unsigned int aux_inuse;
>
>         /* COP0 State */
> -       struct mips_coproc *cop0;
> +       struct mips_coproc cop0;
Maybe keeping it as a pointer and allocate in kvm_arch_vcpu_create()
is better? (smaller modification)

Huacai
>
>         /* Resume PC after MMIO completion */
>         unsigned long io_pc;
> @@ -698,7 +698,7 @@ static inline bool kvm_mips_guest_can_have_fpu(struct kvm_vcpu_arch *vcpu)
>  static inline bool kvm_mips_guest_has_fpu(struct kvm_vcpu_arch *vcpu)
>  {
>         return kvm_mips_guest_can_have_fpu(vcpu) &&
> -               kvm_read_c0_guest_config1(vcpu->cop0) & MIPS_CONF1_FP;
> +               kvm_read_c0_guest_config1(&vcpu->cop0) & MIPS_CONF1_FP;
>  }
>
>  static inline bool kvm_mips_guest_can_have_msa(struct kvm_vcpu_arch *vcpu)
> @@ -710,7 +710,7 @@ static inline bool kvm_mips_guest_can_have_msa(struct kvm_vcpu_arch *vcpu)
>  static inline bool kvm_mips_guest_has_msa(struct kvm_vcpu_arch *vcpu)
>  {
>         return kvm_mips_guest_can_have_msa(vcpu) &&
> -               kvm_read_c0_guest_config3(vcpu->cop0) & MIPS_CONF3_MSA;
> +               kvm_read_c0_guest_config3(&vcpu->cop0) & MIPS_CONF3_MSA;
>  }
>
>  struct kvm_mips_callbacks {
> diff --git a/arch/mips/kvm/emulate.c b/arch/mips/kvm/emulate.c
> index edaec93a1a1f..e64372b8f66a 100644
> --- a/arch/mips/kvm/emulate.c
> +++ b/arch/mips/kvm/emulate.c
> @@ -312,7 +312,7 @@ int kvm_get_badinstrp(u32 *opc, struct kvm_vcpu *vcpu, u32 *out)
>   */
>  int kvm_mips_count_disabled(struct kvm_vcpu *vcpu)
>  {
> -       struct mips_coproc *cop0 = vcpu->arch.cop0;
> +       struct mips_coproc *cop0 = &vcpu->arch.cop0;
>
>         return  (vcpu->arch.count_ctl & KVM_REG_MIPS_COUNT_CTL_DC) ||
>                 (kvm_read_c0_guest_cause(cop0) & CAUSEF_DC);
> @@ -384,7 +384,7 @@ static inline ktime_t kvm_mips_count_time(struct kvm_vcpu *vcpu)
>   */
>  static u32 kvm_mips_read_count_running(struct kvm_vcpu *vcpu, ktime_t now)
>  {
> -       struct mips_coproc *cop0 = vcpu->arch.cop0;
> +       struct mips_coproc *cop0 = &vcpu->arch.cop0;
>         ktime_t expires, threshold;
>         u32 count, compare;
>         int running;
> @@ -444,7 +444,7 @@ static u32 kvm_mips_read_count_running(struct kvm_vcpu *vcpu, ktime_t now)
>   */
>  u32 kvm_mips_read_count(struct kvm_vcpu *vcpu)
>  {
> -       struct mips_coproc *cop0 = vcpu->arch.cop0;
> +       struct mips_coproc *cop0 = &vcpu->arch.cop0;
>
>         /* If count disabled just read static copy of count */
>         if (kvm_mips_count_disabled(vcpu))
> @@ -502,7 +502,7 @@ ktime_t kvm_mips_freeze_hrtimer(struct kvm_vcpu *vcpu, u32 *count)
>  static void kvm_mips_resume_hrtimer(struct kvm_vcpu *vcpu,
>                                     ktime_t now, u32 count)
>  {
> -       struct mips_coproc *cop0 = vcpu->arch.cop0;
> +       struct mips_coproc *cop0 = &vcpu->arch.cop0;
>         u32 compare;
>         u64 delta;
>         ktime_t expire;
> @@ -603,7 +603,7 @@ int kvm_mips_restore_hrtimer(struct kvm_vcpu *vcpu, ktime_t before,
>   */
>  void kvm_mips_write_count(struct kvm_vcpu *vcpu, u32 count)
>  {
> -       struct mips_coproc *cop0 = vcpu->arch.cop0;
> +       struct mips_coproc *cop0 = &vcpu->arch.cop0;
>         ktime_t now;
>
>         /* Calculate bias */
> @@ -649,7 +649,7 @@ void kvm_mips_init_count(struct kvm_vcpu *vcpu, unsigned long count_hz)
>   */
>  int kvm_mips_set_count_hz(struct kvm_vcpu *vcpu, s64 count_hz)
>  {
> -       struct mips_coproc *cop0 = vcpu->arch.cop0;
> +       struct mips_coproc *cop0 = &vcpu->arch.cop0;
>         int dc;
>         ktime_t now;
>         u32 count;
> @@ -696,7 +696,7 @@ int kvm_mips_set_count_hz(struct kvm_vcpu *vcpu, s64 count_hz)
>   */
>  void kvm_mips_write_compare(struct kvm_vcpu *vcpu, u32 compare, bool ack)
>  {
> -       struct mips_coproc *cop0 = vcpu->arch.cop0;
> +       struct mips_coproc *cop0 = &vcpu->arch.cop0;
>         int dc;
>         u32 old_compare = kvm_read_c0_guest_compare(cop0);
>         s32 delta = compare - old_compare;
> @@ -779,7 +779,7 @@ void kvm_mips_write_compare(struct kvm_vcpu *vcpu, u32 compare, bool ack)
>   */
>  static ktime_t kvm_mips_count_disable(struct kvm_vcpu *vcpu)
>  {
> -       struct mips_coproc *cop0 = vcpu->arch.cop0;
> +       struct mips_coproc *cop0 = &vcpu->arch.cop0;
>         u32 count;
>         ktime_t now;
>
> @@ -806,7 +806,7 @@ static ktime_t kvm_mips_count_disable(struct kvm_vcpu *vcpu)
>   */
>  void kvm_mips_count_disable_cause(struct kvm_vcpu *vcpu)
>  {
> -       struct mips_coproc *cop0 = vcpu->arch.cop0;
> +       struct mips_coproc *cop0 = &vcpu->arch.cop0;
>
>         kvm_set_c0_guest_cause(cop0, CAUSEF_DC);
>         if (!(vcpu->arch.count_ctl & KVM_REG_MIPS_COUNT_CTL_DC))
> @@ -826,7 +826,7 @@ void kvm_mips_count_disable_cause(struct kvm_vcpu *vcpu)
>   */
>  void kvm_mips_count_enable_cause(struct kvm_vcpu *vcpu)
>  {
> -       struct mips_coproc *cop0 = vcpu->arch.cop0;
> +       struct mips_coproc *cop0 = &vcpu->arch.cop0;
>         u32 count;
>
>         kvm_clear_c0_guest_cause(cop0, CAUSEF_DC);
> @@ -852,7 +852,7 @@ void kvm_mips_count_enable_cause(struct kvm_vcpu *vcpu)
>   */
>  int kvm_mips_set_count_ctl(struct kvm_vcpu *vcpu, s64 count_ctl)
>  {
> -       struct mips_coproc *cop0 = vcpu->arch.cop0;
> +       struct mips_coproc *cop0 = &vcpu->arch.cop0;
>         s64 changed = count_ctl ^ vcpu->arch.count_ctl;
>         s64 delta;
>         ktime_t expire, now;
> diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c
> index 884be4ef99dc..aa5583a7b05b 100644
> --- a/arch/mips/kvm/mips.c
> +++ b/arch/mips/kvm/mips.c
> @@ -649,7 +649,7 @@ static int kvm_mips_copy_reg_indices(struct kvm_vcpu *vcpu, u64 __user *indices)
>  static int kvm_mips_get_reg(struct kvm_vcpu *vcpu,
>                             const struct kvm_one_reg *reg)
>  {
> -       struct mips_coproc *cop0 = vcpu->arch.cop0;
> +       struct mips_coproc *cop0 = &vcpu->arch.cop0;
>         struct mips_fpu_struct *fpu = &vcpu->arch.fpu;
>         int ret;
>         s64 v;
> @@ -761,7 +761,7 @@ static int kvm_mips_get_reg(struct kvm_vcpu *vcpu,
>  static int kvm_mips_set_reg(struct kvm_vcpu *vcpu,
>                             const struct kvm_one_reg *reg)
>  {
> -       struct mips_coproc *cop0 = vcpu->arch.cop0;
> +       struct mips_coproc *cop0 = &vcpu->arch.cop0;
>         struct mips_fpu_struct *fpu = &vcpu->arch.fpu;
>         s64 v;
>         s64 vs[2];
> @@ -1086,7 +1086,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
>  int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu)
>  {
>         return kvm_mips_pending_timer(vcpu) ||
> -               kvm_read_c0_guest_cause(vcpu->arch.cop0) & C_TI;
> +               kvm_read_c0_guest_cause(&vcpu->arch.cop0) & C_TI;
>  }
>
>  int kvm_arch_vcpu_dump_regs(struct kvm_vcpu *vcpu)
> @@ -1110,7 +1110,7 @@ int kvm_arch_vcpu_dump_regs(struct kvm_vcpu *vcpu)
>         kvm_debug("\thi: 0x%08lx\n", vcpu->arch.hi);
>         kvm_debug("\tlo: 0x%08lx\n", vcpu->arch.lo);
>
> -       cop0 = vcpu->arch.cop0;
> +       cop0 = &vcpu->arch.cop0;
>         kvm_debug("\tStatus: 0x%08x, Cause: 0x%08x\n",
>                   kvm_read_c0_guest_status(cop0),
>                   kvm_read_c0_guest_cause(cop0));
> @@ -1232,7 +1232,7 @@ static int __kvm_mips_handle_exit(struct kvm_vcpu *vcpu)
>
>         case EXCCODE_TLBS:
>                 kvm_debug("TLB ST fault:  cause %#x, status %#x, PC: %p, BadVaddr: %#lx\n",
> -                         cause, kvm_read_c0_guest_status(vcpu->arch.cop0), opc,
> +                         cause, kvm_read_c0_guest_status(&vcpu->arch.cop0), opc,
>                           badvaddr);
>
>                 ++vcpu->stat.tlbmiss_st_exits;
> @@ -1304,7 +1304,7 @@ static int __kvm_mips_handle_exit(struct kvm_vcpu *vcpu)
>                 kvm_get_badinstr(opc, vcpu, &inst);
>                 kvm_err("Exception Code: %d, not yet handled, @ PC: %p, inst: 0x%08x  BadVaddr: %#lx Status: %#x\n",
>                         exccode, opc, inst, badvaddr,
> -                       kvm_read_c0_guest_status(vcpu->arch.cop0));
> +                       kvm_read_c0_guest_status(&vcpu->arch.cop0));
>                 kvm_arch_vcpu_dump_regs(vcpu);
>                 run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
>                 ret = RESUME_HOST;
> @@ -1377,7 +1377,7 @@ int noinstr kvm_mips_handle_exit(struct kvm_vcpu *vcpu)
>  /* Enable FPU for guest and restore context */
>  void kvm_own_fpu(struct kvm_vcpu *vcpu)
>  {
> -       struct mips_coproc *cop0 = vcpu->arch.cop0;
> +       struct mips_coproc *cop0 = &vcpu->arch.cop0;
>         unsigned int sr, cfg5;
>
>         preempt_disable();
> @@ -1421,7 +1421,7 @@ void kvm_own_fpu(struct kvm_vcpu *vcpu)
>  /* Enable MSA for guest and restore context */
>  void kvm_own_msa(struct kvm_vcpu *vcpu)
>  {
> -       struct mips_coproc *cop0 = vcpu->arch.cop0;
> +       struct mips_coproc *cop0 = &vcpu->arch.cop0;
>         unsigned int sr, cfg5;
>
>         preempt_disable();
> diff --git a/arch/mips/kvm/vz.c b/arch/mips/kvm/vz.c
> index 3d21cbfa7443..99d5a71e4300 100644
> --- a/arch/mips/kvm/vz.c
> +++ b/arch/mips/kvm/vz.c
> @@ -422,7 +422,7 @@ static void _kvm_vz_restore_htimer(struct kvm_vcpu *vcpu,
>   */
>  static void kvm_vz_restore_timer(struct kvm_vcpu *vcpu)
>  {
> -       struct mips_coproc *cop0 = vcpu->arch.cop0;
> +       struct mips_coproc *cop0 = &vcpu->arch.cop0;
>         u32 cause, compare;
>
>         compare = kvm_read_sw_gc0_compare(cop0);
> @@ -517,7 +517,7 @@ static void _kvm_vz_save_htimer(struct kvm_vcpu *vcpu,
>   */
>  static void kvm_vz_save_timer(struct kvm_vcpu *vcpu)
>  {
> -       struct mips_coproc *cop0 = vcpu->arch.cop0;
> +       struct mips_coproc *cop0 = &vcpu->arch.cop0;
>         u32 gctl0, compare, cause;
>
>         gctl0 = read_c0_guestctl0();
> @@ -863,7 +863,7 @@ static unsigned long mips_process_maar(unsigned int op, unsigned long val)
>
>  static void kvm_write_maari(struct kvm_vcpu *vcpu, unsigned long val)
>  {
> -       struct mips_coproc *cop0 = vcpu->arch.cop0;
> +       struct mips_coproc *cop0 = &vcpu->arch.cop0;
>
>         val &= MIPS_MAARI_INDEX;
>         if (val == MIPS_MAARI_INDEX)
> @@ -876,7 +876,7 @@ static enum emulation_result kvm_vz_gpsi_cop0(union mips_instruction inst,
>                                               u32 *opc, u32 cause,
>                                               struct kvm_vcpu *vcpu)
>  {
> -       struct mips_coproc *cop0 = vcpu->arch.cop0;
> +       struct mips_coproc *cop0 = &vcpu->arch.cop0;
>         enum emulation_result er = EMULATE_DONE;
>         u32 rt, rd, sel;
>         unsigned long curr_pc;
> @@ -1911,7 +1911,7 @@ static int kvm_vz_get_one_reg(struct kvm_vcpu *vcpu,
>                               const struct kvm_one_reg *reg,
>                               s64 *v)
>  {
> -       struct mips_coproc *cop0 = vcpu->arch.cop0;
> +       struct mips_coproc *cop0 = &vcpu->arch.cop0;
>         unsigned int idx;
>
>         switch (reg->id) {
> @@ -2081,7 +2081,7 @@ static int kvm_vz_get_one_reg(struct kvm_vcpu *vcpu,
>         case KVM_REG_MIPS_CP0_MAARI:
>                 if (!cpu_guest_has_maar || cpu_guest_has_dyn_maar)
>                         return -EINVAL;
> -               *v = kvm_read_sw_gc0_maari(vcpu->arch.cop0);
> +               *v = kvm_read_sw_gc0_maari(&vcpu->arch.cop0);
>                 break;
>  #ifdef CONFIG_64BIT
>         case KVM_REG_MIPS_CP0_XCONTEXT:
> @@ -2135,7 +2135,7 @@ static int kvm_vz_set_one_reg(struct kvm_vcpu *vcpu,
>                               const struct kvm_one_reg *reg,
>                               s64 v)
>  {
> -       struct mips_coproc *cop0 = vcpu->arch.cop0;
> +       struct mips_coproc *cop0 = &vcpu->arch.cop0;
>         unsigned int idx;
>         int ret = 0;
>         unsigned int cur, change;
> @@ -2562,7 +2562,7 @@ static void kvm_vz_vcpu_load_tlb(struct kvm_vcpu *vcpu, int cpu)
>
>  static int kvm_vz_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
>  {
> -       struct mips_coproc *cop0 = vcpu->arch.cop0;
> +       struct mips_coproc *cop0 = &vcpu->arch.cop0;
>         bool migrated, all;
>
>         /*
> @@ -2704,7 +2704,7 @@ static int kvm_vz_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
>
>  static int kvm_vz_vcpu_put(struct kvm_vcpu *vcpu, int cpu)
>  {
> -       struct mips_coproc *cop0 = vcpu->arch.cop0;
> +       struct mips_coproc *cop0 = &vcpu->arch.cop0;
>
>         if (current->flags & PF_VCPU)
>                 kvm_vz_vcpu_save_wired(vcpu);
> @@ -3076,7 +3076,7 @@ static void kvm_vz_vcpu_uninit(struct kvm_vcpu *vcpu)
>
>  static int kvm_vz_vcpu_setup(struct kvm_vcpu *vcpu)
>  {
> -       struct mips_coproc *cop0 = vcpu->arch.cop0;
> +       struct mips_coproc *cop0 = &vcpu->arch.cop0;
>         unsigned long count_hz = 100*1000*1000; /* default to 100 MHz */
>
>         /*
>
> --
> Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
> good idea.                                                [ RFC1925, 2.3 ]
Yu Zhao June 17, 2023, 1:52 a.m. UTC | #5
On Fri, Jun 16, 2023 at 10:23:22AM +0200, Thomas Bogendoerfer wrote:
> On Fri, Jun 16, 2023 at 01:18:31AM -0600, Yu Zhao wrote:
> > On Tue, Jul 28, 2020 at 23:58:20PM -0700, Huacai Chen wrote:
> > > James Hogan has become inactive for a long time and leaves KVM for MIPS
> > > orphan. I'm working on KVM/Loongson and attempt to make it upstream both
> > > in kernel and QEMU, while Aleksandar Markovic is already a maintainer of
> > > QEMU/MIPS. We are both interested in QEMU/KVM/MIPS, and we have already
> > > made some contributions in kernel and QEMU. If possible, we want to take
> > > the KVM/MIPS maintainership.
> > >
> > > Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> > > Reviewed-by: Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>
> > > Signed-off-by: Huacai Chen <chenhc@lemote.com>
> > > ---
> > >  MAINTAINERS | 4 +++-
> > >  1 file changed, 3 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/MAINTAINERS b/MAINTAINERS
> > > index bddc79a..5f9c2fd 100644
> > > --- a/MAINTAINERS
> > > +++ b/MAINTAINERS
> > > @@ -9441,9 +9441,11 @@ F:	arch/arm64/kvm/
> > >  F:	include/kvm/arm_*
> > >
> > >  KERNEL VIRTUAL MACHINE FOR MIPS (KVM/mips)
> > > +M:	Huacai Chen <chenhc@lemote.com>
> > > +M:	Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>
> > >  L:	linux-mips@vger.kernel.org
> > >  L:	kvm@vger.kernel.org
> > > -S:	Orphan
> > > +S:	Maintained
> > >  F:	arch/mips/include/asm/kvm*
> > >  F:	arch/mips/include/uapi/asm/kvm*
> > >  F:	arch/mips/kvm/
> > 
> > Hi,
> > 
> > Is kvm/mips still maintained? Thanks.
> > 
> > I tried v6.4-rc6 and hit the following crash. It seems it has been broken since
> > 
> >   commit 45c7e8af4a5e3f0bea4ac209eea34118dd57ac64
> >   Author: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
> >   Date:   Mon Mar 1 16:29:57 2021 +0100
> >   
> >       MIPS: Remove KVM_TE support
> 
> ok, I see what I missed when removing TE support, d'oh. Does the patch
> below fix the issue for you ?

Thanks!

It made some progress but somehow crashed the guest kernel.

$ qemu-system-mips64el --version
QEMU emulator version 7.2.2 (Debian 1:7.2+dfsg-7)
Copyright (c) 2003-2022 Fabrice Bellard and the QEMU Project developers

# w/o KVM

  # malta: working (but slow)

    $ qemu-system-mips64el -nographic -kernel lede-malta-le64-vmlinux-initramfs.elf
    [    0.000000] Linux version 4.9.58 (buildbot@builds) (gcc version 5.5.0 (LEDE GCC 5.5.0 r5218-f90f94d) ) #0 SMP Wed Nov 1 21:08:14 2017
    ...

  # loongson3-virt: hanged

    $ qemu-system-mips64el -M loongson3-virt -m 512m -nographic -kernel vmlinuz-6.1.0-9-loongson-3 -initrd initrd.gz
    [    0.000000] Linux version 6.1.0-9-loongson-3 (debian-kernel@lists.debian.org) (gcc-12 (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40) #1 SMP PREEMPT Debian 6.1.27-1 (2023-05-08)
    ...
    [    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x000000009fffffff]

# w/ KVM

  # malta: qemu error

    $ sudo qemu-system-mips64el -M accel=kvm -nographic -kernel lede-malta-le64-vmlinux-initramfs.elf
    qemu-system-mips64el: KVM guest kernels must be linked in useg. Did you forget to enable CONFIG_KVM_GUEST?

  # loongson3-virt: qemu error

    $ sudo qemu-system-mips64el -M loongson3-virt,accel=kvm -m 512m -nographic -kernel vmlinuz-6.1.0-9-loongson-3 -initrd initrd.gz
    qemu-system-mips64el: ../../accel/kvm/kvm-all.c:2310: kvm_init: Assertion `TARGET_PAGE_SIZE <= qemu_real_host_page_size()' failed.
    Aborted

$ qemu-system-mips64el --version
QEMU emulator version 8.0.2 (Debian 1:8.0.2+dfsg-1)
Copyright (c) 2003-2022 Fabrice Bellard and the QEMU Project developers

# w/o KVM

  # malta: no change
  # loongson3-virt: no change

# w/ KVM

  # loongson3-virt: the same qemu error

  # malta: booted very fast but guest crashed:

$ sudo qemu-system-mips64el -M accel=kvm -nographic -kernel lede-malta-le64-vmlinux-initramfs.elf
[    0.000000] Linux version 4.9.58 (buildbot@builds) (gcc version 5.5.0 (LEDE GCC 5.5.0 r5218-f90f94d) ) #0 SMP Wed Nov 1 21:08:14 2017
[    0.000000] earlycon: uart8250 at I/O port 0x3f8 (options '38400n8')
[    0.000000] bootconsole [uart8250] enabled
[    0.000000] Config serial console: console=ttyS0,38400n8r
[    0.000000] CPU0 revision is: 000d9602 (Cavium Octeon III)
[    0.000000] FPU revision is: 00739600
[    0.000000] Checking for the multiply/shift bug... [    0.000000] no.
[    0.000000] Checking for the daddiu bug... [    0.000000] no.
[    0.000000] MIPS: machine is mti,malta
[    0.000000] Software DMA cache coherency enabled
[    0.000000] Determined physical RAM map:
[    0.000000]  memory: 0000000008000000 @ 0000000000000000 (usable)
[    0.000000] Initrd not found or empty - disabling initrd
[    0.000000] Primary instruction cache 16kB, VIVT, 8-way, linesize 128 bytes.
[    0.000000] Primary data cache 8kB, 8-way, VIPT, no aliases, linesize 128 bytes
[    0.000000] Zone ranges:
[    0.000000]   DMA      [mem 0x0000000000000000-0x0000000000ffffff]
[    0.000000]   DMA32    [mem 0x0000000001000000-0x00000000ffffffff]
[    0.000000]   Normal   empty
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000000000-0x0000000007ffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x0000000007ffffff]
[    0.000000] percpu: Embedded 18 pages/cpu @80000000011c5000 s33120 r8192 d32416 u73728
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 32320
[    0.000000] Kernel command line:  console=ttyS0,38400n8r
[    0.000000] PID hash table entries: 512 (order: 0, 4096 bytes)
[    0.000000] Dentry cache hash table entries: 16384 (order: 5, 131072 bytes)
[    0.000000] Inode-cache hash table entries: 8192 (order: 4, 65536 bytes)
[    0.000000] Memory: 114464K/131072K available (4299K kernel code, 322K rwdata, 1168K rodata, 7368K init, 295K bss, 16608K reserved, 0K cma-reserved)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] Hierarchical RCU implementation.
[    0.000000]  CONFIG_RCU_FANOUT set to non-default value of 32
[    0.000000]  RCU restricting CPUs from NR_CPUS=2 to nr_cpu_ids=1.
[    0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=1
[    0.000000] NR_IRQS:256
[    0.000000] CPU frequency 1999.99 MHz
[    0.000000] clocksource: MIPS: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 1911270662 ns
[    0.000007] sched_clock: 32 bits at 999MHz, resolution 1ns, wraps every 2147494911ns
[    0.003394] Console: colour dummy device 80x25
[    0.004942] Calibrating delay loop... 653.72 BogoMIPS (lpj=3268608)
[    0.276221] pid_max: default: 32768 minimum: 301
[    0.277862] Mount-cache hash table entries: 512 (order: 0, 4096 bytes)
[    0.280038] Mountpoint-cache hash table entries: 512 (order: 0, 4096 bytes)
[    0.284299] Checking for the daddi bug... [    0.286094] no.
[    0.289633] Brought up 1 CPUs
[    0.292878] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.296595] futex hash table entries: 256 (order: 2, 16384 bytes)
[    0.299743] CPU 0 Unable to handle kernel paging request at virtual address c000000000002002, epc == ffffffff804445d4, ra == ffffffff80444cb8
[    0.303942] Oops[#1]:
[    0.304738] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.9.58 #0
[    0.307060] task: 8000000007c58000 task.stack: 8000000007c54000
[    0.309171] $ 0   : 0000000000000000 0000000000000000 0000000000000042 80000000011cf1a8
[    0.312027] $ 4   : c000000000002000 0000000000000000 0000000000000000 0000000000000001
[    0.314882] $ 8   : 0000000000000006 c000000000002238 0000000e00000030 0000000800000054
[    0.317913] $12   : 0000000004000015 ffffffff80326c1c 0000000000000000 0000000e00000028
[    0.320774] $16   : c000000000002000 0000000000000210 8000000007c57d90 ffffffff8067b730
[    0.323622] $20   : ffffffff80680000 ffffffff806e5298 ffffffff806ae2b0 ffffffff80de0000
[    0.326675] $24   : 0000000000000000 ffffffff8016036c
[    0.329539] $28   : 8000000007c54000 8000000007c57cf0 ffffffff80de0000 ffffffff80444cb8
[    0.332388] Hi    : 0000000000000000
[    0.333656] Lo    : 00000000001b4760
[    0.335001] epc   : ffffffff804445d4 bpf_prepare_filter+0x2c/0x674
[    0.337394] ra    : ffffffff80444cb8 bpf_prog_create+0x9c/0xdc
[    0.339461] Status: 140027e3 KX SX UX KERNEL EXL IE
[    0.341260] Cause : 0080004c (ExcCode 13)
[    0.342683] PrId  : 000d9602 (Cavium Octeon III)
[    0.344321] Modules linked in:
[    0.345617] Process swapper/0 (pid: 1, threadinfo=8000000007c54000, task=8000000007c58000, tls=0000000000000000)
[    0.349216] Stack : ffffffff806ae2b0 c000000000002000 00000000024080c2 0000000000001000
[    0.352066]         c000000000002000 0000000000000210 8000000007c57d90 ffffffff8067b730
[    0.354914]         ffffffff80680000 ffffffff806e5298 ffffffff806ae2b0 ffffffff80de0000
[    0.357959]         ffffffff80de0000 ffffffff80444cb8 ffffffff80680000 0000000000000000
[    0.360809]         ffffffff806a0000 0000000000000000 ffffffff806d4848 ffffffff806cce20
[    0.363664]         ffffffff80680042 ffffffff806dfdb0 ffffffff806a0000 ffffffff806cc1b0
[    0.366714]         ffffffff80680000 ffffffff80680000 ffffffff806cc108 ffffffff80100608
[    0.369591]         0000000000000001 0000000000000000 0000000000000000 ffffffff80555660
[    0.372440]         ffffffff805f6338 ffffffff805f0000 0000000000000061 0000000000000002
[    0.375490]         ffffffff806d4888 000000000004093a 0000000000000061 0000000000000002
[    0.378343]         ...
[    0.379220] Call Trace:
[    0.380111] [<ffffffff804445d4>] bpf_prepare_filter+0x2c/0x674
[    0.382177] [<ffffffff80444cb8>] bpf_prog_create+0x9c/0xdc
[    0.384160] [<ffffffff806cce20>] ptp_classifier_init+0x2c/0x3c
[    0.386465] [<ffffffff806cc1b0>] sock_init+0xa8/0xc0
[    0.388276] [<ffffffff80100608>] do_one_initcall+0xa8/0x180
[    0.390289] [<ffffffff806aede0>] kernel_init_freeable+0x180/0x234
[    0.392482] [<ffffffff8052aa38>] kernel_init+0x10/0x10c
[    0.394372] [<ffffffff801062e8>] ret_from_kernel_thread+0x14/0x1c
[    0.396780] Code: ffb10028  ffb00020  ffbe0060 <90820002> 00808025  304200fe  a0820002  fc800020  64920028
[    0.400307]
[    0.401013] ---[ end trace 7278246801a7bc60 ]---
[    0.402570] Kernel panic - not syncing: Fatal exception
[    0.404311] Rebooting in 1 seconds..
[    2.385408] Reboot failed -- System halted

openwrt/malta: https://downloads.openwrt.org/snapshots/targets/malta/le64/
debian/loongson-3: https://deb.debian.org/debian/dists/sid/main/installer-mips64el/current/images/
debian/malta: not working
Huacai Chen June 18, 2023, 2:13 a.m. UTC | #6
Hi, Zhao,

I have reproduced the problem, and I hope I can fix it in a few days,
of course you can also try to do that. :)

Huacai

On Sat, Jun 17, 2023 at 9:52 AM Yu Zhao <yuzhao@google.com> wrote:
>
> On Fri, Jun 16, 2023 at 10:23:22AM +0200, Thomas Bogendoerfer wrote:
> > On Fri, Jun 16, 2023 at 01:18:31AM -0600, Yu Zhao wrote:
> > > On Tue, Jul 28, 2020 at 23:58:20PM -0700, Huacai Chen wrote:
> > > > James Hogan has become inactive for a long time and leaves KVM for MIPS
> > > > orphan. I'm working on KVM/Loongson and attempt to make it upstream both
> > > > in kernel and QEMU, while Aleksandar Markovic is already a maintainer of
> > > > QEMU/MIPS. We are both interested in QEMU/KVM/MIPS, and we have already
> > > > made some contributions in kernel and QEMU. If possible, we want to take
> > > > the KVM/MIPS maintainership.
> > > >
> > > > Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> > > > Reviewed-by: Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>
> > > > Signed-off-by: Huacai Chen <chenhc@lemote.com>
> > > > ---
> > > >  MAINTAINERS | 4 +++-
> > > >  1 file changed, 3 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/MAINTAINERS b/MAINTAINERS
> > > > index bddc79a..5f9c2fd 100644
> > > > --- a/MAINTAINERS
> > > > +++ b/MAINTAINERS
> > > > @@ -9441,9 +9441,11 @@ F: arch/arm64/kvm/
> > > >  F:       include/kvm/arm_*
> > > >
> > > >  KERNEL VIRTUAL MACHINE FOR MIPS (KVM/mips)
> > > > +M:       Huacai Chen <chenhc@lemote.com>
> > > > +M:       Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>
> > > >  L:       linux-mips@vger.kernel.org
> > > >  L:       kvm@vger.kernel.org
> > > > -S:       Orphan
> > > > +S:       Maintained
> > > >  F:       arch/mips/include/asm/kvm*
> > > >  F:       arch/mips/include/uapi/asm/kvm*
> > > >  F:       arch/mips/kvm/
> > >
> > > Hi,
> > >
> > > Is kvm/mips still maintained? Thanks.
> > >
> > > I tried v6.4-rc6 and hit the following crash. It seems it has been broken since
> > >
> > >   commit 45c7e8af4a5e3f0bea4ac209eea34118dd57ac64
> > >   Author: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
> > >   Date:   Mon Mar 1 16:29:57 2021 +0100
> > >
> > >       MIPS: Remove KVM_TE support
> >
> > ok, I see what I missed when removing TE support, d'oh. Does the patch
> > below fix the issue for you ?
>
> Thanks!
>
> It made some progress but somehow crashed the guest kernel.
>
> $ qemu-system-mips64el --version
> QEMU emulator version 7.2.2 (Debian 1:7.2+dfsg-7)
> Copyright (c) 2003-2022 Fabrice Bellard and the QEMU Project developers
>
> # w/o KVM
>
>   # malta: working (but slow)
>
>     $ qemu-system-mips64el -nographic -kernel lede-malta-le64-vmlinux-initramfs.elf
>     [    0.000000] Linux version 4.9.58 (buildbot@builds) (gcc version 5.5.0 (LEDE GCC 5.5.0 r5218-f90f94d) ) #0 SMP Wed Nov 1 21:08:14 2017
>     ...
>
>   # loongson3-virt: hanged
>
>     $ qemu-system-mips64el -M loongson3-virt -m 512m -nographic -kernel vmlinuz-6.1.0-9-loongson-3 -initrd initrd.gz
>     [    0.000000] Linux version 6.1.0-9-loongson-3 (debian-kernel@lists.debian.org) (gcc-12 (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40) #1 SMP PREEMPT Debian 6.1.27-1 (2023-05-08)
>     ...
>     [    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x000000009fffffff]
>
> # w/ KVM
>
>   # malta: qemu error
>
>     $ sudo qemu-system-mips64el -M accel=kvm -nographic -kernel lede-malta-le64-vmlinux-initramfs.elf
>     qemu-system-mips64el: KVM guest kernels must be linked in useg. Did you forget to enable CONFIG_KVM_GUEST?
>
>   # loongson3-virt: qemu error
>
>     $ sudo qemu-system-mips64el -M loongson3-virt,accel=kvm -m 512m -nographic -kernel vmlinuz-6.1.0-9-loongson-3 -initrd initrd.gz
>     qemu-system-mips64el: ../../accel/kvm/kvm-all.c:2310: kvm_init: Assertion `TARGET_PAGE_SIZE <= qemu_real_host_page_size()' failed.
>     Aborted
>
> $ qemu-system-mips64el --version
> QEMU emulator version 8.0.2 (Debian 1:8.0.2+dfsg-1)
> Copyright (c) 2003-2022 Fabrice Bellard and the QEMU Project developers
>
> # w/o KVM
>
>   # malta: no change
>   # loongson3-virt: no change
>
> # w/ KVM
>
>   # loongson3-virt: the same qemu error
>
>   # malta: booted very fast but guest crashed:
>
> $ sudo qemu-system-mips64el -M accel=kvm -nographic -kernel lede-malta-le64-vmlinux-initramfs.elf
> [    0.000000] Linux version 4.9.58 (buildbot@builds) (gcc version 5.5.0 (LEDE GCC 5.5.0 r5218-f90f94d) ) #0 SMP Wed Nov 1 21:08:14 2017
> [    0.000000] earlycon: uart8250 at I/O port 0x3f8 (options '38400n8')
> [    0.000000] bootconsole [uart8250] enabled
> [    0.000000] Config serial console: console=ttyS0,38400n8r
> [    0.000000] CPU0 revision is: 000d9602 (Cavium Octeon III)
> [    0.000000] FPU revision is: 00739600
> [    0.000000] Checking for the multiply/shift bug... [    0.000000] no.
> [    0.000000] Checking for the daddiu bug... [    0.000000] no.
> [    0.000000] MIPS: machine is mti,malta
> [    0.000000] Software DMA cache coherency enabled
> [    0.000000] Determined physical RAM map:
> [    0.000000]  memory: 0000000008000000 @ 0000000000000000 (usable)
> [    0.000000] Initrd not found or empty - disabling initrd
> [    0.000000] Primary instruction cache 16kB, VIVT, 8-way, linesize 128 bytes.
> [    0.000000] Primary data cache 8kB, 8-way, VIPT, no aliases, linesize 128 bytes
> [    0.000000] Zone ranges:
> [    0.000000]   DMA      [mem 0x0000000000000000-0x0000000000ffffff]
> [    0.000000]   DMA32    [mem 0x0000000001000000-0x00000000ffffffff]
> [    0.000000]   Normal   empty
> [    0.000000] Movable zone start for each node
> [    0.000000] Early memory node ranges
> [    0.000000]   node   0: [mem 0x0000000000000000-0x0000000007ffffff]
> [    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x0000000007ffffff]
> [    0.000000] percpu: Embedded 18 pages/cpu @80000000011c5000 s33120 r8192 d32416 u73728
> [    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 32320
> [    0.000000] Kernel command line:  console=ttyS0,38400n8r
> [    0.000000] PID hash table entries: 512 (order: 0, 4096 bytes)
> [    0.000000] Dentry cache hash table entries: 16384 (order: 5, 131072 bytes)
> [    0.000000] Inode-cache hash table entries: 8192 (order: 4, 65536 bytes)
> [    0.000000] Memory: 114464K/131072K available (4299K kernel code, 322K rwdata, 1168K rodata, 7368K init, 295K bss, 16608K reserved, 0K cma-reserved)
> [    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
> [    0.000000] Hierarchical RCU implementation.
> [    0.000000]  CONFIG_RCU_FANOUT set to non-default value of 32
> [    0.000000]  RCU restricting CPUs from NR_CPUS=2 to nr_cpu_ids=1.
> [    0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=1
> [    0.000000] NR_IRQS:256
> [    0.000000] CPU frequency 1999.99 MHz
> [    0.000000] clocksource: MIPS: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 1911270662 ns
> [    0.000007] sched_clock: 32 bits at 999MHz, resolution 1ns, wraps every 2147494911ns
> [    0.003394] Console: colour dummy device 80x25
> [    0.004942] Calibrating delay loop... 653.72 BogoMIPS (lpj=3268608)
> [    0.276221] pid_max: default: 32768 minimum: 301
> [    0.277862] Mount-cache hash table entries: 512 (order: 0, 4096 bytes)
> [    0.280038] Mountpoint-cache hash table entries: 512 (order: 0, 4096 bytes)
> [    0.284299] Checking for the daddi bug... [    0.286094] no.
> [    0.289633] Brought up 1 CPUs
> [    0.292878] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
> [    0.296595] futex hash table entries: 256 (order: 2, 16384 bytes)
> [    0.299743] CPU 0 Unable to handle kernel paging request at virtual address c000000000002002, epc == ffffffff804445d4, ra == ffffffff80444cb8
> [    0.303942] Oops[#1]:
> [    0.304738] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.9.58 #0
> [    0.307060] task: 8000000007c58000 task.stack: 8000000007c54000
> [    0.309171] $ 0   : 0000000000000000 0000000000000000 0000000000000042 80000000011cf1a8
> [    0.312027] $ 4   : c000000000002000 0000000000000000 0000000000000000 0000000000000001
> [    0.314882] $ 8   : 0000000000000006 c000000000002238 0000000e00000030 0000000800000054
> [    0.317913] $12   : 0000000004000015 ffffffff80326c1c 0000000000000000 0000000e00000028
> [    0.320774] $16   : c000000000002000 0000000000000210 8000000007c57d90 ffffffff8067b730
> [    0.323622] $20   : ffffffff80680000 ffffffff806e5298 ffffffff806ae2b0 ffffffff80de0000
> [    0.326675] $24   : 0000000000000000 ffffffff8016036c
> [    0.329539] $28   : 8000000007c54000 8000000007c57cf0 ffffffff80de0000 ffffffff80444cb8
> [    0.332388] Hi    : 0000000000000000
> [    0.333656] Lo    : 00000000001b4760
> [    0.335001] epc   : ffffffff804445d4 bpf_prepare_filter+0x2c/0x674
> [    0.337394] ra    : ffffffff80444cb8 bpf_prog_create+0x9c/0xdc
> [    0.339461] Status: 140027e3 KX SX UX KERNEL EXL IE
> [    0.341260] Cause : 0080004c (ExcCode 13)
> [    0.342683] PrId  : 000d9602 (Cavium Octeon III)
> [    0.344321] Modules linked in:
> [    0.345617] Process swapper/0 (pid: 1, threadinfo=8000000007c54000, task=8000000007c58000, tls=0000000000000000)
> [    0.349216] Stack : ffffffff806ae2b0 c000000000002000 00000000024080c2 0000000000001000
> [    0.352066]         c000000000002000 0000000000000210 8000000007c57d90 ffffffff8067b730
> [    0.354914]         ffffffff80680000 ffffffff806e5298 ffffffff806ae2b0 ffffffff80de0000
> [    0.357959]         ffffffff80de0000 ffffffff80444cb8 ffffffff80680000 0000000000000000
> [    0.360809]         ffffffff806a0000 0000000000000000 ffffffff806d4848 ffffffff806cce20
> [    0.363664]         ffffffff80680042 ffffffff806dfdb0 ffffffff806a0000 ffffffff806cc1b0
> [    0.366714]         ffffffff80680000 ffffffff80680000 ffffffff806cc108 ffffffff80100608
> [    0.369591]         0000000000000001 0000000000000000 0000000000000000 ffffffff80555660
> [    0.372440]         ffffffff805f6338 ffffffff805f0000 0000000000000061 0000000000000002
> [    0.375490]         ffffffff806d4888 000000000004093a 0000000000000061 0000000000000002
> [    0.378343]         ...
> [    0.379220] Call Trace:
> [    0.380111] [<ffffffff804445d4>] bpf_prepare_filter+0x2c/0x674
> [    0.382177] [<ffffffff80444cb8>] bpf_prog_create+0x9c/0xdc
> [    0.384160] [<ffffffff806cce20>] ptp_classifier_init+0x2c/0x3c
> [    0.386465] [<ffffffff806cc1b0>] sock_init+0xa8/0xc0
> [    0.388276] [<ffffffff80100608>] do_one_initcall+0xa8/0x180
> [    0.390289] [<ffffffff806aede0>] kernel_init_freeable+0x180/0x234
> [    0.392482] [<ffffffff8052aa38>] kernel_init+0x10/0x10c
> [    0.394372] [<ffffffff801062e8>] ret_from_kernel_thread+0x14/0x1c
> [    0.396780] Code: ffb10028  ffb00020  ffbe0060 <90820002> 00808025  304200fe  a0820002  fc800020  64920028
> [    0.400307]
> [    0.401013] ---[ end trace 7278246801a7bc60 ]---
> [    0.402570] Kernel panic - not syncing: Fatal exception
> [    0.404311] Rebooting in 1 seconds..
> [    2.385408] Reboot failed -- System halted
>
> openwrt/malta: https://downloads.openwrt.org/snapshots/targets/malta/le64/
> debian/loongson-3: https://deb.debian.org/debian/dists/sid/main/installer-mips64el/current/images/
> debian/malta: not working
Yu Zhao June 18, 2023, 2:51 a.m. UTC | #7
On Sat, Jun 17, 2023 at 8:13 PM Huacai Chen <chenhuacai@kernel.org> wrote:
>
> On Sat, Jun 17, 2023 at 9:52 AM Yu Zhao <yuzhao@google.com> wrote:
> >
> > On Fri, Jun 16, 2023 at 10:23:22AM +0200, Thomas Bogendoerfer wrote:
> > > On Fri, Jun 16, 2023 at 01:18:31AM -0600, Yu Zhao wrote:
> > > > On Tue, Jul 28, 2020 at 23:58:20PM -0700, Huacai Chen wrote:
> > > > > James Hogan has become inactive for a long time and leaves KVM for MIPS
> > > > > orphan. I'm working on KVM/Loongson and attempt to make it upstream both
> > > > > in kernel and QEMU, while Aleksandar Markovic is already a maintainer of
> > > > > QEMU/MIPS. We are both interested in QEMU/KVM/MIPS, and we have already
> > > > > made some contributions in kernel and QEMU. If possible, we want to take
> > > > > the KVM/MIPS maintainership.
> > > > >
> > > > > Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> > > > > Reviewed-by: Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>
> > > > > Signed-off-by: Huacai Chen <chenhc@lemote.com>
> > > > > ---
> > > > >  MAINTAINERS | 4 +++-
> > > > >  1 file changed, 3 insertions(+), 1 deletion(-)
> > > > >
> > > > > diff --git a/MAINTAINERS b/MAINTAINERS
> > > > > index bddc79a..5f9c2fd 100644
> > > > > --- a/MAINTAINERS
> > > > > +++ b/MAINTAINERS
> > > > > @@ -9441,9 +9441,11 @@ F: arch/arm64/kvm/
> > > > >  F:       include/kvm/arm_*
> > > > >
> > > > >  KERNEL VIRTUAL MACHINE FOR MIPS (KVM/mips)
> > > > > +M:       Huacai Chen <chenhc@lemote.com>
> > > > > +M:       Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>
> > > > >  L:       linux-mips@vger.kernel.org
> > > > >  L:       kvm@vger.kernel.org
> > > > > -S:       Orphan
> > > > > +S:       Maintained
> > > > >  F:       arch/mips/include/asm/kvm*
> > > > >  F:       arch/mips/include/uapi/asm/kvm*
> > > > >  F:       arch/mips/kvm/
> > > >
> > > > Hi,
> > > >
> > > > Is kvm/mips still maintained? Thanks.
> > > >
> > > > I tried v6.4-rc6 and hit the following crash. It seems it has been broken since
> > > >
> > > >   commit 45c7e8af4a5e3f0bea4ac209eea34118dd57ac64
> > > >   Author: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
> > > >   Date:   Mon Mar 1 16:29:57 2021 +0100
> > > >
> > > >       MIPS: Remove KVM_TE support
> > >
> > > ok, I see what I missed when removing TE support, d'oh. Does the patch
> > > below fix the issue for you ?
> >
> > Thanks!
> >
> > It made some progress but somehow crashed the guest kernel.
> >
> > $ qemu-system-mips64el --version
> > QEMU emulator version 7.2.2 (Debian 1:7.2+dfsg-7)
> > Copyright (c) 2003-2022 Fabrice Bellard and the QEMU Project developers
> >
> > # w/o KVM
> >
> >   # malta: working (but slow)
> >
> >     $ qemu-system-mips64el -nographic -kernel lede-malta-le64-vmlinux-initramfs.elf
> >     [    0.000000] Linux version 4.9.58 (buildbot@builds) (gcc version 5.5.0 (LEDE GCC 5.5.0 r5218-f90f94d) ) #0 SMP Wed Nov 1 21:08:14 2017
> >     ...
> >
> >   # loongson3-virt: hanged
> >
> >     $ qemu-system-mips64el -M loongson3-virt -m 512m -nographic -kernel vmlinuz-6.1.0-9-loongson-3 -initrd initrd.gz
> >     [    0.000000] Linux version 6.1.0-9-loongson-3 (debian-kernel@lists.debian.org) (gcc-12 (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40) #1 SMP PREEMPT Debian 6.1.27-1 (2023-05-08)
> >     ...
> >     [    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x000000009fffffff]
> >
> > # w/ KVM
> >
> >   # malta: qemu error
> >
> >     $ sudo qemu-system-mips64el -M accel=kvm -nographic -kernel lede-malta-le64-vmlinux-initramfs.elf
> >     qemu-system-mips64el: KVM guest kernels must be linked in useg. Did you forget to enable CONFIG_KVM_GUEST?
> >
> >   # loongson3-virt: qemu error
> >
> >     $ sudo qemu-system-mips64el -M loongson3-virt,accel=kvm -m 512m -nographic -kernel vmlinuz-6.1.0-9-loongson-3 -initrd initrd.gz
> >     qemu-system-mips64el: ../../accel/kvm/kvm-all.c:2310: kvm_init: Assertion `TARGET_PAGE_SIZE <= qemu_real_host_page_size()' failed.
> >     Aborted
> >
> > $ qemu-system-mips64el --version
> > QEMU emulator version 8.0.2 (Debian 1:8.0.2+dfsg-1)
> > Copyright (c) 2003-2022 Fabrice Bellard and the QEMU Project developers
> >
> > # w/o KVM
> >
> >   # malta: no change
> >   # loongson3-virt: no change
> >
> > # w/ KVM
> >
> >   # loongson3-virt: the same qemu error
> >
> >   # malta: booted very fast but guest crashed:
> >
> > $ sudo qemu-system-mips64el -M accel=kvm -nographic -kernel lede-malta-le64-vmlinux-initramfs.elf
> > [    0.000000] Linux version 4.9.58 (buildbot@builds) (gcc version 5.5.0 (LEDE GCC 5.5.0 r5218-f90f94d) ) #0 SMP Wed Nov 1 21:08:14 2017

...

> > [    0.402570] Kernel panic - not syncing: Fatal exception
> > [    0.404311] Rebooting in 1 seconds..
> > [    2.385408] Reboot failed -- System halted
> >
> > openwrt/malta: https://downloads.openwrt.org/snapshots/targets/malta/le64/
> > debian/loongson-3: https://deb.debian.org/debian/dists/sid/main/installer-mips64el/current/images/
> > debian/malta: not working
>
> I have reproduced the problem, and I hope I can fix it in a few days,

That's great. Thanks a lot!
Thomas Bogendoerfer June 18, 2023, 7:55 a.m. UTC | #8
On Fri, Jun 16, 2023 at 04:31:13PM +0800, Huacai Chen wrote:
> On Fri, Jun 16, 2023 at 4:23 PM Thomas Bogendoerfer
> <tsbogend@alpha.franken.de> wrote:
> >
> > index 957121a495f0..04cedf9f8811 100644
> > --- a/arch/mips/include/asm/kvm_host.h
> > +++ b/arch/mips/include/asm/kvm_host.h
> > @@ -317,7 +317,7 @@ struct kvm_vcpu_arch {
> >         unsigned int aux_inuse;
> >
> >         /* COP0 State */
> > -       struct mips_coproc *cop0;
> > +       struct mips_coproc cop0;
> Maybe keeping it as a pointer and allocate in kvm_arch_vcpu_create()
> is better? (smaller modification)

I thought about it, but then we have another dynmic object, which we
need to care about lifetime. And I don't think we need *cop any longer,
so this cleanes up the code and makes it even slightly faster.

Thomas.
Huacai Chen June 26, 2023, 8 a.m. UTC | #9
Hi, Zhao,

On Sun, Jun 18, 2023 at 10:51 AM Yu Zhao <yuzhao@google.com> wrote:
>
> On Sat, Jun 17, 2023 at 8:13 PM Huacai Chen <chenhuacai@kernel.org> wrote:
> >
> > On Sat, Jun 17, 2023 at 9:52 AM Yu Zhao <yuzhao@google.com> wrote:
> > >
> > > On Fri, Jun 16, 2023 at 10:23:22AM +0200, Thomas Bogendoerfer wrote:
> > > > On Fri, Jun 16, 2023 at 01:18:31AM -0600, Yu Zhao wrote:
> > > > > On Tue, Jul 28, 2020 at 23:58:20PM -0700, Huacai Chen wrote:
> > > > > > James Hogan has become inactive for a long time and leaves KVM for MIPS
> > > > > > orphan. I'm working on KVM/Loongson and attempt to make it upstream both
> > > > > > in kernel and QEMU, while Aleksandar Markovic is already a maintainer of
> > > > > > QEMU/MIPS. We are both interested in QEMU/KVM/MIPS, and we have already
> > > > > > made some contributions in kernel and QEMU. If possible, we want to take
> > > > > > the KVM/MIPS maintainership.
> > > > > >
> > > > > > Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> > > > > > Reviewed-by: Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>
> > > > > > Signed-off-by: Huacai Chen <chenhc@lemote.com>
> > > > > > ---
> > > > > >  MAINTAINERS | 4 +++-
> > > > > >  1 file changed, 3 insertions(+), 1 deletion(-)
> > > > > >
> > > > > > diff --git a/MAINTAINERS b/MAINTAINERS
> > > > > > index bddc79a..5f9c2fd 100644
> > > > > > --- a/MAINTAINERS
> > > > > > +++ b/MAINTAINERS
> > > > > > @@ -9441,9 +9441,11 @@ F: arch/arm64/kvm/
> > > > > >  F:       include/kvm/arm_*
> > > > > >
> > > > > >  KERNEL VIRTUAL MACHINE FOR MIPS (KVM/mips)
> > > > > > +M:       Huacai Chen <chenhc@lemote.com>
> > > > > > +M:       Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>
> > > > > >  L:       linux-mips@vger.kernel.org
> > > > > >  L:       kvm@vger.kernel.org
> > > > > > -S:       Orphan
> > > > > > +S:       Maintained
> > > > > >  F:       arch/mips/include/asm/kvm*
> > > > > >  F:       arch/mips/include/uapi/asm/kvm*
> > > > > >  F:       arch/mips/kvm/
> > > > >
> > > > > Hi,
> > > > >
> > > > > Is kvm/mips still maintained? Thanks.
> > > > >
> > > > > I tried v6.4-rc6 and hit the following crash. It seems it has been broken since
> > > > >
> > > > >   commit 45c7e8af4a5e3f0bea4ac209eea34118dd57ac64
> > > > >   Author: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
> > > > >   Date:   Mon Mar 1 16:29:57 2021 +0100
> > > > >
> > > > >       MIPS: Remove KVM_TE support
> > > >
> > > > ok, I see what I missed when removing TE support, d'oh. Does the patch
> > > > below fix the issue for you ?
> > >
> > > Thanks!
> > >
> > > It made some progress but somehow crashed the guest kernel.
> > >
> > > $ qemu-system-mips64el --version
> > > QEMU emulator version 7.2.2 (Debian 1:7.2+dfsg-7)
> > > Copyright (c) 2003-2022 Fabrice Bellard and the QEMU Project developers
> > >
> > > # w/o KVM
> > >
> > >   # malta: working (but slow)
> > >
> > >     $ qemu-system-mips64el -nographic -kernel lede-malta-le64-vmlinux-initramfs.elf
> > >     [    0.000000] Linux version 4.9.58 (buildbot@builds) (gcc version 5.5.0 (LEDE GCC 5.5.0 r5218-f90f94d) ) #0 SMP Wed Nov 1 21:08:14 2017
> > >     ...
> > >
> > >   # loongson3-virt: hanged
> > >
> > >     $ qemu-system-mips64el -M loongson3-virt -m 512m -nographic -kernel vmlinuz-6.1.0-9-loongson-3 -initrd initrd.gz
> > >     [    0.000000] Linux version 6.1.0-9-loongson-3 (debian-kernel@lists.debian.org) (gcc-12 (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40) #1 SMP PREEMPT Debian 6.1.27-1 (2023-05-08)
> > >     ...
> > >     [    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x000000009fffffff]
> > >
> > > # w/ KVM
> > >
> > >   # malta: qemu error
> > >
> > >     $ sudo qemu-system-mips64el -M accel=kvm -nographic -kernel lede-malta-le64-vmlinux-initramfs.elf
> > >     qemu-system-mips64el: KVM guest kernels must be linked in useg. Did you forget to enable CONFIG_KVM_GUEST?
> > >
> > >   # loongson3-virt: qemu error
> > >
> > >     $ sudo qemu-system-mips64el -M loongson3-virt,accel=kvm -m 512m -nographic -kernel vmlinuz-6.1.0-9-loongson-3 -initrd initrd.gz
> > >     qemu-system-mips64el: ../../accel/kvm/kvm-all.c:2310: kvm_init: Assertion `TARGET_PAGE_SIZE <= qemu_real_host_page_size()' failed.
> > >     Aborted
> > >
> > > $ qemu-system-mips64el --version
> > > QEMU emulator version 8.0.2 (Debian 1:8.0.2+dfsg-1)
> > > Copyright (c) 2003-2022 Fabrice Bellard and the QEMU Project developers
> > >
> > > # w/o KVM
> > >
> > >   # malta: no change
> > >   # loongson3-virt: no change
> > >
> > > # w/ KVM
> > >
> > >   # loongson3-virt: the same qemu error
> > >
> > >   # malta: booted very fast but guest crashed:
> > >
> > > $ sudo qemu-system-mips64el -M accel=kvm -nographic -kernel lede-malta-le64-vmlinux-initramfs.elf
> > > [    0.000000] Linux version 4.9.58 (buildbot@builds) (gcc version 5.5.0 (LEDE GCC 5.5.0 r5218-f90f94d) ) #0 SMP Wed Nov 1 21:08:14 2017
>
> ...
>
> > > [    0.402570] Kernel panic - not syncing: Fatal exception
> > > [    0.404311] Rebooting in 1 seconds..
> > > [    2.385408] Reboot failed -- System halted
> > >
> > > openwrt/malta: https://downloads.openwrt.org/snapshots/targets/malta/le64/
> > > debian/loongson-3: https://deb.debian.org/debian/dists/sid/main/installer-mips64el/current/images/
> > > debian/malta: not working
> >
> > I have reproduced the problem, and I hope I can fix it in a few days,
>
> That's great. Thanks a lot!
I fixed the KVM problems on Loongson [1][2][3]. However, you have
tried [1] but still have problems, while [2] and [3] are specific to
Loongson, so maybe you are still unable to use KVM.

[1] https://lore.kernel.org/linux-mips/20230626074919.1871944-1-chenhuacai@loongson.cn/T/#u
[2] https://lore.kernel.org/linux-mips/20230626075014.1872632-1-chenhuacai@loongson.cn/T/#u
[3] https://lore.kernel.org/linux-mips/20230626075047.1872818-1-chenhuacai@loongson.cn/T/#u

Huacai
Yu Zhao June 27, 2023, 6:58 p.m. UTC | #10
On Mon, Jun 26, 2023 at 2:00 AM Huacai Chen <chenhuacai@kernel.org> wrote:
>
> Hi, Zhao,
>
> On Sun, Jun 18, 2023 at 10:51 AM Yu Zhao <yuzhao@google.com> wrote:
> >
> > On Sat, Jun 17, 2023 at 8:13 PM Huacai Chen <chenhuacai@kernel.org> wrote:
> > >
> > > On Sat, Jun 17, 2023 at 9:52 AM Yu Zhao <yuzhao@google.com> wrote:
> > > >
> > > > On Fri, Jun 16, 2023 at 10:23:22AM +0200, Thomas Bogendoerfer wrote:
> > > > > On Fri, Jun 16, 2023 at 01:18:31AM -0600, Yu Zhao wrote:
> > > > > > On Tue, Jul 28, 2020 at 23:58:20PM -0700, Huacai Chen wrote:
> > > > > > > James Hogan has become inactive for a long time and leaves KVM for MIPS
> > > > > > > orphan. I'm working on KVM/Loongson and attempt to make it upstream both
> > > > > > > in kernel and QEMU, while Aleksandar Markovic is already a maintainer of
> > > > > > > QEMU/MIPS. We are both interested in QEMU/KVM/MIPS, and we have already
> > > > > > > made some contributions in kernel and QEMU. If possible, we want to take
> > > > > > > the KVM/MIPS maintainership.
> > > > > > >
> > > > > > > Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> > > > > > > Reviewed-by: Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>
> > > > > > > Signed-off-by: Huacai Chen <chenhc@lemote.com>
> > > > > > > ---
> > > > > > >  MAINTAINERS | 4 +++-
> > > > > > >  1 file changed, 3 insertions(+), 1 deletion(-)
> > > > > > >
> > > > > > > diff --git a/MAINTAINERS b/MAINTAINERS
> > > > > > > index bddc79a..5f9c2fd 100644
> > > > > > > --- a/MAINTAINERS
> > > > > > > +++ b/MAINTAINERS
> > > > > > > @@ -9441,9 +9441,11 @@ F: arch/arm64/kvm/
> > > > > > >  F:       include/kvm/arm_*
> > > > > > >
> > > > > > >  KERNEL VIRTUAL MACHINE FOR MIPS (KVM/mips)
> > > > > > > +M:       Huacai Chen <chenhc@lemote.com>
> > > > > > > +M:       Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>
> > > > > > >  L:       linux-mips@vger.kernel.org
> > > > > > >  L:       kvm@vger.kernel.org
> > > > > > > -S:       Orphan
> > > > > > > +S:       Maintained
> > > > > > >  F:       arch/mips/include/asm/kvm*
> > > > > > >  F:       arch/mips/include/uapi/asm/kvm*
> > > > > > >  F:       arch/mips/kvm/
> > > > > >
> > > > > > Hi,
> > > > > >
> > > > > > Is kvm/mips still maintained? Thanks.
> > > > > >
> > > > > > I tried v6.4-rc6 and hit the following crash. It seems it has been broken since
> > > > > >
> > > > > >   commit 45c7e8af4a5e3f0bea4ac209eea34118dd57ac64
> > > > > >   Author: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
> > > > > >   Date:   Mon Mar 1 16:29:57 2021 +0100
> > > > > >
> > > > > >       MIPS: Remove KVM_TE support
> > > > >
> > > > > ok, I see what I missed when removing TE support, d'oh. Does the patch
> > > > > below fix the issue for you ?
> > > >
> > > > Thanks!
> > > >
> > > > It made some progress but somehow crashed the guest kernel.
> > > >
> > > > $ qemu-system-mips64el --version
> > > > QEMU emulator version 7.2.2 (Debian 1:7.2+dfsg-7)
> > > > Copyright (c) 2003-2022 Fabrice Bellard and the QEMU Project developers
> > > >
> > > > # w/o KVM
> > > >
> > > >   # malta: working (but slow)
> > > >
> > > >     $ qemu-system-mips64el -nographic -kernel lede-malta-le64-vmlinux-initramfs.elf
> > > >     [    0.000000] Linux version 4.9.58 (buildbot@builds) (gcc version 5.5.0 (LEDE GCC 5.5.0 r5218-f90f94d) ) #0 SMP Wed Nov 1 21:08:14 2017
> > > >     ...
> > > >
> > > >   # loongson3-virt: hanged
> > > >
> > > >     $ qemu-system-mips64el -M loongson3-virt -m 512m -nographic -kernel vmlinuz-6.1.0-9-loongson-3 -initrd initrd.gz
> > > >     [    0.000000] Linux version 6.1.0-9-loongson-3 (debian-kernel@lists.debian.org) (gcc-12 (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40) #1 SMP PREEMPT Debian 6.1.27-1 (2023-05-08)
> > > >     ...
> > > >     [    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x000000009fffffff]
> > > >
> > > > # w/ KVM
> > > >
> > > >   # malta: qemu error
> > > >
> > > >     $ sudo qemu-system-mips64el -M accel=kvm -nographic -kernel lede-malta-le64-vmlinux-initramfs.elf
> > > >     qemu-system-mips64el: KVM guest kernels must be linked in useg. Did you forget to enable CONFIG_KVM_GUEST?
> > > >
> > > >   # loongson3-virt: qemu error
> > > >
> > > >     $ sudo qemu-system-mips64el -M loongson3-virt,accel=kvm -m 512m -nographic -kernel vmlinuz-6.1.0-9-loongson-3 -initrd initrd.gz
> > > >     qemu-system-mips64el: ../../accel/kvm/kvm-all.c:2310: kvm_init: Assertion `TARGET_PAGE_SIZE <= qemu_real_host_page_size()' failed.
> > > >     Aborted
> > > >
> > > > $ qemu-system-mips64el --version
> > > > QEMU emulator version 8.0.2 (Debian 1:8.0.2+dfsg-1)
> > > > Copyright (c) 2003-2022 Fabrice Bellard and the QEMU Project developers
> > > >
> > > > # w/o KVM
> > > >
> > > >   # malta: no change
> > > >   # loongson3-virt: no change
> > > >
> > > > # w/ KVM
> > > >
> > > >   # loongson3-virt: the same qemu error
> > > >
> > > >   # malta: booted very fast but guest crashed:
> > > >
> > > > $ sudo qemu-system-mips64el -M accel=kvm -nographic -kernel lede-malta-le64-vmlinux-initramfs.elf
> > > > [    0.000000] Linux version 4.9.58 (buildbot@builds) (gcc version 5.5.0 (LEDE GCC 5.5.0 r5218-f90f94d) ) #0 SMP Wed Nov 1 21:08:14 2017
> >
> > ...
> >
> > > > [    0.402570] Kernel panic - not syncing: Fatal exception
> > > > [    0.404311] Rebooting in 1 seconds..
> > > > [    2.385408] Reboot failed -- System halted
> > > >
> > > > openwrt/malta: https://downloads.openwrt.org/snapshots/targets/malta/le64/
> > > > debian/loongson-3: https://deb.debian.org/debian/dists/sid/main/installer-mips64el/current/images/
> > > > debian/malta: not working
> > >
> > > I have reproduced the problem, and I hope I can fix it in a few days,
> >
> > That's great. Thanks a lot!
> I fixed the KVM problems on Loongson [1][2][3]. However, you have
> tried [1] but still have problems, while [2] and [3] are specific to
> Loongson, so maybe you are still unable to use KVM.
>
> [1] https://lore.kernel.org/linux-mips/20230626074919.1871944-1-chenhuacai@loongson.cn/T/#u
> [2] https://lore.kernel.org/linux-mips/20230626075014.1872632-1-chenhuacai@loongson.cn/T/#u
> [3] https://lore.kernel.org/linux-mips/20230626075047.1872818-1-chenhuacai@loongson.cn/T/#u

Thanks for the update. I'll take a look if I get a chance.
diff mbox series

Patch

diff --git a/MAINTAINERS b/MAINTAINERS
index bddc79a..5f9c2fd 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -9441,9 +9441,11 @@  F:	arch/arm64/kvm/
 F:	include/kvm/arm_*
 
 KERNEL VIRTUAL MACHINE FOR MIPS (KVM/mips)
+M:	Huacai Chen <chenhc@lemote.com>
+M:	Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>
 L:	linux-mips@vger.kernel.org
 L:	kvm@vger.kernel.org
-S:	Orphan
+S:	Maintained
 F:	arch/mips/include/asm/kvm*
 F:	arch/mips/include/uapi/asm/kvm*
 F:	arch/mips/kvm/