From patchwork Sat Nov 25 20:57:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10075159 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 6C74060383 for ; Sat, 25 Nov 2017 20:59:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E0C5286EC for ; Sat, 25 Nov 2017 20:59:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 52FA228B53; Sat, 25 Nov 2017 20:59:15 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D264F286EC for ; Sat, 25 Nov 2017 20:59:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=OrB3rW5E8hzr/5W+RqaM2lW2BVJMuSU43Fyni5sZA3A=; b=bEkY9oJ+5q4udPDCIavY1fp+d8 Du48It3Z8rte8VSIBXe9ZESGf4+ZU8UGqxpfgAt/mFECt270A5j9sypE3vW5+nbx8lWDr+wNdk43e bEztNEQ50OTPudPivXBGFmFlAxS2KOS7Qe1ppW6fWGFm6k22ubiOOlM3s+RBh23ifg4lFsRdqcB+7 dW+tXKXD76lD46VsWXd6oqdGMWr3bgJzD78wMnKZivnKakr1UUtgr7eMG1JJGZAeABR1T2YWHZ5oT eDf/NFTLm1lrSermKhP42Ax6pOSABketYlTimanCT4BIiwuXNdA0k5dJfMCNVpf49p47em239GmK2 0PHzxscw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eIhXb-0006P5-Kf; Sat, 25 Nov 2017 20:59:11 +0000 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eIhW6-00059B-Rc for linux-arm-kernel@lists.infradead.org; Sat, 25 Nov 2017 20:57:42 +0000 Received: by mail-wr0-x241.google.com with SMTP id z75so21667365wrc.5 for ; Sat, 25 Nov 2017 12:57:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Ny0zQ+6naqJMxg1v/kJ/YPA9h7EUYTci1EyO77zJsR4=; b=g2ViyK/MzyoMoEFdnbmi+BqUN99BcKKbMU9UGchF6f3YdwajaaLqfhSknHJWrwuWr1 KnOx3SYfZuSnecQ8TP2Zw8QCA9Qj0ZyPQiWnQD83vN446kSkSAD8PG0v7bNOoXTiNXvn a/GhPf7HLEHwDpNozQeFtr7L8JyWsoRqIKxU8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Ny0zQ+6naqJMxg1v/kJ/YPA9h7EUYTci1EyO77zJsR4=; b=JWWT2Fro+VD5nKi7mEfRfn2O5NfHJY6ZlmqLQM0f6u9jopefw/t81BnObu7P7+9uLX iTQbNEntXknOHBXFPJGgo5LohjbZGWgmO05m6NL1yHdBCEXQjNO9dc8wYN/Eg9TKv8wx vOv4bUsibMEVypwPhnvfkHz6ozlUrjvVfP9wJOIzIkBbLrXVdo9OXaEINxWxVOVhXecG mMUVrpAiflYn/yw/3qyViP+RhDK6rAVL1gF15ll+iEeZyOrt0dUX461e0z46t5CP9Urv +UGgODnP9S3bojMvN/NsjY8wGlvJwnG61aPD6bUZGTsHrsz5+FEGRLYsI15pA781yJSQ sVSw== X-Gm-Message-State: AJaThX698T6iNZZKfG9PqmDRqCYss++pHkkRjzhpLLIDeCpBWEDjOtnx j2Uqv/wZe9jKQ0bF+ucKzkVhWg== X-Google-Smtp-Source: AGs4zMYKFb7fmiNucBb/gPEXoeTfF7v4CWcLVQpmvh7FdcTHeVDk69ZDD8AA9Q23TTlyIBt1D9gGoQ== X-Received: by 10.223.202.1 with SMTP id o1mr29369757wrh.233.1511643440219; Sat, 25 Nov 2017 12:57:20 -0800 (PST) Received: from localhost.localdomain (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id z37sm15157577wrc.31.2017.11.25.12.57.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 25 Nov 2017 12:57:19 -0800 (PST) From: Christoffer Dall To: kvm@vger.kernel.org Subject: [PATCH 05/15] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_set_regs Date: Sat, 25 Nov 2017 21:57:08 +0100 Message-Id: <20171125205718.7731-6-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171125205718.7731-1-christoffer.dall@linaro.org> References: <20171125205718.7731-1-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171125_125739_262066_33F0FB81 X-CRM114-Status: GOOD ( 12.53 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mips@linux-mips.org, Andrew Jones , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Marc Zyngier , James Hogan , Cornelia Huck , Christian Borntraeger , kvm-ppc@vger.kernel.org, Alexander Graf , linux-arm-kernel@lists.infradead.org, Paolo Bonzini , linux-s390@vger.kernel.org, kvmarm@lists.cs.columbia.edu, Christoffer Dall MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Move vcpu_load() and vcpu_put() into the architecture specific implementations of kvm_arch_vcpu_ioctl_set_regs(). Signed-off-by: Christoffer Dall --- arch/mips/kvm/mips.c | 6 ++++++ arch/powerpc/kvm/book3s.c | 6 ++++++ arch/powerpc/kvm/booke.c | 6 ++++++ arch/s390/kvm/kvm-s390.c | 6 ++++++ arch/x86/kvm/x86.c | 7 +++++++ virt/kvm/kvm_main.c | 4 ---- 6 files changed, 31 insertions(+), 4 deletions(-) diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c index 1cb1020e044f..55d2e6e2c4e6 100644 --- a/arch/mips/kvm/mips.c +++ b/arch/mips/kvm/mips.c @@ -1153,8 +1153,13 @@ int kvm_arch_vcpu_dump_regs(struct kvm_vcpu *vcpu) int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) { + int r; int i; + r = vcpu_load(vcpu); + if (r) + return r; + for (i = 1; i < ARRAY_SIZE(vcpu->arch.gprs); i++) vcpu->arch.gprs[i] = regs->gpr[i]; vcpu->arch.gprs[0] = 0; /* zero is special, and cannot be set. */ @@ -1162,6 +1167,7 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) vcpu->arch.lo = regs->lo; vcpu->arch.pc = regs->pc; + vcpu_put(vcpu); return 0; } diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c index 04cfe6749858..047d3178d70f 100644 --- a/arch/powerpc/kvm/book3s.c +++ b/arch/powerpc/kvm/book3s.c @@ -529,8 +529,13 @@ 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) { + int r; int i; + r = vcpu_load(vcpu); + if (r) + return r; + kvmppc_set_pc(vcpu, regs->pc); kvmppc_set_cr(vcpu, regs->cr); kvmppc_set_ctr(vcpu, regs->ctr); @@ -551,6 +556,7 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) for (i = 0; i < ARRAY_SIZE(regs->gpr); i++) kvmppc_set_gpr(vcpu, i, regs->gpr[i]); + vcpu_put(vcpu); return 0; } diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index 19b6299a5aad..47b3d11345ed 100644 --- a/arch/powerpc/kvm/booke.c +++ b/arch/powerpc/kvm/booke.c @@ -1464,8 +1464,13 @@ 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) { + int r; int i; + r = vcpu_load(vcpu); + if (r) + return r; + vcpu->arch.pc = regs->pc; kvmppc_set_cr(vcpu, regs->cr); vcpu->arch.ctr = regs->ctr; @@ -1487,6 +1492,7 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) for (i = 0; i < ARRAY_SIZE(regs->gpr); i++) kvmppc_set_gpr(vcpu, i, regs->gpr[i]); + vcpu_put(vcpu); return 0; } diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index 51ad3c6fc694..eb2724d6e524 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -2713,7 +2713,13 @@ static int kvm_arch_vcpu_ioctl_initial_reset(struct kvm_vcpu *vcpu) int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) { + int r; + + r = vcpu_load(vcpu); + if (r) + return r; memcpy(&vcpu->run->s.regs.gprs, ®s->gprs, sizeof(regs->gprs)); + vcpu_put(vcpu); return 0; } diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index f6594eb2b3be..e4e34af97ba0 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -7329,6 +7329,12 @@ 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) { + int r; + + r = vcpu_load(vcpu); + if (r) + return r; + vcpu->arch.emulate_regs_need_sync_from_vcpu = true; vcpu->arch.emulate_regs_need_sync_to_vcpu = false; @@ -7358,6 +7364,7 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) kvm_make_request(KVM_REQ_EVENT, vcpu); + vcpu_put(vcpu); return 0; } diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 759f3a1e042e..7671ebb5971f 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -2580,11 +2580,7 @@ static long kvm_vcpu_ioctl(struct file *filp, r = PTR_ERR(kvm_regs); goto out; } - r = vcpu_load(vcpu); - if (r) - goto out; r = kvm_arch_vcpu_ioctl_set_regs(vcpu, kvm_regs); - vcpu_put(vcpu); kfree(kvm_regs); break; }