[PATCH v2 4/9] target/loongarch: Add header file cpu-mmu.h

2025-07-18 Thread Bibo Mao
New header file cpu-mmu.h is added and move mmu relative function declaration to this file. Signed-off-by: Bibo Mao --- target/loongarch/cpu-mmu.h| 30 ++ target/loongarch/cpu.c| 1 + target/loongarch/cpu_helper.c | 1 + target/loongarch

[PATCH v2 6/9] target/loongarch: Use loongarch_check_pte() with page table walking

2025-07-18 Thread Bibo Mao
Function loongarch_check_pte() can get physical address and access priviledge, it works on both TLB entry and pte entry. It can be used at page table walking. Signed-off-by: Bibo Mao --- target/loongarch/cpu_helper.c | 35 ++- 1 file changed, 10 insertions(+), 25

[PATCH v2 8/9] target/loongarch: Use correct page size when flush tlb

2025-07-18 Thread Bibo Mao
On LoongArch system, there are two pages with one TLB entry. If the whole TLB entry is flushed, two pages will be flushed. Otherwise if tlb is flushed one by one, page size is one page at a time. Also virtual address of odd page is fixed here. Signed-off-by: Bibo Mao --- target/loongarch/tcg

[PATCH v2 9/9] target/loongarch: Use fine-grained tlb flush method

2025-07-18 Thread Bibo Mao
Qemu TCG provides some tlb flushing API, tlb can be flushed with specified mmu idx and virtual address. Here fine-grained tlb flush method is used. Signed-off-by: Bibo Mao --- target/loongarch/tcg/tlb_helper.c | 19 +++ 1 file changed, 15 insertions(+), 4 deletions(-) diff

[PATCH v2 7/9] target/loongarch: Use mmu idx bitmap method when flush tlb

2025-07-18 Thread Bibo Mao
With API tlb_flush_range_by_mmuidx(), bitmap method of mmu idx should be used rather than itself. Also mmu idx comes from page table entry information rather current running mode. With page table entry, global bit for MMU_KERNEL_IDX, otherwise it is MMU_USER_IDX. Signed-off-by: Bibo Mao

[PATCH v2 2/9] target/loongarch: Define function loongarch_cpu_post_init as static

2025-07-18 Thread Bibo Mao
-by: Bibo Mao --- target/loongarch/cpu.c | 180 - target/loongarch/cpu.h | 2 - 2 files changed, 90 insertions(+), 92 deletions(-) diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c index abad84c054..b96429ffb1 100644 --- a/target/loongarch

[PATCH v2 0/9] target/loongarch: Enhancement about tcg mmu

2025-07-18 Thread Bibo Mao
bitmap method with mmu idx, page size and address calculation --- Bibo Mao (9): target/loongarch: Move some function definition to kvm directory target/loongarch: Define function loongarch_cpu_post_init as static target/loongarch: Set page size in TLB misc with STLB target/loongarch: Add

[PATCH v2 1/9] target/loongarch: Move some function definition to kvm directory

2025-07-18 Thread Bibo Mao
Move function definition specified with kvm to the corresponding directory. Also remove header file "cpu.h" including outside of macro QEMU_KVM_LOONGARCH_H. Signed-off-by: Bibo Mao --- hw/loongarch/virt.c | 1 + target/loongarch/cpu.h | 9 ---

[PATCH v2 3/9] target/loongarch: Set page size in TLB misc with STLB

2025-07-18 Thread Bibo Mao
entries, even with STLB, it is convenient with TLB maintainance operation. Signed-off-by: Bibo Mao --- target/loongarch/tcg/tlb_helper.c | 41 --- 1 file changed, 10 insertions(+), 31 deletions(-) diff --git a/target/loongarch/tcg/tlb_helper.c b/target/loongarch/tcg

[PATCH v2 5/9] target/loongarch: Add common function loongarch_check_pte()

2025-07-18 Thread Bibo Mao
Common function loongarch_check_pte() is to check tlb entry, return the physical address and access priviledge. Also it can be used with page table entry, which is used in page table walker. Signed-off-by: Bibo Mao --- target/loongarch/cpu-mmu.h| 8 target/loongarch/cpu_helper.c

Re: [PATCH v5 02/11] hw/loongarch: add virt feature avecintc support

