* [PATCH 0/2] MIPS misc fixes
@ 2021-11-30 21:17 Jiaxun Yang
2021-11-30 21:17 ` [PATCH 1/2] hw/mips: bootloader: Fix write_ulong Jiaxun Yang
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Jiaxun Yang @ 2021-11-30 21:17 UTC (permalink / raw)
To: qemu-devel; +Cc: f4bug
Two problems caught when I was trying to add CI job for various configurations.
Jiaxun Yang (2):
hw/mips: bootloader: Fix write_ulong
hw/mips/boston: Fix elf_load error detection
hw/mips/bootloader.c | 6 +++++-
hw/mips/boston.c | 5 +++--
2 files changed, 8 insertions(+), 3 deletions(-)
--
2.11.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/2] hw/mips: bootloader: Fix write_ulong
2021-11-30 21:17 [PATCH 0/2] MIPS misc fixes Jiaxun Yang
@ 2021-11-30 21:17 ` Jiaxun Yang
2021-11-30 21:52 ` Philippe Mathieu-Daudé
2021-11-30 21:17 ` [PATCH 2/2] hw/mips/boston: Fix load_elf error detection Jiaxun Yang
2021-12-02 18:02 ` [PATCH 0/2] MIPS misc fixes Philippe Mathieu-Daudé
2 siblings, 1 reply; 9+ messages in thread
From: Jiaxun Yang @ 2021-11-30 21:17 UTC (permalink / raw)
To: qemu-devel; +Cc: f4bug
bl_gen_write_ulong uses sd for both 32 and 64 bit CPU,
while sd is illegal on 32 bit CPUs.
Replace sd with sw on 32bit CPUs.
Fixes: 3ebbf86 ("hw/mips: Add a bootloader helper")
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
Should be backported to 6.0 onwards.
---
hw/mips/bootloader.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/hw/mips/bootloader.c b/hw/mips/bootloader.c
index 6ec8314490..99991f8b2b 100644
--- a/hw/mips/bootloader.c
+++ b/hw/mips/bootloader.c
@@ -182,7 +182,11 @@ void bl_gen_write_ulong(uint32_t **p, target_ulong addr, target_ulong val)
{
bl_gen_load_ulong(p, BL_REG_K0, val);
bl_gen_load_ulong(p, BL_REG_K1, addr);
- bl_gen_sd(p, BL_REG_K0, BL_REG_K1, 0x0);
+ if (bootcpu_supports_isa(ISA_MIPS3)) {
+ bl_gen_sd(p, BL_REG_K0, BL_REG_K1, 0x0);
+ } else {
+ bl_gen_sw(p, BL_REG_K0, BL_REG_K1, 0x0);
+ }
}
void bl_gen_write_u32(uint32_t **p, target_ulong addr, uint32_t val)
--
2.11.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/2] hw/mips/boston: Fix load_elf error detection
2021-11-30 21:17 [PATCH 0/2] MIPS misc fixes Jiaxun Yang
2021-11-30 21:17 ` [PATCH 1/2] hw/mips: bootloader: Fix write_ulong Jiaxun Yang
@ 2021-11-30 21:17 ` Jiaxun Yang
2021-11-30 21:54 ` Philippe Mathieu-Daudé
2021-12-02 18:02 ` [PATCH 0/2] MIPS misc fixes Philippe Mathieu-Daudé
2 siblings, 1 reply; 9+ messages in thread
From: Jiaxun Yang @ 2021-11-30 21:17 UTC (permalink / raw)
To: qemu-devel; +Cc: f4bug
load_elf gives negative return in case of error, not zero.
Fixes: 10e3f30 ("hw/mips/boston: Allow loading elf kernel and dtb")
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
For 6.2.
---
hw/mips/boston.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/hw/mips/boston.c b/hw/mips/boston.c
index 0e3cca5511..296e9fa2ad 100644
--- a/hw/mips/boston.c
+++ b/hw/mips/boston.c
@@ -777,14 +777,15 @@ static void boston_mach_init(MachineState *machine)
exit(1);
}
} else if (machine->kernel_filename) {
- uint64_t kernel_entry, kernel_high, kernel_size;
+ uint64_t kernel_entry, kernel_high;
+ ssize_t kernel_size;
kernel_size = load_elf(machine->kernel_filename, NULL,
cpu_mips_kseg0_to_phys, NULL,
&kernel_entry, NULL, &kernel_high,
NULL, 0, EM_MIPS, 1, 0);
- if (kernel_size) {
+ if (kernel_size > 0) {
int dt_size;
g_autofree const void *dtb_file_data, *dtb_load_data;
hwaddr dtb_paddr = QEMU_ALIGN_UP(kernel_high, 64 * KiB);
--
2.11.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] hw/mips: bootloader: Fix write_ulong
2021-11-30 21:17 ` [PATCH 1/2] hw/mips: bootloader: Fix write_ulong Jiaxun Yang
@ 2021-11-30 21:52 ` Philippe Mathieu-Daudé
2021-12-02 10:51 ` Jiaxun Yang
0 siblings, 1 reply; 9+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-11-30 21:52 UTC (permalink / raw)
To: Jiaxun Yang, qemu-devel
On 11/30/21 22:17, Jiaxun Yang wrote:
> bl_gen_write_ulong uses sd for both 32 and 64 bit CPU,
> while sd is illegal on 32 bit CPUs.
>
> Replace sd with sw on 32bit CPUs.
>
> Fixes: 3ebbf86 ("hw/mips: Add a bootloader helper")
> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> ---
> Should be backported to 6.0 onwards.
> ---
> hw/mips/bootloader.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/hw/mips/bootloader.c b/hw/mips/bootloader.c
> index 6ec8314490..99991f8b2b 100644
> --- a/hw/mips/bootloader.c
> +++ b/hw/mips/bootloader.c
> @@ -182,7 +182,11 @@ void bl_gen_write_ulong(uint32_t **p, target_ulong addr, target_ulong val)
> {
> bl_gen_load_ulong(p, BL_REG_K0, val);
> bl_gen_load_ulong(p, BL_REG_K1, addr);
> - bl_gen_sd(p, BL_REG_K0, BL_REG_K1, 0x0);
> + if (bootcpu_supports_isa(ISA_MIPS3)) {
> + bl_gen_sd(p, BL_REG_K0, BL_REG_K1, 0x0);
> + } else {
> + bl_gen_sw(p, BL_REG_K0, BL_REG_K1, 0x0);
> + }
We have bl_gen_load_ulong(); having bl_gen_store_ulong()
would make the API even. Mind sending a patch? Otherwise:
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> }
>
> void bl_gen_write_u32(uint32_t **p, target_ulong addr, uint32_t val)
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] hw/mips/boston: Fix load_elf error detection
2021-11-30 21:17 ` [PATCH 2/2] hw/mips/boston: Fix load_elf error detection Jiaxun Yang
@ 2021-11-30 21:54 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 9+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-11-30 21:54 UTC (permalink / raw)
To: Jiaxun Yang, qemu-devel
On 11/30/21 22:17, Jiaxun Yang wrote:
> load_elf gives negative return in case of error, not zero.
>
> Fixes: 10e3f30 ("hw/mips/boston: Allow loading elf kernel and dtb")
> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> ---
> For 6.2.
> ---
> hw/mips/boston.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] hw/mips: bootloader: Fix write_ulong
2021-11-30 21:52 ` Philippe Mathieu-Daudé
@ 2021-12-02 10:51 ` Jiaxun Yang
2021-12-02 18:01 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 9+ messages in thread
From: Jiaxun Yang @ 2021-12-02 10:51 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, BALATON Zoltan via
在2021年11月30日十一月 下午9:52,Philippe Mathieu-Daudé写道:
> On 11/30/21 22:17, Jiaxun Yang wrote:
>> bl_gen_write_ulong uses sd for both 32 and 64 bit CPU,
>> while sd is illegal on 32 bit CPUs.
>>
>> Replace sd with sw on 32bit CPUs.
>>
>> Fixes: 3ebbf86 ("hw/mips: Add a bootloader helper")
>> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
>> ---
>> Should be backported to 6.0 onwards.
>> ---
>> hw/mips/bootloader.c | 6 +++++-
>> 1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/hw/mips/bootloader.c b/hw/mips/bootloader.c
>> index 6ec8314490..99991f8b2b 100644
>> --- a/hw/mips/bootloader.c
>> +++ b/hw/mips/bootloader.c
>> @@ -182,7 +182,11 @@ void bl_gen_write_ulong(uint32_t **p, target_ulong addr, target_ulong val)
>> {
>> bl_gen_load_ulong(p, BL_REG_K0, val);
>> bl_gen_load_ulong(p, BL_REG_K1, addr);
>> - bl_gen_sd(p, BL_REG_K0, BL_REG_K1, 0x0);
>> + if (bootcpu_supports_isa(ISA_MIPS3)) {
>> + bl_gen_sd(p, BL_REG_K0, BL_REG_K1, 0x0);
>> + } else {
>> + bl_gen_sw(p, BL_REG_K0, BL_REG_K1, 0x0);
>> + }
>
> We have bl_gen_load_ulong(); having bl_gen_store_ulong()
> would make the API even. Mind sending a patch? Otherwise:
Should I revisit this set or start another patch?
Thanks.
>
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>
>> }
>>
>> void bl_gen_write_u32(uint32_t **p, target_ulong addr, uint32_t val)
>>
--
- Jiaxun
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] hw/mips: bootloader: Fix write_ulong
2021-12-02 10:51 ` Jiaxun Yang
@ 2021-12-02 18:01 ` Philippe Mathieu-Daudé
2021-12-05 15:25 ` Jiaxun Yang
0 siblings, 1 reply; 9+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-12-02 18:01 UTC (permalink / raw)
To: Jiaxun Yang, BALATON Zoltan via
On 12/2/21 11:51, Jiaxun Yang wrote:
> 在2021年11月30日十一月 下午9:52,Philippe Mathieu-Daudé写道:
>> On 11/30/21 22:17, Jiaxun Yang wrote:
>>> bl_gen_write_ulong uses sd for both 32 and 64 bit CPU,
>>> while sd is illegal on 32 bit CPUs.
>>>
>>> Replace sd with sw on 32bit CPUs.
>>>
>>> Fixes: 3ebbf86 ("hw/mips: Add a bootloader helper")
>>> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
>>> ---
>>> Should be backported to 6.0 onwards.
>>> ---
>>> hw/mips/bootloader.c | 6 +++++-
>>> 1 file changed, 5 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/hw/mips/bootloader.c b/hw/mips/bootloader.c
>>> index 6ec8314490..99991f8b2b 100644
>>> --- a/hw/mips/bootloader.c
>>> +++ b/hw/mips/bootloader.c
>>> @@ -182,7 +182,11 @@ void bl_gen_write_ulong(uint32_t **p, target_ulong addr, target_ulong val)
>>> {
>>> bl_gen_load_ulong(p, BL_REG_K0, val);
>>> bl_gen_load_ulong(p, BL_REG_K1, addr);
>>> - bl_gen_sd(p, BL_REG_K0, BL_REG_K1, 0x0);
>>> + if (bootcpu_supports_isa(ISA_MIPS3)) {
>>> + bl_gen_sd(p, BL_REG_K0, BL_REG_K1, 0x0);
>>> + } else {
>>> + bl_gen_sw(p, BL_REG_K0, BL_REG_K1, 0x0);
>>> + }
>>
>> We have bl_gen_load_ulong(); having bl_gen_store_ulong()
>> would make the API even. Mind sending a patch? Otherwise:
>
> Should I revisit this set or start another patch?
Another patch :)
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 0/2] MIPS misc fixes
2021-11-30 21:17 [PATCH 0/2] MIPS misc fixes Jiaxun Yang
2021-11-30 21:17 ` [PATCH 1/2] hw/mips: bootloader: Fix write_ulong Jiaxun Yang
2021-11-30 21:17 ` [PATCH 2/2] hw/mips/boston: Fix load_elf error detection Jiaxun Yang
@ 2021-12-02 18:02 ` Philippe Mathieu-Daudé
2 siblings, 0 replies; 9+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-12-02 18:02 UTC (permalink / raw)
To: Jiaxun Yang, qemu-devel
On 11/30/21 22:17, Jiaxun Yang wrote:
> Two problems caught when I was trying to add CI job for various configurations.
>
> Jiaxun Yang (2):
> hw/mips: bootloader: Fix write_ulong
> hw/mips/boston: Fix elf_load error detection
Thanks, queued to mips-fixes.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] hw/mips: bootloader: Fix write_ulong
2021-12-02 18:01 ` Philippe Mathieu-Daudé
@ 2021-12-05 15:25 ` Jiaxun Yang
0 siblings, 0 replies; 9+ messages in thread
From: Jiaxun Yang @ 2021-12-05 15:25 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, BALATON Zoltan via
在2021年12月2日十二月 下午6:01,Philippe Mathieu-Daudé写道:
> On 12/2/21 11:51, Jiaxun Yang wrote:
>> 在2021年11月30日十一月 下午9:52,Philippe Mathieu-Daudé写道:
>>> On 11/30/21 22:17, Jiaxun Yang wrote:
>>>> bl_gen_write_ulong uses sd for both 32 and 64 bit CPU,
>>>> while sd is illegal on 32 bit CPUs.
>>>>
>>>> Replace sd with sw on 32bit CPUs.
>>>>
>>>> Fixes: 3ebbf86 ("hw/mips: Add a bootloader helper")
>>>> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
>>>> ---
>>>> Should be backported to 6.0 onwards.
>>>> ---
>>>> hw/mips/bootloader.c | 6 +++++-
>>>> 1 file changed, 5 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/hw/mips/bootloader.c b/hw/mips/bootloader.c
>>>> index 6ec8314490..99991f8b2b 100644
>>>> --- a/hw/mips/bootloader.c
>>>> +++ b/hw/mips/bootloader.c
>>>> @@ -182,7 +182,11 @@ void bl_gen_write_ulong(uint32_t **p, target_ulong addr, target_ulong val)
>>>> {
>>>> bl_gen_load_ulong(p, BL_REG_K0, val);
>>>> bl_gen_load_ulong(p, BL_REG_K1, addr);
>>>> - bl_gen_sd(p, BL_REG_K0, BL_REG_K1, 0x0);
>>>> + if (bootcpu_supports_isa(ISA_MIPS3)) {
>>>> + bl_gen_sd(p, BL_REG_K0, BL_REG_K1, 0x0);
>>>> + } else {
>>>> + bl_gen_sw(p, BL_REG_K0, BL_REG_K1, 0x0);
>>>> + }
>>>
>>> We have bl_gen_load_ulong(); having bl_gen_store_ulong()
>>> would make the API even. Mind sending a patch? Otherwise:
>>
>> Should I revisit this set or start another patch?
>
> Another patch :)
Just revisited the code and bl_gen_load_ulong means load a target_ulong
immedaite number, not load from memory so it's not even.
I'd leave it as is.
Thanks.
--
- Jiaxun
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2021-12-05 15:27 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-30 21:17 [PATCH 0/2] MIPS misc fixes Jiaxun Yang
2021-11-30 21:17 ` [PATCH 1/2] hw/mips: bootloader: Fix write_ulong Jiaxun Yang
2021-11-30 21:52 ` Philippe Mathieu-Daudé
2021-12-02 10:51 ` Jiaxun Yang
2021-12-02 18:01 ` Philippe Mathieu-Daudé
2021-12-05 15:25 ` Jiaxun Yang
2021-11-30 21:17 ` [PATCH 2/2] hw/mips/boston: Fix load_elf error detection Jiaxun Yang
2021-11-30 21:54 ` Philippe Mathieu-Daudé
2021-12-02 18:02 ` [PATCH 0/2] MIPS misc fixes Philippe Mathieu-Daudé
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.