From patchwork Mon Feb 27 11:35:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 656956 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp2300695wrb; Mon, 27 Feb 2023 03:41:01 -0800 (PST) X-Google-Smtp-Source: AK7set9M/Mped5oK+vpxJEePmf+ee5xROx5bBBY6dSHPu2LO177btDkFFuLiPozRl77VCnzcwpYF X-Received: by 2002:ac8:5703:0:b0:3bd:1647:15cd with SMTP id 3-20020ac85703000000b003bd164715cdmr38810236qtw.2.1677498061526; Mon, 27 Feb 2023 03:41:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677498061; cv=none; d=google.com; s=arc-20160816; b=zY4K/gibFaUY625D/+6q1jig1XeSznVjRv6vD5dXJKebEL4qY/xvBFE8GGrE1fm+dx CGL0ND5w+c08dGCfGDDa/uOuLYk9CPhZs6iG1xtCKyIWtJDw/p/wTb61tV7Mhoau0/+Q fKkPaxjni7xYEOk8sWa1SRoZukm7+1/uBbvopx/6YRFYx7VfTX2nUVOdStwBv6MvdeI6 pc02YLLTU+TIq7WpeY+oAjfGxoKxhox+nOPMhhgDD8j6C6/LKNuoWF5aTTqeHFGsIh8Z 7MjAc9NLpZV3Y6WXxf+EU2ybcU2TcFo/iIXfPU1kUbzw1gaOrIvmc2lG+UTuK7IrCHe5 TVpg== 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=QKAMphEjWC3G2kT87C3UlKB2yZG6Vl47kFoNLNmNTk8=; b=ATh/xjhTpX4Z9zFbVNgDE8WkcPOdtkcEpwAS2BS0OTxHeTdTRglI/NVL/jrmvylS9R iP3L9SKfxpyXoWRpLVzoLojGZ7wGIlXiAtLreeH4V4ElHyQ/bg5q+zW7xBV3mxo60AQ4 rZVXU56Axp/RiXIeTxVft+V4JMswQ9CSbYAcPfwwyxrBxYjVsSepMWk0/tufgZPLACyT o0i/Ed7rfJcS8NqCt/tIWgp3vwkLo5SPGX1iwN30nC1nfW+o8I5GVDMNv0A6m+dRpk4J RTLr1NdRIt2oEgcxQpFPF04cyN7YqbwvD1r0qVb8qNJgEoszEjZYIQkCThZZBueL7RQn IKPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FNy2QCbj; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v6-20020a05622a130600b003ba26ea2109si6602600qtk.341.2023.02.27.03.41.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Feb 2023 03:41:01 -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=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FNy2QCbj; 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=redhat.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pWboK-0005hk-Cx; Mon, 27 Feb 2023 06:36:52 -0500 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 1pWboF-0005dr-BR for qemu-devel@nongnu.org; Mon, 27 Feb 2023 06:36:47 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pWboD-0005gq-Fc for qemu-devel@nongnu.org; Mon, 27 Feb 2023 06:36:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677497804; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QKAMphEjWC3G2kT87C3UlKB2yZG6Vl47kFoNLNmNTk8=; b=FNy2QCbjjojcG5yXcS4vTCmxdxh8N7tD5A0NmHxmalOyyO2F0tXh2lGCLTHNztElWvQZAr klFRjbPz9vQin9EDHpqot5m0T1YsdKlqUoba2SfDmASFkUwbgXAIp2+6ROExnTyeNMJqfY KD2j3OVh/WE4LJR7VyG3VvBVLJQSOk0= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-562-aPiggFU8NHWU9mlI2j3wGw-1; Mon, 27 Feb 2023 06:36:36 -0500 X-MC-Unique: aPiggFU8NHWU9mlI2j3wGw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 998F83C0E445; Mon, 27 Feb 2023 11:36:35 +0000 (UTC) Received: from thuth.com (unknown [10.45.227.26]) by smtp.corp.redhat.com (Postfix) with ESMTP id AE9BA1121314; Mon, 27 Feb 2023 11:36:34 +0000 (UTC) From: Thomas Huth To: Peter Maydell , qemu-devel@nongnu.org Cc: Richard Henderson , David Hildenbrand Subject: [PULL 10/33] target/s390x: Fix s390_probe_access for user-only Date: Mon, 27 Feb 2023 12:35:58 +0100 Message-Id: <20230227113621.58468-11-thuth@redhat.com> In-Reply-To: <20230227113621.58468-1-thuth@redhat.com> References: <20230227113621.58468-1-thuth@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 Received-SPF: pass client-ip=170.10.133.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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.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 From: Richard Henderson In db9aab5783a2 we broke the contract of s390_probe_access, in that it no longer returned an exception code, nor set __excp_addr. Fix both. Reported-by: David Hildenbrand Signed-off-by: Richard Henderson Reviewed-by: David Hildenbrand Message-Id: <20230109201856.3916639-2-richard.henderson@linaro.org> Signed-off-by: Thomas Huth --- target/s390x/tcg/mem_helper.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/target/s390x/tcg/mem_helper.c b/target/s390x/tcg/mem_helper.c index d6725fd18c..9a6dce4cda 100644 --- a/target/s390x/tcg/mem_helper.c +++ b/target/s390x/tcg/mem_helper.c @@ -138,23 +138,27 @@ typedef struct S390Access { * For !CONFIG_USER_ONLY, the TEC is stored stored to env->tlb_fill_tec. * For CONFIG_USER_ONLY, the faulting address is stored to env->__excp_addr. */ -static int s390_probe_access(CPUArchState *env, target_ulong addr, int size, - MMUAccessType access_type, int mmu_idx, - bool nonfault, void **phost, uintptr_t ra) +static inline int s390_probe_access(CPUArchState *env, target_ulong addr, + int size, MMUAccessType access_type, + int mmu_idx, bool nonfault, + void **phost, uintptr_t ra) { -#if defined(CONFIG_USER_ONLY) - return probe_access_flags(env, addr, access_type, mmu_idx, - nonfault, phost, ra); -#else - int flags; + int flags = probe_access_flags(env, addr, access_type, mmu_idx, + nonfault, phost, ra); - env->tlb_fill_exc = 0; - flags = probe_access_flags(env, addr, access_type, mmu_idx, nonfault, phost, - ra); - if (env->tlb_fill_exc) { + if (unlikely(flags & TLB_INVALID_MASK)) { + assert(!nonfault); +#ifdef CONFIG_USER_ONLY + /* Address is in TEC in system mode; see s390_cpu_record_sigsegv. */ + env->__excp_addr = addr & TARGET_PAGE_MASK; + return (page_get_flags(addr) & PAGE_VALID + ? PGM_PROTECTION : PGM_ADDRESSING); +#else return env->tlb_fill_exc; +#endif } +#ifndef CONFIG_USER_ONLY if (unlikely(flags & TLB_WATCHPOINT)) { /* S390 does not presently use transaction attributes. */ cpu_check_watchpoint(env_cpu(env), addr, size, @@ -162,8 +166,9 @@ static int s390_probe_access(CPUArchState *env, target_ulong addr, int size, (access_type == MMU_DATA_STORE ? BP_MEM_WRITE : BP_MEM_READ), ra); } - return 0; #endif + + return 0; } static int access_prepare_nf(S390Access *access, CPUS390XState *env,