Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1211037pxb; Wed, 6 Apr 2022 11:25:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCKErI2Qd0qB+Ljgt1NL8pmjEcUz8tYrF0NXgtgr+DmhYd+qGvAoEWKZpTAZBJk8y4lhib X-Received: by 2002:a05:6a00:c85:b0:4fa:f806:10f5 with SMTP id a5-20020a056a000c8500b004faf80610f5mr10181931pfv.43.1649269530786; Wed, 06 Apr 2022 11:25:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649269530; cv=none; d=google.com; s=arc-20160816; b=mTgI2Dmw39wx5DM7OSUNXLOkJzyrhpKkx4d+3g5u+dCFCi4VTL3lqja4UoQog7KmZj Zanx9jVwjqwp8hi5bU1VEcmKzGQABfxYbIOu/CB5RoJlKFb0BRtAgBAXaP2wAXLQynxJ vftjc86O2zMyS9duoyiHz2KS/+6NYvCJTO0PnNu4gVnPI6itS+m8/5qM/G4S+e7qHwMy vRQTgkLEUbVUUc6yMo6lNp/5wUsmKjK1cMwfaXAiT2rvqzi2qIUmWKdt91er/Rbssncl 7oHB9fAEX2O7Y4qP3O1qVwvQ/fJ0H8z9uOQ+vmWrJxsTeichZjKlFx/83AbDohvcJq+J gGFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=xFxkHj6Hnd3wMTyUzVX96bCSIm9USDACvlXrpaCbd4w=; b=aLgtVDDY2yYEw8+TSOFoFmP8H+JFCbGLZcS8mLZaDNYpIoD+7uT0MM1Isrx3mLuqQI Lwq9cdami5zy/3Hm9pSy5nPpp8QsPYN9dLXmca1aBeSlgeEY5C1U69G9QylvPGx8tBuy gMU3+48EQ4JmB2+djv2oiGJkoGhsgtZP5k+4csXwrAE5yIZ+Rzg7XRoovWoqgRZ5cyMR qKqlyzOLN4GrT0vpQZlCR8CtolICVHwjCFnrfKiD8ycSRjzQtGJShZJ2CRFjqi2hQQHx 6ggVeU5Vzodg47Gfi/YA1+6oI9y6xiZbbXtBluQswj9HD6IAk3m6OifSx+rCejhVAscw EDqg== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id d15-20020a056a00198f00b004faecd78afesi16970336pfl.255.2022.04.06.11.25.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 11:25:30 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B5176189A3B; Wed, 6 Apr 2022 11:08:40 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240372AbiDFSKR (ORCPT + 99 others); Wed, 6 Apr 2022 14:10:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240531AbiDFSIG (ORCPT ); Wed, 6 Apr 2022 14:08:06 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 68FAF19456B; Wed, 6 Apr 2022 09:46:26 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 505A923A; Wed, 6 Apr 2022 09:46:26 -0700 (PDT) Received: from eglon.cambridge.arm.com (eglon.cambridge.arm.com [10.1.196.218]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A31B93F73B; Wed, 6 Apr 2022 09:46:25 -0700 (PDT) From: James Morse To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: James Morse , Catalin Marinas Subject: [stable:PATCH v4.9.309 27/43] arm64: entry: Free up another register on kpti's tramp_exit path Date: Wed, 6 Apr 2022 17:45:30 +0100 Message-Id: <20220406164546.1888528-27-james.morse@arm.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220406164546.1888528-1-james.morse@arm.com> References: <0220406164217.1888053-1-james.morse@arm.com> <20220406164546.1888528-1-james.morse@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org commit 03aff3a77a58b5b52a77e00537a42090ad57b80b upstream. Kpti stashes x30 in far_el1 while it uses x30 for all its work. Making the vectors a per-cpu data structure will require a second register. Allow tramp_exit two registers before it unmaps the kernel, by leaving x30 on the stack, and stashing x29 in far_el1. Reviewed-by: Russell King (Oracle) Reviewed-by: Catalin Marinas Signed-off-by: James Morse --- arch/arm64/kernel/entry.S | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index 160a3131a190..40647b5e279e 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -244,14 +244,16 @@ alternative_else_nop_endif ldp x24, x25, [sp, #16 * 12] ldp x26, x27, [sp, #16 * 13] ldp x28, x29, [sp, #16 * 14] - ldr lr, [sp, #S_LR] - add sp, sp, #S_FRAME_SIZE // restore sp .if \el == 0 -alternative_insn eret, nop, ARM64_UNMAP_KERNEL_AT_EL0 +alternative_if_not ARM64_UNMAP_KERNEL_AT_EL0 + ldr lr, [sp, #S_LR] + add sp, sp, #S_FRAME_SIZE // restore sp + eret +alternative_else_nop_endif #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 bne 4f - msr far_el1, x30 + msr far_el1, x29 tramp_alias x30, tramp_exit_native br x30 4: @@ -259,6 +261,8 @@ alternative_insn eret, nop, ARM64_UNMAP_KERNEL_AT_EL0 br x30 #endif .else + ldr lr, [sp, #S_LR] + add sp, sp, #S_FRAME_SIZE // restore sp eret .endif .endm @@ -947,10 +951,12 @@ __ni_sys_trace: .macro tramp_exit, regsize = 64 adr x30, tramp_vectors msr vbar_el1, x30 - tramp_unmap_kernel x30 + ldr lr, [sp, #S_LR] + tramp_unmap_kernel x29 .if \regsize == 64 - mrs x30, far_el1 + mrs x29, far_el1 .endif + add sp, sp, #S_FRAME_SIZE // restore sp eret .endm -- 2.30.2