linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selftests: kvm: Fix assert failure in single-step test
@ 2020-08-26  1:55 Yang Weijiang
  2020-09-23 14:24 ` Paolo Bonzini
  0 siblings, 1 reply; 2+ messages in thread
From: Yang Weijiang @ 2020-08-26  1:55 UTC (permalink / raw)
  To: pbonzini, kvm, linux-kernel, sean.j.christopherson; +Cc: Yang Weijiang

This is a follow-up patch to fix an issue left in commit:
98b0bf02738004829d7e26d6cb47b2e469aaba86
selftests: kvm: Use a shorter encoding to clear RAX

With the change in the commit, we also need to modify "xor" instruction
length from 3 to 2 in array ss_size accordingly to pass below check:

for (i = 0; i < (sizeof(ss_size) / sizeof(ss_size[0])); i++) {
        target_rip += ss_size[i];
        CLEAR_DEBUG();
        debug.control = KVM_GUESTDBG_ENABLE | KVM_GUESTDBG_SINGLESTEP;
        debug.arch.debugreg[7] = 0x00000400;
        APPLY_DEBUG();
        vcpu_run(vm, VCPU_ID);
        TEST_ASSERT(run->exit_reason == KVM_EXIT_DEBUG &&
                    run->debug.arch.exception == DB_VECTOR &&
                    run->debug.arch.pc == target_rip &&
                    run->debug.arch.dr6 == target_dr6,
                    "SINGLE_STEP[%d]: exit %d exception %d rip 0x%llx "
                    "(should be 0x%llx) dr6 0x%llx (should be 0x%llx)",
                    i, run->exit_reason, run->debug.arch.exception,
                    run->debug.arch.pc, target_rip, run->debug.arch.dr6,
                    target_dr6);
}

Reported-by: kernel test robot <rong.a.chen@intel.com>
Signed-off-by: Yang Weijiang <weijiang.yang@intel.com>
---
 tools/testing/selftests/kvm/x86_64/debug_regs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/kvm/x86_64/debug_regs.c b/tools/testing/selftests/kvm/x86_64/debug_regs.c
index b8d14f9db5f9..2fc6b3af81a1 100644
--- a/tools/testing/selftests/kvm/x86_64/debug_regs.c
+++ b/tools/testing/selftests/kvm/x86_64/debug_regs.c
@@ -73,7 +73,7 @@ int main(void)
 	int i;
 	/* Instruction lengths starting at ss_start */
 	int ss_size[4] = {
-		3,		/* xor */
+		2,		/* xor */
 		2,		/* cpuid */
 		5,		/* mov */
 		2,		/* rdmsr */
-- 
2.17.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] selftests: kvm: Fix assert failure in single-step test
  2020-08-26  1:55 [PATCH] selftests: kvm: Fix assert failure in single-step test Yang Weijiang
@ 2020-09-23 14:24 ` Paolo Bonzini
  0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2020-09-23 14:24 UTC (permalink / raw)
  To: Yang Weijiang, kvm, linux-kernel, sean.j.christopherson

On 26/08/20 03:55, Yang Weijiang wrote:
> This is a follow-up patch to fix an issue left in commit:
> 98b0bf02738004829d7e26d6cb47b2e469aaba86
> selftests: kvm: Use a shorter encoding to clear RAX
> 
> With the change in the commit, we also need to modify "xor" instruction
> length from 3 to 2 in array ss_size accordingly to pass below check:
> 
> for (i = 0; i < (sizeof(ss_size) / sizeof(ss_size[0])); i++) {
>         target_rip += ss_size[i];
>         CLEAR_DEBUG();
>         debug.control = KVM_GUESTDBG_ENABLE | KVM_GUESTDBG_SINGLESTEP;
>         debug.arch.debugreg[7] = 0x00000400;
>         APPLY_DEBUG();
>         vcpu_run(vm, VCPU_ID);
>         TEST_ASSERT(run->exit_reason == KVM_EXIT_DEBUG &&
>                     run->debug.arch.exception == DB_VECTOR &&
>                     run->debug.arch.pc == target_rip &&
>                     run->debug.arch.dr6 == target_dr6,
>                     "SINGLE_STEP[%d]: exit %d exception %d rip 0x%llx "
>                     "(should be 0x%llx) dr6 0x%llx (should be 0x%llx)",
>                     i, run->exit_reason, run->debug.arch.exception,
>                     run->debug.arch.pc, target_rip, run->debug.arch.dr6,
>                     target_dr6);
> }
> 
> Reported-by: kernel test robot <rong.a.chen@intel.com>
> Signed-off-by: Yang Weijiang <weijiang.yang@intel.com>
> ---
>  tools/testing/selftests/kvm/x86_64/debug_regs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/kvm/x86_64/debug_regs.c b/tools/testing/selftests/kvm/x86_64/debug_regs.c
> index b8d14f9db5f9..2fc6b3af81a1 100644
> --- a/tools/testing/selftests/kvm/x86_64/debug_regs.c
> +++ b/tools/testing/selftests/kvm/x86_64/debug_regs.c
> @@ -73,7 +73,7 @@ int main(void)
>  	int i;
>  	/* Instruction lengths starting at ss_start */
>  	int ss_size[4] = {
> -		3,		/* xor */
> +		2,		/* xor */
>  		2,		/* cpuid */
>  		5,		/* mov */
>  		2,		/* rdmsr */
> 

Queued, thanks.

Paolo


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-09-23 14:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-26  1:55 [PATCH] selftests: kvm: Fix assert failure in single-step test Yang Weijiang
2020-09-23 14:24 ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).