From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752664AbbKQOkr (ORCPT ); Tue, 17 Nov 2015 09:40:47 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:29951 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750708AbbKQOkq (ORCPT ); Tue, 17 Nov 2015 09:40:46 -0500 Subject: Re: [PATCH] xen/x86: Adjust stack pointer in xen_sysexit To: "H. Peter Anvin" , Borislav Petkov , Andy Lutomirski References: <1447456706-24347-1-git-send-email-boris.ostrovsky@oracle.com> <56468D24.8030801@oracle.com> <564A0371.2040104@oracle.com> <20151116195906.GB20137@pd.tnic> <20151116202232.GC20137@pd.tnic> <564A50C3.1000200@zytor.com> Cc: "linux-kernel@vger.kernel.org" , xen-devel , David Vrabel , Konrad Rzeszutek Wilk From: Boris Ostrovsky Message-ID: <564B3C57.5000002@oracle.com> Date: Tue, 17 Nov 2015 09:40:23 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <564A50C3.1000200@zytor.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Source-IP: userv0021.oracle.com [156.151.31.71] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/16/2015 04:55 PM, H. Peter Anvin wrote: > On 11/16/15 12:22, Borislav Petkov wrote: >> Huh, so what's wrong with a jump: >> >> jmp 1f >> swapgs >> 1: >> > What is the point of that jump? > >>> If it would make you feel better, it could be X86_BUG_XENPV :-p >> That doesn't matter - I just don't want to open the flood gates on >> pseudo feature bits. >> >> hpa, what do you think? > Pseudo feature bits are fine, we already have plenty of them. They make > sense as they let us reuse a lot of infrastructure. So how about something like this? And then I think we can remove usergs_sysret32 and irq_enable_sysexit pv ops completely as noone will use them (lguest doesn't set them) diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S index 3eb572e..c43df7b 100644 --- a/arch/x86/entry/entry_32.S +++ b/arch/x86/entry/entry_32.S @@ -308,7 +308,8 @@ sysenter_past_esp: movl %esp, %eax call do_fast_syscall_32 - testl %eax, %eax + /* PV guests always use IRET path */ + ALTERNATIVE "testl %eax, %eax", "jmp .Lsyscall_32_done", X86_FEATURE_PV jz .Lsyscall_32_done /* Opportunistic SYSEXIT */ diff --git a/arch/x86/entry/entry_64_compat.S b/arch/x86/entry/entry_64_compat.S index c320183..2d1bc82 100644 --- a/arch/x86/entry/entry_64_compat.S +++ b/arch/x86/entry/entry_64_compat.S @@ -121,7 +121,7 @@ sysenter_flags_fixed: movq %rsp, %rdi call do_fast_syscall_32 - testl %eax, %eax + ALTERNATIVE "testl %eax, %eax", "jmp .Lsyscall_32_done", X86_FEATURE_PV jz .Lsyscall_32_done jmp sysret32_from_system_call @@ -200,7 +200,8 @@ ENTRY(entry_SYSCALL_compat) movq %rsp, %rdi call do_fast_syscall_32 - testl %eax, %eax + /* PV guests always use IRET path */ + ALTERNATIVE "testl %eax, %eax", "jmp .Lsyscall_32_done", X86_FEATURE_PV jz .Lsyscall_32_done /* Opportunistic SYSRET */ diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h index e4f8010..723327b 100644 --- a/arch/x86/include/asm/cpufeature.h +++ b/arch/x86/include/asm/cpufeature.h @@ -216,6 +216,7 @@ #define X86_FEATURE_PAUSEFILTER ( 8*32+13) /* AMD filtered pause intercept */ #define X86_FEATURE_PFTHRESHOLD ( 8*32+14) /* AMD pause filter threshold */ #define X86_FEATURE_VMMCALL ( 8*32+15) /* Prefer vmmcall to vmcall */ +#define X86_FEATURE_PV ( 8*32+16) /* Paravirtual guest */ /* Intel-defined CPU features, CPUID level 0x00000007:0 (ebx), word 9 */