diff mbox

KVM: SVM: Fix CPL export via SS.DPL

Message ID 53B02CEB.7010607@web.de (mailing list archive)
State New, archived
Headers show

Commit Message

Jan Kiszka June 29, 2014, 3:12 p.m. UTC
From: Jan Kiszka <jan.kiszka@siemens.com>

We import the CPL via SS.DPL since ae9fedc793. However, we fail to
export it this way so far. This caused spurious guest crashes, e.g. of
Linux when accessing the vmport from guest user space which triggered
register saving/restoring to/from host user space.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---

Just in time for the next match :D

 arch/x86/kvm/svm.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Borislav Petkov June 29, 2014, 6 p.m. UTC | #1
On Sun, Jun 29, 2014 at 05:12:43PM +0200, Jan Kiszka wrote:
> From: Jan Kiszka <jan.kiszka@siemens.com>
> 
> We import the CPL via SS.DPL since ae9fedc793. However, we fail to
> export it this way so far. This caused spurious guest crashes, e.g. of
> Linux when accessing the vmport from guest user space which triggered
> register saving/restoring to/from host user space.
> 
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>

Yep, looks good.

Tested-by: Borislav Petkov <bp@suse.de>
Paolo Bonzini June 30, 2014, 3:01 p.m. UTC | #2
Il 29/06/2014 17:12, Jan Kiszka ha scritto:
> From: Jan Kiszka <jan.kiszka@siemens.com>
>
> We import the CPL via SS.DPL since ae9fedc793. However, we fail to
> export it this way so far. This caused spurious guest crashes, e.g. of
> Linux when accessing the vmport from guest user space which triggered
> register saving/restoring to/from host user space.
>
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>
> Just in time for the next match :D
>
>  arch/x86/kvm/svm.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
> index ec8366c..b5e994a 100644
> --- a/arch/x86/kvm/svm.c
> +++ b/arch/x86/kvm/svm.c
> @@ -1462,6 +1462,7 @@ static void svm_get_segment(struct kvm_vcpu *vcpu,
>  		 */
>  		if (var->unusable)
>  			var->db = 0;
> +		var->dpl = to_svm(vcpu)->vmcb->save.cpl;
>  		break;
>  	}
>  }
>

Thanks.  In theory this is not necessary, the SS.DPL should be the same 
as the CPL according to the manuals (the manual say that the SS.DPL 
"should match" the CPL, and that's the only reason why I included the 
import in ae9fedc793).  But apparently this is not the case.

Paolo
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jan Kiszka June 30, 2014, 3:03 p.m. UTC | #3
On 2014-06-30 17:01, Paolo Bonzini wrote:
> Il 29/06/2014 17:12, Jan Kiszka ha scritto:
>> From: Jan Kiszka <jan.kiszka@siemens.com>
>>
>> We import the CPL via SS.DPL since ae9fedc793. However, we fail to
>> export it this way so far. This caused spurious guest crashes, e.g. of
>> Linux when accessing the vmport from guest user space which triggered
>> register saving/restoring to/from host user space.
>>
>> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
>> ---
>>
>> Just in time for the next match :D
>>
>>  arch/x86/kvm/svm.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
>> index ec8366c..b5e994a 100644
>> --- a/arch/x86/kvm/svm.c
>> +++ b/arch/x86/kvm/svm.c
>> @@ -1462,6 +1462,7 @@ static void svm_get_segment(struct kvm_vcpu *vcpu,
>>           */
>>          if (var->unusable)
>>              var->db = 0;
>> +        var->dpl = to_svm(vcpu)->vmcb->save.cpl;
>>          break;
>>      }
>>  }
>>
> 
> Thanks.  In theory this is not necessary, the SS.DPL should be the same
> as the CPL according to the manuals (the manual say that the SS.DPL
> "should match" the CPL, and that's the only reason why I included the
> import in ae9fedc793).  But apparently this is not the case.

15.5.1:

"When examining segment attributes after a #VMEXIT:
[...]
• Retrieve the CPL from the CPL field in the VMCB, not from any segment
DPL."

Jan
Borislav Petkov June 30, 2014, 3:15 p.m. UTC | #4
On Mon, Jun 30, 2014 at 05:03:57PM +0200, Jan Kiszka wrote:
> 15.5.1:
> 
> "When examining segment attributes after a #VMEXIT:
> [...]
> • Retrieve the CPL from the CPL field in the VMCB, not from any segment
> DPL."

Heey, it is even documented! :-P
Gleb Natapov June 30, 2014, 3:25 p.m. UTC | #5
On Mon, Jun 30, 2014 at 05:15:44PM +0200, Borislav Petkov wrote:
> On Mon, Jun 30, 2014 at 05:03:57PM +0200, Jan Kiszka wrote:
> > 15.5.1:
> > 
> > "When examining segment attributes after a #VMEXIT:
> > [...]
> > • Retrieve the CPL from the CPL field in the VMCB, not from any segment
> > DPL."
> 
> Heey, it is even documented! :-P
> 
Yes, on SVM we should always respect this field. Unfortunately there
is no such field in VMX, so we have to do DPL gymnastics there.

--
			Gleb.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Paolo Bonzini June 30, 2014, 3:26 p.m. UTC | #6
Il 30/06/2014 17:03, Jan Kiszka ha scritto:
> 15.5.1:
>
> "When examining segment attributes after a #VMEXIT:
> [...]
> • Retrieve the CPL from the CPL field in the VMCB, not from any segment
> DPL."

It's only the fourth paragraph below the one I did read...

Paolo
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index ec8366c..b5e994a 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -1462,6 +1462,7 @@  static void svm_get_segment(struct kvm_vcpu *vcpu,
 		 */
 		if (var->unusable)
 			var->db = 0;
+		var->dpl = to_svm(vcpu)->vmcb->save.cpl;
 		break;
 	}
 }