Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp4073654pxb; Wed, 13 Oct 2021 20:15:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy3lmg8CDVgl5x1XNcxfTj6yT1qwfApTKn2dVxDBcWJztvUHpy9qrE70Q7hPa+HGosBUNQ+ X-Received: by 2002:a17:902:f551:b0:13e:fb56:f519 with SMTP id h17-20020a170902f55100b0013efb56f519mr2789454plf.0.1634181353915; Wed, 13 Oct 2021 20:15:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634181353; cv=none; d=google.com; s=arc-20160816; b=ru2Wfgub2bLGypHODdD/NddWPDVRA1e6ijW8xLr1N8M3suOLgp5kHMt256qEj2A0zT ZR07Riga7EJyF1YEGWFRFrktG/NGZYu9rJ1/7WyWV1a+6kTQehQhnr/YnIXMrqkuE4W0 OYnn0my1I6NSrkI2jHemhLUWXg1XJty2UIBpd8wcalaMwIQI3AA+c3W8yqxX+1NGZfAL GKKdVVmou3mKj2XwD/oXx9dxv753+7jPVNnw562H10V6ykG1t02lmaUrClLG62Amuigo 0krkMOSnq11XRMsE3hmK6iTQWwFhQItgnglFBQJQ6UxWCLhBGaXhxIKB32rMTY1XUx9v 19kg== 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=vnLo8nRGURPjjod70p5B9U+vosN1RZ1Olin9TSfC/G0=; b=TtJaqUcl3mnElC7yA37Cdc9Qt1w2gsamS+phoVo7KXM6E2sMHmc5ZmIriEO1foJ0pf sMGpfTYItOOCS6YvrD6Nypz72kPjRNk/WOiRewwvyGT28agoANipFAJQzdgcEO3fC43C t7hZ+A0mFNQnfcfeXe51Ls6UFkTuOa5+/b+7EVVEqYVU5o2gxcvTrtAFhqPZAfk9HKBK khc3bAt6WB3x7T/VzgPjI0A1mN21Rh9r73QItNrAsMzEcuHImI7VRXcKHGxz01TTqb5D 7v1sA7jse6CuyZUzO/GRoC71a5MHvp+C7QJvIkzqB/bBOrGLe3z9csEJDb1Wl5Pwzjvh RYQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=U0QWpWFj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f31si2087503pgf.371.2021.10.13.20.15.41; Wed, 13 Oct 2021 20:15:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=U0QWpWFj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S229930AbhJNDQn (ORCPT + 99 others); Wed, 13 Oct 2021 23:16:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229846AbhJNDQk (ORCPT ); Wed, 13 Oct 2021 23:16:40 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A2FBC061570 for ; Wed, 13 Oct 2021 20:14:36 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id t11so3167496plq.11 for ; Wed, 13 Oct 2021 20:14:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vnLo8nRGURPjjod70p5B9U+vosN1RZ1Olin9TSfC/G0=; b=U0QWpWFj/fgRzufewZ1UMTcbZkyOUOQ10JKjlqi9fC4tnRVwtSeZLHL+0kaXegdZ7P 2Se6blAc/29VYJgXSAoTC4T+xWS70WTImPbXrklHvUcA/dJgMEt4Sx7vth5X+895zrcS GydQYAjWG0bhO7cWc8ur6c8HN8UFs8ZGY1CfS1iwzDVrAm30zL7nMyqZtMCD7c+8gIde HPt3/Q492CTBBWEy94Z555tIz7de72/TmWSDOgpkXKGUNw9y0aAZy4MpRR3dqMnbnW+W YIulCltgh90pmeVDZLdnkScteLjUUn6QM3+xaadCly5dqgfCGPL1G+Yi8Z8A8dZoCBJe K3sA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vnLo8nRGURPjjod70p5B9U+vosN1RZ1Olin9TSfC/G0=; b=pvRXJSOiBX/dlH7CQ1dx5SUI50zqzNrGtj1zpTOc1tB3lpSx91uL4UFSM8Xcg4Gbu9 BQja+UVwFAFY7M+68VYFKU+fdPm8qv44kkaDaCjY8XYL3PwnmhtI5YWhZZj98U7u3oS/ C5fle9g/V5B0XptbrS2ippFMwvQK/QsDXp/WU6hmLiPKYOHtuYsdbQcbu8+5nwEMecad dezrMCekp/qejbN9uBGfiURdtyB+ygeF8HoxwiYgQ1a5ECFzDZ+7cNaPDRllL4+c7tQl /OAk3xOHKPI04dV9+9NXHCmj+Rj7/YLr0lClptvVUMXG8++NdCrFtJTp/Aa2akGB6HhC CNUw== X-Gm-Message-State: AOAM530eNcU3nQPi9JUz6p1BXOgIYakO9NTDMN1r/W+1ygkwlnJB5sSx qHLHNNh7OxYMXHe/0JMgy3qmPgbUuck= X-Received: by 2002:a17:90a:c58e:: with SMTP id l14mr18095996pjt.213.1634181275667; Wed, 13 Oct 2021 20:14:35 -0700 (PDT) Received: from localhost ([198.11.178.15]) by smtp.gmail.com with ESMTPSA id c192sm789099pfb.110.2021.10.13.20.14.34 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Oct 2021 20:14:35 -0700 (PDT) From: Lai Jiangshan To: linux-kernel@vger.kernel.org Cc: x86@kernel.org, Lai Jiangshan , Josh Poimboeuf , "Chang S . Bae" , Sasha Levin , Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" Subject: [PATCH V3 01/49] x86/entry: Add fence for kernel entry swapgs in paranoid_entry() Date: Thu, 14 Oct 2021 11:13:24 +0800 Message-Id: <20211014031413.14471-2-jiangshanlai@gmail.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20211014031413.14471-1-jiangshanlai@gmail.com> References: <20211014031413.14471-1-jiangshanlai@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lai Jiangshan Commit 18ec54fdd6d18 ("x86/speculation: Prepare entry code for Spectre v1 swapgs mitigations") adds FENCE_SWAPGS_{KERNEL|USER}_ENTRY for conditional swapgs. And in paranoid_entry(), it uses only FENCE_SWAPGS_KERNEL_ENTRY for both branches. It is because the fence is required for both cases since the CR3 write is conditinal even PTI is enabled. But commit 96b2371413e8f ("x86/entry/64: Switch CR3 before SWAPGS in paranoid entry") switches the code order and changes the branches. And it misses the needed FENCE_SWAPGS_KERNEL_ENTRY for user gsbase case. Add it back. Fixes: Commit 96b2371413e8f ("x86/entry/64: Switch CR3 before SWAPGS in paranoid entry") Cc: Josh Poimboeuf Cc: Chang S. Bae Cc: Sasha Levin Signed-off-by: Lai Jiangshan --- arch/x86/entry/entry_64.S | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S index e38a4cf795d9..1f98188e83ef 100644 --- a/arch/x86/entry/entry_64.S +++ b/arch/x86/entry/entry_64.S @@ -898,6 +898,7 @@ SYM_CODE_START_LOCAL(paranoid_entry) rdmsr testl %edx, %edx jns .Lparanoid_entry_swapgs + FENCE_SWAPGS_KERNEL_ENTRY ret .Lparanoid_entry_swapgs: -- 2.19.1.6.gb485710b