From patchwork Mon Oct 30 02:56:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10031919 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 E8E12603B5 for ; Mon, 30 Oct 2017 03:00:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D4AD728720 for ; Mon, 30 Oct 2017 03:00:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C8FE528723; Mon, 30 Oct 2017 03:00:14 +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 5915128720 for ; Mon, 30 Oct 2017 03:00: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=2i7ewmcAfRPyyIyTp4zE727G9eojDE6mfwzu5KOmbmw=; b=l3ebIAnuUnGmNnRCwdzc1wN6J5 RHpB/koOfacz2WPIebk57o6TPJAvPu00yw+eoYzXZt6CJYkESGFJUcoxbM58FR13bPFNoIOQne0rO CZU5usoDcxjQtCs00hcamYFnMSdMFz7etMJdP44z9OzLuYiwE0OaunMRHRMEOMC8plpuD0W1CFubf u5AKNyre32+ZumppQvbHlaXav1weB0olc4/Q3bK4idcI2WVdNN8hNrGFTsw8MudGcHZd8lnlYSc8r qV3FxHuhRO/7QVUCVDeEPQiy/DheYGX+meQb+vLOwrq1pauJRn6IgELMaXtXzgY4WdwzV0A7v1aqW S92Ax95A==; 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 1e90JB-0008RE-4I; Mon, 30 Oct 2017 03:00:13 +0000 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e90Fh-00060D-E6 for linux-arm-kernel@lists.infradead.org; Mon, 30 Oct 2017 02:56:41 +0000 Received: by mail-wm0-x242.google.com with SMTP id m72so12945355wmc.1 for ; Sun, 29 Oct 2017 19:56:17 -0700 (PDT) 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=tfSebk1BHHfNGj2o3awqCxK+MUilwM8nzbptmp2Nfzg=; b=FZ6nX2AIY+J2sHZjEvLvLqXy6fgZCND+aCIDqTpIGF494v1TSv4TtHTFKz+OXKJWk/ vG22fKoPoJ4/KFCMnqmi7v9QhB2qZajCLPRHZbpXi4Be54ELWg30UxS+WBQWIQm/ej1W oqNPGaf87Y2/4a8StvRm6FcYou4k2i2fWq35s= 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=tfSebk1BHHfNGj2o3awqCxK+MUilwM8nzbptmp2Nfzg=; b=EDD4hR8VWG8+moWQG985EHbBb1zTnOvAyK3qSUChe1oF3sU9cmDbrTTNnoWCJVYRZS s3LpW6fWPACEhdxz0kWYZGBiUa5WgUF2ud4z3L0lomv5ee7pujiwTjIm9w1q8K0CmqMG cNJ8HaAy4UZq53fkqKiNj86+JmVtOWemsc+p2ALYJefzcU1AX2usVtOyx5mbAEV20PBb 0pMlnADpvXsKqCSDilbQPMf9rEm1/tO1l8KRFr02LJNFQTjS50LpQ0CQaMD4HyKwGv0P bwzOb0cnLhVBkvBQlJX9gjxl+CRk7Q/F7yOXE+Y9brIj+HiNuse25PH3zWZe3xXW1nFX CwIg== X-Gm-Message-State: AMCzsaVWPpaG62/E/tjyZgAjQhkrnJuWtEqHf/e7Zn0nyctAWEyR9YF5 jDvSSf/AQhxsJiS0gMquiunBSg== X-Google-Smtp-Source: ABhQp+TheGwIDOE+q8E6qij4RmmuiHcyHxV8+ytbql2KIT8kY8bfYyotI22Bb1gt/Ko6QpDtLQ2cFg== X-Received: by 10.80.169.193 with SMTP id n59mr10102713edc.282.1509332175705; Sun, 29 Oct 2017 19:56:15 -0700 (PDT) Received: from localhost.localdomain (xd93dd96b.cust.hiper.dk. [217.61.217.107]) by smtp.gmail.com with ESMTPSA id u14sm7856415edd.47.2017.10.29.19.56.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 29 Oct 2017 19:56:14 -0700 (PDT) From: Christoffer Dall To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Subject: [PULL 5/8] KVM: arm/arm64: vgic-its: Fix return value for device table restore Date: Mon, 30 Oct 2017 03:56:00 +0100 Message-Id: <20171030025603.23550-6-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171030025603.23550-1-christoffer.dall@linaro.org> References: <20171030025603.23550-1-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171029_195637_832479_F9CE660D X-CRM114-Status: GOOD ( 15.67 ) 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: kvm@vger.kernel.org, Marc Zyngier , Eric Auger , Christoffer Dall , wanghaibin , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org 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 From: wanghaibin If ITT only contains invalid entries, vgic_its_restore_itt returns 1 and this is considered as an an error in vgic_its_restore_dte. Also in case the device table only contains invalid entries, the table restore fails and this is not correct. This patch fixes those 2 issues: - vgic_its_restore_itt now returns <= 0 values. If all ITEs are invalid, this is considered as successful. - vgic_its_restore_device_tables also returns <= 0 values. We also simplify the returned value computation in handle_l1_dte. Signed-off-by: wanghaibin Signed-off-by: Eric Auger Reviewed-by: Christoffer Dall Signed-off-by: Christoffer Dall --- virt/kvm/arm/vgic/vgic-its.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c index 77652885a7c1..76685f4c6261 100644 --- a/virt/kvm/arm/vgic/vgic-its.c +++ b/virt/kvm/arm/vgic/vgic-its.c @@ -1936,6 +1936,14 @@ static int vgic_its_save_itt(struct vgic_its *its, struct its_device *device) return 0; } +/** + * vgic_its_restore_itt - restore the ITT of a device + * + * @its: its handle + * @dev: device handle + * + * Return 0 on success, < 0 on error + */ static int vgic_its_restore_itt(struct vgic_its *its, struct its_device *dev) { const struct vgic_its_abi *abi = vgic_its_get_abi(its); @@ -1947,6 +1955,10 @@ static int vgic_its_restore_itt(struct vgic_its *its, struct its_device *dev) ret = scan_its_table(its, base, max_size, ite_esz, 0, vgic_its_restore_ite, dev); + /* scan_its_table returns +1 if all ITEs are invalid */ + if (ret > 0) + ret = 0; + return ret; } @@ -2103,10 +2115,7 @@ static int handle_l1_dte(struct vgic_its *its, u32 id, void *addr, ret = scan_its_table(its, gpa, SZ_64K, dte_esz, l2_start_id, vgic_its_restore_dte, NULL); - if (ret <= 0) - return ret; - - return 1; + return ret; } /** @@ -2136,8 +2145,9 @@ static int vgic_its_restore_device_tables(struct vgic_its *its) vgic_its_restore_dte, NULL); } + /* scan_its_table returns +1 if all entries are invalid */ if (ret > 0) - ret = -EINVAL; + ret = 0; return ret; }