From patchwork Mon Dec 18 19:06:29 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: 10121711 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 A838A60390 for ; Mon, 18 Dec 2017 19:07:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9735628C67 for ; Mon, 18 Dec 2017 19:07:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8B9DF28C6C; Mon, 18 Dec 2017 19:07:21 +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 0C08528C88 for ; Mon, 18 Dec 2017 19:07:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934048AbdLRTHT (ORCPT ); Mon, 18 Dec 2017 14:07:19 -0500 Received: from mx02.bbu.dsd.mx.bitdefender.com ([91.199.104.133]:54614 "EHLO mx02.buh.bitdefender.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933764AbdLRTHC (ORCPT ); Mon, 18 Dec 2017 14:07:02 -0500 Comment: DomainKeys? See http://domainkeys.sourceforge.net/ DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=bitdefender.com; b=fqy0Llp+733gjen8az7QIMnEPV47xDHeaPT7Tw1nGRgqu9lxwIQsKN/PLfv0oGrCe2zoZH/DriCjDHNB2aiiNgVmBSAcDl3780HSP/rCpvEwNQGboX30/0fTRkF1whNoeNgd6aOLet4A3kmouuEXYSBHuFSANrLS2c8NlQCqvVn4XRRu1w1SDxW6qPs8xL4oOlZa/yxYzbKrY/hJSUAgFjQ4gP1TITieWQZKoB6VCmPVdaYhPAG9mdraTpjDqUuErVjng7BQdkxWN4QKPxMrWJzGVhHwDygPFLgtf9B8ULoLKS4pwbom4H1vgUOHDZxyNFazgn0PXYEj1vpuR4d1aQ==; 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=rYNfIWii3 K5hhNRBB0/gGPT6FWs=; b=QC6PreX7OKLbvNNycPPAD3mV0j7FQ62zgftytktFO 5dVPAKD5GMaomkCQA/v58KfW18QEesXk8+erZm84YX+6xoRaGJBBxcjc7ZAoDS1Y TCOXFp9xIE12fhLVofNrKzDYAT1q9bSatKtt4AuoH4/oUwZExaCqYvwdJP00tKhX +eqP01aOFAsdYZjjfkZ0aBog0x4iOqiUShqd0k5M+7XMZBHMIvSxEgsItNl9MGcA VhZcPYTY0MnG5biJpd/vQpmjJkM1E48KIKnOP84+I5AJ1KnuE6ySXIC0eJvoUMxq tfs/xytbs/Cfzphk1lYqSO4cpQfVAEUj9CG8JmFbJHXPQ== Received: (qmail 30713 invoked from network); 18 Dec 2017 21:06:56 +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:56 +0200 Received: (qmail 31348 invoked from network); 18 Dec 2017 21:06:56 +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:56 +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 Subject: [RFC PATCH v4 05/18] kvm: x86: add kvm_arch_vcpu_set_regs() Date: Mon, 18 Dec 2017 21:06:29 +0200 Message-Id: <20171218190642.7790-6-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 This is a version of kvm_arch_vcpu_ioctl_set_regs() which does not touch the exceptions vector. Signed-off-by: Mihai Donțu --- arch/x86/kvm/x86.c | 34 ++++++++++++++++++++++++++++++++++ include/linux/kvm_host.h | 1 + 2 files changed, 35 insertions(+) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index e1a3c2c6ec08..4b0c3692386d 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -7389,6 +7389,40 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) return 0; } +/* + * Similar to kvm_arch_vcpu_ioctl_set_regs() but it does not reset + * the exceptions + */ +void kvm_arch_vcpu_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) +{ + vcpu->arch.emulate_regs_need_sync_from_vcpu = true; + vcpu->arch.emulate_regs_need_sync_to_vcpu = false; + + kvm_register_write(vcpu, VCPU_REGS_RAX, regs->rax); + kvm_register_write(vcpu, VCPU_REGS_RBX, regs->rbx); + kvm_register_write(vcpu, VCPU_REGS_RCX, regs->rcx); + kvm_register_write(vcpu, VCPU_REGS_RDX, regs->rdx); + kvm_register_write(vcpu, VCPU_REGS_RSI, regs->rsi); + kvm_register_write(vcpu, VCPU_REGS_RDI, regs->rdi); + kvm_register_write(vcpu, VCPU_REGS_RSP, regs->rsp); + kvm_register_write(vcpu, VCPU_REGS_RBP, regs->rbp); +#ifdef CONFIG_X86_64 + kvm_register_write(vcpu, VCPU_REGS_R8, regs->r8); + kvm_register_write(vcpu, VCPU_REGS_R9, regs->r9); + kvm_register_write(vcpu, VCPU_REGS_R10, regs->r10); + kvm_register_write(vcpu, VCPU_REGS_R11, regs->r11); + kvm_register_write(vcpu, VCPU_REGS_R12, regs->r12); + kvm_register_write(vcpu, VCPU_REGS_R13, regs->r13); + kvm_register_write(vcpu, VCPU_REGS_R14, regs->r14); + kvm_register_write(vcpu, VCPU_REGS_R15, regs->r15); +#endif + + kvm_rip_write(vcpu, regs->rip); + kvm_set_rflags(vcpu, regs->rflags); + + kvm_make_request(KVM_REQ_EVENT, vcpu); +} + void kvm_get_cs_db_l_bits(struct kvm_vcpu *vcpu, int *db, int *l) { struct kvm_segment cs; diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 6bdd4b9f6611..68e4d756f5c9 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -767,6 +767,7 @@ int kvm_arch_vcpu_ioctl_translate(struct kvm_vcpu *vcpu, int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs); int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs); +void kvm_arch_vcpu_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs); int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs); int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu,