QEMU-Devel Archive on lore.kernel.org
 help / color / Atom feed
* [PULL 0/1] HVF fix QEMU 4.2-rc
@ 2019-12-03  8:12 Paolo Bonzini
  2019-12-03  8:12 ` [PULL 1/1] hvf: correctly inject VMCS_INTR_T_HWINTR versus VMCS_INTR_T_SWINTR Paolo Bonzini
  2019-12-03 11:03 ` [PULL 0/1] HVF fix QEMU 4.2-rc Peter Maydell
  0 siblings, 2 replies; 3+ messages in thread
From: Paolo Bonzini @ 2019-12-03  8:12 UTC (permalink / raw)
  To: qemu-devel

The following changes since commit 39032981fa851d25fb27527f25f046fed800e585:

  Merge remote-tracking branch 'remotes/armbru/tags/pull-error-2019-12-02' into staging (2019-12-02 16:29:41 +0000)

are available in the Git repository at:

  git://github.com/bonzini/qemu.git tags/for-upstream

for you to fetch changes up to 64bef038e777208e4c35beae7f980fbd994b87eb:

  hvf: correctly inject VMCS_INTR_T_HWINTR versus VMCS_INTR_T_SWINTR. (2019-12-03 09:11:42 +0100)

----------------------------------------------------------------
* last HVF fix (Cameron)

----------------------------------------------------------------
Cameron Esfahani (1):
      hvf: correctly inject VMCS_INTR_T_HWINTR versus VMCS_INTR_T_SWINTR.

 target/i386/hvf/hvf.c    |  4 +++-
 target/i386/hvf/x86hvf.c | 14 +++++++++-----
 2 files changed, 12 insertions(+), 6 deletions(-)
-- 
2.21.0



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PULL 1/1] hvf: correctly inject VMCS_INTR_T_HWINTR versus VMCS_INTR_T_SWINTR.
  2019-12-03  8:12 [PULL 0/1] HVF fix QEMU 4.2-rc Paolo Bonzini
@ 2019-12-03  8:12 ` Paolo Bonzini
  2019-12-03 11:03 ` [PULL 0/1] HVF fix QEMU 4.2-rc Peter Maydell
  1 sibling, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2019-12-03  8:12 UTC (permalink / raw)
  To: qemu-devel; +Cc: Cameron Esfahani

From: Cameron Esfahani <dirty@apple.com>

Previous implementation in hvf_inject_interrupts() would always inject
VMCS_INTR_T_SWINTR even when VMCS_INTR_T_HWINTR was required.  Now
correctly determine when VMCS_INTR_T_HWINTR is appropriate versus
VMCS_INTR_T_SWINTR.

Make sure to clear ins_len and has_error_code when ins_len isn't
valid and error_code isn't set.

