From patchwork Mon Feb 20 23:26:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 655147 Delivered-To: patch@linaro.org Received: by 2002:adf:9bcd:0:0:0:0:0 with SMTP id e13csp1661934wrc; Mon, 20 Feb 2023 15:29:17 -0800 (PST) X-Google-Smtp-Source: AK7set8WX4AM0ak/ZH6NWiFNdEJZL7Uu18ien22deVwUdSzjQAAHg+aS+218E3EJt0dYoIf2IqLl X-Received: by 2002:a05:622a:348:b0:3b5:2a7:b4f5 with SMTP id r8-20020a05622a034800b003b502a7b4f5mr20737652qtw.10.1676935756988; Mon, 20 Feb 2023 15:29:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676935756; cv=none; d=google.com; s=arc-20160816; b=IHJYrf7r4qKcTBBBvmqt09oyyO9R0YQmepKH11Ru2ezjIc47OyhkFCAFvRcftdHrkU h6M5pM4ktm+3Jg4XrAn5yf9aqsZTtoO9yBmhTGYlTQjEDRCXfh7UPBBimGnfSG6rlOMe ftbCOafS+zmIFX43Oj7k/olXsU4KdAlT2xiGvMDG4E3EApNVkI4OVN0FTDCGT/GfL77l bv2Fvj9VCET6GZBLLsJJPW7PHzkBmD9Vp769yk7Sk06Hi2h5TDXV4OqR6VPrDBsFvmd3 PvN5pRZ5Jz73tHlRQosOUVAKvKRqpE50Z5ZKEqZTY5S9req22l0CO8OI5byIU2JwMw1o f95A== 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=Hddjs2iU8lgJmQnwAvhIIZw97YOfc6Ski+WodJ2W4+A=; b=xD7ImEkcxDsglegFNqC3HjA9ZyBKW3AuXvYBKYrpxD87gGC1NE/WXUjPjSP9lorKZ+ phpkURbNjgcUmhskg+TsKi4SnzmYCluPX0GjQ+3c1BiBzPrj5ufk/6fyPkWGVCGomLc7 OjzDS6EYJImKioAG4D1GVb034QSMxGTyJXSAPAlikcrwAVlA3O0a5goe9kYfEYLPzvbo xxzqEEf0eXKE8FzYtiH7nWKVcqR7JhWXQyimqijMbQhS6eRNlgsJdZR8GBMh8/cVg/sj XHZKxss2bTn9xW6l2kpDGpbEY+YDEqngsrgkZus8CePWju4xZpro1APWRU8cU8VwEZyF juxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=V3BLRJTX; 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 c5-20020ac85a85000000b003b569f2ce62si10838996qtc.475.2023.02.20.15.29.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Feb 2023 15:29:16 -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=@linaro.org header.s=google header.b=V3BLRJTX; 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 1pUFYO-0003gy-31; Mon, 20 Feb 2023 18:26:40 -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 1pUFYK-0003ek-JI for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:26:37 -0500 Received: from mail-pj1-x1042.google.com ([2607:f8b0:4864:20::1042]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUFYI-0000HJ-Dh for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:26:36 -0500 Received: by mail-pj1-x1042.google.com with SMTP id cp9so3981687pjb.0 for ; Mon, 20 Feb 2023 15:26:34 -0800 (PST) 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 :message-id:reply-to; bh=Hddjs2iU8lgJmQnwAvhIIZw97YOfc6Ski+WodJ2W4+A=; b=V3BLRJTX8Qq4f7g5vSdXiAZvyvdi8X3Eg62l3jCCNzKLoJsTlQDsN9wnRdFOAXdBzp 96d8cZibJmYrzOAGpzEgn8AfvjAe9h+M6Z8Ny2JohJr4RR6UqB9uXGOOnqZiwzcgpt6o yOgaV4QDSCTXJwYHvacgXWIrXmoJ8HX4bMQWG/QoTRsbhGcC0b7RSyviT42G6QBrXNk8 B9f0g+7IV85ZxamXJUT7+5cA87MZsWlpFnPlHHfZlmMWmsygIveoei5/D68pw2M8BntV 4lb7NSLEpBdp3t3KNCDlxelZjf8kJ05puNjkr77mF4waqCag2qgm0fVIHzkQGo58Kzmc d/tQ== 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:message-id:reply-to; bh=Hddjs2iU8lgJmQnwAvhIIZw97YOfc6Ski+WodJ2W4+A=; b=5oDe8lFywDuV+Lzp69O6Brm5mi9KTwIxy1w36Cip45TpRNxiX9vevNCnXyShEmr9rR h/MjwmfyB9wbkCTpy3wqLDuSelpcdDA5LgF7NNYTxA3LxZqX6Bwk2iit6+XwpxW3FYyW hb93W1eJ979aA2vxS5mEaK2mA+gDUezmxOLXFv27L413RQQFZStoFHxUtyCJE/C93Fkl HaBWjvPJjtvGGjURNl/FU5M3VttfZ+7g1IBJEHKjbSs+grUPSuyfLfcCSVnzQt6WGeuJ osCHekgNq1coAkgMahDexKtPEhEUugBBgPbpvOD2PoxhJQUgaeSAmD2bG9icycl6zh7Z 9H3Q== X-Gm-Message-State: AO0yUKXuWOJPLjFX++dvklUNIWh2NPSzUA+KQA+30kcejLCrLEM4eD8H +G716dVtF67ua9t8mQ/G2aSfg62rMsynxmZYWDxhzg== X-Received: by 2002:a17:902:e547:b0:19a:abb0:1e with SMTP id n7-20020a170902e54700b0019aabb0001emr4473312plf.38.1676935592731; Mon, 20 Feb 2023 15:26:32 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id j10-20020a170902690a00b001992e74d058sm2665348plk.7.2023.02.20.15.26.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Feb 2023 15:26:32 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH v2 01/21] target/arm: Rewrite check_s2_mmu_setup Date: Mon, 20 Feb 2023 13:26:06 -1000 Message-Id: <20230220232626.429947-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220232626.429947-1-richard.henderson@linaro.org> References: <20230220232626.429947-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1042; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1042.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=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 Integrate neighboring code from get_phys_addr_lpae which computed starting level, as it is easier to validate when doing both at the same time. Mirror the checks at the start of AArch{64,32}.S2Walk, especially S2InvalidSL and S2InconsistentSL. This reverts 49ba115bb74, which was incorrect -- there is nothing in the ARM pseudocode that depends on TxSZ, i.e. outputsize; the pseudocode is consistent in referencing PAMax. Fixes: 49ba115bb74 ("target/arm: Pass outputsize down to check_s2_mmu_setup") Signed-off-by: Richard Henderson --- target/arm/ptw.c | 173 ++++++++++++++++++++++++++--------------------- 1 file changed, 97 insertions(+), 76 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 2b125fff44..6fb72fb086 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -1077,70 +1077,119 @@ static ARMVAParameters aa32_va_parameters(CPUARMState *env, uint32_t va, * check_s2_mmu_setup * @cpu: ARMCPU * @is_aa64: True if the translation regime is in AArch64 state - * @startlevel: Suggested starting level - * @inputsize: Bitsize of IPAs + * @tcr: VTCR_EL2 or VSTCR_EL2 + * @ds: Effective value of TCR.DS. + * @iasize: Bitsize of IPAs * @stride: Page-table stride (See the ARM ARM) * - * Returns true if the suggested S2 translation parameters are OK and - * false otherwise. + * Decode the starting level of the S2 lookup, returning INT_MIN if + * the configuration is invalid. */ -static bool check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, int level, - int inputsize, int stride, int outputsize) +static int check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, uint64_t tcr, + bool ds, int iasize, int stride) { - const int grainsize = stride + 3; - int startsizecheck; - - /* - * Negative levels are usually not allowed... - * Except for FEAT_LPA2, 4k page table, 52-bit address space, which - * begins with level -1. Note that previous feature tests will have - * eliminated this combination if it is not enabled. - */ - if (level < (inputsize == 52 && stride == 9 ? -1 : 0)) { - return false; - } - - startsizecheck = inputsize - ((3 - level) * stride + grainsize); - if (startsizecheck < 1 || startsizecheck > stride + 4) { - return false; - } + int sl0, sl2, startlevel, granulebits, levels; + int s1_min_iasize, s1_max_iasize; + sl0 = extract32(tcr, 6, 2); if (is_aa64) { + /* + * AArch64.S2InvalidTxSZ: While we checked tsz_oob near the top of + * get_phys_addr_lpae, that used aa64_va_parameters which apply + * to aarch64. If Stage1 is aarch32, the min_txsz is larger. + * See AArch64.S2MinTxSZ, where min_tsz is 24, translated to + * inputsize is 64 - 24 = 40. + */ + if (iasize < 40 && !arm_el_is_aa64(&cpu->env, 1)) { + goto fail; + } + + /* + * AArch64.S2InvalidSL: Interpretation of SL depends on the page size, + * so interleave AArch64.S2StartLevel. + */ switch (stride) { - case 13: /* 64KB Pages. */ - if (level == 0 || (level == 1 && outputsize <= 42)) { - return false; + case 9: /* 4KB */ + /* SL2 is RES0 unless DS=1 & 4KB granule. */ + sl2 = extract64(tcr, 33, 1); + if (ds && sl2) { + if (sl0 != 0) { + goto fail; + } + startlevel = -1; + } else { + startlevel = 2 - sl0; + switch (sl0) { + case 2: + if (arm_pamax(cpu) < 44) { + goto fail; + } + break; + case 3: + if (!cpu_isar_feature(aa64_st, cpu)) { + goto fail; + } + startlevel = 3; + break; + } } break; - case 11: /* 16KB Pages. */ - if (level == 0 || (level == 1 && outputsize <= 40)) { - return false; + case 11: /* 16KB */ + switch (sl0) { + case 2: + if (arm_pamax(cpu) < 42) { + goto fail; + } + break; + case 3: + if (!ds) { + goto fail; + } + break; } + startlevel = 3 - sl0; break; - case 9: /* 4KB Pages. */ - if (level == 0 && outputsize <= 42) { - return false; + case 13: /* 64KB */ + switch (sl0) { + case 2: + if (arm_pamax(cpu) < 44) { + goto fail; + } + break; + case 3: + goto fail; } + startlevel = 3 - sl0; break; default: g_assert_not_reached(); } - - /* Inputsize checks. */ - if (inputsize > outputsize && - (arm_el_is_aa64(&cpu->env, 1) || inputsize > 40)) { - /* This is CONSTRAINED UNPREDICTABLE and we choose to fault. */ - return false; - } } else { - /* AArch32 only supports 4KB pages. Assert on that. */ + /* + * Things are simpler for AArch32 EL2, with only 4k pages. + * There is no separate S2InvalidSL function, but AArch32.S2Walk + * begins with walkparms.sl0 in {'1x'}. + */ assert(stride == 9); - - if (level == 0) { - return false; + if (sl0 >= 2) { + goto fail; } + startlevel = 2 - sl0; } - return true; + + /* AArch{64,32}.S2InconsistentSL are functionally equivalent. */ + levels = 3 - startlevel; + granulebits = stride + 3; + + s1_min_iasize = levels * stride + granulebits + 1; + s1_max_iasize = s1_min_iasize + (stride - 1) + 4; + + if (iasize >= s1_min_iasize && iasize <= s1_max_iasize) { + return startlevel; + } + + fail: + return INT_MIN; } /** @@ -1296,38 +1345,10 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, */ level = 4 - (inputsize - 4) / stride; } else { - /* - * For stage 2 translations the starting level is specified by the - * VTCR_EL2.SL0 field (whose interpretation depends on the page size) - */ - uint32_t sl0 = extract32(tcr, 6, 2); - uint32_t sl2 = extract64(tcr, 33, 1); - int32_t startlevel; - bool ok; - - /* SL2 is RES0 unless DS=1 & 4kb granule. */ - if (param.ds && stride == 9 && sl2) { - if (sl0 != 0) { - level = 0; - goto do_translation_fault; - } - startlevel = -1; - } else if (!aarch64 || stride == 9) { - /* AArch32 or 4KB pages */ - startlevel = 2 - sl0; - - if (cpu_isar_feature(aa64_st, cpu)) { - startlevel &= 3; - } - } else { - /* 16KB or 64KB pages */ - startlevel = 3 - sl0; - } - - /* Check that the starting level is valid. */ - ok = check_s2_mmu_setup(cpu, aarch64, startlevel, - inputsize, stride, outputsize); - if (!ok) { + int startlevel = check_s2_mmu_setup(cpu, aarch64, tcr, param.ds, + inputsize, stride); + if (startlevel == INT_MIN) { + level = 0; goto do_translation_fault; } level = startlevel; From patchwork Mon Feb 20 23:26:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 655145 Delivered-To: patch@linaro.org Received: by 2002:adf:9bcd:0:0:0:0:0 with SMTP id e13csp1661846wrc; Mon, 20 Feb 2023 15:29:04 -0800 (PST) X-Google-Smtp-Source: AK7set9Ahf/Wu46jqDkLYQ5j+2PLWfP9Wqn+PpbINNKzWMkf12/wXCDazT4i3JjkPTrxMiwdCUEu X-Received: by 2002:ad4:5ba2:0:b0:56b:ea0b:3bb0 with SMTP id 2-20020ad45ba2000000b0056bea0b3bb0mr3915207qvq.26.1676935744203; Mon, 20 Feb 2023 15:29:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676935744; cv=none; d=google.com; s=arc-20160816; b=imyynZt4VsGCcO8BDMKENYzXizcLEbEkzjIXjpbjGWlFlA8kIVWkEuAmltyhn7NDd2 r70v7lk+OdWT/6RlweVqlSnUU3lk/Hgv8CawqMDE1mexm1QOD4Z7cs8AK51P1HEt6YdJ bIXiJHg2T61X3oaxRQlztC4enxC5WBdVDtKKDMWDHhlM15Xmd6VS2eVNby5tfIli5rK6 p3k77dOpg78qpzogCTvzr88XxTlEWPpxcdJzwhPSki4E/SUHZMjz2xmL/5I6Xfb/K+Ho u/u2Zc8SCW8o3MWa6XY4Ap82fiZukkiFsXzvDyN/Kfmq6OVlZtPV3CKfwywLL9QfCseT 9FYA== 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=6Qu5gxD3YQ1g3NpmrFTN+XCbNU1pC9zMqzEJSxEiZBE=; b=b5uX0BA+r1NObas+lbUeYW4/nFzkTzyRguNWfhtlrMBDuoKjEWxLJfpOr6S7Ca1Q5e TTWbKNhhsQiM1v5rCC6qZ+KibNf2+fmtCO4MsT9rOCFtkjrS7nwYbdupUPLekw66XVon 1PXmyNFxqza2JHOWPrcIdKt18/pWzP+ZLBT46A8O5Xw9+BNCbz3nSfd/arxIUvnJDL/r DtlwmD3gpW1OGrg/zO3D07IKTmq0pcgld3sPZUGty4L0FBFZhIATB+mU2N+xZoB2KPL1 xtNw5zzIzdKmGuz+CkIJWYVoCX2IaJTQUac+kLkm5kPZCimmdezMypcJPQyFSM8g4GL6 phsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EKXdduJe; 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 a23-20020a0ca997000000b0056eb364bd43si5073063qvb.429.2023.02.20.15.29.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Feb 2023 15:29:04 -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=@linaro.org header.s=google header.b=EKXdduJe; 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 1pUFYO-0003hQ-IO; Mon, 20 Feb 2023 18:26:40 -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 1pUFYL-0003fc-Tu for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:26:37 -0500 Received: from mail-pj1-x1041.google.com ([2607:f8b0:4864:20::1041]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUFYK-0000IO-Bs for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:26:37 -0500 Received: by mail-pj1-x1041.google.com with SMTP id g14so2820759pjb.2 for ; Mon, 20 Feb 2023 15:26:35 -0800 (PST) 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 :message-id:reply-to; bh=6Qu5gxD3YQ1g3NpmrFTN+XCbNU1pC9zMqzEJSxEiZBE=; b=EKXdduJeENkKGmYARPZuvL7nQxI2Igm3uWPxBmFsncScgp1LYpRiQvYefGiokIeWv9 VJiqZ2J1057wvZTcK9Wff9gKkILwnI6eoIcSg5rUYys6wGUImYnfCZzm6cvICMT32ogE 8WV6zKCfXKrm/PdPiMw0+ypn9Qi3ZxzFcpSdMO7BcNpgUbij4PMIWxC81tsdp2mVBfIe ARHw83iUwVNO2FXYicNeoR2/X68BDhgBpjuqkQVolv8PIOA9KN+hA9V+maoDh8P9lEO5 iBV3GUhrzGsxDK05drysVBP64AiDCmjGaavFadgxb6o/8NGN0lMyZf0TG+69g0s2S9d6 NCzw== 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:message-id:reply-to; bh=6Qu5gxD3YQ1g3NpmrFTN+XCbNU1pC9zMqzEJSxEiZBE=; b=He+/Q5wzPJ2uetH8xbOXRaURrJFYoxsxOYjBlq506sBdAn3ug3ck/Lr6ZKKdFuBr8S 8YzO7+ad35CwL2DTwImApMrdJztiMqgmpDRFOJ2RYP1fyTxNurG0tZDzA6YJ5QhTUZJl rrKcWwPMT1oKI/p7fMXuJ/THdTosjzCBTzyz/aju0zFsu3w8g5rSLFIW6eSiUzEMPXD1 61D6g0+5g2M26hy2Pr6RR7T5rFvWriFR3uK5OvpA+ErcV8dINfPvOL/3uEwEKvsaFjgd wpJD5M0WABWlPO5BFrVYaCB1etIfMw43tvhqbmsk4x05UxB2GNw/uzitT+eV8wSH+LTm oG0g== X-Gm-Message-State: AO0yUKXTxUd3gnlWrnwSe4YgtMrW/Y9+eaXVV91y8UbR1OIGdaLrr7Cz DvU2YnXrBlimEeQ2NWIVWsRxZoQLiZ7rdFsqjLweJw== X-Received: by 2002:a17:902:cf46:b0:199:1682:9175 with SMTP id e6-20020a170902cf4600b0019916829175mr3264866plg.8.1676935594414; Mon, 20 Feb 2023 15:26:34 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id j10-20020a170902690a00b001992e74d058sm2665348plk.7.2023.02.20.15.26.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Feb 2023 15:26:33 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell Subject: [PATCH v2 02/21] target/arm: Add isar_feature_aa64_rme Date: Mon, 20 Feb 2023 13:26:07 -1000 Message-Id: <20230220232626.429947-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220232626.429947-1-richard.henderson@linaro.org> References: <20230220232626.429947-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1041; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1041.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 Add the missing field for ID_AA64PFR0, and the predicate. Disable it if EL3 is forced off by the board or command-line. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/cpu.h | 6 ++++++ target/arm/cpu.c | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 12b1082537..04f000cc54 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -2190,6 +2190,7 @@ FIELD(ID_AA64PFR0, SEL2, 36, 4) FIELD(ID_AA64PFR0, MPAM, 40, 4) FIELD(ID_AA64PFR0, AMU, 44, 4) FIELD(ID_AA64PFR0, DIT, 48, 4) +FIELD(ID_AA64PFR0, RME, 52, 4) FIELD(ID_AA64PFR0, CSV2, 56, 4) FIELD(ID_AA64PFR0, CSV3, 60, 4) @@ -3802,6 +3803,11 @@ static inline bool isar_feature_aa64_sel2(const ARMISARegisters *id) return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, SEL2) != 0; } +static inline bool isar_feature_aa64_rme(const ARMISARegisters *id) +{ + return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, RME) != 0; +} + static inline bool isar_feature_aa64_vh(const ARMISARegisters *id) { return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, VH) != 0; diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 876ab8f3bf..83685ed247 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1947,6 +1947,10 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) cpu->isar.id_dfr0 = FIELD_DP32(cpu->isar.id_dfr0, ID_DFR0, COPSDBG, 0); cpu->isar.id_aa64pfr0 = FIELD_DP64(cpu->isar.id_aa64pfr0, ID_AA64PFR0, EL3, 0); + + /* Disable the realm management extension, which requires EL3. */ + cpu->isar.id_aa64pfr0 = FIELD_DP64(cpu->isar.id_aa64pfr0, + ID_AA64PFR0, RME, 0); } if (!cpu->has_el2) { From patchwork Mon Feb 20 23:26:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 655136 Delivered-To: patch@linaro.org Received: by 2002:adf:9bcd:0:0:0:0:0 with SMTP id e13csp1661511wrc; Mon, 20 Feb 2023 15:27:55 -0800 (PST) X-Google-Smtp-Source: AK7set+e9Xq5rROWJGh3mt7gEchkHDiPjSKT2TfCxaH/XeHjH0VdcbOUJ0GX3zuSqe6uysuPT76y X-Received: by 2002:ad4:4ea2:0:b0:56e:abf3:91c0 with SMTP id ed2-20020ad44ea2000000b0056eabf391c0mr7206093qvb.28.1676935675767; Mon, 20 Feb 2023 15:27:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676935675; cv=none; d=google.com; s=arc-20160816; b=sBW9nklm3dDkgNDc8KSOrSMmsqxiQrATB/KUWHHQEjLkXHIPLb5xbX0Oe+V6v1aTdJ 4f1+QayNgejtflHwmjTUEmJK/DfbRT/YKpcCUWHeVw0TzJP/SUnJI1Ywc9VmsymwI2QO hcv6lBwPV1H6W9EwPJqpeTQoTXcIQaNJ0PyV0UllSZTGUEN7kRCxeSQ4+sAFe63FhPTc jY2uK36WjmSJZs49jv32j2s8B6uN3hR5WZy+e92xrpEIgD/8NmM1eY+CPOR6FKob5vhT bC+3IE3Pu1bdBvxuFqsy07Si9uuJKoGGCw1pimEDqS+C37E7m1RRjzVZUFXyXDpycKVM EstQ== 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=hZ5RT1U0BG9RauOmNkX+PjAfe5FY1kHSfa1bLxVuTYM=; b=Yd87tuGeonYa/WK1wCpuX6DiJh3UgAXkII0ik+YWm7azYF54I2QZQBCp5LZnwFXycg mawuIvCksspzg5PVGkQ2FjnDlDpNIFt4gVLdxDxnejA3Ij2igD7t6zWh815hug51GFLI wB3pdVumYd6/ejw35kn4YCHJJa85sYT6sUpvcYzu/L4tbYwsMjiV5AS9qQ97Y69T3UEX BEAGB0tZY8kHEhO0IMege89YF3k6gbDSpck/Xbj6awaBzKxOcWfVUw+EQ7C6LCTXsIOz 0lkYjNsWKJFIxlhw2rfv+T9FAUSkDfkv5irSj+WIeUMhWcW0xd1RJOA2hD3JZosoo38B ntHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=E2OkhAs2; 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 x16-20020a0cda10000000b0056bf9b4f42fsi10646185qvj.390.2023.02.20.15.27.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Feb 2023 15:27:55 -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=@linaro.org header.s=google header.b=E2OkhAs2; 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 1pUFYP-0003jH-Iv; Mon, 20 Feb 2023 18:26:41 -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 1pUFYN-0003fz-Es for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:26:39 -0500 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUFYL-0000Ik-7g for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:26:39 -0500 Received: by mail-pj1-x1033.google.com with SMTP id co23-20020a17090afe9700b002341fadc370so2882801pjb.1 for ; Mon, 20 Feb 2023 15:26:36 -0800 (PST) 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 :message-id:reply-to; bh=hZ5RT1U0BG9RauOmNkX+PjAfe5FY1kHSfa1bLxVuTYM=; b=E2OkhAs2HCKxNlV+9SVLVsK/KuBKP8cJAZXpzrPE21cl4xOpbpBS7Mg5sfPF1fVoBQ VWlNC5Gz0VEte2zKHbBJF2kyDiimS5TDzla/7U+Ra963vRvZ9KmIKZ45GBflYf7dQoxC tQu6PIxDFq4AveWjokaxrneVHwcmTZdCRCO+Yr8Spj/opVkxrsNgGijsOUL5/Tfd5nZw M84mtPP+cLM2nRxKKPd5+KXmpNqPx0EKV43p5/em1uJehucCzU8wdavXA35jrKKEo5Fx +TgvfPIJRan0+s5jzXAg4S6EsKf3G6WnlTSPZRzticvtBXko9XtvJCtdQxkDqPRt0Xt5 Fyzg== 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:message-id:reply-to; bh=hZ5RT1U0BG9RauOmNkX+PjAfe5FY1kHSfa1bLxVuTYM=; b=JPOa7ScbWPw54a+tD2Cc0+xvUhme+/Xg6WOIeoO/K4YL9M0fmn6kKj7GhIvqL1KzMy 8pB9Q1KXKKdO7RwYndteOWzwVf4Xod4Hbrn8HNeo5ksW1InCm/h5hoXlWFZdOOGOsgxW 19zi4+SPrbl3RwDpO/7ahLkIScpycFNoTiDpf4lokE7hTeGbiobWq4MpCBQGqcamidIO h7GhUCs4JsnT2sGNJ3b1ZD96Um/3R/T4Mk2xucLqh5go2eq//3YTav5PXGDID0VvXzVp 1S3TDv/vz8W4DMyXgAusabxIp+4MltfhBx84Bp+VfLSRP2MoNZPlyg6p/lsy9jqHoFSi MhTQ== X-Gm-Message-State: AO0yUKX/JkG8iEFO7iKrrt/UX6lm6yy5k8TgtqHRTZ8eEryX1tGwvjQC x7pmJlHnwcTW9bfKbo1lpuf7ojx6B4Wcrvh8xD0= X-Received: by 2002:a17:903:2291:b0:19b:33c0:4092 with SMTP id b17-20020a170903229100b0019b33c04092mr3327416plh.24.1676935595910; Mon, 20 Feb 2023 15:26:35 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id j10-20020a170902690a00b001992e74d058sm2665348plk.7.2023.02.20.15.26.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Feb 2023 15:26:35 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell Subject: [PATCH v2 03/21] target/arm: Update SCR and HCR for RME Date: Mon, 20 Feb 2023 13:26:08 -1000 Message-Id: <20230220232626.429947-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220232626.429947-1-richard.henderson@linaro.org> References: <20230220232626.429947-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1033; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1033.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 Define the missing SCR and HCR bits, allow SCR_NSE and {SCR,HCR}_GPF to be set, and invalidate TLBs when NSE changes. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/cpu.h | 5 +++-- target/arm/helper.c | 10 ++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 04f000cc54..486baf3924 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1650,7 +1650,7 @@ static inline void xpsr_write(CPUARMState *env, uint32_t val, uint32_t mask) #define HCR_TERR (1ULL << 36) #define HCR_TEA (1ULL << 37) #define HCR_MIOCNCE (1ULL << 38) -/* RES0 bit 39 */ +#define HCR_TME (1ULL << 39) #define HCR_APK (1ULL << 40) #define HCR_API (1ULL << 41) #define HCR_NV (1ULL << 42) @@ -1659,7 +1659,7 @@ static inline void xpsr_write(CPUARMState *env, uint32_t val, uint32_t mask) #define HCR_NV2 (1ULL << 45) #define HCR_FWB (1ULL << 46) #define HCR_FIEN (1ULL << 47) -/* RES0 bit 48 */ +#define HCR_GPF (1ULL << 48) #define HCR_TID4 (1ULL << 49) #define HCR_TICAB (1ULL << 50) #define HCR_AMVOFFEN (1ULL << 51) @@ -1724,6 +1724,7 @@ static inline void xpsr_write(CPUARMState *env, uint32_t val, uint32_t mask) #define SCR_TRNDR (1ULL << 40) #define SCR_ENTP2 (1ULL << 41) #define SCR_GPF (1ULL << 48) +#define SCR_NSE (1ULL << 62) #define HSTR_TTEE (1 << 16) #define HSTR_TJDBX (1 << 17) diff --git a/target/arm/helper.c b/target/arm/helper.c index 07d4100365..42d94e0904 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -1875,6 +1875,9 @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) if (cpu_isar_feature(aa64_fgt, cpu)) { valid_mask |= SCR_FGTEN; } + if (cpu_isar_feature(aa64_rme, cpu)) { + valid_mask |= SCR_NSE | SCR_GPF; + } } else { valid_mask &= ~(SCR_RW | SCR_ST); if (cpu_isar_feature(aa32_ras, cpu)) { @@ -1904,10 +1907,10 @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) env->cp15.scr_el3 = value; /* - * If SCR_EL3.NS changes, i.e. arm_is_secure_below_el3, then + * If SCR_EL3.{NS,NSE} changes, i.e. change of security state, * we must invalidate all TLBs below EL3. */ - if (changed & SCR_NS) { + if (changed & (SCR_NS | SCR_NSE)) { tlb_flush_by_mmuidx(env_cpu(env), (ARMMMUIdxBit_E10_0 | ARMMMUIdxBit_E20_0 | ARMMMUIdxBit_E10_1 | @@ -5655,6 +5658,9 @@ static void do_hcr_write(CPUARMState *env, uint64_t value, uint64_t valid_mask) if (cpu_isar_feature(aa64_fwb, cpu)) { valid_mask |= HCR_FWB; } + if (cpu_isar_feature(aa64_rme, cpu)) { + valid_mask |= HCR_GPF; + } } if (cpu_isar_feature(any_evt, cpu)) { From patchwork Mon Feb 20 23:26:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 655137 Delivered-To: patch@linaro.org Received: by 2002:adf:9bcd:0:0:0:0:0 with SMTP id e13csp1661563wrc; Mon, 20 Feb 2023 15:28:03 -0800 (PST) X-Google-Smtp-Source: AK7set+ijlrXI6p3ZgL2Kx5+13P8KW7QICRYJVI5UyuRF+GCoH6vzgEM0ocfFM2fJtvM40EA/xut X-Received: by 2002:a05:6214:248c:b0:56e:99f2:1b91 with SMTP id gi12-20020a056214248c00b0056e99f21b91mr3663364qvb.23.1676935683832; Mon, 20 Feb 2023 15:28:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676935683; cv=none; d=google.com; s=arc-20160816; b=ZCByUc3FR8wP2TH6+xWMqWpArajp6bkDYC0VyHR0x9MyxUtSMuBVB9AfKIPSFhBlOg U0LODU5st20AEO+uJJ6fpClCLPF7H0GAFFKC52cmlmq5o2vX17DVo8OufnETNx1Axu4J Jazvrso6u1sqIaiFCT5FmEjdZBCGzaHdnfrYiBOdQnJ6y2pT8z1h981/M6PSjXyI73yR bvnjGGLlVONuFBFWfTuvoRLISaL6bD2jfBV96OkAi+Tsja0p8KRy1qOUJXOu5Y+yzxRq MgLIvEHlWMAH2Cjp4sDvo+mjdPnIkp+0JPWdNSPDUvxHUnKnw+6Uf0saxhwN3hcs6gmk SQzQ== 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=mH7WMawWeBvYR6Z0Haoxdyec8KWtOPSKDJkaIsK10I4=; b=NXIFPriXyfkl/LogO01cIyUKyP/tOTBnjlS9LSabLx9Xx5JyEzMwf6qTo5MFccxyym k923QENqjn8AQvbo/1X3em7FsNbu+OazDLNbR07/M+pKRvqTIfchkfa61wlcTCq/0Xff KAVZuZuC3MsG8YPC1dliumKqgDk461TAl1wmd3OSbwFJJblg/YeQZ9NPWKEDMAUw8s9U g7kMqnkpNuM5RAigLJSJbYSJLnyPoFTiO4jFO5vfPC1DdhjcT0/uG7kZI2WFiUtDvmDn ANmKL1Jg4n/9HuqM6b0eb62wzpTx5k7rAT+RnmY0Z6LdcGtfc5G09g/g1USKg8FLJE9H YElg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nvVlE274; 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 dm38-20020a05620a1d6600b006fca83b669dsi10251523qkb.61.2023.02.20.15.28.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Feb 2023 15:28:03 -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=@linaro.org header.s=google header.b=nvVlE274; 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 1pUFYQ-0003jT-2H; Mon, 20 Feb 2023 18:26:42 -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 1pUFYO-0003hz-NU for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:26:40 -0500 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUFYN-0000JI-30 for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:26:40 -0500 Received: by mail-pj1-x1029.google.com with SMTP id o16so2898252pjp.3 for ; Mon, 20 Feb 2023 15:26:38 -0800 (PST) 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 :message-id:reply-to; bh=mH7WMawWeBvYR6Z0Haoxdyec8KWtOPSKDJkaIsK10I4=; b=nvVlE274/tK3ExBcRxUCRMfxZtDgtaXLidNuM/h88+aFHH42rv7txuXLvJPi9QU3wp ST3DgC+FuSc9yh1ld89cVh8o5MzK4ChA+tekjIZtUTZMgjePQEXcsVExbfOk3wkgPjR6 szfXtyxk6/gBYsYUgJhNnK74rj5n2OMRlsp2ByKYR3+j4/3oYY3a33LB5HlZfmd7CttQ E19d0y8QLxc+Fn6AGFhR5OgB395ccd2I0JvbuZ+yg5OjyDEIqzQow16l2Sgu/dW6gC9+ NDl6gvlS0FYXm5FpT++5WMa/v32hP4GbcesMDaNh/Zv5vsQj2dfTAMasFn6EBUjGaEgU ev0Q== 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:message-id:reply-to; bh=mH7WMawWeBvYR6Z0Haoxdyec8KWtOPSKDJkaIsK10I4=; b=ldRfqjNF6JHUuZdgD9R7b82vObrJDTHuAubhrEBCGk18t+5VOVIiwdme31wD8sZzHl jmnHYMDRs2yMKmyMCysD0wCCtlYTZvOPYB+f+DMTOnXxOI8pFLF4Rm9PDYgVHpjowHhN d5HqgecPFinvYkJllL4i69VYLngr4LVGMprSYkMUUyrboat62qUcqqfWm74sg3yonJVd rUzcfLnk3sJEijzgBYDaFrDiLNwEOdPZxa8vhHpbwhRzwV9UYtOB09m5B5V0Gkvadyve zkjRTBEZhsdtLKqxeXkI1F+RvQCOwRhXgFC/SGvVLrxppTryOTd2qmDzY18eBpHwHun1 vShQ== X-Gm-Message-State: AO0yUKUTiBPeKwDsQKOXqmVvS2X0FtX+iN8CTqGhD+8/2KFgggSjD04H fO96LqOlHc+GxKJPHfB7OflD249ZnWQdj3KdrE0= X-Received: by 2002:a17:903:2808:b0:19a:ea48:730c with SMTP id kp8-20020a170903280800b0019aea48730cmr1919079plb.46.1676935597252; Mon, 20 Feb 2023 15:26:37 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id j10-20020a170902690a00b001992e74d058sm2665348plk.7.2023.02.20.15.26.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Feb 2023 15:26:36 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH v2 04/21] target/arm: SCR_EL3.NS may be RES1 Date: Mon, 20 Feb 2023 13:26:09 -1000 Message-Id: <20230220232626.429947-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220232626.429947-1-richard.henderson@linaro.org> References: <20230220232626.429947-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1029; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1029.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 With RME, SEL2 must also be present to support secure state. The NS bit is RES1 if SEL2 is not present. Signed-off-by: Richard Henderson --- target/arm/helper.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/arm/helper.c b/target/arm/helper.c index 42d94e0904..2ebca3e2b6 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -1856,6 +1856,9 @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) } if (cpu_isar_feature(aa64_sel2, cpu)) { valid_mask |= SCR_EEL2; + } else if (cpu_isar_feature(aa64_rme, cpu)) { + /* With RME and without SEL2, NS is RES1 (R_GSWWH, I_DJJQJ). */ + value |= SCR_NS; } if (cpu_isar_feature(aa64_mte, cpu)) { valid_mask |= SCR_ATA; From patchwork Mon Feb 20 23:26:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 655142 Delivered-To: patch@linaro.org Received: by 2002:adf:9bcd:0:0:0:0:0 with SMTP id e13csp1661735wrc; Mon, 20 Feb 2023 15:28:44 -0800 (PST) X-Google-Smtp-Source: AK7set/HJRwpjGPAowooO4CI+uhZ9c0wwOFtdgILdgHUxRsLcmv3or9+rNVQ52kdSvkdLwJO/FgH X-Received: by 2002:ad4:5c84:0:b0:56e:f9a2:3eba with SMTP id o4-20020ad45c84000000b0056ef9a23ebamr5221204qvh.41.1676935723959; Mon, 20 Feb 2023 15:28:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676935723; cv=none; d=google.com; s=arc-20160816; b=QUA5C0Mj0DRas0F0BRqjjY6fwWUHVwZwMf1y7bDsGjg3AFYZb+dsliwcpxsJZWjOyo oEutW39ukCyeqX9NVshDxam1sCa9q6j/6rbOb+G/h0WRl4is8rGAtzn+psVfwZEdKqia x2CBMzVVpOLkDO4BGuki8zbeOY9Fp8dAoTSKoid7tJijU7+XyWfmjzAFbbrVvfPH8xwm fstBpEhh2UDhw6dPKY8bL00myGmHZsXUtvUdtc7+XzyrBW74Ityu+fKyuORSa9/FRSm8 l1iT7TCpujI0EzwiUVymDbcZ5MXdnU0vtP5CauEkRTH6EQMdCQ5an9HWbde7GV32/tzS VGbw== 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=kl7nsc9p6BIDSk+FSIUoP/kFXINcnp5gsZ8dnkbWdwU=; b=hZdSI325N5lz/fjMr4kN8fpO4OZBvdnmTB4Sy0R7cMHTXE84+jisbsxlsw2UMiSHnp EQEda/xGGt6HdZLN5ZRSBasGePz/QxDesELz+kvIMqfrd0Fy/Os8lNBH0AFuVmFwsIY2 UJNZ+IFW6Ju2oza6x4Yoe0scRsUUuQ5tibX7dNwpCr2nMat/m21DozR0KnSnHzL9K4iH MSHFDf3HXwcIddDGugOX9+MqP7+BYoLd3YUDRYg6ZMeS6szfzUtqorEaYUyOVCbjlb8P xEO/zNzQlxWt7UdxnhJQyDvCvHtXx9TGdSg+tREZDWtkYcgjP052+lMvCIP2GKks8uo9 APdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Px0cV/J3"; 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 az11-20020a05620a170b00b0071c5429ce79si10796509qkb.743.2023.02.20.15.28.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Feb 2023 15:28:43 -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=@linaro.org header.s=google header.b="Px0cV/J3"; 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 1pUFYR-0003lv-8S; Mon, 20 Feb 2023 18:26:43 -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 1pUFYQ-0003k7-Dd for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:26:42 -0500 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUFYO-0000Jl-Jo for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:26:42 -0500 Received: by mail-pj1-x102c.google.com with SMTP id g14so2820879pjb.2 for ; Mon, 20 Feb 2023 15:26:40 -0800 (PST) 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 :message-id:reply-to; bh=kl7nsc9p6BIDSk+FSIUoP/kFXINcnp5gsZ8dnkbWdwU=; b=Px0cV/J3cA5nxUSIyPH4WmDlrGXHRfWGHBHPLb9gDVPzqc5DzcQKJSyzqE9QlLI+KI MP0WilTKdLe3pXXIH00HYQMyLsx62Pkqwk6Y/a1VB8bKZpfoW7Bizazr8jZyFSj1hq6E ASiaiGbPrGXVTacms4f97QAVgpX0FOiK7uTEzf/O7O6hgzlAo4w3JO1TwflpHZIYew6h yICHGIc4nhDV/KSmGXZXjCaqbpkBKNmpArxqGPrBv4FQy+j/U1cr+O25W87Znir7OezD 6WLLXy02d05orj0R+erfCvNimihBA7U8BBPh4y3xIYrv5aXNr7uAJtTLWTEX1Ok7JS/i 1+uw== 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:message-id:reply-to; bh=kl7nsc9p6BIDSk+FSIUoP/kFXINcnp5gsZ8dnkbWdwU=; b=PC5wWMlxetl122Buf3Vbf72iPYj+p0/4b7bMnJ5s9q9mIXBwy1wexqAAasoSvc9LH6 gRe5Md8G+rAZAWO07lMd9fmLzVa07dc+PcqYx2ZnClBqs0F16lPsDHIIcmcXyHIErLwn xSSoO/RSgShkll1Lbr9FpQnJssGkEZsXYFtVrvmHzzkHObLZ39yo9oTe/w9IQ6759tkC B8wxozJiY2woENNmMX36Ne9JGYz+qDLYf5tqqZj0eRm5Ez3aMmKWoM+pOMWwWtu/T4l5 j4ZtQ15y1pPyILxgmEB7JTNnhMifMZOb8WeqoDd0/lVBWmWaKSN0ga/le7/DRmF13R4r EcGg== X-Gm-Message-State: AO0yUKX6UfbgJnXUpOzFlIA0CBpRMF75VtnTQu7lkqzAOlYCvQlzFdIw DvB8MuR7yS8bZ3iaYCuHV9t6IFramAcHU+EaUT4= X-Received: by 2002:a17:902:d4cc:b0:19b:dc8:c67b with SMTP id o12-20020a170902d4cc00b0019b0dc8c67bmr2462597plg.50.1676935598836; Mon, 20 Feb 2023 15:26:38 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id j10-20020a170902690a00b001992e74d058sm2665348plk.7.2023.02.20.15.26.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Feb 2023 15:26:38 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell Subject: [PATCH v2 05/21] target/arm: Add RME cpregs Date: Mon, 20 Feb 2023 13:26:10 -1000 Message-Id: <20230220232626.429947-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220232626.429947-1-richard.henderson@linaro.org> References: <20230220232626.429947-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102c.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 This includes GPCCR, GPTBR, MFAR, the TLB flush insns PAALL, PAALLOS, RPALOS, RPAOS, and the cache flush insns CIPAPA and CIGDPAPA. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/cpu.h | 19 +++++++++++ target/arm/helper.c | 83 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 486baf3924..6a97c727d1 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -541,6 +541,11 @@ typedef struct CPUArchState { uint64_t fgt_read[2]; /* HFGRTR, HDFGRTR */ uint64_t fgt_write[2]; /* HFGWTR, HDFGWTR */ uint64_t fgt_exec[1]; /* HFGITR */ + + /* RME registers */ + uint64_t gpccr_el3; + uint64_t gptbr_el3; + uint64_t mfar_el3; } cp15; struct { @@ -1043,6 +1048,7 @@ struct ArchCPU { uint64_t reset_cbar; uint32_t reset_auxcr; bool reset_hivecs; + uint8_t reset_l0gptsz; /* * Intermediate values used during property parsing. @@ -2336,6 +2342,19 @@ FIELD(MVFR1, SIMDFMAC, 28, 4) FIELD(MVFR2, SIMDMISC, 0, 4) FIELD(MVFR2, FPMISC, 4, 4) +FIELD(GPCCR, PPS, 0, 3) +FIELD(GPCCR, IRGN, 8, 2) +FIELD(GPCCR, ORGN, 10, 2) +FIELD(GPCCR, SH, 12, 2) +FIELD(GPCCR, PGS, 14, 2) +FIELD(GPCCR, GPC, 16, 1) +FIELD(GPCCR, GPCP, 17, 1) +FIELD(GPCCR, L0GPTSZ, 20, 4) + +FIELD(MFAR, FPA, 12, 40) +FIELD(MFAR, NSE, 62, 1) +FIELD(MFAR, NS, 63, 1) + QEMU_BUILD_BUG_ON(ARRAY_SIZE(((ARMCPU *)0)->ccsidr) <= R_V7M_CSSELR_INDEX_MASK); /* If adding a feature bit which corresponds to a Linux ELF diff --git a/target/arm/helper.c b/target/arm/helper.c index 2ebca3e2b6..c769218763 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6932,6 +6932,83 @@ static const ARMCPRegInfo sme_reginfo[] = { .access = PL2_RW, .accessfn = access_esm, .type = ARM_CP_CONST, .resetvalue = 0 }, }; + +static void tlbi_aa64_paall_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + CPUState *cs = env_cpu(env); + + tlb_flush(cs); +} + +static void gpccr_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + /* L0GPTSZ is RO; other bits not mentioned are RES0. */ + uint64_t rw_mask = R_GPCCR_PPS_MASK | R_GPCCR_IRGN_MASK | + R_GPCCR_ORGN_MASK | R_GPCCR_SH_MASK | R_GPCCR_PGS_MASK | + R_GPCCR_GPC_MASK | R_GPCCR_GPCP_MASK; + + env->cp15.gpccr_el3 = (value & rw_mask) | (env->cp15.gpccr_el3 & ~rw_mask); +} + +static void gpccr_reset(CPUARMState *env, const ARMCPRegInfo *ri) +{ + env->cp15.gpccr_el3 = FIELD_DP64(0, GPCCR, L0GPTSZ, + env_archcpu(env)->reset_l0gptsz); +} + +static void tlbi_aa64_paallos_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + CPUState *cs = env_cpu(env); + + tlb_flush_all_cpus_synced(cs); +} + +static const ARMCPRegInfo rme_reginfo[] = { + { .name = "GPCCR_EL3", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 6, .crn = 2, .crm = 1, .opc2 = 6, + .access = PL3_RW, .writefn = gpccr_write, .resetfn = gpccr_reset, + .fieldoffset = offsetof(CPUARMState, cp15.gpccr_el3) }, + { .name = "GPTBR_EL3", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 6, .crn = 2, .crm = 1, .opc2 = 4, + .access = PL3_RW, .fieldoffset = offsetof(CPUARMState, cp15.gptbr_el3) }, + { .name = "MFAR_EL3", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 6, .crn = 6, .crm = 0, .opc2 = 5, + .access = PL3_RW, .fieldoffset = offsetof(CPUARMState, cp15.mfar_el3) }, + { .name = "TLBI_PAALL", .state = ARM_CP_STATE_AA64, + .opc0 = 1, .opc1 = 6, .crn = 8, .crm = 7, .opc2 = 4, + .access = PL3_W, .type = ARM_CP_NO_RAW, + .writefn = tlbi_aa64_paall_write }, + { .name = "TLBI_PAALLOS", .state = ARM_CP_STATE_AA64, + .opc0 = 1, .opc1 = 6, .crn = 8, .crm = 1, .opc2 = 4, + .access = PL3_W, .type = ARM_CP_NO_RAW, + .writefn = tlbi_aa64_paallos_write }, + /* + * QEMU does not have a way to invalidate by physical address, thus + * invalidating a range of physical addresses is accomplished by + * flushing all tlb entries in the outer sharable domain, + * just like PAALLOS. + */ + { .name = "TLBI_RPALOS", .state = ARM_CP_STATE_AA64, + .opc0 = 1, .opc1 = 6, .crn = 8, .crm = 4, .opc2 = 7, + .access = PL3_W, .type = ARM_CP_NO_RAW, + .writefn = tlbi_aa64_paallos_write }, + { .name = "TLBI_RPAOS", .state = ARM_CP_STATE_AA64, + .opc0 = 1, .opc1 = 6, .crn = 8, .crm = 4, .opc2 = 3, + .access = PL3_W, .type = ARM_CP_NO_RAW, + .writefn = tlbi_aa64_paallos_write }, + { .name = "DC_CIPAPA", .state = ARM_CP_STATE_AA64, + .opc0 = 1, .opc1 = 6, .crn = 7, .crm = 14, .opc2 = 1, + .access = PL3_W, .type = ARM_CP_NOP }, +}; + +static const ARMCPRegInfo rme_mte_reginfo[] = { + { .name = "DC_CIGDPAPA", .state = ARM_CP_STATE_AA64, + .opc0 = 1, .opc1 = 6, .crn = 7, .crm = 14, .opc2 = 5, + .access = PL3_W, .type = ARM_CP_NOP }, +}; #endif /* TARGET_AARCH64 */ static void define_pmu_regs(ARMCPU *cpu) @@ -9123,6 +9200,12 @@ void register_cp_regs_for_features(ARMCPU *cpu) if (cpu_isar_feature(aa64_tlbios, cpu)) { define_arm_cp_regs(cpu, tlbios_reginfo); } + if (cpu_isar_feature(aa64_rme, cpu)) { + define_arm_cp_regs(cpu, rme_reginfo); + if (cpu_isar_feature(aa64_mte, cpu)) { + define_arm_cp_regs(cpu, rme_mte_reginfo); + } + } #ifndef CONFIG_USER_ONLY /* Data Cache clean instructions up to PoP */ if (cpu_isar_feature(aa64_dcpop, cpu)) { From patchwork Mon Feb 20 23:26:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 655135 Delivered-To: patch@linaro.org Received: by 2002:adf:9bcd:0:0:0:0:0 with SMTP id e13csp1661447wrc; Mon, 20 Feb 2023 15:27:45 -0800 (PST) X-Google-Smtp-Source: AK7set8bho2d/7YO4siwDA9ftunlDtk70jBOQ9aiosCiWTaHPYa2jyIaKv2TunGsHPt3r5aDpqb3 X-Received: by 2002:ad4:5de5:0:b0:56e:a658:84e4 with SMTP id jn5-20020ad45de5000000b0056ea65884e4mr6564527qvb.36.1676935665680; Mon, 20 Feb 2023 15:27:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676935665; cv=none; d=google.com; s=arc-20160816; b=uq01CwYKCDwHrDmXX+UGiYdWDz2wboeK3pTfxyNkeRKH/QFU2Ajryz+12jXrjARUNx Z6AfxOqVzGKKO1tP/dLQz9iLma2yc41l8RB3m7bMxC5a6J5wJwMChwqHtSup5kZApkRL gd0/rTejeGvgMKBQVXHflxTUe5EmwaBia3HkH5MNKsVLuN0N+ulW8yrF0OFJ/M6dcFJw oshsK+VY+ATi3ygBMH5mmTl8mCgVhI3jYz7m+pcf2Je0MEq1gFH6F0hK3+6pW7BHc8EJ hXVuDiECg0rfnmPUPXbo55zN3F3T/Mi6HnnfyasZGsdjSnFT2ao+eszrKxfxPmhX20Gk CC1w== 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=HJ0eXW5VRS0QeP2fz4cJY2IGgEGJA0/xJ9DiQojdrZw=; b=axMUc/v6NsLYTnkRTPd2Hh5G5Lu8ZIHKBeTlWSOr+8/hwHtDLMpAJY0cFdhbI13o+Z 6DYPxyCzl9S6Ci0gLOX6gL7NkeEdWVUSh0hLR9W1YeMnbK3vNJW9+SVoO2ABZH6fhFjd 4z6HAIhKV2TE0Qy3fS3DlD5UNwjcKfFv4IFnDlsqfZrKj5hDraRyLAAhF0W1a3ZPHogb Ye9iWMPbzUTTdarLekqsyt9CGTg/YdAW5u1rKWHXwaxpQn686CVwMVWiVmnmc5t6Cbb+ Xo8mckOJaVg7HDrNJlvedvgPd+Aa4r9Tj2A1/wD7euq2HRmmd19pQaxx78RAVChL/Oq9 pRBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yRDIFZ1h; 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 fh5-20020a0562141a0500b0056eb97aaa5bsi6201103qvb.299.2023.02.20.15.27.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Feb 2023 15:27:45 -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=@linaro.org header.s=google header.b=yRDIFZ1h; 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 1pUFYT-0003nz-47; Mon, 20 Feb 2023 18:26:45 -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 1pUFYR-0003mk-SF for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:26:43 -0500 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUFYQ-0000KX-2z for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:26:43 -0500 Received: by mail-pl1-x635.google.com with SMTP id s5so3043308plg.0 for ; Mon, 20 Feb 2023 15:26:41 -0800 (PST) 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 :message-id:reply-to; bh=HJ0eXW5VRS0QeP2fz4cJY2IGgEGJA0/xJ9DiQojdrZw=; b=yRDIFZ1hKKh+Ou/BE6Reih1mFOWMoebCVm+cMDPqZ5c2cxlG3tAA0RHtzgEN72RHpX YpuG5AhWzbkZssamR3klbLOas5k8adeIG2NNdcNUpVymjT+fRiVg/HAo9yqYy0iDWKzb LntjVnqTsUNdlcLbWaeXFAilncY2iqyD2PQPAkiSUX3N21wO/OmZbx4tHFFYP3GdBo5o rTN9ZDlg0QbxYMxXGrbC1/lhBkQgP7cCdDSWFtx90hePJ5booLmPRYe0x4NIuvzT04FY +arhbBeWhjZmWcVxIcPUsgYOUtLReCKO5g4t/A2BgZJEdA5zUxlqHUAYp8X7jPXOUm3b f19A== 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:message-id:reply-to; bh=HJ0eXW5VRS0QeP2fz4cJY2IGgEGJA0/xJ9DiQojdrZw=; b=OOtEpXkOoh06AautUquuKM5NeMsRWXcs3729ESx1TG1rMIp7BtyKgHfl+Vo2L4hP9E FR9iE0t+jNBzfzCZk74IzLl58ISXE1Dk6VcgYN14z+JHX6X2u/s4N8dXOUNw80w7S3qQ pICGchsEMBVN8DVvOtL0pZpnjo79HRTTBUWyMan/20Cq1PBlUP6l4hGIvkYQfu6QpSUt Iqum37Gy0EfoEOyE5T16Pc/I71AKHHKQoER2OTgNyy1mvdU3VGf4kLPq2GEvvMkK5Lkd wBWRpMBJGp911ZIvDB6YB/QG7yhDR8zJou5AKYovHASrM5a/hOMvmTScDrkpUj4sQ0XP gldA== X-Gm-Message-State: AO0yUKUb2UphRMwip1QVkAg4a5OTf1HnbUfHuSPjW0ToLyw/f84PQ/SJ fBC6lwEz7igDdJK8NXlNo23WIAU/vFkiSUyNGOw= X-Received: by 2002:a17:902:e84b:b0:19a:ba6f:b179 with SMTP id t11-20020a170902e84b00b0019aba6fb179mr5320893plg.29.1676935600266; Mon, 20 Feb 2023 15:26:40 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id j10-20020a170902690a00b001992e74d058sm2665348plk.7.2023.02.20.15.26.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Feb 2023 15:26:39 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell Subject: [PATCH v2 06/21] target/arm: Introduce ARMSecuritySpace Date: Mon, 20 Feb 2023 13:26:11 -1000 Message-Id: <20230220232626.429947-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220232626.429947-1-richard.henderson@linaro.org> References: <20230220232626.429947-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.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=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 Introduce both the enumeration and functions to retrieve the current state, and state outside of EL3. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/cpu.h | 86 +++++++++++++++++++++++++++++++++++---------- target/arm/helper.c | 54 ++++++++++++++++++++++++++++ 2 files changed, 122 insertions(+), 18 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 6a97c727d1..1b982dc94c 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -2409,23 +2409,53 @@ static inline int arm_feature(CPUARMState *env, int feature) void arm_cpu_finalize_features(ARMCPU *cpu, Error **errp); +/* + * ARM v9 security states. + * The ordering of the enumeration corresponds to the low 2 bits + * of the GPI value, and (except for Root) the concat of NSE:NS. + */ + +typedef enum ARMSecuritySpace { + ARMSS_Secure = 0, + ARMSS_NonSecure = 1, + ARMSS_Root = 2, + ARMSS_Realm = 3, +} ARMSecuritySpace; + +/* Return true if @space is secure, in the pre-v9 sense. */ +static inline bool arm_space_is_secure(ARMSecuritySpace space) +{ + return space == ARMSS_Secure || space == ARMSS_Root; +} + +/* Return the ARMSecuritySpace for @secure, assuming !RME or EL[0-2]. */ +static inline ARMSecuritySpace arm_secure_to_space(bool secure) +{ + return secure ? ARMSS_Secure : ARMSS_NonSecure; +} + #if !defined(CONFIG_USER_ONLY) -/* Return true if exception levels below EL3 are in secure state, - * or would be following an exception return to that level. - * Unlike arm_is_secure() (which is always a question about the - * _current_ state of the CPU) this doesn't care about the current - * EL or mode. +/** + * arm_security_space_below_el3: + * @env: cpu context + * + * Return the security space of exception levels below EL3, following + * an exception return to those levels. Unlike arm_security_space, + * this doesn't care about the current EL. + */ +ARMSecuritySpace arm_security_space_below_el3(CPUARMState *env); + +/** + * arm_is_secure_below_el3: + * @env: cpu context + * + * Return true if exception levels below EL3 are in secure state, + * or would be following an exception return to those levels. */ static inline bool arm_is_secure_below_el3(CPUARMState *env) { - if (arm_feature(env, ARM_FEATURE_EL3)) { - return !(env->cp15.scr_el3 & SCR_NS); - } else { - /* If EL3 is not supported then the secure state is implementation - * defined, in which case QEMU defaults to non-secure. - */ - return false; - } + ARMSecuritySpace ss = arm_security_space_below_el3(env); + return ss == ARMSS_Secure; } /* Return true if the CPU is AArch64 EL3 or AArch32 Mon */ @@ -2444,13 +2474,23 @@ static inline bool arm_is_el3_or_mon(CPUARMState *env) return false; } -/* Return true if the processor is in secure state */ +/** + * arm_security_space: + * @env: cpu context + * + * Return the current security space of the cpu. + */ +ARMSecuritySpace arm_security_space(CPUARMState *env); + +/** + * arm_is_secure: + * @env: cpu context + * + * Return true if the processor is in secure state. + */ static inline bool arm_is_secure(CPUARMState *env) { - if (arm_is_el3_or_mon(env)) { - return true; - } - return arm_is_secure_below_el3(env); + return arm_space_is_secure(arm_security_space(env)); } /* @@ -2469,11 +2509,21 @@ static inline bool arm_is_el2_enabled(CPUARMState *env) } #else +static inline ARMSecuritySpace arm_security_space_below_el3(CPUARMState *env) +{ + return ARMSS_NonSecure; +} + static inline bool arm_is_secure_below_el3(CPUARMState *env) { return false; } +static inline ARMSecuritySpace arm_security_space(CPUARMState *env) +{ + return ARMSS_NonSecure; +} + static inline bool arm_is_secure(CPUARMState *env) { return false; diff --git a/target/arm/helper.c b/target/arm/helper.c index c769218763..13af812215 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -12535,3 +12535,57 @@ void aarch64_sve_change_el(CPUARMState *env, int old_el, } } #endif + +#ifndef CONFIG_USER_ONLY +ARMSecuritySpace arm_security_space(CPUARMState *env) +{ + /* + * If EL3 is not supported then the secure state is implementation + * defined, in which case QEMU defaults to non-secure. + */ + if (!arm_feature(env, ARM_FEATURE_EL3)) { + return ARMSS_NonSecure; + } + + /* Check for AArch64 EL3 or AArch32 Mon. */ + if (is_a64(env)) { + if (extract32(env->pstate, 2, 2) == 3) { + if (cpu_isar_feature(aa64_rme, env_archcpu(env))) { + return ARMSS_Root; + } else { + return ARMSS_Secure; + } + } + } else { + if ((env->uncached_cpsr & CPSR_M) == ARM_CPU_MODE_MON) { + return ARMSS_Secure; + } + } + + return arm_security_space_below_el3(env); +} + +ARMSecuritySpace arm_security_space_below_el3(CPUARMState *env) +{ + /* + * If EL3 is not supported then the secure state is implementation + * defined, in which case QEMU defaults to non-secure. + */ + if (!arm_feature(env, ARM_FEATURE_EL3)) { + return ARMSS_NonSecure; + } + + /* + * Note NSE cannot be set without RME, and NSE & !NS is Reserved. + * Ignoring NSE when !NS retains consistency without having to + * modify other predicates. + */ + if (!(env->cp15.scr_el3 & SCR_NS)) { + return ARMSS_Secure; + } else if (env->cp15.scr_el3 & SCR_NSE) { + return ARMSS_Realm; + } else { + return ARMSS_NonSecure; + } +} +#endif /* !CONFIG_USER_ONLY */ From patchwork Mon Feb 20 23:26:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 655133 Delivered-To: patch@linaro.org Received: by 2002:adf:9bcd:0:0:0:0:0 with SMTP id e13csp1661271wrc; Mon, 20 Feb 2023 15:27:20 -0800 (PST) X-Google-Smtp-Source: AK7set9xJomkH+Od0Pl95kdSbo1H2Ch/wcK2g8a5+nAp9YPJbWO1Cirtn8og5Zz+5TY27S+9fxqr X-Received: by 2002:a05:622a:118d:b0:3b0:b9a4:a20f with SMTP id m13-20020a05622a118d00b003b0b9a4a20fmr3449424qtk.4.1676935640364; Mon, 20 Feb 2023 15:27:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676935640; cv=none; d=google.com; s=arc-20160816; b=dPvmIpy9WjeSDgZQOHofiWcvvNyGG6Jg2RjiCEgt+pyCUA95lb7freAreth3g4cH90 mIV3OXB4L/YlGUl3A0Vj//OHgb0vFm+RtOL5XPpA/P2sZaOTysGcXr4F5izd0NjiGk8G F8ySkTD7ARO9aZB7pckuSXQkXDD4aGCpjk9FNcVgMdfqaY5PVN7CDrI7X2dm6N9oostX C486ktYz7trZ3ytrAPF5kRjQ2Z39KDqeamAZmh0xGyBbhRaoFlQ0ISezqO7OV6Tf2RI6 f8E5ANVgcSsl9z0YWqvQCGIo+DjeEAr01qC8Xp3RYBoqVZGTDenRSDgrBTo6Z/cGPsqG ihBg== 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=0zAr88doy4l35/U8kOUIKFNAL46N655Bwwt/mOy9kK4=; b=Hkwo5tbw1gOKXUYaEbZLRUa2X7+Q1nlQjydUSE73FMYOmzZT7ztIrKR7G3W1X/3ErK eyalyjs6BkCOei5w3/NxGA3eYOt7uQACh7Wi5R+203HMuUJ0QM8r9vPq2prYfP61040t 0V1TVtenbkbdAGb06tocy3jAiXGnrwJu8nz9hrQCZwjKm7fCPEokPDqAvaxKYbPlSE2P oDf6v9QUqjpsnkNwITaZYu020G0iaeFxB3bQHfYKMVjqccVsI4rre685b2kb3OM9Vd2S oHhFgkKLk5ncEOdQvh0W8FKiTKGoGgeRJGunipoq5qF/Oxn8olNHukW2b4uWPgSpyVnF yWjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S6sEYxzG; 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 k7-20020ac85fc7000000b003b86b4bbefdsi11280165qta.370.2023.02.20.15.27.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Feb 2023 15:27:20 -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=@linaro.org header.s=google header.b=S6sEYxzG; 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 1pUFYV-0003uG-1I; Mon, 20 Feb 2023 18:26:47 -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 1pUFYT-0003nu-0f for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:26:45 -0500 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUFYR-0000LF-Gn for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:26:44 -0500 Received: by mail-pj1-x102b.google.com with SMTP id d1-20020a17090a3b0100b00229ca6a4636so3132876pjc.0 for ; Mon, 20 Feb 2023 15:26:43 -0800 (PST) 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 :message-id:reply-to; bh=0zAr88doy4l35/U8kOUIKFNAL46N655Bwwt/mOy9kK4=; b=S6sEYxzGxO3bfpesCdh8SoyA0w8Nm+dMMgqv79oqg0RDkdwJjOTil9JPT1AYe84ZfJ 8uFmlk38dM+iwRR8uf3a/sbjebwSrt2ssGewg89oYl5uC+hcKAaXoN34UJT616QEIJi/ Apx6uKufuN0zUtOiLGE/84w921NlCwj3BT3rXBwyAgEvAR1I1Wj5HFY4SJaWFmu10VvP uo1J4+J01t8e4cZTg/fUCeLq3Mbg90DMJ6Cj1dqgaI+2cKB/H9ragb9IITl3TEb6D8xK JtgyOiLnEtSTZ0Q+2ICVic+p0wxn1Wl307BUP39tz1zoCGb++2jOaYVUaRTQEQSl6Mba odFQ== 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:message-id:reply-to; bh=0zAr88doy4l35/U8kOUIKFNAL46N655Bwwt/mOy9kK4=; b=DAZZNPTDCq1GBiTKwWGMC3BtSedsLiVBdF/6OyEIgxzraRdeIw5ZOLEZa3w2Zi9hFC LUx1lsRpA5+gNmwjmoBLisqhZan5x27GYnjz5wAyDbui9wNaVgtumDfCE3dAnNLftQEq fMijhCoZP4GtU4IbYO0rZCtJm8EnhNb8sRd7p/yeEudJfrIsch7XjwFjjN9wOI9Y9smG eyIiQBSDX20o7RlNjIc4YYDZaB2JmycIRsowJwkuPODSuoWrqiQBjBKUlBgYDLEY9sgp DfH6FnCDR8gkPlz45jh4ItGanugiIzbfpQsvmOGZydSAa92BKCsYE0lmhjdDJLfZk23t CwgQ== X-Gm-Message-State: AO0yUKWdxm3kHbG2RoPVLLfY0l33aZOiTlTxILgBByC/rCfH2mXCUWP1 jPOnJO5ejRlA0nPYOpFeeGbhiiAaawLWi47JNjA= X-Received: by 2002:a17:902:d2c3:b0:19a:80c9:2cd7 with SMTP id n3-20020a170902d2c300b0019a80c92cd7mr3138209plc.47.1676935601902; Mon, 20 Feb 2023 15:26:41 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id j10-20020a170902690a00b001992e74d058sm2665348plk.7.2023.02.20.15.26.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Feb 2023 15:26:41 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell Subject: [PATCH v2 07/21] include/exec/memattrs: Add two bits of space to MemTxAttrs Date: Mon, 20 Feb 2023 13:26:12 -1000 Message-Id: <20230220232626.429947-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220232626.429947-1-richard.henderson@linaro.org> References: <20230220232626.429947-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.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 We will need 2 bits to represent ARMSecurityState. Do not attempt to replace or widen secure, even though it logically overlaps the new field -- there are uses within e.g. hw/block/pflash_cfi01.c, which don't know anything specific about ARM. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- include/exec/memattrs.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/include/exec/memattrs.h b/include/exec/memattrs.h index 9fb98bc1ef..d04170aa27 100644 --- a/include/exec/memattrs.h +++ b/include/exec/memattrs.h @@ -29,10 +29,17 @@ typedef struct MemTxAttrs { * "didn't specify" if necessary. */ unsigned int unspecified:1; - /* ARM/AMBA: TrustZone Secure access + /* + * ARM/AMBA: TrustZone Secure access * x86: System Management Mode access */ unsigned int secure:1; + /* + * ARM: ArmSecuritySpace. This partially overlaps secure, but it is + * easier to have both fields to assist code that does not understand + * ARMv9 RME, or no specific knowledge of ARM at all (e.g. pflash). + */ + unsigned int space:2; /* Memory access is usermode (unprivileged) */ unsigned int user:1; /* From patchwork Mon Feb 20 23:26:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 655131 Delivered-To: patch@linaro.org Received: by 2002:adf:9bcd:0:0:0:0:0 with SMTP id e13csp1661212wrc; Mon, 20 Feb 2023 15:27:13 -0800 (PST) X-Google-Smtp-Source: AK7set83o10wfVHfEp9FC4qgGKmJ7K1am2OxrFWq0AEVoBWz/zMlosnBjYrSFu8Qc3n3G8tmqT97 X-Received: by 2002:a05:6214:301c:b0:56b:fd8c:746f with SMTP id ke28-20020a056214301c00b0056bfd8c746fmr5794362qvb.39.1676935633690; Mon, 20 Feb 2023 15:27:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676935633; cv=none; d=google.com; s=arc-20160816; b=CzI2mPpWrkozyjbSTavjZvcwBeQlco9CRW8vUhUSReyaFL1Jd9TFv2DGndbR5Ewcr9 cVWXI4Q6vkwOG+rf6BGCMLbGyV6BQY2Z/y9k6atH1tFG/ZAIggAdDWBIV1ky7CufVL1m q9XhgGMZW4eP2aRebl4pdburHpqfhIAIYGujN36aW4uC536VwPo8u9qt3b5iIr1Nz3Dm yFVlReNJc+kT8Xr27T9jVlWlzYShp6V84uLgXCW9tupOEH8xYl1I4dg5Ax8OQYd+SBz3 qe4A8BxfNKK6WxhWIBZJdjAmTZ8L42ZpEP/KxSxbfqrjQMosJrLm7ZzLjLO5brXFzxoj vaoA== 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=16mYzaWfQJouACxZdLwovOfwLxSjOAqgX/IHmcrs7RY=; b=maWAoCEG0Z3dkvGhhLTAneGztw9S64KUl7BRs/uAeynsZ96NK96Wc+0VPqjMGKXDG0 15ofpf7i5EixP+kvfXXOGKJsQ1Ftu2zNgGOx22KAKjDsAzwJJ2W1+G8H1X/RnKwtkLGI OF7vIrqsWmAc/mApfkM+g3c9jUetwhmkReSFMdxn7XwdqsL7jedNqZ3mntuHrTVtWLqr Pu7fXjkVKhwBJwAYQWYeJmkJaqrvoNWNbbUlMaAkmf4Fo7Mu4znPJ2PxDY0iUWlHNxox OF0986Ye/ujO+SS4Fxmc/1s0iazT/vM3q0nhYsd0+1ILOKBLmlE5d10FpSKoKTBuXyWc vceA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Bvk251Oc; 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 o9-20020a0ccb09000000b0056ea4991a40si10295296qvk.50.2023.02.20.15.27.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Feb 2023 15:27:13 -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=@linaro.org header.s=google header.b=Bvk251Oc; 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 1pUFYW-0003zB-2m; Mon, 20 Feb 2023 18:26:48 -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 1pUFYU-0003sx-Jj for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:26:46 -0500 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUFYS-0000M3-Rg for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:26:46 -0500 Received: by mail-pj1-x102b.google.com with SMTP id pt11so3453804pjb.1 for ; Mon, 20 Feb 2023 15:26:44 -0800 (PST) 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 :message-id:reply-to; bh=16mYzaWfQJouACxZdLwovOfwLxSjOAqgX/IHmcrs7RY=; b=Bvk251OcJAGbyvjnVS1iUWZTpk8ZIqihTDIrgBX5pCz1tLqGdqevHp0Q/l45wce+m/ DPx5ljItbUYNmDS6DP2/osBOX0x7jqXFe7RqxkNhadrnrJcXCLptnKxhDpq6UruPOx5z OiCBidO76lkBjYARUYwvXaXzl3TOC5irZQVPCxHKeT7ohuK72rbemYvwAcbOwg+dZgNc q1TPFDtce3xrzpm/XuSNVAY5TfRhfqliW4KPhc/edsZhL7PDpFCj87mwLGDtMoZE8/48 X27eMTscQou9Lu/gmIY4DsTsJBaMYv3Eje8RJmuakuRkPStM4bTsIdx0YptTyzAr7dQY GODw== 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:message-id:reply-to; bh=16mYzaWfQJouACxZdLwovOfwLxSjOAqgX/IHmcrs7RY=; b=o7+uzQZdManxgtd/MBAqWIg663IkiG1ObgNEWBR/HSuK8V+aEHN0DhepXaJyhI2Fbx 8itGmxNVnm3SbOt6EL8hlr1DovGyNZYyckWWlIVWwy8wWgY41iCCCQhzsXIr5zdBpKCO ERx6r9jCVb8AWMB58bGNgjGiDuYHDohqVWHoicPzFFu4Rdn9htjhakM5jQG+uTd+2UWN yyN6af846xiHD4hVr+ZDKmEYT06xXeK6GvFNYXsO6PDRcNeM+aQxmDlwUwWhaQEk2OzO 5g/K8vuZsCSxK8Xqj8d3SOIRLI6fuQM7SUPE9QBnqYBka1nlXP3Tqksbvc2ZPMUWd1Az MAQA== X-Gm-Message-State: AO0yUKXQExaj+v3FDqobJvZnkihspyKLjW13tIqq0PASIYLAqK4LSR3e bCt8pOPTVoIxRRN5TQ9GBfq7mWVqKbPioK7TAEo= X-Received: by 2002:a17:902:ba93:b0:196:6ec0:345a with SMTP id k19-20020a170902ba9300b001966ec0345amr4157755pls.25.1676935603520; Mon, 20 Feb 2023 15:26:43 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id j10-20020a170902690a00b001992e74d058sm2665348plk.7.2023.02.20.15.26.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Feb 2023 15:26:43 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell Subject: [PATCH v2 08/21] target/arm: Adjust the order of Phys and Stage2 ARMMMUIdx Date: Mon, 20 Feb 2023 13:26:13 -1000 Message-Id: <20230220232626.429947-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220232626.429947-1-richard.henderson@linaro.org> References: <20230220232626.429947-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.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=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 It will be helpful to have ARMMMUIdx_Phys_* to be in the same relative order as ARMSecuritySpace enumerators. This requires the adjustment to the nstable check. While there, check for being in secure state rather than rely on clearing the low bit making no change to non-secure state. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/cpu.h | 12 ++++++------ target/arm/ptw.c | 12 +++++------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 1b982dc94c..c9585390d4 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -2854,18 +2854,18 @@ typedef enum ARMMMUIdx { ARMMMUIdx_E2 = 6 | ARM_MMU_IDX_A, ARMMMUIdx_E3 = 7 | ARM_MMU_IDX_A, - /* TLBs with 1-1 mapping to the physical address spaces. */ - ARMMMUIdx_Phys_NS = 8 | ARM_MMU_IDX_A, - ARMMMUIdx_Phys_S = 9 | ARM_MMU_IDX_A, - /* * Used for second stage of an S12 page table walk, or for descriptor * loads during first stage of an S1 page table walk. Note that both * are in use simultaneously for SecureEL2: the security state for * the S2 ptw is selected by the NS bit from the S1 ptw. */ - ARMMMUIdx_Stage2 = 10 | ARM_MMU_IDX_A, - ARMMMUIdx_Stage2_S = 11 | ARM_MMU_IDX_A, + ARMMMUIdx_Stage2_S = 8 | ARM_MMU_IDX_A, + ARMMMUIdx_Stage2 = 9 | ARM_MMU_IDX_A, + + /* TLBs with 1-1 mapping to the physical address spaces. */ + ARMMMUIdx_Phys_S = 10 | ARM_MMU_IDX_A, + ARMMMUIdx_Phys_NS = 11 | ARM_MMU_IDX_A, /* * These are not allocated TLBs and are used only for AT system diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 6fb72fb086..5ed5bb5039 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -1410,16 +1410,14 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, descaddr |= (address >> (stride * (4 - level))) & indexmask; descaddr &= ~7ULL; nstable = extract32(tableattrs, 4, 1); - if (nstable) { + if (nstable && ptw->in_secure) { /* * Stage2_S -> Stage2 or Phys_S -> Phys_NS - * Assert that the non-secure idx are even, and relative order. + * Assert the relative order of the secure/non-secure indexes. */ - QEMU_BUILD_BUG_ON((ARMMMUIdx_Phys_NS & 1) != 0); - QEMU_BUILD_BUG_ON((ARMMMUIdx_Stage2 & 1) != 0); - QEMU_BUILD_BUG_ON(ARMMMUIdx_Phys_NS + 1 != ARMMMUIdx_Phys_S); - QEMU_BUILD_BUG_ON(ARMMMUIdx_Stage2 + 1 != ARMMMUIdx_Stage2_S); - ptw->in_ptw_idx &= ~1; + QEMU_BUILD_BUG_ON(ARMMMUIdx_Phys_S + 1 != ARMMMUIdx_Phys_NS); + QEMU_BUILD_BUG_ON(ARMMMUIdx_Stage2_S + 1 != ARMMMUIdx_Stage2); + ptw->in_ptw_idx += 1; ptw->in_secure = false; } if (!S1_ptw_translate(env, ptw, descaddr, fi)) { From patchwork Mon Feb 20 23:26:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 655150 Delivered-To: patch@linaro.org Received: by 2002:adf:9bcd:0:0:0:0:0 with SMTP id e13csp1662081wrc; Mon, 20 Feb 2023 15:29:44 -0800 (PST) X-Google-Smtp-Source: AK7set9wIqgxb53cQcDBc6jDxTAD4GIUSGgPbuOt6058Uh5XpDP9IhbAn9rspuLltvJEkkffQ7cE X-Received: by 2002:a05:6214:528d:b0:56b:edfa:57cc with SMTP id kj13-20020a056214528d00b0056bedfa57ccmr4671370qvb.41.1676935784074; Mon, 20 Feb 2023 15:29:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676935784; cv=none; d=google.com; s=arc-20160816; b=zb+/B37K99IRuTI+dRFz50tOwHBA/K4iSdxUDTeUpITRAYW9cDKJXxweBgp5IcC1Bg hEF1YIheWB+Utd9qzYAfj4rfUrm9NZudK65fdrHvU0d4WU+9pW61OGQDfgLVROF7OIYL srRIRJ+iFaphN+U4IyeGtyWWRIUdnYJ9fW7LX2tEEHbOzM6PuicS7O3yXrS9MXReBOaO rul5NvBvlYR1WHHvWiW1TrdtvBuC3NKeFFsr1FoErfdjDXHIt0xw2Hb5wgHaqpsEKUUS cYrZMNEF9aA1I8xB+PYNVLaqq0e+rPyZcPPJUdR565C59LdA1yVgetCtbiGV40JkUyTj m/rw== 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=3Gj4J+B5iGnKsOwsF9h/fX8hbpbRCBs9B/CdgKeQjUk=; b=iMnO5odpK55GvC0vknrUtyamQptQZyjhhF2lCz3r0FMtQ/QydCeS8PPRI/OUClcB5j pZnxnjEwu8EfEXEDgVQTgT7u46dbCU54ZP+Nv1ose4qlMFkng6s6O9LAUwBv9En0Az5z 1K/eXObS/cbqAQTzOdkUS5aN8yjbuI49ekRsE6IIFUgnrHLGrKCYpiQ/NtZpu1Y7SE0K 20h6mMfXG/Y9j7oe30VcViAB6JHXr7i86bsYXd0xHzD1NSuXJXDvUFnWaLvRGUnuQ88C 2ATzsj5a2yNt4uUFWWpzSiABttIYTTPvuNj/yH+e4m1z9BxtMVuX2euqTDTmhqmEZuWM 6vgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fyUIuc71; 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 w12-20020a0cdf8c000000b0056ea79333dasi10786926qvl.345.2023.02.20.15.29.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Feb 2023 15:29:44 -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=@linaro.org header.s=google header.b=fyUIuc71; 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 1pUFYX-00041P-N5; Mon, 20 Feb 2023 18:26:49 -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 1pUFYW-0003za-6Z for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:26:48 -0500 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUFYU-0000NW-IW for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:26:47 -0500 Received: by mail-pl1-x62e.google.com with SMTP id p1so1087511plg.7 for ; Mon, 20 Feb 2023 15:26:46 -0800 (PST) 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 :message-id:reply-to; bh=3Gj4J+B5iGnKsOwsF9h/fX8hbpbRCBs9B/CdgKeQjUk=; b=fyUIuc71rFe6mvaGGhsFVhXHBMoqkDcb07bruBj7PkPGxVyMePN7RvurG38Z2WNCpR TT7GK3ds7K6Fh9x/n76Z7lCLaxrecWdQMff1KBUjYUefxAqUnfglNL2Je+Z3Ae6Jj1sG wmykFuXQGXqtdOZXEETNcbXS7fjcCs1yhp+wr2JBBplJ8y2uTtm+M7Q2bhhBh3xLTJfh /yduR+5rHfF+8Df7hv7DEhQlrzhKGWwVZBUxV6Zzj7zhtJyLggF0KuU8Cf6+yaPNcysO OQFIB2uDzwa20r6n8GSEbjr2fXKIi8Y445/mYU0EuPd6TFpAp8BhYVA+IhAfX5aQdI7Z rBiQ== 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:message-id:reply-to; bh=3Gj4J+B5iGnKsOwsF9h/fX8hbpbRCBs9B/CdgKeQjUk=; b=frSBeeZwI7Z+JovoAkVTdMwnd/xDXSBdhlK3oOHxw2aS0oaN9qmM5jXJ1HY51PkSL2 0NOtVVs/m86NLn55ooX7ZkhAqL13Uy/K6RE94BNmA/mQXb2dW+iASJUEI98vymmk7vuJ Hkk+b5vxlgWAGo5ul5sOSU7dkXr3gDQmNUFGY0+j8mum9gznkSOlUYJ+RqIdOUaDnlub C5P7kRL/dsnRcF6dzwdEyodox4wVsiIxcwBJaI3jepr6EHCsjBex4m5VOC8NtTdmjC29 QUhCal+WfdFVlBwCqaV/o8bwnL+BsnajOzPQpJuCvd1aI21WorYoxC71NJWr+BfSqAv2 QAbA== X-Gm-Message-State: AO0yUKXrpMMSUpHlmUPxFhgieAXpZoj2+WwNwsEzg4isk/wxcLlCM+Ja VllMCpyOyk6vROsQxoMO/3x1MUo69Miei/XbJnQ= X-Received: by 2002:a05:6a20:8f0d:b0:b8:71b7:b903 with SMTP id b13-20020a056a208f0d00b000b871b7b903mr3989221pzk.31.1676935605303; Mon, 20 Feb 2023 15:26:45 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id j10-20020a170902690a00b001992e74d058sm2665348plk.7.2023.02.20.15.26.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Feb 2023 15:26:44 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell Subject: [PATCH v2 09/21] target/arm: Introduce ARMMMUIdx_Phys_{Realm,Root} Date: Mon, 20 Feb 2023 13:26:14 -1000 Message-Id: <20230220232626.429947-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220232626.429947-1-richard.henderson@linaro.org> References: <20230220232626.429947-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.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=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 With FEAT_RME, there are four physical address spaces. For now, just define the symbols, and mention them in the same spots as the other Phys indexes in ptw.c. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/cpu-param.h | 2 +- target/arm/cpu.h | 23 +++++++++++++++++++++-- target/arm/ptw.c | 10 ++++++++-- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/target/arm/cpu-param.h b/target/arm/cpu-param.h index 53cac9c89b..8dfd7a0bb6 100644 --- a/target/arm/cpu-param.h +++ b/target/arm/cpu-param.h @@ -47,6 +47,6 @@ bool guarded; #endif -#define NB_MMU_MODES 12 +#define NB_MMU_MODES 14 #endif diff --git a/target/arm/cpu.h b/target/arm/cpu.h index c9585390d4..4bafe8340e 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -2864,8 +2864,10 @@ typedef enum ARMMMUIdx { ARMMMUIdx_Stage2 = 9 | ARM_MMU_IDX_A, /* TLBs with 1-1 mapping to the physical address spaces. */ - ARMMMUIdx_Phys_S = 10 | ARM_MMU_IDX_A, - ARMMMUIdx_Phys_NS = 11 | ARM_MMU_IDX_A, + ARMMMUIdx_Phys_S = 10 | ARM_MMU_IDX_A, + ARMMMUIdx_Phys_NS = 11 | ARM_MMU_IDX_A, + ARMMMUIdx_Phys_Root = 12 | ARM_MMU_IDX_A, + ARMMMUIdx_Phys_Realm = 13 | ARM_MMU_IDX_A, /* * These are not allocated TLBs and are used only for AT system @@ -2929,6 +2931,23 @@ typedef enum ARMASIdx { ARMASIdx_TagS = 3, } ARMASIdx; +static inline ARMMMUIdx arm_space_to_phys(ARMSecuritySpace space) +{ + /* Assert the relative order of the physical mmu indexes. */ + QEMU_BUILD_BUG_ON(ARMSS_Secure != 0); + QEMU_BUILD_BUG_ON(ARMMMUIdx_Phys_NS != ARMMMUIdx_Phys_S + ARMSS_NonSecure); + QEMU_BUILD_BUG_ON(ARMMMUIdx_Phys_Root != ARMMMUIdx_Phys_S + ARMSS_Root); + QEMU_BUILD_BUG_ON(ARMMMUIdx_Phys_Realm != ARMMMUIdx_Phys_S + ARMSS_Realm); + + return ARMMMUIdx_Phys_S + space; +} + +static inline ARMSecuritySpace arm_phys_to_space(ARMMMUIdx idx) +{ + assert(idx >= ARMMMUIdx_Phys_S && idx <= ARMMMUIdx_Phys_Realm); + return idx - ARMMMUIdx_Phys_S; +} + static inline bool arm_v7m_csselr_razwi(ARMCPU *cpu) { /* If all the CLIDR.Ctypem bits are 0 there are no caches, and diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 5ed5bb5039..5a0c5edc88 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -182,8 +182,10 @@ static bool regime_translation_disabled(CPUARMState *env, ARMMMUIdx mmu_idx, case ARMMMUIdx_E3: break; - case ARMMMUIdx_Phys_NS: case ARMMMUIdx_Phys_S: + case ARMMMUIdx_Phys_NS: + case ARMMMUIdx_Phys_Root: + case ARMMMUIdx_Phys_Realm: /* No translation for physical address spaces. */ return true; @@ -2632,8 +2634,10 @@ static bool get_phys_addr_disabled(CPUARMState *env, target_ulong address, switch (mmu_idx) { case ARMMMUIdx_Stage2: case ARMMMUIdx_Stage2_S: - case ARMMMUIdx_Phys_NS: case ARMMMUIdx_Phys_S: + case ARMMMUIdx_Phys_NS: + case ARMMMUIdx_Phys_Root: + case ARMMMUIdx_Phys_Realm: break; default: @@ -2830,6 +2834,8 @@ static bool get_phys_addr_with_struct(CPUARMState *env, S1Translate *ptw, switch (mmu_idx) { case ARMMMUIdx_Phys_S: case ARMMMUIdx_Phys_NS: + case ARMMMUIdx_Phys_Root: + case ARMMMUIdx_Phys_Realm: /* Checking Phys early avoids special casing later vs regime_el. */ return get_phys_addr_disabled(env, address, access_type, mmu_idx, is_secure, result, fi); From patchwork Mon Feb 20 23:26:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 655138 Delivered-To: patch@linaro.org Received: by 2002:adf:9bcd:0:0:0:0:0 with SMTP id e13csp1661572wrc; Mon, 20 Feb 2023 15:28:05 -0800 (PST) X-Google-Smtp-Source: AK7set+Yh/dbJRl9NKSUvO4lKNBUpkzvzOSVoKO1j3JiqB8iYXoDLlndOLfOeruoSw/Kn30ZRo0L X-Received: by 2002:ad4:5dcb:0:b0:570:7026:2a19 with SMTP id m11-20020ad45dcb000000b0057070262a19mr3319323qvh.36.1676935684956; Mon, 20 Feb 2023 15:28:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676935684; cv=none; d=google.com; s=arc-20160816; b=MDgYe+0rRAhKxvYAyzFfFvBC0OnGWXrL0+p3xRINClVbDHLFduO08YItJelYnrlUOE S2VH7db5xnFMQRLh4afphj7vplZR2yb6dzDolLx966KivF6FdQL1zOj6YBT+Rltr2Yw+ 4sNJL0ndyP4riJdqXe2C69RzXT6DyY8wivnd1SNG2BzFD4L8oSCLTfah3XDOBM+M8tct agpYtzuGm2jB+sv/Frxt9uaQ4wzYYWk9DRdi2K7c1+fxKpHWLYXei9VKrULUxcLMGngj cJURYXbQqFZWvL9aFhgfft+D0BWCZ+ooxcSUxpWdj9V++852c7BCEIf07wReZqnoWscl jPKQ== 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=HSjxF6mCj3nhvrrRuM2gW/YQifDnxgBhjfPXSNiexPo=; b=vNzW9LnP13vwTuNm9Rnv+4olT79XLpok4qt2Mj6w9fZNuogDN8+1PNCyMbnvO7U8xX zHsB5jjlcCjv0MN7skWO7xGzbbi9LyuHO0tp5RJPf2KES1FoR0PH3hf/jxeLHFlpuYvb dOUwrkVU+huIJT9JxA2XKiRsEjyFMEEduqiJ/KpRVNuNL+2RhXhWZLCPzQtgnHpV8kL9 xlZ9a8bbCTTsEXNeCw4WBMcjdOspI6vRgDvzNY910qufn6aYJBQbDnKKPYKZztr8tmVS HvRR3mrsyxXpG+IemxGXoWPXTytOJWkQ897XBOBHWC1i1XRmiq2rXkvKvPLgTQw6dHwe V/iQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Hn5CVnt2; 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 71-20020a37074a000000b00720354ad796si9789257qkh.277.2023.02.20.15.28.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Feb 2023 15:28:04 -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=@linaro.org header.s=google header.b=Hn5CVnt2; 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 1pUFYb-00044A-0g; Mon, 20 Feb 2023 18:26:53 -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 1pUFYY-00042d-5M for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:26:50 -0500 Received: from mail-pj1-x1044.google.com ([2607:f8b0:4864:20::1044]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUFYW-0000OP-2l for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:26:49 -0500 Received: by mail-pj1-x1044.google.com with SMTP id ei9-20020a17090ae54900b002349a303ca5so2877293pjb.4 for ; Mon, 20 Feb 2023 15:26:47 -0800 (PST) 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 :message-id:reply-to; bh=HSjxF6mCj3nhvrrRuM2gW/YQifDnxgBhjfPXSNiexPo=; b=Hn5CVnt26hi2yiCnvLgQOUl1+yYVFihNbd4J/h2R7kWNESobiiiz7tDXYm0kRljD1X mR5Kjref2/gmuTIbCASXlyl6wD+WDOq8qlOGBphAxe4be5Tq5yK9L0+C5jvWPgQXfukQ YrhMcq7u6Wp4FOqkW0U9KYJWvez9Ac0za6j9fGIGP7PscWw7KqsgqMPd7Ifn7nmpvVsY WWhmmzlHNcRik0YsMAo3EifHSKOMcPB5hA/3W7AZxqNJ2vxMjTf4McXjiEqmW+W8T/0R blBSUD6w6f1aZVaZpoUWNkYG2yusF4J6iecfYW8fggyjdVCKVuz4t6S2XrNY1t5BKOrB L5xA== 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:message-id:reply-to; bh=HSjxF6mCj3nhvrrRuM2gW/YQifDnxgBhjfPXSNiexPo=; b=Qb0ZjJi2upHhikJXcneal/fuSRQ123lrQpGgTrgwdtP+NgvR9u8LFs58hHBuwrcze4 VhU5o6x0PC1KDdTUFRsXcB22FwjCRw1c47duJWSROvA6X7YOiAg5s5+xFzfIky4jbc/x sGZTF4iK82zkyy+39BoXumKErcqXx1v5spGmrni3qFJTMT7QXuvdhl/Ip3yQIljktvIh AMvN9a0FANoKxrAe38s8kbTNVYh+dMoCtQS6ZRg04ZeUQbzRaqggYqC7i4hH2iyjgxP0 MPN9kEIc7DRC0ZGtlrxAV4RV8ry1WW24fq6g30Cm6H2nG/fQikJaMx+STVwTXm7X2dLf SxyA== X-Gm-Message-State: AO0yUKVqm3KJtl/7GwinOtg3R0o7eOYJ/Ek0lppWJiZaqt6yskqi79Mn tAnZzad7UDu3Q+xv6SzXguQsyOP0kG85P6zuQY0MuQ== X-Received: by 2002:a05:6a21:32a9:b0:bc:930e:4165 with SMTP id yt41-20020a056a2132a900b000bc930e4165mr3395695pzb.15.1676935606791; Mon, 20 Feb 2023 15:26:46 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id j10-20020a170902690a00b001992e74d058sm2665348plk.7.2023.02.20.15.26.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Feb 2023 15:26:46 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell Subject: [PATCH v2 10/21] target/arm: Pipe ARMSecuritySpace through ptw.c Date: Mon, 20 Feb 2023 13:26:15 -1000 Message-Id: <20230220232626.429947-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220232626.429947-1-richard.henderson@linaro.org> References: <20230220232626.429947-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1044; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1044.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 Add input and output space members to S1Translate. Set and adjust them in S1_ptw_translate, and the various points at which we drop secure state. Initialize the space in get_phys_addr; for now leave get_phys_addr_with_secure considering only secure vs non-secure spaces. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/ptw.c | 95 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 76 insertions(+), 19 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 5a0c5edc88..7745287a46 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -19,11 +19,13 @@ typedef struct S1Translate { ARMMMUIdx in_mmu_idx; ARMMMUIdx in_ptw_idx; + ARMSecuritySpace in_space; bool in_secure; bool in_debug; bool out_secure; bool out_rw; bool out_be; + ARMSecuritySpace out_space; hwaddr out_virt; hwaddr out_phys; void *out_host; @@ -218,6 +220,7 @@ static bool S2_attrs_are_device(uint64_t hcr, uint8_t attrs) static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw, hwaddr addr, ARMMMUFaultInfo *fi) { + ARMSecuritySpace space = ptw->in_space; bool is_secure = ptw->in_secure; ARMMMUIdx mmu_idx = ptw->in_mmu_idx; ARMMMUIdx s2_mmu_idx = ptw->in_ptw_idx; @@ -234,7 +237,8 @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw, if (regime_is_stage2(s2_mmu_idx)) { S1Translate s2ptw = { .in_mmu_idx = s2_mmu_idx, - .in_ptw_idx = is_secure ? ARMMMUIdx_Phys_S : ARMMMUIdx_Phys_NS, + .in_ptw_idx = arm_space_to_phys(space), + .in_space = space, .in_secure = is_secure, .in_debug = true, }; @@ -292,10 +296,17 @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw, } /* Check if page table walk is to secure or non-secure PA space. */ - ptw->out_secure = (is_secure - && !(pte_secure + if (is_secure) { + bool out_secure = !(pte_secure ? env->cp15.vstcr_el2 & VSTCR_SW - : env->cp15.vtcr_el2 & VTCR_NSW)); + : env->cp15.vtcr_el2 & VTCR_NSW); + if (!out_secure) { + is_secure = false; + space = ARMSS_NonSecure; + } + } + ptw->out_secure = is_secure; + ptw->out_space = space; ptw->out_be = regime_translation_big_endian(env, mmu_idx); return true; @@ -326,7 +337,10 @@ static uint32_t arm_ldl_ptw(CPUARMState *env, S1Translate *ptw, } } else { /* Page tables are in MMIO. */ - MemTxAttrs attrs = { .secure = ptw->out_secure }; + MemTxAttrs attrs = { + .secure = ptw->out_secure, + .space = ptw->out_space, + }; AddressSpace *as = arm_addressspace(cs, attrs); MemTxResult result = MEMTX_OK; @@ -369,7 +383,10 @@ static uint64_t arm_ldq_ptw(CPUARMState *env, S1Translate *ptw, #endif } else { /* Page tables are in MMIO. */ - MemTxAttrs attrs = { .secure = ptw->out_secure }; + MemTxAttrs attrs = { + .secure = ptw->out_secure, + .space = ptw->out_space, + }; AddressSpace *as = arm_addressspace(cs, attrs); MemTxResult result = MEMTX_OK; @@ -875,6 +892,7 @@ static bool get_phys_addr_v6(CPUARMState *env, S1Translate *ptw, * regime, because the attribute will already be non-secure. */ result->f.attrs.secure = false; + result->f.attrs.space = ARMSS_NonSecure; } result->f.phys_addr = phys_addr; return false; @@ -1579,6 +1597,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, * regime, because the attribute will already be non-secure. */ result->f.attrs.secure = false; + result->f.attrs.space = ARMSS_NonSecure; } /* When in aarch64 mode, and BTI is enabled, remember GP in the TLB. */ @@ -2363,6 +2382,7 @@ static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, */ if (sattrs.ns) { result->f.attrs.secure = false; + result->f.attrs.space = ARMSS_NonSecure; } else if (!secure) { /* * NS access to S memory must fault. @@ -2712,6 +2732,7 @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw, bool is_secure = ptw->in_secure; bool ret, ipa_secure, s2walk_secure; ARMCacheAttrs cacheattrs1; + ARMSecuritySpace ipa_space, s2walk_space; bool is_el0; uint64_t hcr; @@ -2724,20 +2745,24 @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw, ipa = result->f.phys_addr; ipa_secure = result->f.attrs.secure; + ipa_space = result->f.attrs.space; if (is_secure) { /* Select TCR based on the NS bit from the S1 walk. */ s2walk_secure = !(ipa_secure ? env->cp15.vstcr_el2 & VSTCR_SW : env->cp15.vtcr_el2 & VTCR_NSW); + s2walk_space = arm_secure_to_space(s2walk_secure); } else { assert(!ipa_secure); s2walk_secure = false; + s2walk_space = ipa_space; } is_el0 = ptw->in_mmu_idx == ARMMMUIdx_Stage1_E0; ptw->in_mmu_idx = s2walk_secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2; - ptw->in_ptw_idx = s2walk_secure ? ARMMMUIdx_Phys_S : ARMMMUIdx_Phys_NS; + ptw->in_ptw_idx = arm_space_to_phys(s2walk_space); ptw->in_secure = s2walk_secure; + ptw->in_space = s2walk_space; /* * S1 is done, now do S2 translation. @@ -2825,11 +2850,12 @@ static bool get_phys_addr_with_struct(CPUARMState *env, S1Translate *ptw, ARMMMUIdx s1_mmu_idx; /* - * The page table entries may downgrade secure to non-secure, but - * cannot upgrade an non-secure translation regime's attributes - * to secure. + * The page table entries may downgrade Secure to NonSecure, but + * cannot upgrade a NonSecure translation regime's attributes + * to Secure or Realm. */ result->f.attrs.secure = is_secure; + result->f.attrs.space = ptw->in_space; switch (mmu_idx) { case ARMMMUIdx_Phys_S: @@ -2871,7 +2897,7 @@ static bool get_phys_addr_with_struct(CPUARMState *env, S1Translate *ptw, default: /* Single stage and second stage uses physical for ptw. */ - ptw->in_ptw_idx = is_secure ? ARMMMUIdx_Phys_S : ARMMMUIdx_Phys_NS; + ptw->in_ptw_idx = arm_space_to_phys(ptw->in_space); break; } @@ -2946,6 +2972,7 @@ bool get_phys_addr_with_secure(CPUARMState *env, target_ulong address, S1Translate ptw = { .in_mmu_idx = mmu_idx, .in_secure = is_secure, + .in_space = arm_secure_to_space(is_secure), }; return get_phys_addr_with_struct(env, &ptw, address, access_type, result, fi); @@ -2955,7 +2982,10 @@ bool get_phys_addr(CPUARMState *env, target_ulong address, MMUAccessType access_type, ARMMMUIdx mmu_idx, GetPhysAddrResult *result, ARMMMUFaultInfo *fi) { - bool is_secure; + S1Translate ptw = { + .in_mmu_idx = mmu_idx, + }; + ARMSecuritySpace ss; switch (mmu_idx) { case ARMMMUIdx_E10_0: @@ -2968,30 +2998,55 @@ bool get_phys_addr(CPUARMState *env, target_ulong address, case ARMMMUIdx_Stage1_E1: case ARMMMUIdx_Stage1_E1_PAN: case ARMMMUIdx_E2: - is_secure = arm_is_secure_below_el3(env); + ss = arm_security_space_below_el3(env); break; case ARMMMUIdx_Stage2: + /* + * For Secure EL2, we need this index to be NonSecure; + * otherwise this will already be NonSecure or Realm. + */ + ss = arm_security_space_below_el3(env); + if (ss == ARMSS_Secure) { + ss = ARMSS_NonSecure; + } + break; case ARMMMUIdx_Phys_NS: case ARMMMUIdx_MPrivNegPri: case ARMMMUIdx_MUserNegPri: case ARMMMUIdx_MPriv: case ARMMMUIdx_MUser: - is_secure = false; + ss = ARMSS_NonSecure; break; - case ARMMMUIdx_E3: case ARMMMUIdx_Stage2_S: case ARMMMUIdx_Phys_S: case ARMMMUIdx_MSPrivNegPri: case ARMMMUIdx_MSUserNegPri: case ARMMMUIdx_MSPriv: case ARMMMUIdx_MSUser: - is_secure = true; + ss = ARMSS_Secure; + break; + case ARMMMUIdx_E3: + if (arm_feature(env, ARM_FEATURE_AARCH64) && + cpu_isar_feature(aa64_rme, env_archcpu(env))) { + ss = ARMSS_Root; + } else { + ss = ARMSS_Secure; + } + break; + case ARMMMUIdx_Phys_Root: + ss = ARMSS_Root; + break; + case ARMMMUIdx_Phys_Realm: + ss = ARMSS_Realm; break; default: g_assert_not_reached(); } - return get_phys_addr_with_secure(env, address, access_type, mmu_idx, - is_secure, result, fi); + + ptw.in_space = ss; + ptw.in_secure = arm_space_is_secure(ss); + return get_phys_addr_with_struct(env, &ptw, address, access_type, + result, fi); } hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr, @@ -2999,9 +3054,11 @@ hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr, { ARMCPU *cpu = ARM_CPU(cs); CPUARMState *env = &cpu->env; + ARMSecuritySpace ss = arm_security_space(env); S1Translate ptw = { .in_mmu_idx = arm_mmu_idx(env), - .in_secure = arm_is_secure(env), + .in_space = ss, + .in_secure = arm_space_is_secure(ss), .in_debug = true, }; GetPhysAddrResult res = {}; From patchwork Mon Feb 20 23:26:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 655130 Delivered-To: patch@linaro.org Received: by 2002:adf:9bcd:0:0:0:0:0 with SMTP id e13csp1661211wrc; Mon, 20 Feb 2023 15:27:13 -0800 (PST) X-Google-Smtp-Source: AK7set9xaVXpvEzX98s4hpZgyDpqTvdnT8hJapvb8dSqGQMfzkJE8DuHEA70TxEvVcxLNqDVkmMe X-Received: by 2002:ad4:5fcd:0:b0:56f:4d1:cfbc with SMTP id jq13-20020ad45fcd000000b0056f04d1cfbcmr4221411qvb.33.1676935633539; Mon, 20 Feb 2023 15:27:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676935633; cv=none; d=google.com; s=arc-20160816; b=RHuS+7Z772o1cBrdjv4eAl4WsXiFcKgApm5zTFKodMMGNyBWW90iDGk+sh8mJnvAo5 pTTEOqjs4zy6+gjoUUyByCW48coDCQlL7yxEnaTpiVXZhNogDJICkKdIMsjMVPmO/fVv wa7NELI0uBEj7AKuM+51Vx/LzEnBQp8ZhUbhWKXs5i0LpK+7VjrTPHCK0EEEmHOkcYYJ ijf/Wd2sbS6KV9fnJsFE/vL8TxxCfxMzmYrmdxaDUj8z8xsLjx/Lc/dyr49MvFWCLUGZ VHsT9gWMiHjyhA6Ps7W3EbAQgm0VeLiWdNf9FYDz2kRPuuYmWTWEPa7jOeLQuUoncKB6 qNMg== 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=9O4rQ+1tSrDA/VIHaikB47RvthTap5eXu1DpMH/jhqs=; b=SZMUl1OEPR6jnVB4N0lQ+8nlFacbt8OBXCzuXQk7CaB/lsl0eE5A0xuhMJWbrjYZMB YPZKzJ8RJbesEYcF4mS7EArpHt5GKrolPBa1gqQnApVtW9VF/ZXYXG6w3bflf6IjZrJ0 Zf1O2U09pWIY/vtUUK8Y6emUnE0cVG9k71EMJCEJZzbT6dHcSwEiYOKK7GYbmyIJCxfo s41urxnIP5m7BEkz4o/9jBZwApmE0eDtqprUtB4sXLi3/haYYlKxCRxKtPvdu+iZNxXQ QheR3UqYAIxfyRZ+AoBdINdIEujWz7wvMG18viT4RNyxzwwh2E1uplvIgk6KEjZ52n56 hr9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="A7/KCoOv"; 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 fi14-20020a0562141a4e00b005376fc51789si2222614qvb.43.2023.02.20.15.27.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Feb 2023 15:27:13 -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=@linaro.org header.s=google header.b="A7/KCoOv"; 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 1pUFYc-00048M-5m; Mon, 20 Feb 2023 18:26:54 -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 1pUFYZ-00043a-Os for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:26:51 -0500 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUFYX-0000Or-NT for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:26:51 -0500 Received: by mail-pl1-x636.google.com with SMTP id e5so4173347plg.8 for ; Mon, 20 Feb 2023 15:26:49 -0800 (PST) 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 :message-id:reply-to; bh=9O4rQ+1tSrDA/VIHaikB47RvthTap5eXu1DpMH/jhqs=; b=A7/KCoOvzdkchqGOJQIfJM9hQTufU2tNpCTEO9VwXDuY3E49vaflRpzqnfGj3L7wj8 PzSsZGiEDQm36f5zCTtlpyrTCSmCzotgP4daU2b1/s+YLmcOTRxBlP/Yoadhl3UcOWta qa4OL9tAHQzVeHvDwQfMnDlC9U3MxtnrHlYF5diehNDjmrABFwEqt6iqEeCwhkJ09cSa lFX1gqWKE+s8LUNTySJATjVjRx7yxUphN8com+DzFHF0HjZ9yr/EzDPN7SUUxj33aafn uDAW+L9IWYfL1jp0xFib/LAb8HJjP2LFBnY7zq55ZfgaL3lwYzUQKBjelkqGVfsdPfYK cHIQ== 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:message-id:reply-to; bh=9O4rQ+1tSrDA/VIHaikB47RvthTap5eXu1DpMH/jhqs=; b=tcSRIjR/3NmbcNfgjdyhjH9srE9bfUfXl5s4svtTogr1qeO3CdtryNoXwQmfhr8oMZ dsFEj7dRGiodpCH+EwQBH0tOHmqFMZ0WbtvW9Q38tozHmrve40Y7XUqetnpBG0QMQXZa zJXNvuU3o6zbugJPPPtCBIgYJrvqx7EHOJxjHqqmWsER91D9V5tgpBXLz7x3/ZY8rPrf xE0OMO0ScyoCgO7ism/TmcIk6AchxcifVjA0lRQxLPszsqT3CLuvwAkyTI+Vb+LSi9QD H7XIgSG/ZG5mddObMjKnhNmB4Z9dP8nBX2W5wtrbyWIENHp4zi1/3Cp2AqN8QKr3kLzR 1dhw== X-Gm-Message-State: AO0yUKUEXHudxzTG/ngajw7rMzBxBJEcqsu9WjFiQ8SJ4X8SagsDS8Mr K2/TydJZyNOCz+Qm6Pd35QGS9AkLRFQGU5/z3mw= X-Received: by 2002:a17:903:2305:b0:19a:a4fc:7f80 with SMTP id d5-20020a170903230500b0019aa4fc7f80mr6249197plh.26.1676935608092; Mon, 20 Feb 2023 15:26:48 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id j10-20020a170902690a00b001992e74d058sm2665348plk.7.2023.02.20.15.26.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Feb 2023 15:26:47 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH v2 11/21] target/arm: NSTable is RES0 for the RME EL3 regime Date: Mon, 20 Feb 2023 13:26:16 -1000 Message-Id: <20230220232626.429947-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220232626.429947-1-richard.henderson@linaro.org> References: <20230220232626.429947-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.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 Test in_space instead of in_secure so that we don't switch out of Root space. Handle the output space change immediately, rather than try and combine the NSTable and NS bits later. Signed-off-by: Richard Henderson --- target/arm/ptw.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 7745287a46..d612e5f38a 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -1240,7 +1240,6 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, { ARMCPU *cpu = env_archcpu(env); ARMMMUIdx mmu_idx = ptw->in_mmu_idx; - bool is_secure = ptw->in_secure; int32_t level; ARMVAParameters param; uint64_t ttbr; @@ -1256,7 +1255,6 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, uint64_t descaddrmask; bool aarch64 = arm_el_is_aa64(env, el); uint64_t descriptor, new_descriptor; - bool nstable; /* TODO: This code does not support shareability levels. */ if (aarch64) { @@ -1417,20 +1415,19 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, descaddrmask = MAKE_64BIT_MASK(0, 40); } descaddrmask &= ~indexmask_grainsize; - - /* - * Secure accesses start with the page table in secure memory and - * can be downgraded to non-secure at any step. Non-secure accesses - * remain non-secure. We implement this by just ORing in the NSTable/NS - * bits at each step. - */ - tableattrs = is_secure ? 0 : (1 << 4); + tableattrs = 0; next_level: descaddr |= (address >> (stride * (4 - level))) & indexmask; descaddr &= ~7ULL; - nstable = extract32(tableattrs, 4, 1); - if (nstable && ptw->in_secure) { + + /* + * Process the NSTable bit from the previous level. This changes + * the table address space and the output space from Secure to + * NonSecure. With RME, the EL3 translation regime does not change + * from Root to NonSecure. + */ + if (extract32(tableattrs, 4, 1) && ptw->in_space == ARMSS_Secure) { /* * Stage2_S -> Stage2 or Phys_S -> Phys_NS * Assert the relative order of the secure/non-secure indexes. @@ -1439,7 +1436,11 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, QEMU_BUILD_BUG_ON(ARMMMUIdx_Stage2_S + 1 != ARMMMUIdx_Stage2); ptw->in_ptw_idx += 1; ptw->in_secure = false; + ptw->in_space = ARMSS_NonSecure; + result->f.attrs.secure = false; + result->f.attrs.space = ARMSS_NonSecure; } + if (!S1_ptw_translate(env, ptw, descaddr, fi)) { goto do_fault; } @@ -1542,7 +1543,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, */ attrs = new_descriptor & (MAKE_64BIT_MASK(2, 10) | MAKE_64BIT_MASK(50, 14)); if (!regime_is_stage2(mmu_idx)) { - attrs |= nstable << 5; /* NS */ + attrs |= !ptw->in_secure << 5; /* NS */ if (!param.hpd) { attrs |= extract64(tableattrs, 0, 2) << 53; /* XN, PXN */ /* From patchwork Mon Feb 20 23:26:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 655144 Delivered-To: patch@linaro.org Received: by 2002:adf:9bcd:0:0:0:0:0 with SMTP id e13csp1661819wrc; Mon, 20 Feb 2023 15:29:00 -0800 (PST) X-Google-Smtp-Source: AK7set923vbL7f3PcdHTwjSl83o8l2ffXVWFQh5Ny2JLjcnUzBrSw09VEKebAM3ahv/OAq3Q7H21 X-Received: by 2002:a05:622a:190a:b0:3bd:155c:3ac8 with SMTP id w10-20020a05622a190a00b003bd155c3ac8mr23436320qtc.67.1676935740624; Mon, 20 Feb 2023 15:29:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676935740; cv=none; d=google.com; s=arc-20160816; b=pM3ppq4pdilYLbYiTFBnjmFtdFgg5MExb/L+RYzE27ZItaGO/6XHBvkayDT/GeNg7o Astp0KAx3ALiBXJawymS7AyDPfHxR0PWCtVt8k8icVHnKFrOJjNuVQB8rmIlEeqmVVnQ mSznJCSgTDYCW8Hj4oTAVDhWrkdctV8eLL3KkBkcTgC9Ux/dq3uy9vzeU154RCni/6FW +oyFYQcp6isZF3NajR8IDBLSY3PiclZZpufJ+hfmzn1ERqF9PMXTttOkobsaJ832xsJH W5ZT2qRyFg5qCpMq//NQYY6B7RrE4PCRvrKjntMgdgUb2fiwC3P2rZhThzveZ5t6QW/V 392g== 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=01eI1hEc43nacXFE44/G2p50ZjHhh23ihEX6wOuioA8=; b=TCrBqBZZPBqrdab7fZ9o+FXXuxFicmrGf41MYvD0MAEGHnqTeFpwo6ZgAabayhiLjE u0KPLeyf+obZovZLJJdnCnnW1YjfQQS7sibx2UB/0igYTbffd0B17M+8sEvgXPJrRDaX v0ufB8z5a0naTPh7oVUoNMVErRHPgfx7TOz1Nmcdvo9G+HR5Bz1MchqvSCfaU2iUNtFh t7uzPdVkGGWqmpp/+qC5Ri7GOUSjSm0z4c3wInVOVFHqcoAXl0JhivJQMgQH9JH1jlR3 uj8uXehYO7wYWmxdNl2xxOXwCfFwwZd448ERgMpp5ynkJhj7nhFceWns2xHML2VXPBWN X8bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HLA5kCka; 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 o12-20020a05622a044c00b003b9b4ba1b52si11067857qtx.73.2023.02.20.15.29.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Feb 2023 15:29:00 -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=@linaro.org header.s=google header.b=HLA5kCka; 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 1pUFYe-0004Ev-Nx; Mon, 20 Feb 2023 18:26:56 -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 1pUFYa-00044B-Dy for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:26:52 -0500 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUFYY-0000Ly-HF for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:26:52 -0500 Received: by mail-pl1-x62e.google.com with SMTP id ky4so4300889plb.3 for ; Mon, 20 Feb 2023 15:26:50 -0800 (PST) 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 :message-id:reply-to; bh=01eI1hEc43nacXFE44/G2p50ZjHhh23ihEX6wOuioA8=; b=HLA5kCka6JXxRy3XBdm/Wk+vRHf0cF8EQuJSwUkcjrHtAdGHyfzdweVt96dBE42so2 Z2wix15PGpX8SbvT0KkC1N3XVzAXbtDf9VQH2wyQ0fzTvWI4z6Tr4kV7frDNnLpGtGY5 NrRqChIAQ0s+D68iOOvXFZOXA8Bkzz+x3/cxla6iRix7Om66gQVVw3Vk9poKirncq+Fb N0mpT6wa2o75RTWDMpuMdHFl98V6HIf4LRUdVdmnE0xnpr02BHfymqjKem8p05UA8vts eUm3QHnJDdjvqJJ1LU47LSS5LcPTjuizEYIZrN5u9lGCqigRQkhkKuKkzG0QmD83+xQ7 pKjA== 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:message-id:reply-to; bh=01eI1hEc43nacXFE44/G2p50ZjHhh23ihEX6wOuioA8=; b=hOER+6IoUQyKSn+NN1gosp+6cZc9nvPrTm7myITNPKWU7xCf1a9bh8dmC/lGvoPLe7 VPd17SHVZYKrtGOSvfV6yokcNJflI562/tCsGprWZTZQ/rGeb816YvInNprOdt5Zx2We WwrJKu2mjW7EkEu0EhtIrPAVkI+dVOu0CV7M1oPABgrMQI+bjszEtQ5w44whgMWLFlIN xdadkfu5Oiwh1rE1pvuqrdysBBNj56oOZolOkZlx1whvTB1l+QnE3HMzasiSLGGAeo4D Ma/bVXfZDRgqXEzeAbR+tiEJ6FNslo9xizACnf2tYnQ4odiq7/Soqqbl+JowlpZq4blk I5aw== X-Gm-Message-State: AO0yUKXekEAtjol0AiFz20A1aVNCxBsDz//h5bUSwcxLkvPHkLfDIB1y SUnsmVOqGVN7bQIV0ml+YQdiUnaYLsyxhLgBK5U= X-Received: by 2002:a17:902:d4c8:b0:199:30a6:376c with SMTP id o8-20020a170902d4c800b0019930a6376cmr3190508plg.68.1676935609584; Mon, 20 Feb 2023 15:26:49 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id j10-20020a170902690a00b001992e74d058sm2665348plk.7.2023.02.20.15.26.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Feb 2023 15:26:49 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH v2 12/21] target/arm: Handle Block and Page bits for security space Date: Mon, 20 Feb 2023 13:26:17 -1000 Message-Id: <20230220232626.429947-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220232626.429947-1-richard.henderson@linaro.org> References: <20230220232626.429947-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.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=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 With Realm security state, bit 55 of a block or page descriptor during the stage2 walk becomes the NS bit; during the stage1 walk the bit 5 NS bit is RES0. With Root security state, bit 11 of the block or page descriptor during the stage1 walk becomes the NSE bit. Rather than collecting an NS bit and applying it later, compute the output pa space from the input pa space and unconditionally assign. This means that we no longer need to adjust the output space earlier for the NSTable bit. Signed-off-by: Richard Henderson --- target/arm/ptw.c | 91 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 73 insertions(+), 18 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index d612e5f38a..a9a9a8a403 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -956,12 +956,14 @@ static int get_S2prot(CPUARMState *env, int s2ap, int xn, bool s1_is_el0) * @mmu_idx: MMU index indicating required translation regime * @is_aa64: TRUE if AArch64 * @ap: The 2-bit simple AP (AP[2:1]) - * @ns: NS (non-secure) bit * @xn: XN (execute-never) bit * @pxn: PXN (privileged execute-never) bit + * @in_pa: The original input pa space + * @out_pa: The output pa space, modified by NSTable, NS, and NSE */ static int get_S1prot(CPUARMState *env, ARMMMUIdx mmu_idx, bool is_aa64, - int ap, int ns, int xn, int pxn) + int ap, int xn, int pxn, + ARMSecuritySpace in_pa, ARMSecuritySpace out_pa) { bool is_user = regime_is_user(env, mmu_idx); int prot_rw, user_rw; @@ -982,7 +984,8 @@ static int get_S1prot(CPUARMState *env, ARMMMUIdx mmu_idx, bool is_aa64, } } - if (ns && arm_is_secure(env) && (env->cp15.scr_el3 & SCR_SIF)) { + if (out_pa == ARMSS_NonSecure && in_pa == ARMSS_Secure && + (env->cp15.scr_el3 & SCR_SIF)) { return prot_rw; } @@ -1250,11 +1253,12 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, int32_t stride; int addrsize, inputsize, outputsize; uint64_t tcr = regime_tcr(env, mmu_idx); - int ap, ns, xn, pxn; + int ap, xn, pxn; uint32_t el = regime_el(env, mmu_idx); uint64_t descaddrmask; bool aarch64 = arm_el_is_aa64(env, el); uint64_t descriptor, new_descriptor; + ARMSecuritySpace out_space; /* TODO: This code does not support shareability levels. */ if (aarch64) { @@ -1437,8 +1441,6 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, ptw->in_ptw_idx += 1; ptw->in_secure = false; ptw->in_space = ARMSS_NonSecure; - result->f.attrs.secure = false; - result->f.attrs.space = ARMSS_NonSecure; } if (!S1_ptw_translate(env, ptw, descaddr, fi)) { @@ -1556,15 +1558,75 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, } ap = extract32(attrs, 6, 2); + out_space = ptw->in_space; if (regime_is_stage2(mmu_idx)) { - ns = mmu_idx == ARMMMUIdx_Stage2; + /* + * R_GYNXY: For stage2 in Realm security state, bit 55 is NS. + * The bit remains ignored for other security states. + */ + if (out_space == ARMSS_Realm && extract64(attrs, 55, 1)) { + out_space = ARMSS_NonSecure; + } xn = extract64(attrs, 53, 2); result->f.prot = get_S2prot(env, ap, xn, s1_is_el0); } else { - ns = extract32(attrs, 5, 1); + int nse, ns = extract32(attrs, 5, 1); + switch (out_space) { + case ARMSS_Root: + /* + * R_GVZML: Bit 11 becomes the NSE field in the EL3 regime. + * R_XTYPW: NSE and NS together select the output pa space. + */ + nse = extract32(attrs, 11, 1); + out_space = (nse << 1) | ns; + if (out_space == ARMSS_Secure && + !cpu_isar_feature(aa64_sel2, cpu)) { + out_space = ARMSS_NonSecure; + } + break; + case ARMSS_Secure: + if (ns) { + out_space = ARMSS_NonSecure; + } + break; + case ARMSS_Realm: + switch (mmu_idx) { + case ARMMMUIdx_Stage1_E0: + case ARMMMUIdx_Stage1_E1: + case ARMMMUIdx_Stage1_E1_PAN: + /* I_CZPRF: For Realm EL1&0 stage1, NS bit is RES0. */ + break; + case ARMMMUIdx_E2: + case ARMMMUIdx_E20_0: + case ARMMMUIdx_E20_2: + case ARMMMUIdx_E20_2_PAN: + /* + * R_LYKFZ, R_WGRZN: For Realm EL2 and EL2&1, + * NS changes the output to non-secure space. + */ + if (ns) { + out_space = ARMSS_NonSecure; + } + break; + default: + g_assert_not_reached(); + } + break; + case ARMSS_NonSecure: + /* R_QRMFF: For NonSecure state, the NS bit is RES0. */ + break; + default: + g_assert_not_reached(); + } xn = extract64(attrs, 54, 1); pxn = extract64(attrs, 53, 1); - result->f.prot = get_S1prot(env, mmu_idx, aarch64, ap, ns, xn, pxn); + + /* + * Note that we modified ptw->in_space earlier for NSTable, but + * result->f.attrs retains a copy of the original security space. + */ + result->f.prot = get_S1prot(env, mmu_idx, aarch64, ap, xn, pxn, + result->f.attrs.space, out_space); } if (!(result->f.prot & (1 << access_type))) { @@ -1591,15 +1653,8 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, } } - if (ns) { - /* - * The NS bit will (as required by the architecture) have no effect if - * the CPU doesn't support TZ or this is a non-secure translation - * regime, because the attribute will already be non-secure. - */ - result->f.attrs.secure = false; - result->f.attrs.space = ARMSS_NonSecure; - } + result->f.attrs.space = out_space; + result->f.attrs.secure = arm_space_is_secure(out_space); /* When in aarch64 mode, and BTI is enabled, remember GP in the TLB. */ if (aarch64 && cpu_isar_feature(aa64_bti, cpu)) { From patchwork Mon Feb 20 23:26:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 655148 Delivered-To: patch@linaro.org Received: by 2002:adf:9bcd:0:0:0:0:0 with SMTP id e13csp1661958wrc; Mon, 20 Feb 2023 15:29:21 -0800 (PST) X-Google-Smtp-Source: AK7set/C7YSf6GwfLurLNJcYFQR4rX3oeZg3z17gRaWmpXNci2RsxkrDBYP1Bf6u4jNIAZldKDQp X-Received: by 2002:a05:622a:60f:b0:3a7:e9a2:4f4a with SMTP id z15-20020a05622a060f00b003a7e9a24f4amr19685424qta.8.1676935761133; Mon, 20 Feb 2023 15:29:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676935761; cv=none; d=google.com; s=arc-20160816; b=jFNsW16zR9SZ2lQWSsCdh+8X9ELVuekdMMP+DvnzXa+W2kgllLR5P7r5n0aq0Xo7B5 INU35Pe7dQpvWpir1DU8eSOVcd1SrImeV/J+LdIhtfSe3yMiCn2Gj9utdJyDCPy7vHkG Ae2diiwCveq7Ks73x4b9s+GdX1XOQNobbp3QDJnMKIqLOiU/3kOdNeecPc/uyQYONupi H5vDaaR83P8f3KTWQqAESUWfivXUt7jtgplqOQNh5wzNDjWq2V+g3MNxB7lniWByqksI xFKb5z/SMcd4SdY2VY5iuq9YCKHs/fY0gVe5jgrO3ywUPnZSgSMkERuYIHsY+BdoYqP9 Xacg== 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=Q2wDlc9y+ZmDdlYUvnbEL+qYl6ONKTEgAFqhyLih/rk=; b=WSozsbENa0opebraAlAkvMaIksI2wnbuF9JK2diZQRbQWIlV6ck0Qf7q+ZvfTb1JWD rtLd/G5BIptoKrP8hKsrZIkVtFn6yh8c6VLB01UWZLDIN+VUBgkgd2hjGGP3pFWCwXbG tvDFD1AbBA3LJpkroum1Tf3FT4+Cc8Bakhx+jiaGpsWTadQeo3MS1CIjItoar2IR8BTD +WOHBX8lNvSBELFJkILvC6s9FdVwIOERV2ZFUxfAIOcQDGpsRmsE/reV5d1s7s+IF80Y YyEXzy4B6EpVgG2XDZaqbEwJ/WpeZMxpjvKIycO/i1Tu8nF/BetLhdrP7+A9YUdppT4H L+OQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SI9939Ck; 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 u13-20020a05620a454d00b00738e6f037d4si11404532qkp.757.2023.02.20.15.29.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Feb 2023 15:29:21 -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=@linaro.org header.s=google header.b=SI9939Ck; 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 1pUFYe-0004EY-K9; Mon, 20 Feb 2023 18:26:56 -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 1pUFYb-00046u-LU for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:26:53 -0500 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUFYZ-0000Os-SV for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:26:53 -0500 Received: by mail-pj1-x1032.google.com with SMTP id nw10-20020a17090b254a00b00233d7314c1cso3015542pjb.5 for ; Mon, 20 Feb 2023 15:26:51 -0800 (PST) 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 :message-id:reply-to; bh=Q2wDlc9y+ZmDdlYUvnbEL+qYl6ONKTEgAFqhyLih/rk=; b=SI9939CkfMXh2gPFkBNyfUSn311jdAXhlcxpI26CQBa3jmX48aYVUJnNUe298tv0tA /55rvZT1CahipYUH1Ds2W1emizOmKY1KMHEU2McyMcTk5Ao+cM0895YjzE0oVYAZyO9N gaQAUwBjTxhKcIBvHFgpNgWsr1lanhNcQWEz6QMY/nM8ywl9WNlJnL0Z+NoJC+M4rKw5 YlJkGHlgHVgr1LiYKywbBMqXEZpHmEO13E1a3u94o6N0MKb7RhgNEouS4cgr51/G+lhE c4x0uqPh03jiltHhtgLOENZ2EFiy6G/ANfowJLNf13Vo3+O3RfklFKG8YAJZfFVpg+Ao 0Q4Q== 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:message-id:reply-to; bh=Q2wDlc9y+ZmDdlYUvnbEL+qYl6ONKTEgAFqhyLih/rk=; b=YoqeTugKycJ9mJGjDnQ0btWiO8AhbOgFdf8Cht+yQ//rMk2CXlDixZP9EsBsibWeZb PcK0ho4sDhqy+8uHltztTST3HWvBFPqKveuKdUP6Y25F8Y0fjO7nPjxHCgKC3hpXUqRJ 2r+xiDHSbpUc1oryGi7gaBBM1kK+LiskJT7xEjjERhkhmsbFMd+MaAPb7op007BaIyzy 6ynyF7EegBJncjjFTeAKCW8ei5CFz4kHiZKWrUfru7b81vOSEIezuoQQ1z1Cp8Ys4NjU n9NK5nR63hFzX9B6SPrOK5UptnLohEC2WlL8DGg1EeiBERa1pABLHbnf/X/CzA9zoXb7 4VVw== X-Gm-Message-State: AO0yUKUi1XaG5dAveS1VT358/CNU3+EAC0domKdLnbKt610lbWfqNELb lt/a3VtkWl/UTp5AutgCe8TKkPahRELH4HZD6D0= X-Received: by 2002:a17:902:e547:b0:19a:a815:2876 with SMTP id n7-20020a170902e54700b0019aa8152876mr4075649plf.62.1676935610970; Mon, 20 Feb 2023 15:26:50 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id j10-20020a170902690a00b001992e74d058sm2665348plk.7.2023.02.20.15.26.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Feb 2023 15:26:50 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH v2 13/21] target/arm: Handle no-execute for Realm and Root regimes Date: Mon, 20 Feb 2023 13:26:18 -1000 Message-Id: <20230220232626.429947-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220232626.429947-1-richard.henderson@linaro.org> References: <20230220232626.429947-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1032.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 While Root and Realm may read and write data from other spaces, neither may execute from other pa spaces. This happens for Stage1 EL3, EL2, EL2&0, but stage2 EL1&0. Signed-off-by: Richard Henderson --- target/arm/ptw.c | 52 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 6 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index a9a9a8a403..54e72baff5 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -909,7 +909,7 @@ do_fault: * @xn: XN (execute-never) bits * @s1_is_el0: true if this is S2 of an S1+2 walk for EL0 */ -static int get_S2prot(CPUARMState *env, int s2ap, int xn, bool s1_is_el0) +static int get_S2prot_noexecute(int s2ap) { int prot = 0; @@ -919,6 +919,12 @@ static int get_S2prot(CPUARMState *env, int s2ap, int xn, bool s1_is_el0) if (s2ap & 2) { prot |= PAGE_WRITE; } + return prot; +} + +static int get_S2prot(CPUARMState *env, int s2ap, int xn, bool s1_is_el0) +{ + int prot = get_S2prot_noexecute(s2ap); if (cpu_isar_feature(any_tts2uxn, env_archcpu(env))) { switch (xn) { @@ -984,9 +990,39 @@ static int get_S1prot(CPUARMState *env, ARMMMUIdx mmu_idx, bool is_aa64, } } - if (out_pa == ARMSS_NonSecure && in_pa == ARMSS_Secure && - (env->cp15.scr_el3 & SCR_SIF)) { - return prot_rw; + if (in_pa != out_pa) { + switch (in_pa) { + case ARMSS_Root: + /* + * R_ZWRVD: permission fault for insn fetched from non-Root, + * I_WWBFB: SIF has no effect in EL3. + */ + return prot_rw; + case ARMSS_Realm: + /* + * R_PKTDS: permission fault for insn fetched from non-Realm, + * for Realm EL2 or EL2&0. The corresponding fault for EL1&0 + * happens during any stage2 translation. + */ + switch (mmu_idx) { + case ARMMMUIdx_E2: + case ARMMMUIdx_E20_0: + case ARMMMUIdx_E20_2: + case ARMMMUIdx_E20_2_PAN: + return prot_rw; + default: + break; + } + break; + case ARMSS_Secure: + if (env->cp15.scr_el3 & SCR_SIF) { + return prot_rw; + } + break; + default: + /* Input NonSecure must have output NonSecure. */ + g_assert_not_reached(); + } } /* TODO have_wxn should be replaced with @@ -1563,12 +1599,16 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, /* * R_GYNXY: For stage2 in Realm security state, bit 55 is NS. * The bit remains ignored for other security states. + * R_YMCSL: Executing an insn fetched from non-Realm causes + * a stage2 permission fault. */ if (out_space == ARMSS_Realm && extract64(attrs, 55, 1)) { out_space = ARMSS_NonSecure; + result->f.prot = get_S2prot_noexecute(ap); + } else { + xn = extract64(attrs, 53, 2); + result->f.prot = get_S2prot(env, ap, xn, s1_is_el0); } - xn = extract64(attrs, 53, 2); - result->f.prot = get_S2prot(env, ap, xn, s1_is_el0); } else { int nse, ns = extract32(attrs, 5, 1); switch (out_space) { From patchwork Mon Feb 20 23:26:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 655143 Delivered-To: patch@linaro.org Received: by 2002:adf:9bcd:0:0:0:0:0 with SMTP id e13csp1661815wrc; Mon, 20 Feb 2023 15:29:00 -0800 (PST) X-Google-Smtp-Source: AK7set8oSY0Xv5uClJkM2zOeVOfGak1QxYT/IVfSJ3u0nofxaLjDe0/ZZzRrjgytcYUv+pt+grYA X-Received: by 2002:a05:622a:182:b0:3b9:bd77:1971 with SMTP id s2-20020a05622a018200b003b9bd771971mr19092837qtw.42.1676935740192; Mon, 20 Feb 2023 15:29:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676935740; cv=none; d=google.com; s=arc-20160816; b=X5UTY/Xnk0WFr6zmZmZ2ZNiqEi35rAFRadPMZn6dGU+MAN+35NgO1Hmfh5nDc24r4P GNLibhzSyNbXA3AdbjVL4LaatAzvtKBrMfSWmTLEYlvc48o5nF6n2SVmIjh+LSRonDP0 cP0831fAbtP6kqK3IkUNKnf3wTCXImHmKD2ojxnNRIOQwHzCDUDGewyXikMzL96LcsdA HozqYi1ILRGSt+GIwBjDd6dFXlgK0LAH0VIQy3up3DgeZmrimymGa4cHZJ7WCBkb3hg6 AiLBKt7Y8x+y53PZd/BzYn+dw7eNllWYUHT8er9Eqf+Nqssi17Y7SbHu8skWvzExY9Ql oohQ== 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=d4Ci3OKSOkWsuhLLCd9XsBSP6q75DdfzpORQaA+1Aqs=; b=r1th81hmFs96PEszutPlQGTRWs9peDraOiSr72gAZ6X4z646JrwVNJvM+EhSgnDSfY jlvaqwJXXm5HPD5v6i16zfVNTKQ07n8Qb37pbZbJ37kIRnCm6g5U7gPBR+71K7UzTicb c3zrrCDoAqCzIUfH33JUt7/XWoPVZeq58ieA9mfg6MeXVayfR9zeNkZYJI0XL1/UBc/c GIXUUm/62QJpjqPIC2Jm8ALIZRY1PeU3tTESCMB4G9Le/Xlcx/rQikkl/KFHeBQu6oGd Sh79LJTs+YYF70j6z/tPqh/nCZAhJB+U0BPd7wqpc7b7mutICPFc1k1p6pNkRjRuij59 4i7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=F6+sFcFd; 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 x7-20020a05620a448700b0071c19e6d114si1177387qkp.113.2023.02.20.15.29.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Feb 2023 15:29:00 -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=@linaro.org header.s=google header.b=F6+sFcFd; 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 1pUFYj-0004Sf-EE; Mon, 20 Feb 2023 18:27:01 -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 1pUFYe-0004F6-NO for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:26:56 -0500 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUFYc-0000QK-3j for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:26:56 -0500 Received: by mail-pj1-x1034.google.com with SMTP id v3-20020a17090a6b0300b002341a2656e5so2795817pjj.1 for ; Mon, 20 Feb 2023 15:26:53 -0800 (PST) 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 :message-id:reply-to; bh=d4Ci3OKSOkWsuhLLCd9XsBSP6q75DdfzpORQaA+1Aqs=; b=F6+sFcFdW1ZtAnPQO4GNXDAuyz+Q5bFePcMX6bH5wEf8dqWAfCSSbjDG47dxVIXFKa Ed7KwcyusTxKS0uEEQxt0ggaXA8AQ5pS5hRdwB727Pz7dXcT5NdzM0BVEDV+PPG/Oh5V j/PoWFd9bTplJ5jjf/Wpwf3hWeybIf/kGTfEIUlvaeT+rAS8/aLG9/XjLl0NYeyoXp8d EjM3WLdZIQqgdBlygpF3JzNRBf8TYzE3uO0/oHESxtdxlIWfIreot5dZj7fWTDCnMN6r 6xKZM856uexts1tP5D9qszL+atib9EOFNywhzIRQf5h/pGJUMWinVTJfPfI1GH8u7Wbp vQZw== 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:message-id:reply-to; bh=d4Ci3OKSOkWsuhLLCd9XsBSP6q75DdfzpORQaA+1Aqs=; b=a4pChJ4GZCG9/VhBopvBSMzZn7C6wSwRf4CkezygqEDSQbGU2wXR1i6GRgDVoH2uY0 Ob92eXDtp9l5UsKvvajomQ/5yxY6lZU+wLWmtWGY8EH+IuMDQbIXi25IQbKJuSPRFKhx YXY/cUHtZ5OYC6p3JIv99I25Njw+oGPOvuSWhfN4G8d75wN/x/e+WyodffVm1TZix+eW xvsn6PV+C9/QDSkkCh+/loJ0A6apiWqeciW76XVX/WFuD8XvrZMkEg07ZOpz3OaYLnhq vyo0yCswN2zp/FwiKFN1F2hwzUK8inwSOcpByI6c/7dWSVqMgDxpnDR0ebO7KGMHRIdY jGfA== X-Gm-Message-State: AO0yUKUXayJ+r2C+Un6a9YOx69uhywTJ0x0N3CyLylqmm8597pwN0AJv b8f0MW4wjeljz8y64yJ1PWiiSK48haeF3RylBF8= X-Received: by 2002:a17:902:c40d:b0:19a:8284:83a2 with SMTP id k13-20020a170902c40d00b0019a828483a2mr4647179plk.10.1676935612564; Mon, 20 Feb 2023 15:26:52 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id j10-20020a170902690a00b001992e74d058sm2665348plk.7.2023.02.20.15.26.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Feb 2023 15:26:52 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell Subject: [PATCH v2 14/21] target/arm: Use get_phys_addr_with_struct in S1_ptw_translate Date: Mon, 20 Feb 2023 13:26:19 -1000 Message-Id: <20230220232626.429947-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220232626.429947-1-richard.henderson@linaro.org> References: <20230220232626.429947-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1034.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 Do not provide a fast-path for physical addresses, as those will need to be validated for GPC. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/ptw.c | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 54e72baff5..6e980654be 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -234,29 +234,22 @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw, * From gdbstub, do not use softmmu so that we don't modify the * state of the cpu at all, including softmmu tlb contents. */ - if (regime_is_stage2(s2_mmu_idx)) { - S1Translate s2ptw = { - .in_mmu_idx = s2_mmu_idx, - .in_ptw_idx = arm_space_to_phys(space), - .in_space = space, - .in_secure = is_secure, - .in_debug = true, - }; - GetPhysAddrResult s2 = { }; + S1Translate s2ptw = { + .in_mmu_idx = s2_mmu_idx, + .in_ptw_idx = arm_space_to_phys(space), + .in_space = space, + .in_secure = is_secure, + .in_debug = true, + }; + GetPhysAddrResult s2 = { }; - if (get_phys_addr_lpae(env, &s2ptw, addr, MMU_DATA_LOAD, - false, &s2, fi)) { - goto fail; - } - ptw->out_phys = s2.f.phys_addr; - pte_attrs = s2.cacheattrs.attrs; - pte_secure = s2.f.attrs.secure; - } else { - /* Regime is physical. */ - ptw->out_phys = addr; - pte_attrs = 0; - pte_secure = is_secure; + if (get_phys_addr_with_struct(env, &s2ptw, addr, + MMU_DATA_LOAD, &s2, fi)) { + goto fail; } + ptw->out_phys = s2.f.phys_addr; + pte_attrs = s2.cacheattrs.attrs; + pte_secure = s2.f.attrs.secure; ptw->out_host = NULL; ptw->out_rw = false; } else { From patchwork Mon Feb 20 23:26:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 655141 Delivered-To: patch@linaro.org Received: by 2002:adf:9bcd:0:0:0:0:0 with SMTP id e13csp1661733wrc; Mon, 20 Feb 2023 15:28:44 -0800 (PST) X-Google-Smtp-Source: AK7set+a4OP7K16SxhcVsMnm4ESW+pdRh6cAUZ7JGeYt1UCx5qWfgYA2hV4sIa2cVerSkeJkNVqF X-Received: by 2002:ac8:5a0e:0:b0:3bd:efe:9a09 with SMTP id n14-20020ac85a0e000000b003bd0efe9a09mr2512720qta.28.1676935723923; Mon, 20 Feb 2023 15:28:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676935723; cv=none; d=google.com; s=arc-20160816; b=D5iuI2EJciko2/Lo5ssN6wvdwcaKYmfSDJqIovKnpvbG1XqSQhRN0to7arE19XHkIM tJ9E1aZNf/Bc5KCc1eXOJ+gv1nBWTGqoHPjvmszTn2RY4oDVF18Ti5bzkDB1aJ0bSKoU qXrYrTO/w5J1VMjhik33CiSXwFdoQ0ioP1qjCmff+UYpZH6i7Q06/V4qnIvkHszggUmL 7RsGRP0p5haMR2Jno0Kr49EgGsW5ULQB6A1e5Pd8QN0L7C6snNel8f7Zn90lH+fnmfiy /IFzhA8N9b37drQVEBtG5pku/1I+hBjMhu7ZZwdsybHdxM2fKVlCjAGHYStuPJFGLOKw Tufw== 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=BVEetkVG320ZxIQr9yDM+qYom+RuVqLVN5o0T0FCipE=; b=V7zRNHoehWlYJiQQOaR58HngBEPqFq/GVJxyL3N1Li30QyReaNFW4IMB7RSnsnUblQ NNtsAoT8l66ic1six9061nPDJsBHJsIbJ9+ZsXnhd0G2Iw6O1MEGVzM+XNqU/Y7vWDE9 pP5xdT5KvEfd7YCX296zwfxq2v1lctlaqR+xhh+hL+GMUw/ArfijDLciHQ9Cfi7LitOD d6hc/ZeRunae++rS31ydXeAJMty0Tzl7lctm8laNBpRegonYUZJnRSParCXkRWjgqbXQ xRMhDm/itfQTcTT0Mqso8aLbmPDuSdgdfYfbyt15KP9e0jvuZZ69Mjjq5YuTFwu08EvI yC1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OW8KVE9s; 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 s6-20020a05620a0bc600b0073b7269e3edsi11256364qki.650.2023.02.20.15.28.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Feb 2023 15:28:43 -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=@linaro.org header.s=google header.b=OW8KVE9s; 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 1pUFYj-0004Sy-Fj; Mon, 20 Feb 2023 18:27:01 -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 1pUFYg-0004IC-3d for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:26:58 -0500 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUFYc-0000NW-TH for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:26:57 -0500 Received: by mail-pl1-x62e.google.com with SMTP id p1so1087727plg.7 for ; Mon, 20 Feb 2023 15:26:54 -0800 (PST) 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 :message-id:reply-to; bh=BVEetkVG320ZxIQr9yDM+qYom+RuVqLVN5o0T0FCipE=; b=OW8KVE9sJMbB+drBXDgUajHsWhzA/EGZfNsi8UmVDZwIek6zhfldCnEmhcogxh8IaG 7wHHo7hQmh+HmFneIlIqtCzDpViXDzz+MXDBkapjOlIrdAjsFnv1k40Dt0TWTV/mrVHQ a/3ngITwO+idNWOv1yakpDwq3UEvGh/3kajqy+Aa4apd6v47nGN41sY2vIhuCyDFbHle vWhlx4GhG7AWtUHahTK59jGXV7oO1MF9660Hs/9SR6finiqwyGG+zgbN1Z8rUWYITv8O /egsoV/gxZ0m9vCx2EL4VAJgUqLW3TaZLYin6/4duS4/gK91JparqugLmbd8Vc3/hbvq A1VQ== 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:message-id:reply-to; bh=BVEetkVG320ZxIQr9yDM+qYom+RuVqLVN5o0T0FCipE=; b=ycZaMoK0sSQY2tnCe54i2mQuKn5aYiJ7YPDgJ3fqnNfkJJd1VmtOCNOZuqiiTGu7CQ aAUAa+6GGMRQOMrXGNJeX2WHQbEG1nJcZ56raLOl98XOxR7I+Mrwk05Og0di7a8xisiV aDiC0bL8ipJGT/D0FwVv9M3XzWvM/dlhPCwqV6D+3EQjBlCM1iWUkRSamSmAs/7roE0/ UL60StIrQZGrasp0pJG/jXiU1tT0ximuIVUdCDBPDzCjTgjH/j6ZhvgbJ5r41qj4TDhp 7klY5hehFxLW+3tks+Z3oMjCgc6wrvdm9hhjEoVPjIxfRxvub3R89BsYNQcnRPR6MVZ6 RaCg== X-Gm-Message-State: AO0yUKWx3gdZLfxK7bbcidFBTh0hIcmmj86O5qGkn3pc6VT5rUvoFgol p7AR2NSUVJxi4JzYyqU7MOPkMFEoImR26R/DZUo= X-Received: by 2002:a17:902:f546:b0:19a:8304:21eb with SMTP id h6-20020a170902f54600b0019a830421ebmr2215395plf.6.1676935614019; Mon, 20 Feb 2023 15:26:54 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id j10-20020a170902690a00b001992e74d058sm2665348plk.7.2023.02.20.15.26.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Feb 2023 15:26:53 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell Subject: [PATCH v2 15/21] target/arm: Move s1_is_el0 into S1Translate Date: Mon, 20 Feb 2023 13:26:20 -1000 Message-Id: <20230220232626.429947-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220232626.429947-1-richard.henderson@linaro.org> References: <20230220232626.429947-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.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=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 Instead of passing this to get_phys_addr_lpae, stash it in the S1Translate structure. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/ptw.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 6e980654be..d4027ce763 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -22,6 +22,12 @@ typedef struct S1Translate { ARMSecuritySpace in_space; bool in_secure; bool in_debug; + /* + * If this is stage 2 of a stage 1+2 page table walk, then this must + * be true if stage 1 is an EL0 access; otherwise this is ignored. + * Stage 2 is indicated by in_mmu_idx set to ARMMMUIdx_Stage2{,_S}. + */ + bool in_s1_is_el0; bool out_secure; bool out_rw; bool out_be; @@ -33,7 +39,7 @@ typedef struct S1Translate { static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, uint64_t address, - MMUAccessType access_type, bool s1_is_el0, + MMUAccessType access_type, GetPhysAddrResult *result, ARMMMUFaultInfo *fi) __attribute__((nonnull)); @@ -1257,17 +1263,12 @@ static int check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, uint64_t tcr, * @ptw: Current and next stage parameters for the walk. * @address: virtual address to get physical address for * @access_type: MMU_DATA_LOAD, MMU_DATA_STORE or MMU_INST_FETCH - * @s1_is_el0: if @ptw->in_mmu_idx is ARMMMUIdx_Stage2 - * (so this is a stage 2 page table walk), - * must be true if this is stage 2 of a stage 1+2 - * walk for an EL0 access. If @mmu_idx is anything else, - * @s1_is_el0 is ignored. * @result: set on translation success, * @fi: set to fault info if the translation fails */ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, uint64_t address, - MMUAccessType access_type, bool s1_is_el0, + MMUAccessType access_type, GetPhysAddrResult *result, ARMMMUFaultInfo *fi) { ARMCPU *cpu = env_archcpu(env); @@ -1600,7 +1601,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, result->f.prot = get_S2prot_noexecute(ap); } else { xn = extract64(attrs, 53, 2); - result->f.prot = get_S2prot(env, ap, xn, s1_is_el0); + result->f.prot = get_S2prot(env, ap, xn, ptw->in_s1_is_el0); } } else { int nse, ns = extract32(attrs, 5, 1); @@ -2822,7 +2823,6 @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw, bool ret, ipa_secure, s2walk_secure; ARMCacheAttrs cacheattrs1; ARMSecuritySpace ipa_space, s2walk_space; - bool is_el0; uint64_t hcr; ret = get_phys_addr_with_struct(env, ptw, address, access_type, result, fi); @@ -2847,7 +2847,7 @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw, s2walk_space = ipa_space; } - is_el0 = ptw->in_mmu_idx == ARMMMUIdx_Stage1_E0; + ptw->in_s1_is_el0 = ptw->in_mmu_idx == ARMMMUIdx_Stage1_E0; ptw->in_mmu_idx = s2walk_secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2; ptw->in_ptw_idx = arm_space_to_phys(s2walk_space); ptw->in_secure = s2walk_secure; @@ -2866,8 +2866,7 @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw, ret = get_phys_addr_pmsav8(env, ipa, access_type, ptw->in_mmu_idx, is_secure, result, fi); } else { - ret = get_phys_addr_lpae(env, ptw, ipa, access_type, - is_el0, result, fi); + ret = get_phys_addr_lpae(env, ptw, ipa, access_type, result, fi); } fi->s2addr = ipa; @@ -3043,8 +3042,7 @@ static bool get_phys_addr_with_struct(CPUARMState *env, S1Translate *ptw, } if (regime_using_lpae_format(env, mmu_idx)) { - return get_phys_addr_lpae(env, ptw, address, access_type, false, - result, fi); + return get_phys_addr_lpae(env, ptw, address, access_type, result, fi); } else if (arm_feature(env, ARM_FEATURE_V7) || regime_sctlr(env, mmu_idx) & SCTLR_XP) { return get_phys_addr_v6(env, ptw, address, access_type, result, fi); From patchwork Mon Feb 20 23:26:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 655140 Delivered-To: patch@linaro.org Received: by 2002:adf:9bcd:0:0:0:0:0 with SMTP id e13csp1661723wrc; Mon, 20 Feb 2023 15:28:42 -0800 (PST) X-Google-Smtp-Source: AK7set83nXBCYqJM6uirfLwFDe7ZT20tEEKBoLmTvQIKhke5T8uztkTCa/iXi739jQwwkKX3YhYl X-Received: by 2002:a05:622a:120a:b0:3bd:11a5:c12b with SMTP id y10-20020a05622a120a00b003bd11a5c12bmr26481206qtx.5.1676935722697; Mon, 20 Feb 2023 15:28:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676935722; cv=none; d=google.com; s=arc-20160816; b=rV8aeqARAh9E31S5wbemTbdjP6Dqz7IOZDEvwJLoMrVynn2CkdQjhfWHP2tMzhCfYy vkVTuZ/fsKOvJrjbTOPudhYkSo5e1oPy3pG9AZN3jgp/DPjh3abt1ACOQYxTLUHp5CAj VQZZ+OCsMIoPxMEYy0d9wVWD8h51VgiTfVmmDgRyET3Jx0sjkY4FfeLhZmtXGgB5Uzs3 vtinIKTBdjZHG8lW/eoPGNFd9Atj3KfhlCIu8aZWfu0cFPHiBZXHvtCCxH2Fk1ufIcvZ K/7o9ofKl5QoxsmZHcX5+eeJxe15HH8jK7ziM+10p977hWCjyGu44M5ST9lz6uGPjeVr 4M1A== 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=Z+JHhydbaosxqUvfvn4Z1EbkvskX2ro+PNfi5dyuur8=; b=HtPjpT86PRelQ2gAKB9ht5icW4k26opU96VZcTBym97NDglxX9zCxR+qLDv6EgzNJf C/rxc4tvpt99icYqClUlMmedZx4Wx3FMIBsvtG0K4WU1qQq4nyiPKda2W1hyoCrlKIUq 7Im1mCd1Ik7lbEQIf5X5P1i4S7yOGjzbn5MJEuC4z2DWCRUMDisKqaKPxlVwEHH3IHoR xkuTFq+Mt/ADl/adf8XjqozPnMVo81CnRJtuEg3jhSK6ppg8TWGpKT5TuE8ZhQEuvr8f qTNcsTU1ieacEjAF7ycdx/b6uG9DfDMxKbqgJBEBOOdeymwNvcaXwnasRBpj0Si8ScSN MHKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iShDDGQE; 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 v10-20020a05622a014a00b003bcda120a13si10728187qtw.644.2023.02.20.15.28.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Feb 2023 15:28:42 -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=@linaro.org header.s=google header.b=iShDDGQE; 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 1pUFYo-0004dF-W3; Mon, 20 Feb 2023 18:27:07 -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 1pUFYg-0004LJ-Fl for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:26:58 -0500 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUFYe-0000Ql-N4 for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:26:58 -0500 Received: by mail-pl1-x62e.google.com with SMTP id l15so4272588pls.1 for ; Mon, 20 Feb 2023 15:26:56 -0800 (PST) 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 :message-id:reply-to; bh=Z+JHhydbaosxqUvfvn4Z1EbkvskX2ro+PNfi5dyuur8=; b=iShDDGQEfJEYmQi1R7YjYxYit1A3Rd0HP10oApwqXWIITj9GEJk0CNj6Wyux5FP4Jk 6puaMKIZYhkpTNqtPCkvX0YixG0EimoV88DdhWyyxCX4BiaImsfES1NOo+6jbYcq+v7f eH+gFn/bk2n5JJ9ZejikUToKmX79XN3esNHuUi9Ay1WYlaRQYCEMnb1aj9oMom6Wca/c CxMdeJYRl9wzc+jmMdg4DZrIEQlqxTYPoVGU4Tx9kGyNyQ4p631O7buLgfL26PQ18DX+ yWMnq1GFk4n8a0UHIW5ZSKV972jY6qwQLk0zX2eaUs+yO3qgVM3u9wFosfM3eZnnkwS9 xD2A== 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:message-id:reply-to; bh=Z+JHhydbaosxqUvfvn4Z1EbkvskX2ro+PNfi5dyuur8=; b=0BzzZtRiYDj1S5QpyjMpI0BTKnsmNfoEMD3/m9/r1tRJCWJ97F3V9U13bb55s0ZFJQ F/Zr8phtwPnyqMtrCQW53nB950Ax37ytlbxhuwX051S4uGGraXamyHO+pzPD5SJijd8I Ks1dc1SEJ1LSJV8OTzaTlDxv5haWm0EG4P7u/Z2vN1XQ1IP8Bbvn4/+CjZgJNkRCJW1G Ki6VvmTk0mdHVdF7WqC40pXskSROInBsGaLLZCa/vqXZthWap4OLfZaxTeqQ2kdu/cHy FOLM+FmAhjxtmL4XmZzSCBq/AUFkX0pDN263Md/Te0kfgNwBXM9D+xvNUCiY5FceXzGl BVXw== X-Gm-Message-State: AO0yUKV2GF7fRXcIQ5+fHButIooAwsZ7ulYpsFm74uBzHvMY2FM1Rnd3 b/hL4+b1gZhhmeRYp+dtYvrPmUNsN6CDxHkc8Mw= X-Received: by 2002:a17:903:110c:b0:199:3683:5410 with SMTP id n12-20020a170903110c00b0019936835410mr6148568plh.50.1676935615402; Mon, 20 Feb 2023 15:26:55 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id j10-20020a170902690a00b001992e74d058sm2665348plk.7.2023.02.20.15.26.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Feb 2023 15:26:54 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH v2 16/21] target/arm: Use get_phys_addr_with_struct for stage2 Date: Mon, 20 Feb 2023 13:26:21 -1000 Message-Id: <20230220232626.429947-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220232626.429947-1-richard.henderson@linaro.org> References: <20230220232626.429947-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.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=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 This fixes a bug in which we failed to initialize the result attributes properly after the memset. Signed-off-by: Richard Henderson --- target/arm/ptw.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index d4027ce763..a797750f9b 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -37,12 +37,6 @@ typedef struct S1Translate { void *out_host; } S1Translate; -static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, - uint64_t address, - MMUAccessType access_type, - GetPhysAddrResult *result, ARMMMUFaultInfo *fi) - __attribute__((nonnull)); - static bool get_phys_addr_with_struct(CPUARMState *env, S1Translate *ptw, target_ulong address, MMUAccessType access_type, @@ -2862,12 +2856,7 @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw, cacheattrs1 = result->cacheattrs; memset(result, 0, sizeof(*result)); - if (arm_feature(env, ARM_FEATURE_PMSA)) { - ret = get_phys_addr_pmsav8(env, ipa, access_type, - ptw->in_mmu_idx, is_secure, result, fi); - } else { - ret = get_phys_addr_lpae(env, ptw, ipa, access_type, result, fi); - } + ret = get_phys_addr_with_struct(env, ptw, ipa, access_type, result, fi); fi->s2addr = ipa; /* Combine the S1 and S2 perms. */ From patchwork Mon Feb 20 23:26:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 655146 Delivered-To: patch@linaro.org Received: by 2002:adf:9bcd:0:0:0:0:0 with SMTP id e13csp1661915wrc; Mon, 20 Feb 2023 15:29:14 -0800 (PST) X-Google-Smtp-Source: AK7set94oCw3QMo1bx9HLqp3hhhzhHqjbRseXTFcrdd0H2MtVi4Y1vmK/R4hi18OLaJPpHPwvaIe X-Received: by 2002:ad4:5ec6:0:b0:56e:9dd8:4812 with SMTP id jm6-20020ad45ec6000000b0056e9dd84812mr7272477qvb.3.1676935754697; Mon, 20 Feb 2023 15:29:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676935754; cv=none; d=google.com; s=arc-20160816; b=gcElCIfK+IwUwxgkz3uF7h/Nw1DDSGR987SAlfAT9637lobyob2slOiUnaoyjklOyC GH/cSrkLwBUoH6r69WZ5ffXHXD4/g1iCkPLU9pH+UNLD6JhuQsBdKSOplj1uNPgbG+Ki TsABAPIkUpT+I92HbUvnLg5nsDaeVEKArfJHofZ9MtA6NtTPUKUDk/zgfx67ipBfe+ma xNpl8qxRyH35VQCyQNXoHb0iW+n3Jlr5bIboZQMFuh1yMs9gcQK6wgga4zl54mYzFXT6 hHB6SCyhDml55zUqpvOLgtvwMLOuKQkM16dAj//uH//ryKXb24jwQ581vyVSJO+jr4fV QW5A== 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=BdnIrBC/vjhypfMOEhRm01STyDVGWe2QDHvXiznUOKk=; b=r+3ahHTqtTfR+MfJeb+d/PooVRfVZZHiK3Co8RcVqEY4Zi/+KuM+sdg824yKfyBM6s 8r506ifBATIx3zreFmK7XyFFyCKYqQ4QazEetaGw437bBiqEBfKTQDjFYOWU0z1ddibV IWzhtC3qD7w7J/UzW0FK18aFK0EkA3/DejgJZasVIxRKqT7Hc2ltp4k9H+ttb6P/eWuo nDrV8Z4AyPa7WO+yUDg15OfLykbifdlVEZIzGL4IM2PFzIM8Ni8ln+P7YPHRec7/IXqF SD1EyS/SQc6e4sOV7hVn8lXEapxCY59sMCr0981kZwgpziCZXXb9OUxBip6dsLFz81r6 a/Gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TUOdBq8x; 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 l2-20020a05620a28c200b0071fe862c92dsi11603189qkp.63.2023.02.20.15.29.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Feb 2023 15:29:14 -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=@linaro.org header.s=google header.b=TUOdBq8x; 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 1pUFYp-0004eI-3j; Mon, 20 Feb 2023 18:27:07 -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 1pUFYh-0004P6-Cy for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:26:59 -0500 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUFYf-0000M3-Qk for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:26:59 -0500 Received: by mail-pj1-x102b.google.com with SMTP id pt11so3454283pjb.1 for ; Mon, 20 Feb 2023 15:26:57 -0800 (PST) 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 :message-id:reply-to; bh=BdnIrBC/vjhypfMOEhRm01STyDVGWe2QDHvXiznUOKk=; b=TUOdBq8xbouISD67Tp0NvVaozs9Bhh6/loj1Byeww6gSDx3TKf4KT8/XkpqD+AMNTd eT2cc+p+ri/R1YCaaGWdbTJDkHzeeNc7RT4BCNXXf809f1VEeGq5EbjKeMQM2mJr12VK Z4FSa4NH5rcikVDpvGATz3KU7Rz8EbcHC37Q3TBIblxKO/H+UbRCPeM+3MIjW0F8UweS R2NkhLcxYODbpY99GUGX7rq+zGD2q5/z0ur8Icl1PTiBCnbOUrMlHHMpj7HhVGCtlI3m tBQrzz9pyNwuaQm1HMDzm72TNnc5q0xzDCMy2O/rnk0PiEiKoRFvMFhvHCzFHTg/lrNJ Xm0g== 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:message-id:reply-to; bh=BdnIrBC/vjhypfMOEhRm01STyDVGWe2QDHvXiznUOKk=; b=i4GFXfMsigZzHg/z36BVCC2XpDnvaD3ARRJhb6i3FeoAgP4OzFK0elrkEHdTu1HYoL x+kICsiFLqBCmWy+8HZ8D1Y7HfriBqpJ1V76UBfm/mfKjEhhgWstqUhmUMKKfKSmCmNP 3Ndpa5wRW+TKWbiR670v44cncVepxy4h9fCjXGvHdKqsx6Frg4mP/hH5pe1XDoUTsUlB tDzLBjRhseUrT3mqmaWBfXMNXO9tA+c69ZuUBjHH8BFHZFPhcBYc1gQ464hndCiFp5VW 199sQJPW8V3fT81/cy5UCuyMYEyPEsxFQOh93aOTF9BWBYPU/uQBaABuknxwgb2nMid9 kbKA== X-Gm-Message-State: AO0yUKVBxmE/VHkTpi7EkG1tpNQoNj6Gld+/xwjL+RWpxWshrjlVsPaE 2J9V0XlyioSVQl4+7w24k8vujFj5jjGRqJJys2M= X-Received: by 2002:a17:903:32cf:b0:19a:b092:b31a with SMTP id i15-20020a17090332cf00b0019ab092b31amr2393748plr.8.1676935616792; Mon, 20 Feb 2023 15:26:56 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id j10-20020a170902690a00b001992e74d058sm2665348plk.7.2023.02.20.15.26.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Feb 2023 15:26:56 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell Subject: [PATCH v2 17/21] target/arm: Add GPC syndrome Date: Mon, 20 Feb 2023 13:26:22 -1000 Message-Id: <20230220232626.429947-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220232626.429947-1-richard.henderson@linaro.org> References: <20230220232626.429947-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.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=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 The function takes the fields as filled in by the Arm ARM pseudocode for TakeGPCException. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/syndrome.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/target/arm/syndrome.h b/target/arm/syndrome.h index d27d1bc31f..62254d0e51 100644 --- a/target/arm/syndrome.h +++ b/target/arm/syndrome.h @@ -50,6 +50,7 @@ enum arm_exception_class { EC_SVEACCESSTRAP = 0x19, EC_ERETTRAP = 0x1a, EC_SMETRAP = 0x1d, + EC_GPC = 0x1e, EC_INSNABORT = 0x20, EC_INSNABORT_SAME_EL = 0x21, EC_PCALIGNMENT = 0x22, @@ -247,6 +248,15 @@ static inline uint32_t syn_bxjtrap(int cv, int cond, int rm) (cv << 24) | (cond << 20) | rm; } +static inline uint32_t syn_gpc(int s2ptw, int ind, int gpcsc, + int cm, int s1ptw, int wnr, int fsc) +{ + /* TODO: FEAT_NV2 adds VNCR */ + return (EC_GPC << ARM_EL_EC_SHIFT) | ARM_EL_IL | (s2ptw << 21) + | (ind << 20) | (gpcsc << 14) | (cm << 8) | (s1ptw << 7) + | (wnr << 6) | fsc; +} + static inline uint32_t syn_insn_abort(int same_el, int ea, int s1ptw, int fsc) { return (EC_INSNABORT << ARM_EL_EC_SHIFT) | (same_el << ARM_EL_EC_SHIFT) From patchwork Mon Feb 20 23:26:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 655132 Delivered-To: patch@linaro.org Received: by 2002:adf:9bcd:0:0:0:0:0 with SMTP id e13csp1661257wrc; Mon, 20 Feb 2023 15:27:18 -0800 (PST) X-Google-Smtp-Source: AK7set/B4jpSkBjm+YIhQ4NLirU4/cpFjqtXgn8j6Rn80hRWhp7quJ+dgUGu7YNdV7mUTatM8efr X-Received: by 2002:a05:6214:4112:b0:56f:d8:dbb4 with SMTP id kc18-20020a056214411200b0056f00d8dbb4mr7062220qvb.2.1676935638396; Mon, 20 Feb 2023 15:27:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676935638; cv=none; d=google.com; s=arc-20160816; b=eh8Fp3aiJJKgs3OdciRZBsP4B5d1x3zk34YVCOz3c14HM+rXCIC+8cnpEyBftmL7F2 sHxt2RLKaidCIZLQ359XzIaPbVzuH9k9j88APNJOG8EmiOpQKhBocf9bSxm4foN2jFSC 82OTrSnJ+NDTBkBjFrevVABHV4hnv4YLpTJCZlO6hHrpqCFKtMI4jrAHhXKPD3Vi+7SF VyFlm9fKxC27JoFFrVMaHVKeE7rw8d/UOnnfQggQ1CMoQ3HR7+erXV2DNzyZv90mtWiU K55B+WBbHKmvqeDALyxZ/xhDdVj8LaW4IbzXgdWFBRT0B6SSgWabCn3/GyVyzuXOEBAz Quew== 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=P3y/FFraIBsrnZDMo6qHECYIBj1ugEm+zw6wnTUMfbE=; b=kv2o9KDul5+GIwk+OjaBYQl+k7bbFOib9GO+eRaXBUgKjUglO8URA4uxtFmDOPV00+ B6MnGfIL48iIHEYxb21++LEujDJ6Mej//rTQf66DieNAzkF5xZyxzIHFQwr9RhzmxZoN wpbvqNvekwNOmaUCLleQ0jOQ4c00xoE582Ang8SJQqHYSR4cKqi+C1JUTp7ZPsiHSsRA 1YfFrqNvK2ktbc+XJx2PxqrRfxMAiMCDhejT4D3uo33XhyntpAjan7UHoRgdqYlonXkI PR3PM2B4kx5LAbe2Dpo93U6bxRhD+v99jfVkq/3v2YSsu8JTGp7sFVZE2ZxP7zQrwcsU 2Mzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mxQDkBOf; 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 s1-20020a0cb301000000b0056ec2583b02si9500915qve.464.2023.02.20.15.27.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Feb 2023 15:27:18 -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=@linaro.org header.s=google header.b=mxQDkBOf; 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 1pUFYn-0004XP-CS; Mon, 20 Feb 2023 18:27:05 -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 1pUFYj-0004T0-7A for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:27:01 -0500 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUFYh-0000Qk-7U for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:27:00 -0500 Received: by mail-pj1-x102e.google.com with SMTP id ei9-20020a17090ae54900b002349a303ca5so2877639pjb.4 for ; Mon, 20 Feb 2023 15:26:58 -0800 (PST) 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 :message-id:reply-to; bh=P3y/FFraIBsrnZDMo6qHECYIBj1ugEm+zw6wnTUMfbE=; b=mxQDkBOfFwdPkteMkuHJBNcH5ZhRHkLd6u/0Sa34cJsBW4eJApwzGrcV5pHqC0FWsy Nuxvkvd/5T4ETncOVzCMXNEsHG/EuacIkWjZ6Vjjy5wKz9EYDj0KJmhdwnedhEJlLLf2 RhecQwZ4RdKkI4hwZKBfiAYhoyTFZzYs5WBBCg2ocCPkg6BbNu9LurrGpuXjv3Ix+pMh B+iaz+51fhxPTPBVufpYDugvQHjPzQJ1YUdrs+Qiz3WFtn/W+R9Rqdi2dobrOU4lvl1f P9wOnlra4B5GJa6tlmiz+o49zpOnZG3WbqGKbU/xywhmMCTaH5xzxWE9fvDTiClsBL0T Rhew== 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:message-id:reply-to; bh=P3y/FFraIBsrnZDMo6qHECYIBj1ugEm+zw6wnTUMfbE=; b=q1014vV7/6xcfvoGyVZCbjkKn1sQP2cKsDuFzTON2jHg7Bo/rKmDKqHeh3OMFB1x2p IaiHpAMqxifViN1YhzuherFPGwWdecnJZDATby2OqafbInIT4TqtjKGp+IyGKvrNvPa2 vSQlsRoA7EBjcaDzt5v25W9GMvY4pelJWJ2t83Q5kSw6W/+ZGxnmd36L8Gh2k4w8aXYN UMxkJtXPDDdbg2wAbq18IpR0f8u96Kf2ZnnKKzgg7453skZ2ZMn09p6T67RStczrViPd +Mj4kSQt5ceRCjLcX0U1zdCgM45favn7yWIBpCoxOL3uDXr4zXSpnZZsnwQKvYUbPUaG KCgw== X-Gm-Message-State: AO0yUKXYZNzCXmYchRwigDFnPL8Olay0WwISoJKxaHsBHgnGDw/2v90t RXyzBMlXBjKZSn7rQ9eyuHsedYpU9WuMSrvYT0E= X-Received: by 2002:a17:903:11d1:b0:19b:3b4:3af5 with SMTP id q17-20020a17090311d100b0019b03b43af5mr5917488plh.34.1676935618273; Mon, 20 Feb 2023 15:26:58 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id j10-20020a170902690a00b001992e74d058sm2665348plk.7.2023.02.20.15.26.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Feb 2023 15:26:57 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell Subject: [PATCH v2 18/21] target/arm: Implement GPC exceptions Date: Mon, 20 Feb 2023 13:26:23 -1000 Message-Id: <20230220232626.429947-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220232626.429947-1-richard.henderson@linaro.org> References: <20230220232626.429947-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102e.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=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 Handle GPC Fault types in arm_deliver_fault, reporting as either a GPC exception at EL3, or falling through to insn or data aborts at various exception levels. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/cpu.h | 1 + target/arm/internals.h | 27 ++++++++++++ target/arm/helper.c | 5 +++ target/arm/tlb_helper.c | 96 +++++++++++++++++++++++++++++++++++++++-- 4 files changed, 126 insertions(+), 3 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 4bafe8340e..faafb63520 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -57,6 +57,7 @@ #define EXCP_UNALIGNED 22 /* v7M UNALIGNED UsageFault */ #define EXCP_DIVBYZERO 23 /* v7M DIVBYZERO UsageFault */ #define EXCP_VSERR 24 +#define EXCP_GPC 25 /* v9 Granule Protection Check Fault */ /* NB: add new EXCP_ defines to the array in arm_log_exception() too */ #define ARMV7M_EXCP_RESET 1 diff --git a/target/arm/internals.h b/target/arm/internals.h index 759b70c646..5e88649fea 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -352,14 +352,27 @@ typedef enum ARMFaultType { ARMFault_ICacheMaint, ARMFault_QEMU_NSCExec, /* v8M: NS executing in S&NSC memory */ ARMFault_QEMU_SFault, /* v8M: SecureFault INVTRAN, INVEP or AUVIOL */ + ARMFault_GPCFOnWalk, + ARMFault_GPCFOnOutput, } ARMFaultType; +typedef enum ARMGPCF { + GPCF_None, + GPCF_AddressSize, + GPCF_Walk, + GPCF_EABT, + GPCF_Fail, +} ARMGPCF; + /** * ARMMMUFaultInfo: Information describing an ARM MMU Fault * @type: Type of fault + * @gpcf: Subtype of ARMFault_GPCFOn{Walk,Output}. * @level: Table walk level (for translation, access flag and permission faults) * @domain: Domain of the fault address (for non-LPAE CPUs only) * @s2addr: Address that caused a fault at stage 2 + * @paddr: physical address that caused a fault for gpc + * @paddr_space: physical address space that caused a fault for gpc * @stage2: True if we faulted at stage 2 * @s1ptw: True if we faulted at stage 2 while doing a stage 1 page-table walk * @s1ns: True if we faulted on a non-secure IPA while in secure state @@ -368,7 +381,10 @@ typedef enum ARMFaultType { typedef struct ARMMMUFaultInfo ARMMMUFaultInfo; struct ARMMMUFaultInfo { ARMFaultType type; + ARMGPCF gpcf; target_ulong s2addr; + target_ulong paddr; + ARMSecuritySpace paddr_space; int level; int domain; bool stage2; @@ -542,6 +558,17 @@ static inline uint32_t arm_fi_to_lfsc(ARMMMUFaultInfo *fi) case ARMFault_Exclusive: fsc = 0x35; break; + case ARMFault_GPCFOnWalk: + assert(fi->level >= -1 && fi->level <= 3); + if (fi->level < 0) { + fsc = 0b100011; + } else { + fsc = 0b100100 | fi->level; + } + break; + case ARMFault_GPCFOnOutput: + fsc = 0b101000; + break; default: /* Other faults can't occur in a context that requires a * long-format status code. diff --git a/target/arm/helper.c b/target/arm/helper.c index 13af812215..5dc3329f0c 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -10235,6 +10235,7 @@ void arm_log_exception(CPUState *cs) [EXCP_UNALIGNED] = "v7M UNALIGNED UsageFault", [EXCP_DIVBYZERO] = "v7M DIVBYZERO UsageFault", [EXCP_VSERR] = "Virtual SERR", + [EXCP_GPC] = "Granule Protection Check", }; if (idx >= 0 && idx < ARRAY_SIZE(excnames)) { @@ -10963,6 +10964,10 @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs) } switch (cs->exception_index) { + case EXCP_GPC: + qemu_log_mask(CPU_LOG_INT, "...with MFAR 0x%" PRIx64 "\n", + env->cp15.mfar_el3); + /* fall through */ case EXCP_PREFETCH_ABORT: case EXCP_DATA_ABORT: /* diff --git a/target/arm/tlb_helper.c b/target/arm/tlb_helper.c index 60abcbebe6..aa03d3f8dc 100644 --- a/target/arm/tlb_helper.c +++ b/target/arm/tlb_helper.c @@ -109,17 +109,106 @@ static uint32_t compute_fsr_fsc(CPUARMState *env, ARMMMUFaultInfo *fi, return fsr; } +static bool report_as_gpc_exception(ARMCPU *cpu, int current_el, + ARMMMUFaultInfo *fi) +{ + bool ret; + + switch (fi->gpcf) { + case GPCF_None: + return false; + case GPCF_AddressSize: + case GPCF_Walk: + case GPCF_EABT: + /* R_PYTGX: GPT faults are reported as GPC. */ + ret = true; + break; + case GPCF_Fail: + /* + * R_BLYPM: A GPF at EL3 is reported as insn or data abort. + * R_VBZMW, R_LXHQR: A GPF at EL[0-2] is reported as a GPC + * if SCR_EL3.GPF is set, otherwise an insn or data abort. + */ + ret = (cpu->env.cp15.scr_el3 & SCR_GPF) && current_el != 3; + break; + default: + g_assert_not_reached(); + } + + assert(cpu_isar_feature(aa64_rme, cpu)); + assert(fi->type == ARMFault_GPCFOnWalk || + fi->type == ARMFault_GPCFOnOutput); + if (fi->gpcf == GPCF_AddressSize) { + assert(fi->level == 0); + } else { + assert(fi->level >= 0 && fi->level <= 1); + } + + return ret; +} + +static unsigned encode_gpcsc(ARMMMUFaultInfo *fi) +{ + static uint8_t const gpcsc[] = { + [GPCF_AddressSize] = 0b000000, + [GPCF_Walk] = 0b000100, + [GPCF_Fail] = 0b001100, + [GPCF_EABT] = 0b010100, + }; + + /* Note that we've validated fi->gpcf and fi->level above. */ + return gpcsc[fi->gpcf] | fi->level; +} + static G_NORETURN void arm_deliver_fault(ARMCPU *cpu, vaddr addr, MMUAccessType access_type, int mmu_idx, ARMMMUFaultInfo *fi) { CPUARMState *env = &cpu->env; - int target_el; + int target_el = exception_target_el(env); + int current_el = arm_current_el(env); bool same_el; uint32_t syn, exc, fsr, fsc; - target_el = exception_target_el(env); + if (report_as_gpc_exception(cpu, current_el, fi)) { + target_el = 3; + + fsr = compute_fsr_fsc(env, fi, target_el, mmu_idx, &fsc); + + syn = syn_gpc(fi->stage2 && fi->type == ARMFault_GPCFOnWalk, + access_type == MMU_INST_FETCH, + encode_gpcsc(fi), 0, fi->s1ptw, + access_type == MMU_DATA_STORE, fsc); + + env->cp15.mfar_el3 = fi->paddr; + switch (fi->paddr_space) { + case ARMSS_Secure: + break; + case ARMSS_NonSecure: + env->cp15.mfar_el3 |= R_MFAR_NS_MASK; + break; + case ARMSS_Root: + env->cp15.mfar_el3 |= R_MFAR_NSE_MASK; + break; + case ARMSS_Realm: + env->cp15.mfar_el3 |= R_MFAR_NSE_MASK | R_MFAR_NS_MASK; + break; + default: + g_assert_not_reached(); + } + + exc = EXCP_GPC; + goto do_raise; + } + + /* If SCR_EL3.GPF is unset, GPF may still be routed to EL2. */ + if (fi->gpcf == GPCF_Fail && target_el < 2) { + if (arm_hcr_el2_eff(env) & HCR_GPF) { + target_el = 2; + } + } + if (fi->stage2) { target_el = 2; env->cp15.hpfar_el2 = extract64(fi->s2addr, 12, 47) << 4; @@ -127,8 +216,8 @@ void arm_deliver_fault(ARMCPU *cpu, vaddr addr, env->cp15.hpfar_el2 |= HPFAR_NS; } } - same_el = (arm_current_el(env) == target_el); + same_el = current_el == target_el; fsr = compute_fsr_fsc(env, fi, target_el, mmu_idx, &fsc); if (access_type == MMU_INST_FETCH) { @@ -146,6 +235,7 @@ void arm_deliver_fault(ARMCPU *cpu, vaddr addr, exc = EXCP_DATA_ABORT; } + do_raise: env->exception.vaddress = addr; env->exception.fsr = fsr; raise_exception(env, exc, syn, target_el); From patchwork Mon Feb 20 23:26:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 655149 Delivered-To: patch@linaro.org Received: by 2002:adf:9bcd:0:0:0:0:0 with SMTP id e13csp1662036wrc; Mon, 20 Feb 2023 15:29:38 -0800 (PST) X-Google-Smtp-Source: AK7set+2rke2let7KNUHlnnEg1vw9iwxhPCtfdvSLGQGaqdlqj//cpbteOvLR/QZwkeFtpm/MFdV X-Received: by 2002:a05:622a:183:b0:3ba:1acd:4f8 with SMTP id s3-20020a05622a018300b003ba1acd04f8mr4419671qtw.42.1676935777893; Mon, 20 Feb 2023 15:29:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676935777; cv=none; d=google.com; s=arc-20160816; b=hCcdxKftIy5hHJIOqv4nVmppG9ZD8ibyONRhBqEWFh7KiIkpa7erVFAAMqGrpcar58 vsvU5vbexGDKnEaHjPDGo011OPW6MjM5vhTKVpmpzbm65s5JcIAScq35JBJJxWz1SwN7 fl3ug0xme0hCJs7FOC215URhzB2Lt9c+ySWAKdpn1t+G/yRcBeEPg9ceQbyNEw0zo3ah TWzTa8ptiLEwWqvCG8QObd7ldvjF73E0I/nMqupvs4zWHH5AQyvoJ1kxF5CbQFsdbH8N dSYEy1oE71Mw90Wjf12cL+b7fK9cB59KRJOrhvLNKR3qLbOEGlKOBoNphaBZbI3yEQla dx0g== 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=CB7v28W7W1Dv5HV9sB7O4wNr8EzlcB/4NWcFaAYvGQM=; b=i5GqYWnjdVw2RgEXSX7iozVh4D9lDQvvddfrOaUVLK40jtuy2Mi95OURSShJPJrsNa b/VItvuQlRgzWdSWgCTnQkf/Cz+366356MP/JDf5VHNwhk/HJ3a8UEJ6jBCVMsjoCckA M/LN+b/G/SksQvCwwDEKDE1IV4os/zuZ2SMQY7tRX6/faPmzBvNwBz5ATOoq+Dqj/WdF tsK+AyitbfhiSu7mbLhEJGeskmZcLAmbLhD26y2A6pCQDN/2690THADoWK6HW9cg0r1k 3iSmCV/83ahhmhmbYoZ7/rGSJI53m6SosSDvi4Bul3R9NpxY3h41rxZ6R/+YT988GIr6 4cAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CnnaTUXh; 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 u17-20020a05620a431100b007416f83da7csi565341qko.163.2023.02.20.15.29.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Feb 2023 15:29:37 -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=@linaro.org header.s=google header.b=CnnaTUXh; 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 1pUFYp-0004f7-AU; Mon, 20 Feb 2023 18:27:07 -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 1pUFYl-0004WZ-5r for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:27:03 -0500 Received: from mail-pj1-x1043.google.com ([2607:f8b0:4864:20::1043]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUFYj-0000Sr-0s for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:27:02 -0500 Received: by mail-pj1-x1043.google.com with SMTP id co23-20020a17090afe9700b002341fadc370so2883489pjb.1 for ; Mon, 20 Feb 2023 15:27:00 -0800 (PST) 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 :message-id:reply-to; bh=CB7v28W7W1Dv5HV9sB7O4wNr8EzlcB/4NWcFaAYvGQM=; b=CnnaTUXhBcptOtQXod9rLLmTGyY7/tB7jN6obmasYkKL/qxH6/YGXuf0D+8yk0Fco0 AyYgNKgKFIdjqFTvCOz2lSv/EWwGBpw/aUIaIo7FQEPifutOZDgZfkltDdUSbg1Z/jIW itb/Zg/QFCDKYiOmYHghTi3lkDPsfu8BsdE3tpCkIn8Nwzyao1vQt5AqMGYXgI8e2GEs yJV6KIS+RUXfoGNzv0mAHZact4gbK0UEQDE6h2WuyYutO4KCYfJ5WdSl0ya5jkw+B5FN NmAzpRgXMyvXFxYD2EXqu96OK2ZeKGthc/OU+SYag/GED3zQtdLKa1ZxcBxKY016wWxQ VXnQ== 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:message-id:reply-to; bh=CB7v28W7W1Dv5HV9sB7O4wNr8EzlcB/4NWcFaAYvGQM=; b=0OTUnClj8q26wfl2cx6ebhAXT0zNEfCfrgWF28rPJj+X6H94/Ik4i6pa0Kx6MkphK2 jXH4U/1BjrVwwHq+yojIdHt/YWifVU2+b49fhpqiOpfkgFBaH0ELIs/Du+8vqZ07yVEi qwJI6e2mvSu77PRwTDxgYHn2662bWb+v+D3cSR1kM7347VtUNC0+U4IHLjmktx2G3fpw QQ0mqRiT8DtlbFXqlcYyYqshYkfVUNcwO3OqSN/xs4jYJmnTRDoabumcUabtlQBvHSmS 6cZfgMIj4avxbdBOpX/AIdSxl1Mrek4CEZCiCtZGwi4oI5btNd5U1mRe5xy3jIxvq70d B9GQ== X-Gm-Message-State: AO0yUKVspiVQoLOtjyP8ce5xWUKi8QhpMie4njtkPEPftJRcJsHdmCf0 yChivYtv6N5gI93Q8VpsRCUn2Sw83RZZSfLEnaZ7MA== X-Received: by 2002:a17:902:d48c:b0:19a:841f:57 with SMTP id c12-20020a170902d48c00b0019a841f0057mr5135948plg.27.1676935619715; Mon, 20 Feb 2023 15:26:59 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id j10-20020a170902690a00b001992e74d058sm2665348plk.7.2023.02.20.15.26.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Feb 2023 15:26:59 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell Subject: [PATCH v2 19/21] target/arm: Implement the granule protection check Date: Mon, 20 Feb 2023 13:26:24 -1000 Message-Id: <20230220232626.429947-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220232626.429947-1-richard.henderson@linaro.org> References: <20230220232626.429947-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1043; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1043.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=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 Place the check at the end of get_phys_addr_with_struct, so that we check all physical results. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/ptw.c | 246 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 228 insertions(+), 18 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index a797750f9b..b2f55f7f66 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -37,12 +37,11 @@ typedef struct S1Translate { void *out_host; } S1Translate; -static bool get_phys_addr_with_struct(CPUARMState *env, S1Translate *ptw, - target_ulong address, - MMUAccessType access_type, - GetPhysAddrResult *result, - ARMMMUFaultInfo *fi) - __attribute__((nonnull)); +static bool get_phys_addr_nogpc(CPUARMState *env, S1Translate *ptw, + target_ulong address, + MMUAccessType access_type, + GetPhysAddrResult *result, + ARMMMUFaultInfo *fi); /* This mapping is common between ID_AA64MMFR0.PARANGE and TCR_ELx.{I}PS. */ static const uint8_t pamax_map[] = { @@ -198,6 +197,197 @@ static bool regime_translation_disabled(CPUARMState *env, ARMMMUIdx mmu_idx, return (regime_sctlr(env, mmu_idx) & SCTLR_M) == 0; } +static bool granule_protection_check(CPUARMState *env, uint64_t paddress, + ARMSecuritySpace pspace, + ARMMMUFaultInfo *fi) +{ + MemTxAttrs attrs = { + .secure = true, + .space = ARMSS_Root, + }; + ARMCPU *cpu = env_archcpu(env); + uint64_t gpccr = env->cp15.gpccr_el3; + unsigned pps, pgs, l0gptsz, level = 0; + uint64_t tableaddr, pps_mask, align, entry, index; + AddressSpace *as; + MemTxResult result; + int gpi; + + if (!FIELD_EX64(gpccr, GPCCR, GPC)) { + return true; + } + + /* + * GPC Priority 1 (R_GMGRR): + * R_JWCSM: If the configuration of GPCCR_EL3 is invalid, + * the access fails as GPT walk fault at level 0. + */ + + /* + * Configuration of PPS to a value exceeding the implemented + * physical address size is invalid. + */ + pps = FIELD_EX64(gpccr, GPCCR, PPS); + if (pps > FIELD_EX64(cpu->isar.id_aa64mmfr0, ID_AA64MMFR0, PARANGE)) { + goto fault_walk; + } + pps = pamax_map[pps]; + pps_mask = MAKE_64BIT_MASK(0, pps); + + switch (FIELD_EX64(gpccr, GPCCR, SH)) { + case 0b10: /* outer shareable */ + break; + case 0b00: /* non-shareable */ + case 0b11: /* inner shareable */ + /* Inner and Outer non-cacheable requires Outer shareable. */ + if (FIELD_EX64(gpccr, GPCCR, ORGN) == 0 && + FIELD_EX64(gpccr, GPCCR, IRGN) == 0) { + goto fault_walk; + } + break; + default: /* reserved */ + goto fault_walk; + } + + switch (FIELD_EX64(gpccr, GPCCR, PGS)) { + case 0b00: /* 4KB */ + pgs = 12; + break; + case 0b01: /* 64KB */ + pgs = 16; + break; + case 0b10: /* 16KB */ + pgs = 14; + break; + default: /* reserved */ + goto fault_walk; + } + + /* Note this field is read-only and fixed at reset. */ + l0gptsz = 30 + FIELD_EX64(gpccr, GPCCR, L0GPTSZ); + + /* + * GPC Priority 2: Secure, Realm or Root address exceeds PPS. + * R_CPDSB: A NonSecure physical address input exceeding PPS + * does not experience any fault. + */ + if (paddress & ~pps_mask) { + if (pspace == ARMSS_NonSecure) { + return true; + } + goto fault_size; + } + + /* GPC Priority 3: the base address of GPTBR_EL3 exceeds PPS. */ + tableaddr = env->cp15.gptbr_el3 << 12; + if (tableaddr & ~pps_mask) { + goto fault_size; + } + + /* + * BADDR is aligned per a function of PPS and L0GPTSZ. + * These bits of GPTBR_EL3 are RES0, but are not a configuration error, + * unlike the RES0 bits of the GPT entries (R_XNKFZ). + */ + align = MAX(pps - l0gptsz + 3, 12); + align = MAKE_64BIT_MASK(0, align); + tableaddr &= ~align; + + as = arm_addressspace(env_cpu(env), attrs); + + /* Level 0 lookup. */ + index = extract64(paddress, l0gptsz, pps - l0gptsz); + tableaddr += index * 8; + entry = address_space_ldq_le(as, tableaddr, attrs, &result); + if (result != MEMTX_OK) { + goto fault_eabt; + } + + switch (extract32(entry, 0, 4)) { + case 1: /* block descriptor */ + if (entry >> 8) { + goto fault_walk; /* RES0 bits not 0 */ + } + gpi = extract32(entry, 4, 4); + goto found; + case 3: /* table descriptor */ + tableaddr = entry & ~0xf; + align = MAX(l0gptsz - pgs - 1, 12); + align = MAKE_64BIT_MASK(0, align); + if (tableaddr & (~pps_mask | align)) { + goto fault_walk; /* RES0 bits not 0 */ + } + break; + default: /* invalid */ + goto fault_walk; + } + + /* Level 1 lookup */ + level = 1; + index = extract64(paddress, pgs + 4, l0gptsz - pgs - 4); + tableaddr += index * 8; + entry = address_space_ldq_le(as, tableaddr, attrs, &result); + if (result != MEMTX_OK) { + goto fault_eabt; + } + + switch (extract32(entry, 0, 4)) { + case 1: /* contiguous descriptor */ + if (entry >> 10) { + goto fault_walk; /* RES0 bits not 0 */ + } + /* + * Because the softmmu tlb only works on units of TARGET_PAGE_SIZE, + * and because we cannot invalidate by pa, and thus will always + * flush entire tlbs, we don't actually care about the range here + * and can simply extract the GPI as the result. + */ + if (extract32(entry, 8, 2) == 0) { + goto fault_walk; /* reserved contig */ + } + gpi = extract32(entry, 4, 4); + break; + default: + index = extract64(paddress, pgs, 4); + gpi = extract64(entry, index * 4, 4); + break; + } + + found: + switch (gpi) { + case 0b0000: /* no access */ + break; + case 0b1111: /* all access */ + return true; + case 0b1000: + case 0b1001: + case 0b1010: + case 0b1011: + if (pspace == (gpi & 3)) { + return true; + } + break; + default: + goto fault_walk; /* reserved */ + } + + fi->gpcf = GPCF_Fail; + goto fault_common; + fault_eabt: + fi->gpcf = GPCF_EABT; + goto fault_common; + fault_size: + fi->gpcf = GPCF_AddressSize; + goto fault_common; + fault_walk: + fi->gpcf = GPCF_Walk; + fault_common: + fi->level = level; + fi->paddr = paddress; + fi->paddr_space = pspace; + return false; +} + static bool S2_attrs_are_device(uint64_t hcr, uint8_t attrs) { /* @@ -243,10 +433,15 @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw, }; GetPhysAddrResult s2 = { }; - if (get_phys_addr_with_struct(env, &s2ptw, addr, - MMU_DATA_LOAD, &s2, fi)) { + if (get_phys_addr_nogpc(env, &s2ptw, addr, MMU_DATA_LOAD, &s2, fi)) { goto fail; } + if (!granule_protection_check(env, s2.f.phys_addr, + s2.f.attrs.space, fi)) { + fi->type = ARMFault_GPCFOnWalk; + goto fail; + } + ptw->out_phys = s2.f.phys_addr; pte_attrs = s2.cacheattrs.attrs; pte_secure = s2.f.attrs.secure; @@ -2732,7 +2927,7 @@ static bool get_phys_addr_disabled(CPUARMState *env, target_ulong address, ARMMMUFaultInfo *fi) { uint8_t memattr = 0x00; /* Device nGnRnE */ - uint8_t shareability = 0; /* non-sharable */ + uint8_t shareability = 0; /* non-shareable */ int r_el; switch (mmu_idx) { @@ -2791,7 +2986,7 @@ static bool get_phys_addr_disabled(CPUARMState *env, target_ulong address, } else { memattr = 0x44; /* Normal, NC, No */ } - shareability = 2; /* outer sharable */ + shareability = 2; /* outer shareable */ } result->cacheattrs.is_s2_format = false; break; @@ -2819,7 +3014,7 @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw, ARMSecuritySpace ipa_space, s2walk_space; uint64_t hcr; - ret = get_phys_addr_with_struct(env, ptw, address, access_type, result, fi); + ret = get_phys_addr_nogpc(env, ptw, address, access_type, result, fi); /* If S1 fails, return early. */ if (ret) { @@ -2856,7 +3051,7 @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw, cacheattrs1 = result->cacheattrs; memset(result, 0, sizeof(*result)); - ret = get_phys_addr_with_struct(env, ptw, ipa, access_type, result, fi); + ret = get_phys_addr_nogpc(env, ptw, ipa, access_type, result, fi); fi->s2addr = ipa; /* Combine the S1 and S2 perms. */ @@ -2916,7 +3111,7 @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw, return false; } -static bool get_phys_addr_with_struct(CPUARMState *env, S1Translate *ptw, +static bool get_phys_addr_nogpc(CPUARMState *env, S1Translate *ptw, target_ulong address, MMUAccessType access_type, GetPhysAddrResult *result, @@ -3040,6 +3235,23 @@ static bool get_phys_addr_with_struct(CPUARMState *env, S1Translate *ptw, } } +static bool get_phys_addr_gpc(CPUARMState *env, S1Translate *ptw, + target_ulong address, + MMUAccessType access_type, + GetPhysAddrResult *result, + ARMMMUFaultInfo *fi) +{ + if (get_phys_addr_nogpc(env, ptw, address, access_type, result, fi)) { + return true; + } + if (!granule_protection_check(env, result->f.phys_addr, + result->f.attrs.space, fi)) { + fi->type = ARMFault_GPCFOnOutput; + return true; + } + return false; +} + bool get_phys_addr_with_secure(CPUARMState *env, target_ulong address, MMUAccessType access_type, ARMMMUIdx mmu_idx, bool is_secure, GetPhysAddrResult *result, @@ -3050,8 +3262,7 @@ bool get_phys_addr_with_secure(CPUARMState *env, target_ulong address, .in_secure = is_secure, .in_space = arm_secure_to_space(is_secure), }; - return get_phys_addr_with_struct(env, &ptw, address, access_type, - result, fi); + return get_phys_addr_gpc(env, &ptw, address, access_type, result, fi); } bool get_phys_addr(CPUARMState *env, target_ulong address, @@ -3121,8 +3332,7 @@ bool get_phys_addr(CPUARMState *env, target_ulong address, ptw.in_space = ss; ptw.in_secure = arm_space_is_secure(ss); - return get_phys_addr_with_struct(env, &ptw, address, access_type, - result, fi); + return get_phys_addr_gpc(env, &ptw, address, access_type, result, fi); } hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr, @@ -3141,7 +3351,7 @@ hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr, ARMMMUFaultInfo fi = {}; bool ret; - ret = get_phys_addr_with_struct(env, &ptw, addr, MMU_DATA_LOAD, &res, &fi); + ret = get_phys_addr_gpc(env, &ptw, addr, MMU_DATA_LOAD, &res, &fi); *attrs = res.f.attrs; if (ret) { From patchwork Mon Feb 20 23:26:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 655151 Delivered-To: patch@linaro.org Received: by 2002:adf:9bcd:0:0:0:0:0 with SMTP id e13csp1662085wrc; Mon, 20 Feb 2023 15:29:44 -0800 (PST) X-Google-Smtp-Source: AK7set8WdtoB/jIykdrvU9TLAxvQmBOLl7w23oBA2xm5FtXW4AhCXvaaaujzEwDHCviU0vIOIIoo X-Received: by 2002:a05:622a:15c4:b0:3bd:16c9:b34d with SMTP id d4-20020a05622a15c400b003bd16c9b34dmr2742262qty.24.1676935784293; Mon, 20 Feb 2023 15:29:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676935784; cv=none; d=google.com; s=arc-20160816; b=oqkmQFQXflODeAAK30h6jeAxScWm3xsMYxPXHiCMueopIQH3vGjBqsupV399RFwPRe PLzW4z+5HAcRyVZ+GTdl4KwzPlYTJ1eS3/uSCg+58kc4VyJruMco6d1fGwXYJJnuzgYL I6aLhGf6i55GBkO9qU7bl6CIkJ+ZKjTL+BxRczF0wmxYQhI838rRtC5bdhgBck6DWrSA FyxqCMkeC4b7JgkvXXwA0v9rLQnckzpROfhrfh2fK4dbbxMp6FTSnMkhJUREhWnTzf4d qsuF8GjhFmRW8EPuZSJQABrBbMTtBxwBn35UGTolRmPT7QbBPXOfCBOIB4zaSDL4Lyyv uGcw== 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=/Ut/aS2oezKic9UZ9DAK+e9x8VNxmPUkA0viJdZ3AGc=; b=OON6okOu9mMEBZUS/6rdD56K7m4DklqZ1w+UAFuexmtTVNPZmV4YcJbqv+pW72pErJ DX+O/m+c9SdG0TwrhIBuTSEY+WIHRGfJXBCiVe4rfxvdYGd2BqVVJjOJOCZWnAqS2YKJ Umt+fa90QzHckfy3Y6xFhRwcpcX0JMnJYtkoSi5iipMr7Lr+cGeamcrsAeCUOoOPQYpP ezBywR8/SqcntT8HPHiTFoazRQ4y2HRfwgOYb91q5PDFKkwUPGV3+3ALpDWMU08GCduA S4dAtO3JboiX+7lHDDfyA5696exekFtwV0C7vZN4JHVLv9DPslZHE0JR0ibH1XcIqD2D OTNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GhqdHjbr; 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 q10-20020a05620a0d8a00b006fc29969febsi11184747qkl.145.2023.02.20.15.29.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Feb 2023 15:29:44 -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=@linaro.org header.s=google header.b=GhqdHjbr; 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 1pUFYs-0004oG-FX; Mon, 20 Feb 2023 18:27:10 -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 1pUFYm-0004XW-Sf for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:27:05 -0500 Received: from mail-pj1-x1044.google.com ([2607:f8b0:4864:20::1044]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUFYl-0000TE-8Q for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:27:04 -0500 Received: by mail-pj1-x1044.google.com with SMTP id nt5-20020a17090b248500b00237161e33f4so1010286pjb.4 for ; Mon, 20 Feb 2023 15:27:02 -0800 (PST) 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 :message-id:reply-to; bh=/Ut/aS2oezKic9UZ9DAK+e9x8VNxmPUkA0viJdZ3AGc=; b=GhqdHjbrt2izcd84632/7HzZ/sVbJWMYyIOeUcjyL8xy8c7HZzFlH8ta323uZjYDZo gXvumDAmYks8aeypQrvrHTFIYKYUOzqmE+VJZd0fk20foX5qK9n6ShZJijB7I1fGXVAM a4QV/bX+kRZi0Ak5Dj1kNuPieD74OSiHjFFZwRcxGhKfVS7f8jPRDdZfuEMvSNp6c89R ymkHyyPngC3JM2yBJyRHI21tFx5e063YklRuGWxdfBi44/PiN3gTIlUUqn06QmISh8RM Ff1eaPESw+r+VyUAfkZ72aNc3cNSr2yW8iQjdMgY+1VuT5VceREwR2scRyQ7qJWWHixg r/eA== 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:message-id:reply-to; bh=/Ut/aS2oezKic9UZ9DAK+e9x8VNxmPUkA0viJdZ3AGc=; b=lP5JDXv241aA8yJhCPRlgojp7013x9K6XROOZZmF56q0DtQzm/sIAg/j9rRglwDgdO 6o0QTjsAAx90v0nBy+oc+vbUwLg4QPZHaof2nWyU5YjEt5NCk+xUPnXUC5Vj3moi8QgA s14NDKQIasJITlqcTv8sUTAd+0Oy8H7yqOdgCwXR5VX9DXprp+MCVCbIMfHdJMX1C+Sn yxl91mrf7sU5mLDKgTnzSWvqyr5Q7Un3aejEGzIQtThjOxKrpE4NipQ6DE9SSJfR4Osw YY4wvCa+RI/kkn0mvKcbDnxxUvI5OJin2VDv8cgELHPvaYegCl2j9xznjYVZmmj/INhx G19Q== X-Gm-Message-State: AO0yUKVmJTShHAlekYO7fl93n7u+h80iBVnBEz2X3lFXE4Cs4tfBaJlP pZspWGZ/tYROfbJ4+6RlDhYEPuvR50DPiWAMWt6T3w== X-Received: by 2002:a17:902:ea07:b0:199:33ff:918a with SMTP id s7-20020a170902ea0700b0019933ff918amr4216964plg.21.1676935621746; Mon, 20 Feb 2023 15:27:01 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id j10-20020a170902690a00b001992e74d058sm2665348plk.7.2023.02.20.15.27.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Feb 2023 15:27:01 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [NOTFORMERGE PATCH v2 20/21] target/arm: Enable RME for -cpu max Date: Mon, 20 Feb 2023 13:26:25 -1000 Message-Id: <20230220232626.429947-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220232626.429947-1-richard.henderson@linaro.org> References: <20230220232626.429947-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1044; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1044.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 Add a cpu property to set GPCCR_EL3.L0GPTSZ, for testing various possible configurations. Signed-off-by: Richard Henderson --- target/arm/cpu64.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 4066950da1..70c173ee3d 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -672,6 +672,40 @@ void arm_cpu_lpa2_finalize(ARMCPU *cpu, Error **errp) cpu->isar.id_aa64mmfr0 = t; } +static void cpu_max_set_l0gptsz(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + ARMCPU *cpu = ARM_CPU(obj); + uint32_t value; + + if (!visit_type_uint32(v, name, &value, errp)) { + return; + } + + /* Encode the value for the GPCCR_EL3 field. */ + switch (value) { + case 30: + case 34: + case 36: + case 39: + cpu->reset_l0gptsz = value - 30; + break; + default: + error_setg(errp, "invalid value for l0gptsz"); + error_append_hint(errp, "valid values are 30, 34, 36, 39\n"); + break; + } +} + +static void cpu_max_get_l0gptsz(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + ARMCPU *cpu = ARM_CPU(obj); + uint32_t value = cpu->reset_l0gptsz + 30; + + visit_type_uint32(v, name, &value, errp); +} + static void aarch64_a57_initfn(Object *obj) { ARMCPU *cpu = ARM_CPU(obj); @@ -1200,6 +1234,7 @@ static void aarch64_max_initfn(Object *obj) t = FIELD_DP64(t, ID_AA64PFR0, SVE, 1); t = FIELD_DP64(t, ID_AA64PFR0, SEL2, 1); /* FEAT_SEL2 */ t = FIELD_DP64(t, ID_AA64PFR0, DIT, 1); /* FEAT_DIT */ + t = FIELD_DP64(t, ID_AA64PFR0, RME, 1); /* FEAT_RME */ t = FIELD_DP64(t, ID_AA64PFR0, CSV2, 2); /* FEAT_CSV2_2 */ t = FIELD_DP64(t, ID_AA64PFR0, CSV3, 1); /* FEAT_CSV3 */ cpu->isar.id_aa64pfr0 = t; @@ -1301,6 +1336,8 @@ static void aarch64_max_initfn(Object *obj) object_property_add(obj, "sve-max-vq", "uint32", cpu_max_get_sve_max_vq, cpu_max_set_sve_max_vq, NULL, NULL); qdev_property_add_static(DEVICE(obj), &arm_cpu_lpa2_property); + object_property_add(obj, "l0gptsz", "uint32", cpu_max_get_l0gptsz, + cpu_max_set_l0gptsz, NULL, NULL); } static const ARMCPUInfo aarch64_cpus[] = { From patchwork Mon Feb 20 23:26:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 655134 Delivered-To: patch@linaro.org Received: by 2002:adf:9bcd:0:0:0:0:0 with SMTP id e13csp1661445wrc; Mon, 20 Feb 2023 15:27:45 -0800 (PST) X-Google-Smtp-Source: AK7set88pJBzAj9TxaCzBnHiI6ZqLl5TUO/oJ5igTZQjT0kRAo+J+UyUwxPgbnzTn0xu4xFVLDo3 X-Received: by 2002:ac8:5b89:0:b0:3b8:938e:73b3 with SMTP id a9-20020ac85b89000000b003b8938e73b3mr4367416qta.45.1676935665059; Mon, 20 Feb 2023 15:27:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676935665; cv=none; d=google.com; s=arc-20160816; b=0l8r5iHFUBaWFU4oGquhZ3J9XfXCcVhipzFKiLJo1uzgkrxi/7bEzxVGsRYZWniJZN v58UgUQ/V946fxdoee4ozhbjLTj66oXOzmuF2yHdnJuYgxMvu/GQLEMTmp3W4JH7TMSk 7LUU/KWi7Zg6zBuiOx9VUk/WP10E4gRBvQU/i5UzXsOgLI67oGqyIUTbNlz4+nfkJr5H P2vQ49+9qKISinurwungIEVdQQdX7ZDww0++b3gFDVN1nUISiScI9t6wOU2AZGuBV4DN KDzsqlffVAvgpTvtHR+KG8yfDpplFR5zzGPjWG3eow4zhV8f/kLTVorhIls/UVqP5eCw 6HvA== 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=H9Qr7wA8wSIkfPgh/j+3hKBpjrPyoBLV3ksLdpb2kIs=; b=Q5J4wG3q695g83zqD75zPNdSsFRsuqwMrdKYXsfwVMHO20H3WCGZPSKOQGUhbGNhDv MzSmeT5Mt9MQr6a2As5dyhUbc0G+9z3STb7gHKkOMoaGA5oMxJxyVDULrgSpUqe84LrI LEjd4ZSlK9lwUZ6KDQkrzV65lvO2LckK29v7BQvDYk4z/c4KUKCc2vYqwB5N+Y4mfl0I GOfvTB1SPniPVjigwEywnCmYb4nNdW7eGKDMDZHB8fnXmOJSpDIwLjwPgetzWs8lVubL f0b17Llk8qIWYOIuV4uVVpbIJtwJ9n8pQeSPYWn3uW0JEOBQ/iMVJt8nsOoVpiq3adac JSsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Cr7nFj4S; 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 n18-20020a05620a295200b0073bac9cae69si9039239qkp.549.2023.02.20.15.27.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Feb 2023 15:27:45 -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=@linaro.org header.s=google header.b=Cr7nFj4S; 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 1pUFYr-0004if-7t; Mon, 20 Feb 2023 18:27:09 -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 1pUFYo-0004bz-1l for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:27:06 -0500 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUFYm-0000QK-1G for qemu-devel@nongnu.org; Mon, 20 Feb 2023 18:27:05 -0500 Received: by mail-pj1-x1034.google.com with SMTP id v3-20020a17090a6b0300b002341a2656e5so2796166pjj.1 for ; Mon, 20 Feb 2023 15:27:03 -0800 (PST) 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 :message-id:reply-to; bh=H9Qr7wA8wSIkfPgh/j+3hKBpjrPyoBLV3ksLdpb2kIs=; b=Cr7nFj4SILcFDKj/Sxrao5rEXlPsCryfOXCDlh+Nf1jQ4Sxl300qNIafsVBRnM25Fk D/A+8heOpnJxYc88c8ntJRleQ457TPRKotefEojkvIm8nXTdqAitoFjgd+5XCVzwD7ad M1ccXMHwKuKRKRUZktgLABKUqg5mhRYNpWl6e//ZB4IEz4nYIgEWq4QBSc8WyI0fTQ5i KyVEw0v63kMzUAeamE6x+4WnTHXZPyFmE303IUUnQRTxWRj8Utcl6w0FIudRCgTKBaoy TTWDTxukPBJFtz9M2yxoR73YUM5LRqnblk3AeyrwPh+YjwLWUITFFPz37jdwU3t/arYh v/Aw== 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:message-id:reply-to; bh=H9Qr7wA8wSIkfPgh/j+3hKBpjrPyoBLV3ksLdpb2kIs=; b=afejGhz+hRHU8HyEXPJnRKtgygquXQ3ZSlffz64GQGt64fUEGQmB+MNx5Mf4zOP+xy hFAM7nd0qwq2CKRl4PHuzEVD4tzDnJiU4ZILM/IpDPZgNaJ6SjXhDHxG78F9fUPt60q7 0WaW4DsB2NsPMd7/KvQrQMfD9YA9dvDgNc6A77SSvPlsk2DKuJ05NOI1a9ktwbLZjXgu 3qtDrfHjfkMKR32JY9X/WLWKKl9o6fNRFovNeJOx3hdh6O8MYQEPaPLwWTXhq0xtlFi9 g4fiweCdeBplKup4TypPnH54AN8m8AUJxxmCPVKm5XxD+xI5BTwRHTL/Y+7BWRf05VNo oihA== X-Gm-Message-State: AO0yUKV6bQHAd88giGDISVuesKadteMk0RiJ5sILLcy6lOCYc30VpUlm ShOX/vR0AfchkG3hg8Gzbh7qojcX57QpeVHVghQ= X-Received: by 2002:a17:902:f544:b0:196:6577:5a96 with SMTP id h4-20020a170902f54400b0019665775a96mr5634257plf.30.1676935623209; Mon, 20 Feb 2023 15:27:03 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id j10-20020a170902690a00b001992e74d058sm2665348plk.7.2023.02.20.15.27.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Feb 2023 15:27:02 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [NOTFORMERGE PATCH v2 21/21] hw/arm/virt: Add some memory for Realm Management Monitor Date: Mon, 20 Feb 2023 13:26:26 -1000 Message-Id: <20230220232626.429947-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220232626.429947-1-richard.henderson@linaro.org> References: <20230220232626.429947-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1034.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=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 This is arbitrary, but used by the Huawei TF-A test code. Signed-off-by: Richard Henderson --- include/hw/arm/virt.h | 2 ++ hw/arm/virt.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index e1ddbea96b..5c0c8a67e4 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -86,6 +86,7 @@ enum { VIRT_ACPI_GED, VIRT_NVDIMM_ACPI, VIRT_PVTIME, + VIRT_RMM_MEM, VIRT_LOWMEMMAP_LAST, }; @@ -159,6 +160,7 @@ struct VirtMachineState { bool virt; bool ras; bool mte; + bool rmm; bool dtb_randomness; OnOffAuto acpi; VirtGICType gic_version; diff --git a/hw/arm/virt.c b/hw/arm/virt.c index ac626b3bef..067f16cd77 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -159,6 +159,7 @@ static const MemMapEntry base_memmap[] = { /* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */ [VIRT_PLATFORM_BUS] = { 0x0c000000, 0x02000000 }, [VIRT_SECURE_MEM] = { 0x0e000000, 0x01000000 }, + [VIRT_RMM_MEM] = { 0x0f000000, 0x00100000 }, [VIRT_PCIE_MMIO] = { 0x10000000, 0x2eff0000 }, [VIRT_PCIE_PIO] = { 0x3eff0000, 0x00010000 }, [VIRT_PCIE_ECAM] = { 0x3f000000, 0x01000000 }, @@ -1602,6 +1603,25 @@ static void create_secure_ram(VirtMachineState *vms, g_free(nodename); } +static void create_rmm_ram(VirtMachineState *vms, + MemoryRegion *sysmem, + MemoryRegion *tag_sysmem) +{ + MemoryRegion *rmm_ram = g_new(MemoryRegion, 1); + hwaddr base = vms->memmap[VIRT_RMM_MEM].base; + hwaddr size = vms->memmap[VIRT_RMM_MEM].size; + + memory_region_init_ram(rmm_ram, NULL, "virt.rmm-ram", size, + &error_fatal); + memory_region_add_subregion(sysmem, base, rmm_ram); + + /* do not fill in fdt to hide rmm from normal world guest */ + + if (tag_sysmem) { + create_tag_ram(tag_sysmem, base, size, "mach-virt.rmm-tag"); + } +} + static void *machvirt_dtb(const struct arm_boot_info *binfo, int *fdt_size) { const VirtMachineState *board = container_of(binfo, VirtMachineState, @@ -2283,6 +2303,10 @@ static void machvirt_init(MachineState *machine) machine->ram_size, "mach-virt.tag"); } + if (vms->rmm) { + create_rmm_ram(vms, sysmem, tag_sysmem); + } + vms->highmem_ecam &= (!firmware_loaded || aarch64); create_rtc(vms); @@ -2562,6 +2586,20 @@ static void virt_set_mte(Object *obj, bool value, Error **errp) vms->mte = value; } +static bool virt_get_rmm(Object *obj, Error **errp) +{ + VirtMachineState *vms = VIRT_MACHINE(obj); + + return vms->rmm; +} + +static void virt_set_rmm(Object *obj, bool value, Error **errp) +{ + VirtMachineState *vms = VIRT_MACHINE(obj); + + vms->rmm = value; +} + static char *virt_get_gic_version(Object *obj, Error **errp) { VirtMachineState *vms = VIRT_MACHINE(obj); @@ -3115,6 +3153,11 @@ static void virt_machine_class_init(ObjectClass *oc, void *data) "guest CPU which implements the ARM " "Memory Tagging Extension"); + object_class_property_add_bool(oc, "rmm", virt_get_rmm, virt_set_rmm); + object_class_property_set_description(oc, "rmm", + "Set on/off to enable/disable ram " + "for the Realm Management Monitor"); + object_class_property_add_bool(oc, "its", virt_get_its, virt_set_its); object_class_property_set_description(oc, "its",