Received: by 2002:a17:907:c68a:b0:84d:2074:29bb with SMTP id ue10csp1561727ejc; Fri, 27 Jan 2023 17:47:26 -0800 (PST) X-Google-Smtp-Source: AMrXdXvm3bfMeOxwYz/EugDNUHKuc+hjp+ZyBHLR1amBxs3LFyI2LMP5E8SXAraZCMXpieqTGiWF X-Received: by 2002:a05:622a:1dc4:b0:3b6:3b60:e0 with SMTP id bn4-20020a05622a1dc400b003b63b6000e0mr55823035qtb.31.1674870446534; Fri, 27 Jan 2023 17:47:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674870446; cv=none; d=google.com; s=arc-20160816; b=Op4rngTbZTDSHsuks/w8GEIw+LoLG5YsHoThUZQqivq0hSjRSa0RoQX8P9nUAMX/PO Wziys3s3loholK4J3QMo/JEU3ou5AYMCEJ9hNSLzohbs33/bvXunRa6aZxvFQR50y7kH VzGcV4pnbaYYLvegK5mUKEeJHPatnx6HupvXLgh13m4+goLgzislJanWHzcLPUGI/U1U RosBUdyvYLntEx0+lQxPZOuk3RGab+Ri/caVMrXYn6Meoi7Md5bTGDfcGt7uusZwa5Pm 9ULVbej4eoU6wpe7X3a2hBD72KeRbD0eKftRdRAJBynb6bZ+EzlIIVQ1Doa67shRwIgF j+/w== 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 :in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:dkim-signature; bh=JIMnU4HZfi5aqUU026Ue3HyisdN6V43OjLbp8WZb4K0=; b=RAEqd2F93X9XzI3ifs4QA2x44aEEC2syhVHqpL8kA9fOzEecC6im7XEQEM8jw3q4Nk rUqpMNLX2QDQnGb2a48zupiaeGpOK4Fiaka4VcL0N6ri9KfhqWrx8FjPfpZdqe/bF/28 4Pbe7GebMhpDxRKJX/ok81yTsOzIWWtYLx7xnB50L0zDYNzqPmUaRVT/m1VCbDZ5smpv wDdBatwqZgX93XLR3C0Uvk+NRR8RcDKgz6rwH3XEHNCWJinwnduyfXef0u3oPavLFTkZ jf/zJ5Tzg0t+zqksrb/lsH5qriC4UnTaVB8v7znLBy8bw1H60/1YyCc1P5FOdFCyPH4G f+AQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=F4Lwljz9; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=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 k15-20020a05620a414f00b00719bf1a115esi1390006qko.479.2023.01.27.17.47.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 27 Jan 2023 17:47:26 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-arm-bounces+alex.bennee=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=F4Lwljz9; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=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 1pLaJH-0002nR-3J; Fri, 27 Jan 2023 20:47:15 -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 1pLaJD-0002mU-Sn for qemu-arm@nongnu.org; Fri, 27 Jan 2023 20:47:11 -0500 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pLaJC-000673-4Y for qemu-arm@nongnu.org; Fri, 27 Jan 2023 20:47:11 -0500 Received: by mail-pj1-x102d.google.com with SMTP id v6-20020a17090ad58600b00229eec90a7fso9496543pju.0 for ; Fri, 27 Jan 2023 17:47:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=JIMnU4HZfi5aqUU026Ue3HyisdN6V43OjLbp8WZb4K0=; b=F4Lwljz9DkbT8A0ARFNR4a3EgcLutCYlAYeeIvdkq4o3uN/CF76H0gPxavd0NqXySB 5kDUXEaZ1Dg7RayVshY7LOZwgw7bl6Y3QpaDAV48Froe75EmSIITA1As4ZwqFC1khfwh rl5iJi06bR2Ktdmj5zYQymMZ8r5e/r+L9MeQfrA4sYsEbSAvLNi5BjupKxcSFV6hYGPG twPYXBUs4dgV1o+wNgEBVgOM/K8gpz+/A0Ey+ZRtSLm/NDONo/crpFwRbjtrcRQD6JXL jG255MkBV6y/FPTjytUzF2YLZG+x49Bul41ZNjY1kwBi3ryslCnGFeHpx346/nZzmq0u KVDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=JIMnU4HZfi5aqUU026Ue3HyisdN6V43OjLbp8WZb4K0=; b=ydBT34ihoi53o6FHwvu2ZqvPhl7LUor4aHy5dnV/ATnfDpcg6O0UZtXRM4FsAzS6Ta CIeImGE4uLkL+NKdHuXT+07wMn14A0UJRtNVFDQvim+zc7r25GitO8wPGqcYzSUgs8fa /kdjw2Y5fUoCVn7+kQOfLJkQC4cMmTVJzCHGEwr6mLHF6etThCD79F24J2amO6RfsGb1 4HrbIWFGTI/sBrWHxaEsNdsfUo+GPLWrN0+jNv3z3FraINlQ5mu8fDzX5RPsoLAiFMpp EIrxtX45sv9mDHfS2gSOYRqBQD2Kn1IpmyqAtZxD9HVrw1W0GinmMzoC4+XeYsKOS0gz g0uQ== X-Gm-Message-State: AO0yUKUA67CXj+qKhiFyPrvKrw5oEFJpjC6EdfqKcCe/ND3q+YhcK2zL ejftC4cesP+FYRqKI8PdVed3mA== X-Received: by 2002:a05:6a21:6d9b:b0:bc:5d69:754f with SMTP id wl27-20020a056a216d9b00b000bc5d69754fmr4087555pzb.18.1674870428364; Fri, 27 Jan 2023 17:47:08 -0800 (PST) Received: from [192.168.50.174] (rrcs-173-197-98-118.west.biz.rr.com. [173.197.98.118]) by smtp.gmail.com with ESMTPSA id b197-20020a6334ce000000b004da637aae96sm2928120pga.31.2023.01.27.17.47.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 27 Jan 2023 17:47:07 -0800 (PST) Message-ID: <351b2481-4e80-57db-f06c-3dbf95db06fe@linaro.org> Date: Fri, 27 Jan 2023 15:47:04 -1000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: [PATCH 06/23] target/arm: Make HSTR_EL2 traps take priority over UNDEF-at-EL1 Content-Language: en-US To: Peter Maydell , qemu-arm@nongnu.org, qemu-devel@nongnu.org References: <20230127175507.2895013-1-peter.maydell@linaro.org> <20230127175507.2895013-7-peter.maydell@linaro.org> From: Richard Henderson In-Reply-To: <20230127175507.2895013-7-peter.maydell@linaro.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=2607:f8b0:4864:20::102d; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102d.google.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 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, NICE_REPLY_A=-1.148, 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-arm@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-arm-bounces+alex.bennee=linaro.org@nongnu.org Sender: qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org X-TUID: C8ruYlJYTYci On 1/27/23 07:54, Peter Maydell wrote: > +void HELPER(hstr_trap_check)(CPUARMState *env, uint32_t mask, uint32_t syndrome) > +{ > + if (env->cp15.hstr_el2 & mask) { > + raise_exception(env, EXCP_UDEF, syndrome, 2); > + } This is so simple... > @@ -4760,6 +4761,28 @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64, > break; > } > > + if (s->hstr_active && cpnum == 15 && s->current_el == 1) { > + /* > + * At EL1, check for a HSTR_EL2 trap, which must take precedence > + * over the UNDEF for "no such register" or the UNDEF for "access > + * permissions forbid this EL1 access". HSTR_EL2 traps from EL0 > + * only happen if the cpreg doesn't UNDEF at EL0, so we do those in > + * access_check_cp_reg(), after the checks for whether the access > + * configurably trapped to EL1. > + */ > + uint32_t maskbit = is64 ? crm : crn; > + > + if (maskbit != 4 && maskbit != 14) { > + /* T4 and T14 are RES0 so never cause traps */ > + gen_set_condexec(s); > + gen_update_pc(s, 0); > + emitted_update_pc = true; > + gen_helper_hstr_trap_check(cpu_env, > + tcg_constant_i32(1 << maskbit), > + tcg_constant_i32(syndrome)); > + } How about if (maskbit...) { TCGv_i32 t = load_cpu_offset(offsetoflow32(CPUARMState, hstr_el2)); DisasLabel *over = gen_disas_label(s); tcg_gen_andi_i32(t, t, 1u << maskbit); tcg_gen_brcondi_i32(TCG_COND_EQ, t, 0, over.label); tcg_temp_free_i32(t); gen_exception_insn(s, 0, EXCP_UDEF, syndrome); set_disas_label(s, over); } which also eliminates the need for emitted_update_pc. r~