From patchwork Wed Dec 3 20:17:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 41877 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B9A7325E88 for ; Wed, 3 Dec 2014 20:17:16 +0000 (UTC) Received: by mail-lb0-f197.google.com with SMTP id n15sf10032646lbi.8 for ; Wed, 03 Dec 2014 12:17:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:cc:subject:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:errors-to:sender :x-original-sender:x-original-authentication-results:mailing-list; bh=xePXNS17LBRNMbmjPZ5uKWUISC5wcywOiPz6YjTxk60=; b=Lq5M8iQXz9l9bhMsrkrbyKMrVnmPVbVQAhezFPyCPyG17e0LiDtclDR1paWhV/9gsH yfTX20O0mXb0bdpbf/HqQsPsTM9Q23we8Vn1M8L1Ro6+HHNw89WoixpL7IPB6owpjPtb 6ggB8TmF6BqQwzmUpsJSg/T3Ua8CO5nVxtju61CqSonsXC+ycT5q9L3luw4DlkBbUqLk kKSTZwHtFOKGpCPKnbMDBHkSt1J7U9jKjCV417VbbOSDMwP997l+8mU/dCg8ZHgXugGV UXVskd5TbauSrAE3Fi+1gPetA4Nk4CKrN+NBtYjrzid3eMYlhEWsQr1Tuz+4wfhA4Vai JKfA== X-Gm-Message-State: ALoCoQnsrLXRkcvgD7y80Uo386wgbAZjj5eHaqlJOCgfpdFNJPFXNpgz1u1i6qMq/bgRXy/161DO X-Received: by 10.152.6.133 with SMTP id b5mr9543laa.10.1417637835730; Wed, 03 Dec 2014 12:17:15 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.6.134 with SMTP id b6ls96709laa.27.gmail; Wed, 03 Dec 2014 12:17:15 -0800 (PST) X-Received: by 10.152.8.194 with SMTP id t2mr5881709laa.21.1417637835390; Wed, 03 Dec 2014 12:17:15 -0800 (PST) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com. [209.85.215.51]) by mx.google.com with ESMTPS id q13si23992473laa.27.2014.12.03.12.17.15 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 03 Dec 2014 12:17:15 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) client-ip=209.85.215.51; Received: by mail-la0-f51.google.com with SMTP id ms9so13165343lab.10 for ; Wed, 03 Dec 2014 12:17:15 -0800 (PST) X-Received: by 10.152.21.66 with SMTP id t2mr5826783lae.27.1417637835271; Wed, 03 Dec 2014 12:17:15 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp732327lbc; Wed, 3 Dec 2014 12:17:14 -0800 (PST) X-Received: by 10.180.107.136 with SMTP id hc8mr5940355wib.32.1417637834613; Wed, 03 Dec 2014 12:17:14 -0800 (PST) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id eu6si41563780wjb.48.2014.12.03.12.17.14 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 03 Dec 2014 12:17:14 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:43236 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XwGML-0004Ne-BM for patch@linaro.org; Wed, 03 Dec 2014 15:17:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57038) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XwGLZ-0003iA-Ip for qemu-devel@nongnu.org; Wed, 03 Dec 2014 15:16:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XwGLT-0000Mb-LR for qemu-devel@nongnu.org; Wed, 03 Dec 2014 15:16:25 -0500 Received: from mail-lb0-f179.google.com ([209.85.217.179]:63470) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XwGLT-0000MS-DW for qemu-devel@nongnu.org; Wed, 03 Dec 2014 15:16:19 -0500 Received: by mail-lb0-f179.google.com with SMTP id z11so12820880lbi.38 for ; Wed, 03 Dec 2014 12:16:18 -0800 (PST) X-Received: by 10.152.19.71 with SMTP id c7mr5888405lae.79.1417637778562; Wed, 03 Dec 2014 12:16:18 -0800 (PST) Received: from localhost.localdomain (188-178-240-98-static.dk.customer.tdc.net. [188.178.240.98]) by mx.google.com with ESMTPSA id kf6sm6703134lbc.44.2014.12.03.12.16.17 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 03 Dec 2014 12:16:17 -0800 (PST) From: Christoffer Dall To: qemu-devel@nongnu.org Date: Wed, 3 Dec 2014 21:17:02 +0100 Message-Id: <1417637822-28984-1-git-send-email-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.1.2.330.g565301e.dirty X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.217.179 Cc: kvmarm@lists.cs.columbia.edu, Christoffer Dall Subject: [Qemu-devel] [PATCH] target-arm: Check error conditions on kvm_arm_reset_vcpu X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: christoffer.dall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 When resetting a VCPU we currently call both kvm_arm_vcpu_init() and write_kvmstate_to_list(), both of which can fail, but we never check the return value. The only choice here is to print an error an exit if the calls fail. Signed-off-by: Christoffer Dall --- target-arm/kvm32.c | 13 +++++++++++-- target-arm/kvm64.c | 8 +++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/target-arm/kvm32.c b/target-arm/kvm32.c index 5ec4eb1..1fd0e83 100644 --- a/target-arm/kvm32.c +++ b/target-arm/kvm32.c @@ -511,9 +511,18 @@ int kvm_arch_get_registers(CPUState *cs) void kvm_arm_reset_vcpu(ARMCPU *cpu) { + int ret; + /* Re-init VCPU so that all registers are set to * their respective reset values. */ - kvm_arm_vcpu_init(CPU(cpu)); - write_kvmstate_to_list(cpu); + ret = kvm_arm_vcpu_init(CPU(cpu)); + if (ret < 0) { + fprintf(stderr, "kvm_arm_vcpu_init failed: %s\n", strerror(ret)); + abort(); + } + if (!write_kvmstate_to_list(cpu)) { + fprintf(stderr, "write_kvmstate_to_list failed\n"); + abort(); + } } diff --git a/target-arm/kvm64.c b/target-arm/kvm64.c index c615286..101354a 100644 --- a/target-arm/kvm64.c +++ b/target-arm/kvm64.c @@ -263,8 +263,14 @@ int kvm_arch_get_registers(CPUState *cs) void kvm_arm_reset_vcpu(ARMCPU *cpu) { + int ret; + /* Re-init VCPU so that all registers are set to * their respective reset values. */ - kvm_arm_vcpu_init(CPU(cpu)); + ret = kvm_arm_vcpu_init(CPU(cpu)); + if (ret < 0) { + fprintf(stderr, "kvm_arm_vcpu_init failed: %s\n", strerror(ret)); + abort(); + } }