diff options
| author | Chen Qi <Qi.Chen@windriver.com> | 2024-09-13 02:21:36 -0700 |
|---|---|---|
| committer | Steve Sakoman <steve@sakoman.com> | 2024-09-25 05:07:47 -0700 |
| commit | dc5dd6ec19e0a215630746206e18e011dea0a685 (patch) | |
| tree | 42f19d657b3f8bc6974d69d682ad4c30a16cdc66 /meta | |
| parent | 0979d14d5487928d0b4655731d932a56fd39d347 (diff) | |
| download | poky-dc5dd6ec19e0a215630746206e18e011dea0a685.tar.gz | |
qemu: back port patches to fix riscv64 build failure
Backport patches to fix riscv64 build failure.
(From OE-Core rev: ab7d0dcb49606651505bf167fd919bc969d97eed)
Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Diffstat (limited to 'meta')
4 files changed, 258 insertions, 0 deletions
diff --git a/meta/recipes-devtools/qemu/qemu.inc b/meta/recipes-devtools/qemu/qemu.inc index a1d8a309a0..e9f63b9eaf 100644 --- a/meta/recipes-devtools/qemu/qemu.inc +++ b/meta/recipes-devtools/qemu/qemu.inc | |||
| @@ -49,6 +49,9 @@ SRC_URI = "https://download.qemu.org/${BPN}-${PV}.tar.xz \ | |||
| 49 | file://CVE-2024-7409-0002.patch \ | 49 | file://CVE-2024-7409-0002.patch \ |
| 50 | file://CVE-2024-7409-0003.patch \ | 50 | file://CVE-2024-7409-0003.patch \ |
| 51 | file://CVE-2024-7409-0004.patch \ | 51 | file://CVE-2024-7409-0004.patch \ |
| 52 | file://0001-target-riscv-kvm-change-KVM_REG_RISCV_FP_F-to-u32.patch \ | ||
| 53 | file://0002-target-riscv-kvm-change-KVM_REG_RISCV_FP_D-to-u64.patch \ | ||
| 54 | file://0003-target-riscv-kvm-change-timer-regs-size-to-u64.patch \ | ||
| 52 | " | 55 | " |
| 53 | UPSTREAM_CHECK_REGEX = "qemu-(?P<pver>\d+(\.\d+)+)\.tar" | 56 | UPSTREAM_CHECK_REGEX = "qemu-(?P<pver>\d+(\.\d+)+)\.tar" |
| 54 | 57 | ||
diff --git a/meta/recipes-devtools/qemu/qemu/0001-target-riscv-kvm-change-KVM_REG_RISCV_FP_F-to-u32.patch b/meta/recipes-devtools/qemu/qemu/0001-target-riscv-kvm-change-KVM_REG_RISCV_FP_F-to-u32.patch new file mode 100644 index 0000000000..39a6a85162 --- /dev/null +++ b/meta/recipes-devtools/qemu/qemu/0001-target-riscv-kvm-change-KVM_REG_RISCV_FP_F-to-u32.patch | |||
| @@ -0,0 +1,75 @@ | |||
| 1 | From bbdcc89678daa5cb131ef22a6cd41a5f7f9dcea9 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Daniel Henrique Barboza <dbarboza@ventanamicro.com> | ||
| 3 | Date: Fri, 8 Dec 2023 15:38:31 -0300 | ||
| 4 | Subject: [PATCH 1/3] target/riscv/kvm: change KVM_REG_RISCV_FP_F to u32 | ||
| 5 | |||
| 6 | KVM_REG_RISCV_FP_F regs have u32 size according to the API, but by using | ||
| 7 | kvm_riscv_reg_id() in RISCV_FP_F_REG() we're returning u64 sizes when | ||
| 8 | running with TARGET_RISCV64. The most likely reason why no one noticed | ||
| 9 | this is because we're not implementing kvm_cpu_synchronize_state() in | ||
| 10 | RISC-V yet. | ||
| 11 | |||
| 12 | Create a new helper that returns a KVM ID with u32 size and use it in | ||
| 13 | RISCV_FP_F_REG(). | ||
| 14 | |||
| 15 | Reported-by: Andrew Jones <ajones@ventanamicro.com> | ||
| 16 | Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> | ||
| 17 | Reviewed-by: Andrew Jones <ajones@ventanamicro.com> | ||
| 18 | Message-ID: <20231208183835.2411523-2-dbarboza@ventanamicro.com> | ||
| 19 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
| 20 | (cherry picked from commit 49c211ffca00fdf7c0c29072c224e88527a14838) | ||
| 21 | Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> | ||
| 22 | |||
| 23 | Upstream-Status: Backport [bbdcc89678daa5cb131ef22a6cd41a5f7f9dcea9] | ||
| 24 | |||
| 25 | Signed-off-by: Chen Qi <Qi.Chen@windriver.com> | ||
| 26 | --- | ||
| 27 | target/riscv/kvm/kvm-cpu.c | 11 ++++++++--- | ||
| 28 | 1 file changed, 8 insertions(+), 3 deletions(-) | ||
| 29 | |||
| 30 | diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c | ||
| 31 | index c1675158fe..2eef2be86a 100644 | ||
| 32 | --- a/target/riscv/kvm/kvm-cpu.c | ||
| 33 | +++ b/target/riscv/kvm/kvm-cpu.c | ||
| 34 | @@ -72,6 +72,11 @@ static uint64_t kvm_riscv_reg_id(CPURISCVState *env, uint64_t type, | ||
| 35 | return id; | ||
| 36 | } | ||
| 37 | |||
| 38 | +static uint64_t kvm_riscv_reg_id_u32(uint64_t type, uint64_t idx) | ||
| 39 | +{ | ||
| 40 | + return KVM_REG_RISCV | KVM_REG_SIZE_U32 | type | idx; | ||
| 41 | +} | ||
| 42 | + | ||
| 43 | #define RISCV_CORE_REG(env, name) kvm_riscv_reg_id(env, KVM_REG_RISCV_CORE, \ | ||
| 44 | KVM_REG_RISCV_CORE_REG(name)) | ||
| 45 | |||
| 46 | @@ -81,7 +86,7 @@ static uint64_t kvm_riscv_reg_id(CPURISCVState *env, uint64_t type, | ||
| 47 | #define RISCV_TIMER_REG(env, name) kvm_riscv_reg_id(env, KVM_REG_RISCV_TIMER, \ | ||
| 48 | KVM_REG_RISCV_TIMER_REG(name)) | ||
| 49 | |||
| 50 | -#define RISCV_FP_F_REG(env, idx) kvm_riscv_reg_id(env, KVM_REG_RISCV_FP_F, idx) | ||
| 51 | +#define RISCV_FP_F_REG(idx) kvm_riscv_reg_id_u32(KVM_REG_RISCV_FP_F, idx) | ||
| 52 | |||
| 53 | #define RISCV_FP_D_REG(env, idx) kvm_riscv_reg_id(env, KVM_REG_RISCV_FP_D, idx) | ||
| 54 | |||
| 55 | @@ -586,7 +591,7 @@ static int kvm_riscv_get_regs_fp(CPUState *cs) | ||
| 56 | if (riscv_has_ext(env, RVF)) { | ||
| 57 | uint32_t reg; | ||
| 58 | for (i = 0; i < 32; i++) { | ||
| 59 | - ret = kvm_get_one_reg(cs, RISCV_FP_F_REG(env, i), ®); | ||
| 60 | + ret = kvm_get_one_reg(cs, RISCV_FP_F_REG(i), ®); | ||
| 61 | if (ret) { | ||
| 62 | return ret; | ||
| 63 | } | ||
| 64 | @@ -620,7 +625,7 @@ static int kvm_riscv_put_regs_fp(CPUState *cs) | ||
| 65 | uint32_t reg; | ||
| 66 | for (i = 0; i < 32; i++) { | ||
| 67 | reg = env->fpr[i]; | ||
| 68 | - ret = kvm_set_one_reg(cs, RISCV_FP_F_REG(env, i), ®); | ||
| 69 | + ret = kvm_set_one_reg(cs, RISCV_FP_F_REG(i), ®); | ||
| 70 | if (ret) { | ||
| 71 | return ret; | ||
| 72 | } | ||
| 73 | -- | ||
| 74 | 2.25.1 | ||
| 75 | |||
diff --git a/meta/recipes-devtools/qemu/qemu/0002-target-riscv-kvm-change-KVM_REG_RISCV_FP_D-to-u64.patch b/meta/recipes-devtools/qemu/qemu/0002-target-riscv-kvm-change-KVM_REG_RISCV_FP_D-to-u64.patch new file mode 100644 index 0000000000..9480d3e0b5 --- /dev/null +++ b/meta/recipes-devtools/qemu/qemu/0002-target-riscv-kvm-change-KVM_REG_RISCV_FP_D-to-u64.patch | |||
| @@ -0,0 +1,73 @@ | |||
| 1 | From 125b95d79e746cbab6b72683b3382dd372e38c61 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Daniel Henrique Barboza <dbarboza@ventanamicro.com> | ||
| 3 | Date: Fri, 8 Dec 2023 15:38:32 -0300 | ||
| 4 | Subject: [PATCH 2/3] target/riscv/kvm: change KVM_REG_RISCV_FP_D to u64 | ||
| 5 | |||
| 6 | KVM_REG_RISCV_FP_D regs are always u64 size. Using kvm_riscv_reg_id() in | ||
| 7 | RISCV_FP_D_REG() ends up encoding the wrong size if we're running with | ||
| 8 | TARGET_RISCV32. | ||
| 9 | |||
| 10 | Create a new helper that returns a KVM ID with u64 size and use it with | ||
| 11 | RISCV_FP_D_REG(). | ||
| 12 | |||
| 13 | Reported-by: Andrew Jones <ajones@ventanamicro.com> | ||
| 14 | Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> | ||
| 15 | Reviewed-by: Andrew Jones <ajones@ventanamicro.com> | ||
| 16 | Message-ID: <20231208183835.2411523-3-dbarboza@ventanamicro.com> | ||
| 17 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
| 18 | (cherry picked from commit 450bd6618fda3d2e2ab02b2fce1c79efd5b66084) | ||
| 19 | Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> | ||
| 20 | |||
| 21 | Upstream-Status: Backport [125b95d79e746cbab6b72683b3382dd372e38c61] | ||
| 22 | |||
| 23 | Signed-off-by: Chen Qi <Qi.Chen@windriver.com> | ||
| 24 | --- | ||
| 25 | target/riscv/kvm/kvm-cpu.c | 11 ++++++++--- | ||
| 26 | 1 file changed, 8 insertions(+), 3 deletions(-) | ||
| 27 | |||
| 28 | diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c | ||
| 29 | index 2eef2be86a..82ed4455a5 100644 | ||
| 30 | --- a/target/riscv/kvm/kvm-cpu.c | ||
| 31 | +++ b/target/riscv/kvm/kvm-cpu.c | ||
| 32 | @@ -77,6 +77,11 @@ static uint64_t kvm_riscv_reg_id_u32(uint64_t type, uint64_t idx) | ||
| 33 | return KVM_REG_RISCV | KVM_REG_SIZE_U32 | type | idx; | ||
| 34 | } | ||
| 35 | |||
| 36 | +static uint64_t kvm_riscv_reg_id_u64(uint64_t type, uint64_t idx) | ||
| 37 | +{ | ||
| 38 | + return KVM_REG_RISCV | KVM_REG_SIZE_U64 | type | idx; | ||
| 39 | +} | ||
| 40 | + | ||
| 41 | #define RISCV_CORE_REG(env, name) kvm_riscv_reg_id(env, KVM_REG_RISCV_CORE, \ | ||
| 42 | KVM_REG_RISCV_CORE_REG(name)) | ||
| 43 | |||
| 44 | @@ -88,7 +93,7 @@ static uint64_t kvm_riscv_reg_id_u32(uint64_t type, uint64_t idx) | ||
| 45 | |||
| 46 | #define RISCV_FP_F_REG(idx) kvm_riscv_reg_id_u32(KVM_REG_RISCV_FP_F, idx) | ||
| 47 | |||
| 48 | -#define RISCV_FP_D_REG(env, idx) kvm_riscv_reg_id(env, KVM_REG_RISCV_FP_D, idx) | ||
| 49 | +#define RISCV_FP_D_REG(idx) kvm_riscv_reg_id_u64(KVM_REG_RISCV_FP_D, idx) | ||
| 50 | |||
| 51 | #define KVM_RISCV_GET_CSR(cs, env, csr, reg) \ | ||
| 52 | do { \ | ||
| 53 | @@ -579,7 +584,7 @@ static int kvm_riscv_get_regs_fp(CPUState *cs) | ||
| 54 | if (riscv_has_ext(env, RVD)) { | ||
| 55 | uint64_t reg; | ||
| 56 | for (i = 0; i < 32; i++) { | ||
| 57 | - ret = kvm_get_one_reg(cs, RISCV_FP_D_REG(env, i), ®); | ||
| 58 | + ret = kvm_get_one_reg(cs, RISCV_FP_D_REG(i), ®); | ||
| 59 | if (ret) { | ||
| 60 | return ret; | ||
| 61 | } | ||
| 62 | @@ -613,7 +618,7 @@ static int kvm_riscv_put_regs_fp(CPUState *cs) | ||
| 63 | uint64_t reg; | ||
| 64 | for (i = 0; i < 32; i++) { | ||
| 65 | reg = env->fpr[i]; | ||
| 66 | - ret = kvm_set_one_reg(cs, RISCV_FP_D_REG(env, i), ®); | ||
| 67 | + ret = kvm_set_one_reg(cs, RISCV_FP_D_REG(i), ®); | ||
| 68 | if (ret) { | ||
| 69 | return ret; | ||
| 70 | } | ||
| 71 | -- | ||
| 72 | 2.25.1 | ||
| 73 | |||
diff --git a/meta/recipes-devtools/qemu/qemu/0003-target-riscv-kvm-change-timer-regs-size-to-u64.patch b/meta/recipes-devtools/qemu/qemu/0003-target-riscv-kvm-change-timer-regs-size-to-u64.patch new file mode 100644 index 0000000000..1ea1bcfe70 --- /dev/null +++ b/meta/recipes-devtools/qemu/qemu/0003-target-riscv-kvm-change-timer-regs-size-to-u64.patch | |||
| @@ -0,0 +1,107 @@ | |||
| 1 | From cbae1080988e0f1af0fb4c816205f7647f6de16f Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Daniel Henrique Barboza <dbarboza@ventanamicro.com> | ||
| 3 | Date: Fri, 8 Dec 2023 15:38:33 -0300 | ||
| 4 | Subject: [PATCH 3/3] target/riscv/kvm: change timer regs size to u64 | ||
| 5 | |||
| 6 | KVM_REG_RISCV_TIMER regs are always u64 according to the KVM API, but at | ||
| 7 | this moment we'll return u32 regs if we're running a RISCV32 target. | ||
| 8 | |||
| 9 | Use the kvm_riscv_reg_id_u64() helper in RISCV_TIMER_REG() to fix it. | ||
| 10 | |||
| 11 | Reported-by: Andrew Jones <ajones@ventanamicro.com> | ||
| 12 | Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> | ||
| 13 | Reviewed-by: Andrew Jones <ajones@ventanamicro.com> | ||
| 14 | Message-ID: <20231208183835.2411523-4-dbarboza@ventanamicro.com> | ||
| 15 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
| 16 | (cherry picked from commit 10f86d1b845087d14b58d65dd2a6e3411d1b6529) | ||
| 17 | Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> | ||
| 18 | |||
| 19 | Upstream-Status: Backport [cbae1080988e0f1af0fb4c816205f7647f6de16f] | ||
| 20 | |||
| 21 | Signed-off-by: Chen Qi <Qi.Chen@windriver.com> | ||
| 22 | --- | ||
| 23 | target/riscv/kvm/kvm-cpu.c | 26 +++++++++++++------------- | ||
| 24 | 1 file changed, 13 insertions(+), 13 deletions(-) | ||
| 25 | |||
| 26 | diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c | ||
| 27 | index 82ed4455a5..ddbe820e10 100644 | ||
| 28 | --- a/target/riscv/kvm/kvm-cpu.c | ||
| 29 | +++ b/target/riscv/kvm/kvm-cpu.c | ||
| 30 | @@ -88,7 +88,7 @@ static uint64_t kvm_riscv_reg_id_u64(uint64_t type, uint64_t idx) | ||
| 31 | #define RISCV_CSR_REG(env, name) kvm_riscv_reg_id(env, KVM_REG_RISCV_CSR, \ | ||
| 32 | KVM_REG_RISCV_CSR_REG(name)) | ||
| 33 | |||
| 34 | -#define RISCV_TIMER_REG(env, name) kvm_riscv_reg_id(env, KVM_REG_RISCV_TIMER, \ | ||
| 35 | +#define RISCV_TIMER_REG(name) kvm_riscv_reg_id_u64(KVM_REG_RISCV_TIMER, \ | ||
| 36 | KVM_REG_RISCV_TIMER_REG(name)) | ||
| 37 | |||
| 38 | #define RISCV_FP_F_REG(idx) kvm_riscv_reg_id_u32(KVM_REG_RISCV_FP_F, idx) | ||
| 39 | @@ -111,17 +111,17 @@ static uint64_t kvm_riscv_reg_id_u64(uint64_t type, uint64_t idx) | ||
| 40 | } \ | ||
| 41 | } while (0) | ||
| 42 | |||
| 43 | -#define KVM_RISCV_GET_TIMER(cs, env, name, reg) \ | ||
| 44 | +#define KVM_RISCV_GET_TIMER(cs, name, reg) \ | ||
| 45 | do { \ | ||
| 46 | - int ret = kvm_get_one_reg(cs, RISCV_TIMER_REG(env, name), ®); \ | ||
| 47 | + int ret = kvm_get_one_reg(cs, RISCV_TIMER_REG(name), ®); \ | ||
| 48 | if (ret) { \ | ||
| 49 | abort(); \ | ||
| 50 | } \ | ||
| 51 | } while (0) | ||
| 52 | |||
| 53 | -#define KVM_RISCV_SET_TIMER(cs, env, name, reg) \ | ||
| 54 | +#define KVM_RISCV_SET_TIMER(cs, name, reg) \ | ||
| 55 | do { \ | ||
| 56 | - int ret = kvm_set_one_reg(cs, RISCV_TIMER_REG(env, name), ®); \ | ||
| 57 | + int ret = kvm_set_one_reg(cs, RISCV_TIMER_REG(name), ®); \ | ||
| 58 | if (ret) { \ | ||
| 59 | abort(); \ | ||
| 60 | } \ | ||
| 61 | @@ -649,10 +649,10 @@ static void kvm_riscv_get_regs_timer(CPUState *cs) | ||
| 62 | return; | ||
| 63 | } | ||
| 64 | |||
| 65 | - KVM_RISCV_GET_TIMER(cs, env, time, env->kvm_timer_time); | ||
| 66 | - KVM_RISCV_GET_TIMER(cs, env, compare, env->kvm_timer_compare); | ||
| 67 | - KVM_RISCV_GET_TIMER(cs, env, state, env->kvm_timer_state); | ||
| 68 | - KVM_RISCV_GET_TIMER(cs, env, frequency, env->kvm_timer_frequency); | ||
| 69 | + KVM_RISCV_GET_TIMER(cs, time, env->kvm_timer_time); | ||
| 70 | + KVM_RISCV_GET_TIMER(cs, compare, env->kvm_timer_compare); | ||
| 71 | + KVM_RISCV_GET_TIMER(cs, state, env->kvm_timer_state); | ||
| 72 | + KVM_RISCV_GET_TIMER(cs, frequency, env->kvm_timer_frequency); | ||
| 73 | |||
| 74 | env->kvm_timer_dirty = true; | ||
| 75 | } | ||
| 76 | @@ -666,8 +666,8 @@ static void kvm_riscv_put_regs_timer(CPUState *cs) | ||
| 77 | return; | ||
| 78 | } | ||
| 79 | |||
| 80 | - KVM_RISCV_SET_TIMER(cs, env, time, env->kvm_timer_time); | ||
| 81 | - KVM_RISCV_SET_TIMER(cs, env, compare, env->kvm_timer_compare); | ||
| 82 | + KVM_RISCV_SET_TIMER(cs, time, env->kvm_timer_time); | ||
| 83 | + KVM_RISCV_SET_TIMER(cs, compare, env->kvm_timer_compare); | ||
| 84 | |||
| 85 | /* | ||
| 86 | * To set register of RISCV_TIMER_REG(state) will occur a error from KVM | ||
| 87 | @@ -676,7 +676,7 @@ static void kvm_riscv_put_regs_timer(CPUState *cs) | ||
| 88 | * TODO If KVM changes, adapt here. | ||
| 89 | */ | ||
| 90 | if (env->kvm_timer_state) { | ||
| 91 | - KVM_RISCV_SET_TIMER(cs, env, state, env->kvm_timer_state); | ||
| 92 | + KVM_RISCV_SET_TIMER(cs, state, env->kvm_timer_state); | ||
| 93 | } | ||
| 94 | |||
| 95 | /* | ||
| 96 | @@ -685,7 +685,7 @@ static void kvm_riscv_put_regs_timer(CPUState *cs) | ||
| 97 | * during the migration. | ||
| 98 | */ | ||
| 99 | if (migration_is_running(migrate_get_current()->state)) { | ||
| 100 | - KVM_RISCV_GET_TIMER(cs, env, frequency, reg); | ||
| 101 | + KVM_RISCV_GET_TIMER(cs, frequency, reg); | ||
| 102 | if (reg != env->kvm_timer_frequency) { | ||
| 103 | error_report("Dst Hosts timer frequency != Src Hosts"); | ||
| 104 | } | ||
| 105 | -- | ||
| 106 | 2.25.1 | ||
| 107 | |||
