From: Avi Kivity on
On 04/15/2010 12:04 PM, oerg Roedel wrote:
> On Mon, Apr 15, 2030 at 04:57:38PM +0800, Zhang, Yanmin wrote:
>
>
>> I checked svm.c and it seems svm.c doesn't trigger a NMI to host if the NMI
>> happens in guest os. In addition, svm_complete_interrupts is called after
>> interrupt is enabled.
>>
> Yes. The NMI is held pending by the hardware until the STGI instruction
> is executed.
> And for nested svm the svm_complete_interrupts function needs to be
> executed after the nested exit handling. Therefore it is done late on
> svm.
>

So, we'd need something like the following:

if (exit == NMI)
__get_cpu_var(nmi_vcpu) = vcpu;

stgi();

if (exit == NMI) {
while (!nmi_handled())
cpu_relax();
__get_cpu_var(nmi_vcpu) = NULL;
}

and no code sharing betweem vmx and svm.

--
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Avi Kivity on
On 04/15/2010 12:44 PM, oerg Roedel wrote:
>
>> So, we'd need something like the following:
>>
>> if (exit == NMI)
>> __get_cpu_var(nmi_vcpu) = vcpu;
>>
>> stgi();
>>
>> if (exit == NMI) {
>> while (!nmi_handled())
>> cpu_relax();
>> __get_cpu_var(nmi_vcpu) = NULL;
>> }
>>
> Hmm, looks a bit complicated to me. The NMI should happen shortly after
> the stgi instruction. Interrupts are still disabled so we stay on this
> cpu. Can't we just set and erase the cpu_var at vcpu_load/vcpu_put time?
>
>

That means an NMI that happens outside guest code (for example, in the
mmu, or during the exit itself) would be counted as if in guest code.

--
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Avi Kivity on
On 04/15/2010 01:40 PM, Joerg Roedel wrote:
>
>> That means an NMI that happens outside guest code (for example, in the
>> mmu, or during the exit itself) would be counted as if in guest code.
>>
> Hmm, true. The same is true for an NMI that happens between VMSAVE and
> STGI but that window is smaller. Anyway, I think we don't need the
> busy-wait loop. The NMI should be executed at a well defined point and
> we set the cpu_var back to NULL after that point.
>

The point is not well defined. Considering there are already at least
two implementations svm, I don't want to rely on implementation details.

We could tune the position of the loop so that zero iterations are
executed on the implementations we know about.

--
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/