Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4597200rwl; Mon, 3 Apr 2023 07:11:46 -0700 (PDT) X-Google-Smtp-Source: AK7set8MzZJOkSdGw8UA/ZyyWYEc8B3KBfKce6RoVpaHjkDRO3if0wYtH1qyMS0YZoKhcmuSqVyC X-Received: by 2002:a05:6a20:47e2:b0:da:adbf:7b96 with SMTP id ey34-20020a056a2047e200b000daadbf7b96mr29546383pzb.21.1680531106329; Mon, 03 Apr 2023 07:11:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680531106; cv=none; d=google.com; s=arc-20160816; b=ROCxIryogL1Mfajyv5nSK+X/LU8AbChkEkeBMzUW3NiJ80G44uKOP7JhSCYxOH3SeS 3Qs7ePAUw62WA5AkunucwMtdvC741KqTywAomJDYuRIHNdaepsdIJKanAhCfrBDFSqbD Sy2foAIZ3b0NsIUA0sJzriCSfpaNCHQhXd6wNu0/eWwvz6/MIJh/LT16Ud1y14r4jbxR M23j29HzEOxGitjHiu23oGpcB5lpnM3YBTzsbTbcnN2m6rb7P5uHlAqqycUqqkjvkMPu polGAsFobcgTQWBlwnrg+A4ydGou7Y1avGt2cdoh3ADERvJPf3efEbmcbjt5tYf3wGTR hv4A== 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 :dkim-signature; bh=vhwgcDtAklxhqM6EYQPuvUq6965STEsFa04g+nFznic=; b=m0UnKZbRuaQkeUsYILonpsjH5RGzxXbjbIvP1tq4c0+uhPe7IcPioLoc4jjJoZffFx 42cpLFHBkCp21Q13sfUMulkBRIQbMSSyEQcQv9Rl6MyXr1ROUnr0b0fJzybmAS9ajuIj Bei706+WD955oXs99unlc+7PyV2T6+6w37+jnKOG9i1bUPRWkX49jV6tTUoPF2xw35/H m4LEs0UmJcZu4VzHnHJgUBHJME+ec/2rc2Ih7E0JQhFOcOLc6TgIUsoxQGto0IHUhPgT 9EKg0Q8yeRfnVT+QYT9AoMiT7Hdtd9eIr4C2yYRyRYLZCvIb4cAx90BeWphBDLTfifmO iEnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Hel87nL2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y12-20020aa79aec000000b005a7ea9c6d7csi8453076pfp.41.2023.04.03.07.11.27; Mon, 03 Apr 2023 07:11:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Hel87nL2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232788AbjDCOFV (ORCPT + 99 others); Mon, 3 Apr 2023 10:05:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232792AbjDCOFQ (ORCPT ); Mon, 3 Apr 2023 10:05:16 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1440E2B0E0; Mon, 3 Apr 2023 07:05:04 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id qe8-20020a17090b4f8800b0023f07253a2cso30627976pjb.3; Mon, 03 Apr 2023 07:05:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680530703; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vhwgcDtAklxhqM6EYQPuvUq6965STEsFa04g+nFznic=; b=Hel87nL2p8AdJk1YAXlMZNr6u+Kyo+BZ3Q4c7lJ4uY9DgXLnyJhjYijHU8kvz4xTAl lvAe0p7Mmzkp4d4j5eq4FfqeqenxwXTf6z2NGqxgESMZHL/fL2y+xbXQGxCHVFA9xo4h V0Snthjpt0jP4POzvJlQ4FNwbaDHXHQcZR6w0dcT8iFP11VdsmMpwqnY/5CjCblOgYmu cAC62agxmrtJ16rqlfD12Hb0rMFxVy18UwEQriL3uiNa6qhISCkNJZy5my1Ebae43KOD 0hIvN8ny4TGjXoVj8JkjLtzY26lPcfLSwNQhYG1jC8J406wFY/zqTiEvJBNKfGIrgaVV quzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680530703; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vhwgcDtAklxhqM6EYQPuvUq6965STEsFa04g+nFznic=; b=LtmD4KceTCw/C1xurdFi2y1p3hTi6KkuUYzmKk3mgN6pnT9hLZjbuFcRpw7pFRx6lG 2A25YzHcC+oYDxtfwYuPhPFjCyN+/OyXcevam3hDNhl4RZxdDQdzu0IKFlI5Gb/zFwRO 5dL+Uc10/jxuVlSeqGpPZjocHWr+LBCgBmjkKQ2K0ms7CyIT8X0p6KjfJcTad+18EAYq xQHHP80J4SEgL3KO2YPGHUSHBdes288DqFngt9VsM9SCwo9Yya9uONMCJJNLv3H2NS/n S3cxwGpdc7OaI/JWSdJ531yHf078O3goeyi6962EnI+/td9R17tcFH41EU+XZEI+eU92 2i+A== X-Gm-Message-State: AAQBX9cjGZkCU/DNKRzjm5ht1uY20c3Gk7P9/J/Lhf3PKjGDB/9L5X/m EPZ3798o8lVRIfQ6MtfByhIPVBmF+Vs= X-Received: by 2002:a17:902:d4c6:b0:1a1:cc5a:b07 with SMTP id o6-20020a170902d4c600b001a1cc5a0b07mr45012190plg.37.1680530702603; Mon, 03 Apr 2023 07:05:02 -0700 (PDT) Received: from localhost ([47.89.225.180]) by smtp.gmail.com with ESMTPSA id b19-20020a170902d89300b001a072be70desm6696500plz.41.2023.04.03.07.05.01 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Apr 2023 07:05:02 -0700 (PDT) From: Lai Jiangshan To: linux-kernel@vger.kernel.org Cc: Lai Jiangshan , "H. Peter Anvin" , Andi Kleen , Andrew Cooper , Andy Lutomirski , Asit Mallick , Cfir Cohen , Dan Williams , Dave Hansen , David Kaplan , David Rientjes , Dirk Hohndel , Erdem Aktas , Jan Kiszka , Jiri Slaby , Joerg Roedel , Juergen Gross , Kees Cook , Kirill Shutemov , Kuppuswamy Sathyanarayanan , Linus Torvalds , Mike Stunes , Peter Zijlstra , Raj Ashok , Sean Christopherson , Thomas Gleixner , Tom Lendacky , Tony Luck , kvm@vger.kernel.org, linux-coco@lists.linux.dev, x86@kernel.org, Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" Subject: [RFC PATCH 1/7] x86/entry: Move PUSH_AND_CLEAR_REGS out of paranoid_entry Date: Mon, 3 Apr 2023 22:05:59 +0800 Message-Id: <20230403140605.540512-2-jiangshanlai@gmail.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20230403140605.540512-1-jiangshanlai@gmail.com> References: <20230403140605.540512-1-jiangshanlai@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 From: Lai Jiangshan Prepare to call paranoid_entry() with pt_regs pushed. Signed-off-by: Lai Jiangshan --- arch/x86/entry/entry_64.S | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S index eccc3431e515..49ddc4dd3117 100644 --- a/arch/x86/entry/entry_64.S +++ b/arch/x86/entry/entry_64.S @@ -475,11 +475,13 @@ SYM_CODE_START(\asmsym) testb $3, CS-ORIG_RAX(%rsp) jnz .Lfrom_usermode_switch_stack_\@ + PUSH_AND_CLEAR_REGS + UNWIND_HINT_REGS + ENCODE_FRAME_POINTER + /* paranoid_entry returns GS information for paranoid_exit in EBX. */ call paranoid_entry - UNWIND_HINT_REGS - movq %rsp, %rdi /* pt_regs pointer */ call \cfunc @@ -530,14 +532,16 @@ SYM_CODE_START(\asmsym) testb $3, CS-ORIG_RAX(%rsp) jnz .Lfrom_usermode_switch_stack_\@ + PUSH_AND_CLEAR_REGS + UNWIND_HINT_REGS + ENCODE_FRAME_POINTER + /* * paranoid_entry returns SWAPGS flag for paranoid_exit in EBX. * EBX == 0 -> SWAPGS, EBX == 1 -> no SWAPGS */ call paranoid_entry - UNWIND_HINT_REGS - /* * Switch off the IST stack to make it free for nested exceptions. The * vc_switch_off_ist() function will switch back to the interrupted @@ -587,9 +591,12 @@ SYM_CODE_START(\asmsym) ASM_CLAC cld + PUSH_AND_CLEAR_REGS + UNWIND_HINT_REGS + ENCODE_FRAME_POINTER + /* paranoid_entry returns GS information for paranoid_exit in EBX. */ call paranoid_entry - UNWIND_HINT_REGS movq %rsp, %rdi /* pt_regs pointer into first argument */ movq ORIG_RAX(%rsp), %rsi /* get error code into 2nd argument*/ @@ -903,8 +910,8 @@ SYM_CODE_END(xen_failsafe_callback) #endif /* CONFIG_XEN_PV */ /* - * Save all registers in pt_regs. Return GSBASE related information - * in EBX depending on the availability of the FSGSBASE instructions: + * Return GSBASE related information in EBX depending on the availability + * of the FSGSBASE instructions: * * FSGSBASE R/EBX * N 0 -> SWAPGS on exit @@ -915,11 +922,8 @@ SYM_CODE_END(xen_failsafe_callback) * R14 - old CR3 * R15 - old SPEC_CTRL */ -SYM_CODE_START(paranoid_entry) +SYM_FUNC_START(paranoid_entry) ANNOTATE_NOENDBR - UNWIND_HINT_FUNC - PUSH_AND_CLEAR_REGS save_ret=1 - ENCODE_FRAME_POINTER 8 /* * Always stash CR3 in %r14. This value will be restored, @@ -988,7 +992,7 @@ SYM_CODE_START(paranoid_entry) UNTRAIN_RET_FROM_CALL RET -SYM_CODE_END(paranoid_entry) +SYM_FUNC_END(paranoid_entry) /* * "Paranoid" exit path from exception stack. This is invoked @@ -1443,6 +1447,10 @@ end_repeat_nmi: */ pushq $-1 /* ORIG_RAX: no syscall to restart */ + PUSH_AND_CLEAR_REGS + UNWIND_HINT_REGS + ENCODE_FRAME_POINTER + /* * Use paranoid_entry to handle SWAPGS, but no need to use paranoid_exit * as we should not be calling schedule in NMI context. @@ -1451,7 +1459,6 @@ end_repeat_nmi: * exceptions might do. */ call paranoid_entry - UNWIND_HINT_REGS movq %rsp, %rdi movq $-1, %rsi -- 2.19.1.6.gb485710b