Skip to contentSkip to conversation

hvf x86 correctness and efficiency improvements

PATCH Applied Phil Dennis-Jordan 3 participants 10 messages Jun 5, 2024 – Jun 6, 2024

lore
Share & tools
lore
#0 lore raw

v3 cover hvf x86 correctness and efficiency improvements

This is a series of semi-related patches for the x86 macOS Hypervisor.framework (hvf) accelerator backend. The intention is to (1) fix bugs and (2) move the hvf backend to use more modern and efficient APIs in Hypervisor.framework.

The goal is to replace the main hv_vcpu_run() call with hv_vcpu_run_until(). On the one hand, doing so noticeably improves performance in itself. On the other hand, using the new API is a prerequisite for enabling hvf's in-kernel virtual APIC implementation, which provides a further, even more drastic performance improvement on many workloads. Integrating the APIC requires a bunch of large commits which still need some compatibility bugfixing, and which I hope to submit as a later patch set.

Compared to v2 of the patch set, I've re-added the kick and hv_vcpu_run_until patches after analysing hv_vcpu_interrupt in more detail and finding it safe. Plus, there's an ergonomic improvement to the assert_hvf_ok macro.

In this series:

Patch 1 enables the INVTSC CPUID bit when running with hvf. This can enable some optimisations in the guest OS, and I've not found any reason it shouldn't be allowed for hvf based hosts. It now also includes setting a migration blocker when the feature is active.

Patch 2 fixes a bunch of compile warnings that kept littering my build logs, so I finally caved and fixed them. As far as I can tell, these were all ancient typos.

Patch 3 sorts out the minor mess of hvf vCPU IDs/handles. The aarch64 and x86-64 versions of Hypervisor.framework's APIs use different integral types (uint64_t vs unsigned int) when referencing vCPUs, so this changes the code to use the correct one depending on build arch instead of awkward pointer casts. (There's currently only one instance of such a cast, but patches 5 and 6 would have added more, so I'm fixing this preemptively.)

Patch 4 fixes dirty page tracking for the x86 hvf backend. This has previously only accidentally worked because hv_vcpu_run() makes spurious EPT fault exits. Switching to hv_vcpu_run_until() surfaces this issue when using an emulated VGA adapter for example, as those use dirty page tracking to do partial screen updates. This issue was causing problems on previous attempts of switching to the newer HVF APIs as it was masked by the inefficiency of the older APIs.

Patch 5 implements a "real" vCPU kick using hv_vcpu_interrupt(). So far, the x86 hvf backend's external interrupt injection has relied on hv_vcpu_run()'s behaviour of exiting the VM very frequently without host action to handle external interrupts. This is not a great state of affairs in itself, but fails entirely when switching to hv_vcpu_run_until() which returns only when there is actual work to be done by the VMM.
In previous attempts to introduce this improved 'kick', there has been doubt about hv_vcpu_interrupt()'s reliability in edge cases, particularly when an interrupt is issued when the vCPU thread is either not running hv_vcpu_run_until() at all, or either entering or exiting VMX mode. I believe this concern is unfounded for three reasons:
1) The patches have been in use in a fleet of hundreds of production systems running CI workloads for over two years. No symptoms of a missed interrupt (or indeed any other issues) have been encountered.
2) I have tried to provoke such an edge case and failed. To do this, I hacked up Michael Steil's toy "hvdos" VMM to run some bare-metal assembly code, then hit the running VM with a barrage of hv_vcpu_interrupt calls at randomly spaced intervals. Any hv_vcpu_interrupt call is followed shortly by a VM exit, regardless of what state the vCPU thread was in. Multiple interrupts in short succession are coalesced, but only before a VM exit. If an interrupt is issued after the VM has already exited, a further exit is triggered as soon as the vCPU thread attempts to re-enter the VM. The code for this is here: https://gitlab.com/pmdj/hvf-edge-cases
3) The doubts about hv_vcpu_interrupt edge cases seem to originate in observed behaviour that was actually caused by the dirty memory tracking bug fixed in patch 4 of this series. That bug had nothing to do with hv_vcpu_interrupt as such, it was surfaced by hv_vcpu_run_until()'s change in EPT fault exit behaviour compared to hv_vcpu_run().
Of course, this is not PROOF of absence of defects, but I'm not aware of any formal proofs covering other Qemu code or dependencies. I have also asked Apple's DTS to officially clarify hv_vcpu_interrupt()'s behaviour in edge cases but unfortunately received no reply.