2025-07-14 Thread Bibo Mao
l be better if tcg_enabled() is used here, since CONFIG_TCG and CONFIG_KVM is enabled by default. It should be supported in KVM mode now. It is suggested in V4 review process :) Regards Bibo Mao +object_class_property_add(oc, "avecintc", "OnOffAuto", +

Re: [PATCH v5 09/11] target/loongarch: CPU enable msg interrupts.

2025-07-14 Thread Bibo Mao
inal sentence work? env->CSR_ESTAT = deposit64(env->CSR_ESTAT, irq, 1, level != 0); This piece of code is a little strange. Regards Bibo Mao +} else { +env->CSR_ESTAT = deposit64(env->CSR_ESTAT, irq, 1, level != 0); +} if (FIELD_EX64

Re: [PATCH v5 07/11] hw/loongarch: Implement avec controller imput and output pins

2025-07-14 Thread Bibo Mao
range to declare new variable between sentences, I think it should be put in the beginning of function. Regards Bibo Mao +for (int cpu = 0; cpu < ms->smp.cpus; cpu++) { +cpu_state = qemu_get_cpu(cpu); +cpudev = DEVICE(cpu_state); +

Re: [PATCH v5 08/11] hw/loongarch: Implement avec set irq

2025-07-14 Thread Bibo Mao
GARCH_AVEC(opaque); +uint64_t msg_addr = addr + VIRT_AVEC_BASE; +cpu_num = FIELD_EX64(msg_addr, MSG_ADDR, CPU_NUM); Here is physical cpuid rather than logic cpu index. We need convert physical cpuid to logic cpu index. Regards Bibo Mao +irq_num = FIELD_EX64(msg_addr, MSG_ADDR, IRQ_NUM

Re: [PATCH v5 05/11] target/loongarch: add msg interrupt CSR registers

2025-07-14 Thread Bibo Mao
VMSTATE_UINT64_ARRAY(env.CSR_MSGIS, LoongArchCPU, 4), ditto, it will be better if there is macro replaced with 4. Regards Bibo Mao +VMSTATE_UINT64(env.CSR_MSGIR, LoongArchCPU), +VMSTATE_UINT64(env.CSR_MSGIE, LoongArchCPU), +VMSTATE_END_OF_LIST() +}, +}; + static co

[PATCH] target/loongarch: Fix valid virtual address checking

2025-07-13 Thread Bibo Mao
val; addr = malloc(100); *(int *)addr = 1; addr1 = 0xULL + addr; val = *(int *)addr1; printf("val %d \n", val); } Cc: qemu-sta...@nongnu.org Signed-off-by: Bibo Mao --- target/loongarch/cpu_helper.c | 4 ++-- 1 file changed, 2

[PULL v2 0/4] loongarch-to-apply queue

2025-07-11 Thread Bibo Mao
The following changes since commit df6fe2abf2e990f767ce755d426bc439c7bba336: Merge tag 'pull-target-arm-20250704' of https://gitlab.com/pm215/qemu into staging (2025-07-07 09:22:41 -0400) are available in the Git repository at: https://github.com/bibo-mao/qemu.git tags/pull

[PULL v2 4/4] target/loongarch: Remove unnecessary page size validity checking

2025-07-11 Thread Bibo Mao
unnecessary in tlb entry fill path. Signed-off-by: Bibo Mao Reviewed-by: Song Gao --- target/loongarch/tcg/tlb_helper.c | 27 ++- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/target/loongarch/tcg/tlb_helper.c b/target/loongarch/tcg/tlb_helper.c index

[PULL v2 1/4] hw/intc/loongarch_extioi: Move unrealize function to common code

2025-07-11 Thread Bibo Mao
Memory about LoongArchExtIOICommonState::cpu is allocated in common code, it had better be freed in common code also. Signed-off-by: Bibo Mao Reviewed-by: Song Gao --- hw/intc/loongarch_extioi.c| 9 - hw/intc/loongarch_extioi_common.c | 9 + include/hw

[PULL v2 3/4] target/loongarch: Fix CSR STLBPS register write emulation

2025-07-11 Thread Bibo Mao
Function helper_csrwr_stlbps() is emulation with CSR STLBPS register write operation. However there is only parameter checking action, and no register updating action. Here update value of CSR_STLBPS when parameter passes to check. Signed-off-by: Bibo Mao Reviewed-by: Song Gao --- target

[PULL v2 2/4] target/loongarch: Correct spelling in helper_csrwr_pwcl()

2025-07-11 Thread Bibo Mao
There is small typo issue in function helper_csrwr_pwcl(), this patch corrects this issue. Signed-off-by: Bibo Mao Reviewed-by: Song Gao --- target/loongarch/tcg/csr_helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/loongarch/tcg/csr_helper.c b/target

Re: [PULL 0/4] loongarch-to-apply queue

2025-07-10 Thread Bibo Mao
On 2025/7/10 下午8:43, Stefan Hajnoczi wrote: On Thu, Jul 10, 2025 at 5:34 AM Bibo Mao wrote: The following changes since commit df6fe2abf2e990f767ce755d426bc439c7bba336: Merge tag 'pull-target-arm-20250704' of https://gitlab.com/pm215/qemu into staging (2025-07-07 09:22:41 -

[PULL 3/4] target/loongarch: Fix CSR STLBPS register write emulation

2025-07-10 Thread Bibo Mao
Function helper_csrwr_stlbps() is emulation with CSR STLBPS register write operation. However there is only parameter checking action, and no register updating action. Here update value of CSR_STLBPS when parameter passes to check. Signed-off-by: Bibo Mao Reviewed-by: Song Gao --- target

[PULL 0/4] loongarch-to-apply queue

2025-07-10 Thread Bibo Mao
The following changes since commit df6fe2abf2e990f767ce755d426bc439c7bba336: Merge tag 'pull-target-arm-20250704' of https://gitlab.com/pm215/qemu into staging (2025-07-07 09:22:41 -0400) are available in the Git repository at: https://github.com/bibo-mao/qemu.git tags/pull

[PULL 4/4] target/loongarch: Remove unnecessary page size validity checking

2025-07-10 Thread Bibo Mao
unnecessary in tlb entry fill path. Signed-off-by: Bibo Mao Reviewed-by: Song Gao --- target/loongarch/tcg/tlb_helper.c | 24 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/target/loongarch/tcg/tlb_helper.c b/target/loongarch/tcg/tlb_helper.c index dc48b0f4d2

[PULL 1/4] hw/intc/loongarch_extioi: Move unrealize function to common code

2025-07-10 Thread Bibo Mao
Memory about LoongArchExtIOICommonState::cpu is allocated in common code, it had better be freed in common code also. Signed-off-by: Bibo Mao Reviewed-by: Song Gao --- hw/intc/loongarch_extioi.c| 9 - hw/intc/loongarch_extioi_common.c | 9 + include/hw

