Received: by 10.223.164.202 with SMTP id h10csp3189249wrb; Tue, 28 Nov 2017 07:30:32 -0800 (PST) X-Google-Smtp-Source: AGs4zMaYTqAS9fk2WpAbxOA3qlEMLEzGZQ+mrt/mmLmG/z8YMlqYtiTW6d+oto3Kh+Bh2tRz/gsZ X-Received: by 10.84.202.194 with SMTP id q2mr43293247plh.19.1511883031963; Tue, 28 Nov 2017 07:30:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511883031; cv=none; d=google.com; s=arc-20160816; b=n9zMjWn8OeIoGRgOMgAKZJdSKzBprKVal0M3dlrppCMwtaECZN9JuFnG2u36I2hdPA btsdVk0ryhyKAGtWvNTUwQoK3EI/WHz+HnNAR4TCCT557EK/88N6y802u5Ru+rX53zdN UQ+dK/BPLXo+XQh/oC0xkXqEbbAD2ZOuHS9vRkIRJw03+OdpVqYDo716L+MhLw/f8pRo W59t86D4CKN6+nQ8UXC0pwRHs/LbPmWeYiSsbwakHLZ4rlXQskFigHMqV9PVJGqRtqai nFQkAyMktUCAPkrAEFDlw1xdap9c8xvM5tic2X0LgNu2Y4rt66n0lNaNanZb2LpCB35R rMTg== 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=SnVc2zpA1LqPETOMiL5ln2MhzVUKMq0FGQeepOyyu40=; b=CJGFBio8H1ik+3FKUO1U5vTPTcEqd4XkGyujV1zCOIJmXKgRiwe+qaIm1DSsxWYYLE lD/0FLKF36GPgNmSh873foFOhnuHBZB9mQvUQTLpeCZiY21Q1mGM9spJZ2fAbUEJ7O3F BmhiB8n8bigaLL0Vaob5Th+2RrxKbkfYpFJQpBgdMJI+c+CbYbRjvSiwtqmQba2CwxlG OuEP0wrNXfx4oSVuQBdyHLRS7YZVG3SYWwjXB/sJDr/IvsuyKeuNUN4tLPQEv6rDR7JL Vuf6kQ3pIcAJXYsWC3g239qOHgViny20I1/GaHulQhNTwh9xlJT/H6+qI3s5XZ7ryCXD E4SA== 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 f64si27593691pfk.57.2017.11.28.07.30.20; Tue, 28 Nov 2017 07:30:31 -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 S1753470AbdK1P3E (ORCPT + 78 others); Tue, 28 Nov 2017 10:29:04 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:37111 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753064AbdK1P3C (ORCPT ); Tue, 28 Nov 2017 10:29:02 -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 vASFSjir002440 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 28 Nov 2017 15:28:45 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 vASFSjdZ006942 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 28 Nov 2017 15:28:45 GMT Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id vASFSgon027202; Tue, 28 Nov 2017 15:28:44 GMT Received: from ovs101.us.oracle.com (/10.149.76.201) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 28 Nov 2017 07:28:42 -0800 From: Boris Ostrovsky To: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, jgross@suse.com, luto@kernel.org, Boris Ostrovsky Subject: [PATCH v2] x86/entry/64/paravirt: Use paravirt-safe macro to access eflags Date: Tue, 28 Nov 2017 10:28:25 -0500 Message-Id: <1511882905-6326-1-git-send-email-boris.ostrovsky@oracle.com> X-Mailer: git-send-email 1.7.1 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 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 --- V2: * Preserve %rax in DEBUG_ENTRY_ASSERT_IRQS_OFF * Return (pop) %rax in SAVE_FLAGS for !CONFIG_PARAVIRT (irqflags.h) arch/x86/entry/entry_64.S | 7 ++++--- 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, 19 insertions(+), 3 deletions(-) diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S index f81d50d..c208dc1 100644 --- a/arch/x86/entry/entry_64.S +++ b/arch/x86/entry/entry_64.S @@ -466,12 +466,13 @@ END(irq_entries_start) .macro DEBUG_ENTRY_ASSERT_IRQS_OFF #ifdef CONFIG_DEBUG_ENTRY - pushfq - testl $X86_EFLAGS_IF, (%rsp) + pushq %rax + SAVE_FLAGS(CLBR_ANY) + testl $X86_EFLAGS_IF, %eax jz .Lokay_\@ ud2 .Lokay_\@: - addq $8, %rsp + popq %rax #endif .endm diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h index c8ef23f..89f0895 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; popq %rax +#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 1585426879017301185@xxx Wed Nov 29 18:41:35 +0000 2017 X-GM-THRID: 1585426879017301185 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread