From patchwork Thu Jul 6 14:08:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Philippe Brucker X-Patchwork-Id: 699604 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp3335989wrs; Thu, 6 Jul 2023 07:13:13 -0700 (PDT) X-Google-Smtp-Source: APBJJlHKdE1gigdY/bjcCwBVigyTKxTo+wefuLdwo1vXD6gcScVZgoIsK/6DBNNk3mp+7+q/85VG X-Received: by 2002:a0c:8ecf:0:b0:637:77d7:7c45 with SMTP id y15-20020a0c8ecf000000b0063777d77c45mr1824230qvb.45.1688652793596; Thu, 06 Jul 2023 07:13:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688652793; cv=none; d=google.com; s=arc-20160816; b=OzxWEsFo1UQr9CXsXqox24wbpwmvJOTl5X13VCBLa+uNOT4m9m+vMgFQu7znH9jqOn ZAlNcL3lGGkw2xijh2Cv32xvX01pWXOk9MemeJr9gc2qf/ZUfga+bA1e+5apO1iFVj0C Xrj5bgRaxhw7KSzHvD+Ba4pwdEE1JHFLJnHvhE87DLhZmsdivjj9EoiapYeFnbQEIxtf KoGRqz5RsuIeyt3xNLwnEVt5j3dBCSU9PrH3IlKd2AT6dMJdfNcFWt++C+pekvjr0DmR ZjGFIpIxlDMTHWpEZ+IDaPv9JxJqI0hXEIpWTTbd4uvpw2ulpQZHIiUkQC1PDU9I7wuP IbLg== 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:message-id:date:subject:cc:to:from:dkim-signature; bh=y8EcAtZee2xyMmG6qvAV2IgEtPw0oRg5VwhrhipzSYs=; fh=zMLmPP9ozJY0jj0bAXqZquWHP0BgmjJZ9lKiHhJNaWU=; b=kFmW8TBAI6QV1ak/vKjcoGjdLmBBw/PegfonW/An3hV8WgpJavE12Ut62/Mxnjzd4Q y+bBjg0uLpLu/kypGi2XcVeDJVHlKmhIlodOfioXup+MX1Buow/jPE04pbZ2Kq+JbTGk Dk1UV/vTm3C6b4mIzPTAm8wil31707iBSEXoc+qN57MyALS9GD9iH0Bj2Xnumf9pROCP iDhqhNrVAP6K85JPZyZiqiTfBqP/iWbwktJI3w2Lp0Vev4mwQA3XnAcRJTVvpcUVuHZ8 +ORcsOiW9iSY0koBu2eMdMczEiEBC1GFrEpqolCeIm3IKlmg3GLEpwBxQz9KgpQgnMDC Nt+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JN2+eRKc; 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 l4-20020a0ce084000000b0062b5c0de74esi946794qvk.592.2023.07.06.07.13.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Jul 2023 07:13:13 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JN2+eRKc; 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 1qHPif-0004Qs-IO; Thu, 06 Jul 2023 10:12:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qHPid-0004QY-Sr for qemu-devel@nongnu.org; Thu, 06 Jul 2023 10:12:27 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qHPib-0005lB-Vl for qemu-devel@nongnu.org; Thu, 06 Jul 2023 10:12:27 -0400 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-3142970df44so660036f8f.3 for ; Thu, 06 Jul 2023 07:12:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688652744; x=1691244744; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=y8EcAtZee2xyMmG6qvAV2IgEtPw0oRg5VwhrhipzSYs=; b=JN2+eRKcb487n3IfDnwMiVDYw2P006KKtXU2S9h1ZJAPmy95/wStwSLHd1VdQy/EJN 8hajgfH4gM+YCfQn5LEiLOL/ijpFZOVDrvOypr/sNyU+fMFyowL+S2VDK1YCCl2WU5bF Bk8PevrnrUuMcbAb025Hyv3/QEjNN699K8c+lRlCLxcZeGtdSzwLgesIgQwtHLfZ1gLN iBJkj8jOrzVaG05a30+W2FMQda6jTbwhZW+0FkqcqKq5jK2Y53DkJccAJkhHOji2cfCl 5q0jk6Eio+pGjCBx3hgKlNVz7wApFLHhkh4xP5JxXs0amNI3r8bQmqHC6CKNZl52d9DC OF9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688652744; x=1691244744; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=y8EcAtZee2xyMmG6qvAV2IgEtPw0oRg5VwhrhipzSYs=; b=LGi9RwLYZ1VYlWgoE6Tq/x9+x+ayeD4YJtAcCTJqCUYU1UH6WvuQiMyi9pb7a9OhSd DbwKB7zizKbUrIgP6mgux/wQvSpTgdx0Y9ySyD4hiY49bNn4YdN6WZEDzbuNxUr3doa6 TV578hpFMe0ofDXqSwpuLgp9vIcc9MnG26rYqp0xBFXzyK1EkZ6q5aROb0P8uKjh/yI/ UGjRZycYrOpPjCBAomXf9TWwntg9PszQgrah7qF3qiATJsVLXImQ9Ix6R+wtGl6mYvJs QGekGR64ZhJgTP7WOnW8L8ucoXtHA+53GiLc/izNn77EPr2HMNYcHyUvER/3TZe4Dpbg 30pg== X-Gm-Message-State: ABy/qLZbFnHw7x1MtAvzFr1X1FohZNVXTFz5jDRxO2LkJMmIFe/qFZNU fXC1eaLA4xJIcyXMLmzNpURv0Q== X-Received: by 2002:adf:e790:0:b0:314:824:3777 with SMTP id n16-20020adfe790000000b0031408243777mr1689836wrm.48.1688652744037; Thu, 06 Jul 2023 07:12:24 -0700 (PDT) Received: from localhost.localdomain ([2.219.138.198]) by smtp.gmail.com with ESMTPSA id f18-20020adff992000000b003142e438e8csm2008708wrr.26.2023.07.06.07.12.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jul 2023 07:12:23 -0700 (PDT) From: Jean-Philippe Brucker To: peter.maydell@linaro.org Cc: richard.henderson@linaro.org, qemu-arm@nongnu.org, qemu-devel@nongnu.org, Jean-Philippe Brucker Subject: [PATCH] target/arm: Fix ptw parameters in S1_ptw_translate() for debug contexts Date: Thu, 6 Jul 2023 15:08:51 +0100 Message-ID: <20230706140850.3007762-2-jean-philippe@linaro.org> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=jean-philippe@linaro.org; helo=mail-wr1-x430.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, T_SCC_BODY_TEXT_LINE=-0.01 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 Arm TF-A fails to boot via semihosting following a recent change to the MMU code. Semihosting attempts to read parameters passed by TF-A in secure RAM via cpu_memory_rw_debug(). While performing the S1 translation, we call S1_ptw_translate() on the page table descriptor address, with an MMU index of ARMMMUIdx_Phys_S. At the moment S1_ptw_translate() doesn't interpret this as a secure access, and as a result we attempt to read the page table descriptor from the non-secure address space, which fails. Fixes: fe4a5472ccd6 ("target/arm: Use get_phys_addr_with_struct in S1_ptw_translate") Signed-off-by: Jean-Philippe Brucker --- I'm not entirely sure why the semihosting parameters are accessed through stage-1 translation rather than directly as physical addresses, but I'm not familiar with semihosting. --- target/arm/ptw.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 9aaff1546a..e3a738c28e 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -465,10 +465,8 @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw, S1Translate s2ptw = { .in_mmu_idx = s2_mmu_idx, .in_ptw_idx = ptw_idx_for_stage_2(env, s2_mmu_idx), - .in_secure = s2_mmu_idx == ARMMMUIdx_Stage2_S, - .in_space = (s2_mmu_idx == ARMMMUIdx_Stage2_S ? ARMSS_Secure - : space == ARMSS_Realm ? ARMSS_Realm - : ARMSS_NonSecure), + .in_secure = is_secure, + .in_space = space, .in_debug = true, }; GetPhysAddrResult s2 = { };