Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp405637ybt; Wed, 1 Jul 2020 01:08:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwGoDpwQCYCA88Lv8ZiESzMlilN18kOLMNRljYqOk39OcRYnfgfaAqrh2lcaorxHfcv1lJB X-Received: by 2002:a17:906:648f:: with SMTP id e15mr21168325ejm.99.1593590908535; Wed, 01 Jul 2020 01:08:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593590908; cv=none; d=google.com; s=arc-20160816; b=W7V5uad8SvWfKkNuN6xBTRnZb/cC5Y++rzsR9KBymotwKC/4SboXm+D38ljBKwD2R+ 9RkWEjYhBlhA059C9cOXmzLqh/c2T1bRfvwWCUsuJEkNKjc0bDMYV/6TjtriDp5qsC3h rbDKSMKQmZFUuMWsdoEHDib4ebcn/DtFUNGZmoe1XdAyR8KNUEl4fDNGA3kxdKCB07Yk FksoPPLqX6rjhYiZPJiMWzzsXSsVxgOwE8t2TjxjclTM8TpNACMKbjKnSnEN8X2N/q7o HgJesO4W7ySVTTWGuAfuKHmCWbAWpPDlIMliozhZefNENzzSuLPBzkUWftV5gFyS9ZIJ +z5A== 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 :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:dkim-signature :dkim-signature:date; bh=dI8s4+cIJXIr3ppZrNkXAQDHLyAZwlVAKlfgSA65wnI=; b=iWFHPSw77v6NX6hZ/DKKTnKFpZW2DeI77FmSqILUgUgd1YrjApc8zSMO3IMLHSEBGE LJqqAh9YCQRibLXaRO/5bXH9VtnhsRM0dSSajqXyh1AOeMX3dd3+xYGwgpeYXOLd65kp xs2TdOE4QMSRE2PKQoaUXvf7Jmhn2vPM+AwYfp+sRQIHK6CyNCbtDS6NKYD52Mq5oY1h PUPMaJvHzXBL7AaFcQkVjVGh+GvOrJmP2a3vgOh5Yr1FtYTYyM07O/uPte1lFeHYiUhv c9/qiPyjB4uu6KtHWuyz+q21TMH+qr1xFDV5E9aX0q/NNXtnwoRHgP76o/D+zM6CQ2fy LElg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linutronix.de header.s=2020 header.b=DY25a8mn; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=Moaa4emO; 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o11si3311664ejr.391.2020.07.01.01.08.05; Wed, 01 Jul 2020 01:08:28 -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=fail header.i=@linutronix.de header.s=2020 header.b=DY25a8mn; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=Moaa4emO; 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728752AbgGAIFT (ORCPT + 99 others); Wed, 1 Jul 2020 04:05:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728559AbgGAIEy (ORCPT ); Wed, 1 Jul 2020 04:04:54 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D46D5C061755; Wed, 1 Jul 2020 01:04:53 -0700 (PDT) Date: Wed, 01 Jul 2020 08:04:51 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1593590692; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dI8s4+cIJXIr3ppZrNkXAQDHLyAZwlVAKlfgSA65wnI=; b=DY25a8mn0Pg5hMJvjsu2zJz6qOoeYO7zHf0D57EhYxOWg7/7dScMHQTMr/040/M1P3FrL5 AyJ7BYearhVtOI7Cmb5elDKe2PnQyAyysqnpYkmnM3FLjig7jo1iI2HPXuZZ8h7pvH3mzJ Z+WspR5NZ2sxOnZX5+2FwByQbQce3qlxGwPiJH+IYA1iPDx84XhitUOra7/BuOemCoLR8D hoSgnN6c8Dumyb4ZovyB7C7wBAa1MFfyCw7c/Cqq6cV/VRV3iJEQ7JS28Ig56vQrT/CRd9 AdAGTNDGYuf+z4ix1Cog1kavECKv9J1qqJ1QFVERto6XbaNV4EYCuLc3PTsbmg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1593590692; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dI8s4+cIJXIr3ppZrNkXAQDHLyAZwlVAKlfgSA65wnI=; b=Moaa4emOtmLyMHEYslHaop0GLGJIOEhMSuwCVRLvQHlBDYP1diR7p/RPPicqnP3RfqPYfe Rlvie/SECazeHIDA== From: "tip-bot2 for Andy Lutomirski" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/urgent] x86/entry/64/compat: Fix Xen PV SYSENTER frame setup Cc: Andy Lutomirski , Thomas Gleixner , Boris Ostrovsky , x86 , LKML In-Reply-To: <947880c41ade688ff4836f665d0c9fcaa9bd1201.1593191971.git.luto@kernel.org> References: <947880c41ade688ff4836f665d0c9fcaa9bd1201.1593191971.git.luto@kernel.org> MIME-Version: 1.0 Message-ID: <159359069165.4006.16569596642784099904.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/urgent branch of tip: Commit-ID: ffae641f57476369b4d503402b37ebe489d23395 Gitweb: https://git.kernel.org/tip/ffae641f57476369b4d503402b37ebe489d23395 Author: Andy Lutomirski AuthorDate: Fri, 26 Jun 2020 10:21:13 -07:00 Committer: Thomas Gleixner CommitterDate: Wed, 01 Jul 2020 10:00:26 +02:00 x86/entry/64/compat: Fix Xen PV SYSENTER frame setup The SYSENTER frame setup was nonsense. It worked by accident because the normal code into which the Xen asm jumped (entry_SYSENTER_32/compat) threw away SP without touching the stack. entry_SYSENTER_compat was recently modified such that it relied on having a valid stack pointer, so now the Xen asm needs to invoke it with a valid stack. Fix it up like SYSCALL: use the Xen-provided frame and skip the bare metal prologue. Fixes: 1c3e5d3f60e2 ("x86/entry: Make entry_64_compat.S objtool clean") Signed-off-by: Andy Lutomirski Signed-off-by: Thomas Gleixner Reviewed-by: Boris Ostrovsky Link: https://lkml.kernel.org/r/947880c41ade688ff4836f665d0c9fcaa9bd1201.1593191971.git.luto@kernel.org --- arch/x86/entry/entry_64_compat.S | 1 + arch/x86/xen/xen-asm_64.S | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/arch/x86/entry/entry_64_compat.S b/arch/x86/entry/entry_64_compat.S index 7b9d815..381a6de 100644 --- a/arch/x86/entry/entry_64_compat.S +++ b/arch/x86/entry/entry_64_compat.S @@ -79,6 +79,7 @@ SYM_CODE_START(entry_SYSENTER_compat) pushfq /* pt_regs->flags (except IF = 0) */ pushq $__USER32_CS /* pt_regs->cs */ pushq $0 /* pt_regs->ip = 0 (placeholder) */ +SYM_INNER_LABEL(entry_SYSENTER_compat_after_hwframe, SYM_L_GLOBAL) pushq %rax /* pt_regs->orig_ax */ pushq %rdi /* pt_regs->di */ pushq %rsi /* pt_regs->si */ diff --git a/arch/x86/xen/xen-asm_64.S b/arch/x86/xen/xen-asm_64.S index 5d252aa..e1e1c7e 100644 --- a/arch/x86/xen/xen-asm_64.S +++ b/arch/x86/xen/xen-asm_64.S @@ -161,10 +161,22 @@ SYM_FUNC_END(xen_syscall32_target) /* 32-bit compat sysenter target */ SYM_FUNC_START(xen_sysenter_target) - mov 0*8(%rsp), %rcx - mov 1*8(%rsp), %r11 - mov 5*8(%rsp), %rsp - jmp entry_SYSENTER_compat + /* + * NB: Xen is polite and clears TF from EFLAGS for us. This means + * that we don't need to guard against single step exceptions here. + */ + popq %rcx + popq %r11 + + /* + * Neither Xen nor the kernel really knows what the old SS and + * CS were. The kernel expects __USER32_DS and __USER32_CS, so + * report those values even though Xen will guess its own values. + */ + movq $__USER32_DS, 4*8(%rsp) + movq $__USER32_CS, 1*8(%rsp) + + jmp entry_SYSENTER_compat_after_hwframe SYM_FUNC_END(xen_sysenter_target) #else /* !CONFIG_IA32_EMULATION */