Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Vladimir Murzin <vladimir.murzin@arm.com>
To: Sascha Bischoff <sascha.bischoff@arm.com>,
	will@kernel.org, julien.thierry.kdev@gmail.com
Cc: maz@kernel.org, kvm@vger.kernel.org, kvmarm@lists.linux.dev,
	timothy.hayes@arm.com, Peter Maydell <peter.maydell@linaro.org>
Subject: Re: [PATCH kvmtool v5 09/23] arm64: Configure the GICv5 IRS
Date: Thu, 19 Nov 2026 09:40:37 +0000	[thread overview]
Message-ID: <7eb028fc-b647-49d2-9528-7d79bc4e4f29@arm.com> (raw)
In-Reply-To: <20261118175755.1946977-10-sascha.bischoff@arm.com>

On 11/18/26 17:57, Sascha Bischoff wrote:
> Place the IRS CONFIG and SETLPI frames in two 64 KiB regions below the
> guest AXI area, and pass the IRS base to KVM through
> KVM_VGIC_V5_ADDR_TYPE_IRS.
> 
> The GICv5 NR_IRQS attribute counts SPIs without the 32 SGI/PPI lines
> included for earlier GICs. Use that count for GICv5 while retaining
> the existing count for GICv2/v3. Allow zero-based GICv5 IRQ numbers
> when setting the level through KVM_IRQ_LINE.
> 
> Tested-by: Vladimir Murzin <vladimir.murzin@arm.com>
> Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com>
> ---
>  arm64/gic.c                  | 30 ++++++++++++++++++++++++++++--
>  arm64/include/kvm/kvm-arch.h |  8 ++++++++
>  2 files changed, 36 insertions(+), 2 deletions(-)
> 
> diff --git a/arm64/gic.c b/arm64/gic.c
> index 58644036..5034b034 100644
> --- a/arm64/gic.c
> +++ b/arm64/gic.c
> @@ -18,6 +18,7 @@
>  static int gic_fd = -1;
>  static u64 gic_redists_base;
>  static u64 gic_redists_size;
> +static u64 gicv5_irs_base;
>  static u64 gic_msi_base;
>  static u64 gic_msi_size = 0;
>  static bool vgic_is_init = false;
> @@ -201,6 +202,22 @@ static int gic__set_redist(enum irqchip_type type)
>  	}
>  }
>  
> +static int gic__set_irs(enum irqchip_type type)
> +{
> +	struct kvm_device_attr irs_attr = {
> +		.group	= KVM_DEV_ARM_VGIC_GRP_ADDR,
> +		.attr	= KVM_VGIC_V5_ADDR_TYPE_IRS,
> +		.addr	= (u64)(unsigned long)&gicv5_irs_base,
> +	};
> +
> +	switch (type) {
> +	case IRQCHIP_GICV5:
> +		return ioctl(gic_fd, KVM_SET_DEVICE_ATTR, &irs_attr);
> +	default:	/* No IRS needed */
> +		return 0;
> +	}
> +}
> +
>  static int gic__set_dist(enum irqchip_type type)
>  {
>  	u64 dist_addr = ARM_GIC_DIST_BASE;
> @@ -291,6 +308,10 @@ static int gic__create_device(struct kvm *kvm, enum irqchip_type type)
>  	if (err)
>  		goto out_err;
>  
> +	err = gic__set_irs(type);
> +	if (err)
> +		goto out_err;
> +
>  	err = gic__set_dist(type);
>  	if (err)
>  		goto out_err;
> @@ -376,6 +397,7 @@ int gic__create(struct kvm *kvm, enum irqchip_type type)
>  		gic_msi_base = gic_redists_base - gic_msi_size;
>  		break;
>  	case IRQCHIP_GICV5:
> +		gicv5_irs_base = ARM_GICV5_IRS_BASE;
>  		break;
>  	default:
>  		return -ENODEV;
> @@ -397,8 +419,9 @@ static int gic__init_gic(struct kvm *kvm)
>  	int ret;
>  
>  	int lines = irq__get_nr_allocated_lines();
> -	u32 nr_irqs = ALIGN(lines, 32) + GIC_SPI_IRQ_BASE;
>  	u32 maint_irq = GIC_PPI_IRQ_BASE + GIC_MAINT_IRQ;
> +	u32 nr_irqs = max(ALIGN(lines, 32), 32);
> +
>  	struct kvm_device_attr nr_irqs_attr = {
>  		.group	= KVM_DEV_ARM_VGIC_GRP_NR_IRQS,
>  		.addr	= (u64)(unsigned long)&nr_irqs,
> @@ -412,6 +435,8 @@ static int gic__init_gic(struct kvm *kvm)
>  		.attr	= KVM_DEV_ARM_VGIC_CTRL_INIT,
>  	};
>  
> +	nr_irqs += gic__get_spi_base();
> +
>  	/*
>  	 * If we didn't use the KVM_CREATE_DEVICE method, KVM will
>  	 * give us some default number of interrupts. The GIC initialization
> @@ -540,12 +565,13 @@ u32 gic__get_fdt_irq_cpumask(struct kvm *kvm)
>  
>  void kvm__irq_line(struct kvm *kvm, int irq, int level)
>  {
> +	int spi_base = gic__get_spi_base();
>  	struct kvm_irq_level irq_level = {
>  		.irq	= KVM_IRQCHIP_IRQ(irq),
>  		.level	= !!level,
>  	};
>  
> -	if (irq < GIC_SPI_IRQ_BASE || irq > GIC_MAX_IRQ)
> +	if (irq < spi_base || irq > GIC_MAX_IRQ)
>  		pr_warning("Ignoring invalid GIC IRQ %d", irq);
>  	else if (ioctl(kvm->vm_fd, KVM_IRQ_LINE, &irq_level) < 0)
>  		pr_warning("Could not KVM_IRQ_LINE for irq %d", irq);
> diff --git a/arm64/include/kvm/kvm-arch.h b/arm64/include/kvm/kvm-arch.h
> index e7dd5269..94140364 100644
> --- a/arm64/include/kvm/kvm-arch.h
> +++ b/arm64/include/kvm/kvm-arch.h
> @@ -57,6 +57,14 @@
>  #define ARM_GIC_CPUI_SIZE	0x20000
>  
>  
> +/* GICv5 IRS CONFIG and SETLPI frames occupy the end of the MMIO area. */
> +#define ARM_GICV5_IRS_BASE		(ARM_AXI_AREA - ARM_GICV5_IRS_SIZE)
> +#define ARM_GICV5_IRS_SIZE		(ARM_GICV5_IRS_CONFIG_SIZE + ARM_GICV5_IRS_SETLPI_SIZE)
> +#define ARM_GICV5_IRS_CONFIG_BASE	ARM_GICV5_IRS_BASE
> +#define ARM_GICV5_IRS_CONFIG_SIZE	0x10000
> +#define ARM_GICV5_IRS_SETLPI_BASE	(ARM_GICV5_IRS_CONFIG_BASE + ARM_GICV5_IRS_CONFIG_SIZE)
> +#define ARM_GICV5_IRS_SETLPI_SIZE	0x10000
> +
>  #define KVM_PCI_CFG_AREA	ARM_AXI_AREA
>  #define ARM_PCI_CFG_SIZE	(1ULL << 28)
>  #define KVM_PCI_MMIO_AREA	(KVM_PCI_CFG_AREA + ARM_PCI_CFG_SIZE)
> -- 2.34.1
> 

FWIW,

Reviewed-by: Vladimir Murzin <vladimir.murzin@arm.com>

  reply	other threads:[~2026-11-19  9:40 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 17:57 [PATCH kvmtool v5 00/23] arm64: Support GICv5-based guests Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 01/23] arm64: Propagate IRQ routing initialisation errors Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 02/23] arm64: Close the ITS descriptor when setup fails Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 03/23] arm64: Split GIC device setup Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 04/23] Sync kernel UAPI headers with v7.4-rc1 Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 05/23] arm64: Add GICv5 irqchip device support Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 06/23] arm64: Configure GIC interrupt bases Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 07/23] irq: Allow the initial interrupt line number to be set Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 08/23] arm64: Start GICv5 SPI line allocation at zero Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 09/23] arm64: Configure the GICv5 IRS Sascha Bischoff
