Received: by 10.223.164.202 with SMTP id h10csp2217964wrb; Mon, 27 Nov 2017 13:42:39 -0800 (PST) X-Google-Smtp-Source: AGs4zMbJGw7jms57FFnpPMPEo/7Wqgvz3f4DrPY8fia/qb1y1IHfmI/ROKSipaz6AkfP4EgHvBRe X-Received: by 10.101.101.131 with SMTP id u3mr30684091pgv.76.1511818959015; Mon, 27 Nov 2017 13:42:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511818958; cv=none; d=google.com; s=arc-20160816; b=ObwJanpYzVwMJ8jFntkg+FSkO0E+WIOY8z6g0Nsv/N5XyEbIpG2avHTSK5DHmvHm9J 0vcg9k4Okr3/qsu05lrfyfOHdRrhGZl9P+UwjvR4G6KI0vLORVwGiJ8g59nt/1fWqZsq z6fGBX31Zv10IlWg13ygFomvBDNxDepd1k4EePzpO01gZcVkWwZtIJQD5aln/ekYJJe9 KE/SuGK7XRnhlKkEd7q0T8M4zLRUCZdIOzpIYkBdaFMT5KvzRTOZKnZqzMo7AEoUGsB2 eaNOhZ4HBBWceRIuxstkJwe+EaLRRun8GSDAa/Vk4a0cZuRl2O5S84sGvCcF3aosI6aJ djwQ== 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:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:arc-authentication-results; bh=VL7wjMsTMrsZVwivoyfZcPhA13DAcEX2pXPSiOBx+ng=; b=nd3tfAMPyIjWUKIE31yRjPlfJXj6bEy9zaF87slMMBEh/4DcfwKrmAG/GdYjuCRoKt VgHr/+VpwIASuYOHGkCab5ND8oRrh/32qyfi1cp8utfojBGQm8SdA4UNkYNlqCbmvCis yUK6WDhsLKkzauPbRVZKxQ3ZGXnDokDKo/DxIcdMyTvaXusfoK0fDnOzkdlL1xe/g52k yX5KTFkZzZlWnRSpDGoVlwsOcclFZTripx960x2sfIhkR8K87IhOMOCvgjFG0odq9jR7 1LWeFk4yphCUK9PW835pTtuqZi5yUr9s7h24pafCcEPsaD84yXisYMVsckdjU50fMTIY +Wug== 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=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x66si26145420pfi.70.2017.11.27.13.42.27; Mon, 27 Nov 2017 13:42:38 -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; 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=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753274AbdK0Vlv (ORCPT + 78 others); Mon, 27 Nov 2017 16:41:51 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:21733 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752494AbdK0Vlr (ORCPT ); Mon, 27 Nov 2017 16:41:47 -0500 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id vARLeTgO012536 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 27 Nov 2017 21:40:30 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id vARLeTOg026802 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 27 Nov 2017 21:40:29 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id vARLeS0g014312; Mon, 27 Nov 2017 21:40:28 GMT Received: from bostrovs-us.us.oracle.com (/10.152.32.65) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 27 Nov 2017 13:40:28 -0800 Subject: Re: [PATCH] x86/entry/64/paravirt: Use paravirt-safe macro to access eflags To: Juergen Gross , linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org References: <1511805918-8041-1-git-send-email-boris.ostrovsky@oracle.com> Cc: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, luto@kernel.org From: Boris Ostrovsky Message-ID: Date: Mon, 27 Nov 2017 16:40:25 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Source-IP: userv0021.oracle.com [156.151.31.71] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/27/2017 02:22 PM, Juergen Gross wrote: > 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) ? Yes to both. Need to save %rax in DEBUG_ENTRY_ASSERT_IRQS_OFF. Thanks. -boris From 1585248338307706885@xxx Mon Nov 27 19:23:45 +0000 2017 X-GM-THRID: 1585242480710091344 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread