* [PATCH 0/2] hw/mips: Code simplifications
@ 2020-09-27 16:39 Philippe Mathieu-Daudé
2020-09-27 16:39 ` [PATCH 1/2] hw/mips: Simplify loading 64-bit ELF kernels Philippe Mathieu-Daudé
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-09-27 16:39 UTC (permalink / raw)
To: qemu-devel
Cc: Huacai Chen, Aleksandar Rikalo, Philippe Mathieu-Daudé,
Aleksandar Markovic, Aurelien Jarno
Doing housekeeping on old branches older than 1 year.
Some patches are still valuable, so post them.
These patches should not introduce logical change,
they simply rewrite old style code using more recent
API/macros.
Philippe Mathieu-Daudé (2):
hw/mips: Simplify loading 64-bit ELF kernels
hw/mips: Simplify code using ROUND_UP(INITRD_PAGE_SIZE)
include/hw/mips/mips.h | 4 +++-
hw/mips/fuloong2e.c | 3 +--
hw/mips/malta.c | 6 +++---
hw/mips/mipssim.c | 9 ++-------
hw/mips/r4k.c | 9 ++-------
5 files changed, 11 insertions(+), 20 deletions(-)
--
2.26.2
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/2] hw/mips: Simplify loading 64-bit ELF kernels
2020-09-27 16:39 [PATCH 0/2] hw/mips: Code simplifications Philippe Mathieu-Daudé
@ 2020-09-27 16:39 ` Philippe Mathieu-Daudé
2020-10-05 13:36 ` Richard Henderson
2020-09-27 16:39 ` [PATCH 2/2] hw/mips: Simplify code using ROUND_UP(INITRD_PAGE_SIZE) Philippe Mathieu-Daudé
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-09-27 16:39 UTC (permalink / raw)
To: qemu-devel
Cc: Huacai Chen, Aleksandar Rikalo, Philippe Mathieu-Daudé,
Aleksandar Markovic, Aurelien Jarno
Since 82790064116 ("Cast ELF datatypes properly to host 64bit types")
we don't need to sign-extend the entry_point address. Remove this
unnecessary code.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/mips/mipssim.c | 6 +-----
hw/mips/r4k.c | 6 +-----
2 files changed, 2 insertions(+), 10 deletions(-)
diff --git a/hw/mips/mipssim.c b/hw/mips/mipssim.c
index 1b3b7622035..3aeb1207e1a 100644
--- a/hw/mips/mipssim.c
+++ b/hw/mips/mipssim.c
@@ -76,11 +76,7 @@ static int64_t load_kernel(void)
(uint64_t *)&entry, NULL,
(uint64_t *)&kernel_high, NULL, big_endian,
EM_MIPS, 1, 0);
- if (kernel_size >= 0) {
- if ((entry & ~0x7fffffffULL) == 0x80000000) {
- entry = (int32_t)entry;
- }
- } else {
+ if (kernel_size < 0) {
error_report("could not load kernel '%s': %s",
loaderparams.kernel_filename,
load_elf_strerror(kernel_size));
diff --git a/hw/mips/r4k.c b/hw/mips/r4k.c
index 3487013a4a1..74f916a3982 100644
--- a/hw/mips/r4k.c
+++ b/hw/mips/r4k.c
@@ -101,11 +101,7 @@ static int64_t load_kernel(void)
(uint64_t *)&entry, NULL,
(uint64_t *)&kernel_high, NULL, big_endian,
EM_MIPS, 1, 0);
- if (kernel_size >= 0) {
- if ((entry & ~0x7fffffffULL) == 0x80000000) {
- entry = (int32_t)entry;
- }
- } else {
+ if (kernel_size < 0) {
error_report("could not load kernel '%s': %s",
loaderparams.kernel_filename,
load_elf_strerror(kernel_size));
--
2.26.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/2] hw/mips: Simplify code using ROUND_UP(INITRD_PAGE_SIZE)
2020-09-27 16:39 [PATCH 0/2] hw/mips: Code simplifications Philippe Mathieu-Daudé
2020-09-27 16:39 ` [PATCH 1/2] hw/mips: Simplify loading 64-bit ELF kernels Philippe Mathieu-Daudé
@ 2020-09-27 16:39 ` Philippe Mathieu-Daudé
2020-10-05 13:37 ` Richard Henderson
2020-10-05 7:41 ` [PATCH 0/2] hw/mips: Code simplifications Philippe Mathieu-Daudé
2020-10-07 13:21 ` Philippe Mathieu-Daudé
3 siblings, 1 reply; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-09-27 16:39 UTC (permalink / raw)
To: qemu-devel
Cc: Huacai Chen, Aleksandar Rikalo, Philippe Mathieu-Daudé,
Aleksandar Markovic, Huacai Chen, Aurelien Jarno
Instead of using a INITRD_PAGE_MASK definition, use the
simpler INITRD_PAGE_SIZE one which allows us to simplify
the code by using directly the self-explicit ROUND_UP()
macro.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
include/hw/mips/mips.h | 4 +++-
hw/mips/fuloong2e.c | 3 +--
hw/mips/malta.c | 6 +++---
hw/mips/mipssim.c | 3 +--
hw/mips/r4k.c | 3 +--
5 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/include/hw/mips/mips.h b/include/hw/mips/mips.h
index 0af4c3d5d74..6c9c8805f3f 100644
--- a/include/hw/mips/mips.h
+++ b/include/hw/mips/mips.h
@@ -2,8 +2,10 @@
#define HW_MIPS_H
/* Definitions for mips board emulation. */
+#include "qemu/units.h"
+
/* Kernels can be configured with 64KB pages */
-#define INITRD_PAGE_MASK (~((1 << 16) - 1))
+#define INITRD_PAGE_SIZE (64 * KiB)
#include "exec/memory.h"
diff --git a/hw/mips/fuloong2e.c b/hw/mips/fuloong2e.c
index f28609976bf..ef5dbe97b7d 100644
--- a/hw/mips/fuloong2e.c
+++ b/hw/mips/fuloong2e.c
@@ -132,8 +132,7 @@ static int64_t load_kernel(CPUMIPSState *env)
if (loaderparams.initrd_filename) {
initrd_size = get_image_size(loaderparams.initrd_filename);
if (initrd_size > 0) {
- initrd_offset = (kernel_high + ~INITRD_PAGE_MASK) &
- INITRD_PAGE_MASK;
+ initrd_offset = ROUND_UP(kernel_high, INITRD_PAGE_SIZE);
if (initrd_offset + initrd_size > ram_size) {
error_report("memory too small for initial ram disk '%s'",
loaderparams.initrd_filename);
diff --git a/hw/mips/malta.c b/hw/mips/malta.c
index 4019c9dc1a8..5de5cb152eb 100644
--- a/hw/mips/malta.c
+++ b/hw/mips/malta.c
@@ -1074,9 +1074,9 @@ static int64_t load_kernel(void)
* the initrd. It takes at most 128kiB for 2GB RAM and 4kiB
* pages.
*/
- initrd_offset = (loaderparams.ram_low_size - initrd_size
- - (128 * KiB)
- - ~INITRD_PAGE_MASK) & INITRD_PAGE_MASK;
+ initrd_offset = ROUND_UP(loaderparams.ram_low_size
+ - (initrd_size + 128 * KiB),
+ INITRD_PAGE_SIZE);
if (kernel_high >= initrd_offset) {
error_report("memory too small for initial ram disk '%s'",
loaderparams.initrd_filename);
diff --git a/hw/mips/mipssim.c b/hw/mips/mipssim.c
index 3aeb1207e1a..1862eeda396 100644
--- a/hw/mips/mipssim.c
+++ b/hw/mips/mipssim.c
@@ -89,8 +89,7 @@ static int64_t load_kernel(void)
if (loaderparams.initrd_filename) {
initrd_size = get_image_size(loaderparams.initrd_filename);
if (initrd_size > 0) {
- initrd_offset = (kernel_high + ~INITRD_PAGE_MASK) &
- INITRD_PAGE_MASK;
+ initrd_offset = ROUND_UP(kernel_high, INITRD_PAGE_SIZE);
if (initrd_offset + initrd_size > loaderparams.ram_size) {
error_report("memory too small for initial ram disk '%s'",
loaderparams.initrd_filename);
diff --git a/hw/mips/r4k.c b/hw/mips/r4k.c
index 74f916a3982..24cee357f34 100644
--- a/hw/mips/r4k.c
+++ b/hw/mips/r4k.c
@@ -114,8 +114,7 @@ static int64_t load_kernel(void)
if (loaderparams.initrd_filename) {
initrd_size = get_image_size(loaderparams.initrd_filename);
if (initrd_size > 0) {
- initrd_offset = (kernel_high + ~INITRD_PAGE_MASK) &
- INITRD_PAGE_MASK;
+ initrd_offset = ROUND_UP(kernel_high, INITRD_PAGE_SIZE);
if (initrd_offset + initrd_size > ram_size) {
error_report("memory too small for initial ram disk '%s'",
loaderparams.initrd_filename);
--
2.26.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 0/2] hw/mips: Code simplifications
2020-09-27 16:39 [PATCH 0/2] hw/mips: Code simplifications Philippe Mathieu-Daudé
2020-09-27 16:39 ` [PATCH 1/2] hw/mips: Simplify loading 64-bit ELF kernels Philippe Mathieu-Daudé
2020-09-27 16:39 ` [PATCH 2/2] hw/mips: Simplify code using ROUND_UP(INITRD_PAGE_SIZE) Philippe Mathieu-Daudé
@ 2020-10-05 7:41 ` Philippe Mathieu-Daudé
2020-10-07 13:21 ` Philippe Mathieu-Daudé
3 siblings, 0 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-10-05 7:41 UTC (permalink / raw)
To: qemu-devel
Cc: Huacai Chen, Aleksandar Rikalo, Aleksandar Markovic, Aurelien Jarno
ping?
On 9/27/20 6:39 PM, Philippe Mathieu-Daudé wrote:
> Doing housekeeping on old branches older than 1 year.
> Some patches are still valuable, so post them.
>
> These patches should not introduce logical change,
> they simply rewrite old style code using more recent
> API/macros.
>
> Philippe Mathieu-Daudé (2):
> hw/mips: Simplify loading 64-bit ELF kernels
> hw/mips: Simplify code using ROUND_UP(INITRD_PAGE_SIZE)
>
> include/hw/mips/mips.h | 4 +++-
> hw/mips/fuloong2e.c | 3 +--
> hw/mips/malta.c | 6 +++---
> hw/mips/mipssim.c | 9 ++-------
> hw/mips/r4k.c | 9 ++-------
> 5 files changed, 11 insertions(+), 20 deletions(-)
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] hw/mips: Simplify loading 64-bit ELF kernels
2020-09-27 16:39 ` [PATCH 1/2] hw/mips: Simplify loading 64-bit ELF kernels Philippe Mathieu-Daudé
@ 2020-10-05 13:36 ` Richard Henderson
0 siblings, 0 replies; 7+ messages in thread
From: Richard Henderson @ 2020-10-05 13:36 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Huacai Chen, Aleksandar Rikalo, Aleksandar Markovic, Aurelien Jarno
On 9/27/20 11:39 AM, Philippe Mathieu-Daudé wrote:
> Since 82790064116 ("Cast ELF datatypes properly to host 64bit types")
> we don't need to sign-extend the entry_point address. Remove this
> unnecessary code.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> hw/mips/mipssim.c | 6 +-----
> hw/mips/r4k.c | 6 +-----
> 2 files changed, 2 insertions(+), 10 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] hw/mips: Simplify code using ROUND_UP(INITRD_PAGE_SIZE)
2020-09-27 16:39 ` [PATCH 2/2] hw/mips: Simplify code using ROUND_UP(INITRD_PAGE_SIZE) Philippe Mathieu-Daudé
@ 2020-10-05 13:37 ` Richard Henderson
0 siblings, 0 replies; 7+ messages in thread
From: Richard Henderson @ 2020-10-05 13:37 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Huacai Chen, Aleksandar Rikalo, Aleksandar Markovic,
Aurelien Jarno, Huacai Chen
On 9/27/20 11:39 AM, Philippe Mathieu-Daudé wrote:
> Instead of using a INITRD_PAGE_MASK definition, use the
> simpler INITRD_PAGE_SIZE one which allows us to simplify
> the code by using directly the self-explicit ROUND_UP()
> macro.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> include/hw/mips/mips.h | 4 +++-
> hw/mips/fuloong2e.c | 3 +--
> hw/mips/malta.c | 6 +++---
> hw/mips/mipssim.c | 3 +--
> hw/mips/r4k.c | 3 +--
> 5 files changed, 9 insertions(+), 10 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/2] hw/mips: Code simplifications
2020-09-27 16:39 [PATCH 0/2] hw/mips: Code simplifications Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2020-10-05 7:41 ` [PATCH 0/2] hw/mips: Code simplifications Philippe Mathieu-Daudé
@ 2020-10-07 13:21 ` Philippe Mathieu-Daudé
3 siblings, 0 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-10-07 13:21 UTC (permalink / raw)
To: qemu-devel
Cc: Huacai Chen, Aleksandar Rikalo, Aleksandar Markovic, Aurelien Jarno
On 9/27/20 6:39 PM, Philippe Mathieu-Daudé wrote:
> Doing housekeeping on old branches older than 1 year.
> Some patches are still valuable, so post them.
>
> These patches should not introduce logical change,
> they simply rewrite old style code using more recent
> API/macros.
>
> Philippe Mathieu-Daudé (2):
> hw/mips: Simplify loading 64-bit ELF kernels
> hw/mips: Simplify code using ROUND_UP(INITRD_PAGE_SIZE)
>
> include/hw/mips/mips.h | 4 +++-
> hw/mips/fuloong2e.c | 3 +--
> hw/mips/malta.c | 6 +++---
> hw/mips/mipssim.c | 9 ++-------
> hw/mips/r4k.c | 9 ++-------
> 5 files changed, 11 insertions(+), 20 deletions(-)
Thanks, applied to mips-hw-next.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2020-10-07 13:22 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-27 16:39 [PATCH 0/2] hw/mips: Code simplifications Philippe Mathieu-Daudé
2020-09-27 16:39 ` [PATCH 1/2] hw/mips: Simplify loading 64-bit ELF kernels Philippe Mathieu-Daudé
2020-10-05 13:36 ` Richard Henderson
2020-09-27 16:39 ` [PATCH 2/2] hw/mips: Simplify code using ROUND_UP(INITRD_PAGE_SIZE) Philippe Mathieu-Daudé
2020-10-05 13:37 ` Richard Henderson
2020-10-05 7:41 ` [PATCH 0/2] hw/mips: Code simplifications Philippe Mathieu-Daudé
2020-10-07 13:21 ` 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.