qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anup Patel <anup@brainfault.org>
To: Yifei Jiang <jiangyifei@huawei.com>
Cc: Bin Meng <bin.meng@windriver.com>,
	"open list:RISC-V" <qemu-riscv@nongnu.org>,
	Mingwang Li <limingwang@huawei.com>,
	KVM General <kvm@vger.kernel.org>,
	libvir-list@redhat.com, Anup Patel <anup.patel@wdc.com>,
	QEMU Developers <qemu-devel@nongnu.org>,
	wanbo13@huawei.com, Palmer Dabbelt <palmer@dabbelt.com>,
	kvm-riscv@lists.infradead.org, wanghaibin.wang@huawei.com,
	Alistair Francis <Alistair.Francis@wdc.com>,
	fanliang@huawei.com, "Wubin \(H\)" <wu.wubin@huawei.com>
Subject: Re: [PATCH v3 07/12] target/riscv: Support setting external interrupt by KVM
Date: Thu, 23 Dec 2021 11:35:23 +0530	[thread overview]
Message-ID: <CAAhSdy1rsRKwwLu2n58U0Wk8FVG17c3md-gDVAipgEC1P=srSQ@mail.gmail.com> (raw)
In-Reply-To: <20211220130919.413-8-jiangyifei@huawei.com>

On Mon, Dec 20, 2021 at 6:39 PM Yifei Jiang <jiangyifei@huawei.com> wrote:
>
> When KVM is enabled, set the S-mode external interrupt through
> kvm_riscv_set_irq function.
>
> Signed-off-by: Yifei Jiang <jiangyifei@huawei.com>
> Signed-off-by: Mingwang Li <limingwang@huawei.com>
> Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Looks good to me.

Reviewed-by: Anup Patel <anup.patel@wdc.com>

Regards,
Anup

