mirror of
https://github.com/qemu/qemu.git
synced 2026-07-08 17:56:38 +00:00
Merge tag 'pull-loongarch-20260707' of https://github.com/gaosong715/qemu into staging
pull-loongarch-20260707 # -----BEGIN PGP SIGNATURE----- # # iLMEAAEKAB0WIQS4/x2g0v3LLaCcbCxAov/yOSY+3wUCakz1yAAKCRBAov/yOSY+ # 30ghBACjPw9Tv22Qyl3UEImccxWO9opvxq006pkKCRib8et5SdSROzZQHZOre6M8 # jwY3O7nNHem9MyXvzGo6GoDKUo1qmJlrYGydRb9QXeZS/EHdN9OUNm/tHjKnpJdN # kyvXpv2fT2FnPQ/doGnUHsYCJl6e9gxEsl4iM17F2vaV+VZnCg== # =NHlN # -----END PGP SIGNATURE----- # gpg: Signature made Tue 07 Jul 2026 14:49:12 CEST # gpg: using RSA key B8FF1DA0D2FDCB2DA09C6C2C40A2FFF239263EDF # gpg: Good signature from "Song Gao <m17746591750@163.com>" [unknown] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: B8FF 1DA0 D2FD CB2D A09C 6C2C 40A2 FFF2 3926 3EDF * tag 'pull-loongarch-20260707' of https://github.com/gaosong715/qemu: MAINTAINERS: add LoongArch's maintainers MAINTAINERS: update Song Gao's email address hw/intc/loongarch_dintc: Fix OOB access in DINT MMIO write handler target/loongarch: Enable TARGET_PAGE_BITS_VARY for loongarch64 user-only target/loongarch/kvm: fix cpucfg sync error handling target/loongarch/kvm: remove redundant cpucfg failure traces target/loongarch/kvm: pass device attr by reference to kvm_vcpu_ioctl target/loongarch/kvm: fix uninitialized val and unchecked GET in cpucfg2 check Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
1
.mailmap
1
.mailmap
@@ -119,6 +119,7 @@ Roman Bolshakov <rbolshakov@ddn.com> <r.bolshakov@yadro.com>
|
|||||||
Sriram Yagnaraman <sriram.yagnaraman@ericsson.com> <sriram.yagnaraman@est.tech>
|
Sriram Yagnaraman <sriram.yagnaraman@ericsson.com> <sriram.yagnaraman@est.tech>
|
||||||
Stefan Brankovic <stefan.brankovic@syrmia.com> <stefan.brankovic@rt-rk.com.com>
|
Stefan Brankovic <stefan.brankovic@syrmia.com> <stefan.brankovic@rt-rk.com.com>
|
||||||
Stefan Weil <sw@weilnetz.de> Stefan Weil <stefan@weilnetz.de>
|
Stefan Weil <sw@weilnetz.de> Stefan Weil <stefan@weilnetz.de>
|
||||||
|
Song Gao <17746591750@163.com> <gaosong@loongson.cn>
|
||||||
Taylor Simpson <ltaylorsimpson@gmail.com> <tsimpson@quicinc.com>
|
Taylor Simpson <ltaylorsimpson@gmail.com> <tsimpson@quicinc.com>
|
||||||
Yongbok Kim <yongbok.kim@mips.com> <yongbok.kim@imgtec.com>
|
Yongbok Kim <yongbok.kim@mips.com> <yongbok.kim@imgtec.com>
|
||||||
|
|
||||||
|
|||||||
@@ -280,7 +280,9 @@ F: disas/hppa.c
|
|||||||
F: tests/tcg/hppa/
|
F: tests/tcg/hppa/
|
||||||
|
|
||||||
LoongArch TCG CPUs
|
LoongArch TCG CPUs
|
||||||
M: Song Gao <gaosong@loongson.cn>
|
M: Song Gao <17746591750@163.com>
|
||||||
|
M: Bibo Mao <maobibo@loongson.cn>
|
||||||
|
R: Xianglai Li <lixianglai@loongson.cn>
|
||||||
S: Maintained
|
S: Maintained
|
||||||
F: target/loongarch/
|
F: target/loongarch/
|
||||||
F: tests/docker/dockerfiles/debian-loongarch-cross.docker
|
F: tests/docker/dockerfiles/debian-loongarch-cross.docker
|
||||||
@@ -1360,8 +1362,9 @@ F: docs/devel/hexagon-sys.rst
|
|||||||
LoongArch Machines
|
LoongArch Machines
|
||||||
------------------
|
------------------
|
||||||
Virt
|
Virt
|
||||||
M: Song Gao <gaosong@loongson.cn>
|
M: Song Gao <17746591750@163.com>
|
||||||
M: Bibo Mao <maobibo@loongson.cn>
|
M: Bibo Mao <maobibo@loongson.cn>
|
||||||
|
R: Xianglai Li <lixianglai@loongson.cn>
|
||||||
R: Jiaxun Yang <jiaxun.yang@flygoat.com>
|
R: Jiaxun Yang <jiaxun.yang@flygoat.com>
|
||||||
S: Maintained
|
S: Maintained
|
||||||
F: docs/system/loongarch/virt.rst
|
F: docs/system/loongarch/virt.rst
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#include "target/loongarch/cpu.h"
|
#include "target/loongarch/cpu.h"
|
||||||
#include "qemu/error-report.h"
|
#include "qemu/error-report.h"
|
||||||
#include "system/hw_accel.h"
|
#include "system/hw_accel.h"
|
||||||
|
#include "qemu/log.h"
|
||||||
|
|
||||||
/* msg addr field */
|
/* msg addr field */
|
||||||
FIELD(MSG_ADDR, IRQ_NUM, 4, 8)
|
FIELD(MSG_ADDR, IRQ_NUM, 4, 8)
|
||||||
@@ -52,7 +53,19 @@ static void loongarch_dintc_mem_write(void *opaque, hwaddr addr,
|
|||||||
CPUState *cs;
|
CPUState *cs;
|
||||||
|
|
||||||
cpu_num = FIELD_EX64(msg_addr, MSG_ADDR, CPU_NUM);
|
cpu_num = FIELD_EX64(msg_addr, MSG_ADDR, CPU_NUM);
|
||||||
|
|
||||||
|
/* Validate cpu_num against the configured number of CPUs */
|
||||||
|
if (cpu_num >= s->num_cpu) {
|
||||||
|
qemu_log_mask(LOG_GUEST_ERROR,
|
||||||
|
"loongarch-dintc: invalid cpu number%d\n", cpu_num);
|
||||||
|
return;
|
||||||
|
}
|
||||||
cs = cpu_by_arch_id(cpu_num);
|
cs = cpu_by_arch_id(cpu_num);
|
||||||
|
if (!cs) {
|
||||||
|
qemu_log_mask(LOG_GUEST_ERROR,
|
||||||
|
"loongarch-dintc: no CPU for arch_id %d\n", cpu_num);
|
||||||
|
return;
|
||||||
|
}
|
||||||
irq_num = FIELD_EX64(msg_addr, MSG_ADDR, IRQ_NUM);
|
irq_num = FIELD_EX64(msg_addr, MSG_ADDR, IRQ_NUM);
|
||||||
|
|
||||||
async_run_on_cpu(cs, do_set_vcpu_dintc_irq,
|
async_run_on_cpu(cs, do_set_vcpu_dintc_irq,
|
||||||
|
|||||||
@@ -10,6 +10,11 @@
|
|||||||
|
|
||||||
#define TARGET_VIRT_ADDR_SPACE_BITS 48
|
#define TARGET_VIRT_ADDR_SPACE_BITS 48
|
||||||
|
|
||||||
#define TARGET_PAGE_BITS 12
|
#ifdef CONFIG_USER_ONLY
|
||||||
|
/* Allow user-only to vary page size from 4k */
|
||||||
|
# define TARGET_PAGE_BITS_VARY
|
||||||
|
#else
|
||||||
|
# define TARGET_PAGE_BITS 12
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -46,12 +46,12 @@ static int kvm_get_stealtime(CPUState *cs)
|
|||||||
.addr = (uint64_t)&env->stealtime.guest_addr,
|
.addr = (uint64_t)&env->stealtime.guest_addr,
|
||||||
};
|
};
|
||||||
|
|
||||||
err = kvm_vcpu_ioctl(cs, KVM_HAS_DEVICE_ATTR, attr);
|
err = kvm_vcpu_ioctl(cs, KVM_HAS_DEVICE_ATTR, &attr);
|
||||||
if (err) {
|
if (err) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = kvm_vcpu_ioctl(cs, KVM_GET_DEVICE_ATTR, attr);
|
err = kvm_vcpu_ioctl(cs, KVM_GET_DEVICE_ATTR, &attr);
|
||||||
if (err) {
|
if (err) {
|
||||||
error_report("PVTIME: KVM_GET_DEVICE_ATTR: %s", strerror(errno));
|
error_report("PVTIME: KVM_GET_DEVICE_ATTR: %s", strerror(errno));
|
||||||
return err;
|
return err;
|
||||||
@@ -70,12 +70,12 @@ static int kvm_set_stealtime(CPUState *cs)
|
|||||||
.addr = (uint64_t)&env->stealtime.guest_addr,
|
.addr = (uint64_t)&env->stealtime.guest_addr,
|
||||||
};
|
};
|
||||||
|
|
||||||
err = kvm_vcpu_ioctl(cs, KVM_HAS_DEVICE_ATTR, attr);
|
err = kvm_vcpu_ioctl(cs, KVM_HAS_DEVICE_ATTR, &attr);
|
||||||
if (err) {
|
if (err) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = kvm_vcpu_ioctl(cs, KVM_SET_DEVICE_ATTR, attr);
|
err = kvm_vcpu_ioctl(cs, KVM_SET_DEVICE_ATTR, &attr);
|
||||||
if (err) {
|
if (err) {
|
||||||
error_report("PVTIME: KVM_SET_DEVICE_ATTR %s with gpa "TARGET_FMT_lx,
|
error_report("PVTIME: KVM_SET_DEVICE_ATTR %s with gpa "TARGET_FMT_lx,
|
||||||
strerror(errno), env->stealtime.guest_addr);
|
strerror(errno), env->stealtime.guest_addr);
|
||||||
@@ -96,13 +96,13 @@ static int kvm_set_pv_features(CPUState *cs)
|
|||||||
.addr = (uint64_t)&val,
|
.addr = (uint64_t)&val,
|
||||||
};
|
};
|
||||||
|
|
||||||
err = kvm_vcpu_ioctl(cs, KVM_HAS_DEVICE_ATTR, attr);
|
err = kvm_vcpu_ioctl(cs, KVM_HAS_DEVICE_ATTR, &attr);
|
||||||
if (err) {
|
if (err) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
val = env->pv_features;
|
val = env->pv_features;
|
||||||
err = kvm_vcpu_ioctl(cs, KVM_SET_DEVICE_ATTR, attr);
|
err = kvm_vcpu_ioctl(cs, KVM_SET_DEVICE_ATTR, &attr);
|
||||||
if (err) {
|
if (err) {
|
||||||
error_report("Fail to set pv feature "TARGET_FMT_lx " with error %s",
|
error_report("Fail to set pv feature "TARGET_FMT_lx " with error %s",
|
||||||
val, strerror(errno));
|
val, strerror(errno));
|
||||||
@@ -713,11 +713,11 @@ static int kvm_loongarch_get_cpucfg(CPUState *cs)
|
|||||||
CPULoongArchState *env = cpu_env(cs);
|
CPULoongArchState *env = cpu_env(cs);
|
||||||
|
|
||||||
for (i = 0; i < 21; i++) {
|
for (i = 0; i < 21; i++) {
|
||||||
ret = kvm_get_one_reg(cs, KVM_IOC_CPUCFG(i), &val);
|
int r = kvm_get_one_reg(cs, KVM_IOC_CPUCFG(i), &val);
|
||||||
if (ret < 0) {
|
ret |= r;
|
||||||
trace_kvm_failed_get_cpucfg(strerror(errno));
|
if (!r) {
|
||||||
|
env->cpucfg[i] = (uint32_t)val;
|
||||||
}
|
}
|
||||||
env->cpucfg[i] = (uint32_t)val;
|
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -725,7 +725,7 @@ static int kvm_loongarch_get_cpucfg(CPUState *cs)
|
|||||||
static int kvm_check_cpucfg2(CPUState *cs)
|
static int kvm_check_cpucfg2(CPUState *cs)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
uint64_t val;
|
uint64_t val = 0;
|
||||||
struct kvm_device_attr attr = {
|
struct kvm_device_attr attr = {
|
||||||
.group = KVM_LOONGARCH_VCPU_CPUCFG,
|
.group = KVM_LOONGARCH_VCPU_CPUCFG,
|
||||||
.attr = 2,
|
.attr = 2,
|
||||||
@@ -736,8 +736,17 @@ static int kvm_check_cpucfg2(CPUState *cs)
|
|||||||
ret = kvm_vcpu_ioctl(cs, KVM_HAS_DEVICE_ATTR, &attr);
|
ret = kvm_vcpu_ioctl(cs, KVM_HAS_DEVICE_ATTR, &attr);
|
||||||
|
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
kvm_vcpu_ioctl(cs, KVM_GET_DEVICE_ATTR, &attr);
|
/*
|
||||||
env->cpucfg[2] &= val;
|
* The &= mask is best-effort feature negotiation. If HAS succeeded,
|
||||||
|
* a GET failure is most likely a copy_{from,to}_user issue; warn and
|
||||||
|
* keep the cpucfg2 the guest already has rather than failing the sync.
|
||||||
|
*/
|
||||||
|
int r = kvm_vcpu_ioctl(cs, KVM_GET_DEVICE_ATTR, &attr);
|
||||||
|
if (r) {
|
||||||
|
warn_report("CPUCFG2: KVM_GET_DEVICE_ATTR: %s", strerror(errno));
|
||||||
|
} else {
|
||||||
|
env->cpucfg[2] &= val;
|
||||||
|
}
|
||||||
|
|
||||||
if (FIELD_EX32(env->cpucfg[2], CPUCFG2, FP)) {
|
if (FIELD_EX32(env->cpucfg[2], CPUCFG2, FP)) {
|
||||||
/* The FP minimal version is 1. */
|
/* The FP minimal version is 1. */
|
||||||
@@ -761,16 +770,13 @@ static int kvm_loongarch_put_cpucfg(CPUState *cs)
|
|||||||
|
|
||||||
for (i = 0; i < 21; i++) {
|
for (i = 0; i < 21; i++) {
|
||||||
if (i == 2) {
|
if (i == 2) {
|
||||||
ret = kvm_check_cpucfg2(cs);
|
int r = kvm_check_cpucfg2(cs);
|
||||||
if (ret) {
|
if (r) {
|
||||||
return ret;
|
return r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val = env->cpucfg[i];
|
val = env->cpucfg[i];
|
||||||
ret = kvm_set_one_reg(cs, KVM_IOC_CPUCFG(i), &val);
|
ret |= kvm_set_one_reg(cs, KVM_IOC_CPUCFG(i), &val);
|
||||||
if (ret < 0) {
|
|
||||||
trace_kvm_failed_put_cpucfg(strerror(errno));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,5 @@ kvm_failed_get_mpstate(const char *msg) "Failed to get mp_state from KVM: %s"
|
|||||||
kvm_failed_put_mpstate(const char *msg) "Failed to put mp_state into KVM: %s"
|
kvm_failed_put_mpstate(const char *msg) "Failed to put mp_state into KVM: %s"
|
||||||
kvm_failed_get_counter(const char *msg) "Failed to get counter from KVM: %s"
|
kvm_failed_get_counter(const char *msg) "Failed to get counter from KVM: %s"
|
||||||
kvm_failed_put_counter(const char *msg) "Failed to put counter into KVM: %s"
|
kvm_failed_put_counter(const char *msg) "Failed to put counter into KVM: %s"
|
||||||
kvm_failed_get_cpucfg(const char *msg) "Failed to get cpucfg from KVM: %s"
|
|
||||||
kvm_failed_put_cpucfg(const char *msg) "Failed to put cpucfg into KVM: %s"
|
|
||||||
kvm_arch_handle_exit(int num) "kvm arch handle exit, the reason number: %d"
|
kvm_arch_handle_exit(int num) "kvm arch handle exit, the reason number: %d"
|
||||||
kvm_set_intr(int irq, int level) "kvm set interrupt, irq num: %d, level: %d"
|
kvm_set_intr(int irq, int level) "kvm set interrupt, irq num: %d, level: %d"
|
||||||
|
|||||||
Reference in New Issue
Block a user