From patchwork Tue May 9 10:44:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 9717601 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 489A960237 for ; Tue, 9 May 2017 10:50:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A15C20683 for ; Tue, 9 May 2017 10:50:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D80C2833C; Tue, 9 May 2017 10:50:56 +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=-1.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_SORBS_SPAM autolearn=no 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 B732920683 for ; Tue, 9 May 2017 10:50:55 +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=701hwQVtVEsceFgjghGhW3KJ0/9TVNriM41IrSroGUU=; b=qz6CYiaHwSBuBe1jFVQXIwEmwz eqiaE/qJiUK+rjc3goZ4f9nAQHmLdQNUz3f90DiIv6mSevdik5GJpixhHlL3buPdgTEzodE7u1tfO 0f6gf2gQD1OIR8cKQNRiEcf4aZYcpWx02JJTniWQ6f+3dXhRUdE6cBMSEDOkLJfGPrBytJqnqCG23 tb90bH/JF6YvxwfOoFOyv4aKif7bxKMzjUmLi80L590vsF+8+aeH55/2t6oK0ugLGwZ4ltRBlFHi5 LupIV67N82AvJLu1jQQvhiAgFmugPv2qilYOPd2L+79R6QsoOkHgvYaX0jMWWD458RjxMwvs/aA5s 8VUK5PPw==; 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 1d82jG-0001js-Qn; Tue, 09 May 2017 10:50:54 +0000 Received: from mail-qk0-f181.google.com ([209.85.220.181]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d82eQ-0002rX-V0 for linux-arm-kernel@lists.infradead.org; Tue, 09 May 2017 10:46:01 +0000 Received: by mail-qk0-f181.google.com with SMTP id a72so58965898qkj.2 for ; Tue, 09 May 2017 03:45:34 -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=xnTkTrTf4J5V9uAXCAOAJ0SOddpCUl5lBsqjfFF5dVM=; b=GXl9EmskoprZ64H908d+TOqF4T7441/3Oe+pyXsRGeEifn+ZXSoyEEMo8ZaG4Ha3Bs 8x1R0hTPP/FakkNybTLm8cbW8E26uJZCILfon9u5c4LoAV1qzXfw6VTICa7HOGZYgZzj 4yoJgZKGabDXy9DuraK1k5kgshgCbLKNdM5ls= 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=xnTkTrTf4J5V9uAXCAOAJ0SOddpCUl5lBsqjfFF5dVM=; b=WhMbpPV91TuH8aYm960MGAz+CYQIkL5A99NovnWV9uxKi4DGI/sWjwrhNlSk8QO294 dO9mDymE3TMimh+yulHlX0jmP9U/1C/DSBw7dBGpOJrNqHGno7Jo/AX+a0N8xLMgwYgZ j2OnL2H2c1nTgx6LgNDU9CRqOiJBP//TMgMuEtpOZ29cFXXC4nrSC5FV7uGPGRxtmKzi sqk/YwEosq04/tyIUhWlb0deAN5ZcTESN25e347GL4ua20wPHED5APZmy6qvNkDDJH8U d7hK1sFdaCOhPG3jC0Fy3c7QcnDRyXItHAijQ6IhGw55OMSpgwF3TI7p6KrnkNmVqDa0 wyhQ== X-Gm-Message-State: AN3rC/4j+hsIU9MUpF8WjvMsvljV28B4JMu4pVvWZa2fINve8mOoSmy6 KHu4aCTDCgQAK40U X-Received: by 10.80.134.115 with SMTP id 48mr21267841edt.26.1494326733583; Tue, 09 May 2017 03:45:33 -0700 (PDT) Received: from localhost.localdomain (xd93ddc2d.cust.hiper.dk. [217.61.220.45]) by smtp.gmail.com with ESMTPSA id o30sm2331510edc.42.2017.05.09.03.45.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 May 2017 03:45:32 -0700 (PDT) From: Christoffer Dall To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Subject: [PULL 22/37] KVM: arm64: vgic-its: vgic_its_check_id returns the entry's GPA Date: Tue, 9 May 2017 12:44:51 +0200 Message-Id: <20170509104506.30929-23-cdall@linaro.org> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170509104506.30929-1-cdall@linaro.org> References: <20170509104506.30929-1-cdall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170509_034556_067072_471A8C3F X-CRM114-Status: GOOD ( 11.72 ) 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: Marc Zyngier , Eric Auger , kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, 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: Eric Auger As vgic_its_check_id() computes the device/collection entry's GPA, let's return it so that new callers can retrieve it easily. Signed-off-by: Eric Auger Acked-by: Christoffer Dall Acked-by: Marc Zyngier --- virt/kvm/arm/vgic/vgic-its.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c index 5523f0a..90afc83 100644 --- a/virt/kvm/arm/vgic/vgic-its.c +++ b/virt/kvm/arm/vgic/vgic-its.c @@ -694,7 +694,8 @@ static int vgic_its_cmd_handle_movi(struct kvm *kvm, struct vgic_its *its, * is actually valid (covered by a memslot and guest accessible). * For this we have to read the respective first level entry. */ -static bool vgic_its_check_id(struct vgic_its *its, u64 baser, u32 id) +static bool vgic_its_check_id(struct vgic_its *its, u64 baser, u32 id, + gpa_t *eaddr) { int l1_tbl_size = GITS_BASER_NR_PAGES(baser) * SZ_64K; u64 indirect_ptr, type = GITS_BASER_TYPE(baser); @@ -725,6 +726,8 @@ static bool vgic_its_check_id(struct vgic_its *its, u64 baser, u32 id) addr = BASER_ADDRESS(baser) + id * esz; gfn = addr >> PAGE_SHIFT; + if (eaddr) + *eaddr = addr; return kvm_is_visible_gfn(its->dev->kvm, gfn); } @@ -757,6 +760,8 @@ static bool vgic_its_check_id(struct vgic_its *its, u64 baser, u32 id) indirect_ptr += index * esz; gfn = indirect_ptr >> PAGE_SHIFT; + if (eaddr) + *eaddr = indirect_ptr; return kvm_is_visible_gfn(its->dev->kvm, gfn); } @@ -766,7 +771,7 @@ static int vgic_its_alloc_collection(struct vgic_its *its, { struct its_collection *collection; - if (!vgic_its_check_id(its, its->baser_coll_table, coll_id)) + if (!vgic_its_check_id(its, its->baser_coll_table, coll_id, NULL)) return E_ITS_MAPC_COLLECTION_OOR; collection = kzalloc(sizeof(*collection), GFP_KERNEL); @@ -939,7 +944,7 @@ static int vgic_its_cmd_handle_mapd(struct kvm *kvm, struct vgic_its *its, gpa_t itt_addr = its_cmd_get_ittaddr(its_cmd); struct its_device *device; - if (!vgic_its_check_id(its, its->baser_device_table, device_id)) + if (!vgic_its_check_id(its, its->baser_device_table, device_id, NULL)) return E_ITS_MAPD_DEVICE_OOR; if (valid && num_eventid_bits > VITS_TYPER_IDBITS)