Avi Kivity wrote on 2013-02-20:
> On Wed, Feb 20, 2013 at 4:46 AM, Zhang, Yang Z <[email protected]>
> wrote:
>>>>
>>>> +static void vmx_handle_external_intr(struct kvm_vcpu *vcpu) +{ +
>>>> u32 exit_intr_info = vmcs_read32(VM_EXIT_INTR_INFO); + + /* +
>>>> * If external interrupt exists, IF bit is set in rflags/eflags on
>>>> the + * interrupt stack frame, and interrupt will be enabled on
>>>> a return + * from interrupt handler. + */ + if
>>>> ((exit_intr_info & (INTR_INFO_VALID_MASK |
> INTR_INFO_INTR_TYPE_MASK)) +
>>>> == (INTR_INFO_VALID_MASK |
> INTR_TYPE_EXT_INTR)) {
>>>> + unsigned int vector; + unsigned long
>>>> entry; + gate_desc *desc; + struct
>>>> vcpu_vmx *vmx = to_vmx(vcpu); + + vector =
>>>> exit_intr_info & INTR_INFO_VECTOR_MASK; +#ifdef CONFIG_X86_64 + desc
>>>> = (void *)vmx->host_idt_base + vector * 16; +#else +
>>>> desc = (void *)vmx->host_idt_base + vector * 8; +#endif + + entry =
>>>> gate_offset(*desc); + asm( +
>>>> "mov %0, %%" _ASM_DX " \n\t" +#ifdef CONFIG_X86_64 +
>>>> "mov %%" _ASM_SP ", %%" _ASM_BX " \n\t" +
>>>> "and $0xfffffffffffffff0, %%" _ASM_SP " \n\t" +
>>>> "mov %%ss, %%" _ASM_AX " \n\t" + "push %%"
>>>> _ASM_AX " \n\t" + "push %%" _ASM_BX " \n\t"
>>>> +#endif
>>>
>>> Are we sure no interrupts are using the IST feature? I guess it's unlikely.
>> Linux uses IST for NMI, stack fault, machine-check, double fault and
>> debug interrupt . No external interrupt will use it. This feature is
>> only for external interrupt. So we don't need to check it here.
>
> Ok, thanks for checking.
>
>>
>>>
>>>> + "pushf \n\t"
>>>> + "pop %%" _ASM_AX " \n\t"
>>>> + "or $0x200, %%" _ASM_AX " \n\t"
>>>> + "push %%" _ASM_AX " \n\t"
>>>
>>> Can simplify to pushf; orl $0x200, %%rsp.
>> Sure.
>>
>>>> + "mov %%cs, %%" _ASM_AX " \n\t"
>>>> + "push %%" _ASM_AX " \n\t"
>>>
>>> push %%cs
>> "push %%cs" is invalid in x86_64.
>
> Oops. 'push[lq] $__KERNEL_CS' then.
Is this right? Just copy it from other file.
#define __STR(X) #X
#define STR(X) __STR(X)
#ifdef CONFIG_X86_64
"pushq $"STR(__KERNEL_CS)" \n\t"
#else
"pushl $"STR(__KERNEL_CS)" \n\t"
#endif
#undef STR
#undef __STR
>>
>>>> + "push intr_return \n\t"
>>>
>>> push $1f. Or even combine with the next instruction, and call %rdx.
>> Which is faster? jmp or call?
>
> Actually it doesn't matter, the processor is clever enough to minimize
> the difference. But the code is simpler and shorter with 'call'. -- To
Yes, 'call' is better.
Best regards,
Yang
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html