Received: by 10.223.164.202 with SMTP id h10csp1964492wrb; Mon, 27 Nov 2017 09:50:39 -0800 (PST) X-Google-Smtp-Source: AGs4zMYWbsaudB+UFje42lOcaqkPACr0mjGBLOMlI9s+w7j0o3UoBiu9npeYS6djnuOmjiE/QbTG X-Received: by 10.84.230.135 with SMTP id e7mr38094789plk.299.1511805039212; Mon, 27 Nov 2017 09:50:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511805039; cv=none; d=google.com; s=arc-20160816; b=YQfDeUg6CpMQReIFj7xhdiFb50+Y6vOKin57bRGnQ70vuIQgCov2csjc9VaAp6PsL2 L6PXUNgySGP6R/QWcMkF+q4ss5jPnYyc7yS2BBUhd0eXq92VJxdwuohC8dyaaUZor2Mv iW27nXfx6rptg296ObZ05nbD4qnZ0XfPy4ESry5IHUYwOuzOgD3RGGcJZcn7+d19NCnQ NVHmVXeqm7btko/c0eEU5TC0581S58VgLiiUjX6ldC/wRpG7CdymVVZ3PowvMxKhQlAX Ydwocu9B61qlkdnAnOomq8e00doIfsUbCLNuoTOd0v5OTbJHX2m04+7NHV0XlxEXHNs6 NMVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=hutoAU3Y17jhUj5QVpZ4D4QWTMtKRYJusRRFP1FN9es=; b=UyEWRdfiwkkcKZMH6ZPZzcHfB1cSzDjMvZjzxkIoHXLePTU5nTRcd7slkmqDVh/W6X HGHS1vAlL85gJ11qA35ItpxC5DsRUmFFrZ73+Ok/H5bTy34b0Qa/f0UK4bD0N0sEiwdx OuC26ZhsREjrexYWV5J6urjtqJKQXTmEUEahCYzV3rxPzDbx8mtnbk7XNivxPxxBs9RP p+LtcoRYulkSbnODemkr0ZUSWgjcyW02v0wfqZLoiIn8uQqrzEiAGtO300FSOL6N3TR9 CcZ6QlIZ3lDlqbdVOMaqXlJSJIH2dFUjr3/+tp9OPb/eIn/a6JvPttwmW4gtCYJjinpy +S6w== 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 f4si3154640pgo.205.2017.11.27.09.50.26; Mon, 27 Nov 2017 09:50:39 -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 S932398AbdK0Rrq (ORCPT + 78 others); Mon, 27 Nov 2017 12:47:46 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:46612 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753876AbdK0Rro (ORCPT ); Mon, 27 Nov 2017 12:47:44 -0500 Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id vARHlQTA015364 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 27 Nov 2017 17:47:27 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id vARHlQkd031396 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 27 Nov 2017 17:47:26 GMT Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id vARHlOJh008716; Mon, 27 Nov 2017 17:47:25 GMT Received: from ovs101.us.oracle.com (/10.149.76.201) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 27 Nov 2017 09:47:24 -0800 From: Boris Ostrovsky To: linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org Cc: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, jgross@suse.com, x86@kernel.org, luto@kernel.org Subject: [PATCH] x86/entry/64/paravirt: Use paravirt-safe macro to access eflags Date: Mon, 27 Nov 2017 13:05:18 -0500 Message-Id: <1511805918-8041-1-git-send-email-boris.ostrovsky@oracle.com> X-Mailer: git-send-email 1.7.1 X-Source-IP: aserv0021.oracle.com [141.146.126.233] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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 +#endif #else #define INTERRUPT_RETURN iret #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h index 283efca..892df37 100644 --- a/arch/x86/include/asm/paravirt.h +++ b/arch/x86/include/asm/paravirt.h @@ -927,6 +927,15 @@ static inline notrace unsigned long arch_local_irq_save(void) PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_usergs_sysret64), \ CLBR_NONE, \ jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_usergs_sysret64)) + +#ifdef CONFIG_DEBUG_ENTRY +#define SAVE_FLAGS(clobbers) \ + PARA_SITE(PARA_PATCH(pv_irq_ops, PV_IRQ_save_fl), clobbers, \ + PV_SAVE_REGS(clobbers | CLBR_CALLEE_SAVE); \ + call PARA_INDIRECT(pv_irq_ops+PV_IRQ_save_fl); \ + PV_RESTORE_REGS(clobbers | CLBR_CALLEE_SAVE);) +#endif + #endif /* CONFIG_X86_32 */ #endif /* __ASSEMBLY__ */ diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c index 630212f..e3a5175 100644 --- a/arch/x86/kernel/asm-offsets_64.c +++ b/arch/x86/kernel/asm-offsets_64.c @@ -23,6 +23,9 @@ int main(void) #ifdef CONFIG_PARAVIRT OFFSET(PV_CPU_usergs_sysret64, pv_cpu_ops, usergs_sysret64); OFFSET(PV_CPU_swapgs, pv_cpu_ops, swapgs); +#ifdef CONFIG_DEBUG_ENTRY + OFFSET(PV_IRQ_save_fl, pv_irq_ops, save_fl); +#endif BLANK(); #endif -- 1.7.1 From 1585413472389664161@xxx Wed Nov 29 15:08:29 +0000 2017 X-GM-THRID: 1585410745266710231 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread