summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f>2023-05-10 17:29:47 +0000
committervboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f>2023-05-10 17:29:47 +0000
commit0e50eb623993788d110fa4f29ea5aa572fe8f004 (patch)
tree761d11aa898140a2a95e761ef336fb63326b4bc9
parentd3bd81c0c3fc003a91f8b3109777bb3df4a01e30 (diff)
downloadVirtualBox-svn-0e50eb623993788d110fa4f29ea5aa572fe8f004.tar.gz
VMM/NEMR3Native-darwin-armv8: Set and clear the PPI interrupt of the vTimer if activated, bugref:10390
git-svn-id: https://www.virtualbox.org/svn/vbox/trunk@99735 cfe28804-0f27-0410-a406-dd0f0b0b656f
-rw-r--r--src/VBox/VMM/VMMR3/NEMR3Native-darwin-armv8.cpp33
-rw-r--r--src/VBox/VMM/include/NEMInternal.h2
2 files changed, 30 insertions, 5 deletions
diff --git a/src/VBox/VMM/VMMR3/NEMR3Native-darwin-armv8.cpp b/src/VBox/VMM/VMMR3/NEMR3Native-darwin-armv8.cpp
index 0c12309b1ff..24b61201ede 100644
--- a/src/VBox/VMM/VMMR3/NEMR3Native-darwin-armv8.cpp
+++ b/src/VBox/VMM/VMMR3/NEMR3Native-darwin-armv8.cpp
@@ -39,10 +39,8 @@
#include <VBox/vmm/nem.h>
#include <VBox/vmm/iem.h>
#include <VBox/vmm/em.h>
-#include <VBox/vmm/apic.h>
+#include <VBox/vmm/gic.h>
#include <VBox/vmm/pdm.h>
-#include <VBox/vmm/hm.h>
-#include <VBox/vmm/hm_vmx.h>
#include <VBox/vmm/dbgftrace.h>
#include <VBox/vmm/gcm.h>
#include "NEMInternal.h"
@@ -69,6 +67,10 @@
*********************************************************************************************************************************/
+/** @todo The vTimer PPI for the virt platform, make it configurable. */
+#define NEM_DARWIN_VTIMER_GIC_PPI_IRQ 11
+
+
/*********************************************************************************************************************************
* Structures and Typedefs *
*********************************************************************************************************************************/
@@ -1083,8 +1085,8 @@ static VBOXSTRICTRC nemR3DarwinHandleExit(PVM pVM, PVMCPU pVCpu)
case HV_EXIT_REASON_EXCEPTION:
return nemR3DarwinHandleExitException(pVM, pVCpu, pExit);
case HV_EXIT_REASON_VTIMER_ACTIVATED:
- /** @todo Set interrupt. */
- return VINF_EM_RESCHEDULE;
+ pVCpu->nem.s.fVTimerActivated = true;
+ return GICPpiSet(pVCpu, NEM_DARWIN_VTIMER_GIC_PPI_IRQ, true /*fAsserted*/);
default:
AssertReleaseFailed();
break;
@@ -1135,6 +1137,27 @@ static VBOXSTRICTRC nemR3DarwinPreRunGuest(PVM pVM, PVMCPU pVCpu, bool fSingleSt
int rc = nemR3DarwinExportGuestState(pVM, pVCpu);
AssertRCReturn(rc, rc);
+ /* Check whether the vTimer interrupt was handled by the guest and we can unmask the vTimer. */
+ if (pVCpu->nem.s.fVTimerActivated)
+ {
+ /* Read the CNTV_CTL_EL0 register. */
+ uint64_t u64CntvCtl = 0;
+
+ hv_return_t hrc = hv_vcpu_get_sys_reg(pVCpu->nem.s.hVCpu, HV_SYS_REG_CNTV_CTL_EL0, &u64CntvCtl);
+ AssertRCReturn(hrc == HV_SUCCESS, VERR_NEM_IPE_9);
+
+ if ( (u64CntvCtl & (ARMV8_CNTV_CTL_EL0_AARCH64_ENABLE | ARMV8_CNTV_CTL_EL0_AARCH64_IMASK | ARMV8_CNTV_CTL_EL0_AARCH64_ISTATUS))
+ != (ARMV8_CNTV_CTL_EL0_AARCH64_ENABLE | ARMV8_CNTV_CTL_EL0_AARCH64_ISTATUS))
+ {
+ /* Clear the interrupt. */
+ GICPpiSet(pVCpu, NEM_DARWIN_VTIMER_GIC_PPI_IRQ, false /*fAsserted*/);
+
+ pVCpu->nem.s.fVTimerActivated = false;
+ hrc = hv_vcpu_set_vtimer_mask(pVCpu->nem.s.hVCpu, false /*vtimer_is_masked*/);
+ AssertReturn(hrc == HV_SUCCESS, VERR_NEM_IPE_9);
+ }
+ }
+
/* Set the pending interrupt state. */
if (VMCPU_FF_IS_ANY_SET(pVCpu, VMCPU_FF_INTERRUPT_IRQ | VMCPU_FF_INTERRUPT_FIQ))
{
diff --git a/src/VBox/VMM/include/NEMInternal.h b/src/VBox/VMM/include/NEMInternal.h
index 9950529c6e5..5222f6eee11 100644
--- a/src/VBox/VMM/include/NEMInternal.h
+++ b/src/VBox/VMM/include/NEMInternal.h
@@ -482,6 +482,8 @@ typedef struct NEMCPU
hv_vcpu_exit_t *pHvExit;
/** Flag whether an event is pending. */
bool fEventPending;
+ /** Flag whether the vTimer got activated and is masked. */
+ bool fVTimerActivated;
# else
/** The vCPU handle associated with the EMT executing this vCPU. */
hv_vcpuid_t hVCpuId;