Re: [PATCH 1/3] KVM: x86 emulator: Fix task switch privilege checks

2012-01-27 Thread Kevin Wolf
Am 25.01.2012 17:00, schrieb Joerg Roedel: On Tue, Jan 24, 2012 at 06:23:50PM +0200, Gleb Natapov wrote: On Tue, Jan 24, 2012 at 03:24:50PM +0100, Kevin Wolf wrote: However, task_switch_interception() itself does some more based on the value of reason, for example it decides whether or not

Re: [PATCH 1/3] KVM: x86 emulator: Fix task switch privilege checks

2012-01-27 Thread Joerg Roedel
On Fri, Jan 27, 2012 at 01:58:38PM +0100, Kevin Wolf wrote: Am 25.01.2012 17:00, schrieb Joerg Roedel: I just retried. I use kvm-kmod and kvm.git with HEAD at ff92e9b5 plus the tree patches of this series plus a printk to output exit_int_info in task_switch_intercept(). I ran taskswitch2 from

Re: [PATCH 1/3] KVM: x86 emulator: Fix task switch privilege checks

2012-01-27 Thread Kevin Wolf
Am 27.01.2012 14:34, schrieb Joerg Roedel: On Fri, Jan 27, 2012 at 01:58:38PM +0100, Kevin Wolf wrote: Am 25.01.2012 17:00, schrieb Joerg Roedel: I just retried. I use kvm-kmod and kvm.git with HEAD at ff92e9b5 plus the tree patches of this series plus a printk to output exit_int_info in

Re: [PATCH 1/3] KVM: x86 emulator: Fix task switch privilege checks

2012-01-27 Thread Joerg Roedel
On Fri, Jan 27, 2012 at 02:55:12PM +0100, Kevin Wolf wrote: Am 27.01.2012 14:34, schrieb Joerg Roedel: On Fri, Jan 27, 2012 at 01:58:38PM +0100, Kevin Wolf wrote: Am 25.01.2012 17:00, schrieb Joerg Roedel: I just retried. I use kvm-kmod and kvm.git with HEAD at ff92e9b5 plus the tree

Re: [PATCH 1/3] KVM: x86 emulator: Fix task switch privilege checks

2012-01-27 Thread Kevin Wolf
Am 27.01.2012 15:17, schrieb Joerg Roedel: On Fri, Jan 27, 2012 at 02:55:12PM +0100, Kevin Wolf wrote: Am 27.01.2012 14:34, schrieb Joerg Roedel: On Fri, Jan 27, 2012 at 01:58:38PM +0100, Kevin Wolf wrote: Am 25.01.2012 17:00, schrieb Joerg Roedel: I just retried. I use kvm-kmod and kvm.git

Re: [PATCH 1/3] KVM: x86 emulator: Fix task switch privilege checks

2012-01-27 Thread Gleb Natapov
On Fri, Jan 27, 2012 at 04:02:30PM +0100, Kevin Wolf wrote: Am 27.01.2012 15:17, schrieb Joerg Roedel: On Fri, Jan 27, 2012 at 02:55:12PM +0100, Kevin Wolf wrote: Am 27.01.2012 14:34, schrieb Joerg Roedel: On Fri, Jan 27, 2012 at 01:58:38PM +0100, Kevin Wolf wrote: Am 25.01.2012 17:00,

Re: [PATCH 1/3] KVM: x86 emulator: Fix task switch privilege checks

2012-01-25 Thread Joerg Roedel
On Tue, Jan 24, 2012 at 06:23:50PM +0200, Gleb Natapov wrote: On Tue, Jan 24, 2012 at 03:24:50PM +0100, Kevin Wolf wrote: However, task_switch_interception() itself does some more based on the value of reason, for example it decides whether or not to call skip_emulated_instruction().

Re: [PATCH 1/3] KVM: x86 emulator: Fix task switch privilege checks

2012-01-25 Thread Gleb Natapov
On Wed, Jan 25, 2012 at 05:00:58PM +0100, Joerg Roedel wrote: On Tue, Jan 24, 2012 at 06:23:50PM +0200, Gleb Natapov wrote: On Tue, Jan 24, 2012 at 03:24:50PM +0100, Kevin Wolf wrote: However, task_switch_interception() itself does some more based on the value of reason, for example it

Re: [PATCH 1/3] KVM: x86 emulator: Fix task switch privilege checks

2012-01-24 Thread Gleb Natapov
On Mon, Jan 23, 2012 at 05:10:46PM +0100, Kevin Wolf wrote: Currently, all task switches check privileges against the DPL of the TSS. This is only correct for jmp/call to a TSS. If a task gate is used, the DPL of this take gate is used for the check instead. Exceptions, external interrupts and

Re: [PATCH 1/3] KVM: x86 emulator: Fix task switch privilege checks

2012-01-24 Thread Kevin Wolf
Am 24.01.2012 10:52, schrieb Gleb Natapov: On Mon, Jan 23, 2012 at 05:10:46PM +0100, Kevin Wolf wrote: Currently, all task switches check privileges against the DPL of the TSS. This is only correct for jmp/call to a TSS. If a task gate is used, the DPL of this take gate is used for the check

Re: [PATCH 1/3] KVM: x86 emulator: Fix task switch privilege checks

