All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] target/riscv: Fix satp write
@ 2021-09-01 12:45 ` LIU Zhiwei
  0 siblings, 0 replies; 22+ messages in thread
From: LIU Zhiwei @ 2021-09-01 12:45 UTC (permalink / raw)
  To: qemu-devel, qemu-riscv
  Cc: palmer, richard.henderson, bin.meng, Alistair.Francis, LIU Zhiwei

These variables should be target_ulong. If truncated to int,
the bool conditions they indicate will be wrong.

As satp is very important for Linux, this bug almost fails every boot.

Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com>
---
 target/riscv/csr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/riscv/csr.c b/target/riscv/csr.c
index 50a2c3a3b4..ba9818f6a5 100644
--- a/target/riscv/csr.c
+++ b/target/riscv/csr.c
@@ -986,7 +986,7 @@ static RISCVException read_satp(CPURISCVState *env, int csrno,
 static RISCVException write_satp(CPURISCVState *env, int csrno,
                                  target_ulong val)
 {
-    int vm, mask, asid;
+    target_ulong vm, mask, asid;
 
     if (!riscv_feature(env, RISCV_FEATURE_MMU)) {
         return RISCV_EXCP_NONE;
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH] target/riscv: Fix satp write
@ 2021-09-01 12:45 ` LIU Zhiwei
  0 siblings, 0 replies; 22+ messages in thread
From: LIU Zhiwei @ 2021-09-01 12:45 UTC (permalink / raw)
  To: qemu-devel, qemu-riscv
  Cc: Alistair.Francis, palmer, bin.meng, richard.henderson, LIU Zhiwei

These variables should be target_ulong. If truncated to int,
the bool conditions they indicate will be wrong.

As satp is very important for Linux, this bug almost fails every boot.

Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com>
---
 target/riscv/csr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/riscv/csr.c b/target/riscv/csr.c