[PULL 2/4] target/loongarch: Correct spelling in helper_csrwr_pwcl()

2025-07-10 Thread Bibo Mao
There is small typo issue in function helper_csrwr_pwcl(), this patch corrects this issue. Signed-off-by: Bibo Mao Reviewed-by: Song Gao --- target/loongarch/tcg/csr_helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/loongarch/tcg/csr_helper.c b/target

Re: [PATCH v4 10/11] target/loongarch:Implement csrrd CSR_MSGIR register

2025-07-09 Thread Bibo Mao
irq = -1; How about irq = BIT(31), the other bits keeps zero except bit 31? Regards Bibo Mao +} + +return irq; +} + target_ulong helper_csrwr_estat(CPULoongArchState *env, target_ulong val) { int64_t old_v = env->CSR_ESTAT; diff --git a/target/loongarch/tcg/helper.h b/targe

Re: [PATCH v4 09/11] target/loongarch: CPU enable msg interrupts.

2025-07-09 Thread Bibo Mao
+} + if (kvm_enabled()) { kvm_loongarch_set_interrupt(cpu, irq, level); } else if (tcg_enabled()) { modification estat should be put here. Regards Bibo Mao

Re: [PATCH v4 08/11] hw/loongarch: Implement avec set irq

2025-07-09 Thread Bibo Mao
num / 64]); +qemu_set_irq(s->cpu[cpu_num].parent_irq, 1); +} +qemu_set_irq(s->cpu[cpu_num].parent_irq, level); There is double function call with qemu_set_irq(). Regards Bibo Mao +} + static void loongarch_avec_mem_write(void *opaque, hwaddr addr,

Re: [PATCH v4 03/11] hw/loongarch: add misc register supoort avecintc

2025-07-09 Thread Bibo Mao
be renamed as virt_has_avecintc()? Regards Bibo Mao +ret |= BIT(IOCSRF_AVEC); +} if (kvm_enabled()) { ret |= BIT(IOCSRF_VM); } @@ -624,6 +631,10 @@ static MemTxResult virt_iocsr_misc_read(void *opaque, hwaddr addr, if (

Re: [PATCH v4 02/11] hw/loongarch: add virt feature avecintc support

2025-07-09 Thread Bibo Mao
re & BIT(IOCSRF_AVEC))) { +return false; +} There had better be one empty line, however it is up to you since I am not good at coding style. Regards Bibo Mao +return true; +} + static inline bool virt_is_veiointc_enabled(LoongArchVirtMachineState *lvms) { if (lvms->veiointc == ON_OFF_AUTO_OFF) {

Re: [PATCH v4 01/11] target/loongarch: move some machine dfine to virt.h

2025-07-09 Thread Bibo Mao
e, %s/dfine/define/ "move some machine dfine to virt.h" otherwise look good to me. Reviewed-by: Bibo Mao

[PATCH 2/6] target/loongarch: Define function loongarch_cpu_post_init as static

2025-07-08 Thread Bibo Mao
-by: Bibo Mao --- target/loongarch/cpu.c | 180 - target/loongarch/cpu.h | 2 - 2 files changed, 90 insertions(+), 92 deletions(-) diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c index abad84c054..b96429ffb1 100644 --- a/target/loongarch

[PATCH 3/6] target/loongarch: Set page size in TLB misc with STLB

2025-07-08 Thread Bibo Mao
entries, even with STLB, it is convenient with TLB maintainance operation. Signed-off-by: Bibo Mao --- target/loongarch/tcg/tlb_helper.c | 41 --- 1 file changed, 10 insertions(+), 31 deletions(-) diff --git a/target/loongarch/tcg/tlb_helper.c b/target/loongarch/tcg

[PATCH 4/6] target/loongarch: Add header file cpu-mmu.h

2025-07-08 Thread Bibo Mao
New header file cpu-mmu.h is added and move mmu relative function declaration to this file. Signed-off-by: Bibo Mao --- target/loongarch/cpu-mmu.h| 30 ++ target/loongarch/cpu.c| 1 + target/loongarch/cpu_helper.c | 1 + target/loongarch

[PATCH 6/6] target/loongarch: Use loongarch_check_pte() with page table walking

2025-07-08 Thread Bibo Mao
Function loongarch_check_pte() can get physical address and access priviledge, it works on both TLB entry and pte entry. It can be used at page table walking. Signed-off-by: Bibo Mao --- target/loongarch/cpu_helper.c | 35 ++- 1 file changed, 10 insertions(+), 25

[PATCH 0/6] target/loongarch: Enhancement about tcg mmu

2025-07-08 Thread Bibo Mao
table walk emluation in future. Bibo Mao (6): target/loongarch: Move some function definition to kvm directory target/loongarch: Define function loongarch_cpu_post_init as static target/loongarch: Set page size in TLB misc with STLB target/loongarch: Add header file cpu-mmu.h target

[PATCH 5/6] target/loongarch: Add common function loongarch_check_pte()

2025-07-08 Thread Bibo Mao
Common function loongarch_check_pte() is to check tlb entry, return the physical address and access priviledge. Also it can be used with page table entry, which is used in page table walker. Signed-off-by: Bibo Mao --- target/loongarch/cpu-mmu.h| 9 + target/loongarch/cpu_helper.c

[PATCH 1/6] target/loongarch: Move some function definition to kvm directory

2025-07-08 Thread Bibo Mao
Move function definition specified with kvm to the corresponding directory. Also remove header file "cpu.h" including outside of macro QEMU_KVM_LOONGARCH_H. Signed-off-by: Bibo Mao --- hw/loongarch/virt.c | 1 + target/loongarch/cpu.h | 9 ---

[PATCH 4/6] target/loongarch: Add header file cpu-mmu.h

2025-07-08 Thread Bibo Mao
New header file cpu-mmu.h is added and move mmu relative function declaration to this file. Signed-off-by: Bibo Mao --- target/loongarch/cpu-mmu.h| 30 ++ target/loongarch/cpu.c| 1 + target/loongarch/cpu_helper.c | 1 + target/loongarch

[PATCH 0/6] target/loongarch: Enhancement about tcg mmu

2025-07-08 Thread Bibo Mao
table walk emluation in future. Bibo Mao (6): target/loongarch: Move some function definition to kvm directory target/loongarch: Define function loongarch_cpu_post_init as static target/loongarch: Set page size in TLB misc with STLB target/loongarch: Add header file cpu-mmu.h target

Re: [PATCH V1 1/2] hw/rtc: Fixed loongson rtc emulation errors

2025-07-07 Thread Bibo Mao
On 2025/7/7 下午2:36, lixianglai wrote: Hi Bibo Mao: On 2025/6/13 上午9:31, Xianglai Li wrote: The expire time is sent to the timer only when the expire Time is greater than 0 or greater than now. Otherwise, the timer will trigger interruption continuously. Timer interrupts are sent using

Re: [PATCH v3 7/9] hw/loongarch: Implement avec set irq

2025-07-02 Thread Bibo Mao
On 2025/7/2 下午3:21, gaosong wrote: 在 2025/7/2 上午11:15, Bibo Mao 写道: On 2025/6/27 上午11:01, Song Gao wrote: Implement avec set irq and update CSR_MSIS and CSR_MSGIR. Signed-off-by: Song Gao ---   hw/intc/loongarch_avec.c | 44 ++--   1 file changed, 42

Re: [PATCH v3 2/9] hw/loongarch: add virt feature avecintc support

2025-07-02 Thread Bibo Mao
On 2025/7/2 下午3:10, gaosong wrote: 在 2025/7/2 上午10:03, Bibo Mao 写道: On 2025/6/27 上午11:01, Song Gao wrote: LoongArchVirtMachinState adds avecintc features, and it use to check whether virt machine support advance interrupt controller and default set avecintc = ON_OFF_AUTO_ON

Re: [PATCH v3 2/9] hw/loongarch: add virt feature avecintc support

2025-07-01 Thread Bibo Mao
{ +if (!(lvms->misc_feature & BIT(IOCSRF_AVEC))) { +return false; + } + +if (lvms->avecintc == ON_OFF_AUTO_OFF) { +return false; +} Is it enough to only check variable misc_feature? checking avecintc seems unnecessary duplicated. Regards Bibo Mao +return true; +} + static inline bool virt_is_veiointc_enabled(LoongArchVirtMachineState *lvms) { if (lvms->veiointc == ON_OFF_AUTO_OFF) {

Re: [PATCH v3 8/9] target/loongarch: CPU enable msg interrupts.

2025-07-01 Thread Bibo Mao
if (irq == INT_AVEC) { env->CSR_ESTAT = FIELD_DP64(env->CSR_ESTAT, CSR_ESTAT, MSGINT, 1); env->CSR_ECFG = FIELD_DP64(env->CSR_ECFG, CSR_ECFG, MSGINT, 1); } Regards Bibo Mao + if (kvm_enabled()) { kvm_loongarch_set_interrupt(cpu, irq, level); } else if (tcg_enabled()) {

Re: [PATCH v3 7/9] hw/loongarch: Implement avec set irq

2025-07-01 Thread Bibo Mao
MSGIS[i]) { +return; +} +} +qemu_set_irq(s->cpu[cpu_num].parent_irq, 0); Here such code can inject interrupt to cpu side. if (level) { set_bit(irq_num, &env->CSR_MSGIS[irq_num / 64]); qemu_set_irq(s->cpu[cpu_num].parent_irq, 1);

Re: [PATCH v3 0/9] hw/loongarch: add the advanced extended interrupt controllers (AVECINTC) support

2025-07-01 Thread Bibo Mao
s on how MSI vector is allocated on VM. Regards Bibo Mao ^ ^ ^ | | | +-+ +-+ +-+ | Devices | | PCH-LPC |

Re: [PATCH v3 4/9] target/loongarch: add msg interrupt CSR registers

2025-07-01 Thread Bibo Mao
LoongArchCPU *cpu = opaque; + +return FIELD_EX64(cpu->env.cpucfg[1], CPUCFG1, MSG_INT); For AVEC capability, there is bit MSG_INT in register cpucfg1 and bit IOCSRF_AVEC in IOCSR FEATURE_REG register. Which should be used by real hardware? Regards Bibo Mao +} + +static const VMStateDescr

Re: [PATCH v3 6/9] hw/loongarch: Implement avec controller imput and output pins

2025-07-01 Thread Bibo Mao
to config so many gpio lines with number NR_VECTORS * s->num_cpu. Regards Bibo Mao + return; } diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c index 6fb08740c2..1d4e62b1cf 100644 --- a/hw/loongarch/virt.c +++ b/hw/loongarch/virt.c @@ -381,7 +381,7 @@ static void virt_cpu_i

Re: [PATCH v3 1/9] hw/loongarch: move some machine define to virt.h

2025-07-01 Thread Bibo Mao
51 I suggest to split it into two patches, one is purely code moving between header files, the other is actual code modification. Regards Bibo Mao #define LOONGARCH_MAX_CPUS 256 #define VIRT_FWCFG_BASE 0x1e02UL diff --git a/target/loongarch/cpu.h b/target/loongarc

Re: [PATCH v2 7/9] hw/loongarch: Implement avec set irq

2025-06-20 Thread Bibo Mao
CSR_MSGIS[4] in CSR register emulation. And when all bits about CSR_MSGIS[4] are cleared, parent irq can be set with 0 such as: qemu_set_irq(s->cpu[cpu_num].parent_irq, 0); Regards Bibo Mao +} + static void loongarch_avec_mem_write(void *opaque, hwaddr addr,

Re: [PATCH v2 4/9] target/loongarch: add msg interrupt CSR registers

2025-06-20 Thread Bibo Mao
is compatible with old machine. Regards Bibo Mao VMSTATE_UINT64(kvm_state_counter, LoongArchCPU), /* PV steal time */ VMSTATE_UINT64(env.stealtime.guest_addr, LoongArchCPU),

Re: [PATCH v6] target/loongarch: fix vldi/xvldi raise wrong error

2025-06-18 Thread Bibo Mao
It will be better if check_vldi_mode() is renamed as check_valid_vldi_mode(). Reviewed-by: Bibo Mao On 2025/6/18 下午3:49, gaosong wrote: Ping ! :-) 在 2025/6/5 上午9:53, Song Gao 写道: on qemu we got an aborted error ** ERROR:../target/loongarch/tcg/insn_trans/trans_vec.c.inc:3574:vldi_get_value

[PATCH 0/3] target/loongarch: Code cleanup with tlb emulation

2025-06-17 Thread Bibo Mao
This patchset is small code cleanup with LoongArch TLB emulation. LoongArch does not support hardware page table walker, TLB handling is complicated compared with common architectures. Bibo Mao (3): target/loongarch: Correct spelling in helper_csrwr_pwcl() target/loongarch: Fix CSR STLBPS

[PATCH 2/3] target/loongarch: Fix CSR STLBPS register write emulation

2025-06-17 Thread Bibo Mao
Function helper_csrwr_stlbps() is emulation with CSR STLBPS register write operation. However there is only parameter checking action, and no register updating action. Here update value of CSR_STLBPS when parameter passes to check. Signed-off-by: Bibo Mao --- target/loongarch/tcg/csr_helper.c

[PATCH 3/3] target/loongarch: Remove unnecessary page size validity checking

2025-06-17 Thread Bibo Mao
unnecessary in tlb entry fill path. Signed-off-by: Bibo Mao --- target/loongarch/tcg/tlb_helper.c | 24 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/target/loongarch/tcg/tlb_helper.c b/target/loongarch/tcg/tlb_helper.c index dc48b0f4d2..21381ba59f 100644 --- a

[PATCH 1/3] target/loongarch: Correct spelling in helper_csrwr_pwcl()

2025-06-17 Thread Bibo Mao
There is small typo issue in function helper_csrwr_pwcl(), this patch corrects this issue. Signed-off-by: Bibo Mao --- target/loongarch/tcg/csr_helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/loongarch/tcg/csr_helper.c b/target/loongarch/tcg/csr_helper.c

Re: [PATCH 07/10] hw/loongarch: connect pch_msi controller to avec controller

2025-06-17 Thread Bibo Mao
On 2025/6/17 上午9:58, gaosong wrote: 在 2025/6/11 下午2:36, Bibo Mao 写道: On 2025/6/9 下午6:48, Song Gao wrote: Signed-off-by: Song Gao ---   hw/loongarch/virt.c | 18 +-   1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c

Re: [PATCH 02/10] loongarch: add virt feature avecintc support

2025-06-15 Thread Bibo Mao
On 2025/6/13 下午3:54, gaosong wrote: 在 2025/6/11 下午2:46, Bibo Mao 写道: On 2025/6/9 下午6:48, Song Gao wrote: LoongArchVirtMachinState add  avecintc features, and it use to check whether virt machine support advance interrupt controller and default is on. Signed-off-by: Song Gao ---   hw

Re: [PATCH V1 2/2] hw/loongarch: add rtc acpi table

2025-06-12 Thread Bibo Mao
On 2025/6/13 上午9:31, Xianglai Li wrote: Add the acpi table to the loongson rtc hardware so that the virtual machine kernel can use the loongson RTC-related drivers. Signed-off-by: Xianglai Li --- Cc: Bibo Mao Cc: Song Gao Cc: Jiaxun Yang Cc: Xianglai Li hw/loongarch/virt-acpi-build.c

Re: [PATCH V1 1/2] hw/rtc: Fixed loongson rtc emulation errors

2025-06-12 Thread Bibo Mao
: Bibo Mao Cc: Song Gao Cc: Jiaxun Yang Cc: Xianglai Li hw/loongarch/virt-fdt-build.c | 11 +-- hw/rtc/ls7a_rtc.c | 26 +- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/hw/loongarch/virt-fdt-build.c b/hw/loongarch/virt-fdt-build.c

Re: [PATCH V1 1/2] hw/rtc: Fixed loongson rtc emulation errors

2025-06-12 Thread Bibo Mao
split into two patches, one is fixup with irq pulse type setting, the other is fixup with expired time out calculation in rtc emulation driver. Regards Bibo Mao Timer interrupts are sent using pulse functions. Signed-off-by: Xianglai Li --- Cc: Bibo Mao Cc: Song Gao Cc: Jiaxun Yang Cc

Re: [PATCH V1 2/2] hw/loongarch: add rtc acpi table

2025-06-12 Thread Bibo Mao
: Xianglai Li --- Cc: Bibo Mao Cc: Song Gao Cc: Jiaxun Yang Cc: Xianglai Li hw/loongarch/virt-acpi-build.c | 24 1 file changed, 24 insertions(+) diff --git a/hw/loongarch/virt-acpi-build.c b/hw/loongarch/virt-acpi-build.c index 2cd2d9d842..2cfc5421c5 100644 --- a/hw

[PATCH v3 0/5] Add bios-tables-test for LoongArch system

2025-06-12 Thread Bibo Mao
requirement with virtio-blk-pci with test case. 4. Merge patch 6 and patch 3 into together, and adjust patch order. 5. Add oem-id test case. --- Bibo Mao (5): tests/acpi: Add empty ACPI data files for LoongArch tests/qtest/bios-tables-test: Add basic testing for LoongArch rebuild-expected

[PATCH v3 4/5] tests/acpi: Fill acpi table data for LoongArch

2025-06-12 Thread Bibo Mao
The acpi table data is filled for LoongArch virt machine with the following command: tests/data/acpi/rebuild-expected-aml.sh Signed-off-by: Bibo Mao --- tests/data/acpi/loongarch64/virt/APIC | Bin 0 -> 108 bytes tests/data/acpi/loongarch64/virt/APIC.topology | Bin 0 -> 153

[PATCH v3 2/5] tests/qtest/bios-tables-test: Add basic testing for LoongArch

2025-06-12 Thread Bibo Mao
Add basic ACPI table test case for LoongArch, including cpu topology, numa memory, memory hotplug and oem-id test cases. Signed-off-by: Bibo Mao --- tests/qtest/bios-tables-test.c | 79 ++ tests/qtest/meson.build| 1 + 2 files changed, 80 insertions

[PATCH v3 3/5] rebuild-expected-aml.sh: Add support for LoongArch

2025-06-12 Thread Bibo Mao
Update the list of supported architectures to include LoongArch. Signed-off-by: Bibo Mao --- tests/data/acpi/rebuild-expected-aml.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/data/acpi/rebuild-expected-aml.sh b/tests/data/acpi/rebuild-expected-aml.sh index

[PATCH v3 5/5] tests/acpi: Remove stale allowed tables

2025-06-12 Thread Bibo Mao
Remove stale allowed tables for LoongArch virt machine. Signed-off-by: Bibo Mao --- tests/qtest/bios-tables-test-allowed-diff.h | 8 1 file changed, 8 deletions(-) diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h index bad1380eec

[PATCH v3 1/5] tests/acpi: Add empty ACPI data files for LoongArch

2025-06-12 Thread Bibo Mao
Add empty acpi table for LoongArch virt machine, it is only empty file and there is no data in these files. Signed-off-by: Bibo Mao --- tests/data/acpi/loongarch64/virt/APIC | 0 tests/data/acpi/loongarch64/virt/DSDT | 0 tests/data/acpi/loongarch64/virt/FACP | 0 tests/data

Re: [PATCH 02/10] loongarch: add virt feature avecintc support

2025-06-10 Thread Bibo Mao
vec default */ -ret |= BIT_ULL(IOCSRM_AVEC_EN); +if (virt_is_avecintc_enabled(lvms)) { +ret |= BIT_ULL(IOCSRM_AVEC_EN); +} Is it really that reading of MISC_FUNC_REG will return BIT_ULL(IOCSRM_AVEC_EN) if there is avec? Where is the write operation with re

Re: [PATCH 06/10] hw/loongarch: Implement avec controller imput and output pins

2025-06-10 Thread Bibo Mao
RS; irq++) { +qdev_init_gpio_out(dev, &s->cpu[i].parent_irq[irq], 1); +} One parent irqline for per-cpu is ok, so the total number of parent irqline is s->num_cpu, the number of possible cpu. +} +qdev_init_gpio_in(dev, avec_irq_handler, NR_VECTORS * s-

Re: [PATCH 07/10] hw/loongarch: connect pch_msi controller to avec controller

2025-06-10 Thread Bibo Mao
_LOW) for pch_msi is [VIRT_PCH_MSI_ADDR_LOW, VIRT_PCH_MSI_ADDR_LOW + 0x8) For parent line, AVEC is connected to CPU MSGINT BIT14 and pch_msi is connected to extioi. So they can coexists together, it only depends on how guest kernel use MSI controller. Regards Bibo Mao +

