diff mbox

[2/2,V3] KVM: x86: Emulator should set DR6 upon GD like real CPU

Message ID 1487080250-29257-3-git-send-email-tim.gardner@canonical.com
State New
Headers show

Commit Message

Tim Gardner Feb. 14, 2017, 1:50 p.m. UTC
From: Nadav Amit <namit@cs.technion.ac.il>

BugLink: http://bugs.launchpad.net/bugs/1660519

It should clear B0-B3 and set BD.

Signed-off-by: Nadav Amit <namit@cs.technion.ac.il>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(back ported from commit 6d2a0526b09e551d0f395cfb63e7cb965db825af)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
---

v2 - fixed commit log to indicate clean cherry-pick
v3 - dropped the use of DR6_RTM which had only one
use and no definition.

 arch/x86/kvm/emulate.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

Stefan Bader Feb. 14, 2017, 2:16 p.m. UTC | #1
On 14.02.2017 14:50, Tim Gardner wrote:
> From: Nadav Amit <namit@cs.technion.ac.il>
> 
> BugLink: http://bugs.launchpad.net/bugs/1660519
> 
> It should clear B0-B3 and set BD.
> 
> Signed-off-by: Nadav Amit <namit@cs.technion.ac.il>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> (back ported from commit 6d2a0526b09e551d0f395cfb63e7cb965db825af)
> Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
> ---
> 
> v2 - fixed commit log to indicate clean cherry-pick
> v3 - dropped the use of DR6_RTM which had only one
> use and no definition.
> 
>  arch/x86/kvm/emulate.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
> index f8eea19..23717df 100644
> --- a/arch/x86/kvm/emulate.c
> +++ b/arch/x86/kvm/emulate.c
> @@ -3533,8 +3533,15 @@ static int check_dr_read(struct x86_emulate_ctxt *ctxt)
>  	if ((cr4 & X86_CR4_DE) && (dr == 4 || dr == 5))
>  		return emulate_ud(ctxt);
>  
> -	if (check_dr7_gd(ctxt))
> +	if (check_dr7_gd(ctxt)) {
> +		ulong dr6;
> +
> +		ctxt->ops->get_dr(ctxt, 6, &dr6);
> +		dr6 &= ~15;
> +		dr6 |= DR6_BD;

This now sets only bit 13 and not bit 16 ... (it was defined in the original
patch by picking the definition from another patch).


> +		ctxt->ops->set_dr(ctxt, 6, dr6);
>  		return emulate_db(ctxt);
> +	}
>  
>  	return X86EMUL_CONTINUE;
>  }
>
Stefan Bader Feb. 14, 2017, 2:34 p.m. UTC | #2
On 14.02.2017 15:16, Stefan Bader wrote:
> On 14.02.2017 14:50, Tim Gardner wrote:
>> From: Nadav Amit <namit@cs.technion.ac.il>
>>
>> BugLink: http://bugs.launchpad.net/bugs/1660519
>>
>> It should clear B0-B3 and set BD.
>>
>> Signed-off-by: Nadav Amit <namit@cs.technion.ac.il>
>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>> (back ported from commit 6d2a0526b09e551d0f395cfb63e7cb965db825af)
>> Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
>> ---
>>
>> v2 - fixed commit log to indicate clean cherry-pick
>> v3 - dropped the use of DR6_RTM which had only one
>> use and no definition.
>>
>>  arch/x86/kvm/emulate.c | 9 ++++++++-
>>  1 file changed, 8 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
>> index f8eea19..23717df 100644
>> --- a/arch/x86/kvm/emulate.c
>> +++ b/arch/x86/kvm/emulate.c
>> @@ -3533,8 +3533,15 @@ static int check_dr_read(struct x86_emulate_ctxt *ctxt)
>>  	if ((cr4 & X86_CR4_DE) && (dr == 4 || dr == 5))
>>  		return emulate_ud(ctxt);
>>  
>> -	if (check_dr7_gd(ctxt))
>> +	if (check_dr7_gd(ctxt)) {
>> +		ulong dr6;
>> +
>> +		ctxt->ops->get_dr(ctxt, 6, &dr6);
>> +		dr6 &= ~15;
>> +		dr6 |= DR6_BD;
> 
> This now sets only bit 13 and not bit 16 ... (it was defined in the original
> patch by picking the definition from another patch).

After discussing this, its probably correct to drop the flag as the support for
it was added by the change not taken due to too many dependencies.
But should have an eye on testing really being done on that one.

-Stefan

> 
> 
>> +		ctxt->ops->set_dr(ctxt, 6, dr6);
>>  		return emulate_db(ctxt);
>> +	}
>>  
>>  	return X86EMUL_CONTINUE;
>>  }
>>
> 
> 
> 
>
diff mbox

Patch

diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index f8eea19..23717df 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -3533,8 +3533,15 @@  static int check_dr_read(struct x86_emulate_ctxt *ctxt)
 	if ((cr4 & X86_CR4_DE) && (dr == 4 || dr == 5))
 		return emulate_ud(ctxt);
 
-	if (check_dr7_gd(ctxt))
+	if (check_dr7_gd(ctxt)) {
+		ulong dr6;
+
+		ctxt->ops->get_dr(ctxt, 6, &dr6);
+		dr6 &= ~15;
+		dr6 |= DR6_BD;
+		ctxt->ops->set_dr(ctxt, 6, dr6);
 		return emulate_db(ctxt);
+	}
 
 	return X86EMUL_CONTINUE;
 }