From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Jones Subject: [PATCH kvm-unit-tests 12/15] powerpc: enable environ Date: Fri, 13 Jan 2017 19:15:30 +0100 Message-ID: <20170113181533.15145-13-drjones@redhat.com> References: <20170113181533.15145-1-drjones@redhat.com> Cc: rkrcmar@redhat.com, pbonzini@redhat.com, lvivier@redhat.com, thuth@redhat.com To: kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:55694 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751159AbdAMSPz (ORCPT ); Fri, 13 Jan 2017 13:15:55 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3018D80F6D for ; Fri, 13 Jan 2017 18:15:56 +0000 (UTC) In-Reply-To: <20170113181533.15145-1-drjones@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Give powerpc unit tests access to environment variables. The environment variables are passed to the unit test with '-initrd env-file'. Signed-off-by: Andrew Jones --- powerpc/run | 1 + lib/powerpc/setup.c | 8 ++++++++ powerpc/cstart64.S | 5 +++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/powerpc/run b/powerpc/run index afdd487bfc35..6269abb9fe7f 100755 --- a/powerpc/run +++ b/powerpc/run @@ -44,6 +44,7 @@ fi M='-machine pseries' M+=",accel=$ACCEL" command="$qemu -nodefaults $M -bios $FIRMWARE" +[ -f "$ENV" ] && command+=" -initrd $ENV" command+=" -display none -serial stdio -kernel" command="$(timeout_cmd) $command" echo $command "$@" diff --git a/lib/powerpc/setup.c b/lib/powerpc/setup.c index f2dc10e01352..8d44311cac3b 100644 --- a/lib/powerpc/setup.c +++ b/lib/powerpc/setup.c @@ -21,6 +21,7 @@ extern unsigned long stacktop; extern void io_init(void); extern void setup_args_progname(const char *args); +extern void setup_env(char *env, int size); char *initrd; u32 initrd_size; @@ -211,4 +212,11 @@ void setup(const void *fdt) ret = dt_get_bootargs(&bootargs); assert(ret == 0 || ret == -FDT_ERR_NOTFOUND); setup_args_progname(bootargs); + + if (initrd) { + /* environ is currently the only file in the initrd */ + char *env = malloc(initrd_size); + memcpy(env, initrd, initrd_size); + setup_env(env, initrd_size); + } } diff --git a/powerpc/cstart64.S b/powerpc/cstart64.S index 2d660325e854..2204e3bbe44e 100644 --- a/powerpc/cstart64.S +++ b/powerpc/cstart64.S @@ -94,9 +94,10 @@ start: bl setup /* run the test */ - LOAD_REG_ADDR(r5, __argc) + LOAD_REG_ADDR(r3, __argc) LOAD_REG_ADDR(r4, __argv) - lwz r3, 0(r5) + LOAD_REG_ADDR(r5, __environ) + lwz r3, 0(r3) bl main bl exit b halt -- 2.9.3