Skip to contentSkip to conversation

KVM: arm64: fix warnings in W=1 build

PATCH Superseded Sebastian Ott 3 participants 9 messages Jul 12, 2024 – Jul 15, 2024

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover KVM: arm64: fix warnings in W=1 build

Building arch/arm64/kvm/ with W=1 spills out a lot of warnings. When changing stuff I try to use as much tooling as possible to make sure that I don't screw up - having a clean baseline imho helps with that.

With the first 2 patches applied make W=1 arch/arm64/kvm/ runs without warnings for me (fedora userspace, kvm-arm/next). Patch 3 gets rid of sparse lock warnings in arch/arm64/kvm/vgic/.

Sebastian Ott (3):
KVM: arm64: fix override-init warnings in W=1 builds
KVM: arm64: fix kdoc warnings in W=1 builds
KVM: arm64: vgic: fix unexpected unlock sparse warnings

 arch/arm64/kvm/arm.c             |  1 +
 arch/arm64/kvm/handle_exit.c     |  5 +++++
 arch/arm64/kvm/hyp/nvhe/switch.c |  6 ++----
 arch/arm64/kvm/hyp/vhe/switch.c  |  3 +--
 arch/arm64/kvm/sys_regs.c        |  5 +++++
 arch/arm64/kvm/vgic/vgic-irqfd.c |  7 ++++---
 arch/arm64/kvm/vgic/vgic-its.c   | 18 +++++++++++-------
 arch/arm64/kvm/vgic/vgic-v3.c    |  2 +-
 arch/arm64/kvm/vgic/vgic.c       |  2 +-
 arch/arm64/kvm/vgic/vgic.h       |  2 +-
 10 files changed, 32 insertions(+), 19 deletions(-)
Signature · 1 line
2.42.0
#1 lore raw

PATCH 1/3 KVM: arm64: fix override-init warnings in W=1 builds

Remove double initializations in cases where that's easily possible
- like extra NULL initialization in static global structures. In the other cases just silence -Woverride-init.

To fix warnings like the following:
arch/arm64/kvm/hyp/vhe/switch.c:271:43: warning: initialized field overwritten [-Woverride-init]
271 | [ESR_ELx_EC_CP15_32] = kvm_hyp_handle_cp15_32,

      |                                           ^~~~~~~~~~~~~~~~~~~~~~
---
 arch/arm64/kvm/handle_exit.c     | 5 +++++
 arch/arm64/kvm/hyp/nvhe/switch.c | 6 ++----
 arch/arm64/kvm/hyp/vhe/switch.c  | 3 +--
 arch/arm64/kvm/sys_regs.c        | 5 +++++
 4 files changed, 13 insertions(+), 6 deletions(-)
arch/arm64/kvm/handle_exit.c +5 -0
index d7c2990e7c9e..2c049746657c 100644
@@ -291,6 +291,9 @@ static int handle_svc(struct kvm_vcpu *vcpu)
 	return 1;
 }
 
+__diag_push();
+__diag_ignore_all("-Woverride-init", "Allow field overrides in exit_handlers");
+
 static exit_handle_fn arm_exit_handlers[] = {
 	[0 ... ESR_ELx_EC_MAX]	= kvm_handle_unknown_ec,
 	[ESR_ELx_EC_WFx]	= kvm_handle_wfx,
@@ -319,6 +322,8 @@ static exit_handle_fn arm_exit_handlers[] = {
 	[ESR_ELx_EC_PAC]	= kvm_handle_ptrauth,
 };
 
+__diag_pop();
+
 static exit_handle_fn kvm_get_exit_handler(struct kvm_vcpu *vcpu)
 {
 	u64 esr = kvm_vcpu_get_esr(vcpu);
arch/arm64/kvm/hyp/nvhe/switch.c +2 -4
index 6af179c6356d..bf49afc01542 100644
@@ -200,8 +200,7 @@ static void kvm_hyp_save_fpsimd_host(struct kvm_vcpu *vcpu)
 	}
 }
 
-static const exit_handler_fn hyp_exit_handlers[] = {
-	[0 ... ESR_ELx_EC_MAX]		= NULL,
+static const exit_handler_fn hyp_exit_handlers[ESR_ELx_EC_MAX + 1] = {
 	[ESR_ELx_EC_CP15_32]		= kvm_hyp_handle_cp15_32,
 	[ESR_ELx_EC_SYS64]		= kvm_hyp_handle_sysreg,
 	[ESR_ELx_EC_SVE]		= kvm_hyp_handle_fpsimd,
@@ -212,8 +211,7 @@ static const exit_handler_fn hyp_exit_handlers[] = {
 	[ESR_ELx_EC_MOPS]		= kvm_hyp_handle_mops,
 };
 
-static const exit_handler_fn pvm_exit_handlers[] = {
-	[0 ... ESR_ELx_EC_MAX]		= NULL,
+static const exit_handler_fn pvm_exit_handlers[ESR_ELx_EC_MAX + 1] = {
 	[ESR_ELx_EC_SYS64]		= kvm_handle_pvm_sys64,
 	[ESR_ELx_EC_SVE]		= kvm_handle_pvm_restricted,
 	[ESR_ELx_EC_FP_ASIMD]		= kvm_hyp_handle_fpsimd,
arch/arm64/kvm/hyp/vhe/switch.c +1 -2
index 77010b76c150..4e4ff2bd51c9 100644
@@ -415,8 +415,7 @@ static bool kvm_hyp_handle_sysreg_vhe(struct kvm_vcpu *vcpu, u64 *exit_code)
 	return kvm_hyp_handle_sysreg(vcpu, exit_code);
 }
 
-static const exit_handler_fn hyp_exit_handlers[] = {
-	[0 ... ESR_ELx_EC_MAX]		= NULL,
+static const exit_handler_fn hyp_exit_handlers[ESR_ELx_EC_MAX + 1] = {
 	[ESR_ELx_EC_CP15_32]		= kvm_hyp_handle_cp15_32,
 	[ESR_ELx_EC_SYS64]		= kvm_hyp_handle_sysreg_vhe,
 	[ESR_ELx_EC_SVE]		= kvm_hyp_handle_fpsimd,
arch/arm64/kvm/sys_regs.c +5 -0
index c90324060436..00fb6f1e9a48 100644
@@ -2255,6 +2255,9 @@ static bool access_zcr_el2(struct kvm_vcpu *vcpu,
 	return true;
 }
 
+__diag_push();
+__diag_ignore_all("-Woverride-init", "Allow field overrides in sys_reg_descs");
+
 /*
  * Architected system registers.
  * Important: Must be sorted ascending by Op0, Op1, CRn, CRm, Op2
@@ -2803,6 +2806,8 @@ static const struct sys_reg_desc sys_reg_descs[] = {
 	EL2_REG(SP_EL2, NULL, reset_unknown, 0),
 };
 
+__diag_pop();
+
 static bool kvm_supported_tlbi_s12_op(struct kvm_vcpu *vpcu, u32 instr)
 {
 	struct kvm *kvm = vpcu->kvm;
Signature · 1 line
2.42.0
maintainer
#2 lore raw

Re: [PATCH 1/3] KVM: arm64: fix override-init warnings in W=1 builds

Quoted 23 lines · Sebastian Ott

Remove double initializations in cases where that's easily possible
- like extra NULL initialization in static global structures. In the other cases just silence -Woverride-init.

To fix warnings like the following:
arch/arm64/kvm/hyp/vhe/switch.c:271:43: warning: initialized field overwritten [-Woverride-init]
271 | [ESR_ELx_EC_CP15_32] = kvm_hyp_handle_cp15_32,

      |                                           ^~~~~~~~~~~~~~~~~~~~~~
---
 arch/arm64/kvm/handle_exit.c     | 5 +++++
 arch/arm64/kvm/hyp/nvhe/switch.c | 6 ++----
 arch/arm64/kvm/hyp/vhe/switch.c  | 3 +--
 arch/arm64/kvm/sys_regs.c        | 5 +++++
 4 files changed, 13 insertions(+), 6 deletions(-)
arch/arm64/kvm/handle_exit.c +0 -0
index d7c2990e7c9e..2c049746657c 100644

arch/arm64/kvm/handle_exit.c static int handle_svc(struct kvm_vcpu *vcpu) · line 295

Quoted 5 lines
arch/arm64/kvm/handle_exit.c +2 -0
@@ -291,6 +291,9 @@ static int handle_svc(struct kvm_vcpu *vcpu)
 	return 1;
 }
 
+__diag_push();
+__diag_ignore_all("-Woverride-init", "Allow field overrides in exit_handlers");

The wording you are looking for is "Silence stupid warning". I really mean it. There is really nothing wrong with this code, and if the compiler doesn't understand the purpose of a default initialiser, then *maybe* it should be fixed rather than polluting the kernel with this stuff.

Quoted 18 lines
arch/arm64/kvm/handle_exit.c +3 -0
+
 static exit_handle_fn arm_exit_handlers[] = {
 	[0 ... ESR_ELx_EC_MAX]	= kvm_handle_unknown_ec,
 	[ESR_ELx_EC_WFx]	= kvm_handle_wfx,
@@ -319,6 +322,8 @@ static exit_handle_fn arm_exit_handlers[] = {
 	[ESR_ELx_EC_PAC]	= kvm_handle_ptrauth,
 };
 
+__diag_pop();
+
 static exit_handle_fn kvm_get_exit_handler(struct kvm_vcpu *vcpu)
 {
 	u64 esr = kvm_vcpu_get_esr(vcpu);
arch/arm64/kvm/hyp/nvhe/switch.c +0 -0
index 6af179c6356d..bf49afc01542 100644

arch/arm64/kvm/hyp/nvhe/switch.c static void kvm_hyp_save_fpsimd_host(struct kvm_vcpu *vcpu) · line 203

Quoted 6 lines
arch/arm64/kvm/hyp/nvhe/switch.c +1 -2
@@ -200,8 +200,7 @@ static void kvm_hyp_save_fpsimd_host(struct kvm_vcpu *vcpu)
 	}
 }
 
-static const exit_handler_fn hyp_exit_handlers[] = {
-	[0 ... ESR_ELx_EC_MAX]		= NULL,
+static const exit_handler_fn hyp_exit_handlers[ESR_ELx_EC_MAX + 1] = {

Is this really any better? I don't think so. It makes the intent disappear instead of making it explicit. Intent matters *a lot*.

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
reviewer
#3 lore raw

Re: [PATCH 1/3] KVM: arm64: fix override-init warnings in W=1 builds

Quoted 28 lines · Marc Zyngier
Quoted 26 lines · Sebastian Ott

Remove double initializations in cases where that's easily possible
- like extra NULL initialization in static global structures. In the other cases just silence -Woverride-init.

To fix warnings like the following:
arch/arm64/kvm/hyp/vhe/switch.c:271:43: warning: initialized field overwritten [-Woverride-init]
271 | [ESR_ELx_EC_CP15_32] = kvm_hyp_handle_cp15_32,

      |                                           ^~~~~~~~~~~~~~~~~~~~~~
---
 arch/arm64/kvm/handle_exit.c     | 5 +++++
 arch/arm64/kvm/hyp/nvhe/switch.c | 6 ++----
 arch/arm64/kvm/hyp/vhe/switch.c  | 3 +--
 arch/arm64/kvm/sys_regs.c        | 5 +++++
 4 files changed, 13 insertions(+), 6 deletions(-)
arch/arm64/kvm/handle_exit.c +0 -0
index d7c2990e7c9e..2c049746657c 100644
@@ -291,6 +291,9 @@ static int handle_svc(struct kvm_vcpu *vcpu)
 	return 1;
 }
 
Quoted 8 lines

arch/arm64/kvm/handle_exit.c static int handle_svc(struct kvm_vcpu *vcpu) · line 295

Quoted 2 lines
arch/arm64/kvm/handle_exit.c +2 -0
+__diag_push();
+__diag_ignore_all("-Woverride-init", "Allow field overrides in exit_handlers");

The wording you are looking for is "Silence stupid warning". I really mean it. There is really nothing wrong with this code, and if the compiler doesn't understand the purpose of a default initialiser, then *maybe* it should be fixed rather than polluting the kernel with this stuff.

IMO this would be a lot more palatable if this were an attribute on the struct or assignment, like we asked for in the past:

https://lore.kernel.org/lkml/[email protected]/

Having something that we could put specifically on the default assignment would make this a lot more legible and better capture the intent.

Mark.

#4 lore raw

Re: [PATCH 1/3] KVM: arm64: fix override-init warnings in W=1 builds

Quoted 38 lines · Mark Rutland
Quoted 28 lines · Marc Zyngier
Quoted 26 lines · Sebastian Ott

Remove double initializations in cases where that's easily possible
- like extra NULL initialization in static global structures. In the other cases just silence -Woverride-init.

To fix warnings like the following:
arch/arm64/kvm/hyp/vhe/switch.c:271:43: warning: initialized field overwritten [-Woverride-init]
271 | [ESR_ELx_EC_CP15_32] = kvm_hyp_handle_cp15_32,

      |                                           ^~~~~~~~~~~~~~~~~~~~~~
---
 arch/arm64/kvm/handle_exit.c     | 5 +++++
 arch/arm64/kvm/hyp/nvhe/switch.c | 6 ++----
 arch/arm64/kvm/hyp/vhe/switch.c  | 3 +--
 arch/arm64/kvm/sys_regs.c        | 5 +++++
 4 files changed, 13 insertions(+), 6 deletions(-)
arch/arm64/kvm/handle_exit.c +0 -0
index d7c2990e7c9e..2c049746657c 100644
@@ -291,6 +291,9 @@ static int handle_svc(struct kvm_vcpu *vcpu)
 	return 1;
 }
 
Quoted 8 lines

arch/arm64/kvm/handle_exit.c static int handle_svc(struct kvm_vcpu *vcpu) · line 295

Quoted 2 lines
arch/arm64/kvm/handle_exit.c +2 -0
+__diag_push();
+__diag_ignore_all("-Woverride-init", "Allow field overrides in exit_handlers");

The wording you are looking for is "Silence stupid warning". I really mean it. There is really nothing wrong with this code, and if the compiler doesn't understand the purpose of a default initialiser, then *maybe* it should be fixed rather than polluting the kernel with this stuff.

Quoted 7 lines

IMO this would be a lot more palatable if this were an attribute on the struct or assignment, like we asked for in the past:

https://lore.kernel.org/lkml/[email protected]/

Having something that we could put specifically on the default assignment would make this a lot more legible and better capture the intent.

Yea, I double checked in the gcc doc - there seems to be no other means to silence this per var or assignment. We can disable that in the makefile for the whole file or dir or we keep it as it is.

Thanks,
Sebastian

#5 lore raw

Re: [PATCH 1/3] KVM: arm64: fix override-init warnings in W=1 builds

In reply to Marc Zyngier
Quoted 37 lines · Marc Zyngier
Quoted 23 lines · Sebastian Ott

Remove double initializations in cases where that's easily possible
- like extra NULL initialization in static global structures. In the other cases just silence -Woverride-init.

To fix warnings like the following:
arch/arm64/kvm/hyp/vhe/switch.c:271:43: warning: initialized field overwritten [-Woverride-init]
271 | [ESR_ELx_EC_CP15_32] = kvm_hyp_handle_cp15_32,

      |                                           ^~~~~~~~~~~~~~~~~~~~~~
---
 arch/arm64/kvm/handle_exit.c     | 5 +++++
 arch/arm64/kvm/hyp/nvhe/switch.c | 6 ++----
 arch/arm64/kvm/hyp/vhe/switch.c  | 3 +--
 arch/arm64/kvm/sys_regs.c        | 5 +++++
 4 files changed, 13 insertions(+), 6 deletions(-)
arch/arm64/kvm/handle_exit.c +0 -0
index d7c2990e7c9e..2c049746657c 100644

arch/arm64/kvm/handle_exit.c static int handle_svc(struct kvm_vcpu *vcpu) · line 295

Quoted 5 lines
arch/arm64/kvm/handle_exit.c +2 -0
@@ -291,6 +291,9 @@ static int handle_svc(struct kvm_vcpu *vcpu)
 	return 1;
 }
 
+__diag_push();
+__diag_ignore_all("-Woverride-init", "Allow field overrides in exit_handlers");

The wording you are looking for is "Silence stupid warning". I really mean it. There is really nothing wrong with this code, and if the compiler doesn't understand the purpose of a default initialiser, then *maybe* it should be fixed rather than polluting the kernel with this stuff.

[...]

Quoted 6 lines

arch/arm64/kvm/handle_exit.c

Quoted 3 lines
arch/arm64/kvm/handle_exit.c +1 -2
-static const exit_handler_fn hyp_exit_handlers[] = {
-	[0 ... ESR_ELx_EC_MAX]		= NULL,
+static const exit_handler_fn hyp_exit_handlers[ESR_ELx_EC_MAX + 1] = {

Is this really any better? I don't think so. It makes the intent disappear instead of making it explicit. Intent matters *a lot*.

I'm not claiming that it's an improvement to the code. But yea, I see your point. How about disabling that flag in the makefile?

Thanks,
Sebastian

maintainer
#6 lore raw

Re: [PATCH 1/3] KVM: arm64: fix override-init warnings in W=1 builds

Quoted 5 lines · Sebastian Ott
Quoted 3 lines · Marc Zyngier
Quoted 1 line · Sebastian Ott
Quoted 8 lines
Quoted 6 lines

arch/arm64/kvm/hyp/nvhe/switch.c static void kvm_hyp_save_fpsimd_host(struct kvm_vcpu *vcpu) · line 203

Quoted 3 lines
arch/arm64/kvm/hyp/nvhe/switch.c +1 -2
-static const exit_handler_fn hyp_exit_handlers[] = {
-	[0 ... ESR_ELx_EC_MAX]		= NULL,
+static const exit_handler_fn hyp_exit_handlers[ESR_ELx_EC_MAX + 1] = {

Is this really any better? I don't think so. It makes the intent disappear instead of making it explicit. Intent matters *a lot*.

I'm not claiming that it's an improvement to the code.

<rant>
Silencing pointless warnings should never have priority over keeping the code maintainable and understandable. I hope we can agree we are not in the business of making the kernel *worse* than it already is on that front, right?
</rant>

I like good tooling as much as the next kernel tinkerer. But W=1 is, in its current form, quite the opposite. Mark posted a link to a 5 year old thread, showing a number of ways compilers could use extra annotation to lift the multiple initialisation ambiguity. This approach has seen no traction, which is a bit sad.

Quoted 2 lines

But yea, I see your point. How about disabling that flag in the makefile?

Yes, that'd be a reasonable workaround until someone fixes the toolchains. I see that Loongarch is already doing it for the exact same purpose.

Thanks,

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
#7 lore raw

PATCH 2/3 KVM: arm64: fix kdoc warnings in W=1 builds

In reply to Sebastian Ott

Fix kdoc warnings by adding missing function parameter descriptions or by conversion to a normal comment.

---
 arch/arm64/kvm/arm.c             |  1 +
 arch/arm64/kvm/vgic/vgic-irqfd.c |  7 ++++---
 arch/arm64/kvm/vgic/vgic-its.c   | 18 +++++++++++-------
 arch/arm64/kvm/vgic/vgic-v3.c    |  2 +-
 4 files changed, 17 insertions(+), 11 deletions(-)
arch/arm64/kvm/arm.c +1 -0
index c818818398a5..2cbc23dd554d 100644
@@ -164,6 +164,7 @@ static int kvm_arm_default_max_vcpus(void)
 /**
  * kvm_arch_init_vm - initializes a VM data structure
  * @kvm:	pointer to the KVM struct
+ * @type:	kvm device type
  */
 int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
 {
arch/arm64/kvm/vgic/vgic-irqfd.c +4 -3
index 8c711deb25aa..c314c016659a 100644
@@ -9,7 +9,7 @@
 #include <kvm/arm_vgic.h>
 #include "vgic.h"
 
-/**
+/*
  * vgic_irqfd_set_irq: inject the IRQ corresponding to the
  * irqchip routing entry
  *
@@ -75,7 +75,8 @@ static void kvm_populate_msi(struct kvm_kernel_irq_routing_entry *e,
 	msi->flags = e->msi.flags;
 	msi->devid = e->msi.devid;
 }
-/**
+
+/*
  * kvm_set_msi: inject the MSI corresponding to the
  * MSI routing entry
  *
@@ -98,7 +99,7 @@ int kvm_set_msi(struct kvm_kernel_irq_routing_entry *e,
 	return vgic_its_inject_msi(kvm, &msi);
 }
 
-/**
+/*
  * kvm_arch_set_irq_inatomic: fast-path for irqfd injection
  */
 int kvm_arch_set_irq_inatomic(struct kvm_kernel_irq_routing_entry *e,
arch/arm64/kvm/vgic/vgic-its.c +11 -7
index 40bb43f20bf3..ba945ba78cc7 100644
@@ -2040,6 +2040,7 @@ typedef int (*entry_fn_t)(struct vgic_its *its, u32 id, void *entry,
  * @start_id: the ID of the first entry in the table
  * (non zero for 2d level tables)
  * @fn: function to apply on each entry
+ * @opaque: pointer to opaque data
  *
  * Return: < 0 on error, 0 if last element was identified, 1 otherwise
  * (the last element may not be found on second level tables)
@@ -2079,7 +2080,7 @@ static int scan_its_table(struct vgic_its *its, gpa_t base, int size, u32 esz,
 	return 1;
 }
 
-/**
+/*
  * vgic_its_save_ite - Save an interrupt translation entry at @gpa
  */
 static int vgic_its_save_ite(struct vgic_its *its, struct its_device *dev,
@@ -2099,6 +2100,8 @@ static int vgic_its_save_ite(struct vgic_its *its, struct its_device *dev,
 
 /**
  * vgic_its_restore_ite - restore an interrupt translation entry
+ *
+ * @its: its handle
  * @event_id: id used for indexing
  * @ptr: pointer to the ITE entry
  * @opaque: pointer to the its_device
@@ -2231,6 +2234,7 @@ static int vgic_its_restore_itt(struct vgic_its *its, struct its_device *dev)
  * @its: ITS handle
  * @dev: ITS device
  * @ptr: GPA
+ * @dte_esz: device table entry size
  */
 static int vgic_its_save_dte(struct vgic_its *its, struct its_device *dev,
 			     gpa_t ptr, int dte_esz)
@@ -2313,7 +2317,7 @@ static int vgic_its_device_cmp(void *priv, const struct list_head *a,
 		return 1;
 }
 
-/**
+/*
  * vgic_its_save_device_tables - Save the device table and all ITT
  * into guest RAM
  *
@@ -2386,7 +2390,7 @@ static int handle_l1_dte(struct vgic_its *its, u32 id, void *addr,
 	return ret;
 }
 
-/**
+/*
  * vgic_its_restore_device_tables - Restore the device table and all ITT
  * from guest RAM to internal data structs
  */
@@ -2478,7 +2482,7 @@ static int vgic_its_restore_cte(struct vgic_its *its, gpa_t gpa, int esz)
 	return 1;
 }
 
-/**
+/*
  * vgic_its_save_collection_table - Save the collection table into
  * guest RAM
  */
@@ -2518,7 +2522,7 @@ static int vgic_its_save_collection_table(struct vgic_its *its)
 	return ret;
 }
 
-/**
+/*
  * vgic_its_restore_collection_table - reads the collection table
  * in guest memory and restores the ITS internal state. Requires the
  * BASER registers to be restored before.
@@ -2556,7 +2560,7 @@ static int vgic_its_restore_collection_table(struct vgic_its *its)
 	return ret;
 }
 
-/**
+/*
  * vgic_its_save_tables_v0 - Save the ITS tables into guest ARM
  * according to v0 ABI
  */
@@ -2571,7 +2575,7 @@ static int vgic_its_save_tables_v0(struct vgic_its *its)
 	return vgic_its_save_collection_table(its);
 }
 
-/**
+/*
  * vgic_its_restore_tables_v0 - Restore the ITS tables from guest RAM
  * to internal data structs according to V0 ABI
  *
arch/arm64/kvm/vgic/vgic-v3.c +1 -1
index ed6e412cd74b..3eecdd2f4b8f 100644
@@ -370,7 +370,7 @@ static void map_all_vpes(struct kvm *kvm)
 						dist->its_vm.vpes[i]->irq));
 }
 
-/**
+/*
  * vgic_v3_save_pending_tables - Save the pending tables into guest RAM
  * kvm lock and all vcpu lock must be held
  */
Signature · 1 line
2.42.0
#8 lore raw

PATCH 3/3 KVM: arm64: vgic: fix unexpected unlock sparse warnings

In reply to Sebastian Ott

Get rid of unexpected unlock sparse warnings in vgic code by adding an annotation to vgic_queue_irq_unlock().

arch/arm64/kvm/vgic/vgic.c:334:17: warning: context imbalance in 'vgic_queue_irq_unlock' - unexpected unlock arch/arm64/kvm/vgic/vgic.c:419:5: warning: context imbalance in 'kvm_vgic_inject_irq' - different lock contexts for basic block

---
 arch/arm64/kvm/vgic/vgic.c | 2 +-
 arch/arm64/kvm/vgic/vgic.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm64/kvm/vgic/vgic.c +1 -1
index f07b3ddff7d4..974849ea7101 100644
@@ -313,7 +313,7 @@ static bool vgic_validate_injection(struct vgic_irq *irq, bool level, void *owne
  * with all locks dropped.
  */
 bool vgic_queue_irq_unlock(struct kvm *kvm, struct vgic_irq *irq,
-			   unsigned long flags)
+			   unsigned long flags) __releases(&irq->irq_lock)
 {
 	struct kvm_vcpu *vcpu;
 
arch/arm64/kvm/vgic/vgic.h +1 -1
index 6106ebd5ba42..480b5c7e2031 100644
@@ -186,7 +186,7 @@ bool vgic_get_phys_line_level(struct vgic_irq *irq);
 void vgic_irq_set_phys_pending(struct vgic_irq *irq, bool pending);
 void vgic_irq_set_phys_active(struct vgic_irq *irq, bool active);
 bool vgic_queue_irq_unlock(struct kvm *kvm, struct vgic_irq *irq,
-			   unsigned long flags);
+			   unsigned long flags) __releases(&irq->irq_lock);
 void vgic_kick_vcpus(struct kvm *kvm);
 void vgic_irq_handle_resampling(struct vgic_irq *irq,
 				bool lr_deactivated, bool lr_pending);
Signature · 1 line
2.42.0