kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Anup Patel <anup.patel@wdc.com>
Cc: Will Deacon <will@kernel.org>,
	julien.thierry.kdev@gmail.com,
	Paolo Bonzini <pbonzini@redhat.com>,
	Atish Patra <atishp@atishpatra.org>,
	Alistair Francis <Alistair.Francis@wdc.com>,
	Anup Patel <anup@brainfault.org>,
	kvm@vger.kernel.org, kvm-riscv@lists.infradead.org,
	Vincent Chen <vincent.chen@sifive.com>
Subject: Re: [PATCH v10 kvmtool 5/8] riscv: Add PLIC device emulation
Date: Thu, 18 Nov 2021 10:13:28 +0000	[thread overview]
Message-ID: <87mtm17ovr.wl-maz@kernel.org> (raw)
In-Reply-To: <20211116052130.173679-6-anup.patel@wdc.com>

On Tue, 16 Nov 2021 05:21:27 +0000,
Anup Patel <anup.patel@wdc.com> wrote:
> 
> The PLIC (platform level interrupt controller) manages peripheral
> interrupts in RISC-V world. The per-CPU interrupts are managed
> using CPU CSRs hence virtualized in-kernel by KVM RISC-V.
> 
> This patch adds PLIC device emulation for KVMTOOL RISC-V.
> 
> Signed-off-by: Vincent Chen <vincent.chen@sifive.com>
> [For PLIC context CLAIM register emulation]
> Signed-off-by: Anup Patel <anup.patel@wdc.com>
> ---
>  Makefile                     |   1 +
>  riscv/include/kvm/kvm-arch.h |   2 +
>  riscv/irq.c                  |   4 +-
>  riscv/plic.c                 | 518 +++++++++++++++++++++++++++++++++++
>  4 files changed, 523 insertions(+), 2 deletions(-)
>  create mode 100644 riscv/plic.c
>

[...]

> +static void plic__context_write(struct plic_state *s,
> +				struct plic_context *c,
> +				u64 offset, void *data)
> +{
> +	u32 val;
> +	bool irq_update = false;
> +
> +	mutex_lock(&c->irq_lock);
> +
> +	switch (offset) {
> +	case CONTEXT_THRESHOLD:
> +		val = ioport__read32(data);
> +		val &= ((1 << PRIORITY_PER_ID) - 1);
> +		if (val <= s->max_prio)
> +			c->irq_priority_threshold = val;
> +		else
> +			irq_update = true;
> +		break;
> +	case CONTEXT_CLAIM:
> +		val = ioport__read32(data);
> +		if (val < plic.num_irq) {
> +			c->irq_claimed[val / 32] &= ~(1 << (val % 32));
> +			irq_update = true;
> +		}

This seems to ignore the nasty bit of the PLIC spec where a write to
CLAIM is ignored if the interrupt is masked.

	M.

-- 
Without deviation from the norm, progress is not possible.

  reply	other threads:[~2021-11-18 10:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-16  5:21 [PATCH v10 kvmtool 0/8] KVMTOOL RISC-V Support Anup Patel
2021-11-16  5:21 ` [PATCH v10 kvmtool 1/8] update_headers: Sync-up ABI headers with Linux-5.16-rc1 Anup Patel
2021-11-16  5:21 ` [PATCH v10 kvmtool 2/8] riscv: Initial skeletal support Anup Patel
2021-11-16  5:21 ` [PATCH v10 kvmtool 3/8] riscv: Implement Guest/VM arch functions Anup Patel
2021-11-16  5:21 ` [PATCH v10 kvmtool 4/8] riscv: Implement Guest/VM VCPU " Anup Patel
2021-11-16  5:21 ` [PATCH v10 kvmtool 5/8] riscv: Add PLIC device emulation Anup Patel
2021-11-18 10:13   ` Marc Zyngier [this message]
2021-11-18 10:37     ` Anup Patel
2021-11-16  5:21 ` [PATCH v10 kvmtool 6/8] riscv: Generate FDT at runtime for Guest/VM Anup Patel
2021-11-16  5:21 ` [PATCH v10 kvmtool 7/8] riscv: Handle SBI calls forwarded to user space Anup Patel
2021-11-16  5:21 ` [PATCH v10 kvmtool 8/8] riscv: Generate PCI host DT node Anup Patel

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=87mtm17ovr.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=Alistair.Francis@wdc.com \
    --cc=anup.patel@wdc.com \
    --cc=anup@brainfault.org \
    --cc=atishp@atishpatra.org \
    --cc=julien.thierry.kdev@gmail.com \
    --cc=kvm-riscv@lists.infradead.org \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=vincent.chen@sifive.com \
    --cc=will@kernel.org \
    /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).