Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp6011846ybc; Wed, 27 Nov 2019 13:22:03 -0800 (PST) X-Google-Smtp-Source: APXvYqyhEYvQQ52GDLJqhDp1K2ynjOAG7isNZf4yOMq9ulZMRBNstyV/LT5ung9ClQ0/xLUGJejr X-Received: by 2002:a17:906:6dc2:: with SMTP id j2mr50940515ejt.140.1574889723169; Wed, 27 Nov 2019 13:22:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574889723; cv=none; d=google.com; s=arc-20160816; b=t0K1qD/tMJMx41OLjx/0SLA7odVv7oMXsk/92BHx5i1wtq4P1pVY0QueRpDhwr9TNO CY8YMMYP19CA0p/tOtsHk8RtgIuY8SRgXbGoijdIqSDDXrmgrKQJCCaCmLdZgPRnS43d dd35i5Pj7F8/EXRkhKicOlmp1D8HUHFCbNEPllEg2Xz8SQi8MFzBAUrqde4fgTHZP7qu pq3c497Vva49y57JosK6+xHaCTj1mONo+Xa9Rp5rQMG5JEvdxqgKVZeQOuDiAZDZRmbo y9Vhz2E/63RqF4y5pCIjRKixWyQeMaOwh/3n/wfSQgWCRfRjWcSw2Msju4AFQNywx6VN fgUg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=IsJSZdXHdCsAGt+aOxs3wHtBDiGraXnaGh2A/ESWrII=; b=lo0ersRjd10IEq9GVXOXrvm8n+lHGnchR/TyVL+oyzskmTmXYSEQqmPFJlgKUZ7iyN ZMXPxzNuglpo0wuoCT2uoyofKcbhM9kxj1MFYADdxz4qYWd40ezuUZb4uwwI1YzV9ilP fearoDp4RNbexExBTs7/YJHrKfedvxs9+WjKI4ZcHa0B3nBIWgHOIZpkkfdM9bxHcSan fX1vXTnnaI7DNWrO+UZDykbH0WDeCMgpidU5JyUqDwoTn7vjAfDnMzFvgDgwICH8rOL6 8jSfXyxnvL/yEa8yC7aU1SxT1HmIH1WsntYNNe3y1gn4CY30vqzvWzxLEmKBwrcLHobG Rt/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LgSsqEpx; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b19si11751345edb.40.2019.11.27.13.21.40; Wed, 27 Nov 2019 13:22:03 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=LgSsqEpx; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733027AbfK0VKY (ORCPT + 99 others); Wed, 27 Nov 2019 16:10:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:37384 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733012AbfK0VKU (ORCPT ); Wed, 27 Nov 2019 16:10:20 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D01D321555; Wed, 27 Nov 2019 21:10:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574889019; bh=8dLYzmD6yVg83Y8rOOwXkUvVYdDu+qUDgfphnIUNfzc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LgSsqEpxPQ+Khjv3SYMFs6/+wko1IbuzsvhmchI1JegDK0vda+dfPHWSuGyonqrj6 flWByCJDKsgvm/E5cgGgNgRMU6207gEC4Pnl/jMPwDMQFTEgIjd3TAxQOFRVYifsFI aos5cWyNo4amyi9/y7Ro8Zpk0VDfkqsgFOuPaNhY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jan Beulich , Thomas Gleixner , Juergen Gross Subject: [PATCH 5.3 53/95] x86/xen/32: Simplify ring check in xen_iret_crit_fixup() Date: Wed, 27 Nov 2019 21:32:10 +0100 Message-Id: <20191127202919.224124606@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127202845.651587549@linuxfoundation.org> References: <20191127202845.651587549@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jan Beulich commit 922eea2ce5c799228d9ff1be9890e6873ce8fff6 upstream. This can be had with two instead of six insns, by just checking the high CS.RPL bit. Also adjust the comment - there would be no #GP in the mentioned cases, as there's no segment limit violation or alike. Instead there'd be #PF, but that one reports the target EIP of said branch, not the address of the branch insn itself. Signed-off-by: Jan Beulich Signed-off-by: Thomas Gleixner Reviewed-by: Juergen Gross Link: https://lkml.kernel.org/r/a5986837-01eb-7bf8-bf42-4d3084d6a1f5@suse.com Signed-off-by: Greg Kroah-Hartman --- arch/x86/xen/xen-asm_32.S | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) --- a/arch/x86/xen/xen-asm_32.S +++ b/arch/x86/xen/xen-asm_32.S @@ -153,22 +153,15 @@ hyper_iret: * it's still on stack), we need to restore its value here. */ ENTRY(xen_iret_crit_fixup) - pushl %ecx /* * Paranoia: Make sure we're really coming from kernel space. * One could imagine a case where userspace jumps into the * critical range address, but just before the CPU delivers a - * GP, it decides to deliver an interrupt instead. Unlikely? - * Definitely. Easy to avoid? Yes. The Intel documents - * explicitly say that the reported EIP for a bad jump is the - * jump instruction itself, not the destination, but some - * virtual environments get this wrong. + * PF, it decides to deliver an interrupt instead. Unlikely? + * Definitely. Easy to avoid? Yes. */ - movl 3*4(%esp), %ecx /* nested CS */ - andl $SEGMENT_RPL_MASK, %ecx - cmpl $USER_RPL, %ecx - popl %ecx - je 2f + testb $2, 2*4(%esp) /* nested CS */ + jnz 2f /* * If eip is before iret_restore_end then stack