From patchwork Thu Nov 25 15:41:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 519662 Delivered-To: patch@linaro.org Received: by 2002:ac0:c605:0:0:0:0:0 with SMTP id p5csp1011675imj; Thu, 25 Nov 2021 07:42:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJxMXTwJocnOYpCwKdYDZDn7CY2C1HZPW0I7rTaDfUziqxDDhWEVaqyn0/5IVbaZKNv2/zno X-Received: by 2002:a67:c40c:: with SMTP id c12mr10783717vsk.16.1637854972874; Thu, 25 Nov 2021 07:42:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637854972; cv=none; d=google.com; s=arc-20160816; b=aQS/Zhi5yMxoHMXH8yxc3QH2swsu8mE7ltSr19ALJ9vxGQuL9Ge+PcjWLvoMELr4Mi +F9PiPF7ogC0jArzHw/2dDZ2XeRf8deOikSGxtWvmKCS+gc33IQFTrfF90OMN96/mmcv 2DaDnNkOcrJXicrgKf9yt/fFwxymyIkIj0MLWhq/no0CaPhE133fso4gNLkOj96LDvvB SU6rLV+08x4F8dHtoK4gjdUFHEygbieCcMBfbWevu95g1XlsL3WZq/4KoUbKQB+pu31z 4CCtZhMpO7jt71mwpTmC0mgot/1P0zbrTGSFiU5Sm4qo15kc8r4FY4/IGiU40zX+UmGO JeSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=i6Sa/S7mYt2OQVGTXQQ5ol9j8zL0KNw6Xyxd4wnAmmg=; b=JCg08euL2fxNpbHWqILO7cNW1jaXKHW75gk5Xdt3J9e6wCXTAvqa9QxUancpHmBtr8 zUzgHgqisQgYYWPFQYCC1YqbYOI7g5bd8fr2E9C8E20xhnGxCVDe3izR2T2hiLZ9yqL8 wyk4Ik3X2fexRDKJNlQmnXjDm5n3cnGVaCovrSDEyC4Dq1kZQmY/tIhNW37ETEjq8iG9 Lhn8V4Ivjq2TtSgN+aBB/dWVnY6L7BdwHVn4X0OVZ1k0LkBcWuxsvPjxE45WVeRCobHo VqqhkVfzyyxoXOrBCvo9v99InFXPbBgPQALRI32zTBYBSR4cnMqFB3X5Dg0qOHoUzxsP bCaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=zxn0mXl6; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id bl41si8428822vsb.322.2021.11.25.07.42.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 25 Nov 2021 07:42:52 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=zxn0mXl6; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37544 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mqGtf-0006bS-Ow for patch@linaro.org; Thu, 25 Nov 2021 10:42:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47866) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mqGsj-0006ZN-4l for qemu-devel@nongnu.org; Thu, 25 Nov 2021 10:41:53 -0500 Received: from [2a00:1450:4864:20::42c] (port=35821 helo=mail-wr1-x42c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mqGsh-0002JC-7D for qemu-devel@nongnu.org; Thu, 25 Nov 2021 10:41:52 -0500 Received: by mail-wr1-x42c.google.com with SMTP id i5so12553975wrb.2 for ; Thu, 25 Nov 2021 07:41:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=i6Sa/S7mYt2OQVGTXQQ5ol9j8zL0KNw6Xyxd4wnAmmg=; b=zxn0mXl6jo5xUZG/a6ouevDKUP09VGykBhtkoOq04stxP3+tZaBVDFuMJKOqVqI3mj ffeckEi74ql1Ps6+a6bhoWd04s/nvYul+ehAOua4XFYk1XwPl5ZLKJtc+xvDqc2lsjXl yISQeXcTrIplhpmZp0nCPgj+OLkI4nyq1QYk156Pgs09eIO3EBvoWSskZFMt3g+Xa1jB tU1y7duUu9tmX3DbIeWEWxTaMZbiG5zU4je32Gikl4bXhgtq+XtIMfDM01Hky7VxHPPk v/P+YQ+Sth26s1H181Ebsj41VnxPICyhFI+MGSKgMmIoFEe43PKk/RKt+e+JENmq6MCU y8GQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=i6Sa/S7mYt2OQVGTXQQ5ol9j8zL0KNw6Xyxd4wnAmmg=; b=nRO31ERchAYIASTnp9HitMbdW3yDfUnMm7mc9PwhKpIaId0Vz4u66+TMd23qSByvb5 m6sTLEXwlmI2spCz0LRNzvYIj8F5GMsURxqRIA8J2RzB9LFAMQzcbhO5osn4ookatIMr 5VMoxOMgAUdPUDYWVr9XOFYqQNgfrLNKMq1/1cr25aINeTKP7KKaSzeU7rensDnI8gdP 4he8Qu9Nam6FVO8977NQz1bSnBowqY0Ws+jhxelBHJW3j/6EkJuMaI0D7M/6yttMBWGe tXJP/Z9JRTYV/1pxeO77Q010DIFhOwhARUmr/667CB+DK6bYkGPysa6mGNOykJr8FWjh ZJRA== X-Gm-Message-State: AOAM53132uZqhfWVBelbiypjR62cs5LnXHbQzntL69bTyL8mMLVzRvxL 2w4j09m3F05z/xGslo4PJRGYAg== X-Received: by 2002:adf:8010:: with SMTP id 16mr7431949wrk.559.1637854909439; Thu, 25 Nov 2021 07:41:49 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id r17sm9577700wmq.5.2021.11.25.07.41.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Nov 2021 07:41:45 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 164341FF98; Thu, 25 Nov 2021 15:41:45 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 1/7] accel/tcg: introduce CF_NOIRQ Date: Thu, 25 Nov 2021 15:41:38 +0000 Message-Id: <20211125154144.2904741-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211125154144.2904741-1-alex.bennee@linaro.org> References: <20211125154144.2904741-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::42c (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42c.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fam@euphon.net, berrange@redhat.com, Richard Henderson , f4bug@amsat.org, stefanha@redhat.com, crosa@redhat.com, pbonzini@redhat.com, =?utf-8?q?Alex_?= =?utf-8?q?Benn=C3=A9e?= , aurelien@aurel32.net Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Here we introduce a new compiler flag to disable the checking of exit request (icount_decr.u32). This is useful when we want to ensure the next block cannot be preempted by an asynchronous event. Suggested-by: Richard Henderson Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- v2 - split from larger patch - reword the check in cpu_handle_interrupt and scope to CF_NOIRQ only --- include/exec/exec-all.h | 1 + include/exec/gen-icount.h | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 6bb2a0f7ec..35d8e93976 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -503,6 +503,7 @@ struct TranslationBlock { #define CF_USE_ICOUNT 0x00020000 #define CF_INVALID 0x00040000 /* TB is stale. Set with @jmp_lock held */ #define CF_PARALLEL 0x00080000 /* Generate code for a parallel context */ +#define CF_NOIRQ 0x00100000 /* Generate an uninterruptible TB */ #define CF_CLUSTER_MASK 0xff000000 /* Top 8 bits are cluster ID */ #define CF_CLUSTER_SHIFT 24 diff --git a/include/exec/gen-icount.h b/include/exec/gen-icount.h index 610cba58fe..c57204ddad 100644 --- a/include/exec/gen-icount.h +++ b/include/exec/gen-icount.h @@ -21,7 +21,6 @@ static inline void gen_tb_start(const TranslationBlock *tb) { TCGv_i32 count; - tcg_ctx->exitreq_label = gen_new_label(); if (tb_cflags(tb) & CF_USE_ICOUNT) { count = tcg_temp_local_new_i32(); } else { @@ -42,7 +41,19 @@ static inline void gen_tb_start(const TranslationBlock *tb) icount_start_insn = tcg_last_op(); } - tcg_gen_brcondi_i32(TCG_COND_LT, count, 0, tcg_ctx->exitreq_label); + /* + * Emit the check against icount_decr.u32 to see if we should exit + * unless we suppress the check with CF_NOIRQ. If we are using + * icount and have suppressed interruption the higher level code + * should have ensured we don't run more instructions than the + * budget. + */ + if (tb_cflags(tb) & CF_NOIRQ) { + tcg_ctx->exitreq_label = NULL; + } else { + tcg_ctx->exitreq_label = gen_new_label(); + tcg_gen_brcondi_i32(TCG_COND_LT, count, 0, tcg_ctx->exitreq_label); + } if (tb_cflags(tb) & CF_USE_ICOUNT) { tcg_gen_st16_i32(count, cpu_env, @@ -74,8 +85,10 @@ static inline void gen_tb_end(const TranslationBlock *tb, int num_insns) tcgv_i32_arg(tcg_constant_i32(num_insns))); } - gen_set_label(tcg_ctx->exitreq_label); - tcg_gen_exit_tb(tb, TB_EXIT_REQUESTED); + if (tcg_ctx->exitreq_label) { + gen_set_label(tcg_ctx->exitreq_label); + tcg_gen_exit_tb(tb, TB_EXIT_REQUESTED); + } } #endif