From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94B69C433FE for ; Thu, 9 Sep 2021 11:57:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7C7D763247 for ; Thu, 9 Sep 2021 11:57:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344258AbhIIL6o (ORCPT ); Thu, 9 Sep 2021 07:58:44 -0400 Received: from out30-56.freemail.mail.aliyun.com ([115.124.30.56]:58567 "EHLO out30-56.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244877AbhIIL4g (ORCPT ); Thu, 9 Sep 2021 07:56:36 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R101e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04426;MF=houwenlong93@linux.alibaba.com;NM=1;PH=DS;RN=1;SR=0;TI=SMTPD_---0UnnI4Gp_1631188525; Received: from localhost(mailfrom:houwenlong93@linux.alibaba.com fp:SMTPD_---0UnnI4Gp_1631188525) by smtp.aliyun-inc.com(127.0.0.1); Thu, 09 Sep 2021 19:55:25 +0800 From: Hou Wenlong To: kvm@vger.kernel.org Subject: [PATCH v2 0/3] kvm: x86: some fixes of hypercall emulation Date: Thu, 9 Sep 2021 19:55:22 +0800 Message-Id: X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Currently, use hypercall instruction in guest cpl3 would just skip the instruction, however, that behaviour could trigger a exception in Linux host. It is reasonable for hypervisor to inject a exception, especially in nested guest, L1 guest could behaviour like host. As for hypercall instruction emulation, hypervisor would replace the wrong instruction with the right instruction instead of the real instruction emulation. It's guest's responsibility to use the right instruction, hypervisor could emulate it but shouldn't modify it without guest's request. At present, Linux guest could use alternative to choose right instruction, and hyperv guest could use hypercall to modify instruction. So just do the real instruction emualtion job for em_hypercall(). change from v1: v1 is wrong edition, sent by mistake Hou Wenlong (3): kvm: x86: Introduce hypercall x86 ops for handling hypercall not in cpl0 kvm: x86: Refactor kvm_emulate_hypercall() to no skip instruction kvm: x86: Emulate hypercall instead of fixing hypercall instruction arch/x86/include/asm/kvm-x86-ops.h | 1 + arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/emulate.c | 20 +++++------ arch/x86/kvm/kvm_emulate.h | 2 +- arch/x86/kvm/svm/svm.c | 6 ++++ arch/x86/kvm/vmx/vmx.c | 9 +++++ arch/x86/kvm/x86.c | 55 +++++++++++++++++------------- 7 files changed, 59 insertions(+), 35 deletions(-) -- 2.31.1