From patchwork Tue Jul 20 16:31:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Philippe Brucker X-Patchwork-Id: 12388831 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0AEA2C07E95 for ; Tue, 20 Jul 2021 16:38:13 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C40B161019 for ; Tue, 20 Jul 2021 16:38:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C40B161019 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=Yf2T5GxSuo0osLUZBwUS3AzXqMOyt4QpsCChSMm72lg=; b=JZ+ywwVIVNUNBI sYGJs5oWCVRKuKOjIp+tTTMCj7Epw2kCCXSp9dAMrKE1MljM3RKzPIaux2QjfDEAlx4KwpEyxZbMn iNbZReKXVJaK4u3zmyjdanPQbpOn3h9i7/OS53ofjkb0YH3dJTAlaWKqkxLuMO8hDt/e9laxJkIEM FUs87dE+I18XxpBN0LhY8VGKl+xgKsfbteSh0KygpQZ8IAJNZxqVbNX6qnpsZU+9X8xxszB/tI0Vu edTyhT88+PEObStwyZlQy8GZM8t9aqZ4go5ZZ3Pb1jbIgnHCPBIbfYHsaGnrWjJTSAMirBRTdnT/H EzHyhOPINRC5N/3wiFxw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m5sjQ-00DZ3s-Az; Tue, 20 Jul 2021 16:36:32 +0000 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m5sjL-00DZ2c-SW for linux-arm-kernel@lists.infradead.org; Tue, 20 Jul 2021 16:36:29 +0000 Received: by mail-ej1-x636.google.com with SMTP id qb4so35207500ejc.11 for ; Tue, 20 Jul 2021 09:36:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=GPtpKHtr0dmqNWb1OwqWCCfydwpywdA4MNZHHMbeJeA=; b=R7rPg0BnVPkXzXUYc9qw2TJKStGBtuuuH6Ow1JufiugYO2NS4n6UqvGXCnnaAFUbCS lWGTh4SsQQ5by/tf9LXVveYi2HF3Kc3eB261gy8fxkfzo7+o3/fcw354pBVSx5a0FI0L 60Ojqhl0Q09RZQKS7/7V0K9Sq0Y5Ja3deoBLM3nKxGEu/F4sSWNv0PDVtCO9TQ657i8K aMuRp41FA+k0C504tbdS+LbPC/KGQnMVJJ3p7SaLt5i3Srwb7KLkk8QrcgzIMMeE7Y0f TeSYLg/m3TMZJ/lEilY466hxC2K7pbzyra312tVQLfrTuBSMgrWzxxRboeGdY2Bpx0fq yfrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=GPtpKHtr0dmqNWb1OwqWCCfydwpywdA4MNZHHMbeJeA=; b=Z0DtxyYOYgrnJUd+Svjy4X2iqAi/4ivJ7sFHW48bGYy53mQ87KOm044rAGyoX+ZOpO UD/RZZ2f2m6pWA65aei4E3nglPIl9Mvi97yekSM2Jl7OYTkuPSPRN5WAlND9h2nm0hX5 /EeJ1Pe7yHLZttfvN5zO23jqmCAEeKaGaugOB/+eUd/poq0A2wYBd9zowd02PRsfsQe/ GVgyn9Lz1D/nPkszkZUsjoQfxNKR6vuIeEQTPXGIJxOjhfbLi1Pao7sC2dY/xdNmH/eE BS9tWlUGiEedG/tLWjSMuh580rnv3F9S584xuOW7Wmg424W3CvSonynYWEUDtg1eyBX3 eHKA== X-Gm-Message-State: AOAM5318s2NCcBKR26ea2wf26zih88KA/CA3H8uPcdkhndk8arsrHTgd ixS0hUg1LupZhzUO6zeb1TyJhEdhMadSww== X-Google-Smtp-Source: ABdhPJxhwrOnM8c53LT47saQQBVU0zUNYY81Z228S4IR5r+RFyg0fr8BzvlS6hILflSos0JVwkpt8Q== X-Received: by 2002:a17:906:7fcd:: with SMTP id r13mr33651271ejs.547.1626798986197; Tue, 20 Jul 2021 09:36:26 -0700 (PDT) Received: from localhost.localdomain (adsl-84-226-111-173.adslplus.ch. [84.226.111.173]) by smtp.gmail.com with ESMTPSA id b13sm897072ede.49.2021.07.20.09.36.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jul 2021 09:36:25 -0700 (PDT) From: Jean-Philippe Brucker To: catalin.marinas@arm.com, will@kernel.org Cc: broonie@kernel.org, linux-arm-kernel@lists.infradead.org, Jean-Philippe Brucker Subject: [PATCH] arm64: smccc: Save lr before calling __arm_smccc_sve_check() Date: Tue, 20 Jul 2021 18:31:05 +0200 Message-Id: <20210720163103.3836898-1-jean-philippe@linaro.org> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210720_093627_965921_CE8C62BF X-CRM114-Status: GOOD ( 10.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Commit cfa7ff959a78 ("arm64: smccc: Support SMCCC v1.3 SVE register saving hint") added a call to __arm_smccc_sve_check() which clobbers the lr (register x30), causing __arm_smccc_hvc() to return to itself and crash. Save lr on the stack before calling __arm_smccc_sve_check(), and adjust the offsets used to access stack parameters. Fixes: cfa7ff959a78 ("arm64: smccc: Support SMCCC v1.3 SVE register saving hint") Signed-off-by: Jean-Philippe Brucker Acked-by: Ard Biesheuvel Acked-by: Mark Brown --- Under QEMU TCG (-cpu max), PSCI calls now cause a BUG(), since the clobbered lr causes __arm_smccc_hvc() to return to the hvc instruction with invalid x0 parameter, which is treated as undefined instruction by TCG. --- arch/arm64/kernel/smccc-call.S | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kernel/smccc-call.S b/arch/arm64/kernel/smccc-call.S index d3d37f932b97..c16679eec7af 100644 --- a/arch/arm64/kernel/smccc-call.S +++ b/arch/arm64/kernel/smccc-call.S @@ -32,20 +32,22 @@ SYM_FUNC_END(__arm_smccc_sve_check) EXPORT_SYMBOL(__arm_smccc_sve_check) .macro SMCCC instr + stp x29, x30, [sp, #-16]! alternative_if ARM64_SVE bl __arm_smccc_sve_check alternative_else_nop_endif \instr #0 - ldr x4, [sp] + ldr x4, [sp, #16] stp x0, x1, [x4, #ARM_SMCCC_RES_X0_OFFS] stp x2, x3, [x4, #ARM_SMCCC_RES_X2_OFFS] - ldr x4, [sp, #8] + ldr x4, [sp, #24] cbz x4, 1f /* no quirk structure */ ldr x9, [x4, #ARM_SMCCC_QUIRK_ID_OFFS] cmp x9, #ARM_SMCCC_QUIRK_QCOM_A6 b.ne 1f str x6, [x4, ARM_SMCCC_QUIRK_STATE_OFFS] -1: ret +1: ldp x29, x30, [sp], #16 + ret .endm /*