From patchwork Tue Dec 5 08:16:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liran Alon X-Patchwork-Id: 10092423 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1800460348 for ; Tue, 5 Dec 2017 08:16:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 08C8B2950F for ; Tue, 5 Dec 2017 08:16:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F1E1229536; Tue, 5 Dec 2017 08:16:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 94F132950F for ; Tue, 5 Dec 2017 08:16:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752617AbdLEIQx (ORCPT ); Tue, 5 Dec 2017 03:16:53 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:45124 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752554AbdLEIQv (ORCPT ); Tue, 5 Dec 2017 03:16:51 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.21/8.16.0.21) with SMTP id vB58Ceal024911; Tue, 5 Dec 2017 08:16:48 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2017-10-26; bh=v9KhbIu4Qo4X3HHCSvcQ3skNJyvE+m7FXTCFcXZUjpo=; b=qDQy4S75Uc+9J8CwpdKiPdFKpE8tzZtElsTX0FPadlqNr90Fq27rJMfl1X66JRulnrM/ M49YmO4F4TuiPP/NsWMO4B2ZORUweRRomLTeRUNrfJywcisSBpKCvqi+3NrdGvCZds72 FCpMrbQkr6/TwVPIjhGkdGqwU2+B/ct+kAvUJnsmUz5r/3yS2MPcVdBjToPAogtb5YpO m1PY3Eus3dQy27wCUzzeyYsT70v2c/1VD+MYV/2begt03nZ3TEqQesCTmbS20Hj9YJLT 4nk+Uq1pW7Z9lu/U6hvoMREjK4jtiOxxtfrM9ninJuC7VUPniX4iiIm2Pu2InfY+zmEI Dg== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2130.oracle.com with ESMTP id 2en9pgt463-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 05 Dec 2017 08:16:48 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id vB58GmcU026065 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 5 Dec 2017 08:16:48 GMT Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id vB58GlIa005615; Tue, 5 Dec 2017 08:16:47 GMT Received: from localhost.localdomain (/172.58.43.69) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 05 Dec 2017 00:16:47 -0800 From: Liran Alon To: pbonzini@redhat.com, rkrcmar@redhat.com, kvm@vger.kernel.org Cc: jmattson@google.com, wanpeng.li@hotmail.com, idan.brown@oracle.com, Liran Alon , Krish Sadhukhan , Konrad Rzeszutek Wilk Subject: [PATCH v2 1/5] KVM: nVMX: Remove pi_pending as signal to process nested posted-interrupts Date: Tue, 5 Dec 2017 10:16:22 +0200 Message-Id: <1512461786-6465-2-git-send-email-liran.alon@oracle.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1512461786-6465-1-git-send-email-liran.alon@oracle.com> References: <1512461786-6465-1-git-send-email-liran.alon@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8735 signatures=668637 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1712050121 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When L1 wants to send a posted-interrupt to another L1 CPU which runs L2, it does the following operations: 1. Sets the relevant bit in vmx->nested.pi_desc PIR. 2. Set ON bit in vmx->nested.pi_desc->control field. 3. Sends an IPI to dest L1 CPU by writing the the posted-interrupt notification-vector into the LAPIC ICR. Step (3) will exit to L0 on APIC_WRITE which will eventually reach vmx_deliver_nested_posted_interrupt(). If dest L0 CPU is in guest, then a physical IPI of notification-vector will be sent which will trigger evaluation of posted-interrupts and clear vmx->nested.pi_desc->control ON bit. Otherwise (or if dest L0 CPU exited from guest just before sending the physical IPI), the nested-posted-interrupts will be evaluated on next vmentry by vmx_complete_nested_posted_interrupt(). In order for vmx_complete_nested_posted_interrupt() to know if it should do any work, the flag vmx->nested.pi_pending was used which was set by vmx_deliver_nested_posted_interrupt(). However, this seems unnecessary because if posted-interrupts was not processed yet, vmx->nested.pi_desc->control ON bit should still be set. Therefore, it should suffice to use it in order to know if work should be done. Signed-off-by: Liran Alon Reviewed-by: Nikita Leshenko Reviewed-by: Krish Sadhukhan Signed-off-by: Krish Sadhukhan Signed-off-by: Konrad Rzeszutek Wilk --- arch/x86/kvm/vmx.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 714a0673ec3c..f5074ec5701b 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -453,7 +453,6 @@ struct nested_vmx { struct page *virtual_apic_page; struct page *pi_desc_page; struct pi_desc *pi_desc; - bool pi_pending; u16 posted_intr_nv; unsigned long *msr_bitmap; @@ -5050,10 +5049,9 @@ static void vmx_complete_nested_posted_interrupt(struct kvm_vcpu *vcpu) void *vapic_page; u16 status; - if (!vmx->nested.pi_desc || !vmx->nested.pi_pending) + if (!vmx->nested.pi_desc) return; - vmx->nested.pi_pending = false; if (!pi_test_and_clear_on(vmx->nested.pi_desc)) return; @@ -5126,7 +5124,6 @@ static int vmx_deliver_nested_posted_interrupt(struct kvm_vcpu *vcpu, * If a posted intr is not recognized by hardware, * we will accomplish it in the next vmentry. */ - vmx->nested.pi_pending = true; kvm_make_request(KVM_REQ_EVENT, vcpu); return 0; } @@ -10488,7 +10485,6 @@ static int prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12, /* Posted interrupts setting is only taken from vmcs12. */ if (nested_cpu_has_posted_intr(vmcs12)) { vmx->nested.posted_intr_nv = vmcs12->posted_intr_nv; - vmx->nested.pi_pending = false; vmcs_write16(POSTED_INTR_NV, POSTED_INTR_NESTED_VECTOR); } else { exec_control &= ~PIN_BASED_POSTED_INTR;