* [PATCH 1/2] linux-headers: Add support for reads in ioeventfd
2020-10-20 17:00 [PATCH 0/2] KVM: Introduce ioeventfd read support Amey Narkhede
@ 2020-10-20 17:00 ` Amey Narkhede
2020-10-20 17:00 ` [PATCH 2/2] kvm: Add ioeventfd read test code Amey Narkhede
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Amey Narkhede @ 2020-10-20 17:00 UTC (permalink / raw)
To: qemu-devel, ameynarkhede03
Cc: Paolo Bonzini, Cornelia Huck, kvm, Michael S. Tsirkin
This patch introduces a new flag KVM_IOEVENTFD_FLAG_DATAREAD
in ioeventfd to enable receiving a notification when a
guest reads from registered PIO/MMIO address.
Signed-off-by: Amey Narkhede <ameynarkhede03@gmail.com>
---
| 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
--git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h
index 43580c767c..3e71d15a53 100644
--- a/linux-headers/linux/kvm.h
+++ b/linux-headers/linux/kvm.h
@@ -695,6 +695,7 @@ struct kvm_guest_debug {
enum {
kvm_ioeventfd_flag_nr_datamatch,
+ kvm_ioeventfd_flag_nr_dataread,
kvm_ioeventfd_flag_nr_pio,
kvm_ioeventfd_flag_nr_deassign,
kvm_ioeventfd_flag_nr_virtio_ccw_notify,
@@ -703,6 +704,7 @@ enum {
};
#define KVM_IOEVENTFD_FLAG_DATAMATCH (1 << kvm_ioeventfd_flag_nr_datamatch)
+#define KVM_IOEVENTFD_FLAG_DATAREAD (1 << kvm_ioeventfd_flag_nr_dataread)
#define KVM_IOEVENTFD_FLAG_PIO (1 << kvm_ioeventfd_flag_nr_pio)
#define KVM_IOEVENTFD_FLAG_DEASSIGN (1 << kvm_ioeventfd_flag_nr_deassign)
#define KVM_IOEVENTFD_FLAG_VIRTIO_CCW_NOTIFY \
@@ -712,11 +714,12 @@ enum {
struct kvm_ioeventfd {
__u64 datamatch;
+ __u64 dataread;
__u64 addr; /* legal pio/mmio address */
__u32 len; /* 1, 2, 4, or 8 bytes; or 0 to ignore length */
__s32 fd;
__u32 flags;
- __u8 pad[36];
+ __u8 pad[28];
};
#define KVM_X86_DISABLE_EXITS_MWAIT (1 << 0)
--
2.28.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] kvm: Add ioeventfd read test code
2020-10-20 17:00 [PATCH 0/2] KVM: Introduce ioeventfd read support Amey Narkhede
2020-10-20 17:00 ` [PATCH 1/2] linux-headers: Add support for reads in ioeventfd Amey Narkhede
@ 2020-10-20 17:00 ` Amey Narkhede
2020-10-20 17:09 ` [PATCH 0/2] KVM: Introduce ioeventfd read support no-reply
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Amey Narkhede @ 2020-10-20 17:00 UTC (permalink / raw)
To: qemu-devel, ameynarkhede03
Cc: Paolo Bonzini, Cornelia Huck, kvm, Michael S. Tsirkin
This patch adds kvm_set_ioeventfd_read and
dummy_notifier_read functons to test ioeventfd
read support. When the guess writes to address
provided in kvm_set_ioeventfd_read function,
dummy_notifier_read prints to stdio.
Signed-off-by: Amey Narkhede <ameynarkhede03@gmail.com>
---
accel/kvm/kvm-all.c | 55 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 9ef5daf4c5..357e74d84c 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -1006,6 +1006,43 @@ static uint32_t adjust_ioeventfd_endianness(uint32_t val, uint32_t size)
return val;
}
+static void dummy_notifier_read(EventNotifier *n)
+{
+ printf("Received ioeventfd read event\n");
+ event_notifier_test_and_clear(n);
+}
+
+static int kvm_set_ioeventfd_read(int fd, hwaddr addr, uint64_t val,
+ uint64_t size, bool datamatch)
+{
+ int ret;
+ struct kvm_ioeventfd ioevent = {
+ .datamatch = datamatch ? adjust_ioeventfd_endianness(val, size) : 0,
+ .dataread = val,
+ .addr = addr,
+ .len = size,
+ .flags = KVM_IOEVENTFD_FLAG_DATAREAD,
+ .fd = fd,
+ };
+
+ if (!kvm_enabled()) {
+ return -ENOSYS;
+ }
+
+ if (datamatch) {
+ ioevent.flags |= KVM_IOEVENTFD_FLAG_DATAMATCH;
+ }
+
+ ret = kvm_vm_ioctl(kvm_state, KVM_IOEVENTFD, &ioevent);
+
+ if (ret < 0) {
+ return -errno;
+ }
+
+ return 0;
+}
+
+
static int kvm_set_ioeventfd_mmio(int fd, hwaddr addr, uint32_t val,
bool assign, uint32_t size, bool datamatch)
{
@@ -2012,6 +2049,7 @@ static int kvm_init(MachineState *ms)
KVMState *s;
const KVMCapabilityInfo *missing_cap;
int ret;
+ int efd = -1;
int type = 0;
const char *kvm_type;
uint64_t dirty_log_manual_caps;
@@ -2253,6 +2291,22 @@ static int kvm_init(MachineState *ms)
}
cpus_register_accel(&kvm_cpus);
+
+ EventNotifier *e = g_malloc0(sizeof(EventNotifier));
+ ret = event_notifier_init(e, false);
+ if (ret < 0) {
+ printf("Failed to initialize EventNotifier\n");
+ }
+ else {
+ AioContext *ctx = qemu_get_aio_context();
+ efd = event_notifier_get_fd(e);
+ aio_set_event_notifier(ctx, e, false, dummy_notifier_read, NULL);
+ ret = kvm_set_ioeventfd_read(efd, 0xff01003f, 123, 8, false);
+ if (ret < 0)
+ printf("ioeventfd read failed\n");
+ }
+
+
return 0;
err:
@@ -2268,6 +2322,7 @@ err:
return ret;
}
+
void kvm_set_sigmask_len(KVMState *s, unsigned int sigmask_len)
{
s->sigmask_len = sigmask_len;
--
2.28.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] KVM: Introduce ioeventfd read support
2020-10-20 17:00 [PATCH 0/2] KVM: Introduce ioeventfd read support Amey Narkhede
2020-10-20 17:00 ` [PATCH 1/2] linux-headers: Add support for reads in ioeventfd Amey Narkhede
2020-10-20 17:00 ` [PATCH 2/2] kvm: Add ioeventfd read test code Amey Narkhede
@ 2020-10-20 17:09 ` no-reply
2020-10-20 17:19 ` Amey Narkhede
2020-10-31 14:33 ` Paolo Bonzini
4 siblings, 0 replies; 6+ messages in thread
From: no-reply @ 2020-10-20 17:09 UTC (permalink / raw)
To: ameynarkhede03; +Cc: kvm, mst, cohuck, qemu-devel, ameynarkhede03, pbonzini
Patchew URL: https://patchew.org/QEMU/20201020170056.433528-1-ameynarkhede03@gmail.com/
Hi,
This series seems to have some coding style problems. See output below for
more information:
Type: series
Message-id: 20201020170056.433528-1-ameynarkhede03@gmail.com
Subject: [PATCH 0/2] KVM: Introduce ioeventfd read support
=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
- [tag update] patchew/20201020163738.27700-1-alex.bennee@linaro.org -> patchew/20201020163738.27700-1-alex.bennee@linaro.org
* [new tag] patchew/20201020170056.433528-1-ameynarkhede03@gmail.com -> patchew/20201020170056.433528-1-ameynarkhede03@gmail.com
Switched to a new branch 'test'
eccca33 kvm: Add ioeventfd read test code
33b3de6 linux-headers: Add support for reads in ioeventfd
=== OUTPUT BEGIN ===
1/2 Checking commit 33b3de672219 (linux-headers: Add support for reads in ioeventfd)
2/2 Checking commit eccca33098c6 (kvm: Add ioeventfd read test code)
ERROR: code indent should never use tabs
#31: FILE: accel/kvm/kvm-all.c:1016:
+^I^I^I^I uint64_t size, bool datamatch)$
ERROR: code indent should never use tabs
#33: FILE: accel/kvm/kvm-all.c:1018:
+^Iint ret;$
ERROR: code indent should never use tabs
#34: FILE: accel/kvm/kvm-all.c:1019:
+^Istruct kvm_ioeventfd ioevent = {$
WARNING: line over 80 characters
#35: FILE: accel/kvm/kvm-all.c:1020:
+ .datamatch = datamatch ? adjust_ioeventfd_endianness(val, size) : 0,
ERROR: code indent should never use tabs
#35: FILE: accel/kvm/kvm-all.c:1020:
+ ^I.datamatch = datamatch ? adjust_ioeventfd_endianness(val, size) : 0,$
ERROR: code indent should never use tabs
#36: FILE: accel/kvm/kvm-all.c:1021:
+^I^I.dataread = val,$
ERROR: code indent should never use tabs
#37: FILE: accel/kvm/kvm-all.c:1022:
+^I^I.addr = addr,$
ERROR: code indent should never use tabs
#38: FILE: accel/kvm/kvm-all.c:1023:
+^I^I.len = size,$
ERROR: code indent should never use tabs
#39: FILE: accel/kvm/kvm-all.c:1024:
+^I^I.flags = KVM_IOEVENTFD_FLAG_DATAREAD,$
ERROR: code indent should never use tabs
#40: FILE: accel/kvm/kvm-all.c:1025:
+^I^I.fd = fd,$
ERROR: code indent should never use tabs
#41: FILE: accel/kvm/kvm-all.c:1026:
+^I};$
ERROR: code indent should never use tabs
#43: FILE: accel/kvm/kvm-all.c:1028:
+^Iif (!kvm_enabled()) {$
ERROR: code indent should never use tabs
#44: FILE: accel/kvm/kvm-all.c:1029:
+^I^Ireturn -ENOSYS;$
ERROR: code indent should never use tabs
#45: FILE: accel/kvm/kvm-all.c:1030:
+^I}$
ERROR: code indent should never use tabs
#47: FILE: accel/kvm/kvm-all.c:1032:
+^Iif (datamatch) {$
ERROR: code indent should never use tabs
#49: FILE: accel/kvm/kvm-all.c:1034:
+^I}$
ERROR: code indent should never use tabs
#51: FILE: accel/kvm/kvm-all.c:1036:
+^Iret = kvm_vm_ioctl(kvm_state, KVM_IOEVENTFD, &ioevent);$
ERROR: code indent should never use tabs
#53: FILE: accel/kvm/kvm-all.c:1038:
+^Iif (ret < 0) {$
ERROR: code indent should never use tabs
#54: FILE: accel/kvm/kvm-all.c:1039:
+^I^Ireturn -errno;$
ERROR: code indent should never use tabs
#55: FILE: accel/kvm/kvm-all.c:1040:
+^I}$
ERROR: code indent should never use tabs
#57: FILE: accel/kvm/kvm-all.c:1042:
+^Ireturn 0;$
ERROR: code indent should never use tabs
#80: FILE: accel/kvm/kvm-all.c:2298:
+^Iprintf("Failed to initialize EventNotifier\n");$
ERROR: else should follow close brace '}'
#82: FILE: accel/kvm/kvm-all.c:2300:
+ }
+ else {
ERROR: braces {} are necessary for all arms of this statement
#87: FILE: accel/kvm/kvm-all.c:2305:
+ if (ret < 0)
[...]
total: 23 errors, 1 warnings, 79 lines checked
Patch 2/2 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===
Test command exited with code: 1
The full log is available at
http://patchew.org/logs/20201020170056.433528-1-ameynarkhede03@gmail.com/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] KVM: Introduce ioeventfd read support
2020-10-20 17:00 [PATCH 0/2] KVM: Introduce ioeventfd read support Amey Narkhede
` (2 preceding siblings ...)
2020-10-20 17:09 ` [PATCH 0/2] KVM: Introduce ioeventfd read support no-reply
@ 2020-10-20 17:19 ` Amey Narkhede
2020-10-31 14:33 ` Paolo Bonzini
4 siblings, 0 replies; 6+ messages in thread
From: Amey Narkhede @ 2020-10-20 17:19 UTC (permalink / raw)
To: qemu-devel, ameynarkhede03
[-- Attachment #1: Type: text/plain, Size: 886 bytes --]
On 20/10/20 10:30PM, Amey Narkhede wrote:
Please ignore this mail. I meant to send
this mail to stefan but due to me being careless
I forgot that I previously configured git-publish
for qemu and didn't check the final
message before hitting send.
> The first patch updates linux headers to
> add ioeventfd read support while the
> second patch can be used to test the
> ioeventfd read feature with kvm-unit-test
> which reads from specified guest addres.
> Make sure the address provided in
> kvm_set_ioeventfd_read matches with address
> in x86/ioeventfd_read test in kvm-unit-tests.
>
> Amey Narkhede (2):
> linux-headers: Add support for reads in ioeventfd
> kvm: Add ioeventfd read test code
>
> accel/kvm/kvm-all.c | 55 +++++++++++++++++++++++++++++++++++++++
> linux-headers/linux/kvm.h | 5 +++-
> 2 files changed, 59 insertions(+), 1 deletion(-)
>
> --
> 2.28.0
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] KVM: Introduce ioeventfd read support
2020-10-20 17:00 [PATCH 0/2] KVM: Introduce ioeventfd read support Amey Narkhede
` (3 preceding siblings ...)
2020-10-20 17:19 ` Amey Narkhede
@ 2020-10-31 14:33 ` Paolo Bonzini
4 siblings, 0 replies; 6+ messages in thread
From: Paolo Bonzini @ 2020-10-31 14:33 UTC (permalink / raw)
To: Amey Narkhede, qemu-devel; +Cc: Cornelia Huck, kvm, Michael S. Tsirkin
On 20/10/20 19:00, Amey Narkhede wrote:
> The first patch updates linux headers to
> add ioeventfd read support while the
> second patch can be used to test the
> ioeventfd read feature with kvm-unit-test
> which reads from specified guest addres.
> Make sure the address provided in
> kvm_set_ioeventfd_read matches with address
> in x86/ioeventfd_read test in kvm-unit-tests.
>
> Amey Narkhede (2):
> linux-headers: Add support for reads in ioeventfd
> kvm: Add ioeventfd read test code
>
> accel/kvm/kvm-all.c | 55 +++++++++++++++++++++++++++++++++++++++
> linux-headers/linux/kvm.h | 5 +++-
> 2 files changed, 59 insertions(+), 1 deletion(-)
>
Hi,
in what occasions is this useful?
Paolo
^ permalink raw reply [flat|nested] 6+ messages in thread