Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1526417imm; Wed, 26 Sep 2018 20:50:50 -0700 (PDT) X-Google-Smtp-Source: ACcGV63IOi+3/RD1+e3EqxXGAPBgKhjqAhVRa9LcVexN2JeX28Fbe6X61p0LK1BGikWITKtql233 X-Received: by 2002:a62:6104:: with SMTP id v4-v6mr9335769pfb.122.1538020250502; Wed, 26 Sep 2018 20:50:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538020250; cv=none; d=google.com; s=arc-20160816; b=LwC9YG9YRdKWqAj7hrerSTuODGa6BIkO3852KfTEaoegmJaXIaV5AvXLVj92LyLeTW eCSRCKhRRLgiGSOjFgkLfsUqi5dj3il7UgvQD211vPXhxl8ccpMQpirerXl19IHnb2Y9 X8pmJ4cMue6mZ0l4Ff5+CPw1Bb+DhmGB1h5XemJEoXbLsuyZhT1HU3vmai06EFmK68KM SRamSx8rPWvc93EgCJQHyS8c6fw8tfZYJ+nYo+khIs2/Awdi+08BGDu+WL03TYxWta63 JRJRe6w+XPsOCWDyZ/c95iIlRChcGJD9E76L11+ztSwI7Ff4++Xtn9lU1zJakXANSjcR RJ6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:from:dkim-signature; bh=vkM1XDOasZe08xhGjYX+1tcGXbLIMOabyyqCPCQ98DY=; b=JlFvAyXCFS3vGesNf07f0C+M9de148k59h/W+XBHsrJeYs5HrRdf+ctoUcR1aqv8u3 WvimFLK3EBHHcob+MCGIavmQWivgfXcTdsb5ITorVWYnV+ySa1ouQalWSWdoBhQSR5sK 2sE9/McVgzKWCsKTrAjLsyDH+a8NW6WtdFpm9igxnBySGz4iMr3KgQKYALdkpCwuyCKo dh91xCFN+BSM12moXjoRpVIwSJZkEMU2H4BzYRzi/+23dF6Gi7ulr8KlvQthjDuabEeD rEPay0W1oP+n4KaT+sSxmnoxkKZWIAs3Gvx40ZQc+jmCvGtnsm4mfdjJEVeqiltb7qzR POqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b="icVg3G/u"; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u7-v6si973528pfu.143.2018.09.26.20.50.35; Wed, 26 Sep 2018 20:50:50 -0700 (PDT) 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; dkim=pass header.i=@microsoft.com header.s=selector1 header.b="icVg3G/u"; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727443AbeI0KGO (ORCPT + 99 others); Thu, 27 Sep 2018 06:06:14 -0400 Received: from mail-sg2apc01on0117.outbound.protection.outlook.com ([104.47.125.117]:56048 "EHLO APC01-SG2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726684AbeI0KGN (ORCPT ); Thu, 27 Sep 2018 06:06:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vkM1XDOasZe08xhGjYX+1tcGXbLIMOabyyqCPCQ98DY=; b=icVg3G/uUwvDwNf2/byxmP1xYS0xiMAVCGdbrT/uhxL/4LoeYOvHReMgygau4HTE/iDr6c2vQa00aO0ZG5ol8Ud4GlH9OGah4LnOR6jmc49V/LY+HjwaQfug8Z6QIqsZe13IMpZsJ8gHUAdQ9O6Jy6VpvW9mGPIgo69CkCaJjOI= Received: from HK0P153MB0129.APCP153.PROD.OUTLOOK.COM (52.133.156.18) by HK0P153MB0177.APCP153.PROD.OUTLOOK.COM (52.133.210.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1207.3; Thu, 27 Sep 2018 03:50:01 +0000 Received: from HK0P153MB0129.APCP153.PROD.OUTLOOK.COM ([fe80::8584:ad93:130a:6267]) by HK0P153MB0129.APCP153.PROD.OUTLOOK.COM ([fe80::8584:ad93:130a:6267%3]) with mapi id 15.20.1207.011; Thu, 27 Sep 2018 03:50:01 +0000 From: Tianyu Lan CC: Tianyu Lan , "pbonzini@redhat.com" , "rkrcmar@redhat.com" , "tglx@linutronix.de" , "mingo@redhat.com" , "hpa@zytor.com" , "x86@kernel.org" , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "Michael Kelley (EOSG)" , KY Srinivasan , vkuznets , Jork Loeser Subject: [PATCH V3 12/13] KVM/VMX: Change hv flush logic when ept tables are mismatched. Thread-Topic: [PATCH V3 12/13] KVM/VMX: Change hv flush logic when ept tables are mismatched. Thread-Index: AQHUVhUqMmeUDbYBlEutoL/p1B3ROQ== Date: Thu, 27 Sep 2018 03:50:00 +0000 Message-ID: <20180927034829.2230-13-Tianyu.Lan@microsoft.com> References: <20180927034829.2230-1-Tianyu.Lan@microsoft.com> In-Reply-To: <20180927034829.2230-1-Tianyu.Lan@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Tianyu.Lan@microsoft.com; x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;HK0P153MB0177;6:hJMAMvhmxaK6w8U7ED785LcjjUJ/gyyZkBYi+xta1Nf/infv4JkyuY0Hwg4x7uzkEaOF9i2+x/5y+pnl+QD/JLthN0GXGGNBbiPxvfI2h9Q6w86Ha2LrOZuJ2XwOcbXKkSPFGXrE9tuxMQsejAvwUqlMLAKySly6+kwyj+E2zRu//oxZkOUpRjrvN5gnttgqXQOYa2GNltvPTyQoUjgqIl2lF0JxHOSAnpLoRzR4BF12EU2Oc737ylhxzDoIsmwpiZWDSkbeA7hReeB+SMd0v5up7TMCB6/403MoAqXKSQdGUrq3nzD0MuCzotdL2KoCwSgx34ZtOp9axHiZvQvW0O6493x4nWDc1pYe8f6Szx2GCm8wQeV8g/b8kjPeM9j5E6i7JbJHs7gmuAB+olefeSqzJYJ9ScalIrslJgsy3XX2TH+TJ04NnK1jWmiN28Icka5ZPqjfb7LeCSk6FnldnA==;5:MTGu1wfeBndk0TQNWrBRZ3dIx/I+YJu95jkIg27ZEsUF5t353SIV291XbJvU+OIzVfFcwVngYHRbr2UJIjhHQErGuo6BbAfbdA3qfkNk5Yqxe2bjlCU/OwmOvCYGlUZx2Q28m61fQXC4mhBwFs0hVd2KEJDAKxuxzTaHAX9VNB4=;7:77jF5koG6RmkY1kAcM2HzIbe+q1pT1Xt1SbES0pYhZWFhr6fBQNtSS6VQs+XF3iLCu7AwRsUv8oMIN8hD+AH8mpWOfhfObnQ8LipO0dimJFVPpBMFq8pi1G9JYSmF5jqGUWyBwF/544DStk7Cw3Fc6gL3i9WOdEYKEYytF97rPMLtku+XTTfGjXZxN8BavWi6/HJgeHXd4eXyIcAc6G9YUB9Q0Sgan+2TfeqFmxbRvbrrg65sczMPot5AbYHCCzz x-ms-office365-filtering-correlation-id: 504c4654-0797-4d7c-f005-08d6242c4d49 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(2017052603328)(7193020);SRVR:HK0P153MB0177; x-ms-traffictypediagnostic: HK0P153MB0177: x-ld-processed: 72f988bf-86f1-41af-91ab-2d7cd011db47,ExtAddr x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231355)(944501410)(52105095)(93006095)(93001095)(3002001)(10201501046)(6055026)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(201708071742011)(7699051);SRVR:HK0P153MB0177;BCL:0;PCL:0;RULEID:;SRVR:HK0P153MB0177; x-forefront-prvs: 0808323E97 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(376002)(136003)(396003)(346002)(39860400002)(366004)(199004)(189003)(105586002)(99286004)(10290500003)(486006)(478600001)(68736007)(106356001)(14454004)(72206003)(81156014)(6486002)(8676002)(6506007)(1671002)(81166006)(6512007)(2900100001)(2906002)(6436002)(76176011)(8936002)(10090500001)(3846002)(6116002)(54906003)(36756003)(316002)(59246006)(102836004)(26005)(1076002)(5660300001)(5250100002)(109986005)(107886003)(11346002)(446003)(2616005)(4326008)(25786009)(476003)(22452003)(53936002)(86612001)(86362001)(71190400001)(71200400001)(14444005)(66066001)(7736002)(256004)(305945005)(34290500001)(97736004);DIR:OUT;SFP:1102;SCL:1;SRVR:HK0P153MB0177;H:HK0P153MB0129.APCP153.PROD.OUTLOOK.COM;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: /54l+TwwTiQULb46A7DHOUEeY/G++cSQbz+Wd2gHThQbq8fsEdO7yDFzfcpNiW6ginvK4HT45bgx5Oih0yekV9Ox/k08zElDyRkoHEas8ahkoAkvH0e+dLjUhOeqLe7OcHgLaLHWg/kAAxlFPQHuSJGBXNOvC0l14PXPfjsPifVgnv3oYBc62Kkb4KXajoZ8+KzScNmKrN9NmKLjnJoL0c5XZRpKKwXR/vDc5CVX/OtKPd/KXpBYKaeSs3SGlvBER4d2F9fczcGOfxw7KU25XdmW5SA6DbPALYoVHJZnFrztTgDxSCmz5fXNXFUg3GXI1zeUsIlhaTgz1TNHi01iR9IDJALCepHkFQgp596dvmE= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 504c4654-0797-4d7c-f005-08d6242c4d49 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Sep 2018 03:50:00.9423 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HK0P153MB0177 To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If ept table pointers are mismatched, flushing tlb for each vcpus via hv flush interface still helps to reduce vmexits which are triggered by IPI and INEPT emulation. Signed-off-by: Lan Tianyu --- arch/x86/kvm/vmx.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 533a327372c8..2869c3e78168 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -1557,7 +1557,8 @@ static void check_ept_pointer_match(struct kvm *kvm) =20 static int vmx_hv_remote_flush_tlb(struct kvm *kvm) { - int ret; + struct kvm_vcpu *vcpu; + int ret =3D -ENOTSUPP, i; =20 spin_lock(&to_kvm_vmx(kvm)->ept_pointer_lock); =20 @@ -1565,14 +1566,14 @@ static int vmx_hv_remote_flush_tlb(struct kvm *kvm) check_ept_pointer_match(kvm); =20 if (to_kvm_vmx(kvm)->ept_pointers_match !=3D EPT_POINTERS_MATCH) { - ret =3D -ENOTSUPP; - goto out; + kvm_for_each_vcpu(i, vcpu, kvm) + ret |=3D hyperv_flush_guest_mapping( + to_vmx(kvm_get_vcpu(kvm, i))->ept_pointer); + } else { + ret =3D hyperv_flush_guest_mapping( + to_vmx(kvm_get_vcpu(kvm, 0))->ept_pointer); } =20 - ret =3D hyperv_flush_guest_mapping( - to_vmx(kvm_get_vcpu(kvm, 0))->ept_pointer); - -out: spin_unlock(&to_kvm_vmx(kvm)->ept_pointer_lock); return ret; } --=20 2.14.4