From patchwork Tue Feb 8 11:39:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 540761 Delivered-To: patch@linaro.org Received: by 2002:ad5:420f:0:0:0:0:0 with SMTP id e15csp443986imo; Tue, 8 Feb 2022 04:21:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJwmst3rHQnYtKkN8UUIQf7uD+0HptKrtEtulBohEolOPwSggP/tpusKn5mnu01H9AcaSAeR X-Received: by 2002:a25:4842:: with SMTP id v63mr4493991yba.21.1644322915916; Tue, 08 Feb 2022 04:21:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644322915; cv=none; d=google.com; s=arc-20160816; b=mlVJy6bszog3QyfazMv9lIrvBYywZrLGmGON4hvYMYIINanck1AQOcf45xOzwxlgpe f5R4ShozUhiXfWJvDRlxb6e9w2lEEig5rL5XbX7nV2Q80ZpC0DEoKw7grLk1RicWWr3n TMmQTHqT9q8U1op6UA9uWFWIn+MkzyoNufaC0CklYZ4fhqcsJVq12HXAc7AwOA5whsKp C/nhM7nZOzCJzFKYmh5DSANRJwfqEku5X/Dt71SKc3D+lIv1VtleWC57cQwxxd53iyVx +3K4DCFT1Zd48SfVTs2yhteE6ZloZ+QuH2wW85Dj/ZG9dMix9q4dWKyvnW0wd4oWwPZa 5VnA== 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:to:from :dkim-signature; bh=0p89JlNK/gdgxgU6z1QE83PIekJHSLOFEA28AM6yAyk=; b=nw14oOLDyaDflnBMFHCgD6QX4FK5W7Ltd9z6znPH5UKHtdD/u3Cg3kf0T/+0RcpZAV W4Y60w4xjUowuxeaaWrIK8uWzV9j3v9BZEsfGZNQT6PKO/IDrc51riN1zGYdaJiyvrvj 3z11pyPcPPNYQm2aROi99dL/nI673Hqgw+juEH7Lq7lVXZR7D6mMDb/s+v4LfMCFuS0q 9WCV3RqIc4DpYlwrLLIxzbeqJnXfIXBIMaoOBWd54y+CC8xngP3PYgi8ZgE/pZOV/jsf 2sucHI0F7H8vVjnjMBmKPb6EWWFbh4c1tBjsr5Xp71YJSrvBywPlLqQ5R6Z7CQ7AosMK Xkdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RtrCaCwg; 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 b20si9897740ywb.313.2022.02.08.04.21.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 Feb 2022 04:21: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=RtrCaCwg; 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]:45624 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHPVL-0006X6-3e for patch@linaro.org; Tue, 08 Feb 2022 07:21:55 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34748) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHOqt-0000l6-KX for qemu-devel@nongnu.org; Tue, 08 Feb 2022 06:40:08 -0500 Received: from [2a00:1450:4864:20::42c] (port=45049 helo=mail-wr1-x42c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nHOqn-000260-8L for qemu-devel@nongnu.org; Tue, 08 Feb 2022 06:40:04 -0500 Received: by mail-wr1-x42c.google.com with SMTP id k18so30169536wrg.11 for ; Tue, 08 Feb 2022 03:40:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=0p89JlNK/gdgxgU6z1QE83PIekJHSLOFEA28AM6yAyk=; b=RtrCaCwgRKDDgmRcI3b785kbzlleCu0ZpTievGNAnIkU8UkGMevLodBC0t+n40+ujT c7xT8Eg4ivDpAo1rcxy1b3OiIZPaHe2q8k9/y7BzILMLXU8e+0h8gLs1NNvutrXYEam9 NkLm0Dp+riw8GkOcgZNfyYVhRZxK3U5YF9PO94u3FpVjLLHGxEBxxOUu7KvDK+3IG+Nt h7pExs1ZwhC9FX/Fni3t9pz0ZPSbwth/aNOVu+f4EGSMWxK4hes1DrzijsKH4gu21JhE LO/dWq6cwS+Ku4Wm0A/rtefi+3g+m/QEt1WfYcbvHt1WRhSP6iKuPvTTc6FZGwFSkyKn 7i1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0p89JlNK/gdgxgU6z1QE83PIekJHSLOFEA28AM6yAyk=; b=TjlrrLsSKpZcu7Fs33HBbnrG1P9KikeI0XCwmMd7KBst+1eUJ4IPW4fGF2rVX0NI/Q Hr+RZYjSUNjAtXJ/iuDeX5V/imibvcnrA+2gTj7YFqXs4vfnA38zuI28xU9ghhEBx5kO ZjO3YPiitVs8Hn5/v/ij3W/5lXByCen1pqvr8QCpdcxaAZY8u0BOiHgWdwbIP5DiVztG fZjVsy5YxqOewPh5wXw0O5eN+5VWUGqhh187Z9Dh/jZXzNg7160DyvRcP7+4BvGYIGtU 4J//kvuJrdgdrs515YCFdbQS9cej2sJUny2eFERVEvYXt6gcivIIIFdfkdtMXiY4JmA6 Exkg== X-Gm-Message-State: AOAM533W4Et8XVgwvRRWdNkvTQa4LvePXsCwr+KDdEyMXEjfvMq1105P 8s8ZH8DuAfKndeJ+QF1vPxGqXYArX0GgVA== X-Received: by 2002:a5d:59af:: with SMTP id p15mr3310499wrr.488.1644320399960; Tue, 08 Feb 2022 03:39:59 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id r11sm4245199wrt.28.2022.02.08.03.39.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 03:39:59 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 15/39] arm: tcg: Adhere to SMCCC 1.3 section 5.2 Date: Tue, 8 Feb 2022 11:39:24 +0000 Message-Id: <20220208113948.3217356-16-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220208113948.3217356-1-peter.maydell@linaro.org> References: <20220208113948.3217356-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::42c (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42c.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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" The SMCCC 1.3 spec section 5.2 says The Unknown SMC Function Identifier is a sign-extended value of (-1) that is returned in the R0, W0 or X0 registers. An implementation must return this error code when it receives: * An SMC or HVC call with an unknown Function Identifier * An SMC or HVC call for a removed Function Identifier * An SMC64/HVC64 call from AArch32 state To comply with these statements, let's always return -1 when we encounter an unknown HVC or SMC call. [PMM: This is a reinstatement of commit 9fcd15b9193e819b, previously reverted in commit 4825eaae4fdd56fba0f; we can do this now that we have arranged for all the affected board models to not enable the PSCI emulation if they are running guest code at EL3. This avoids the regressions that caused us to revert the change for 7.0.] Signed-off-by: Alexander Graf Reviewed-by: Richard Henderson Reviewed-by: Niek Linnenbank Tested-by: Edgar E. Iglesias Tested-by: Cédric Le Goater Tested-by: Niek Linnenbank Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/psci.c | 35 ++++++----------------------------- 1 file changed, 6 insertions(+), 29 deletions(-) diff --git a/target/arm/psci.c b/target/arm/psci.c index 6709e280133..b279c0b9a45 100644 --- a/target/arm/psci.c +++ b/target/arm/psci.c @@ -27,15 +27,13 @@ bool arm_is_psci_call(ARMCPU *cpu, int excp_type) { - /* Return true if the r0/x0 value indicates a PSCI call and - * the exception type matches the configured PSCI conduit. This is - * called before the SMC/HVC instruction is executed, to decide whether - * we should treat it as a PSCI call or with the architecturally + /* + * Return true if the exception type matches the configured PSCI conduit. + * This is called before the SMC/HVC instruction is executed, to decide + * whether we should treat it as a PSCI call or with the architecturally * defined behaviour for an SMC or HVC (which might be UNDEF or trap * to EL2 or to EL3). */ - CPUARMState *env = &cpu->env; - uint64_t param = is_a64(env) ? env->xregs[0] : env->regs[0]; switch (excp_type) { case EXCP_HVC: @@ -52,27 +50,7 @@ bool arm_is_psci_call(ARMCPU *cpu, int excp_type) return false; } - switch (param) { - case QEMU_PSCI_0_2_FN_PSCI_VERSION: - case QEMU_PSCI_0_2_FN_MIGRATE_INFO_TYPE: - case QEMU_PSCI_0_2_FN_AFFINITY_INFO: - case QEMU_PSCI_0_2_FN64_AFFINITY_INFO: - case QEMU_PSCI_0_2_FN_SYSTEM_RESET: - case QEMU_PSCI_0_2_FN_SYSTEM_OFF: - case QEMU_PSCI_0_1_FN_CPU_ON: - case QEMU_PSCI_0_2_FN_CPU_ON: - case QEMU_PSCI_0_2_FN64_CPU_ON: - case QEMU_PSCI_0_1_FN_CPU_OFF: - case QEMU_PSCI_0_2_FN_CPU_OFF: - case QEMU_PSCI_0_1_FN_CPU_SUSPEND: - case QEMU_PSCI_0_2_FN_CPU_SUSPEND: - case QEMU_PSCI_0_2_FN64_CPU_SUSPEND: - case QEMU_PSCI_0_1_FN_MIGRATE: - case QEMU_PSCI_0_2_FN_MIGRATE: - return true; - default: - return false; - } + return true; } void arm_handle_psci_call(ARMCPU *cpu) @@ -194,10 +172,9 @@ void arm_handle_psci_call(ARMCPU *cpu) break; case QEMU_PSCI_0_1_FN_MIGRATE: case QEMU_PSCI_0_2_FN_MIGRATE: + default: ret = QEMU_PSCI_RET_NOT_SUPPORTED; break; - default: - g_assert_not_reached(); } err: