* [PATCH 1/2] hw/arm/orangepi: check for potential NULL pointer when calling blk_is_available
@ 2020-03-22 20:54 Niek Linnenbank
2020-03-22 20:54 ` [PATCH 2/2] hw/misc/allwinner-h3-dramc: enforce 64-bit multiply when calculating row mirror address Niek Linnenbank
2020-03-26 20:59 ` [PATCH 1/2] hw/arm/orangepi: check for potential NULL pointer when calling blk_is_available Peter Maydell
0 siblings, 2 replies; 5+ messages in thread
From: Niek Linnenbank @ 2020-03-22 20:54 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, Niek Linnenbank, qemu-arm
The Orange Pi PC initialization function needs to verify that the SD card
block backend is usable before calling the Boot ROM setup routine. When
calling blk_is_available() the input parameter should not be NULL.
This commit ensures that blk_is_available is only called with non-NULL input.
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Niek Linnenbank <nieklinnenbank@gmail.com>
---
hw/arm/orangepi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/arm/orangepi.c b/hw/arm/orangepi.c
index 181f5badab..a9f64c5680 100644
--- a/hw/arm/orangepi.c
+++ b/hw/arm/orangepi.c
@@ -104,7 +104,7 @@ static void orangepi_init(MachineState *machine)
machine->ram);
/* Load target kernel or start using BootROM */
- if (!machine->kernel_filename && blk_is_available(blk)) {
+ if (!machine->kernel_filename && blk && blk_is_available(blk)) {
/* Use Boot ROM to copy data from SD card to SRAM */
allwinner_h3_bootrom_setup(h3, blk);
}
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] hw/misc/allwinner-h3-dramc: enforce 64-bit multiply when calculating row mirror address
2020-03-22 20:54 [PATCH 1/2] hw/arm/orangepi: check for potential NULL pointer when calling blk_is_available Niek Linnenbank
@ 2020-03-22 20:54 ` Niek Linnenbank
2020-03-22 21:18 ` Peter Maydell
2020-03-26 20:59 ` [PATCH 1/2] hw/arm/orangepi: check for potential NULL pointer when calling blk_is_available Peter Maydell
1 sibling, 1 reply; 5+ messages in thread
From: Niek Linnenbank @ 2020-03-22 20:54 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, Niek Linnenbank, qemu-arm
The allwinner_h3_dramc_map_rows function simulates row addressing behavior
when bootloader software attempts to detect the amount of available SDRAM.
Currently the line that calculates the 64-bit address of the mirrored row
uses a signed 32-bit multiply operation that in theory could result in the
upper 32-bit be all 1s. This commit ensures that the row mirror address
is calculated using only 64-bit operations.
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Niek Linnenbank <nieklinnenbank@gmail.com>
---
hw/misc/allwinner-h3-dramc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/misc/allwinner-h3-dramc.c b/hw/misc/allwinner-h3-dramc.c
index 2b5260260e..f9f05b5384 100644
--- a/hw/misc/allwinner-h3-dramc.c
+++ b/hw/misc/allwinner-h3-dramc.c
@@ -85,8 +85,8 @@ static void allwinner_h3_dramc_map_rows(AwH3DramCtlState *s, uint8_t row_bits,
} else if (row_bits_actual) {
/* Row bits not matching ram_size, install the rows mirror */
- hwaddr row_mirror = s->ram_addr + ((1 << (row_bits_actual +
- bank_bits)) * page_size);
+ hwaddr row_mirror = s->ram_addr + ((1UL << (row_bits_actual +
+ bank_bits)) * page_size);
memory_region_set_enabled(&s->row_mirror_alias, true);
memory_region_set_address(&s->row_mirror_alias, row_mirror);
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] hw/misc/allwinner-h3-dramc: enforce 64-bit multiply when calculating row mirror address
2020-03-22 20:54 ` [PATCH 2/2] hw/misc/allwinner-h3-dramc: enforce 64-bit multiply when calculating row mirror address Niek Linnenbank
@ 2020-03-22 21:18 ` Peter Maydell
2020-03-23 19:27 ` Niek Linnenbank
0 siblings, 1 reply; 5+ messages in thread
From: Peter Maydell @ 2020-03-22 21:18 UTC (permalink / raw)
To: Niek Linnenbank; +Cc: qemu-arm, QEMU Developers
On Sun, 22 Mar 2020 at 20:54, Niek Linnenbank <nieklinnenbank@gmail.com> wrote:
>
> The allwinner_h3_dramc_map_rows function simulates row addressing behavior
> when bootloader software attempts to detect the amount of available SDRAM.
>
> Currently the line that calculates the 64-bit address of the mirrored row
> uses a signed 32-bit multiply operation that in theory could result in the
> upper 32-bit be all 1s. This commit ensures that the row mirror address
> is calculated using only 64-bit operations.
>
> Reported-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Niek Linnenbank <nieklinnenbank@gmail.com>
> ---
> hw/misc/allwinner-h3-dramc.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/hw/misc/allwinner-h3-dramc.c b/hw/misc/allwinner-h3-dramc.c
> index 2b5260260e..f9f05b5384 100644
> --- a/hw/misc/allwinner-h3-dramc.c
> +++ b/hw/misc/allwinner-h3-dramc.c
> @@ -85,8 +85,8 @@ static void allwinner_h3_dramc_map_rows(AwH3DramCtlState *s, uint8_t row_bits,
>
> } else if (row_bits_actual) {
> /* Row bits not matching ram_size, install the rows mirror */
> - hwaddr row_mirror = s->ram_addr + ((1 << (row_bits_actual +
> - bank_bits)) * page_size);
> + hwaddr row_mirror = s->ram_addr + ((1UL << (row_bits_actual +
> + bank_bits)) * page_size);
This needs to be a "ULL" suffix... (I just sent a different email
with the rationale).
thanks
-- PMM
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] hw/misc/allwinner-h3-dramc: enforce 64-bit multiply when calculating row mirror address
2020-03-22 21:18 ` Peter Maydell
@ 2020-03-23 19:27 ` Niek Linnenbank
0 siblings, 0 replies; 5+ messages in thread
From: Niek Linnenbank @ 2020-03-23 19:27 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-arm, QEMU Developers
[-- Attachment #1: Type: text/plain, Size: 1931 bytes --]
Hi Peter,
On Sun, Mar 22, 2020 at 10:18 PM Peter Maydell <peter.maydell@linaro.org>
wrote:
> On Sun, 22 Mar 2020 at 20:54, Niek Linnenbank <nieklinnenbank@gmail.com>
> wrote:
> >
> > The allwinner_h3_dramc_map_rows function simulates row addressing
> behavior
> > when bootloader software attempts to detect the amount of available
> SDRAM.
> >
> > Currently the line that calculates the 64-bit address of the mirrored row
> > uses a signed 32-bit multiply operation that in theory could result in
> the
> > upper 32-bit be all 1s. This commit ensures that the row mirror address
> > is calculated using only 64-bit operations.
> >
> > Reported-by: Peter Maydell <peter.maydell@linaro.org>
> > Signed-off-by: Niek Linnenbank <nieklinnenbank@gmail.com>
> > ---
> > hw/misc/allwinner-h3-dramc.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/hw/misc/allwinner-h3-dramc.c b/hw/misc/allwinner-h3-dramc.c
> > index 2b5260260e..f9f05b5384 100644
> > --- a/hw/misc/allwinner-h3-dramc.c
> > +++ b/hw/misc/allwinner-h3-dramc.c
> > @@ -85,8 +85,8 @@ static void
> allwinner_h3_dramc_map_rows(AwH3DramCtlState *s, uint8_t row_bits,
> >
> > } else if (row_bits_actual) {
> > /* Row bits not matching ram_size, install the rows mirror */
> > - hwaddr row_mirror = s->ram_addr + ((1 << (row_bits_actual +
> > - bank_bits)) *
> page_size);
> > + hwaddr row_mirror = s->ram_addr + ((1UL << (row_bits_actual +
> > + bank_bits)) *
> page_size);
>
> This needs to be a "ULL" suffix... (I just sent a different email
> with the rationale).
>
Ah ofcourse, it should be ULL indeed. And I can't think of any reason why I
made this mistake.
I simply overlooked it, thanks. I'm resending this patch with the proper
ULL suffix.
Regards,
Niek
>
> thanks
> -- PMM
>
--
Niek Linnenbank
[-- Attachment #2: Type: text/html, Size: 3038 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] hw/arm/orangepi: check for potential NULL pointer when calling blk_is_available
2020-03-22 20:54 [PATCH 1/2] hw/arm/orangepi: check for potential NULL pointer when calling blk_is_available Niek Linnenbank
2020-03-22 20:54 ` [PATCH 2/2] hw/misc/allwinner-h3-dramc: enforce 64-bit multiply when calculating row mirror address Niek Linnenbank
@ 2020-03-26 20:59 ` Peter Maydell
1 sibling, 0 replies; 5+ messages in thread
From: Peter Maydell @ 2020-03-26 20:59 UTC (permalink / raw)
To: Niek Linnenbank; +Cc: qemu-arm, QEMU Developers
On Sun, 22 Mar 2020 at 20:54, Niek Linnenbank <nieklinnenbank@gmail.com> wrote:
>
> The Orange Pi PC initialization function needs to verify that the SD card
> block backend is usable before calling the Boot ROM setup routine. When
> calling blk_is_available() the input parameter should not be NULL.
> This commit ensures that blk_is_available is only called with non-NULL input.
>
> Reported-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Niek Linnenbank <nieklinnenbank@gmail.com>
> ---
> hw/arm/orangepi.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Applied to target-arm.next, thanks.
-- PMM
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-03-26 21:01 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-22 20:54 [PATCH 1/2] hw/arm/orangepi: check for potential NULL pointer when calling blk_is_available Niek Linnenbank
2020-03-22 20:54 ` [PATCH 2/2] hw/misc/allwinner-h3-dramc: enforce 64-bit multiply when calculating row mirror address Niek Linnenbank
2020-03-22 21:18 ` Peter Maydell
2020-03-23 19:27 ` Niek Linnenbank
2020-03-26 20:59 ` [PATCH 1/2] hw/arm/orangepi: check for potential NULL pointer when calling blk_is_available Peter Maydell
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).