From patchwork Wed Sep 19 22:50:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 10606661 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CD272112B for ; Wed, 19 Sep 2018 22:51:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B66B12CC82 for ; Wed, 19 Sep 2018 22:51:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AAA462CDB6; Wed, 19 Sep 2018 22:51:02 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 563E52CC82 for ; Wed, 19 Sep 2018 22:51:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732777AbeITEal (ORCPT ); Thu, 20 Sep 2018 00:30:41 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:36854 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725755AbeITEal (ORCPT ); Thu, 20 Sep 2018 00:30:41 -0400 Received: by mail-wm1-f66.google.com with SMTP id j192-v6so8758465wmj.1; Wed, 19 Sep 2018 15:50:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id; bh=whkDutS3F2DQl4qkMuAGH7T1sbauHEXoAEgLmTSdGRE=; b=gBQDu9tyfmbu4p/voVm+u9ELsdwpwUgvDuMsn1/ylgi/C5Oz9Z8eP0h5yMqbe6LXoJ GLGSD5P5FnoaXfBMy7TDGRem8mqbSNw5jY3rmdHfvSfFeyfPMGiMdm/Ia5zX3KE5FNsX cV00pRDr90u257F5fDDDLEESUVkbR6ICO2KzbumLEYTYh5x5SX4Cr5KDWzPXJdvuIlIb JNxnBUD4sx9ok5fMffiL10jsQkFmAjMwKbEepB2oHYh0dUwZNHMPeqNiCGotM+wth3Wx ygV72PaxqPrSpolfihzA/iRf8k3s9ShcmnyppH7tlosBFDffGSjfPp2n0JPIMVWhoWFt BO/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id; bh=whkDutS3F2DQl4qkMuAGH7T1sbauHEXoAEgLmTSdGRE=; b=GgMI1s2AlmzMLzJL8dWLYKAr/IUoqDmuKK0b3uOg6H/g/IgI+wIJfzwiXrjzsQvIU0 8ET0swXiP21cWEwIdFcuyv4nn/UAhY8ugHPt3QVej70cfwFUovDVLmpNaTZJta1sTR4n HcwIsntJzhgGxsdFwXvVeUqCAeg2wCWhOzbOuYQlLEQNaWntl82DPvudRYn023aBqQR2 XYS9xSZ/15jPR7l3oJeIwouW5dIOazKWLWrcb5uNtUoZ5TaV5a4iPw81G3SAZH5II0kW RdsmcnEoNoBQLIUIv2BC0Cb5num8niXPAbBxljYOhcw+WbMXSCO7eardlxxq5y7Eh9iJ 2Wng== X-Gm-Message-State: ABuFfojR1bgcJGlR5qYScOmHVcz6iyWrcmSF/JnumL3BH0b4bhXwDHxU hp44nc5ycXbcpVDO4dmjqpe6BotJ X-Google-Smtp-Source: ANB0VdY1txpGmp3jzQJZ7tDMzVSwkdXswWd0h8MFFQdIKFRWo58rSyxAwcsat4xfBbuYy3GlRtCo3g== X-Received: by 2002:a1c:e00a:: with SMTP id x10-v6mr80083wmg.58.1537397431595; Wed, 19 Sep 2018 15:50:31 -0700 (PDT) Received: from 640k.lan (94-36-187-248.adsl-ull.clienti.tiscali.it. [94.36.187.248]) by smtp.gmail.com with ESMTPSA id l10-v6sm46721117wre.0.2018.09.19.15.50.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Sep 2018 15:50:30 -0700 (PDT) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Subject: [PATCH v2 0/3] KVM: VMX: handle preemption timer value of zero Date: Thu, 20 Sep 2018 00:50:26 +0200 Message-Id: <1537397429-38588-1-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP A VMX preemption timer value of '0' at the time of VMEnter is architecturally guaranteed to cause a VMExit prior to the CPU executing any instructions in the guest. KVM serendipitously emulates this behavior when running as L0, but doesn't ensure correct emulation when running at L1 or higher. Explicitly emulate the architectural behavior of a timer value of '0'. v1->v2: - move flag to vmx->loaded_vmcs - extract arming the timer to a separate function instead of using a boolean - clean up SVM Sean Christopherson (3): KVM: VMX: immediately mark preemption timer expired only for zero value KVM: VMX: modify preemption timer bit only when arming timer KVM: VMX: use preemption timer to force immediate VMExit arch/x86/include/asm/kvm_host.h | 2 + arch/x86/kvm/svm.c | 2 + arch/x86/kvm/vmx.c | 94 ++++++++++++++++++++++++++--------------- arch/x86/kvm/x86.c | 8 +++- 4 files changed, 70 insertions(+), 36 deletions(-)