From patchwork Tue May 9 10:44:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 9717577 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 0B65860237 for ; Tue, 9 May 2017 10:47:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F18332842E for ; Tue, 9 May 2017 10:47:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E53D828418; Tue, 9 May 2017 10:47:27 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID 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 86CA820683 for ; Tue, 9 May 2017 10:47:27 +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=jrIDJcHt+Il3oPeyfoavFBZX10wzfaWUSnpMKnD4Ec4=; b=UciIayHyghq86CfFNHSeWwbAwI qa/gPUq4nBBK5RdqHJ3SfUoCPtohPyWHYLwwLH5gmTywyxs3MviHM+NSrTXZCZ2kJJdpzq/Eov7Ig KO1Pa/iq7roiUm8JmwdSKiVdgQ9TjMffooMGNCvEbhJuuchKYQBTWIG5reQmpqyvvQanp4LqgT2F3 9XTEpGaCqQ0+15SDd0g/64hiXeF+HFlcrczo72fGZb3L6gXcXoq71CX2SjegGX+w3KSNW17T83za3 eJb6VVmEjPtFkSuPGhoHtMgV+QjAOZknfDRS3UtHzeH70PHby5YNJawweKBq7J6uvTxJ7gPAYlK7J zqpG3EFA==; 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 1d82ft-00058d-7L; Tue, 09 May 2017 10:47:25 +0000 Received: from mail-qk0-x22c.google.com ([2607:f8b0:400d:c09::22c]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d82eB-0002qh-NJ for linux-arm-kernel@lists.infradead.org; Tue, 09 May 2017 10:45:43 +0000 Received: by mail-qk0-x22c.google.com with SMTP id a72so58961527qkj.2 for ; Tue, 09 May 2017 03:45:23 -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=AR5vdZv5gUZkDSGuqiQV2rbx3YrYpWogM/EwJWEFw88=; b=NuCcCT/2YAaKQERUJqmvh529u9QctaM5sepkmHAuqhAknBtm8GCwCZChDPR1tO7KV7 kNGnqhEW1H+SnZTt7Ay0P20R7tEYv7DC2YRaYl8VBbpyKzHI2xJTcFhpOlxPkhsmlEf/ R/BfMNwucbkxs7DWXDuASu2ckLwfy2Jwfro7g= 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=AR5vdZv5gUZkDSGuqiQV2rbx3YrYpWogM/EwJWEFw88=; b=QS01C+wI6IrK/mClw/VAaADn07o0TiylFS5KDZK21gbLnOTfVXx51e7K1axVDdii9s 3AEFCPFk88b1poeMQbKPw9WN23TD50oGqViqolCZram5VyYMNW0/2x8eNWmdx2kkxkY+ iA6K5o2Vtl+3INlKJQ9aThja30Ird5ElbB3oyq8ukdf8Ye2ZxtEyHoAWi4bqiArgNgzw tsBfY0oTHmMzoCRWJ2nFfPzpCwQrrliPpi75uRf/CWWwQ/8w6xz4ArC9lvsjIO/jZHHe TyzwezLpydfRlSZOiYAi+JpcXCLdbKJy99u/qf8PsTicmf4rHNVtGHzk2vB6+5/qLevp MUJA== X-Gm-Message-State: AN3rC/4q4Z4C5+DeMSUpOAbT6tRusUipSypNxGmCww84OTf+HIj3tMon Xywka1Gm1tv/bs4Q X-Received: by 10.80.136.112 with SMTP id c45mr46482967edc.171.1494326722497; Tue, 09 May 2017 03:45:22 -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.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 May 2017 03:45:21 -0700 (PDT) From: Christoffer Dall To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Subject: [PULL 10/37] KVM: arm64: vgic-its: Implement vgic_mmio_uaccess_write_its_creadr Date: Tue, 9 May 2017 12:44:39 +0200 Message-Id: <20170509104506.30929-11-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_034539_978084_271A1ABB X-CRM114-Status: GOOD ( 13.10 ) 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 GITS_CREADR needs to be restored so let's implement the associated uaccess_write_its callback. The write only is allowed if the its is disabled. Signed-off-by: Eric Auger Acked-by: Marc Zyngier Reviewed-by: Christoffer Dall --- virt/kvm/arm/vgic/vgic-its.c | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c index fd2660d..bf3ff09 100644 --- a/virt/kvm/arm/vgic/vgic-its.c +++ b/virt/kvm/arm/vgic/vgic-its.c @@ -1213,6 +1213,33 @@ static unsigned long vgic_mmio_read_its_creadr(struct kvm *kvm, return extract_bytes(its->creadr, addr & 0x7, len); } +static int vgic_mmio_uaccess_write_its_creadr(struct kvm *kvm, + struct vgic_its *its, + gpa_t addr, unsigned int len, + unsigned long val) +{ + u32 cmd_offset; + int ret = 0; + + mutex_lock(&its->cmd_lock); + + if (its->enabled) { + ret = -EBUSY; + goto out; + } + + cmd_offset = ITS_CMD_OFFSET(val); + if (cmd_offset >= ITS_CMD_BUFFER_SIZE(its->cbaser)) { + ret = -EINVAL; + goto out; + } + + its->creadr = cmd_offset; +out: + mutex_unlock(&its->cmd_lock); + return ret; +} + #define BASER_INDEX(addr) (((addr) / sizeof(u64)) & 0x7) static unsigned long vgic_mmio_read_its_baser(struct kvm *kvm, struct vgic_its *its, @@ -1317,6 +1344,16 @@ static void vgic_mmio_write_its_ctlr(struct kvm *kvm, struct vgic_its *its, .its_write = wr, \ } +#define REGISTER_ITS_DESC_UACCESS(off, rd, wr, uwr, length, acc)\ +{ \ + .reg_offset = off, \ + .len = length, \ + .access_flags = acc, \ + .its_read = rd, \ + .its_write = wr, \ + .uaccess_its_write = uwr, \ +} + static void its_mmio_write_wi(struct kvm *kvm, struct vgic_its *its, gpa_t addr, unsigned int len, unsigned long val) { @@ -1339,8 +1376,9 @@ static struct vgic_register_region its_registers[] = { REGISTER_ITS_DESC(GITS_CWRITER, vgic_mmio_read_its_cwriter, vgic_mmio_write_its_cwriter, 8, VGIC_ACCESS_64bit | VGIC_ACCESS_32bit), - REGISTER_ITS_DESC(GITS_CREADR, - vgic_mmio_read_its_creadr, its_mmio_write_wi, 8, + REGISTER_ITS_DESC_UACCESS(GITS_CREADR, + vgic_mmio_read_its_creadr, its_mmio_write_wi, + vgic_mmio_uaccess_write_its_creadr, 8, VGIC_ACCESS_64bit | VGIC_ACCESS_32bit), REGISTER_ITS_DESC(GITS_BASER, vgic_mmio_read_its_baser, vgic_mmio_write_its_baser, 0x40,