2026-11-19  9:40   ` Vladimir Murzin [this message]
2026-11-18 17:57 ` [PATCH kvmtool v5 10/23] arm64: Define GICv5 interrupt types Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 11/23] arm64: Describe the PMU interrupt for GICv5 Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 12/23] arm64: Describe timer PPIs " Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 13/23] arm64: Assign CPU DT phandles Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 14/23] arm64: Describe the GICv5 CPU interface in the DT Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 15/23] arm64: Describe the GICv5 IRS " Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 16/23] arm64: Generate GICv5 SPI specifiers for platform devices Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 17/23] arm64: Generate GICv5 PCI INTx specifiers Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 18/23] arm64: Expose the GICv5 irqchip option Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 19/23] arm64: Add proposed GICv5 ITS UAPI definitions Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 20/23] arm64: Add GICv5 ITS device support Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 21/23] arm64: Describe the GICv5 ITS in the DT Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 22/23] arm64: Map PCI MSI requester IDs to the GICv5 ITS Sascha Bischoff
2026-11-18 17:57 ` [PATCH kvmtool v5 23/23] arm64: Expose the GICv5 ITS irqchip option Sascha Bischoff

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=7eb028fc-b647-49d2-9528-7d79bc4e4f29@arm.com \
    --to=vladimir.murzin@arm.com \
    --cc=julien.thierry.kdev@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=maz@kernel.org \
    --cc=peter.maydell@linaro.org \
    --cc=sascha.bischoff@arm.com \
    --cc=timothy.hayes@arm.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