From patchwork Mon Jul 6 09:59:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 50707 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 14018229FC for ; Mon, 6 Jul 2015 10:02:54 +0000 (UTC) Received: by wgbbj7 with SMTP id bj7sf48448058wgb.2 for ; Mon, 06 Jul 2015 03:02:53 -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:date :message-id:in-reply-to:references:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=DnenWfm3uUwqCk8zlIA3J3fav4C3sLyJ3J3wNr+xBRU=; b=M97l7B1mICzr512AqXG0TB6mZcJ7XpX8bdJpcCc+mZng3x5gdn+vaivfJum6U5lZlY 8AFfPRhp8gCBeot9ySDLlfml71orAeadjzS/Eo+BieCeXgxg1zszUEBVXzIhgxjj2XQo 7KN9Vrr66vWiQV4m2CqJ8Nx/YfmUBsX2DTiO9WZYG2VvrNjmNj3oW9Lm7oOmFxMYw/jM 08nlRvCvR+A+1ej3l3ak/nfMwXCYzVaVGD8WUA1KXdebPZKMWEtpfr0PT/RwsppaAeWd e38+RX0mkQQSvdsA7TeyU6nQKSRfPPDV3/5pPqY8X7+LW3eMnPU78K8pOC9/O9dlKhcd hqNg== X-Gm-Message-State: ALoCoQnXATd20DvZV+FBT/FAGUYE5ZA49ymSUBMqsq+u5fUWRNtZa8GIhBLWxoYgtHcuDeAZEK0G X-Received: by 10.194.175.36 with SMTP id bx4mr30124956wjc.1.1436176973345; Mon, 06 Jul 2015 03:02:53 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.87.2 with SMTP id t2ls682475laz.8.gmail; Mon, 06 Jul 2015 03:02:53 -0700 (PDT) X-Received: by 10.112.119.230 with SMTP id kx6mr39202286lbb.9.1436176973180; Mon, 06 Jul 2015 03:02:53 -0700 (PDT) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com. [209.85.215.53]) by mx.google.com with ESMTPS id p6si14846766laj.67.2015.07.06.03.02.53 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Jul 2015 03:02:53 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) client-ip=209.85.215.53; Received: by laar3 with SMTP id r3so148438221laa.0 for ; Mon, 06 Jul 2015 03:02:53 -0700 (PDT) X-Received: by 10.152.26.163 with SMTP id m3mr48244482lag.86.1436176973045; Mon, 06 Jul 2015 03:02:53 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp1614092lbb; Mon, 6 Jul 2015 03:02:51 -0700 (PDT) X-Received: by 10.66.155.36 with SMTP id vt4mr105279342pab.32.1436176971163; Mon, 06 Jul 2015 03:02:51 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id t3si28243295pdf.232.2015.07.06.03.02.50 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 06 Jul 2015 03:02:51 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:49827 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZC3Ef-0001ht-9z for patch@linaro.org; Mon, 06 Jul 2015 06:02:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54363) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZC3Bi-0005Xc-Eh for qemu-devel@nongnu.org; Mon, 06 Jul 2015 05:59:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZC3Bg-0003Oi-SA for qemu-devel@nongnu.org; Mon, 06 Jul 2015 05:59:46 -0400 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:34581) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZC3Bg-0003HN-LM for qemu-devel@nongnu.org; Mon, 06 Jul 2015 05:59:44 -0400 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1ZC3BX-0007hC-S8 for qemu-devel@nongnu.org; Mon, 06 Jul 2015 10:59:35 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 6 Jul 2015 10:59:31 +0100 Message-Id: <1436176775-29545-4-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1436176775-29545-1-git-send-email-peter.maydell@linaro.org> References: <1436176775-29545-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:8b0:1d0::1 Subject: [Qemu-devel] [PULL 3/7] target-arm: Split DISAS_YIELD from DISAS_WFE X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.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.53 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 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, and have HELPER(wfe) call HELPER(yield). Signed-off-by: Peter Maydell Message-id: 1435672316-3311-2-git-send-email-peter.maydell@linaro.org Reviewed-by: Peter Crosthwaite --- target-arm/helper.h | 1 + target-arm/op_helper.c | 18 +++++++++++++++--- target-arm/translate-a64.c | 6 ++++++ target-arm/translate.h | 1 + 4 files changed, 23 insertions(+), 3 deletions(-) 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..663c05d 100644 --- a/target-arm/op_helper.c +++ b/target-arm/op_helper.c @@ -323,13 +323,25 @@ void HELPER(wfi)(CPUARMState *env) void HELPER(wfe)(CPUARMState *env) { - CPUState *cs = CPU(arm_env_get_cpu(env)); - - /* Don't actually halt the CPU, just yield back to top + /* This is a hint instruction that is semantically different + * from YIELD even though we currently implement it identically. + * Don't actually halt the CPU, just yield back to top * level loop. This is not going into a "low power state" * (ie halting until some event occurs), so we never take * a configurable trap to a different exception level. */ + HELPER(yield)(env); +} + +void HELPER(yield)(CPUARMState *env) +{ + ARMCPU *cpu = arm_env_get_cpu(env); + CPUState *cs = CPU(cpu); + + /* This is a non-trappable hint instruction that generally indicates + * that the guest is currently busy-looping. Yield control back to the + * top level loop so that a more deserving VCPU has a chance to run. + */ cs->exception_index = EXCP_YIELD; cpu_loop_exit(cs); } diff --git a/target-arm/translate-a64.c b/target-arm/translate-a64.c index e077f2d..689f2be 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);