Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp549411ybk; Sat, 9 May 2020 10:39:06 -0700 (PDT) X-Google-Smtp-Source: APiQypIpONxyUhRZINa8ucVZE/l6uuXiMlgUr1G+6WMyXLGslEzJnTV5Jb7u4K7fViim6H3iML5M X-Received: by 2002:a50:a7e3:: with SMTP id i90mr3582970edc.6.1589045945875; Sat, 09 May 2020 10:39:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589045945; cv=none; d=google.com; s=arc-20160816; b=WghL7SY+WnOkDoZaogqf9bwzbsA4whPkCQpRCNzqCA+DZSGA4NrejVSundc8fmy1Zz CpH1YBJpNUl4IwwKnj08wN5ZK817tDDBNYhMpeFWcZn6vP6NJSQk3g89eFKA/wj7+WXa RnM4AMzrlkq8eUzRGc73Y+cLEvnl/1tIAMD3zaFMPR9xu5kjss/YOGs9IaWzhrjzf42P jM14V96FDTWSiOdDYyDFjAA9if0Hyu48xbBDmIhVybFwXQN7leHoCnFzGjOlHL/In3gN aViuqEhVPJCP8UOG9SqnMMqq467aF9MCctIsO4PSdQUdBCRJSU2BBnLrIy5RPAVMCzyq NSXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IYzAshfb4mKBIceD12h0YkSzQJ3BaisLrTWlFivAkhQ=; b=Imbvs5Snb7sLNUUp9OUG1AINOWjNFZ6TjVn7c5F3I39zXqsQa/4k0+GA1Dz6cKb861 iREAtM/16AdCY/9/iaiS3tbz78Bd7GPATE34LcqmSnHGyUJ4WIj73iWf7cPORc1aQB/K jm0NUeWBG2P9JqQFCzYDN84cc1HCUiRoiEN21dDacXf8m5w52tz3WiO+APcekjWo8jYO KqWW8S4rh211/Dk7eZ7xKF1PDPYc4k1veU8uacIksqPiR+uRPwRAElSFUwvQGefg3Gzh OCof+Fzfu6DHjKCnJxstz9d5R5nvHJ0iF/Jvlx222+kWdbCpEtR3WtvazjSOxLxTi1n6 mrVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=g1cx+zlg; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dp5si2749022ejc.344.2020.05.09.10.38.43; Sat, 09 May 2020 10:39:05 -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=@kernel.org header.s=default header.b=g1cx+zlg; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728564AbgEIRhO (ORCPT + 99 others); Sat, 9 May 2020 13:37:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:54504 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728502AbgEIRhL (ORCPT ); Sat, 9 May 2020 13:37:11 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1CC4F24954; Sat, 9 May 2020 17:37:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589045831; bh=lCmbhHyFSvR8ipmtonVqDpN7IU+xGXfjR90A+02sw4I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g1cx+zlgzqCAoS2+B/jPtyuBasegbXTU8iLEoAPOsLYZN5Qjcc77QQrslzV1HvQpo S3BW2EIWVIgJ6L/GLbaEAIVipfzEJUPcKHO0Uego798438br7Y3A01BCRAr+8gX3Ys /MvEYxyp7qaFMn0/DrBpzDaGVk7yDR18CXdXf5v0= From: Sasha Levin To: linux-kernel@vger.kernel.org, tglx@linutronix.de, bp@alien8.de, luto@kernel.org Cc: hpa@zytor.com, dave.hansen@intel.com, tony.luck@intel.com, ak@linux.intel.com, ravi.v.shankar@intel.com, chang.seok.bae@intel.com, Sasha Levin Subject: [PATCH v11 08/18] x86/entry/64: Document GSBASE handling in the paranoid path Date: Sat, 9 May 2020 13:36:45 -0400 Message-Id: <20200509173655.13977-9-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200509173655.13977-1-sashal@kernel.org> References: <20200509173655.13977-1-sashal@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Chang S. Bae" On FSGSBASE systems, the way to handle GS base in the paranoid path is different from the existing SWAPGS-based entry/exit path handling. Document the reason and what has to be done for FSGSBASE enabled systems. Signed-off-by: Chang S. Bae Signed-off-by: Sasha Levin Reviewed-by: Tony Luck Cc: Thomas Gleixner Cc: Borislav Petkov Cc: Andy Lutomirski Cc: H. Peter Anvin Cc: Dave Hansen Cc: Tony Luck Cc: Andi Kleen --- Documentation/x86/entry_64.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Documentation/x86/entry_64.rst b/Documentation/x86/entry_64.rst index a48b3f6ebbe87..0499a40723af3 100644 --- a/Documentation/x86/entry_64.rst +++ b/Documentation/x86/entry_64.rst @@ -108,3 +108,12 @@ We try to only use IST entries and the paranoid entry code for vectors that absolutely need the more expensive check for the GS base - and we generate all 'normal' entry points with the regular (faster) paranoid=0 variant. + +On FSGSBASE systems, however, user space can set GS without kernel +interaction. It means the value of GS base itself does not imply anything, +whether a kernel value or a user space value. So, there is no longer a safe +way to check whether the exception is entering from user mode or kernel +mode in the paranoid entry code path. So the GS base value needs to be read +out, saved and the kernel GS base value written. On exit, the saved GS base +value needs to be restored unconditionally. The non-paranoid entry/exit +code still uses SWAPGS unconditionally as the state is known. -- 2.20.1