index 50a2c3a3b4..ba9818f6a5 100644
--- a/target/riscv/csr.c
+++ b/target/riscv/csr.c
@@ -986,7 +986,7 @@ static RISCVException read_satp(CPURISCVState *env, int csrno,
 static RISCVException write_satp(CPURISCVState *env, int csrno,
                                  target_ulong val)
 {
-    int vm, mask, asid;
+    target_ulong vm, mask, asid;
 
     if (!riscv_feature(env, RISCV_FEATURE_MMU)) {
         return RISCV_EXCP_NONE;
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [PATCH] target/riscv: Fix satp write
  2021-09-01 12:45 ` LIU Zhiwei
@ 2021-09-01 13:05   ` Bin Meng
  -1 siblings, 0 replies; 22+ messages in thread
From: Bin Meng @ 2021-09-01 13:05 UTC (permalink / raw)
  To: LIU Zhiwei
  Cc: open list:RISC-V, Bin Meng, Richard Henderson,
	qemu-devel@nongnu.org Developers, Palmer Dabbelt,
	Alistair Francis

On Wed, Sep 1, 2021 at 8:51 PM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
>
> These variables should be target_ulong. If truncated to int,
> the bool conditions they indicate will be wrong.
>
> As satp is very important for Linux, this bug almost fails every boot.

Could you please describe which Linux configuration is broken? I have
a 64-bit 5.10 kernel and it boots fine.

Please add:

Fixes: 419ddf00ed78 ("target/riscv: Remove the hardcoded SATP_MODE macro")

> Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com>
> ---
>  target/riscv/csr.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/target/riscv/csr.c b/target/riscv/csr.c
> index 50a2c3a3b4..ba9818f6a5 100644
> --- a/target/riscv/csr.c
> +++ b/target/riscv/csr.c
> @@ -986,7 +986,7 @@ static RISCVException read_satp(CPURISCVState *env, int csrno,
>  static RISCVException write_satp(CPURISCVState *env, int csrno,
>                                   target_ulong val)
>  {
> -    int vm, mask, asid;
> +    target_ulong vm, mask, asid;
>
>      if (!riscv_feature(env, RISCV_FEATURE_MMU)) {
>          return RISCV_EXCP_NONE;

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] target/riscv: Fix satp write
@ 2021-09-01 13:05   ` Bin Meng
  0 siblings, 0 replies; 22+ messages in thread
From: Bin Meng @ 2021-09-01 13:05 UTC (permalink / raw)
  To: LIU Zhiwei
  Cc: qemu-devel@nongnu.org Developers, open list:RISC-V,
	Palmer Dabbelt, Richard Henderson, Bin Meng, Alistair Francis

On Wed, Sep 1, 2021 at 8:51 PM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
>
> These variables should be target_ulong. If truncated to int,
> the bool conditions they indicate will be wrong.
>
> As satp is very important for Linux, this bug almost fails every boot.

Could you please describe which Linux configuration is broken? I have
a 64-bit 5.10 kernel and it boots fine.

Please add:

Fixes: 419ddf00ed78 ("target/riscv: Remove the hardcoded SATP_MODE macro")

> Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com>
> ---
>  target/riscv/csr.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/target/riscv/csr.c b/target/riscv/csr.c
> index 50a2c3a3b4..ba9818f6a5 100644
> --- a/target/riscv/csr.c
> +++ b/target/riscv/csr.c
> @@ -986,7 +986,7 @@ static RISCVException read_satp(CPURISCVState *env, int csrno,
>  static RISCVException write_satp(CPURISCVState *env, int csrno,
>                                   target_ulong val)
>  {
> -    int vm, mask, asid;
> +    target_ulong vm, mask, asid;
>
>      if (!riscv_feature(env, RISCV_FEATURE_MMU)) {
>          return RISCV_EXCP_NONE;

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] target/riscv: Fix satp write
  2021-09-01 13:05   ` Bin Meng
@ 2021-09-02  1:02     ` LIU Zhiwei
  -1 siblings, 0 replies; 22+ messages in thread
From: LIU Zhiwei @ 2021-09-02  1:02 UTC (permalink / raw)
  To: Bin Meng
  Cc: open list:RISC-V, Bin Meng, Richard Henderson,
	qemu-devel@nongnu.org Developers, Palmer Dabbelt,
	Alistair Francis


On 2021/9/1 下午9:05, Bin Meng wrote:
> On Wed, Sep 1, 2021 at 8:51 PM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
>> These variables should be target_ulong. If truncated to int,
>> the bool conditions they indicate will be wrong.
>>
>> As satp is very important for Linux, this bug almost fails every boot.
> Could you please describe which Linux configuration is broken?

I use the image from:

https://gitlab.com/c-sky/buildroot/-/jobs/1251564514/artifacts/browse/output/images/

>   I have
> a 64-bit 5.10 kernel and it boots fine.

The login is mostly OK for me. But the busybox can't run properly.

Thanks,
Zhiwei

> Please add:
>
> Fixes: 419ddf00ed78 ("target/riscv: Remove the hardcoded SATP_MODE macro")
>
>> Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com>
>> ---
>>   target/riscv/csr.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/target/riscv/csr.c b/target/riscv/csr.c
>> index 50a2c3a3b4..ba9818f6a5 100644
>> --- a/target/riscv/csr.c
>> +++ b/target/riscv/csr.c
>> @@ -986,7 +986,7 @@ static RISCVException read_satp(CPURISCVState *env, int csrno,
>>   static RISCVException write_satp(CPURISCVState *env, int csrno,
>>                                    target_ulong val)
>>   {
>> -    int vm, mask, asid;
>> +    target_ulong vm, mask, asid;
>>
>>       if (!riscv_feature(env, RISCV_FEATURE_MMU)) {
>>           return RISCV_EXCP_NONE;
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] target/riscv: Fix satp write
@ 2021-09-02  1:02     ` LIU Zhiwei
  0 siblings, 0 replies; 22+ messages in thread
From: LIU Zhiwei @ 2021-09-02  1:02 UTC (permalink / raw)
  To: Bin Meng
  Cc: qemu-devel@nongnu.org Developers, open list:RISC-V,
	Palmer Dabbelt, Richard Henderson, Bin Meng, Alistair Francis


On 2021/9/1 下午9:05, Bin Meng wrote:
> On Wed, Sep 1, 2021 at 8:51 PM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
>> These variables should be target_ulong. If truncated to int,
>> the bool conditions they indicate will be wrong.
>>
>> As satp is very important for Linux, this bug almost fails every boot.
> Could you please describe which Linux configuration is broken?

I use the image from:

https://gitlab.com/c-sky/buildroot/-/jobs/1251564514/artifacts/browse/output/images/

>   I have
> a 64-bit 5.10 kernel and it boots fine.

The login is mostly OK for me. But the busybox can't run properly.

Thanks,
Zhiwei

> Please add:
>
> Fixes: 419ddf00ed78 ("target/riscv: Remove the hardcoded SATP_MODE macro")
>
>> Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com>
>> ---
>>   target/riscv/csr.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/target/riscv/csr.c b/target/riscv/csr.c
>> index 50a2c3a3b4..ba9818f6a5 100644
>> --- a/target/riscv/csr.c
>> +++ b/target/riscv/csr.c
>> @@ -986,7 +986,7 @@ static RISCVException read_satp(CPURISCVState *env, int csrno,
>>   static RISCVException write_satp(CPURISCVState *env, int csrno,
>>                                    target_ulong val)
>>   {
>> -    int vm, mask, asid;
>> +    target_ulong vm, mask, asid;
>>
>>       if (!riscv_feature(env, RISCV_FEATURE_MMU)) {
>>           return RISCV_EXCP_NONE;
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] target/riscv: Fix satp write
  2021-09-02  1:02     ` LIU Zhiwei
@ 2021-09-02  1:59       ` Bin Meng
  -1 siblings, 0 replies; 22+ messages in thread
From: Bin Meng @ 2021-09-02  1:59 UTC (permalink / raw)
  To: LIU Zhiwei
  Cc: open list:RISC-V, Bin Meng, Richard Henderson,
	qemu-devel@nongnu.org Developers, Palmer Dabbelt,
	Alistair Francis

On Thu, Sep 2, 2021 at 9:02 AM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
>
>
> On 2021/9/1 下午9:05, Bin Meng wrote:
> > On Wed, Sep 1, 2021 at 8:51 PM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
> >> These variables should be target_ulong. If truncated to int,
> >> the bool conditions they indicate will be wrong.
> >>
> >> As satp is very important for Linux, this bug almost fails every boot.
> > Could you please describe which Linux configuration is broken?
>
> I use the image from:
>
> https://gitlab.com/c-sky/buildroot/-/jobs/1251564514/artifacts/browse/output/images/
>
> >   I have
> > a 64-bit 5.10 kernel and it boots fine.
>
> The login is mostly OK for me. But the busybox can't run properly.

Which kernel version is this? Could you please investigate and
indicate in the commit message?

I just tested current qemu-system-riscv64 can boot to Ubuntu 20.04
distro user space.

Regards,
Bin


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] target/riscv: Fix satp write
@ 2021-09-02  1:59       ` Bin Meng
  0 siblings, 0 replies; 22+ messages in thread
From: Bin Meng @ 2021-09-02  1:59 UTC (permalink / raw)
  To: LIU Zhiwei
  Cc: qemu-devel@nongnu.org Developers, open list:RISC-V,
	Palmer Dabbelt, Richard Henderson, Bin Meng, Alistair Francis

On Thu, Sep 2, 2021 at 9:02 AM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
>
>
> On 2021/9/1 下午9:05, Bin Meng wrote:
> > On Wed, Sep 1, 2021 at 8:51 PM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
> >> These variables should be target_ulong. If truncated to int,
> >> the bool conditions they indicate will be wrong.
> >>
> >> As satp is very important for Linux, this bug almost fails every boot.
> > Could you please describe which Linux configuration is broken?
>
> I use the image from:
>
> https://gitlab.com/c-sky/buildroot/-/jobs/1251564514/artifacts/browse/output/images/
>
> >   I have
> > a 64-bit 5.10 kernel and it boots fine.
>
> The login is mostly OK for me. But the busybox can't run properly.

Which kernel version is this? Could you please investigate and
indicate in the commit message?

I just tested current qemu-system-riscv64 can boot to Ubuntu 20.04
distro user space.

Regards,
Bin


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] target/riscv: Fix satp write
  2021-09-02  1:59       ` Bin Meng
@ 2021-09-02  2:44         ` LIU Zhiwei
  -1 siblings, 0 replies; 22+ messages in thread
From: LIU Zhiwei @ 2021-09-02  2:44 UTC (permalink / raw)
  To: Bin Meng
  Cc: open list:RISC-V, Bin Meng, Richard Henderson,
	qemu-devel@nongnu.org Developers, Palmer Dabbelt,
	Alistair Francis


On 2021/9/2 上午9:59, Bin Meng wrote:
> On Thu, Sep 2, 2021 at 9:02 AM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
>>
>> On 2021/9/1 下午9:05, Bin Meng wrote:
>>> On Wed, Sep 1, 2021 at 8:51 PM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
>>>> These variables should be target_ulong. If truncated to int,
>>>> the bool conditions they indicate will be wrong.
>>>>
>>>> As satp is very important for Linux, this bug almost fails every boot.
>>> Could you please describe which Linux configuration is broken?
>> I use the image from:
>>
>> https://gitlab.com/c-sky/buildroot/-/jobs/1251564514/artifacts/browse/output/images/
>>
>>>    I have
>>> a 64-bit 5.10 kernel and it boots fine.
>> The login is mostly OK for me. But the busybox can't run properly.
> Which kernel version is this?
5.10.4
> Could you please investigate and
> indicate in the commit message?
>
> I just tested current qemu-system-riscv64 can boot to Ubuntu 20.04
> distro user space.

Very strange.  This will cause tlb_flush can't be called in this function.

Thanks,
Zhiwei

>
> Regards,
> Bin


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] target/riscv: Fix satp write
@ 2021-09-02  2:44         ` LIU Zhiwei
  0 siblings, 0 replies; 22+ messages in thread
From: LIU Zhiwei @ 2021-09-02  2:44 UTC (permalink / raw)
  To: Bin Meng
  Cc: qemu-devel@nongnu.org Developers, open list:RISC-V,
	Palmer Dabbelt, Richard Henderson, Bin Meng, Alistair Francis


On 2021/9/2 上午9:59, Bin Meng wrote:
> On Thu, Sep 2, 2021 at 9:02 AM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
>>
>> On 2021/9/1 下午9:05, Bin Meng wrote:
>>> On Wed, Sep 1, 2021 at 8:51 PM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
>>>> These variables should be target_ulong. If truncated to int,
>>>> the bool conditions they indicate will be wrong.
>>>>
>>>> As satp is very important for Linux, this bug almost fails every boot.
>>> Could you please describe which Linux configuration is broken?
>> I use the image from:
>>
>> https://gitlab.com/c-sky/buildroot/-/jobs/1251564514/artifacts/browse/output/images/
>>
>>>    I have
>>> a 64-bit 5.10 kernel and it boots fine.
>> The login is mostly OK for me. But the busybox can't run properly.
> Which kernel version is this?
5.10.4
> Could you please investigate and
> indicate in the commit message?
>
> I just tested current qemu-system-riscv64 can boot to Ubuntu 20.04
> distro user space.

Very strange.  This will cause tlb_flush can't be called in this function.

Thanks,
Zhiwei

>
> Regards,
> Bin


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] target/riscv: Fix satp write
  2021-09-02  2:44         ` LIU Zhiwei
@ 2021-09-02  2:47           ` Bin Meng
  -1 siblings, 0 replies; 22+ messages in thread
From: Bin Meng @ 2021-09-02  2:47 UTC (permalink / raw)
  To: LIU Zhiwei
  Cc: open list:RISC-V, Bin Meng, Richard Henderson,
	qemu-devel@nongnu.org Developers, Palmer Dabbelt,
	Alistair Francis

On Thu, Sep 2, 2021 at 10:44 AM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
>
>
> On 2021/9/2 上午9:59, Bin Meng wrote:
> > On Thu, Sep 2, 2021 at 9:02 AM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
> >>
> >> On 2021/9/1 下午9:05, Bin Meng wrote:
> >>> On Wed, Sep 1, 2021 at 8:51 PM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
> >>>> These variables should be target_ulong. If truncated to int,
> >>>> the bool conditions they indicate will be wrong.
> >>>>
> >>>> As satp is very important for Linux, this bug almost fails every boot.
> >>> Could you please describe which Linux configuration is broken?
> >> I use the image from:
> >>
> >> https://gitlab.com/c-sky/buildroot/-/jobs/1251564514/artifacts/browse/output/images/
> >>
> >>>    I have
> >>> a 64-bit 5.10 kernel and it boots fine.
> >> The login is mostly OK for me. But the busybox can't run properly.
> > Which kernel version is this?
> 5.10.4
> > Could you please investigate and
> > indicate in the commit message?
> >
> > I just tested current qemu-system-riscv64 can boot to Ubuntu 20.04
> > distro user space.
>
> Very strange.  This will cause tlb_flush can't be called in this function.
>

Did your kernel enable asid?

Regards,
Bin


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] target/riscv: Fix satp write
@ 2021-09-02  2:47           ` Bin Meng
  0 siblings, 0 replies; 22+ messages in thread
From: Bin Meng @ 2021-09-02  2:47 UTC (permalink / raw)
  To: LIU Zhiwei
  Cc: qemu-devel@nongnu.org Developers, open list:RISC-V,
	Palmer Dabbelt, Richard Henderson, Bin Meng, Alistair Francis

On Thu, Sep 2, 2021 at 10:44 AM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
>
>
> On 2021/9/2 上午9:59, Bin Meng wrote:
> > On Thu, Sep 2, 2021 at 9:02 AM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
> >>
> >> On 2021/9/1 下午9:05, Bin Meng wrote:
> >>> On Wed, Sep 1, 2021 at 8:51 PM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
> >>>> These variables should be target_ulong. If truncated to int,
> >>>> the bool conditions they indicate will be wrong.
> >>>>
> >>>> As satp is very important for Linux, this bug almost fails every boot.
> >>> Could you please describe which Linux configuration is broken?
> >> I use the image from:
> >>
> >> https://gitlab.com/c-sky/buildroot/-/jobs/1251564514/artifacts/browse/output/images/
> >>
> >>>    I have
> >>> a 64-bit 5.10 kernel and it boots fine.
> >> The login is mostly OK for me. But the busybox can't run properly.
> > Which kernel version is this?
> 5.10.4
> > Could you please investigate and
> > indicate in the commit message?
> >
> > I just tested current qemu-system-riscv64 can boot to Ubuntu 20.04
> > distro user space.
>
> Very strange.  This will cause tlb_flush can't be called in this function.
>

Did your kernel enable asid?

Regards,
Bin


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] target/riscv: Fix satp write
  2021-09-02  1:59       ` Bin Meng
@ 2021-09-02  2:49         ` Alistair Francis
  -1 siblings, 0 replies; 22+ messages in thread
From: Alistair Francis @ 2021-09-02  2:49 UTC (permalink / raw)
  To: Bin Meng
  Cc: open list:RISC-V, Bin Meng, Richard Henderson,
	qemu-devel@nongnu.org Developers, Palmer Dabbelt,
	Alistair Francis, LIU Zhiwei

On Thu, Sep 2, 2021 at 11:59 AM Bin Meng <bmeng.cn@gmail.com> wrote:
>
> On Thu, Sep 2, 2021 at 9:02 AM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
> >
> >
> > On 2021/9/1 下午9:05, Bin Meng wrote:
> > > On Wed, Sep 1, 2021 at 8:51 PM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
> > >> These variables should be target_ulong. If truncated to int,
> > >> the bool conditions they indicate will be wrong.
> > >>
> > >> As satp is very important for Linux, this bug almost fails every boot.
> > > Could you please describe which Linux configuration is broken?
> >
> > I use the image from:
> >
> > https://gitlab.com/c-sky/buildroot/-/jobs/1251564514/artifacts/browse/output/images/
> >
> > >   I have
> > > a 64-bit 5.10 kernel and it boots fine.
> >
> > The login is mostly OK for me. But the busybox can't run properly.
>
> Which kernel version is this? Could you please investigate and
> indicate in the commit message?
>
> I just tested current qemu-system-riscv64 can boot to Ubuntu 20.04
> distro user space.

I also have never seen any issues.

Looking at this `vm` is set from a `static const char
valid_vm_1_10_64` so an int is fine.

It probably is a good idea for `mask` and `asid` to be target_ulong as
they are set by bit operations on target_ulong's. I guess if your host
int is 32-bits SATP64_ASID will overflow that.

Anyway with 128-bit RISC-V and maybe the ability to run 64-bit guests
no 32-bit hosts this seems like a good step

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

>
> Regards,
> Bin
>


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] target/riscv: Fix satp write
@ 2021-09-02  2:49         ` Alistair Francis
  0 siblings, 0 replies; 22+ messages in thread
From: Alistair Francis @ 2021-09-02  2:49 UTC (permalink / raw)
  To: Bin Meng
  Cc: LIU Zhiwei, open list:RISC-V, Bin Meng, Richard Henderson,
	qemu-devel@nongnu.org Developers, Palmer Dabbelt,
	Alistair Francis

On Thu, Sep 2, 2021 at 11:59 AM Bin Meng <bmeng.cn@gmail.com> wrote:
>
> On Thu, Sep 2, 2021 at 9:02 AM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
> >
> >
> > On 2021/9/1 下午9:05, Bin Meng wrote:
> > > On Wed, Sep 1, 2021 at 8:51 PM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
> > >> These variables should be target_ulong. If truncated to int,
> > >> the bool conditions they indicate will be wrong.
> > >>
> > >> As satp is very important for Linux, this bug almost fails every boot.
> > > Could you please describe which Linux configuration is broken?
> >
> > I use the image from:
> >
> > https://gitlab.com/c-sky/buildroot/-/jobs/1251564514/artifacts/browse/output/images/
> >
> > >   I have
> > > a 64-bit 5.10 kernel and it boots fine.
> >
> > The login is mostly OK for me. But the busybox can't run properly.
>
> Which kernel version is this? Could you please investigate and
> indicate in the commit message?
>
> I just tested current qemu-system-riscv64 can boot to Ubuntu 20.04
> distro user space.

I also have never seen any issues.

Looking at this `vm` is set from a `static const char
valid_vm_1_10_64` so an int is fine.

It probably is a good idea for `mask` and `asid` to be target_ulong as
they are set by bit operations on target_ulong's. I guess if your host
int is 32-bits SATP64_ASID will overflow that.

Anyway with 128-bit RISC-V and maybe the ability to run 64-bit guests
no 32-bit hosts this seems like a good step

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

>
> Regards,
> Bin
>


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] target/riscv: Fix satp write
  2021-09-02  2:47           ` Bin Meng
@ 2021-09-06  3:23             ` LIU Zhiwei
  -1 siblings, 0 replies; 22+ messages in thread
From: LIU Zhiwei @ 2021-09-06  3:23 UTC (permalink / raw)
  To: Bin Meng
  Cc: open list:RISC-V, Bin Meng, Richard Henderson,
	qemu-devel@nongnu.org Developers, Palmer Dabbelt,
	Alistair Francis


On 2021/9/2 上午10:47, Bin Meng wrote:
> On Thu, Sep 2, 2021 at 10:44 AM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
>>
>> On 2021/9/2 上午9:59, Bin Meng wrote:
>>> On Thu, Sep 2, 2021 at 9:02 AM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
>>>> On 2021/9/1 下午9:05, Bin Meng wrote:
>>>>> On Wed, Sep 1, 2021 at 8:51 PM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
>>>>>> These variables should be target_ulong. If truncated to int,
>>>>>> the bool conditions they indicate will be wrong.
>>>>>>
>>>>>> As satp is very important for Linux, this bug almost fails every boot.
>>>>> Could you please describe which Linux configuration is broken?
>>>> I use the image from:
>>>>
>>>> https://gitlab.com/c-sky/buildroot/-/jobs/1251564514/artifacts/browse/output/images/
>>>>
>>>>>     I have
>>>>> a 64-bit 5.10 kernel and it boots fine.
>>>> The login is mostly OK for me. But the busybox can't run properly.
>>> Which kernel version is this?
>> 5.10.4
>>> Could you please investigate and
>>> indicate in the commit message?
>>>
>>> I just tested current qemu-system-riscv64 can boot to Ubuntu 20.04
>>> distro user space.
>> Very strange.  This will cause tlb_flush can't be called in this function.
>>
> Did your kernel enable asid?

Yes. Is it matter?

Thanks,
Zhiwei

>
> Regards,
> Bin


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] target/riscv: Fix satp write
@ 2021-09-06  3:23             ` LIU Zhiwei
  0 siblings, 0 replies; 22+ messages in thread
From: LIU Zhiwei @ 2021-09-06  3:23 UTC (permalink / raw)
  To: Bin Meng
  Cc: qemu-devel@nongnu.org Developers, open list:RISC-V,
	Palmer Dabbelt, Richard Henderson, Bin Meng, Alistair Francis


On 2021/9/2 上午10:47, Bin Meng wrote:
> On Thu, Sep 2, 2021 at 10:44 AM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
>>
>> On 2021/9/2 上午9:59, Bin Meng wrote:
>>> On Thu, Sep 2, 2021 at 9:02 AM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
>>>> On 2021/9/1 下午9:05, Bin Meng wrote:
>>>>> On Wed, Sep 1, 2021 at 8:51 PM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
>>>>>> These variables should be target_ulong. If truncated to int,
>>>>>> the bool conditions they indicate will be wrong.
>>>>>>
>>>>>> As satp is very important for Linux, this bug almost fails every boot.
>>>>> Could you please describe which Linux configuration is broken?
>>>> I use the image from:
>>>>
>>>> https://gitlab.com/c-sky/buildroot/-/jobs/1251564514/artifacts/browse/output/images/
>>>>
>>>>>     I have
>>>>> a 64-bit 5.10 kernel and it boots fine.
>>>> The login is mostly OK for me. But the busybox can't run properly.
>>> Which kernel version is this?
>> 5.10.4
>>> Could you please investigate and
>>> indicate in the commit message?
>>>
>>> I just tested current qemu-system-riscv64 can boot to Ubuntu 20.04
>>> distro user space.
>> Very strange.  This will cause tlb_flush can't be called in this function.
>>
> Did your kernel enable asid?

Yes. Is it matter?

Thanks,
Zhiwei

>
> Regards,
> Bin


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] target/riscv: Fix satp write
  2021-09-06  3:23             ` LIU Zhiwei
@ 2021-09-06  3:26               ` Bin Meng
  -1 siblings, 0 replies; 22+ messages in thread
From: Bin Meng @ 2021-09-06  3:26 UTC (permalink / raw)
  To: LIU Zhiwei
  Cc: open list:RISC-V, Bin Meng, Richard Henderson,
	qemu-devel@nongnu.org Developers, Palmer Dabbelt,
	Alistair Francis

On Mon, Sep 6, 2021 at 11:23 AM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
>
>
> On 2021/9/2 上午10:47, Bin Meng wrote:
> > On Thu, Sep 2, 2021 at 10:44 AM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
> >>
> >> On 2021/9/2 上午9:59, Bin Meng wrote:
> >>> On Thu, Sep 2, 2021 at 9:02 AM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
> >>>> On 2021/9/1 下午9:05, Bin Meng wrote:
> >>>>> On Wed, Sep 1, 2021 at 8:51 PM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
> >>>>>> These variables should be target_ulong. If truncated to int,
> >>>>>> the bool conditions they indicate will be wrong.
> >>>>>>
> >>>>>> As satp is very important for Linux, this bug almost fails every boot.
> >>>>> Could you please describe which Linux configuration is broken?
> >>>> I use the image from:
> >>>>
> >>>> https://gitlab.com/c-sky/buildroot/-/jobs/1251564514/artifacts/browse/output/images/
> >>>>
> >>>>>     I have
> >>>>> a 64-bit 5.10 kernel and it boots fine.
> >>>> The login is mostly OK for me. But the busybox can't run properly.
> >>> Which kernel version is this?
> >> 5.10.4
> >>> Could you please investigate and
> >>> indicate in the commit message?
> >>>
> >>> I just tested current qemu-system-riscv64 can boot to Ubuntu 20.04
> >>> distro user space.
> >> Very strange.  This will cause tlb_flush can't be called in this function.
> >>
> > Did your kernel enable asid?
>
> Yes. Is it matter?

Not sure, the tbl_flush is on the ASID path. I suspect the kernel we
(Alistair and me) tested did not enable ASID.

Regards,
Bin


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] target/riscv: Fix satp write
@ 2021-09-06  3:26               ` Bin Meng
  0 siblings, 0 replies; 22+ messages in thread
From: Bin Meng @ 2021-09-06  3:26 UTC (permalink / raw)
  To: LIU Zhiwei
  Cc: qemu-devel@nongnu.org Developers, open list:RISC-V,
	Palmer Dabbelt, Richard Henderson, Bin Meng, Alistair Francis

On Mon, Sep 6, 2021 at 11:23 AM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
>
>
> On 2021/9/2 上午10:47, Bin Meng wrote:
> > On Thu, Sep 2, 2021 at 10:44 AM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
> >>
> >> On 2021/9/2 上午9:59, Bin Meng wrote:
> >>> On Thu, Sep 2, 2021 at 9:02 AM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
> >>>> On 2021/9/1 下午9:05, Bin Meng wrote:
> >>>>> On Wed, Sep 1, 2021 at 8:51 PM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
> >>>>>> These variables should be target_ulong. If truncated to int,
> >>>>>> the bool conditions they indicate will be wrong.
> >>>>>>
> >>>>>> As satp is very important for Linux, this bug almost fails every boot.
> >>>>> Could you please describe which Linux configuration is broken?
> >>>> I use the image from:
> >>>>
> >>>> https://gitlab.com/c-sky/buildroot/-/jobs/1251564514/artifacts/browse/output/images/
> >>>>
> >>>>>     I have
> >>>>> a 64-bit 5.10 kernel and it boots fine.
> >>>> The login is mostly OK for me. But the busybox can't run properly.
> >>> Which kernel version is this?
> >> 5.10.4
> >>> Could you please investigate and
> >>> indicate in the commit message?
> >>>
> >>> I just tested current qemu-system-riscv64 can boot to Ubuntu 20.04
> >>> distro user space.
> >> Very strange.  This will cause tlb_flush can't be called in this function.
> >>
> > Did your kernel enable asid?
>
> Yes. Is it matter?

Not sure, the tbl_flush is on the ASID path. I suspect the kernel we
(Alistair and me) tested did not enable ASID.

Regards,
Bin


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] target/riscv: Fix satp write
  2021-09-01 12:45 ` LIU Zhiwei
@ 2021-09-06  5:29   ` Alistair Francis
  -1 siblings, 0 replies; 22+ messages in thread
From: Alistair Francis @ 2021-09-06  5:29 UTC (permalink / raw)
  To: LIU Zhiwei
  Cc: open list:RISC-V, Bin Meng, Richard Henderson,
	qemu-devel@nongnu.org Developers, Palmer Dabbelt,
	Alistair Francis

On Wed, Sep 1, 2021 at 10:51 PM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
>
> These variables should be target_ulong. If truncated to int,
> the bool conditions they indicate will be wrong.
>
> As satp is very important for Linux, this bug almost fails every boot.
>
> Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com>

Thanks!

Applied to riscv-to-apply.next

Alistair

> ---
>  target/riscv/csr.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/target/riscv/csr.c b/target/riscv/csr.c
> index 50a2c3a3b4..ba9818f6a5 100644
> --- a/target/riscv/csr.c
> +++ b/target/riscv/csr.c
> @@ -986,7 +986,7 @@ static RISCVException read_satp(CPURISCVState *env, int csrno,
>  static RISCVException write_satp(CPURISCVState *env, int csrno,
>                                   target_ulong val)
>  {
> -    int vm, mask, asid;
> +    target_ulong vm, mask, asid;
>
>      if (!riscv_feature(env, RISCV_FEATURE_MMU)) {
>          return RISCV_EXCP_NONE;
> --
> 2.25.1
>
>


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] target/riscv: Fix satp write
@ 2021-09-06  5:29   ` Alistair Francis
  0 siblings, 0 replies; 22+ messages in thread
From: Alistair Francis @ 2021-09-06  5:29 UTC (permalink / raw)
  To: LIU Zhiwei
  Cc: qemu-devel@nongnu.org Developers, open list:RISC-V,
	Palmer Dabbelt, Richard Henderson, Bin Meng, Alistair Francis

On Wed, Sep 1, 2021 at 10:51 PM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
>
> These variables should be target_ulong. If truncated to int,
> the bool conditions they indicate will be wrong.
>
> As satp is very important for Linux, this bug almost fails every boot.
>
> Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com>

Thanks!

Applied to riscv-to-apply.next

Alistair

> ---
>  target/riscv/csr.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/target/riscv/csr.c b/target/riscv/csr.c
> index 50a2c3a3b4..ba9818f6a5 100644
> --- a/target/riscv/csr.c
> +++ b/target/riscv/csr.c
> @@ -986,7 +986,7 @@ static RISCVException read_satp(CPURISCVState *env, int csrno,
>  static RISCVException write_satp(CPURISCVState *env, int csrno,
>                                   target_ulong val)
>  {
> -    int vm, mask, asid;
> +    target_ulong vm, mask, asid;
>
>      if (!riscv_feature(env, RISCV_FEATURE_MMU)) {
>          return RISCV_EXCP_NONE;
> --
> 2.25.1
>
>


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] target/riscv: Fix satp write
  2021-09-06  3:26               ` Bin Meng
@ 2021-09-06  5:31                 ` LIU Zhiwei
  -1 siblings, 0 replies; 22+ messages in thread
From: LIU Zhiwei @ 2021-09-06  5:31 UTC (permalink / raw)
  To: Bin Meng
  Cc: open list:RISC-V, Bin Meng, Richard Henderson,
	qemu-devel@nongnu.org Developers, Palmer Dabbelt,
	Alistair Francis


On 2021/9/6 上午11:26, Bin Meng wrote:
> On Mon, Sep 6, 2021 at 11:23 AM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
>>
>> On 2021/9/2 上午10:47, Bin Meng wrote:
>>> On Thu, Sep 2, 2021 at 10:44 AM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
>>>> On 2021/9/2 上午9:59, Bin Meng wrote:
>>>>> On Thu, Sep 2, 2021 at 9:02 AM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
>>>>>> On 2021/9/1 下午9:05, Bin Meng wrote:
>>>>>>> On Wed, Sep 1, 2021 at 8:51 PM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
>>>>>>>> These variables should be target_ulong. If truncated to int,
>>>>>>>> the bool conditions they indicate will be wrong.
>>>>>>>>
>>>>>>>> As satp is very important for Linux, this bug almost fails every boot.
>>>>>>> Could you please describe which Linux configuration is broken?
>>>>>> I use the image from:
>>>>>>
>>>>>> https://gitlab.com/c-sky/buildroot/-/jobs/1251564514/artifacts/browse/output/images/
>>>>>>
>>>>>>>      I have
>>>>>>> a 64-bit 5.10 kernel and it boots fine.
>>>>>> The login is mostly OK for me. But the busybox can't run properly.
>>>>> Which kernel version is this?
>>>> 5.10.4
>>>>> Could you please investigate and
>>>>> indicate in the commit message?
>>>>>
>>>>> I just tested current qemu-system-riscv64 can boot to Ubuntu 20.04
>>>>> distro user space.
>>>> Very strange.  This will cause tlb_flush can't be called in this function.
>>>>
>>> Did your kernel enable asid?
>> Yes. Is it matter?
> Not sure, the tbl_flush is on the ASID path. I suspect the kernel we
> (Alistair and me) tested did not enable ASID.
In my opinion, if the ASID is open, we should not flush tlb when ASID 
changes in most cases.
If ASID is not open.
> Regards,
> Bin


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH] target/riscv: Fix satp write
@ 2021-09-06  5:31                 ` LIU Zhiwei
  0 siblings, 0 replies; 22+ messages in thread
From: LIU Zhiwei @ 2021-09-06  5:31 UTC (permalink / raw)
  To: Bin Meng
  Cc: qemu-devel@nongnu.org Developers, open list:RISC-V,
	Palmer Dabbelt, Richard Henderson, Bin Meng, Alistair Francis


On 2021/9/6 上午11:26, Bin Meng wrote:
> On Mon, Sep 6, 2021 at 11:23 AM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
>>
>> On 2021/9/2 上午10:47, Bin Meng wrote:
>>> On Thu, Sep 2, 2021 at 10:44 AM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
>>>> On 2021/9/2 上午9:59, Bin Meng wrote:
>>>>> On Thu, Sep 2, 2021 at 9:02 AM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
>>>>>> On 2021/9/1 下午9:05, Bin Meng wrote:
>>>>>>> On Wed, Sep 1, 2021 at 8:51 PM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
>>>>>>>> These variables should be target_ulong. If truncated to int,
>>>>>>>> the bool conditions they indicate will be wrong.
>>>>>>>>
>>>>>>>> As satp is very important for Linux, this bug almost fails every boot.
>>>>>>> Could you please describe which Linux configuration is broken?
>>>>>> I use the image from:
>>>>>>
>>>>>> https://gitlab.com/c-sky/buildroot/-/jobs/1251564514/artifacts/browse/output/images/
>>>>>>
>>>>>>>      I have
>>>>>>> a 64-bit 5.10 kernel and it boots fine.
>>>>>> The login is mostly OK for me. But the busybox can't run properly.
>>>>> Which kernel version is this?
>>>> 5.10.4
>>>>> Could you please investigate and
>>>>> indicate in the commit message?
>>>>>
>>>>> I just tested current qemu-system-riscv64 can boot to Ubuntu 20.04
>>>>> distro user space.
>>>> Very strange.  This will cause tlb_flush can't be called in this function.
>>>>
>>> Did your kernel enable asid?
>> Yes. Is it matter?
> Not sure, the tbl_flush is on the ASID path. I suspect the kernel we
> (Alistair and me) tested did not enable ASID.
In my opinion, if the ASID is open, we should not flush tlb when ASID 
changes in most cases.
If ASID is not open.
> Regards,
> Bin


^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2021-09-06  5:32 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-01 12:45 [PATCH] target/riscv: Fix satp write LIU Zhiwei
2021-09-01 12:45 ` LIU Zhiwei
2021-09-01 13:05 ` Bin Meng
2021-09-01 13:05   ` Bin Meng
2021-09-02  1:02   ` LIU Zhiwei
2021-09-02  1:02     ` LIU Zhiwei
2021-09-02  1:59     ` Bin Meng
2021-09-02  1:59       ` Bin Meng
2021-09-02  2:44       ` LIU Zhiwei
2021-09-02  2:44         ` LIU Zhiwei
2021-09-02  2:47         ` Bin Meng
2021-09-02  2:47           ` Bin Meng
2021-09-06  3:23           ` LIU Zhiwei
2021-09-06  3:23             ` LIU Zhiwei
2021-09-06  3:26             ` Bin Meng
2021-09-06  3:26               ` Bin Meng
2021-09-06  5:31               ` LIU Zhiwei
2021-09-06  5:31                 ` LIU Zhiwei
2021-09-02  2:49       ` Alistair Francis
2021-09-02  2:49         ` Alistair Francis
2021-09-06  5:29 ` Alistair Francis
2021-09-06  5:29   ` Alistair Francis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.