Patch 6 switches from hv_vcpu_run() to hv_vcpu_run_until() where supported. This was of course the goal, and the previous patches fix all the bugs that caused this patch to surface them.

Patch 7 provides a small improvement to error messages if and when an hvf call fails. assert_hvf_ok() would previously only tell you the error code of the failing call, not which call was failing, nor the call site. The change makes it behave more like a classic assertion, reporting the expression as well as the source code location along with the error.

changelog:
v3:
- Back to one patch series with all the changes.
- Detailed investigation into edge case behaviour of hv_vcpu_interrupt. Determined it was behaving fine, no race condition workarounds needed, so the kick and hv_vcpu_run_until patches have actually stayed essentially the same as in v1.
- Added the assert_hvf_ok patch because I kept using it when debugging.

v2:
- Migration blocker when INVTSC is set (Thanks Paolo for pointing that out!)
- Dirty page tracking fix (Thanks Roman for noticing the regression in observed behaviour on certain VMs, which led me to debugging this issue.)
- vCPU handle type cleanup (Based on discussion with Paolo)
- Added fixes for existing compile warnings.
- Split patch series into 2 parts.

This work has been sponsored by Sauce Labs Inc.

Phil Dennis-Jordan (7):
i386/hvf: Adds support for INVTSC cpuid bit
i386/hvf: Fixes some compilation warnings
hvf: Consistent types for vCPU handles
i386/hvf: Fixes dirty memory tracking by page granularity RX->RWX
change
i386/hvf: In kick_vcpu use hv_vcpu_interrupt to force exit i386/hvf: Updates API usage to use modern vCPU run function
hvf: Makes assert_hvf_ok report failed expression

 accel/hvf/hvf-accel-ops.c    |  2 +-
 accel/hvf/hvf-all.c          | 49 ++++++++++++++++--------------------
 include/sysemu/hvf_int.h     |  9 +++++--
 target/i386/hvf/hvf.c        | 47 +++++++++++++++++++++++++++++++---
 target/i386/hvf/vmx.h        |  3 +--
 target/i386/hvf/x86_cpuid.c  |  4 +++
 target/i386/hvf/x86_decode.c |  2 +-
 target/i386/hvf/x86_emu.c    |  4 +--
 8 files changed, 81 insertions(+), 39 deletions(-)
Signature · 1 line
2.36.1
#1 lore raw

PATCH v3 1/7 i386/hvf: Adds support for INVTSC cpuid bit

This patch adds the INVTSC bit to the Hypervisor.framework accelerator's CPUID bit passthrough allow-list. Previously, specifying +invtsc in the CPU configuration would fail with the following warning despite the host CPU advertising the feature:

qemu-system-x86_64: warning: host doesn't support requested feature:
CPUID.80000007H:EDX.invtsc [bit 8]

x86 macOS itself relies on a fixed rate TSC for its own Mach absolute time timestamp mechanism, so there's no reason we can't enable this bit for guests. When the feature is enabled, a migration blocker is installed.

---
 target/i386/hvf/hvf.c       | 18 ++++++++++++++++++
 target/i386/hvf/x86_cpuid.c |  4 ++++
 2 files changed, 22 insertions(+)
target/i386/hvf/hvf.c +18 -0
index e493452acb..e6e916225b 100644
@@ -49,6 +49,8 @@
 #include "qemu/osdep.h"
 #include "qemu/error-report.h"
 #include "qemu/memalign.h"
+#include "qapi/error.h"
+#include "migration/blocker.h"
 
 #include "sysemu/hvf.h"
 #include "sysemu/hvf_int.h"
@@ -74,6 +76,8 @@
 #include "qemu/accel.h"
 #include "target/i386/cpu.h"
 
+static Error *invtsc_mig_blocker;
+
 void vmx_update_tpr(CPUState *cpu)
 {
     /* TODO: need integrate APIC handling */
@@ -221,6 +225,8 @@ int hvf_arch_init_vcpu(CPUState *cpu)
 {
     X86CPU *x86cpu = X86_CPU(cpu);
     CPUX86State *env = &x86cpu->env;
+    Error *local_err = NULL;
+    int r;
     uint64_t reqCap;
 
     init_emu();
@@ -238,6 +244,18 @@ int hvf_arch_init_vcpu(CPUState *cpu)
         }
     }
 
+    if ((env->features[FEAT_8000_0007_EDX] & CPUID_APM_INVTSC) &&
+        invtsc_mig_blocker == NULL) {
+        error_setg(&invtsc_mig_blocker,
+                   "State blocked by non-migratable CPU device (invtsc flag)");
+        r = migrate_add_blocker(&invtsc_mig_blocker, &local_err);
+        if (r < 0) {
+            error_report_err(local_err);
+            return r;
+        }
+    }
+
+
     if (hv_vmx_read_capability(HV_VMX_CAP_PINBASED,
         &hvf_state->hvf_caps->vmx_cap_pinbased)) {
         abort();
target/i386/hvf/x86_cpuid.c +4 -0
index 9380b90496..e56cd8411b 100644
@@ -146,6 +146,10 @@ uint32_t hvf_get_supported_cpuid(uint32_t func, uint32_t idx,
                 CPUID_EXT3_3DNOWPREFETCH | CPUID_EXT3_OSVW | CPUID_EXT3_XOP |
                 CPUID_EXT3_FMA4 | CPUID_EXT3_TBM;
         break;
+    case 0x80000007:
+        edx &= CPUID_APM_INVTSC;
+        eax = ebx = ecx = 0;
+        break;
     default:
         return 0;
     }
Signature · 1 line
2.36.1
#2 lore raw

PATCH v3 2/7 i386/hvf: Fixes some compilation warnings

In reply to Phil Dennis-Jordan

A bunch of function definitions used empty parentheses instead of (void) syntax, yielding the following warning when building with clang on macOS:

warning: a function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes]

In addition to fixing these function headers, it also fixes what appears to be a typo causing a variable to be unused after initialisation.

warning: variable 'entry_ctls' set but not used [-Wunused-but-set-variable]

---
 target/i386/hvf/vmx.h        | 3 +--
 target/i386/hvf/x86_decode.c | 2 +-
 target/i386/hvf/x86_emu.c    | 4 ++--
 3 files changed, 4 insertions(+), 5 deletions(-)
target/i386/hvf/vmx.h +1 -2
index 0fffcfa46c..3954ef883d 100644
@@ -95,8 +95,7 @@ static void enter_long_mode(hv_vcpuid_t vcpu, uint64_t cr0, uint64_t efer)
     efer |= MSR_EFER_LMA;
     wvmcs(vcpu, VMCS_GUEST_IA32_EFER, efer);
     entry_ctls = rvmcs(vcpu, VMCS_ENTRY_CTLS);
-    wvmcs(vcpu, VMCS_ENTRY_CTLS, rvmcs(vcpu, VMCS_ENTRY_CTLS) |
-          VM_ENTRY_GUEST_LMA);
+    wvmcs(vcpu, VMCS_ENTRY_CTLS, entry_ctls | VM_ENTRY_GUEST_LMA);
 
     uint64_t guest_tr_ar = rvmcs(vcpu, VMCS_GUEST_TR_ACCESS_RIGHTS);
     if ((efer & MSR_EFER_LME) &&
target/i386/hvf/x86_decode.c +1 -1
index 3728d7705e..a4a28f113f 100644
@@ -2111,7 +2111,7 @@ uint32_t decode_instruction(CPUX86State *env, struct x86_decode *decode)
     return decode->len;
 }
 
-void init_decoder()
+void init_decoder(void)
 {
     int i;
     
target/i386/hvf/x86_emu.c +2 -2
index 3a3f0a50d0..38c782b8e3 100644
@@ -1409,7 +1409,7 @@ static struct cmd_handler {
 
 static struct cmd_handler _cmd_handler[X86_DECODE_CMD_LAST];
 
-static void init_cmd_handler()
+static void init_cmd_handler(void)
 {
     int i;
     for (i = 0; i < ARRAY_SIZE(handlers); i++) {
@@ -1481,7 +1481,7 @@ bool exec_instruction(CPUX86State *env, struct x86_decode *ins)
     return true;
 }
 
-void init_emu()
+void init_emu(void)
 {
     init_cmd_handler();
 }
Signature · 1 line
2.36.1
#3 lore raw

PATCH v3 3/7 hvf: Consistent types for vCPU handles

In reply to Phil Dennis-Jordan

macOS Hypervisor.framework uses different types for identifying vCPUs, hv_vcpu_t or hv_vcpuid_t, depending on host architecture. They are not just differently named typedefs for the same primitive type, but reference different-width integers.

Instead of using an integer type and casting where necessary, this change introduces a typedef which resolves the active architecture’s hvf typedef. It also removes a now-unnecessary cast.

---
 accel/hvf/hvf-accel-ops.c | 2 +-
 include/sysemu/hvf_int.h  | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)
accel/hvf/hvf-accel-ops.c +1 -1
index 6f1e27ef46..b2a37a2229 100644
@@ -400,7 +400,7 @@ static int hvf_init_vcpu(CPUState *cpu)
     r = hv_vcpu_create(&cpu->accel->fd,
                        (hv_vcpu_exit_t **)&cpu->accel->exit, NULL);
 #else
-    r = hv_vcpu_create((hv_vcpuid_t *)&cpu->accel->fd, HV_VCPU_DEFAULT);
+    r = hv_vcpu_create(&cpu->accel->fd, HV_VCPU_DEFAULT);
 #endif
     cpu->accel->dirty = true;
     assert_hvf_ok(r);
include/sysemu/hvf_int.h +3 -1
index 4a327fd526..30e739a2b5 100644
@@ -13,8 +13,10 @@
 
 #ifdef __aarch64__
 #include <Hypervisor/Hypervisor.h>
+typedef hv_vcpu_t hvf_vcpuid;
 #else
 #include <Hypervisor/hv.h>
+typedef hv_vcpuid_t hvf_vcpuid;
 #endif
 
 /* hvf_slot flags */
@@ -50,7 +52,7 @@ struct HVFState {
 extern HVFState *hvf_state;
 
 struct AccelCPUState {
-    uint64_t fd;
+    hvf_vcpuid fd;
     void *exit;
     bool vtimer_masked;
     sigset_t unblock_ipi_mask;
Signature · 1 line
2.36.1
#4 lore raw

PATCH v3 4/7 i386/hvf: Fixes dirty memory tracking by page granularity RX->RWX change

In reply to Phil Dennis-Jordan

When using x86 macOS Hypervisor.framework as accelerator, detection of dirty memory regions is implemented by marking logged memory region slots as read-only in the EPT, then setting the dirty flag when a guest write causes a fault. The area marked dirty should then be marked writable in order for subsequent writes to succeed without a VM exit.

However, dirty bits are tracked on a per-page basis, whereas the fault handler was marking the whole logged memory region as writable. This change fixes the fault handler so only the protection of the single faulting page is marked as dirty.

(Note: the dirty page tracking appeared to work despite this error because HVF’s hv_vcpu_run() function generated unnecessary EPT fault exits, which ended up causing the dirty marking handler to run even when the memory region had been marked RW. When using hv_vcpu_run_until(), a change planned for a subsequent commit, these spurious exits no longer occur, so dirty memory tracking malfunctions.)

Additionally, the dirty page is set to permit code execution, the same as all other guest memory; changing memory protection from RX to RW not RWX appears to have been an oversight.

---
 target/i386/hvf/hvf.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
target/i386/hvf/hvf.c +3 -2
index e6e916225b..268c5734d5 100644
@@ -135,9 +135,10 @@ static bool ept_emulation_fault(hvf_slot *slot, uint64_t gpa, uint64_t ept_qual)
 
     if (write && slot) {
         if (slot->flags & HVF_SLOT_LOG) {
+            uint64_t dirty_page_start = gpa & ~(TARGET_PAGE_SIZE - 1u);
             memory_region_set_dirty(slot->region, gpa - slot->start, 1);
-            hv_vm_protect((hv_gpaddr_t)slot->start, (size_t)slot->size,
-                          HV_MEMORY_READ | HV_MEMORY_WRITE);
+            hv_vm_protect(dirty_page_start, TARGET_PAGE_SIZE,
+                          HV_MEMORY_READ | HV_MEMORY_WRITE | HV_MEMORY_EXEC);
         }
     }
 
Signature · 1 line
2.36.1
#5 lore raw

PATCH v3 5/7 i386/hvf: In kick_vcpu use hv_vcpu_interrupt to force exit

In reply to Phil Dennis-Jordan

When interrupting a vCPU thread, this patch actually tells the hypervisor to stop running guest code on that vCPU.

Calling hv_vcpu_interrupt actually forces a vCPU exit, analogously to hv_vcpus_exit on aarch64. Alternatively, if the vCPU thread is not
running the VM, it will immediately cause an exit when it attempts to do so.

Previously, hvf_kick_vcpu_thread relied upon hv_vcpu_run returning very frequently, including many spurious exits, which made it less of a problem that nothing was actively done to stop the vCPU thread running guest code. The newer, more efficient hv_vcpu_run_until exits much more rarely, so a true "kick" is needed before switching to that.

---
 target/i386/hvf/hvf.c | 1 +
 1 file changed, 1 insertion(+)
target/i386/hvf/hvf.c +1 -0
index 268c5734d5..106ac5cbf6 100644
@@ -215,6 +215,7 @@ static inline bool apic_bus_freq_is_known(CPUX86State *env)
 void hvf_kick_vcpu_thread(CPUState *cpu)
 {
     cpus_kick_thread(cpu);
+    hv_vcpu_interrupt(&cpu->accel->fd, 1);
 }
 
 int hvf_arch_init(void)
Signature · 1 line
2.36.1
#6 lore raw

PATCH v3 6/7 i386/hvf: Updates API usage to use modern vCPU run function

In reply to Phil Dennis-Jordan

macOS 10.15 introduced the more efficient hv_vcpu_run_until() function to supersede hv_vcpu_run(). According to the documentation, there is no longer any reason to use the latter on modern host OS versions, especially after 11.0 added support for an indefinite deadline.

Observed behaviour of the newer function is that as documented, it exits much less frequently - and most of the original function’s exits seem to have been effectively pointless.

Another reason to use the new function is that it is a prerequisite for using newer features such as in-kernel APIC support. (Not covered by this patch.)

This change implements the upgrade by selecting one of three code paths at compile time: two static code paths for the new and old functions respectively, when building for targets where the new function is either not available, or where the built executable won’t run on older platforms lacking the new function anyway. The third code path selects dynamically based on runtime detected availability of the weakly-linked symbol.

---
 target/i386/hvf/hvf.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
target/i386/hvf/hvf.c +22 -1
index 106ac5cbf6..2d0eef6cd9 100644
@@ -427,6 +427,27 @@ static void hvf_cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
     }
 }
 
+static hv_return_t hvf_vcpu_run(hv_vcpuid_t vcpu_id)
+{
+    /*
+     * hv_vcpu_run_until is available and recommended from macOS 10.15+,
+     * HV_DEADLINE_FOREVER from 11.0. Test for availability at runtime and fall
+     * back to hv_vcpu_run() only where necessary.
+     */
+#ifndef MAC_OS_VERSION_11_0
+    return hv_vcpu_run(vcpu_id);
+#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_VERSION_11_0
+    return hv_vcpu_run_until(vcpu_id, HV_DEADLINE_FOREVER);
+#else /* MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_VERSION_11_0 */
+    /* 11.0 SDK or newer, but could be < 11 at runtime */
+    if (__builtin_available(macOS 11.0, *)) {
+        return hv_vcpu_run_until(vcpu_id, HV_DEADLINE_FOREVER);
+    } else {
+        return hv_vcpu_run(vcpu_id);
+    }
+#endif
+}
+
 int hvf_vcpu_exec(CPUState *cpu)
 {
     X86CPU *x86_cpu = X86_CPU(cpu);
@@ -455,7 +476,7 @@ int hvf_vcpu_exec(CPUState *cpu)
             return EXCP_HLT;
         }
 
-        hv_return_t r  = hv_vcpu_run(cpu->accel->fd);
+        hv_return_t r = hvf_vcpu_run(cpu->accel->fd);
         assert_hvf_ok(r);
 
         /* handle VMEXIT */
Signature · 1 line
2.36.1
#7 lore raw

PATCH v3 7/7 hvf: Makes assert_hvf_ok report failed expression

In reply to Phil Dennis-Jordan

When a macOS Hypervisor.framework call fails which is checked by assert_hvf_ok(), Qemu exits printing the error value, but not the location
in the code, as regular assert() macro expansions would.

This change turns assert_hvf_ok() into a macro similar to other assertions, which expands to a call to the corresponding _impl() function together with information about the expression that failed the assertion and its location in the code.

Additionally, stringifying the numeric hv_return_t code is factored into a helper function that can be reused for diagnostics and debugging outside of assertions.

---
 accel/hvf/hvf-all.c      | 49 +++++++++++++++++-----------------------
 include/sysemu/hvf_int.h |  5 +++-
 2 files changed, 25 insertions(+), 29 deletions(-)
accel/hvf/hvf-all.c +21 -28
index db05b81be5..c008dc2f1e 100644
@@ -13,40 +13,33 @@
 #include "sysemu/hvf.h"
 #include "sysemu/hvf_int.h"
 
-void assert_hvf_ok(hv_return_t ret)
+const char *hvf_return_string(hv_return_t ret)
 {
-    if (ret == HV_SUCCESS) {
-        return;
-    }
-
     switch (ret) {
-    case HV_ERROR:
-        error_report("Error: HV_ERROR");
-        break;
-    case HV_BUSY:
-        error_report("Error: HV_BUSY");
-        break;
-    case HV_BAD_ARGUMENT:
-        error_report("Error: HV_BAD_ARGUMENT");
-        break;
-    case HV_NO_RESOURCES:
-        error_report("Error: HV_NO_RESOURCES");
-        break;
-    case HV_NO_DEVICE:
-        error_report("Error: HV_NO_DEVICE");
-        break;
-    case HV_UNSUPPORTED:
-        error_report("Error: HV_UNSUPPORTED");
-        break;
+    case HV_SUCCESS:      return "HV_SUCCESS";
+    case HV_ERROR:        return "HV_ERROR";
+    case HV_BUSY:         return "HV_BUSY";
+    case HV_BAD_ARGUMENT: return "HV_BAD_ARGUMENT";
+    case HV_NO_RESOURCES: return "HV_NO_RESOURCES";
+    case HV_NO_DEVICE:    return "HV_NO_DEVICE";
+    case HV_UNSUPPORTED:  return "HV_UNSUPPORTED";
 #if defined(MAC_OS_VERSION_11_0) && \
     MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_VERSION_11_0
-    case HV_DENIED:
-        error_report("Error: HV_DENIED");
-        break;
+    case HV_DENIED:       return "HV_DENIED";
 #endif
-    default:
-        error_report("Unknown Error");
+    default:              return "[unknown hv_return value]";
     }
+}
+
+void assert_hvf_ok_impl(hv_return_t ret, const char *file, unsigned int line,
+                        const char *exp)
+{
+    if (ret == HV_SUCCESS) {
+        return;
+    }
+
+    error_report("Error: %s = %s (0x%x, at %s:%u)",
+        exp, hvf_return_string(ret), ret, file, line);
 
     abort();
 }
include/sysemu/hvf_int.h +4 -1
index 30e739a2b5..5b28d17ba1 100644
@@ -60,7 +60,10 @@ struct AccelCPUState {
     bool dirty;
 };
 
-void assert_hvf_ok(hv_return_t ret);
+void assert_hvf_ok_impl(hv_return_t ret, const char *file, unsigned int line,
+                        const char *exp);
+#define assert_hvf_ok(EX) assert_hvf_ok_impl((EX), __FILE__, __LINE__, #EX)
+const char *hvf_return_string(hv_return_t ret);
 int hvf_arch_init(void);
 int hvf_arch_init_vcpu(CPUState *cpu);
 void hvf_arch_vcpu_destroy(CPUState *cpu);
Signature · 1 line
2.36.1
#8 lore raw
In reply to Phil Dennis-Jordan

Queued, thanks.

Thanks for persisting! It sucks that the hv_vcpu_interrupt() API docs are not clear, but your tests are great. The self-interrupt one is the case that I was most worried about, and you're covering it. Sorry for being a pain for nothing, at least retrospectively.

Paolo

#9 lore raw
Quoted 1 line · Paolo Bonzini

Queued, thanks.

Thanks - also for reviewing, etc.!

Quoted 4 lines

Thanks for persisting! It sucks that the hv_vcpu_interrupt() API docs are not clear, but your tests are great. The self-interrupt one is the case that I was most worried about, and you're covering it. Sorry for being a pain for nothing, at least retrospectively.

No worries - the concern is understandable, especially in the face of the unfortunate apparent regression which turned out to be the dirty page tracking bug.

And I agree, the hv_vcpu_interrupt docs, along with the rest of Hypervisor.framework's, are terrible. There does not appear to have been any thought about what a developer using that API might care about. I've been working on integrating the HVF APIC/PIC/IOAPIC implementations, and there are ambiguities and edge cases galore. Unfortunately (?), the perf improvement is worth the trouble of trial & error…

Phil