From patchwork Thu Dec 4 09:48:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 5436611 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2DE6E9F1C5 for ; Thu, 4 Dec 2014 09:53:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 61EE32035D for ; Thu, 4 Dec 2014 09:53:07 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7DCCC20361 for ; Thu, 4 Dec 2014 09:53:06 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XwT4K-00014Q-LR; Thu, 04 Dec 2014 09:51:28 +0000 Received: from mail-wg0-f45.google.com ([74.125.82.45]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XwT3E-0007mL-SJ for linux-arm-kernel@lists.infradead.org; Thu, 04 Dec 2014 09:50:21 +0000 Received: by mail-wg0-f45.google.com with SMTP id b13so22187925wgh.4 for ; Thu, 04 Dec 2014 01:49:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VuyWk6sI/j/qNVzxXZhmihnzbUYL/6UMsYhwImR4Frk=; b=H+CZqudIC8hG0ZNKKSY8CyQ8dE60nY7AQ7hbMWfNpRaraBpbRXDr05Qt0CgVUKH/SX eWsbZ7PdLcHRPM/sf3q3XQ2kY67Y7iHEM1gjHQ6+ybgpFL2HVwZ2eA6ArvXdVUzlPCSN SiUlTbi4Rbb/IXSogWEmmtjCIedqAoNancEraqJNldfWX8pLdHiI3/o8EW6YElSAlHpr CNuVz84XqmpNFJJ1/cWEHPaz5potQKjzkvTXhVo40VKhEaaiQQGxzKDMEuTJ/mFvoebS mc42ebVMwizLm1ceNp2pPHMIzj2mcHxZKMm3vROgr4sdT5l7kNpZXUnWrTtpaQoQUQ0u 4akA== X-Gm-Message-State: ALoCoQl7WCFFffa+x93LJlcZZ9tMgFJhZuKm/srnfxRFD60aNFVmSDuF7l17MiiIysrHdUamY7de X-Received: by 10.180.77.170 with SMTP id t10mr109948692wiw.57.1417686598693; Thu, 04 Dec 2014 01:49:58 -0800 (PST) Received: from gnx2579.gnb.st.com (LCaen-156-56-7-90.w80-11.abo.wanadoo.fr. [80.11.198.90]) by mx.google.com with ESMTPSA id wz5sm39765342wjc.29.2014.12.04.01.49.56 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 04 Dec 2014 01:49:58 -0800 (PST) From: Eric Auger To: eric.auger@st.com, eric.auger@linaro.org, christoffer.dall@linaro.org, marc.zyngier@arm.com, andre.przywara@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, alex.williamson@redhat.com, agraf@suse.de, gleb@kernel.org, pbonzini@redhat.com Subject: [PATCH v2 4/4] KVM: arm/arm64: vgic: check vgic_initialized in KVM_DEV_ARM_VGIC_GRP_ADDR Date: Thu, 4 Dec 2014 10:48:04 +0100 Message-Id: <1417686484-20828-5-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1417686484-20828-1-git-send-email-eric.auger@linaro.org> References: <1417686484-20828-1-git-send-email-eric.auger@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141204_015021_095010_63F1A980 X-CRM114-Status: GOOD ( 10.02 ) X-Spam-Score: -0.7 (/) Cc: a.motakis@virtualopensystems.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, patches@linaro.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch prevents user-space from changing VGIC base addresses if the vgic already is initialized. Signed-off-by: Eric Auger --- Documentation/virtual/kvm/devices/arm-vgic.txt | 2 ++ virt/kvm/arm/vgic.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/Documentation/virtual/kvm/devices/arm-vgic.txt b/Documentation/virtual/kvm/devices/arm-vgic.txt index 30f5427..8492715 100644 --- a/Documentation/virtual/kvm/devices/arm-vgic.txt +++ b/Documentation/virtual/kvm/devices/arm-vgic.txt @@ -19,6 +19,8 @@ Groups: KVM_VGIC_V2_ADDR_TYPE_CPU (rw, 64-bit) Base address in the guest physical address space of the GIC virtual cpu interface register mappings. + Errors: + -EBUSY: VGIC already is initialized KVM_DEV_ARM_VGIC_GRP_DIST_REGS Attributes: diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c index 89dca86..652e0bb 100644 --- a/virt/kvm/arm/vgic.c +++ b/virt/kvm/arm/vgic.c @@ -2427,6 +2427,9 @@ static int vgic_set_attr(struct kvm_device *dev, struct kvm_device_attr *attr) u64 addr; unsigned long type = (unsigned long)attr->attr; + if (vgic_initialized(dev->kvm)) + return -EBUSY; + if (copy_from_user(&addr, uaddr, sizeof(addr))) return -EFAULT;