[PATCH] target/loongarch: Adjust the cpu reset action to a proper position

Xianglai Li posted 1 patch 1 day, 15 hours ago
There is a newer version of this series
target/loongarch/cpu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] target/loongarch: Adjust the cpu reset action to a proper position
Posted by Xianglai Li 1 day, 15 hours ago
The commit 5a99a10da6cf ("target/loongarch: fix vcpu reset command word issue")
fixes the error in the cpu reset ioctl command word delivery process,
so that the command word can be delivered correctly, and adds the judgment
and processing of the error return value, which exposes another problem that
under loongarch, the cpu reset action is earlier than the creation of vcpu.
An error occurs when the cpu reset command is sent.

Now adjust the order of cpu reset and vcpu create actions to fix this problem

Signed-off-by: Xianglai Li <lixianglai@loongson.cn>
---
Bibo Mao <maobibo@loongson.cn>
Huacai Chen <chenhuacai@loongson.cn>
Song Gao <gaosong@loongson.cn>
Xianglai Li <lixianglai@loongson.cn>

 target/loongarch/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c
index 3788f895c1..67aa7875b6 100644
--- a/target/loongarch/cpu.c
+++ b/target/loongarch/cpu.c
@@ -640,8 +640,8 @@ static void loongarch_cpu_realizefn(DeviceState *dev, Error **errp)
 
     loongarch_cpu_register_gdb_regs_for_features(cs);
 
-    cpu_reset(cs);
     qemu_init_vcpu(cs);
+    cpu_reset(cs);
 
     lacc->parent_realize(dev, errp);
 }
-- 
2.39.1
Re: [PATCH] target/loongarch: Adjust the cpu reset action to a proper position
Posted by bibo mao 1 day, 12 hours ago
Xianglai,

There is a similar modification already, just wait a moment :)
  https://lists.nongnu.org/archive/html/qemu-devel/2025-02/msg01537.html


Regards
Bibo Mao

On 2025/3/3 下午2:30, Xianglai Li wrote:
> The commit 5a99a10da6cf ("target/loongarch: fix vcpu reset command word issue")
> fixes the error in the cpu reset ioctl command word delivery process,
> so that the command word can be delivered correctly, and adds the judgment
> and processing of the error return value, which exposes another problem that
> under loongarch, the cpu reset action is earlier than the creation of vcpu.
> An error occurs when the cpu reset command is sent.
> 
> Now adjust the order of cpu reset and vcpu create actions to fix this problem
> 
> Signed-off-by: Xianglai Li <lixianglai@loongson.cn>
> ---
> Bibo Mao <maobibo@loongson.cn>
> Huacai Chen <chenhuacai@loongson.cn>
> Song Gao <gaosong@loongson.cn>
> Xianglai Li <lixianglai@loongson.cn>
> 
>   target/loongarch/cpu.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c
> index 3788f895c1..67aa7875b6 100644
> --- a/target/loongarch/cpu.c
> +++ b/target/loongarch/cpu.c
> @@ -640,8 +640,8 @@ static void loongarch_cpu_realizefn(DeviceState *dev, Error **errp)
>   
>       loongarch_cpu_register_gdb_regs_for_features(cs);
>   
> -    cpu_reset(cs);
>       qemu_init_vcpu(cs);
> +    cpu_reset(cs);
>   
>       lacc->parent_realize(dev, errp);
>   }
> 


Re: [PATCH] target/loongarch: Adjust the cpu reset action to a proper position
Posted by Igor Mammedov 1 day, 8 hours ago
On Mon, 3 Mar 2025 17:15:13 +0800
bibo mao <maobibo@loongson.cn> wrote:

> Xianglai,
> 
> There is a similar modification already, just wait a moment :)
>   https://lists.nongnu.org/archive/html/qemu-devel/2025-02/msg01537.html

Please ignore my patch (commit message gives good enough justification
for refactoring but that's it).

this patch commit message however points to the concrete issue
wrong reset ordering causes, hence I think it's better to merge
this variant.

Acked-by: Igor Mammedov <imammedo@redhat.com>
 
> 
> 
> Regards
> Bibo Mao
> 
> On 2025/3/3 下午2:30, Xianglai Li wrote:
> > The commit 5a99a10da6cf ("target/loongarch: fix vcpu reset command word issue")
> > fixes the error in the cpu reset ioctl command word delivery process,
> > so that the command word can be delivered correctly, and adds the judgment
> > and processing of the error return value, which exposes another problem that
> > under loongarch, the cpu reset action is earlier than the creation of vcpu.
> > An error occurs when the cpu reset command is sent.
> > 
> > Now adjust the order of cpu reset and vcpu create actions to fix this problem
> > 
> > Signed-off-by: Xianglai Li <lixianglai@loongson.cn>
> > ---
> > Bibo Mao <maobibo@loongson.cn>
> > Huacai Chen <chenhuacai@loongson.cn>
> > Song Gao <gaosong@loongson.cn>
> > Xianglai Li <lixianglai@loongson.cn>
> > 
> >   target/loongarch/cpu.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c
> > index 3788f895c1..67aa7875b6 100644
> > --- a/target/loongarch/cpu.c
> > +++ b/target/loongarch/cpu.c
> > @@ -640,8 +640,8 @@ static void loongarch_cpu_realizefn(DeviceState *dev, Error **errp)
> >   
> >       loongarch_cpu_register_gdb_regs_for_features(cs);
> >   
> > -    cpu_reset(cs);
> >       qemu_init_vcpu(cs);
> > +    cpu_reset(cs);
> >   
> >       lacc->parent_realize(dev, errp);
> >   }
> >   
> 
>