From patchwork Mon Jun 15 18:49:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 49923 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A1170211FD for ; Mon, 15 Jun 2015 18:50:01 +0000 (UTC) Received: by lbcak1 with SMTP id ak1sf27841640lbc.2 for ; Mon, 15 Jun 2015 11:50:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=RnI2359kujyQnPeGmS1Vym4wfZlVKWZYKdlhaahr6B4=; b=iOIc6kOkR9vxm3HFeeEDpV8GDHfeAMOxMxkZo66FL3huJDKjpmO6udFwj4Fm9/IDmd /exceKS1zLskPJ/yDh38dYlkWuPLSW5t2VOA1XURC9fDg+X5pgDlNvoQBh6OM2+M5tBz V6S5O7aVWcV38eSN48AlwkPwFZdmG9TfYYoVur1ul2C7OjB5WY6U0rKwAGgJE1gsoyJ/ OctKW1WBi+XBVtBVGW2rdJgmDgCeSoUtVoLQ9NeVUSOrB/GoFOhl2W6LUfZcb0kF6Ff4 ggRc9DFUdXhbn3BYt9icVRcaQuePB5ALxwS8Y8V+YVXFq7vaggYtPnmazDyPjHcLnsGT k5fQ== X-Gm-Message-State: ALoCoQm6C7WH8tOxAn1N/jgr6yHLeMCNt8/nqEHWvipiFHiycFnIGJbQj51rnL1fMz9OqyVSBJcB X-Received: by 10.180.90.106 with SMTP id bv10mr20796502wib.6.1434394200051; Mon, 15 Jun 2015 11:50:00 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.6.100 with SMTP id z4ls758358laz.57.gmail; Mon, 15 Jun 2015 11:49:59 -0700 (PDT) X-Received: by 10.112.83.135 with SMTP id q7mr1564674lby.13.1434394199894; Mon, 15 Jun 2015 11:49:59 -0700 (PDT) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com. [209.85.215.52]) by mx.google.com with ESMTPS id xj4si11147058lbb.112.2015.06.15.11.49.59 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Jun 2015 11:49:59 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by laka10 with SMTP id a10so16315955lak.0 for ; Mon, 15 Jun 2015 11:49:59 -0700 (PDT) X-Received: by 10.152.1.40 with SMTP id 8mr29060238laj.56.1434394199729; Mon, 15 Jun 2015 11:49:59 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp1606785lbb; Mon, 15 Jun 2015 11:49:58 -0700 (PDT) X-Received: by 10.70.91.35 with SMTP id cb3mr27680564pdb.44.1434394197992; Mon, 15 Jun 2015 11:49:57 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id ph10si19010675pbb.174.2015.06.15.11.49.55 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 15 Jun 2015 11:49:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::1 as permitted sender) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1Z4ZSA-0003bh-BG; Mon, 15 Jun 2015 19:49:50 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, =?UTF-8?q?Alex=20Z=C3=BCpke?= Subject: [PATCH 1/2] target-arm: Split DISAS_YIELD from DISAS_WFE Date: Mon, 15 Jun 2015 19:49:49 +0100 Message-Id: <1434394190-13837-2-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1434394190-13837-1-git-send-email-peter.maydell@linaro.org> References: <1434394190-13837-1-git-send-email-peter.maydell@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Currently we use DISAS_WFE for both WFE and YIELD instructions. This is functionally correct because at the moment both of them are implemented as "yield this CPU back to the top level loop so another CPU has a chance to run". However it's rather confusing that YIELD ends up calling HELPER(wfe), and if we ever want to implement real behaviour for WFE and SEV it's likely to trip us up. Split out the yield codepath to use DISAS_YIELD and a new HELPER(yield) function. Signed-off-by: Peter Maydell --- target-arm/helper.h | 1 + target-arm/op_helper.c | 12 ++++++++++++ target-arm/translate-a64.c | 6 ++++++ target-arm/translate.h | 1 + 4 files changed, 20 insertions(+) diff --git a/target-arm/helper.h b/target-arm/helper.h index fc885de..827b33d 100644 --- a/target-arm/helper.h +++ b/target-arm/helper.h @@ -50,6 +50,7 @@ DEF_HELPER_2(exception_internal, void, env, i32) DEF_HELPER_4(exception_with_syndrome, void, env, i32, i32, i32) DEF_HELPER_1(wfi, void, env) DEF_HELPER_1(wfe, void, env) +DEF_HELPER_1(yield, void, env) DEF_HELPER_1(pre_hvc, void, env) DEF_HELPER_2(pre_smc, void, env, i32) diff --git a/target-arm/op_helper.c b/target-arm/op_helper.c index 7fa32c4..5f06ca0 100644 --- a/target-arm/op_helper.c +++ b/target-arm/op_helper.c @@ -334,6 +334,18 @@ void HELPER(wfe)(CPUARMState *env) cpu_loop_exit(cs); } +void HELPER(yield)(CPUARMState *env) +{ + CPUState *cs = CPU(arm_env_get_cpu(env)); + + /* This is a non-trappable hint instruction, so semantically + * different from WFE even though we currently implement it + * identically. Yield control back to the top level loop. + */ + cs->exception_index = EXCP_YIELD; + cpu_loop_exit(cs); +} + /* Raise an internal-to-QEMU exception. This is limited to only * those EXCP values which are special cases for QEMU to interrupt * execution and not to be used for exceptions which are passed to diff --git a/target-arm/translate-a64.c b/target-arm/translate-a64.c index ffa6cb8..288121f 100644 --- a/target-arm/translate-a64.c +++ b/target-arm/translate-a64.c @@ -1199,6 +1199,8 @@ static void handle_hint(DisasContext *s, uint32_t insn, s->is_jmp = DISAS_WFI; return; case 1: /* YIELD */ + s->is_jmp = DISAS_YIELD; + return; case 2: /* WFE */ s->is_jmp = DISAS_WFE; return; @@ -11107,6 +11109,10 @@ void gen_intermediate_code_internal_a64(ARMCPU *cpu, gen_a64_set_pc_im(dc->pc); gen_helper_wfe(cpu_env); break; + case DISAS_YIELD: + gen_a64_set_pc_im(dc->pc); + gen_helper_yield(cpu_env); + break; case DISAS_WFI: /* This is a special case because we don't want to just halt the CPU * if trying to debug across a WFI. diff --git a/target-arm/translate.h b/target-arm/translate.h index bcdcf11..9ab978f 100644 --- a/target-arm/translate.h +++ b/target-arm/translate.h @@ -103,6 +103,7 @@ static inline int default_exception_el(DisasContext *s) #define DISAS_WFE 7 #define DISAS_HVC 8 #define DISAS_SMC 9 +#define DISAS_YIELD 10 #ifdef TARGET_AARCH64 void a64_translate_init(void);