From: Jan Kiszka <jan.kiszka@siemens.com>
To: Bernhard Kohl <bernhard.kohl@nsn.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH] KVM: Improvements for task switching
Date: Thu, 12 Mar 2009 19:43:09 +0100 [thread overview]
Message-ID: <49B957BD.7000107@siemens.com> (raw)
In-Reply-To: <loom.20090312T170331-256@post.gmane.org>
Bernhard Kohl wrote:
> NSN's proprietary OS DMX sometimes does task switches.
> To get it running in KVM the following changes were necessary:
> Interrupt injection only with interrupt flag set.
> Linking the tss->prev_task_link to itself removed.
> Task linking is required for CALL and GATE.
> Do not call skip_emulated_instruction() for GATE.
Please post independent changes as separate patches. I guess the task
linking changes belong together, but surely not to the IRQ injection
patch. And the last change looks independent, too.
Another wish (specifically as this is tricky stuff): also describe in
the commit log, why you changed something.
>
> Signed-off-by: Bernhard Kohl <bernhard.kohl@nsn.com>
> ---
> arch/x86/kvm/vmx.c | 3 ++-
> arch/x86/kvm/x86.c | 19 +++++++++++++++++--
> 2 files changed, 19 insertions(+), 3 deletions(-)
>
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index 5cf28df..eca57a3 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -3357,7 +3357,8 @@ static void vmx_intr_assist(struct kvm_vcpu *vcpu)
> enable_irq_window(vcpu);
> }
> if (vcpu->arch.interrupt.pending) {
> - vmx_inject_irq(vcpu, vcpu->arch.interrupt.nr);
> + if (vcpu->arch.interrupt_window_open)
> + vmx_inject_irq(vcpu, vcpu->arch.interrupt.nr);
> if (kvm_cpu_has_interrupt(vcpu))
> enable_irq_window(vcpu);
> }
That causes concerns on my side as we had a hard time stabilizing this
code. Need to think about it. Do you happen to have a test case for this
(if it's not publicly shareable, contact me directly)? Did you check
that this change causes no obvious regressions to other guests? What
about the user-inject IRQ case, does it already work for you as-is?
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index b556b6a..9052058 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -3683,7 +3683,7 @@ static void save_state_to_tss32(struct kvm_vcpu *vcpu,
> tss->fs = get_segment_selector(vcpu, VCPU_SREG_FS);
> tss->gs = get_segment_selector(vcpu, VCPU_SREG_GS);
> tss->ldt_selector = get_segment_selector(vcpu, VCPU_SREG_LDTR);
> - tss->prev_task_link = get_segment_selector(vcpu, VCPU_SREG_TR);
> + tss->prev_task_link = 0;
> }
>
> static int load_state_from_tss32(struct kvm_vcpu *vcpu,
> @@ -3810,6 +3810,7 @@ out:
>
> static int kvm_task_switch_32(struct kvm_vcpu *vcpu, u16 tss_selector,
> u32 old_tss_base,
> + u16 old_tss_selector, int reason,
> struct desc_struct *nseg_desc)
> {
> struct tss_segment_32 tss_segment_32;
What about 16-bit switches, are they already correct?
> @@ -3829,6 +3830,18 @@ static int kvm_task_switch_32(struct kvm_vcpu *vcpu, u16
> tss_selector,
> &tss_segment_32, sizeof tss_segment_32))
> goto out;
>
> + /*
> + * SDM 3: table 6-2
> + * Task linking required for CALL and GATE.
> + */
> + if (reason == TASK_SWITCH_CALL || reason == TASK_SWITCH_GATE)
> + {
> + tss_segment_32.prev_task_link = old_tss_selector;
> + kvm_write_guest(vcpu->kvm, get_tss_base_addr(vcpu, nseg_desc),
> + &tss_segment_32, sizeof(struct tss_segment_32));
> +
> + }
> +
> if (load_state_from_tss32(vcpu, &tss_segment_32))
> goto out;
>
> @@ -3882,10 +3895,12 @@ int kvm_task_switch(struct kvm_vcpu *vcpu, u16
> tss_selector, int reason)
> kvm_x86_ops->set_rflags(vcpu, eflags & ~X86_EFLAGS_NT);
> }
>
> - kvm_x86_ops->skip_emulated_instruction(vcpu);
> + if (reason != TASK_SWITCH_GATE)
> + kvm_x86_ops->skip_emulated_instruction(vcpu);
>
> if (nseg_desc.type & 8)
> ret = kvm_task_switch_32(vcpu, tss_selector, old_tss_base,
> + old_tss_sel, reason,
> &nseg_desc);
> else
> ret = kvm_task_switch_16(vcpu, tss_selector, old_tss_base,
Jan
--
Siemens AG, Corporate Technology, CT SE 2
Corporate Competence Center Embedded Linux
next prev parent reply other threads:[~2009-03-12 18:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-12 17:06 [PATCH] KVM: Improvements for task switching Bernhard Kohl
2009-03-12 18:43 ` Jan Kiszka [this message]
2009-03-12 19:12 ` Jan Kiszka
2009-03-13 14:17 ` Bernhard Kohl
2009-03-13 15:17 ` Jan Kiszka
2009-03-13 15:55 ` Kohl, Bernhard (NSN - DE/Munich)
2009-03-13 15:58 ` Jan Kiszka
2009-03-23 18:15 ` Julian Stecklina
2009-04-12 17:31 ` Julian Stecklina
2009-03-18 0:38 ` Andi Kleen
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=49B957BD.7000107@siemens.com \
--to=jan.kiszka@siemens.com \
--cc=bernhard.kohl@nsn.com \
--cc=kvm@vger.kernel.org \
/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