From patchwork Tue May 24 14:02:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chenyi Qiang X-Patchwork-Id: 12860208 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F1E26C433EF for ; Tue, 24 May 2022 14:00:24 +0000 (UTC) Received: from localhost ([::1]:47792 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntV5D-00063I-TJ for qemu-devel@archiver.kernel.org; Tue, 24 May 2022 10:00:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43546) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntV1p-0000uo-Tl for qemu-devel@nongnu.org; Tue, 24 May 2022 09:56:54 -0400 Received: from mga05.intel.com ([192.55.52.43]:62573) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntV1n-0003Gp-56 for qemu-devel@nongnu.org; Tue, 24 May 2022 09:56:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1653400611; x=1684936611; h=from:to:cc:subject:date:message-id; bh=gY5w/fc1CrCywA3P9SvJffDd0T+qKJWSCObbmR+/MR4=; b=X6hrc0/hTKRB4M7s0xDgLc8Q6vpIcFaIbkad5C3uIUOmPGx3ZBVUU5FW 4OBQZTIx3ZS38PtDMRw2+vXzj6hdEuWkJxxzT+0CA+zESw/8RjZHdjwLa QgVLmDX/tC8MNkg36xwwJk5EGbxdsm8xjB9PJqbRBigtDmx6YODt2WBvt iorSktKyGupvSFc58IFMfdDOJRmc8o4z9LOIiW0OgoVWchYYlSod6ezH9 RHdv68VYdILHXY22+8pthaK6uicDDy8vy5Pi/qTchIRGjsJn9OpxKBYUo dITeuyczoW6a7UssvVYHdy3fBCiUbmsi+vPs0W9vNRFWZxrMDUyruo0Nw Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10356"; a="359928356" X-IronPort-AV: E=Sophos;i="5.91,248,1647327600"; d="scan'208";a="359928356" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2022 06:56:47 -0700 X-IronPort-AV: E=Sophos;i="5.91,248,1647327600"; d="scan'208";a="717179414" Received: from chenyi-pc.sh.intel.com ([10.239.159.73]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2022 06:56:45 -0700 From: Chenyi Qiang To: Paolo Bonzini , Sean Christopherson , Richard Henderson , Eduardo Habkost , Marcelo Tosatti , Xiaoyao Li Cc: Chenyi Qiang , qemu-devel@nongnu.org, kvm@vger.kernel.org Subject: [PATCH v4 0/3] Enable notify VM exit Date: Tue, 24 May 2022 22:02:59 +0800 Message-Id: <20220524140302.23272-1-chenyi.qiang@intel.com> X-Mailer: git-send-email 2.17.1 Received-SPF: pass client-ip=192.55.52.43; envelope-from=chenyi.qiang@intel.com; helo=mga05.intel.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Notify VM exit is introduced to mitigate the potential DOS attach from malicious VM. This series is the userspace part to enable this feature through a new KVM capability KVM_CAP_X86_NOTIFY_VMEXIT. The detailed info can be seen in Patch 3. The corresponding KVM patches are avaiable at: https://lore.kernel.org/lkml/20220524135624.22988-1-chenyi.qiang@intel.com/ --- Change logs: v3 -> v4 - Add a new KVM cap KVM_CAP_TRIPLE_FAULT_EVENT to guard the extension of triple fault event save&restore. - v3: https://lore.kernel.org/qemu-devel/20220421074028.18196-1-chenyi.qiang@intel.com/ v2 -> v3 - Extend the argument to include both the notify window and some flags when enabling KVM_CAP_X86_BUS_LOCK_EXIT CAP. - Change to use KVM_VCPUEVENTS_VALID_TRIPLE_FAULT in flags field and add pending_triple_fault field in struct kvm_vcpu_events. - v2: https://lore.kernel.org/qemu-devel/20220318082934.25030-1-chenyi.qiang@intel.com/ v1 -> v2 - Add some commit message to explain why we disable Notify VM exit by default. - Rename KVM_VCPUEVENT_SHUTDOWN to KVM_VCPUEVENT_TRIPLE_FAULT. - Do the corresponding change to use the KVM_VCPUEVENTS_TRIPLE_FAULT to save/restore the triple fault event to avoid lose some synthesized triple fault from KVM. - v1: https://lore.kernel.org/qemu-devel/20220310090205.10645-1-chenyi.qiang@intel.com/ --- Chenyi Qiang (3): linux-header: update linux header i386: kvm: extend kvm_{get, put}_vcpu_events to support pending triple fault i386: Add notify VM exit support hw/i386/x86.c | 45 +++++++++++++++++++ include/hw/i386/x86.h | 5 +++ linux-headers/asm-x86/kvm.h | 6 ++- linux-headers/linux/kvm.h | 11 +++++ target/i386/cpu.c | 1 + target/i386/cpu.h | 1 + target/i386/kvm/kvm.c | 86 ++++++++++++++++++++++++++++--------- 7 files changed, 134 insertions(+), 21 deletions(-)