Re: [PATCH 08/10] hw/loongarch: Implement avec set_irq

2025-06-10 Thread Bibo Mao
aque, int irq, int level) { -return; +int cpu_num, irq_num = 0; +LoongArchAVECState *s = LOONGARCH_AVEC(opaque); +cpu_num = irq / 256; +irq_num = irq % 256; + +avec_set_irq(s, cpu_num, irq_num, level); } When is the function avec_irq_handler() called? Regards Bibo Mao static void loongarch_avec_realize(DeviceState *dev, Error **errp)

Re: [PATCH 09/10] target/loongarch: loongarch CPU supoort avec irqs

2025-06-10 Thread Bibo Mao
4(env->CSR_ESTAT, CSR_ESTAT, MSGINT, 0); + env->CSR_MSGIR = FIELD_DP64(env->CSR_MSGIR, CSR_MSGIR, ACTIVE, 1); + return; +} what is the use about else {} sentences? Does it change interrupt logic if AVEC is disabled? Also I think it should be removed to the followin

Re: [PATCH 10/10] target/loongarch: cpu do interrupt support msg interrupt.

2025-06-10 Thread Bibo Mao
(CSR_ESTAT, IS, 0, 13) -FIELD(CSR_ESTAT, MSGINT, 14, 1) +FIELD(CSR_ESTAT, MSGINT, 14, 1)/* used for msg */ ditto, how about modify IS such as FIELD(CSR_ESTAT, IS, 0, 15)? Regards Bibo Mao FIELD(CSR_ESTAT, ECODE, 16, 6) FIELD(CSR_ESTAT, ESUBCODE, 22, 9) diff --git a/target/loongarch/cpu.c b

