From patchwork Mon Nov 13 09:17:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10055425 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 149E26029B for ; Mon, 13 Nov 2017 09:38:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E55B229191 for ; Mon, 13 Nov 2017 09:38:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D82EF29246; Mon, 13 Nov 2017 09:38:06 +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 742E629191 for ; Mon, 13 Nov 2017 09:38:06 +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=WSvP11U0gjYKqIznk8ymA4Demkday++GT4cimWnqz7k=; b=R9vcrYSl4sY5mU1OIdodiIVhBH 19564pPGgk0qbrL8cvS5PXhEG3TQhO8pRMkzJ/eK32ymUzUXO06q8ceRbzSnA6/5C7zBOHkEAGOLz qaAP91CYKIuoj0ki8SDjZRSnG52h8gKLeZu/Llhz1G+XQoSNd21P8kWg85ES4hb5OTmLMvjFaBuup 0Da0KeQQBZ+ipK2A8EoIy3zh6swLRQgxYH2XIK83V7biwaEpbe5U9khQ3Jm5mxQkF1cLdHAMDBh1S 9KRxSM/c/9ONSWbgYQIdKVSymxFPiHEm9ICsJOcROqNfHPSdDqjwlgiFGLyd+uos4oxz+3Lx2a7eB zphIy91g==; 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 1eEBBX-0005do-B9; Mon, 13 Nov 2017 09:37:43 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eEAtJ-0002ng-VB for linux-arm-kernel@bombadil.infradead.org; Mon, 13 Nov 2017 09:18:54 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=meZDPhCpVPhegN6WZj1dSF5e8AF1etqY2PovRxPgeVw=; b=R4vdBZIgF9JSqm8LAYRnlXjFZ k8sL0gagq7qvUvsIPfW1EYm+H5oa/S/JEJaM5kFBOu2FRXCP3mmu46MJTgJoZzwioNGxDOrvRHLEt UT4MRdb/GKtGdYjvL5mONImd4PziVkY4mfGweJslKKZUMhRTnKcmhVLEh6q7uy67tNlyNkNXJMeDw TTdrZ46HXLijdcWjG/rSj/EJT4qIUrBE3Ryy2Uc9bGSUJ/Xct64v/OO29fFNREqYhmYpiU8oW6Fqh w14ghV6mWey8lcE9QORCtu/grv1j0eSzIvYdZyLK4fIL3tdDxRMzmVUArxt4cdTAWmQ7HquTjZDGG fJWOdWP5w==; Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eEAtH-0005WI-5M for linux-arm-kernel@lists.infradead.org; Mon, 13 Nov 2017 09:18:51 +0000 Received: by mail-wr0-x242.google.com with SMTP id o88so13757014wrb.6 for ; Mon, 13 Nov 2017 01:18:30 -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=meZDPhCpVPhegN6WZj1dSF5e8AF1etqY2PovRxPgeVw=; b=imA9/klOHSTsxvAjE1E/3QXxebIDckSWM4lqQlxfh6B/0jmfTTuAvI2cX7bV84b9+i 9rIi2SY7FPf/Qgx7Z8uBFjlUlDwsda/Uwfi5y5hsnJfRLYgfKg3ljVNYZvqXEq8ViaaW HGzCK5HO6+CJx82mMb/gm/wGWpmVfUaSBgEiI= 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=meZDPhCpVPhegN6WZj1dSF5e8AF1etqY2PovRxPgeVw=; b=HJX1sANTuEfzytUzSxv/1R5OE7HmVKL4guFRW1wj7jNDRD1AD1FIf9FsmhUtAfJ7+j aGHtWIHt6RD+q8F3ggBtUyBEdHVS/V5sb1IQCtpIx32J6+lCXHBc/137VF68n5y3RH/w sXwI9gnoENU+NPC0kxcZOjCnceWlpGm4ndIjOVPVVmZxTxVCq+dg+PnYUU6Yvcaslekc kPM9KHi1MSsjI58z4+9W/kP3u9BWBuHLTSLobNNXuPiPS789mKAb+baXbu7yoLpyYiwm E50X/Dm1DyZbfPP5WOlUdoRLAdjk0R8d9InE/VSlgheaDix/+4cD81ZsE5VBO3XPNDlf sTqw== X-Gm-Message-State: AJaThX6ZJ4TfodjFkhxjRgV7hRxciEOYKv0w9gdNkbvwmSrQ2u5MoOud Y65JySZ4qeY9xQNhr6FZsBbSynEdVc4= X-Google-Smtp-Source: AGs4zMY3qz9s3jE9oZAgKiqEuU2rZp/Kf9E3mrKvAg4XPjaZjbiWNztnhJ4eoKv5e+kctBcHjeNFVA== X-Received: by 10.223.139.73 with SMTP id v9mr7025943wra.77.1510564709146; Mon, 13 Nov 2017 01:18:29 -0800 (PST) Received: from localhost.localdomain (xd93dd96b.cust.hiper.dk. [217.61.217.107]) by smtp.gmail.com with ESMTPSA id x63sm9651399wma.39.2017.11.13.01.18.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 13 Nov 2017 01:18:28 -0800 (PST) From: Christoffer Dall To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Subject: [PULL 22/27] KVM: arm/arm64: GICv4: Prevent a VM using GICv4 from being saved Date: Mon, 13 Nov 2017 10:17:47 +0100 Message-Id: <20171113091752.10663-23-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171113091752.10663-1-christoffer.dall@linaro.org> References: <20171113091752.10663-1-christoffer.dall@linaro.org> 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 , Christoffer Dall , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.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: Marc Zyngier The GICv4 architecture doesn't make it easy for save/restore to work, as it doesn't give any guarantee that the pending state is written into the pending table. So let's not take any chance, and let's return an error if we encounter any LPI that has the HW bit set. In order for userspace to distinguish this error from other failure modes, use -EACCES as an error code. Reviewed-by: Eric Auger Signed-off-by: Marc Zyngier Signed-off-by: Christoffer Dall --- Documentation/virtual/kvm/devices/arm-vgic-its.txt | 2 ++ virt/kvm/arm/vgic/vgic-its.c | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/Documentation/virtual/kvm/devices/arm-vgic-its.txt b/Documentation/virtual/kvm/devices/arm-vgic-its.txt index 8d5830eab26a..4f0c9fc40365 100644 --- a/Documentation/virtual/kvm/devices/arm-vgic-its.txt +++ b/Documentation/virtual/kvm/devices/arm-vgic-its.txt @@ -64,6 +64,8 @@ Groups: -EINVAL: Inconsistent restored data -EFAULT: Invalid guest ram access -EBUSY: One or more VCPUS are running + -EACCES: The virtual ITS is backed by a physical GICv4 ITS, and the + state is not available KVM_DEV_ARM_VGIC_GRP_ITS_REGS Attributes: diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c index bf571f6d2b32..b8c1b724ba3e 100644 --- a/virt/kvm/arm/vgic/vgic-its.c +++ b/virt/kvm/arm/vgic/vgic-its.c @@ -1995,6 +1995,15 @@ static int vgic_its_save_itt(struct vgic_its *its, struct its_device *device) list_for_each_entry(ite, &device->itt_head, ite_list) { gpa_t gpa = base + ite->event_id * ite_esz; + /* + * If an LPI carries the HW bit, this means that this + * interrupt is controlled by GICv4, and we do not + * have direct access to that state. Let's simply fail + * the save operation... + */ + if (ite->irq->hw) + return -EACCES; + ret = vgic_its_save_ite(its, device, ite, gpa, ite_esz); if (ret) return ret;