From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753373AbdK0TWd (ORCPT ); Mon, 27 Nov 2017 14:22:33 -0500 Received: from mx2.suse.de ([195.135.220.15]:52767 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752874AbdK0TWc (ORCPT ); Mon, 27 Nov 2017 14:22:32 -0500 Subject: Re: [PATCH] x86/entry/64/paravirt: Use paravirt-safe macro to access eflags To: Boris Ostrovsky , linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org Cc: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, luto@kernel.org References: <1511805918-8041-1-git-send-email-boris.ostrovsky@oracle.com> From: Juergen Gross Message-ID: Date: Mon, 27 Nov 2017 20:22:28 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <1511805918-8041-1-git-send-email-boris.ostrovsky@oracle.com> Content-Type: text/plain; charset=utf-8 Content-Language: de-DE Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 27/11/17 19:05, Boris Ostrovsky wrote: > Commit 1d3e53e8624a ("x86/entry/64: Refactor IRQ stacks and make > them NMI-safe") added DEBUG_ENTRY_ASSERT_IRQS_OFF macro that acceses > eflags using 'pushfq' instruction when testing for IF bit. On PV Xen > guests looking at IF flag directly will always see it set, resulting > in 'ud2'. > > Introduce SAVE_FLAGS() macro that will use appropriate save_fl pv op > when running paravirt. > > Signed-off-by: Boris Ostrovsky > --- > arch/x86/entry/entry_64.S | 5 ++--- > arch/x86/include/asm/irqflags.h | 3 +++ > arch/x86/include/asm/paravirt.h | 9 +++++++++ > arch/x86/kernel/asm-offsets_64.c | 3 +++ > 4 files changed, 17 insertions(+), 3 deletions(-) > > diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S > index f81d50d..4bb7719 100644 > --- a/arch/x86/entry/entry_64.S > +++ b/arch/x86/entry/entry_64.S > @@ -466,12 +466,11 @@ END(irq_entries_start) > > .macro DEBUG_ENTRY_ASSERT_IRQS_OFF > #ifdef CONFIG_DEBUG_ENTRY > - pushfq > - testl $X86_EFLAGS_IF, (%rsp) > + SAVE_FLAGS(CLBR_ANY) > + testl $X86_EFLAGS_IF, %eax Are you sure %eax is allowed to be modified? > jz .Lokay_\@ > ud2 > .Lokay_\@: > - addq $8, %rsp > #endif > .endm > > diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h > index c8ef23f..7f65f3f 100644 > --- a/arch/x86/include/asm/irqflags.h > +++ b/arch/x86/include/asm/irqflags.h > @@ -142,6 +142,9 @@ static inline notrace unsigned long arch_local_irq_save(void) > swapgs; \ > sysretl > > +#ifdef CONFIG_DEBUG_ENTRY > +#define SAVE_FLAGS(x) pushfq Isn't there a "pop %rax" missing (assuming %rax is allowed to be modified) ? Juergen