[PATCH v3 13/13] hw/loongarch/virt: Add kernel irqchip support

2025-06-05 Thread Bibo Mao
If kvm_irqchip_in_kernel() return true, interrupt controller ExtIOI, IPI, PCH_PCI and PCH_MSI should be emlated in kernel. And it is not necessary to create memory region for these devices in user space. Signed-off-by: Bibo Mao --- hw/loongarch/virt.c| 57

[PATCH v3 12/13] hw/loongarch/virt: Disable emulation with IOCSR misc register

2025-06-05 Thread Bibo Mao
Register IOCSR MISC_FUNC_REG is to enable features about EXTIOI irqchip. If EXTIOI is emulated in kernel, MISC_FUNC_REG register should be emulated in kernel also. Signed-off-by: Bibo Mao --- hw/loongarch/virt.c | 8 1 file changed, 8 insertions(+) diff --git a/hw/loongarch/virt.c b

[PATCH v3 11/13] target/loongarch: Report error with split kernel_irqchip option

2025-06-05 Thread Bibo Mao
Option kernel_irqchip=split is not supported on LoongArch virt machine, report error and exit if detect split kernel_irqchip option. Signed-off-by: Bibo Mao --- target/loongarch/kvm/kvm.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/target/loongarch/kvm/kvm.c b

