From: Ricardo Koller <ricarkol@google.com>
To: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, drjones@redhat.com
Cc: maz@kernel.org, Paolo Bonzini <pbonzini@redhat.com>,
oupton@google.com, reijiw@google.com,
Ricardo Koller <ricarkol@google.com>
Subject: [PATCH v2 5/5] kvm: selftests: aarch64: use a tighter assert in vgic_poke_irq()
Date: Wed, 26 Jan 2022 19:08:58 -0800 [thread overview]
Message-ID: <20220127030858.3269036-6-ricarkol@google.com> (raw)
In-Reply-To: <20220127030858.3269036-1-ricarkol@google.com>
vgic_poke_irq() checks that the attr argument passed to the vgic device
ioctl is sane. Make this check tighter by moving it to after the last
attr update.
Signed-off-by: Ricardo Koller <ricarkol@google.com>
Reported-by: Reiji Watanabe <reijiw@google.com>
Cc: Andrew Jones <drjones@redhat.com>
---
tools/testing/selftests/kvm/lib/aarch64/vgic.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/kvm/lib/aarch64/vgic.c b/tools/testing/selftests/kvm/lib/aarch64/vgic.c
index 79864b941617..f365c32a7296 100644
--- a/tools/testing/selftests/kvm/lib/aarch64/vgic.c
+++ b/tools/testing/selftests/kvm/lib/aarch64/vgic.c
@@ -138,9 +138,6 @@ static void vgic_poke_irq(int gic_fd, uint32_t intid,
uint64_t val;
bool intid_is_private = INTID_IS_SGI(intid) || INTID_IS_PPI(intid);
- /* Check that the addr part of the attr is within 32 bits. */
- assert(attr <= KVM_DEV_ARM_VGIC_OFFSET_MASK);
-
uint32_t group = intid_is_private ? KVM_DEV_ARM_VGIC_GRP_REDIST_REGS
: KVM_DEV_ARM_VGIC_GRP_DIST_REGS;
@@ -150,6 +147,9 @@ static void vgic_poke_irq(int gic_fd, uint32_t intid,
attr += SZ_64K;
}
+ /* Check that the addr part of the attr is within 32 bits. */
+ assert((attr & ~KVM_DEV_ARM_VGIC_OFFSET_MASK) == 0);
+
/*
* All calls will succeed, even with invalid intid's, as long as the
* addr part of the attr is within 32 bits (checked above). An invalid
--
2.35.0.rc0.227.g00780c9af4-goog
next prev parent reply other threads:[~2022-01-27 3:09 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-27 3:08 [PATCH v2 0/5] kvm: selftests: aarch64: some fixes for vgic_irq Ricardo Koller
2022-01-27 3:08 ` [PATCH v2 1/5] kvm: selftests: aarch64: fix assert in gicv3_access_reg Ricardo Koller
2022-01-27 7:34 ` Andrew Jones
2022-01-27 3:08 ` [PATCH v2 2/5] kvm: selftests: aarch64: pass vgic_irq guest args as a pointer Ricardo Koller
2022-01-27 7:46 ` Andrew Jones
2022-01-27 3:08 ` [PATCH v2 3/5] kvm: selftests: aarch64: fix the failure check in kvm_set_gsi_routing_irqchip_check Ricardo Koller
2022-01-27 3:08 ` [PATCH v2 4/5] kvm: selftests: aarch64: fix some vgic related comments Ricardo Koller
2022-01-27 7:49 ` Andrew Jones
2022-01-27 15:06 ` Ricardo Koller
2022-01-27 3:08 ` Ricardo Koller [this message]
2022-01-27 7:51 ` [PATCH v2 5/5] kvm: selftests: aarch64: use a tighter assert in vgic_poke_irq() Andrew Jones
2022-02-08 17:37 ` [PATCH v2 0/5] kvm: selftests: aarch64: some fixes for vgic_irq Marc Zyngier
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=20220127030858.3269036-6-ricarkol@google.com \
--to=ricarkol@google.com \
--cc=drjones@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=maz@kernel.org \
--cc=oupton@google.com \
--cc=pbonzini@redhat.com \
--cc=reijiw@google.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