Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1228109ybp; Fri, 4 Oct 2019 11:21:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqxB2P4zbFq/W0Ey/ur4VSCfHN6siFuhvqEk8e7uvsraHd5+Mt2psKdoPhzjvM/78oJD3/Xu X-Received: by 2002:a17:906:95cf:: with SMTP id n15mr13669410ejy.183.1570213295305; Fri, 04 Oct 2019 11:21:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570213295; cv=none; d=google.com; s=arc-20160816; b=B3XOvoF9cJWOS+MP9If+rwmA9ZwZMlVMT2N+lKnbYauDZCUBtJRI0QVOA4tjbkqWVl DsfBzl8SRP1m/6unLbnZ1m76pMUoImVxP5hQBaDrSBorMrd3KJ7PDHjGnKFrczDSR1Ta Fb6vtoJIgXEhbz/BgfT8eIpNg0/L0+FdWaLjG3kjgeWN/NIIG85Up6N0n/XaufXRi5vD SKmxfKYFIBJYV4WF3ZTVi2UjqFzzNsZTGa/mbJ2xxjG/kE9hmxWsylLVIj6ClCA1PaFP +FnNQYh74lOqhSCfdBgxJsxBqUToe2woao3ZdmfOQ5slZw+U+lxtUIkW3ziirOiFiYcS KxUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=pYUN+9C4qftyzCAWO3dEZNyx8jsAHBV2x1IGPL2Yl70=; b=k0TppwrkLAs43sS1dWvTzJ5R8Fn9un38cmqNnHFo9CIOUl4kEJgvVgqKo4w2ubGvbc zvP/PnCKQVEeBLzp71bKiX09nbGkkY8MRrpoJmhTi2xaILVt8evL2B3/+ozc/rDHpSWY qpIy9XMXHmF+q04kydSWHL40LTJY79E8ezjbN0DkpfYS73pGkRaZyqhHL5MCRZ0EnSvD KXZbDysDtprQ3wkS1Ho95LSRXoHp1509Pad6W5bSSH9Ky4t/YjEBWsMTamvpB24ysZTT fi7DRAIDBq88yYoU6E5kEe+sW63kaEQoEXi/vEgtMLGES4fx/GY/Cl4wAGEO25JeDM+u azNQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id rn2si3284845ejb.14.2019.10.04.11.21.11; Fri, 04 Oct 2019 11:21:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388688AbfJDSRJ (ORCPT + 99 others); Fri, 4 Oct 2019 14:17:09 -0400 Received: from mga07.intel.com ([134.134.136.100]:15508 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730555AbfJDSRD (ORCPT ); Fri, 4 Oct 2019 14:17:03 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Oct 2019 11:17:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,257,1566889200"; d="scan'208";a="204394783" Received: from chang-linux-3.sc.intel.com ([172.25.66.185]) by orsmga002.jf.intel.com with ESMTP; 04 Oct 2019 11:17:02 -0700 From: "Chang S. Bae" 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 Subject: [PATCH v9 08/17] x86/entry/64: Document GSBASE handling in the paranoid path Date: Fri, 4 Oct 2019 11:16:00 -0700 Message-Id: <1570212969-21888-9-git-send-email-chang.seok.bae@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1570212969-21888-1-git-send-email-chang.seok.bae@intel.com> References: <1570212969-21888-1-git-send-email-chang.seok.bae@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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 --- Changes from v8: none Changes from v7: * Massaged doc and changelog by Thomas * Used 'GS base' consistently, instead of 'GSBASE' --- 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 a48b3f6..0499a40 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.7.4