From nobody Fri May 10 03:05:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1621219689; cv=none; d=zohomail.com; s=zohoarc; b=XDrw7bG4uNZzMZ7nInlf9NFb6eZwymzZOdi3PnDtpN/sUtAPk+2ugPoVxEQx3EwmkS+R2pMdbDOMwLKuc0bvekEtUJwijNp4jjUqQL1Lh31EOh1PWBNbCoSu+y1bf5t/tcA6fG52qgOAIJzKU48XtGiT1PNKcXZOImeC+Ix8gGM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621219689; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=0Jk0cKPBs6zBNYJ8PHbQgjtBfcBZqoDnsYAxiX+pq6k=; b=jljxQ7ePE0bOJtiTTvvWPVF7mVBrqRuoWGepmvlO/DSdXWR/TManBUss0N2tJ9mIUv1NNI7oECu4BBiZ9yjIlb03E5UNui4Aj5jHaf9zMnHDV9tP+epacVRnKoNsKYcdQbmOAMPK3U/vjCecd+VjcC9hf6F6ndXI6t4IxzzsCCM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1621219689438265.3938068081642; Sun, 16 May 2021 19:48:09 -0700 (PDT) Received: from localhost ([::1]:40222 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1liTId-0005Rw-VL for importer@patchew.org; Sun, 16 May 2021 22:48:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51398) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1liTHb-0004bi-IQ; Sun, 16 May 2021 22:47:03 -0400 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]:46803) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1liTHZ-0006af-Q2; Sun, 16 May 2021 22:47:03 -0400 Received: by mail-pf1-x436.google.com with SMTP id q2so3934060pfh.13; Sun, 16 May 2021 19:47:00 -0700 (PDT) Received: from bobo.ozlabs.ibm.com (14-201-155-8.tpgi.com.au. [14.201.155.8]) by smtp.gmail.com with ESMTPSA id l6sm8938955pgc.68.2021.05.16.19.46.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 May 2021 19:46:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=0Jk0cKPBs6zBNYJ8PHbQgjtBfcBZqoDnsYAxiX+pq6k=; b=OfaY3NjrUoXkoQdGq/FhvAKnyrdLl85wk0uAV0mwBe1NrB8LMgHmohbWEPG9ADsRfH 5bykQZRiQDrkTA2nPqMs2ZjeiY/hJQGFIHdnERFhKm02nRAPOP+AwPDTia6Yk6ROnbre Z6AEoSm2RqoBRSGu/BcOCa0Raxan0+KNx59lcg8DPJ9wz4jKBzgQPZ/s50xf/GmsPzgW r0vNfCMZPa8wfBSbKH8b+HQ+snGzCP8+0Zu+kbM2cXGtuphKPkX/OdZu3rmT1dwbitKV BZXnQZVfZeX59S4RJ5HOs+rExjGn+o3UfI6sNhkVxE56/nDZGuRY/ptn+xUsyaU72YRP VsNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=0Jk0cKPBs6zBNYJ8PHbQgjtBfcBZqoDnsYAxiX+pq6k=; b=AG1GEUddldl1It+DlbOhaBui4LSH1vuGDDONbPf1mEDfRJkC0RWY6bAEtIKpmfXSd2 t2FGLJgIMpGAQEnCcDt1vlsHAh1QX7JHbfceTs0WUjyv2jwEKjDI3DG7RVOjljqrEKFq dTlXZzJVKFFDYqhqEkNagpYR9j3SQcJwNS4TxsWmvI6WmfuOFxIXA7cBgI4d5/sJhL/S QLNL/8ljpMLECID82cfejOEJshZHqpI9PGivYLmG6dnO7zmCE9f+3klU1q2R/rC56tka O4cjl6tH41ZdEe1fD3iPwpjGmSf3uMoRJH3KQwKl0og6+e5JNT9zIAQKRVn9wXTJ0NLc yx1w== X-Gm-Message-State: AOAM532HkMAbqt9rC8XIIvoQBxoRCTsNizaDrKbA+qUTHJQrdoZgBNID pqWr9n23JDJRhosvgaZ4FUcvRCmoqVU= X-Google-Smtp-Source: ABdhPJyZtgXARWAQUMp4EYQpgWJuYdrlAxP7mUUCO9YBPn8tcqy3D1XxZ+Pl/llcVyqV5QHjtQ+12Q== X-Received: by 2002:a63:dc57:: with SMTP id f23mr57468394pgj.294.1621219619194; Sun, 16 May 2021 19:46:59 -0700 (PDT) From: Nicholas Piggin To: qemu-ppc@nongnu.org Subject: [PATCH] target/ppc: Implement ISA v3.1 wait variants Date: Mon, 17 May 2021 12:46:51 +1000 Message-Id: <20210517024651.2200837-1-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::436; envelope-from=npiggin@gmail.com; helo=mail-pf1-x436.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, Nicholas Piggin , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" ISA v3.1 adds new variations of wait, specified by the WC field. These are not compatible with the wait 0 implementation, because they add additional conditions that cause the processor to resume, which can cause software to hang or run very slowly. Add the new wait variants with a trivial no-op implementation, which is allowed, as explained in comments: software must not depend on any particular architected WC condition having caused resumption of execution, therefore a no-op implementation is architecturally correct. Signed-off-by: Nicholas Piggin --- Implementing cpu_relax() in Linux with wait 2,0 (pause_short) causes a hang on boot without this patch. target/ppc/translate.c | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/target/ppc/translate.c b/target/ppc/translate.c index a6381208a5..80db450cab 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -3619,12 +3619,39 @@ static void gen_sync(DisasContext *ctx) /* wait */ static void gen_wait(DisasContext *ctx) { - TCGv_i32 t0 =3D tcg_const_i32(1); - tcg_gen_st_i32(t0, cpu_env, - -offsetof(PowerPCCPU, env) + offsetof(CPUState, halted)= ); - tcg_temp_free_i32(t0); - /* Stop translation, as the CPU is supposed to sleep from now */ - gen_exception_nip(ctx, EXCP_HLT, ctx->base.pc_next); + uint32_t wc =3D (ctx->opcode >> 21) & 3; + + /* + * wait 0 waits for an exception to occur. + */ + if (wc =3D=3D 0) { + TCGv_i32 t0 =3D tcg_const_i32(1); + tcg_gen_st_i32(t0, cpu_env, + -offsetof(PowerPCCPU, env) + offsetof(CPUState, hal= ted)); + tcg_temp_free_i32(t0); + /* Stop translation, as the CPU is supposed to sleep from now */ + gen_exception_nip(ctx, EXCP_HLT, ctx->base.pc_next); + } + + /* + * Other wait types must not wait until an exception occurs because + * ignoring their other wake-up conditions could cause a hang. + * + * wait 1 (waitrsv) waits for an exception or a reservation to be lost. + * This can happen for implementation specific reasons, so it can be + * implemented as a no-op. + * + * wait 2 waits for an exception or an amount of time to pass. This is + * implementation specific so it can be implemented as a no-op. + * + * wait 3 is reserved, so it may be implemented as a no-op. + * + * ISA v3.1 does allow for execution to resume "in the rare case of + * an implementation-dependent event", so in any case software must + * not depend on the architected resumption condition to become + * true, so no-op implementations are architecturally correct (if + * suboptimal). + */ } =20 #if defined(TARGET_PPC64) --=20 2.23.0