Signed-off-by: Cameron Esfahani <dirty@apple.com>
Message-Id: <bf8d945ea1b423786d7802bbcf769517d1fd01f8.1575330463.git.dirty@apple.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 target/i386/hvf/hvf.c    |  4 +++-
 target/i386/hvf/x86hvf.c | 14 +++++++++-----
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c
index 784e67d77e..d72543dc31 100644
--- a/target/i386/hvf/hvf.c
+++ b/target/i386/hvf/hvf.c
@@ -637,6 +637,8 @@ static void hvf_store_events(CPUState *cpu, uint32_t ins_len, uint64_t idtvec_in
     env->exception_injected = 0;
     env->interrupt_injected = -1;
     env->nmi_injected = false;
+    env->ins_len = 0;
+    env->has_error_code = false;
     if (idtvec_info & VMCS_IDT_VEC_VALID) {
         switch (idtvec_info & VMCS_IDT_VEC_TYPE) {
         case VMCS_IDT_VEC_HWINTR:
@@ -659,7 +661,7 @@ static void hvf_store_events(CPUState *cpu, uint32_t ins_len, uint64_t idtvec_in
             (idtvec_info & VMCS_IDT_VEC_TYPE) == VMCS_IDT_VEC_SWINTR) {
             env->ins_len = ins_len;
         }
-        if (idtvec_info & VMCS_INTR_DEL_ERRCODE) {
+        if (idtvec_info & VMCS_IDT_VEC_ERRCODE_VALID) {
             env->has_error_code = true;
             env->error_code = rvmcs(cpu->hvf_fd, VMCS_IDT_VECTORING_ERROR);
         }
diff --git a/target/i386/hvf/x86hvf.c b/target/i386/hvf/x86hvf.c
index 1485b95776..edefe5319a 100644
--- a/target/i386/hvf/x86hvf.c
+++ b/target/i386/hvf/x86hvf.c
@@ -345,8 +345,6 @@ void vmx_clear_int_window_exiting(CPUState *cpu)
              ~VMCS_PRI_PROC_BASED_CTLS_INT_WINDOW_EXITING);
 }
 
-#define NMI_VEC 2
-
 bool hvf_inject_interrupts(CPUState *cpu_state)
 {
     X86CPU *x86cpu = X86_CPU(cpu_state);
@@ -357,7 +355,11 @@ bool hvf_inject_interrupts(CPUState *cpu_state)
     bool have_event = true;
     if (env->interrupt_injected != -1) {
         vector = env->interrupt_injected;
-        intr_type = VMCS_INTR_T_SWINTR;
+        if (env->ins_len) {
+            intr_type = VMCS_INTR_T_SWINTR;
+        } else {
+            intr_type = VMCS_INTR_T_HWINTR;
+        }
     } else if (env->exception_nr != -1) {
         vector = env->exception_nr;
         if (vector == EXCP03_INT3 || vector == EXCP04_INTO) {
@@ -366,7 +368,7 @@ bool hvf_inject_interrupts(CPUState *cpu_state)
             intr_type = VMCS_INTR_T_HWEXCEPTION;
         }
     } else if (env->nmi_injected) {
-        vector = NMI_VEC;
+        vector = EXCP02_NMI;
         intr_type = VMCS_INTR_T_NMI;
     } else {
         have_event = false;
@@ -390,6 +392,8 @@ bool hvf_inject_interrupts(CPUState *cpu_state)
             if (env->has_error_code) {
                 wvmcs(cpu_state->hvf_fd, VMCS_ENTRY_EXCEPTION_ERROR,
                       env->error_code);
+                /* Indicate that VMCS_ENTRY_EXCEPTION_ERROR is valid */
+                info |= VMCS_INTR_DEL_ERRCODE;
             }
             /*printf("reinject  %lx err %d\n", info, err);*/
             wvmcs(cpu_state->hvf_fd, VMCS_ENTRY_INTR_INFO, info);
@@ -399,7 +403,7 @@ bool hvf_inject_interrupts(CPUState *cpu_state)
     if (cpu_state->interrupt_request & CPU_INTERRUPT_NMI) {
         if (!(env->hflags2 & HF2_NMI_MASK) && !(info & VMCS_INTR_VALID)) {
             cpu_state->interrupt_request &= ~CPU_INTERRUPT_NMI;
-            info = VMCS_INTR_VALID | VMCS_INTR_T_NMI | NMI_VEC;
+            info = VMCS_INTR_VALID | VMCS_INTR_T_NMI | EXCP02_NMI;
             wvmcs(cpu_state->hvf_fd, VMCS_ENTRY_INTR_INFO, info);
         } else {
             vmx_set_nmi_window_exiting(cpu_state);
-- 
2.21.0



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PULL 0/1] HVF fix QEMU 4.2-rc
  2019-12-03  8:12 [PULL 0/1] HVF fix QEMU 4.2-rc Paolo Bonzini
  2019-12-03  8:12 ` [PULL 1/1] hvf: correctly inject VMCS_INTR_T_HWINTR versus VMCS_INTR_T_SWINTR Paolo Bonzini
@ 2019-12-03 11:03 ` Peter Maydell
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2019-12-03 11:03 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: QEMU Developers

On Tue, 3 Dec 2019 at 08:16, Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> The following changes since commit 39032981fa851d25fb27527f25f046fed800e585:
>
>   Merge remote-tracking branch 'remotes/armbru/tags/pull-error-2019-12-02' into staging (2019-12-02 16:29:41 +0000)
>
> are available in the Git repository at:
>
>   git://github.com/bonzini/qemu.git tags/for-upstream
>
> for you to fetch changes up to 64bef038e777208e4c35beae7f980fbd994b87eb:
>
>   hvf: correctly inject VMCS_INTR_T_HWINTR versus VMCS_INTR_T_SWINTR. (2019-12-03 09:11:42 +0100)
>
> ----------------------------------------------------------------
> * last HVF fix (Cameron)
>
> ----------------------------------------------------------------
> Cameron Esfahani (1):
>       hvf: correctly inject VMCS_INTR_T_HWINTR versus VMCS_INTR_T_SWINTR.
>
>  target/i386/hvf/hvf.c    |  4 +++-
>  target/i386/hvf/x86hvf.c | 14 +++++++++-----
>  2 files changed, 12 insertions(+), 6 deletions(-)


Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/4.2
for any user-visible changes.

-- PMM


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-03  8:12 [PULL 0/1] HVF fix QEMU 4.2-rc Paolo Bonzini
2019-12-03  8:12 ` [PULL 1/1] hvf: correctly inject VMCS_INTR_T_HWINTR versus VMCS_INTR_T_SWINTR Paolo Bonzini
2019-12-03 11:03 ` [PULL 0/1] HVF fix QEMU 4.2-rc Peter Maydell

QEMU-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/qemu-devel/0 qemu-devel/git/0.git
	git clone --mirror https://lore.kernel.org/qemu-devel/1 qemu-devel/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 qemu-devel qemu-devel/ https://lore.kernel.org/qemu-devel \
		qemu-devel@nongnu.org
	public-inbox-index qemu-devel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.nongnu.qemu-devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git