From: Paolo Bonzini <pbonzini@redhat.com>
To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: Cathy Avery <cavery@redhat.com>,
Liran Alon <liran.alon@oracle.com>,
Jim Mattson <jmattson@google.com>
Subject: [PATCH 5/7] KVM: nSVM: remove HF_VINTR_MASK
Date: Fri, 15 May 2020 13:41:42 -0400 [thread overview]
Message-ID: <20200515174144.1727-6-pbonzini@redhat.com> (raw)
In-Reply-To: <20200515174144.1727-1-pbonzini@redhat.com>
Now that the int_ctl field is stored in svm->nested.int_ctl, we can
use it instead of vcpu->arch.hflags.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
arch/x86/include/asm/kvm_host.h | 1 -
arch/x86/kvm/svm/nested.c | 12 ++++--------
arch/x86/kvm/svm/svm.c | 2 +-
arch/x86/kvm/svm/svm.h | 4 +++-
4 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index fd78bd44b2d6..6c8417d01bf9 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -1594,7 +1594,6 @@ enum {
#define HF_GIF_MASK (1 << 0)
#define HF_HIF_MASK (1 << 1)
-#define HF_VINTR_MASK (1 << 2)
#define HF_NMI_MASK (1 << 3)
#define HF_IRET_MASK (1 << 4)
#define HF_GUEST_MASK (1 << 5) /* VCPU is in guest-mode */
diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c
index 54be341322d8..e3338aa8b0a3 100644
--- a/arch/x86/kvm/svm/nested.c
+++ b/arch/x86/kvm/svm/nested.c
@@ -116,13 +116,13 @@ void recalc_intercepts(struct vcpu_svm *svm)
c->intercept_exceptions = h->intercept_exceptions;
c->intercept = h->intercept;
- if (svm->vcpu.arch.hflags & HF_VINTR_MASK) {
+ if (svm->nested.int_ctl & V_INTR_MASKING_MASK) {
/* We only want the cr8 intercept bits of L1 */
c->intercept_cr &= ~(1U << INTERCEPT_CR8_READ);
c->intercept_cr &= ~(1U << INTERCEPT_CR8_WRITE);
/*
- * Once running L2 with HF_VINTR_MASK, EFLAGS.IF does not
+ * Once running L2 with V_INTR_MASKING set, EFLAGS.IF does not
* affect any interrupt we may want to inject; therefore,
* interrupt window vmexits are irrelevant to L0.
*/
@@ -297,10 +297,6 @@ static void nested_prepare_vmcb_control(struct vcpu_svm *svm)
kvm_mmu_reset_context(&svm->vcpu);
svm_flush_tlb(&svm->vcpu);
- if (svm->nested.int_ctl & V_INTR_MASKING_MASK)
- svm->vcpu.arch.hflags |= HF_VINTR_MASK;
- else
- svm->vcpu.arch.hflags &= ~HF_VINTR_MASK;
svm->vmcb->control.tsc_offset = svm->vcpu.arch.tsc_offset;
@@ -553,8 +549,8 @@ int nested_svm_vmexit(struct vcpu_svm *svm)
nested_vmcb->control.pause_filter_thresh =
svm->vmcb->control.pause_filter_thresh;
- /* We always set V_INTR_MASKING and remember the old value in hflags */
- if (!(svm->vcpu.arch.hflags & HF_VINTR_MASK))
+ /* We always set V_INTR_MASKING and remember the old value in svm->nested */
+ if (!(svm->nested.int_ctl & V_INTR_MASKING_MASK))
nested_vmcb->control.int_ctl &= ~V_INTR_MASKING_MASK;
/* Restore the original control entries */
diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
index 2b63d15328ba..95d16aa76ebb 100644
--- a/arch/x86/kvm/svm/svm.c
+++ b/arch/x86/kvm/svm/svm.c
@@ -3096,7 +3096,7 @@ bool svm_interrupt_blocked(struct kvm_vcpu *vcpu)
if (is_guest_mode(vcpu)) {
/* As long as interrupts are being delivered... */
- if ((svm->vcpu.arch.hflags & HF_VINTR_MASK)
+ if ((svm->nested.int_ctl & V_INTR_MASKING_MASK)
? !(svm->vcpu.arch.hflags & HF_HIF_MASK)
: !(kvm_get_rflags(vcpu) & X86_EFLAGS_IF))
return true;
diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h
index 5cabed9c733a..39706aa845f2 100644
--- a/arch/x86/kvm/svm/svm.h
+++ b/arch/x86/kvm/svm/svm.h
@@ -388,7 +388,9 @@ bool svm_interrupt_blocked(struct kvm_vcpu *vcpu);
static inline bool svm_nested_virtualize_tpr(struct kvm_vcpu *vcpu)
{
- return is_guest_mode(vcpu) && (vcpu->arch.hflags & HF_VINTR_MASK);
+ struct vcpu_svm *svm = to_svm(vcpu);
+
+ return is_guest_mode(vcpu) && (svm->nested.int_ctl & V_INTR_MASKING_MASK);
}
static inline bool nested_exit_on_smi(struct vcpu_svm *svm)
--
2.18.2
next prev parent reply other threads:[~2020-05-15 17:41 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-15 17:41 [PATCH 0/7] KVM: SVM: baby steps towards nested state migration Paolo Bonzini
2020-05-15 17:41 ` [PATCH 1/7] KVM: SVM: move map argument out of enter_svm_guest_mode Paolo Bonzini
2020-05-15 17:41 ` [PATCH 2/7] KVM: SVM: extract load_nested_vmcb_control Paolo Bonzini
2020-05-15 23:09 ` Krish Sadhukhan
2020-05-15 23:34 ` Paolo Bonzini
2020-05-15 17:41 ` [PATCH 3/7] KVM: SVM: extract preparation of VMCB for nested run Paolo Bonzini
2020-05-15 23:36 ` Paolo Bonzini
2020-05-15 17:41 ` [PATCH 4/7] KVM: SVM: save all control fields in svm->nested Paolo Bonzini
2020-05-15 17:41 ` Paolo Bonzini [this message]
2020-05-15 17:41 ` [PATCH 6/7] KVM: nSVM: do not reload pause filter fields from VMCB Paolo Bonzini
2020-05-15 17:41 ` [PATCH 7/7] KVM: SVM: introduce data structures for nested virt state Paolo Bonzini
2020-05-18 20:07 ` [PATCH 0/7] KVM: SVM: baby steps towards nested state migration Krish Sadhukhan
2020-05-18 20:11 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200515174144.1727-6-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=cavery@redhat.com \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liran.alon@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).