Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp3715098pxu; Sun, 11 Oct 2020 21:42:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDRZCOxHajCmJU65Q8QSt7raDv659RnJF6YlBrSIDhPyD6WZC/LOWlkTz2ImeKbnLchosq X-Received: by 2002:a05:6402:22b5:: with SMTP id cx21mr12550734edb.101.1602477728673; Sun, 11 Oct 2020 21:42:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602477728; cv=none; d=google.com; s=arc-20160816; b=Ti2e7cJbObRF8jdQvchtey9SYH+3ENathRpMloIPtyHEJv++LYQx1K1D2Q4OcJ0tVP LXmB/Kr4mo4ubZbEdDWqcKnUzTs5Pn9Z1YYn7IB0sQ26Up4nWK0QhaufKle93u4p6poi SzQdMLI5KGMOAq72t9tVaKlcFYYt6XeL5nFl6B5tlcd7H6Mgodq11TAlXXV8yc0sut6s RqN4GhLN0bYcG44mV4/iNNoQcPTkhQBeQ4pYBkmd6PMPab+CyFqnn2vqu3rGFPMH8Odo mXiS86pTASfv7BvmU4VTSJOhD6YTRws3aMSPrXiDsRvZjgfGmoz/QFlV/v6vVKQbKQGv RuAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from:ironport-sdr :ironport-sdr; bh=hXnMLXqhbfSDMseGZQ3auUcVtnByD8RfMHHw1nEfTOs=; b=BBTl/4K1MaOA4oKnGouSKdKrNkDO2jBKDsFngKXV9899O41NsHnOnwyD0k8diJ8cso qAEWQoot7fN5x0UuWcJQ8ANkM7F1EaXBqBfrz4r0OF56ENsx1KwZLZUaOA8I7LSy7AD5 7Ck26nFivdbnhLyUKHmr548irMxmcv+tVraJ1U3h2xzOCBhvKpAA/1MFxiMO10FZvzDZ r1IEdeiNeRGBPTluOC1KB467SHX65Gaym/f6iDR6oBWC3Nr0Ewnoo/vZ63rI0/eWvLzX x+6fnWw+sthbEHrRIwO2G8W4G6ZB3K/YJGkqAuWkkK5w8ffATViAPrYqLiqSzuBPRhIo Llkw== 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 g9si11574849edr.404.2020.10.11.21.41.46; Sun, 11 Oct 2020 21:42:08 -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 S1727412AbgJLDdg (ORCPT + 99 others); Sun, 11 Oct 2020 23:33:36 -0400 Received: from mga04.intel.com ([192.55.52.120]:62770 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727312AbgJLDdd (ORCPT ); Sun, 11 Oct 2020 23:33:33 -0400 IronPort-SDR: NCP7zwpDyJfGpqtjqBMPAvrywDOMs2I/4USfx2fjw6CgB1bYwi1JrTEm/mL2ukVoY5VJDrZt/k 1GWvDpmm0k5A== X-IronPort-AV: E=McAfee;i="6000,8403,9771"; a="163046217" X-IronPort-AV: E=Sophos;i="5.77,365,1596524400"; d="scan'208";a="163046217" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2020 20:33:31 -0700 IronPort-SDR: I4kBjAynaAr6A8rjDbaP6xW9BLdI7JcpeqY7/MH778QiFWLbJ8RS12E/HvdYKaLk02EziWOFiF DQ0MvsYVhM9Q== X-IronPort-AV: E=Sophos;i="5.77,365,1596524400"; d="scan'208";a="529780076" Received: from chenyi-pc.sh.intel.com ([10.239.159.72]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2020 20:33:28 -0700 From: Chenyi Qiang To: Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Xiaoyao Li Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RESEND v4 0/2] Add bus lock VM exit support Date: Mon, 12 Oct 2020 11:35:40 +0800 Message-Id: <20201012033542.4696-1-chenyi.qiang@intel.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch series add the support for bus lock VM exit in KVM. It is a sub-feature of bus lock detection. When it is enabled by the VMM, the processor generates a "Bus Lock" VM exit following execution of an instruction if the processor detects that one or more bus locks were caused the instruction was being executed (due to either direct access by the instruction or stuffed accesses like through A/D updates). This first patch applies Sean's refactor for vcpu_vmx.exit_reason available at https://patchwork.kernel.org/patch/11500659. It is necessary as bus lock VM exit adds a new modifier bit(bit 26) in exit_reason field in VMCS. The second patch is the enabling work for bus lock VM exit. Add the support to set the capability to enable bus lock vm exit. The current implementation just exit to user space when handling the bus lock detected in guest. The concrete throttling policy in user space is still to be discussed. We can enforce ratelimit on bus lock in guest, inject some sleep time or maybe other ideas. Document for Bus Lock Detection is now available at the latest "Intel Architecture Instruction Set Extensions Programming Reference". Document Link: https://software.intel.com/content/www/us/en/develop/download/intel-architecture-instruction-set-extensions-programming-reference.html --- Changelogs v3->v4: - rebase on top of v5.9 - some code cleanup. - v3:https://lore.kernel.org/lkml/20200910083751.26686-1-chenyi.qiang@intel.com/ v2->v3: - use a bitmap to get/set the capability of bus lock detection. we support exit and off mode currently. - put the handle of exiting to userspace in vmx.c, thus no need to define a shadow to track vmx->exit_reason.bus_lock_detected. - remove the vcpu->stats.bus_locks since every bus lock exits to userspace. - v2:https://lore.kernel.org/lkml/20200817033604.5836-1-chenyi.qiang@intel.com/ v1->v2: - resolve Vitaly's comment to introduce the KVM_EXIT_BUS_LOCK and a capability to enable it. - add the support to exit to user space when handling bus locks. - extend the vcpu->run->flags to indicate bus lock detected for other exit reasons when exiting to user space. - v1:https://lore.kernel.org/lkml/20200628085341.5107-1-chenyi.qiang@intel.com/ --- Chenyi Qiang (1): KVM: VMX: Enable bus lock VM exit Sean Christopherson (1): KVM: VMX: Convert vcpu_vmx.exit_reason to a union arch/x86/include/asm/kvm_host.h | 7 ++ arch/x86/include/asm/vmx.h | 1 + arch/x86/include/asm/vmxfeatures.h | 1 + arch/x86/include/uapi/asm/kvm.h | 1 + arch/x86/include/uapi/asm/vmx.h | 4 +- arch/x86/kvm/vmx/capabilities.h | 6 ++ arch/x86/kvm/vmx/nested.c | 42 +++++++----- arch/x86/kvm/vmx/vmx.c | 103 +++++++++++++++++++---------- arch/x86/kvm/vmx/vmx.h | 25 ++++++- arch/x86/kvm/x86.c | 29 +++++++- include/uapi/linux/kvm.h | 5 ++ 11 files changed, 172 insertions(+), 52 deletions(-) -- 2.17.1