[PATCH v3 10/13] hw/loongarch/virt: Add reset support for kernel irqchip

2025-06-05 Thread Bibo Mao
to reload register state. Signed-off-by: Bibo Mao --- hw/intc/loongarch_extioi.c | 4 hw/intc/loongarch_extioi_kvm.c | 4 hw/intc/loongarch_ipi.c| 4 hw/intc/loongarch_ipi_kvm.c| 4 hw/intc/loongarch_pch_pic.c| 4 hw/intc/loongarch_pic_kvm.c| 4

[PATCH v3 06/13] hw/intc/loongarch_pch_msi: Inject MSI interrupt to kernel

2025-06-05 Thread Bibo Mao
If kvm_irqchip_in_kernel() return true, MSI interrupt can be injected with API kvm_irqchip_send_msi() to KVM. Signed-off-by: Bibo Mao --- hw/intc/loongarch_pch_msi.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/hw/intc/loongarch_pch_msi.c b/hw/intc/loongarch_pch_msi.c index

[PATCH v3 09/13] hw/intc/loongarch_pch: Inject irq line interrupt to kernel

2025-06-05 Thread Bibo Mao
If kvm_irqchip_in_kernel() return true, irq line interrupt can be injected with API kvm_set_irq() to KVM. Signed-off-by: Bibo Mao --- hw/intc/loongarch_pch_pic.c | 5 + 1 file changed, 5 insertions(+) diff --git a/hw/intc/loongarch_pch_pic.c b/hw/intc/loongarch_pch_pic.c index 4d232f4cca

[PATCH v3 02/13] hw/intc/loongarch_extioi: Add kernel irqchip save and restore function

2025-06-05 Thread Bibo Mao
Add save and store funtction if kvm_irqchip_in_kernel() return true, it is to get and set ExtIOI irqchip state from KVM kernel. Signed-off-by: Bibo Mao --- hw/intc/loongarch_extioi.c | 14 + hw/intc/loongarch_extioi_kvm.c | 90 ++ include/hw/intc

[PATCH v3 04/13] hw/intc/loongson_ipi: Add load and save interface with ipi_common class

2025-06-05 Thread Bibo Mao
Add pre_save and post_load interfaces with ipi_common class, here only framework ipi_common adds these interfaces. The defailed implementation is LoongArchIPI child device in later. Signed-off-by: Bibo Mao --- hw/intc/loongson_ipi_common.c | 28 +++ include/hw

[PATCH v3 01/13] hw/intc/loongarch_extioi: Add kernel irqchip realize function

2025-06-05 Thread Bibo Mao
Function kvm_extioi_realize() is added if kvm_irqchip_in_kernel is set. It is to create and initialize ExtIOI device in kernel mode. Signed-off-by: Bibo Mao --- hw/intc/loongarch_extioi.c | 31 hw/intc/loongarch_extioi_kvm.c | 46

[PATCH v3 08/13] hw/intc/loongarch_pch: Add kernel irqchip save and restore function

2025-06-05 Thread Bibo Mao
Add save and store funtction if kvm_irqchip_in_kernel() return true, it is to get and set PCH PCI irqchip state from KVM kernel. Signed-off-by: Bibo Mao --- hw/intc/loongarch_pch_pic.c| 22 hw/intc/loongarch_pic_kvm.c| 47 ++ include

[PATCH v3 07/13] hw/intc/loongarch_pch: Add kernel irqchip realize function

2025-06-05 Thread Bibo Mao
Function kvm_pic_realize() is added if kvm_irqchip_in_kernel() return true. It is to notify KVM kernel to create and initialize PCH PCI device in kernel mode. Signed-off-by: Bibo Mao --- hw/intc/loongarch_pch_pic.c | 14 --- hw/intc/loongarch_pic_kvm.c | 38

[PATCH v3 05/13] hw/intc/loongarch_ipi: Add kernel irqchip save and restore function

2025-06-05 Thread Bibo Mao
Add save and store funtction if kvm_irqchip_in_kernel() return true, it is to get and set IPI irqchip state from KVM kernel. Signed-off-by: Bibo Mao --- hw/intc/loongarch_ipi.c | 20 hw/intc/loongarch_ipi_kvm.c | 54 + include/hw/intc

[PATCH v3 03/13] hw/intc/loongarch_ipi: Add kernel irqchip realize function

2025-06-05 Thread Bibo Mao
Function kvm_ipi_realize() is added if kvm_irqchip_in_kernel() return true. It is to create and initialize IPI device in kernel mode. Signed-off-by: Bibo Mao --- hw/intc/loongarch_ipi.c | 5 + hw/intc/loongarch_ipi_kvm.c | 27 +++ hw/intc

[PATCH v3 00/13] hw/loongarch/virt: Add kernel irqchip support

2025-06-05 Thread Bibo Mao
irqchip is set since it access EXTIOI memory region, this register need be emulated in kernel. Bibo Mao (13): hw/intc/loongarch_extioi: Add kernel irqchip realize function hw/intc/loongarch_extioi: Add kernel irqchip save and restore function hw/intc/loongarch_ipi: Add kernel irqchip

[PATCH] hw/intc/loongarch_extioi: Fix typo issue about register EXTIOI_COREISR_END

2025-06-05 Thread Bibo Mao
Interrupt controller extioi supports 256 vectors, register EXTIOI_COREISR records pending interrupt status with bitmap method. Size of EXTIOI_COREISR is 256 / 8 = 0x20 bytes, EXTIOI_COREISR_END should be EXTIOI_COREISR_START + 0x20 rather than 0xB20. Signed-off-by: Bibo Mao --- include/hw/intc

[PATCH 0/2] hw/loongarch/virt: Small enhancement about big endian host

2025-06-03 Thread Bibo Mao
On big endian host machine such as S390, bios-table-test fails to run. And also linux kernel fails to boot. This patches solves these two issues. Bibo Mao (2): hw/loongarch/virt: Fix big endian support with MCFG table hw/intc/loongarch_pch: Convert to little endian with ID register hw/intc

[PATCH 1/2] hw/loongarch/virt: Fix big endian support with MCFG table

2025-06-03 Thread Bibo Mao
machine S390. Fixes: 735143f10d3e ("hw/loongarch: Add acpi ged support") Cc: qemu-sta...@nongnu.org Signed-off-by: Bibo Mao --- hw/loongarch/virt-acpi-build.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/loongarch/virt-acpi-build.c b/hw/loongarch/virt-ac

[PATCH 2/2] hw/intc/loongarch_pch: Convert to little endian with ID register

2025-06-03 Thread Bibo Mao
hine with TCG method. Signed-off-by: Bibo Mao --- hw/intc/loongarch_pch_pic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/intc/loongarch_pch_pic.c b/hw/intc/loongarch_pch_pic.c index cbba2fc284..ebb33ed0b0 100644 --- a/hw/intc/loongarch_pch_pic.c +++ b/hw/intc/loonga

Re: [PATCH v5 0/4] Building PPTT with root node and identical implementation flag

2025-06-03 Thread Bibo Mao
Identical Implementation : 0 I'm sending a pull request later today. Once merged, pls rebase on top of that, updating loongarch as appropriate and repost copying relevant people. Cc Bibo Mao for more insight. Hi Micheal, I am trying to reproduce this issue. I have applied the patchset

Re: [PATCH v4] target/loongarch: fix vldi/xvldi raise wrong error

2025-06-03 Thread Bibo Mao
Song, It is a little strange that patch with three version is sent in one day. Maybe we should keep careful and calm :-) Regards Bibo Mao On 2025/6/3 下午4:25, Song Gao wrote: on qemu we got an aborted error ** ERROR:../target/loongarch/tcg/insn_trans/trans_vec.c.inc:3574:vldi_get_value: code

Re: [PATCH] hw/loongarch/virt: inform guest of kvm

2025-06-02 Thread Bibo Mao
Reviewed-by: Bibo Mao On 2025/6/3 上午11:18, Qiang Ma wrote: Commit bab27ea2e3 ("hw/arm/virt: smbios: inform guest of kvm") fixes the same issue on arm. without this patch: [root@localhost ~]# virt-what qemu with this patch: [root@localhost ~]# virt-what kvm Signed-off-by: Qiang Ma

Re: [PULL 00/31] virtio,pci,pc: features, fixes, tests

2025-06-02 Thread Bibo Mao
is the one you published and 3e82ddaa8d is the qemu.git/master. I could not figure it out. Must be a loongarch bug dealing with s390 hosts. I dropped them from the tag for now. Cc contributor to figure it out. Bibo Mao pls take a look. New tag: 0b006153b7ec66505cb2d231235aa19ca5d2ce37 Thanks!

[PATCH v2 12/12] hw/loongarch/virt: Add kernel irqchip support

2025-05-27 Thread Bibo Mao
If kvm_irqchip_in_kernel() return true, interrupt controller ExtIOI, IPI, PCH_PCI and PCH_MSI should be emlated in kernel. And it is not necessary to create memory region for these devices in user space. Signed-off-by: Bibo Mao --- hw/loongarch/virt.c| 57

  1   2   3   4   5   6   7   8   9   >