2012-01-24 Thread Gleb Natapov
On Tue, Jan 24, 2012 at 11:09:09AM +0100, Kevin Wolf wrote: + } else if (reason != TASK_SWITCH_IRET) { + dpl = next_tss_desc.dpl; } No need parentheses around one statement. Documentation/CodingStyle says: This does not apply if only one branch of a conditional statement

Re: [PATCH 1/3] KVM: x86 emulator: Fix task switch privilege checks

2012-01-24 Thread Kevin Wolf
Am 24.01.2012 11:17, schrieb Gleb Natapov: On Tue, Jan 24, 2012 at 11:09:09AM +0100, Kevin Wolf wrote: + } else if (reason != TASK_SWITCH_IRET) { + dpl = next_tss_desc.dpl; } No need parentheses around one statement. Documentation/CodingStyle says: This does not apply if only

Re: [PATCH 1/3] KVM: x86 emulator: Fix task switch privilege checks

2012-01-24 Thread Gleb Natapov
On Tue, Jan 24, 2012 at 11:38:24AM +0100, Kevin Wolf wrote: Am 24.01.2012 11:17, schrieb Gleb Natapov: On Tue, Jan 24, 2012 at 11:09:09AM +0100, Kevin Wolf wrote: +} else if (reason != TASK_SWITCH_IRET) { +dpl = next_tss_desc.dpl; } No need parentheses

Re: [PATCH 1/3] KVM: x86 emulator: Fix task switch privilege checks

2012-01-24 Thread Kevin Wolf
Am 24.01.2012 11:52, schrieb Gleb Natapov: On Tue, Jan 24, 2012 at 11:38:24AM +0100, Kevin Wolf wrote: Am 24.01.2012 11:17, schrieb Gleb Natapov: On Tue, Jan 24, 2012 at 11:09:09AM +0100, Kevin Wolf wrote: +} else if (reason != TASK_SWITCH_IRET) { +dpl =

Re: [PATCH 1/3] KVM: x86 emulator: Fix task switch privilege checks

2012-01-24 Thread Gleb Natapov
On Tue, Jan 24, 2012 at 12:23:07PM +0100, Kevin Wolf wrote: Am 24.01.2012 11:52, schrieb Gleb Natapov: On Tue, Jan 24, 2012 at 11:38:24AM +0100, Kevin Wolf wrote: Am 24.01.2012 11:17, schrieb Gleb Natapov: On Tue, Jan 24, 2012 at 11:09:09AM +0100, Kevin Wolf wrote: + } else if

Re: [PATCH 1/3] KVM: x86 emulator: Fix task switch privilege checks

2012-01-24 Thread Joerg Roedel
On Mon, Jan 23, 2012 at 05:10:46PM +0100, Kevin Wolf wrote: This patch fixes the problem for VMX. For SVM, the logic used to determine the source of the task switch is buggy, so we can't pass useful information to the emulator there and just disable the check in all cases. Actually, SVM isn't

Re: [PATCH 1/3] KVM: x86 emulator: Fix task switch privilege checks

2012-01-24 Thread Kevin Wolf
Am 24.01.2012 15:03, schrieb Joerg Roedel: On Mon, Jan 23, 2012 at 05:10:46PM +0100, Kevin Wolf wrote: This patch fixes the problem for VMX. For SVM, the logic used to determine the source of the task switch is buggy, so we can't pass useful information to the emulator there and just disable

Re: [PATCH 1/3] KVM: x86 emulator: Fix task switch privilege checks

2012-01-24 Thread Gleb Natapov
On Tue, Jan 24, 2012 at 03:15:13PM +0100, Kevin Wolf wrote: Am 24.01.2012 15:03, schrieb Joerg Roedel: On Mon, Jan 23, 2012 at 05:10:46PM +0100, Kevin Wolf wrote: This patch fixes the problem for VMX. For SVM, the logic used to determine the source of the task switch is buggy, so we can't

Re: [PATCH 1/3] KVM: x86 emulator: Fix task switch privilege checks

2012-01-24 Thread Kevin Wolf
Am 24.01.2012 15:16, schrieb Gleb Natapov: On Tue, Jan 24, 2012 at 03:15:13PM +0100, Kevin Wolf wrote: Am 24.01.2012 15:03, schrieb Joerg Roedel: On Mon, Jan 23, 2012 at 05:10:46PM +0100, Kevin Wolf wrote: This patch fixes the problem for VMX. For SVM, the logic used to determine the source

Re: [PATCH 1/3] KVM: x86 emulator: Fix task switch privilege checks

2012-01-24 Thread Gleb Natapov
On Tue, Jan 24, 2012 at 03:24:50PM +0100, Kevin Wolf wrote: Am 24.01.2012 15:16, schrieb Gleb Natapov: On Tue, Jan 24, 2012 at 03:15:13PM +0100, Kevin Wolf wrote: Am 24.01.2012 15:03, schrieb Joerg Roedel: On Mon, Jan 23, 2012 at 05:10:46PM +0100, Kevin Wolf wrote: This patch fixes the

[PATCH 1/3] KVM: x86 emulator: Fix task switch privilege checks

2012-01-23 Thread Kevin Wolf
Currently, all task switches check privileges against the DPL of the TSS. This is only correct for jmp/call to a TSS. If a task gate is used, the DPL of this take gate is used for the check instead. Exceptions, external interrupts and iret shouldn't perform any check. This patch fixes the problem