From patchwork Thu May 2 05:44:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 794094 Delivered-To: patch@linaro.org Received: by 2002:adf:a153:0:b0:34d:5089:5a9e with SMTP id r19csp78161wrr; Wed, 1 May 2024 22:46:45 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVeWeLaEx9WJFqBM4b9P4hkMq66apPbXl59xOmyj7lv4uR4bIfhe9g2z4mKrAcf2OkqpZmDOeEGgjR34aeYd6IV X-Google-Smtp-Source: AGHT+IGZX9hvbpMOUYGY/VBTgWEjz5OsUopYhj43gv/3shdCLgFQfwdybxrWkRT4rzLREd1Uu3/H X-Received: by 2002:a05:6214:2b0d:b0:6a0:cca2:6513 with SMTP id jx13-20020a0562142b0d00b006a0cca26513mr1049871qvb.46.1714628805632; Wed, 01 May 2024 22:46:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714628805; cv=none; d=google.com; s=arc-20160816; b=xe1N5dvEG4I0fZKkKRGaYSATstlHHjS5nyGX8+yn/MkcpmuUfGRQ+7hnPj0UJLfCMo Q5W9Hu/0UhwfRCnr4AlUeXzLkPUwN/ZR89sctnexzjD/M+H4FYEyGQIFvgeZH6unXL8b +y3L8+8U092XcjLlO1fKAMSs2SarB8zhvHVTf7JCK7aoCcJwESwLOvcPLvTzJGgzOfZh 6hxe9tdBlzjS3373w2H9uy65zwynEepmwkT4EP+vSf3+56yYqcI+FWpBAYYHVjzpZEEa NwtiXNW2ZJKktPBN9tPjGE3fcoscGZD0mhpiA0o2R5GkKOn3JAEGgy+sStWpvESsfut1 ogsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=ADqNlAkDm96SQVHhIMZpqIxZeOqZ/sxONedvIjC0scE=; fh=vvIHVEExtoxBacLa1w/xvEOdET6IjbTxlMJ0GExg4HQ=; b=E7qBzKngkmI+Ua/aBiV8QJasP4FH0MMTQtAIfiX3pwT8GrzdA2vkUSGG/SjwXxrDKg 7LPnOnZ+8fXVXRZFFUqC2ND+1iRZwDWd3VINw7ggnWdsNTxAoIbhSdtN8GWlZX6Li0rd 7k5YNQEdljZ3cArWXdkS7sLkA/aNqBYBIM5PeaASm2O0CGf5rg0gDCYIdeVLFrO/fS/U tsQrjBA+EWTM1N8oza8jPONBph7cBj5N0DoAl5KdKye2lS/R7riLciv6h3vPHreBTn9V 2M7h6eCZkyWGGbbydYzKtvvlo5UYt0kVNEgu2W/2q9W2RAf+7cvvb3GvXLbrwOwY4DAr Pkww==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hrS1yJ9h; 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=pass (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 jp14-20020ad45f8e000000b006a0c3f6203bsi232056qvb.236.2024.05.01.22.46.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 May 2024 22:46:45 -0700 (PDT) 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=pass header.i=@linaro.org header.s=google header.b=hrS1yJ9h; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s2PFK-0008TI-Ms; Thu, 02 May 2024 01:44:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s2PFA-0008NT-4C for qemu-devel@nongnu.org; Thu, 02 May 2024 01:44:33 -0400 Received: from mail-oo1-xc2c.google.com ([2607:f8b0:4864:20::c2c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s2PF1-0002bO-Gj for qemu-devel@nongnu.org; Thu, 02 May 2024 01:44:30 -0400 Received: by mail-oo1-xc2c.google.com with SMTP id 006d021491bc7-5af23552172so4531678eaf.1 for ; Wed, 01 May 2024 22:44:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714628661; x=1715233461; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ADqNlAkDm96SQVHhIMZpqIxZeOqZ/sxONedvIjC0scE=; b=hrS1yJ9h4CDdp3kWKbkwFo9hfKvHVz2DLBTEWTrNUO7PbRFmmV14Hj7VkIox4We0/G MGgbawWMdZ7dbb65xpoxwHqC04Cu/8lQ6k2OzzvychUvl1O/wIs2LJOuVYlKNexoa/R7 J5UE5CxGmjXUvhhF21rtJNdwtrtEBIyzPFRk5MYHoGqg1dIEgi9Aqq/ezyqG3oO9FrJ1 GiJCgnj1exTqR1HzmCA1J9nGqtva/LW1AsIfcCKCTGAAH1H0BJYZBnTNmGbMHrYMXPdQ fHJCmjEJ+7OPf9jj31nVGv+nkR5nvAafxfdn+kiTNxNquf8lwOGxfxF7unZ4ij96FzMl JyWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714628661; x=1715233461; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ADqNlAkDm96SQVHhIMZpqIxZeOqZ/sxONedvIjC0scE=; b=lAa/s6xr8zTyIXbh+YShFjBhtSmoSqVCIkP30B0qtDQw+RWqRd+cuJWGpmqhZiqmrZ RB2a5Xxnbmw8qG+wdZ1bulaVMQJn73ShpGjBxmfas+jCBZ7bWuiyU0AxeynGoHA2o6LP uBiZr+ghcIN7l/ktiv6E2A6zsT2Z9SF/zw/5t7t4OSx4PIBKHzzUGg7tc8TM5yNf8Ith BAUUaGQrnprFfoJWUAmyu+9xPIRq58o0s8Z45r9+8SwKck2oAIFjjil1LNxJeeW+Xf6X KYSPOnIi1L9A4qx03aCedB8lM5nS5gPabSBRwEZy5M4n/RtDQdnDFx0NCWzM396TJfqI 71Bw== X-Gm-Message-State: AOJu0YwMdN9dDdg/NYfKBkyAPNuCmwux3fpXHo/j4WxjhcOq+DiEknt/ Mdh4Pn2YFQ0PBoYTmuD+hJhQaeI9/lW2UtVGdzjBxLlZyYWoMVCxWOMMPuY8VnJQyl+qNPaw8Fn 7 X-Received: by 2002:a05:6358:d3a7:b0:17e:53f9:6985 with SMTP id mp39-20020a056358d3a700b0017e53f96985mr1586564rwb.14.1714628660924; Wed, 01 May 2024 22:44:20 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id e18-20020a656492000000b006089cf2cde5sm294401pgv.26.2024.05.01.22.44.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 22:44:20 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-s390x@nongnu.org, iii@linux.ibm.com, david@redhat.com, thuth@redhat.com Subject: [PATCH 01/14] target/s390x: Do not use unwind for per_check_exception Date: Wed, 1 May 2024 22:44:04 -0700 Message-Id: <20240502054417.234340-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240502054417.234340-1-richard.henderson@linaro.org> References: <20240502054417.234340-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::c2c; envelope-from=richard.henderson@linaro.org; helo=mail-oo1-xc2c.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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Using exception unwind via tcg_s390_program_interrupt, we discard the current value of psw.addr, which discards the result of a branch. Pass in the address of the next instruction, which may not be sequential. Pass in ilen, which we would have gotten from unwind and is passed to the exception handler. Sync cc_op before the call, which we would have gotten from unwind. Signed-off-by: Richard Henderson Reviewed-by: Ilya Leoshkevich --- target/s390x/helper.h | 2 +- target/s390x/tcg/excp_helper.c | 2 +- target/s390x/tcg/misc_helper.c | 23 ++++++++++++++++++++--- target/s390x/tcg/translate.c | 13 +++++++------ 4 files changed, 29 insertions(+), 11 deletions(-) diff --git a/target/s390x/helper.h b/target/s390x/helper.h index cc1c20e9e3..96ab71e877 100644 --- a/target/s390x/helper.h +++ b/target/s390x/helper.h @@ -359,7 +359,7 @@ DEF_HELPER_FLAGS_4(ipte, TCG_CALL_NO_RWG, void, env, i64, i64, i32) DEF_HELPER_FLAGS_1(ptlb, TCG_CALL_NO_RWG, void, env) DEF_HELPER_FLAGS_1(purge, TCG_CALL_NO_RWG, void, env) DEF_HELPER_3(lra, i64, env, i64, i64) -DEF_HELPER_1(per_check_exception, void, env) +DEF_HELPER_FLAGS_3(per_check_exception, TCG_CALL_NO_WG, void, env, i64, i32) DEF_HELPER_FLAGS_3(per_branch, TCG_CALL_NO_RWG, void, env, i64, i64) DEF_HELPER_FLAGS_2(per_ifetch, TCG_CALL_NO_RWG, void, env, i64) DEF_HELPER_FLAGS_1(per_store_real, TCG_CALL_NO_RWG, void, env) diff --git a/target/s390x/tcg/excp_helper.c b/target/s390x/tcg/excp_helper.c index f1c33f7967..4c0b692c9e 100644 --- a/target/s390x/tcg/excp_helper.c +++ b/target/s390x/tcg/excp_helper.c @@ -209,7 +209,7 @@ static void do_program_interrupt(CPUS390XState *env) switch (env->int_pgm_code) { case PGM_PER: - advance = !(env->per_perc_atmid & PER_CODE_EVENT_NULLIFICATION); + /* advance already handled */ break; case PGM_ASCE_TYPE: case PGM_REG_FIRST_TRANS: diff --git a/target/s390x/tcg/misc_helper.c b/target/s390x/tcg/misc_helper.c index 8764846ce8..8c27998ab9 100644 --- a/target/s390x/tcg/misc_helper.c +++ b/target/s390x/tcg/misc_helper.c @@ -20,6 +20,7 @@ #include "qemu/osdep.h" #include "qemu/cutils.h" +#include "qemu/log.h" #include "cpu.h" #include "s390x-internal.h" #include "qemu/host-utils.h" @@ -590,10 +591,26 @@ void HELPER(chsc)(CPUS390XState *env, uint64_t inst) #endif #ifndef CONFIG_USER_ONLY -void HELPER(per_check_exception)(CPUS390XState *env) +G_NORETURN static void per_raise_exception(CPUS390XState *env) { - if (env->per_perc_atmid) { - tcg_s390_program_interrupt(env, PGM_PER, GETPC()); + trigger_pgm_exception(env, PGM_PER); + cpu_loop_exit(env_cpu(env)); +} + +G_NORETURN static void per_raise_exception_log(CPUS390XState *env) +{ + qemu_log_mask(CPU_LOG_INT, "PER interrupt after %#" PRIx64 "\n", + env->per_address); + per_raise_exception(env); +} + +void HELPER(per_check_exception)(CPUS390XState *env, uint64_t next_pc, + uint32_t ilen) +{ + if (unlikely(env->per_perc_atmid)) { + env->psw.addr = next_pc; + env->int_pgm_ilen = ilen; + per_raise_exception_log(env); } } diff --git a/target/s390x/tcg/translate.c b/target/s390x/tcg/translate.c index 90a74ee795..2319dcf259 100644 --- a/target/s390x/tcg/translate.c +++ b/target/s390x/tcg/translate.c @@ -6426,13 +6426,14 @@ static DisasJumpType translate_one(CPUS390XState *env, DisasContext *s) #ifndef CONFIG_USER_ONLY if (s->base.tb->flags & FLAG_MASK_PER) { - /* An exception might be triggered, save PSW if not already done. */ - if (ret == DISAS_NEXT || ret == DISAS_TOO_MANY) { - tcg_gen_movi_i64(psw_addr, s->pc_tmp); - } + TCGv_i64 next_pc = psw_addr; - /* Call the helper to check for a possible PER exception. */ - gen_helper_per_check_exception(tcg_env); + if (ret == DISAS_NEXT || ret == DISAS_TOO_MANY) { + next_pc = tcg_constant_i64(s->pc_tmp); + } + update_cc_op(s); + gen_helper_per_check_exception(tcg_env, next_pc, + tcg_constant_i32(s->ilen)); } #endif