From patchwork Sat Oct 1 16:22:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 611394 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp279074pvb; Sat, 1 Oct 2022 09:42:34 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7SkQ4Fukhw8d6nSxqN9WNRQrdElQnxml/Z+H4nUOSdGaPX7oVfsY1lxQ29+1ZHVobXlKXZ X-Received: by 2002:ac8:584a:0:b0:35c:bf11:9e42 with SMTP id h10-20020ac8584a000000b0035cbf119e42mr10973202qth.425.1664642554173; Sat, 01 Oct 2022 09:42:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664642554; cv=none; d=google.com; s=arc-20160816; b=pyjMzBrU7VADFRA68hUr+YAhmxtfr7XZk/hN6QDItmh3ahy+Q77FLl0X19+ogegjXd njMRvkytt2A9PzuIg+I3raL1SICSPFqnhVTCkLR8qVehQiBKpt8IuRNDkk+K832cTAwh UwXcWe6yaOnFIIQS2KPcS0/8iTH6Y9ulKQ24f75BOVPg3zlPljmoNj3pvsuw/0JH+Jqj 8r+5wa+NS7U3sykW6zU67aKhyfkJnjdYtntE/s0HYrlPkzNQKh2W86xIp8B6HxXojn6B bUPHN382P6l093N8dcObgmqgBLXytQEp9VVcYUT4hHFnW7zmOxQ5X/Cp9c7TA8Rqm55U NV1g== 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=4bFcMUoE4kIp+2MWdZM5AsV1Ns0C4SweuGTMktPkM3A=; b=h+zDBE9abHahe8czpHy3+EUihZuEw2BNkkSZh8nO08FBkZ7nqwMckmXtbSDQHy22nr ZyW2Oj3sLXf6SUSmotCCRtKLWHdk+lHGqZnXWqV48V3iIkxcCrx3YIlnVCOVcyhIPmMr 3ln+huchUuvCbmSwb3XZGzcO/I809iy3qZpkjiexpqYVgDGWaliVOCbXIonBS3Taqm/Z C8GKARCT3JkVqroYv88QO51+i5zIeYxT5wkxg9yNClbpIKGD5kYJmOYItSxvdqfgTqnv 2RTA7vg/hOoWG+jBnNRZuU67sJcNbjW+1M4cXEU+V6ZileaB5eAEQB0YEx+fMWLnSpvZ OGrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RmJrPXJW; 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 x6-20020a05620a12a600b006ce968bd444si2448721qki.328.2022.10.01.09.42.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 01 Oct 2022 09:42:34 -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=RmJrPXJW; 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]:51874 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oefZR-0000Uk-Mq for patch@linaro.org; Sat, 01 Oct 2022 12:42:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33448) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oefHY-0006ky-OE for qemu-devel@nongnu.org; Sat, 01 Oct 2022 12:24:06 -0400 Received: from mail-qv1-xf2a.google.com ([2607:f8b0:4864:20::f2a]:46856) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oefHW-0006Hd-0k for qemu-devel@nongnu.org; Sat, 01 Oct 2022 12:24:03 -0400 Received: by mail-qv1-xf2a.google.com with SMTP id j8so4634171qvt.13 for ; Sat, 01 Oct 2022 09:23:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=4bFcMUoE4kIp+2MWdZM5AsV1Ns0C4SweuGTMktPkM3A=; b=RmJrPXJWq/ozpee8FKrA5+CKrZFEc6P5gjFoLee1ET3rtcfkjbr9IEDLwCMC5LWfVZ +vdiwm/iiN+ET2ste4EwEkUtCGFbWuOLC+VlVc+uwhxfUxgMmlYPAclypK+XRcnjIXpc I5f3l+j3FKHsKhgJvWkD6+eSllHvCIY7JI1J9mkm4xtvdrug595RGc7bzQqqP0AkAL7C ecxcKq1UtgBKPCCa7qnQl9D+4WCHorv/c9zaa71V/sNGixlxyyWZZccuWhvjJRoCZ/LM MiDnTtoC0rZR7fWlwqzxap1pwop+YLFYSV9Z86V/Lv6HxlDQqlKnsog2s/KOP1sJPC7T x2dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=4bFcMUoE4kIp+2MWdZM5AsV1Ns0C4SweuGTMktPkM3A=; b=h6EvYrt3GZzpQqT4nbAt0GzR6bQ4lmbvAiMMIxFVwVKzrtHaFUj/epo+K8+o854VyS c6wq0hlMW5TeeIDFs8/NY4oUKHp43Q8UlERl/cOHhhVsRHG79pxrAqfbrHrwRsW+sSq2 jwiMMXbYw8Icxg7hI/UGep1qRp8aAElV3nsS+KmKnWviMoOIZYwgnw1mSquyMO/8j5qt 6CRZ5EfIloQTFOUN0FvGnBPdYLDePIocsTgamM6rZlX0XrhabVN/iDOKwmyg+zrIJ+mw rnwBCDBk+Vm+4xUzImlfl1doW2OyU7l7AfYaJBjDqgKhGmJeIr7T8t9Zrl3r/H4UGU37 4GpQ== X-Gm-Message-State: ACrzQf3i3hoV9AYg8b9pGBQNf0VmVh0h7lj+FTX39Fd/ELOQqcFe3mON qA08GL6XjS3+0q4pYifvojVQJOUCriwDVA== X-Received: by 2002:ad4:5966:0:b0:4ad:7832:a8ec with SMTP id eq6-20020ad45966000000b004ad7832a8ecmr11298393qvb.82.1664641437306; Sat, 01 Oct 2022 09:23:57 -0700 (PDT) Received: from stoup.. ([2605:ef80:8084:91a4:f7cb:db31:c505:b931]) by smtp.gmail.com with ESMTPSA id t4-20020a37ea04000000b006d1d8fdea8asm4387445qkj.85.2022.10.01.09.23.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Oct 2022 09:23:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell Subject: [PATCH v3 14/42] target/arm: Hoist read of *is_secure in S1_ptw_translate Date: Sat, 1 Oct 2022 09:22:50 -0700 Message-Id: <20221001162318.153420-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221001162318.153420-1-richard.henderson@linaro.org> References: <20221001162318.153420-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::f2a; envelope-from=richard.henderson@linaro.org; helo=mail-qv1-xf2a.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" Rename the argument to is_secure_ptr, and introduce a local variable is_secure with the value. We only write back to the pointer toward the end of the function. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/ptw.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 1ea29bec58..cb072792a2 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -207,24 +207,25 @@ static bool ptw_attrs_are_device(CPUARMState *env, ARMCacheAttrs cacheattrs) /* Translate a S1 pagetable walk through S2 if needed. */ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx, - hwaddr addr, bool *is_secure, + hwaddr addr, bool *is_secure_ptr, ARMMMUFaultInfo *fi) { - ARMMMUIdx s2_mmu_idx = *is_secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2; + bool is_secure = *is_secure_ptr; + ARMMMUIdx s2_mmu_idx = is_secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2; if (arm_mmu_idx_is_stage1_of_2(mmu_idx) && - !regime_translation_disabled(env, s2_mmu_idx, *is_secure)) { + !regime_translation_disabled(env, s2_mmu_idx, is_secure)) { GetPhysAddrResult s2 = {}; int ret; ret = get_phys_addr_lpae(env, addr, MMU_DATA_LOAD, s2_mmu_idx, - *is_secure, false, &s2, fi); + is_secure, false, &s2, fi); if (ret) { assert(fi->type != ARMFault_None); fi->s2addr = addr; fi->stage2 = true; fi->s1ptw = true; - fi->s1ns = !*is_secure; + fi->s1ns = !is_secure; return ~0; } if ((arm_hcr_el2_eff(env) & HCR_PTW) && @@ -237,19 +238,20 @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx, fi->s2addr = addr; fi->stage2 = true; fi->s1ptw = true; - fi->s1ns = !*is_secure; + fi->s1ns = !is_secure; return ~0; } if (arm_is_secure_below_el3(env)) { /* Check if page table walk is to secure or non-secure PA space. */ - if (*is_secure) { - *is_secure = !(env->cp15.vstcr_el2 & VSTCR_SW); + if (is_secure) { + is_secure = !(env->cp15.vstcr_el2 & VSTCR_SW); } else { - *is_secure = !(env->cp15.vtcr_el2 & VTCR_NSW); + is_secure = !(env->cp15.vtcr_el2 & VTCR_NSW); } + *is_secure_ptr = is_secure; } else { - assert(!*is_secure); + assert(!is_secure); } addr = s2.phys;