From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [kvm-unit-tests PATCH 4/4] arm/arm64: make stack creation user friendly Date: Tue, 19 Jan 2016 15:29:56 +0100 Message-ID: <569E4864.3090000@redhat.com> References: <1452879690-14493-1-git-send-email-drjones@redhat.com> <1452879690-14493-5-git-send-email-drjones@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit To: Andrew Jones , kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:47773 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753920AbcASO37 (ORCPT ); Tue, 19 Jan 2016 09:29:59 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 4F92BBBF6A for ; Tue, 19 Jan 2016 14:29:59 +0000 (UTC) In-Reply-To: <1452879690-14493-5-git-send-email-drjones@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Changing subject to: "arm/arm64: wrap thread stack creation in a function that returns SP". Paolo On 15/01/2016 18:41, Andrew Jones wrote: > Signed-off-by: Andrew Jones > --- > arm/selftest.c | 3 +-- > lib/arm/asm/thread_info.h | 7 +++++++ > lib/arm/smp.c | 4 +--- > 3 files changed, 9 insertions(+), 5 deletions(-) > > diff --git a/arm/selftest.c b/arm/selftest.c > index 3e13296410fc1..aad7eecd529ad 100644 > --- a/arm/selftest.c > +++ b/arm/selftest.c > @@ -356,9 +356,8 @@ int main(int argc, char **argv) > > } else if (strcmp(argv[0], "vectors-user") == 0) { > > - void *sp = memalign(THREAD_SIZE, THREAD_SIZE); > start_usr(check_vectors, NULL, > - (unsigned long)sp + THREAD_START_SP); > + (unsigned long)thread_stack_alloc()); > > } else if (strcmp(argv[0], "smp") == 0) { > > diff --git a/lib/arm/asm/thread_info.h b/lib/arm/asm/thread_info.h > index 95058bff9d857..7eaac7c32953b 100644 > --- a/lib/arm/asm/thread_info.h > +++ b/lib/arm/asm/thread_info.h > @@ -22,6 +22,7 @@ > > #ifndef __ASSEMBLY__ > #include > +#include > > #ifdef __arm__ > #include > @@ -35,6 +36,12 @@ > #define THREAD_START_SP (THREAD_SIZE - 16) > #endif > > +static inline void *thread_stack_alloc(void) > +{ > + void *sp = memalign(THREAD_SIZE, THREAD_SIZE); > + return sp + THREAD_START_SP; > +} > + > #define TIF_USER_MODE (1U << 0) > > struct thread_info { > diff --git a/lib/arm/smp.c b/lib/arm/smp.c > index 390c53b5d84c3..bbaf9e60e9506 100644 > --- a/lib/arm/smp.c > +++ b/lib/arm/smp.c > @@ -6,7 +6,6 @@ > * This work is licensed under the terms of the GNU LGPL, version 2. > */ > #include > -#include > #include > #include > #include > @@ -43,10 +42,9 @@ secondary_entry_fn secondary_cinit(void) > > void smp_boot_secondary(int cpu, secondary_entry_fn entry) > { > - void *stack_base = memalign(THREAD_SIZE, THREAD_SIZE); > int ret; > > - secondary_data.stack = stack_base + THREAD_START_SP; > + secondary_data.stack = thread_stack_alloc(); > secondary_data.entry = entry; > mmu_mark_disabled(cpu); > ret = cpu_psci_cpu_boot(cpu); >