Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp1602172ybx; Sat, 2 Nov 2019 02:59:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqyp+uD+qHuk4i35/mDdEPKNEjpnP/RluMGuGfRXGk+KzMZ2lWZ7ajlHwPG1UjWloKLg91CU X-Received: by 2002:aa7:cad0:: with SMTP id l16mr14466926edt.82.1572688789729; Sat, 02 Nov 2019 02:59:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572688789; cv=none; d=google.com; s=arc-20160816; b=RC8YQzLVicWJ8o1lXe1pkO1l44+vIaHfHZMViA+aDDAEOpG1rqBf8nWatoKaXHcH42 f3sXbRSsDGujuDeJiJCfAyZ6lSterQe6Udgu29fw8TQv3eTrV6COVPeTMFQnN6fR/Rc3 nL/aSKclJApw8SdZWIgfz9Gl0LkhMcUUClQEXKIVDBDCulH7gcv434xRsReye6SZpS5B eMbXahBJzaiYjFJKKuL7WfxjVBkBEVY+IdnOkJJdjHOGj6O8rvqiLoVt/lf5EAeRxWZb elWSKETXmPDE4h5ffVqWKK9lxFvZT2M1pUjN5JQHpBk5zn+dKwvsZC9jHiv7S5l83Bm6 Qr5Q== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:openpgp:from:references:cc:to:subject; bh=SnHbm5y0Oc/bW/z1BoC7Pi238VT3ZqMdoywC0g3dFqE=; b=vXi6G3pJjGhTquyyM9n4gnMCal8au146aEYRFqpfodaolWmpAaBrTi7cHW4VZFaLBp /7stw56575LzpdsPNwwopXYTcI4Mr+KBNok4fpKP5L4+spdN7nyEjwdx0QcNU4MYaiGI VLhTo1E3dZvX+WtbgvAEDbrgT0FNk/n2ehQzr5BpHLeiPKntJqbBkg06/eMNjQlIeZZd ffmGRbl7vhLGc3Hhz9uXYfgZ1JR9YX6fwb34ODkz9Zn29h3VpRHLb7xfj+9+cnOelC/q T5dqPH6ebDcK/RLdWuNvRPG2LvUhH5/a/1kNUTmmeFeyAtHPmXlGvz/Ut3KZdMZeHiKy +7iw== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g53si2599508edb.313.2019.11.02.02.59.26; Sat, 02 Nov 2019 02:59:49 -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; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726038AbfKBJ5z (ORCPT + 99 others); Sat, 2 Nov 2019 05:57:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58714 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726001AbfKBJ5z (ORCPT ); Sat, 2 Nov 2019 05:57:55 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 95030882FF for ; Sat, 2 Nov 2019 09:57:54 +0000 (UTC) Received: by mail-wr1-f70.google.com with SMTP id g17so2368954wru.4 for ; Sat, 02 Nov 2019 02:57:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:openpgp:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=SnHbm5y0Oc/bW/z1BoC7Pi238VT3ZqMdoywC0g3dFqE=; b=dg7P3We6hGYJwugltIvnZKs8tlq4B002znv++46QsKGsNwz4VARUoLQtwqAEZvmbZM Pxy51QFnafvoKmIehACZk8sktmYFD7QQ7nzwKdfdRmYjPwFMLbq3OAq5Wldx7cvKsf+9 gybY255rRfA6Ua0WM6dPCI7dBEi6M6GHhINdgCtJO17tN4ZADYPCLYVR1kfdq/bs348Z cb8xygC+E0L1HiTAUQB4jwC3+M+x0bSyRr+wXp3o3g/mBHL7lRXydFIC4WzghavGfMrV AOOP20V7gU9kOzBHrg8pdwy6wmOWLMITdwuFm8ka5vMlRNNG+DuNMS43XfB+isuqHKzC jv7Q== X-Gm-Message-State: APjAAAWFO6IJalsbQsiyLySP3fgIZsygwPiUb7v5erX2k/msTSZ7ACUr iiKGLCxVSrmuQD+skthhCnHwN3qQ66vr24v+/MxqyVBQbZM4fGgIBGt/fcZpTXdmlzXB5Oufx28 eHdP8uLH9xMXD4b+LhMAG9+2L X-Received: by 2002:a1c:30b:: with SMTP id 11mr13328562wmd.171.1572688673229; Sat, 02 Nov 2019 02:57:53 -0700 (PDT) X-Received: by 2002:a1c:30b:: with SMTP id 11mr13328541wmd.171.1572688672941; Sat, 02 Nov 2019 02:57:52 -0700 (PDT) Received: from [192.168.42.35] (mob-31-159-163-247.net.vodafone.it. [31.159.163.247]) by smtp.gmail.com with ESMTPSA id l14sm10780581wrr.37.2019.11.02.02.57.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 02 Nov 2019 02:57:52 -0700 (PDT) Subject: Re: [PATCH v4 13/17] kvm: i8254: Deactivate APICv when using in-kernel PIT re-injection mode. To: "Suthikulpanit, Suravee" , "linux-kernel@vger.kernel.org" , "kvm@vger.kernel.org" Cc: "rkrcmar@redhat.com" , "joro@8bytes.org" , "vkuznets@redhat.com" , "rkagan@virtuozzo.com" , "graf@amazon.com" , "jschoenh@amazon.de" , "karahmed@amazon.de" , "rimasluk@amazon.com" , "Grimm, Jon" References: <1572648072-84536-1-git-send-email-suravee.suthikulpanit@amd.com> <1572648072-84536-14-git-send-email-suravee.suthikulpanit@amd.com> From: Paolo Bonzini Openpgp: preference=signencrypt Message-ID: <70fb2b49-2198-bde4-a38b-f37bc8bc9847@redhat.com> Date: Sat, 2 Nov 2019 10:57:47 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <1572648072-84536-14-git-send-email-suravee.suthikulpanit@amd.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/11/19 23:41, Suthikulpanit, Suravee wrote: > + /* > + * AMD SVM AVIC accelerates EOI write and does not trap. > + * This cause in-kernel PIT re-inject mode to fail > + * since it checks ps->irq_ack before kvm_set_irq() > + * and relies on the ack notifier to timely queue > + * the pt->worker work iterm and reinject the missed tick. > + * So, deactivate APICv when PIT is in reinject mode. > + */ > if (reinject) { > + kvm_request_apicv_update(kvm, false, APICV_DEACT_BIT_PIT_REINJ); > /* The initial state is preserved while ps->reinject == 0. */ > kvm_pit_reset_reinject(pit); > kvm_register_irq_ack_notifier(kvm, &ps->irq_ack_notifier); > kvm_register_irq_mask_notifier(kvm, 0, &pit->mask_notifier); > } else { > + kvm_request_apicv_update(kvm, true, APICV_DEACT_BIT_PIT_REINJ); > kvm_unregister_irq_ack_notifier(kvm, &ps->irq_ack_notifier); > kvm_unregister_irq_mask_notifier(kvm, 0, &pit->mask_notifier); This is not too nice for Intel which does support (through the EOI exit mask) APICv even if PIT reinjection active. We can work around it by adding a global mask of inhibit reasons that apply to the vendor, and initializing it as soon as possible in vmx.c/svm.c. Then kvm_request_apicv_update can ignore reasons that the vendor doesn't care about. Paolo