[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 18/23] hyperv: add synic event flag signaling
From: |
Roman Kagan |
Subject: |
[Qemu-devel] [PATCH 18/23] hyperv: add synic event flag signaling |
Date: |
Tue, 6 Jun 2017 21:19:43 +0300 |
Add infrastructure to signal SynIC event flags by atomically setting the
corresponding bit in the event flags page and firing a SINT if
necessary.
Signed-off-by: Roman Kagan <address@hidden>
---
target/i386/hyperv.h | 2 ++
target/i386/hyperv.c | 32 ++++++++++++++++++++++++++++++++
2 files changed, 34 insertions(+)
diff --git a/target/i386/hyperv.h b/target/i386/hyperv.h
index fa3e988..a2d4304 100644
--- a/target/i386/hyperv.h
+++ b/target/i386/hyperv.h
@@ -39,4 +39,6 @@ void hyperv_synic_update(X86CPU *cpu);
int hyperv_post_msg(HvSintRoute *sint_route, struct hyperv_message *msg);
+int hyperv_set_evt_flag(HvSintRoute *sint_route, unsigned evtno);
+
#endif
diff --git a/target/i386/hyperv.c b/target/i386/hyperv.c
index 0a7f9b1..dcf49e4 100644
--- a/target/i386/hyperv.c
+++ b/target/i386/hyperv.c
@@ -17,6 +17,7 @@
#include "hw/qdev-properties.h"
#include "exec/address-spaces.h"
#include "sysemu/cpus.h"
+#include "qemu/bitops.h"
#include "migration/vmstate.h"
#include "hyperv.h"
#include "hyperv_proto.h"
@@ -189,6 +190,37 @@ int hyperv_post_msg(HvSintRoute *sint_route, struct
hyperv_message *src_msg)
return 0;
}
+/*
+ * Set given event flag for a given sint on a given vcpu, and signal the sint.
+ */
+int hyperv_set_evt_flag(HvSintRoute *sint_route, unsigned evtno)
+{
+ int ret;
+ SynICState *synic = sint_route->synic;
+ unsigned long *flags, set_mask;
+ unsigned set_idx;
+
+ if (evtno > HV_EVENT_FLAGS_COUNT) {
+ return -EINVAL;
+ }
+ if (!synic->enabled || !synic->evt_page_addr) {
+ return -ENXIO;
+ }
+
+ set_idx = BIT_WORD(evtno);
+ set_mask = BIT_MASK(evtno);
+ flags = synic->evt_page->slot[sint_route->sint].flags;
+
+ if ((atomic_fetch_or(&flags[set_idx], set_mask) & set_mask) != set_mask) {
+ ret = kvm_hv_sint_route_set_sint(sint_route);
+ memory_region_set_dirty(&synic->evt_page_mr, 0,
+ sizeof(*synic->evt_page));
+ } else {
+ ret = 0;
+ }
+ return ret;
+}
+
static void async_synic_update(CPUState *cs, run_on_cpu_data data)
{
SynICState *synic = data.host_ptr;
--
2.9.4
- [Qemu-devel] [PATCH 14/23] kvm-all: make async_safe_run_on_cpu safe on kvm too, (continued)
[Qemu-devel] [PATCH 15/23] hyperv: make overlay pages for SynIC, Roman Kagan, 2017/06/06
[Qemu-devel] [PATCH 19/23] hyperv: process SIGNAL_EVENT hypercall, Roman Kagan, 2017/06/06
[Qemu-devel] [PATCH 18/23] hyperv: add synic event flag signaling,
Roman Kagan <=
[Qemu-devel] [PATCH 17/23] hyperv: add synic message delivery, Roman Kagan, 2017/06/06
[Qemu-devel] [PATCH 22/23] MAINTAINERS: add myself and eyakovlev@ for hyperv*, Roman Kagan, 2017/06/06
[Qemu-devel] [PATCH 20/23] hyperv: process POST_MESSAGE hypercall, Roman Kagan, 2017/06/06