From patchwork Mon Dec 18 19:06:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Adalbert_Laz=C4=83r?= X-Patchwork-Id: 10121713 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C11E160390 for ; Mon, 18 Dec 2017 19:07:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AFD4028C56 for ; Mon, 18 Dec 2017 19:07:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A4B7228C6C; Mon, 18 Dec 2017 19:07:27 +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.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI 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 16AF228C56 for ; Mon, 18 Dec 2017 19:07:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934254AbdLRTHZ (ORCPT ); Mon, 18 Dec 2017 14:07:25 -0500 Received: from mx02.bbu.dsd.mx.bitdefender.com ([91.199.104.133]:54732 "EHLO mx02.buh.bitdefender.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933847AbdLRTHO (ORCPT ); Mon, 18 Dec 2017 14:07:14 -0500 Comment: DomainKeys? See http://domainkeys.sourceforge.net/ DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=bitdefender.com; b=ibELwXOKzwCXufvIALVApyv0Goj002gQ2lm0ZZzPhrbSOm4E749g9mMrAvV5+B9GwYPaVxHuF5ieDR9ndazQ31nML8awXYc5z/xqYvF04swGq2PxrwDNu/TOD8zSpjm7ieVNqkv+KA+GndfK6W/TElrnRFZD87H9+737QWNWPnlff89Krnvwtz8sP+5ou3K/G4mIlBQJON4wcUpGWKEj2AXskQiw2eYgWbMivX2WunhYUUI7dSgtk1+sHbsjiFymnEO5nvoMEa8W6ZTq+k6WcX79ZJvddV2j1RTVlVirRfgDomRBFMBzRMFx3mpRY+a32PS6bmCaPTG6UJq5lXxJLA==; h=Received:Received:Received:Received:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References:MIME-Version:Content-Type:Content-Transfer-Encoding; DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=bitdefender.com; h=from:to :cc:subject:date:message-id:in-reply-to:references:mime-version :content-type:content-transfer-encoding; s=default; bh=ezQHHPHsg +mDu1ohpoYcEDvggGg=; b=KqOLcfnw4QsRkxrJRdoo2OpLe36KW1tBq/wG9LJj5 P+VqdaoTKUgl3exSUNDJH+NrpUCPuoWpDa9ch7kJw6JpkY97MFEMNGpPZSbEIhUv 7MDH58lnSbN10NBSSrBMQSP0/2RHWoSNe6lpwZ0V5R4UbNL5iB7+IqgEWYFohpwL /2VwFjYC7j62cUlStb9SIJa5K6FPwU02MXrQEDqWBkRU3b7xsxoFi/a6pXJx9UBh uMZYooaIvxfwFBWSjz0dCdbeGNMqUEsW/Kt1qRR7X4Kj+8JwZEypwKyp3/GA7kdl 47eMgIlR4RBvqg/uhxjl0XNN2U/EGOCJ+KZyNDrG9azhQ== Received: (qmail 30967 invoked from network); 18 Dec 2017 21:06:57 +0200 Received: from mx01robo.bbu.dsd.mx.bitdefender.com (10.17.80.60) by mx02.buh.bitdefender.com with AES128-GCM-SHA256 encrypted SMTP; 18 Dec 2017 21:06:57 +0200 Received: (qmail 31445 invoked from network); 18 Dec 2017 21:06:57 +0200 Received: from unknown (HELO host.bbu.bitdefender.biz) (10.10.193.111) by mx01robo.bbu.dsd.mx.bitdefender.com with SMTP; 18 Dec 2017 21:06:57 +0200 From: =?UTF-8?q?Adalber=20Laz=C4=83r?= To: kvm@vger.kernel.org Cc: linux-mm@kvack.org, Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Xiao Guangrong , =?UTF-8?q?Mihai=20Don=C8=9Bu?= , Adalbert Lazar , =?UTF-8?q?Mircea=20C=C3=AErjaliu?= , =?UTF-8?q?Nicu=C8=99or=20C=C3=AE=C8=9Bu?= Subject: [RFC PATCH v4 17/18] kvm: x86: handle the introspection hypercalls Date: Mon, 18 Dec 2017 21:06:41 +0200 Message-Id: <20171218190642.7790-18-alazar@bitdefender.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171218190642.7790-1-alazar@bitdefender.com> References: <20171218190642.7790-1-alazar@bitdefender.com> MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Adalbert Lazar Two hypercalls (KVM_HC_MEM_MAP, KVM_HC_MEM_UNMAP) are used by the introspection tool running in a VM to map/unmap memory from the introspected VM-s. The third hypercall (KVM_HC_XEN_HVM_OP) is used by the code residing inside the introspected guest to call the introspection tool and to report certain details about its operation. For example, a classic antimalware remediation tool can report what it has found during a scan. Signed-off-by: Mircea Cîrjaliu Signed-off-by: Nicușor Cîțu --- arch/x86/kvm/x86.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 271028ccbeca..9a3c315b13e4 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -6333,7 +6333,8 @@ int kvm_emulate_hypercall(struct kvm_vcpu *vcpu) r = kvm_skip_emulated_instruction(vcpu); - if (kvm_hv_hypercall_enabled(vcpu->kvm)) + if (kvm_hv_hypercall_enabled(vcpu->kvm) + && !kvmi_is_agent_hypercall(vcpu)) return kvm_hv_hypercall(vcpu); nr = kvm_register_read(vcpu, VCPU_REGS_RAX); @@ -6371,6 +6372,16 @@ int kvm_emulate_hypercall(struct kvm_vcpu *vcpu) ret = kvm_pv_clock_pairing(vcpu, a0, a1); break; #endif + case KVM_HC_MEM_MAP: + ret = kvmi_host_mem_map(vcpu, (gva_t)a0, (gpa_t)a1, (gpa_t)a2); + break; + case KVM_HC_MEM_UNMAP: + ret = kvmi_host_mem_unmap(vcpu, (gpa_t)a0); + break; + case KVM_HC_XEN_HVM_OP: + kvmi_hypercall_event(vcpu); + ret = 0; + break; default: ret = -KVM_ENOSYS; break;