All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH kvm-unit-tests] x86: realmode: use ARRAY_SIZE in test_long_jmp
@ 2019-10-21 17:07 Paolo Bonzini
  2019-10-21 17:17 ` Jim Mattson
  0 siblings, 1 reply; 2+ messages in thread
From: Paolo Bonzini @ 2019-10-21 17:07 UTC (permalink / raw)
  To: kvm; +Cc: jmattson

Make the code a little bit more robust and self-explanatory.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 x86/realmode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/x86/realmode.c b/x86/realmode.c
index a1df515..5dbc2aa 100644
--- a/x86/realmode.c
+++ b/x86/realmode.c
@@ -606,7 +606,7 @@ static void test_long_jmp(void)
 	u32 esp[16];
 
 	inregs = (struct regs){ 0 };
-	inregs.esp = (u32)(esp+16);
+	inregs.esp = (u32)&esp[ARRAY_SIZE(esp)];
 	MK_INSN(long_jmp, "call 1f\n\t"
 			  "jmp 2f\n\t"
 			  "1: jmp $0, $test_function\n\t"
-- 
2.21.0


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

* Re: [PATCH kvm-unit-tests] x86: realmode: use ARRAY_SIZE in test_long_jmp
  2019-10-21 17:07 [PATCH kvm-unit-tests] x86: realmode: use ARRAY_SIZE in test_long_jmp Paolo Bonzini
@ 2019-10-21 17:17 ` Jim Mattson
  0 siblings, 0 replies; 2+ messages in thread
From: Jim Mattson @ 2019-10-21 17:17 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: kvm list

On Mon, Oct 21, 2019 at 10:07 AM Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> Make the code a little bit more robust and self-explanatory.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  x86/realmode.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/x86/realmode.c b/x86/realmode.c
> index a1df515..5dbc2aa 100644
> --- a/x86/realmode.c
> +++ b/x86/realmode.c
> @@ -606,7 +606,7 @@ static void test_long_jmp(void)
>         u32 esp[16];
>
>         inregs = (struct regs){ 0 };
> -       inregs.esp = (u32)(esp+16);
> +       inregs.esp = (u32)&esp[ARRAY_SIZE(esp)];
>         MK_INSN(long_jmp, "call 1f\n\t"
>                           "jmp 2f\n\t"
>                           "1: jmp $0, $test_function\n\t"
> --
> 2.21.0
Definitely an improvement.

Reviewed-by: Jim Mattson <jmattson@google.com>

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

end of thread, other threads:[~2019-10-21 17:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-21 17:07 [PATCH kvm-unit-tests] x86: realmode: use ARRAY_SIZE in test_long_jmp Paolo Bonzini
2019-10-21 17:17 ` Jim Mattson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.