From mboxrd@z Thu Jan 1 00:00:00 1970 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=-15.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 863D4C07E95 for ; Tue, 20 Jul 2021 16:56:20 +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 454A860FEA for ; Tue, 20 Jul 2021 16:56:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 454A860FEA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.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:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=D7de8xPEprnBer1f1/RPYJHbG21Ff7Dl1M4CoYQJYeI=; b=soyBB7Cf0bNicY gZ0TX16xlN8/G7bOxmXwUUwNhkbyA8ya5ZsPxAvVYfv2jjYoeBpXU/wHqKZxKdIdfjS7Q+Bjzh8R2 gLUwO0NLTXU/DmseLdpInIs4nv0ntBad3tMeLi/eOb0JiRxGi5PuVLVkYDG9TEq41r99YJE9k42iy 0KUI7avVkdm0N8ty3HRNs2OnRpTVY7FAD2jkFoWuuiyy6hHjczyJoY0RKciFiwvpsNqOjcSfXAPYb GArB88DpkuFXX+aLxofxMUToPfNzbaGEjXENS0gOrV6GaiqRUEJRjBYIOoztGofV2iuQbKnU6HJHK RcVOQw3kD8J003Ot45oQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m5t0o-00Db2Z-HS; Tue, 20 Jul 2021 16:54:30 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m5t0X-00Db27-Af for linux-arm-kernel@lists.infradead.org; Tue, 20 Jul 2021 16:54:14 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id ECCA7610FB for ; Tue, 20 Jul 2021 16:54:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626800053; bh=PZyeHr3+WZYJj+mq/NRWwHvlgKvjAGQRJfx7+xLkDc0=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=OxL23t2LZXI8BQqW/W0wS4CIwdU5hdZD4irut+2nLV4XJPp0CZGZkPywbYpsPFbYR 5IQ+ds/oPOTI+fv5wwluBMttWY+A8JYR5XnrJw4P2P7h8AiuqaW2d0pQXdBP3mBa8n 8MNb6PUqqIxBYZiBe8PCEylxVZRwnfyIyADlq5eDPAr/5aBwex5dJ058j/gDbcJWmr mgfL9txbxlCCq5A6LIq35zwcCWYxOXpPlRdgL6qBpOSKXR6tH4XNyIRn+shB8uJJVC ZP4Zn6fhOOxcvQoxvjAaKRhza199z25E8j+NlF+w6SfkI4IezYcc17pol6rYfm0Wy4 IW3lxX5upYiTg== Received: by mail-oi1-f179.google.com with SMTP id w194so25211215oie.5 for ; Tue, 20 Jul 2021 09:54:12 -0700 (PDT) X-Gm-Message-State: AOAM533Krqc590svI1tjEC5NC+SqmKe+rzDrCmyCm8035V3GXGBn7hta EJJSPEI+YjMca/IKuaj5haRW3MTiOnsRb2Wr930= X-Google-Smtp-Source: ABdhPJxlh+YiwYP219E10C7+6/BolsZCwNsfEWWvqzxdkrVY2ghc7vpoYqSitSwh0TdEu6wTRhbuHYqdUjWXA1eAj3o= X-Received: by 2002:aca:5a04:: with SMTP id o4mr21467292oib.33.1626800052364; Tue, 20 Jul 2021 09:54:12 -0700 (PDT) MIME-Version: 1.0 References: <20210720163103.3836898-1-jean-philippe@linaro.org> In-Reply-To: <20210720163103.3836898-1-jean-philippe@linaro.org> From: Ard Biesheuvel Date: Tue, 20 Jul 2021 18:54:01 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] arm64: smccc: Save lr before calling __arm_smccc_sve_check() To: Jean-Philippe Brucker Cc: Catalin Marinas , Will Deacon , Mark Brown , Linux ARM X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210720_095413_443964_2892BB9E X-CRM114-Status: GOOD ( 19.39 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, 20 Jul 2021 at 18:37, Jean-Philippe Brucker wrote: > > 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 > --- > > 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]! Please add a mov x29, sp here to create a proper stack frame With that Acked-by: Ard Biesheuvel > 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 > > /* > -- > 2.32.0 > > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel