qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [Bug 1814343] [NEW] Initrd not loaded on riscv32
@ 2019-02-01 22:06 Jonathan Behrens
  2019-02-01 23:15 ` Philippe Mathieu-Daudé
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Jonathan Behrens @ 2019-02-01 22:06 UTC (permalink / raw)
  To: qemu-devel

Public bug reported:

I attempted to run qemu with a ram disk. However, when reading the
contents of the disk from within the VM I only get back zeros.

I was able to trace the issue to a mismatch of expectations on line 93
of hw/riscv/virt.c. Specifically, when running in 32-bit mode the value
of kernel_entry is sign extended to 64-bits, but load_image_targphys
expects the start address to not be sign extended.

Straw man patch (works for 32-bit but would probably break 64-bit VMs?):

diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
index e7f0716fb6..32216f993c 100644
--- a/hw/riscv/virt.c
+++ b/hw/riscv/virt.c
@@ -90,7 +90,7 @@ static hwaddr load_initrd(const char *filename, uint64_t mem_size,
      * halfway into RAM, and for boards with 256MB of RAM or more we put
      * the initrd at 128MB.
      */
-    *start = kernel_entry + MIN(mem_size / 2, 128 * MiB);
+    *start = (kernel_entry & 0xffffffff) + MIN(mem_size / 2, 128 * MiB);
 
     size = load_ramdisk(filename, *start, mem_size - *start);
     if (size == -1) {


Run command:

$ qemu/build/riscv32-softmmu/qemu-system-riscv32 -machine virt -kernel
mykernel.elf -nographic -initrd payload

Commit hash:

3a183e330dbd7dbcac3841737ac874979552cca2

** Affects: qemu
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1814343

Title:
  Initrd not loaded on riscv32

Status in QEMU:
  New

Bug description:
  I attempted to run qemu with a ram disk. However, when reading the
  contents of the disk from within the VM I only get back zeros.

  I was able to trace the issue to a mismatch of expectations on line 93
  of hw/riscv/virt.c. Specifically, when running in 32-bit mode the
  value of kernel_entry is sign extended to 64-bits, but
  load_image_targphys expects the start address to not be sign extended.

  Straw man patch (works for 32-bit but would probably break 64-bit
  VMs?):

  diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
  index e7f0716fb6..32216f993c 100644
  --- a/hw/riscv/virt.c
  +++ b/hw/riscv/virt.c
  @@ -90,7 +90,7 @@ static hwaddr load_initrd(const char *filename, uint64_t mem_size,
        * halfway into RAM, and for boards with 256MB of RAM or more we put
        * the initrd at 128MB.
        */
  -    *start = kernel_entry + MIN(mem_size / 2, 128 * MiB);
  +    *start = (kernel_entry & 0xffffffff) + MIN(mem_size / 2, 128 * MiB);
   
       size = load_ramdisk(filename, *start, mem_size - *start);
       if (size == -1) {

  
  Run command:

  $ qemu/build/riscv32-softmmu/qemu-system-riscv32 -machine virt -kernel
  mykernel.elf -nographic -initrd payload

  Commit hash:

  3a183e330dbd7dbcac3841737ac874979552cca2

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1814343/+subscriptions

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

* Re: [Qemu-devel] [Bug 1814343] [NEW] Initrd not loaded on riscv32
  2019-02-01 22:06 [Qemu-devel] [Bug 1814343] [NEW] Initrd not loaded on riscv32 Jonathan Behrens
@ 2019-02-01 23:15 ` Philippe Mathieu-Daudé
  2019-02-05 18:36   ` Alistair Francis
  2019-02-01 23:16 ` [Qemu-devel] [Bug 1814343] " Philippe Mathieu-Daudé
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-02-01 23:15 UTC (permalink / raw)
  To: Bug 1814343, qemu-devel, Alistair Francis; +Cc: Alistair Francis, qemu-riscv

Hi Jonathan,

On 2/1/19 11:06 PM, Jonathan Behrens wrote:
> Public bug reported:
> 
> I attempted to run qemu with a ram disk. However, when reading the
> contents of the disk from within the VM I only get back zeros.
> 
> I was able to trace the issue to a mismatch of expectations on line 93
> of hw/riscv/virt.c. Specifically, when running in 32-bit mode the value
> of kernel_entry is sign extended to 64-bits, but load_image_targphys
> expects the start address to not be sign extended.
> 
> Straw man patch (works for 32-bit but would probably break 64-bit VMs?):
> 
> diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
> index e7f0716fb6..32216f993c 100644
> --- a/hw/riscv/virt.c
> +++ b/hw/riscv/virt.c
> @@ -90,7 +90,7 @@ static hwaddr load_initrd(const char *filename, uint64_t mem_size,
>       * halfway into RAM, and for boards with 256MB of RAM or more we put
>       * the initrd at 128MB.
>       */
> -    *start = kernel_entry + MIN(mem_size / 2, 128 * MiB);
> +    *start = (kernel_entry & 0xffffffff) + MIN(mem_size / 2, 128 * MiB);
>  
>      size = load_ramdisk(filename, *start, mem_size - *start);
>      if (size == -1) {
> 
> 
> Run command:
> 
> $ qemu/build/riscv32-softmmu/qemu-system-riscv32 -machine virt -kernel
> mykernel.elf -nographic -initrd payload
> 
> Commit hash:
> 
> 3a183e330dbd7dbcac3841737ac874979552cca2
> 
> ** Affects: qemu
>      Importance: Undecided
>          Status: New

I believe this is fixed by the following patch:
"Ensure the kernel start address is correctly cast"
https://lists.gnu.org/archive/html/qemu-devel/2019-01/msg06358.html

Can you test it?
If if works you can reply to it with a
"Tested-by: Jonathan Behrens <your-email>"
to increases the odds it get merged ;)

Thanks,

Phil.

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

* [Qemu-devel] [Bug 1814343] Re: Initrd not loaded on riscv32
  2019-02-01 22:06 [Qemu-devel] [Bug 1814343] [NEW] Initrd not loaded on riscv32 Jonathan Behrens
  2019-02-01 23:15 ` Philippe Mathieu-Daudé
@ 2019-02-01 23:16 ` Philippe Mathieu-Daudé
  2021-04-20  8:17 ` Thomas Huth
  2021-06-20  4:17 ` Launchpad Bug Tracker
  3 siblings, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-02-01 23:16 UTC (permalink / raw)
  To: qemu-devel

** Changed in: qemu
       Status: New => Confirmed

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1814343

Title:
  Initrd not loaded on riscv32

Status in QEMU:
  Confirmed

Bug description:
  I attempted to run qemu with a ram disk. However, when reading the
  contents of the disk from within the VM I only get back zeros.

  I was able to trace the issue to a mismatch of expectations on line 93
  of hw/riscv/virt.c. Specifically, when running in 32-bit mode the
  value of kernel_entry is sign extended to 64-bits, but
  load_image_targphys expects the start address to not be sign extended.

  Straw man patch (works for 32-bit but would probably break 64-bit
  VMs?):

  diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
  index e7f0716fb6..32216f993c 100644
  --- a/hw/riscv/virt.c
  +++ b/hw/riscv/virt.c
  @@ -90,7 +90,7 @@ static hwaddr load_initrd(const char *filename, uint64_t mem_size,
        * halfway into RAM, and for boards with 256MB of RAM or more we put
        * the initrd at 128MB.
        */
  -    *start = kernel_entry + MIN(mem_size / 2, 128 * MiB);
  +    *start = (kernel_entry & 0xffffffff) + MIN(mem_size / 2, 128 * MiB);
   
       size = load_ramdisk(filename, *start, mem_size - *start);
       if (size == -1) {

  
  Run command:

  $ qemu/build/riscv32-softmmu/qemu-system-riscv32 -machine virt -kernel
  mykernel.elf -nographic -initrd payload

  Commit hash:

  3a183e330dbd7dbcac3841737ac874979552cca2

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1814343/+subscriptions

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

* Re: [Qemu-devel] [Bug 1814343] [NEW] Initrd not loaded on riscv32
  2019-02-01 23:15 ` Philippe Mathieu-Daudé
@ 2019-02-05 18:36   ` Alistair Francis
  0 siblings, 0 replies; 6+ messages in thread
From: Alistair Francis @ 2019-02-05 18:36 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Bug 1814343, qemu-devel@nongnu.org Developers, Alistair Francis,
	Alistair Francis, qemu-riscv

On Fri, Feb 1, 2019 at 3:26 PM Philippe Mathieu-Daudé <philmd@redhat.com> wrote:
>
> Hi Jonathan,
>
> On 2/1/19 11:06 PM, Jonathan Behrens wrote:
> > Public bug reported:
> >
> > I attempted to run qemu with a ram disk. However, when reading the
> > contents of the disk from within the VM I only get back zeros.
> >
> > I was able to trace the issue to a mismatch of expectations on line 93
> > of hw/riscv/virt.c. Specifically, when running in 32-bit mode the value
> > of kernel_entry is sign extended to 64-bits, but load_image_targphys
> > expects the start address to not be sign extended.
> >
> > Straw man patch (works for 32-bit but would probably break 64-bit VMs?):
> >
> > diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
> > index e7f0716fb6..32216f993c 100644
> > --- a/hw/riscv/virt.c
> > +++ b/hw/riscv/virt.c
> > @@ -90,7 +90,7 @@ static hwaddr load_initrd(const char *filename, uint64_t mem_size,
> >       * halfway into RAM, and for boards with 256MB of RAM or more we put
> >       * the initrd at 128MB.
> >       */
> > -    *start = kernel_entry + MIN(mem_size / 2, 128 * MiB);
> > +    *start = (kernel_entry & 0xffffffff) + MIN(mem_size / 2, 128 * MiB);
> >
> >      size = load_ramdisk(filename, *start, mem_size - *start);
> >      if (size == -1) {
> >
> >
> > Run command:
> >
> > $ qemu/build/riscv32-softmmu/qemu-system-riscv32 -machine virt -kernel
> > mykernel.elf -nographic -initrd payload
> >
> > Commit hash:
> >
> > 3a183e330dbd7dbcac3841737ac874979552cca2
> >
> > ** Affects: qemu
> >      Importance: Undecided
> >          Status: New
>
> I believe this is fixed by the following patch:
> "Ensure the kernel start address is correctly cast"
> https://lists.gnu.org/archive/html/qemu-devel/2019-01/msg06358.html
>
> Can you test it?
> If if works you can reply to it with a
> "Tested-by: Jonathan Behrens <your-email>"
> to increases the odds it get merged ;)

Did you get a chance to test this Jonathan?

Alistair

>
> Thanks,
>
> Phil.
>

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

* [Bug 1814343] Re: Initrd not loaded on riscv32
  2019-02-01 22:06 [Qemu-devel] [Bug 1814343] [NEW] Initrd not loaded on riscv32 Jonathan Behrens
  2019-02-01 23:15 ` Philippe Mathieu-Daudé
  2019-02-01 23:16 ` [Qemu-devel] [Bug 1814343] " Philippe Mathieu-Daudé
@ 2021-04-20  8:17 ` Thomas Huth
  2021-06-20  4:17 ` Launchpad Bug Tracker
  3 siblings, 0 replies; 6+ messages in thread
From: Thomas Huth @ 2021-04-20  8:17 UTC (permalink / raw)
  To: qemu-devel

The QEMU project is currently considering to move its bug tracking to another system. For this we need to know which bugs are still valid and which could be closed already. Thus we are setting older bugs to "Incomplete" now.
If you still think this bug report here is valid, then please switch the state back to "New" within the next 60 days, otherwise this report will be marked as "Expired". Or mark it as "Fix Released" if the problem has been solved with a newer version of QEMU already. Thank you and sorry for the inconvenience.

** Changed in: qemu
       Status: Confirmed => Incomplete

** Tags added: riscv

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1814343

Title:
  Initrd not loaded on riscv32

Status in QEMU:
  Incomplete

Bug description:
  I attempted to run qemu with a ram disk. However, when reading the
  contents of the disk from within the VM I only get back zeros.

  I was able to trace the issue to a mismatch of expectations on line 93
  of hw/riscv/virt.c. Specifically, when running in 32-bit mode the
  value of kernel_entry is sign extended to 64-bits, but
  load_image_targphys expects the start address to not be sign extended.

  Straw man patch (works for 32-bit but would probably break 64-bit
  VMs?):

  diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
  index e7f0716fb6..32216f993c 100644
  --- a/hw/riscv/virt.c
  +++ b/hw/riscv/virt.c
  @@ -90,7 +90,7 @@ static hwaddr load_initrd(const char *filename, uint64_t mem_size,
        * halfway into RAM, and for boards with 256MB of RAM or more we put
        * the initrd at 128MB.
        */
  -    *start = kernel_entry + MIN(mem_size / 2, 128 * MiB);
  +    *start = (kernel_entry & 0xffffffff) + MIN(mem_size / 2, 128 * MiB);
   
       size = load_ramdisk(filename, *start, mem_size - *start);
       if (size == -1) {

  
  Run command:

  $ qemu/build/riscv32-softmmu/qemu-system-riscv32 -machine virt -kernel
  mykernel.elf -nographic -initrd payload

  Commit hash:

  3a183e330dbd7dbcac3841737ac874979552cca2

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1814343/+subscriptions


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

* [Bug 1814343] Re: Initrd not loaded on riscv32
  2019-02-01 22:06 [Qemu-devel] [Bug 1814343] [NEW] Initrd not loaded on riscv32 Jonathan Behrens
                   ` (2 preceding siblings ...)
  2021-04-20  8:17 ` Thomas Huth
@ 2021-06-20  4:17 ` Launchpad Bug Tracker
  3 siblings, 0 replies; 6+ messages in thread
From: Launchpad Bug Tracker @ 2021-06-20  4:17 UTC (permalink / raw)
  To: qemu-devel

[Expired for QEMU because there has been no activity for 60 days.]

** Changed in: qemu
       Status: Incomplete => Expired

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1814343

Title:
  Initrd not loaded on riscv32

Status in QEMU:
  Expired

Bug description:
  I attempted to run qemu with a ram disk. However, when reading the
  contents of the disk from within the VM I only get back zeros.

  I was able to trace the issue to a mismatch of expectations on line 93
  of hw/riscv/virt.c. Specifically, when running in 32-bit mode the
  value of kernel_entry is sign extended to 64-bits, but
  load_image_targphys expects the start address to not be sign extended.

  Straw man patch (works for 32-bit but would probably break 64-bit
  VMs?):

  diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
  index e7f0716fb6..32216f993c 100644
  --- a/hw/riscv/virt.c
  +++ b/hw/riscv/virt.c
  @@ -90,7 +90,7 @@ static hwaddr load_initrd(const char *filename, uint64_t mem_size,
        * halfway into RAM, and for boards with 256MB of RAM or more we put
        * the initrd at 128MB.
        */
  -    *start = kernel_entry + MIN(mem_size / 2, 128 * MiB);
  +    *start = (kernel_entry & 0xffffffff) + MIN(mem_size / 2, 128 * MiB);
   
       size = load_ramdisk(filename, *start, mem_size - *start);
       if (size == -1) {

  
  Run command:

  $ qemu/build/riscv32-softmmu/qemu-system-riscv32 -machine virt -kernel
  mykernel.elf -nographic -initrd payload

  Commit hash:

  3a183e330dbd7dbcac3841737ac874979552cca2

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1814343/+subscriptions


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

end of thread, other threads:[~2021-06-20  4:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-01 22:06 [Qemu-devel] [Bug 1814343] [NEW] Initrd not loaded on riscv32 Jonathan Behrens
2019-02-01 23:15 ` Philippe Mathieu-Daudé
2019-02-05 18:36   ` Alistair Francis
2019-02-01 23:16 ` [Qemu-devel] [Bug 1814343] " Philippe Mathieu-Daudé
2021-04-20  8:17 ` Thomas Huth
2021-06-20  4:17 ` Launchpad Bug Tracker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).