> ---
>  target/riscv/cpu.c       |  6 +++++-
>  target/riscv/kvm-stub.c  |  5 +++++
>  target/riscv/kvm.c       | 17 +++++++++++++++++
>  target/riscv/kvm_riscv.h |  1 +
>  4 files changed, 28 insertions(+), 1 deletion(-)
>
> diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
> index 1c944872a3..3fc3a9c45b 100644
> --- a/target/riscv/cpu.c
> +++ b/target/riscv/cpu.c
> @@ -603,7 +603,11 @@ static void riscv_cpu_set_irq(void *opaque, int irq, int level)
>      case IRQ_S_EXT:
>      case IRQ_VS_EXT:
>      case IRQ_M_EXT:
> -        riscv_cpu_update_mip(cpu, 1 << irq, BOOL_TO_MASK(level));
> +        if (kvm_enabled()) {
> +            kvm_riscv_set_irq(cpu, irq, level);
> +        } else {
> +            riscv_cpu_update_mip(cpu, 1 << irq, BOOL_TO_MASK(level));
> +        }
>          break;
>      default:
>          g_assert_not_reached();
> diff --git a/target/riscv/kvm-stub.c b/target/riscv/kvm-stub.c
> index 39b96fe3f4..4e8fc31a21 100644
> --- a/target/riscv/kvm-stub.c
> +++ b/target/riscv/kvm-stub.c
> @@ -23,3 +23,8 @@ void kvm_riscv_reset_vcpu(RISCVCPU *cpu)
>  {
>      abort();
>  }
> +
> +void kvm_riscv_set_irq(RISCVCPU *cpu, int irq, int level)
> +{
> +    abort();
> +}
> diff --git a/target/riscv/kvm.c b/target/riscv/kvm.c
> index db6d8a5b6e..0027f11f45 100644
> --- a/target/riscv/kvm.c
> +++ b/target/riscv/kvm.c
> @@ -383,6 +383,23 @@ void kvm_riscv_reset_vcpu(RISCVCPU *cpu)
>      env->satp = 0;
>  }
>
> +void kvm_riscv_set_irq(RISCVCPU *cpu, int irq, int level)
> +{
> +    int ret;
> +    unsigned virq = level ? KVM_INTERRUPT_SET : KVM_INTERRUPT_UNSET;
> +
> +    if (irq != IRQ_S_EXT) {
> +        perror("kvm riscv set irq != IRQ_S_EXT\n");
> +        abort();
> +    }
> +
> +    ret = kvm_vcpu_ioctl(CPU(cpu), KVM_INTERRUPT, &virq);
> +    if (ret < 0) {
> +        perror("Set irq failed");
> +        abort();
> +    }
> +}
> +
>  bool kvm_arch_cpu_check_are_resettable(void)
>  {
>      return true;
> diff --git a/target/riscv/kvm_riscv.h b/target/riscv/kvm_riscv.h
> index f38c82bf59..ed281bdce0 100644
> --- a/target/riscv/kvm_riscv.h
> +++ b/target/riscv/kvm_riscv.h
> @@ -20,5 +20,6 @@
>  #define QEMU_KVM_RISCV_H
>
>  void kvm_riscv_reset_vcpu(RISCVCPU *cpu);
> +void kvm_riscv_set_irq(RISCVCPU *cpu, int irq, int level);
>
>  #endif
> --
> 2.19.1
>


  reply	other threads:[~2021-12-23  6:12 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-20 13:09 [PATCH v3 00/12] Add riscv kvm accel support Yifei Jiang via
2021-12-20 13:09 ` [PATCH v3 01/12] update-linux-headers: Add asm-riscv/kvm.h Yifei Jiang via
2021-12-20 13:09 ` [PATCH v3 02/12] target/riscv: Add target/riscv/kvm.c to place the public kvm interface Yifei Jiang via
2021-12-20 13:09 ` [PATCH v3 03/12] target/riscv: Implement function kvm_arch_init_vcpu Yifei Jiang via
2021-12-20 13:09 ` [PATCH v3 04/12] target/riscv: Implement kvm_arch_get_registers Yifei Jiang via
2021-12-20 13:09 ` [PATCH v3 05/12] target/riscv: Implement kvm_arch_put_registers Yifei Jiang via
2021-12-20 13:09 ` [PATCH v3 06/12] target/riscv: Support start kernel directly by KVM Yifei Jiang via
2021-12-23  6:03   ` Anup Patel
2021-12-23  6:04     ` Anup Patel
2022-01-10  1:28       ` Jiangyifei via
2021-12-20 13:09 ` [PATCH v3 07/12] target/riscv: Support setting external interrupt " Yifei Jiang via
2021-12-23  6:05   ` Anup Patel [this message]
2021-12-20 13:09 ` [PATCH v3 08/12] target/riscv: Handle KVM_EXIT_RISCV_SBI exit Yifei Jiang via
2022-01-05 22:03   ` Alistair Francis
2022-01-10  1:33     ` Jiangyifei via
2021-12-20 13:09 ` [PATCH v3 09/12] target/riscv: Add host cpu type Yifei Jiang via
2021-12-20 13:09 ` [PATCH v3 10/12] target/riscv: Add kvm_riscv_get/put_regs_timer Yifei Jiang via
2021-12-23  6:06   ` Anup Patel
2021-12-20 13:09 ` [PATCH v3 11/12] target/riscv: Implement virtual time adjusting with vm state changing Yifei Jiang via
2022-01-05 22:04   ` Alistair Francis
2021-12-20 13:09 ` [PATCH v3 12/12] target/riscv: Support virtual time context synchronization Yifei Jiang via
2022-01-05 22:10   ` Alistair Francis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAAhSdy1rsRKwwLu2n58U0Wk8FVG17c3md-gDVAipgEC1P=srSQ@mail.gmail.com' \
    --to=anup@brainfault.org \
    --cc=Alistair.Francis@wdc.com \
    --cc=anup.patel@wdc.com \
    --cc=bin.meng@windriver.com \
    --cc=fanliang@huawei.com \
    --cc=jiangyifei@huawei.com \
    --cc=kvm-riscv@lists.infradead.org \
    --cc=kvm@vger.kernel.org \
    --cc=libvir-list@redhat.com \
    --cc=limingwang@huawei.com \
    --cc=palmer@dabbelt.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    --cc=wanbo13@huawei.com \
    --cc=wanghaibin.wang@huawei.com \
    --cc=wu.wubin@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).