Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3108100pxj; Mon, 7 Jun 2021 02:27:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyA99TkOOZZhsGJ/3eQE8fq3fFjcUXbVIBvEQFF4IkwAGY3q2VcbEaR9T21RbsWPSdQRMHG X-Received: by 2002:a17:906:9455:: with SMTP id z21mr16599806ejx.491.1623058029059; Mon, 07 Jun 2021 02:27:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623058029; cv=none; d=google.com; s=arc-20160816; b=Tm0QSEChp5T/QU5O70ZR5azVsrLIVd9h6fWve6mT/EoHwWBSzDYhgQfgHJ6usPr/Kq rvTV2pEQ/Lt5drYhErjhKN5wLFcDgzZByTuIJcGEYCV7YbCaXm79W/uNngqr2pJ3TYCZ 35pzWqtOO1iA3379tW0TTFBukFN0U3oS/zva2Q/soXQjw7NBsYG+O4ANuRsJHCi3Ytog rdztGLbFRjZmWZGPBiowmYGpmnj7D/OCDCsXhQmMbkTsYNDq9+YaSc+VHP4j+DELXNGV jfiFvqsDhG9bfxi3IiZb1AuvrHSe1fxBw/VZG/m8jHDhmAisjczX3T0bgZq5T2PU8ZbH pvfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:ironport-sdr:ironport-sdr; bh=NhulMJs7Jelix96BJoPc28PIy7kpmoOGFNu5fU1WY+M=; b=x+3qWkcUvuYDZvP3MQITwNAlXuA9z08hJwgLabD7CAJNMQJdvypgnd8uDmlB1/ihHH XSSCaZirgryLB5LtHznLBcCIcXlDP+d30Bc9Chk4k2PR30rvp07BFM52t8h5Ob+Gf1/3 vz90C7sl06Wpd+MxNz3ImA+7DFQ4taX5DFqC96t+S9l5EWnmHL4jZT5XagLr1EeBZNve KVuwsP4+mT3dTVD/Wd9TrY4zGLC6QHgHpbcNyGKShKVbh4BOJa7OnEpHNQT05Siihjf2 OEhvug0V9Jrx0pCGZzQPDKqZHh3RCk+2VTbR/NxwpMAUWYP74sCeTq+2KkB+7gdKlefi NJyA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a10si11690594ejg.385.2021.06.07.02.26.45; Mon, 07 Jun 2021 02:27:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230359AbhFGJ01 (ORCPT + 99 others); Mon, 7 Jun 2021 05:26:27 -0400 Received: from mga17.intel.com ([192.55.52.151]:53714 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230377AbhFGJ00 (ORCPT ); Mon, 7 Jun 2021 05:26:26 -0400 IronPort-SDR: 3nW1UlkcZe/lVpBoKdKR9+gBgZIleKLUEbuk/tCRwqEd3BCgd13a/rRM4tuEiMfG2hK9hLoXIM 4iIs03pAnWwQ== X-IronPort-AV: E=McAfee;i="6200,9189,10007"; a="184960116" X-IronPort-AV: E=Sophos;i="5.83,254,1616482800"; d="scan'208";a="184960116" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jun 2021 02:24:35 -0700 IronPort-SDR: H6qbyRFJ/MHnRqv3D+hTigkPHyRbAHxvuy0WSOeMAQw7MxRPt0huXCAa2cebxDTbT6r6Tefd0t XltBpOBDbAnQ== X-IronPort-AV: E=Sophos;i="5.83,254,1616482800"; d="scan'208";a="447424080" Received: from yujie-nuc.sh.intel.com (HELO [10.239.13.110]) ([10.239.13.110]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jun 2021 02:24:32 -0700 Subject: Re: [PATCH v2] KVM: VMX: Enable Notify VM exit To: Jim Mattson Cc: Vitaly Kuznetsov , Tao Xu , the arch/x86 maintainers , kvm list , LKML , Paolo Bonzini , Sean Christopherson , Wanpeng Li , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" References: <20210525051204.1480610-1-tao3.xu@intel.com> <871r9k36ds.fsf@vitty.brq.redhat.com> <660ceed2-7569-6ce6-627a-9a4e860b8aa9@intel.com> From: Xiaoyao Li Message-ID: Date: Mon, 7 Jun 2021 17:24:30 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/3/2021 9:35 PM, Jim Mattson wrote: > On Wed, Jun 2, 2021 at 6:25 PM Xiaoyao Li wrote: >> >> On 6/2/2021 6:31 PM, Vitaly Kuznetsov wrote: >>> Tao Xu writes: >>> >>>> There are some cases that malicious virtual machines can cause CPU stuck >>>> (event windows don't open up), e.g., infinite loop in microcode when >>>> nested #AC (CVE-2015-5307). No event window obviously means no events, >>>> e.g. NMIs, SMIs, and IRQs will all be blocked, may cause the related >>>> hardware CPU can't be used by host or other VM. >>>> >>>> To resolve those cases, it can enable a notify VM exit if no event >>>> window occur in VMX non-root mode for a specified amount of time >>>> (notify window). Since CPU is first observed the risk of not causing >>>> forward progress, after notify window time in a units of crystal clock, >>>> Notify VM exit will happen. Notify VM exit can happen incident to delivery >>>> of a vectored event. >>>> >>>> Expose a module param for configuring notify window, which is in unit of >>>> crystal clock cycle. >>>> - A negative value (e.g. -1) is to disable this feature. >>>> - Make the default as 0. It is safe because an internal threshold is added >>>> to notify window to ensure all the normal instructions being coverd. >>>> - User can set it to a large value when they want to give more cycles to >>>> wait for some reasons, e.g., silicon wrongly kill some normal instruction >>>> due to internal threshold is too small. >>>> >>>> Notify VM exit is defined in latest Intel Architecture Instruction Set >>>> Extensions Programming Reference, chapter 9.2. >>>> >>>> Co-developed-by: Xiaoyao Li >>>> Signed-off-by: Xiaoyao Li >>>> Signed-off-by: Tao Xu >>>> --- >>>> >>>> Changelog: >>>> v2: >>>> Default set notify window to 0, less than 0 to disable. >>>> Add more description in commit message. >>> >>> Sorry if this was already discussed, but in case of nested >>> virtualization and when L1 also enables >>> SECONDARY_EXEC_NOTIFY_VM_EXITING, shouldn't we just reflect NOTIFY exits >>> during L2 execution to L1 instead of crashing the whole L1? >>> >> >> yes. If we expose it to nested, it should reflect the Notify VM exit to >> L1 when L1 enables it. >> >> But regarding nested, there are more things need to be discussed. e.g., >> 1) It has dependence between L0 and L1, for security consideration. When >> L0 enables it, it shouldn't be turned off during L2 VM is running. >> a. Don't expose to L1 but enable for L1 when L2 VM is running. >> b. expose it to L1 and force it enabled. >> >> 2) When expose it to L1, vmcs02.notify_window needs to be >> min(L0.notify_window, L1.nofity_window) > > I don't think this can be a simple 'min', since L1's clock may run at > a different frequency from L0's clock. > Good catch. We will take it into account. thanks!