From patchwork Wed Jul 17 03:29:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xianglai Li X-Patchwork-Id: 13735046 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AFA6423D2 for ; Wed, 17 Jul 2024 03:47:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=114.242.206.163 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721188063; cv=none; b=CVoMTtCHWCkq8mDPmf348hee1nCUEzcY+KO5zrNkRU4zF7ARqh6htl7Z3fYXaZO8PVfC5x/Q2k2fMHL+7iKiBMBB3ZiAZRmCVMD7pq1g+cMFcsOdJ+hwLRapmxCeQmktBSN+74jbtt0xWbYbQ4u2FCuz7l8ub3201a1z+ZgAuaQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721188063; c=relaxed/simple; bh=M5oWY91NJpRpAU3GjUHkrn4nR1GoURiLdhoF8mUSUKo=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=ZN9LyQbcLV9VDoo/1ExEqoT193XxK2rMFcmFAXYgXYwe9l0bnvmP74fGgbEDkbUon+Viuy0BY0TtwwIV9RmpGBRcsTy+P0yjsW7Hh+3Q0+XG/+g11hFPj/IkQITswzoC8/t1jAdHi4q9Hb8Se+CIAlUduHUhPkffSbRHTkZMM5k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=loongson.cn; spf=pass smtp.mailfrom=loongson.cn; arc=none smtp.client-ip=114.242.206.163 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=loongson.cn Received: from loongson.cn (unknown [10.2.5.185]) by gateway (Coremail) with SMTP id _____8Cxp+rZPpdm0FoFAA--.4391S3; Wed, 17 Jul 2024 11:47:37 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.185]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Bx08TYPpdmIgdMAA--.29770S2; Wed, 17 Jul 2024 11:47:36 +0800 (CST) From: Xianglai Li To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Song Gao , Huacai Chen , Jiaxun Yang , "Michael S. Tsirkin" , Cornelia Huck , kvm@vger.kernel.org, Bibo Mao Subject: [RFC 0/4] Added Interrupt controller emulation for loongarch kvm Date: Wed, 17 Jul 2024 11:29:52 +0800 Message-Id: X-Mailer: git-send-email 2.39.1 Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: AQAAf8Bx08TYPpdmIgdMAA--.29770S2 X-CM-SenderInfo: 5ol0xt5qjotxo6or00hjvr0hdfq/ X-Coremail-Antispam: 1Uk129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7 ZEXasCq-sGcSsGvfJ3UbIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnUUvcSsGvfC2Kfnx nUUI43ZEXa7xR_UUUUUUUUU== Before this, the interrupt controller simulation has been completed in the user mode program. In order to reduce the loss caused by frequent switching of the virtual machine monitor from kernel mode to user mode when the guest accesses the interrupt controller, we add the interrupt controller simulation in kvm. In qemu side implementation is simple, just make a new IPI EXTIOI PCH KVM related several classes, And the interface to access kvm related data is implemented. Most of the simulation work of the interrupt controller is done in kvm. Because KVM the changes have not been the Linux community acceptance, the patches of this series will have RFC label until KVM patch into the community. For the implementation of kvm simulation, refer to the following documents. IPI simulation implementation reference: https://github.com/loongson/LoongArch-Documentation/tree/main/docs/Loongson-3A5000-usermanual-EN/inter-processor-interrupts-and-communication EXTIOI simulation implementation reference: https://github.com/loongson/LoongArch-Documentation/tree/main/docs/Loongson-3A5000-usermanual-EN/io-interrupts/extended-io-interrupts PCH-PIC simulation implementation reference: https://github.com/loongson/LoongArch-Documentation/blob/main/docs/Loongson-7A1000-usermanual-EN/interrupt-controller.adoc For PCH-MSI, we used irqfd mechanism to send the interrupt signal generated by user state to kernel state and then to EXTIOI without maintaining PCH-MSI state in kernel state. You can easily get the code from the link below: the kernel: https://github.com/lixianglai/linux the branch is: interrupt the qemu: https://github.com/lixianglai/qemu the branch is: interrupt Please note that the code above is regularly updated based on community reviews. Cc: Paolo Bonzini Cc: Song Gao Cc: Huacai Chen Cc: Jiaxun Yang Cc: "Michael S. Tsirkin" Cc: Cornelia Huck Cc: kvm@vger.kernel.org Cc: Bibo Mao Xianglai Li (4): hw/loongarch: Add KVM IPI device support hw/loongarch: Add KVM extioi device support hw/loongarch: Add KVM pch pic device support hw/loongarch: Add KVM pch msi device support hw/intc/Kconfig | 12 ++ hw/intc/loongarch_extioi_kvm.c | 141 +++++++++++++++++++ hw/intc/loongarch_ipi_kvm.c | 207 ++++++++++++++++++++++++++++ hw/intc/loongarch_pch_msi.c | 42 ++++-- hw/intc/loongarch_pch_pic.c | 20 ++- hw/intc/loongarch_pch_pic_kvm.c | 189 +++++++++++++++++++++++++ hw/intc/meson.build | 3 + hw/loongarch/virt.c | 141 ++++++++++++------- include/hw/intc/loongarch_extioi.h | 34 ++++- include/hw/intc/loongarch_pch_msi.h | 2 +- include/hw/intc/loongarch_pch_pic.h | 51 ++++++- include/hw/intc/loongson_ipi.h | 22 +++ include/hw/loongarch/virt.h | 15 ++ linux-headers/asm-loongarch/kvm.h | 7 + linux-headers/linux/kvm.h | 6 + 15 files changed, 823 insertions(+), 69 deletions(-) create mode 100644 hw/intc/loongarch_extioi_kvm.c create mode 100644 hw/intc/loongarch_ipi_kvm.c create mode 100644 hw/intc/loongarch_pch_pic_kvm.c