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: Auger Eric X-Patchwork-Id: 41916 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6760825E8C for ; Thu, 4 Dec 2014 09:50:00 +0000 (UTC) Received: by mail-wi0-f200.google.com with SMTP id ex7sf10820775wid.7 for ; Thu, 04 Dec 2014 01:49:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=VuyWk6sI/j/qNVzxXZhmihnzbUYL/6UMsYhwImR4Frk=; b=cJzp1x1Sxprdtv5EugjsG9Z6JSQqxonaf3W1ExtiYhvLNAMRUETvoBoh3xjNWE3HPZ 95JZhwzblpQvNRr1JAmZZOI/vgIPvKldCMCwaDbw53r/prBD2gp49rxLoKZiKFfPx9m/ eh2Tx9iPOeIBFW9Nn5ipOjBw95E7PuUJi+ct9J/FKrraecNBmFe3NLRuWSO0X3dFRzEf wWjvasQcszJgDqF3A2IO6mzsqGSMH/k+HnOpzxjcTya+ZUYDJR0Yp1PB1uXCFN3PVjCX y4+R8H25a5ielsJ3FYgs2GMt1jjX1o+ciXCjQx2EKJ6Jj9ievy1o4Ns6gZI+FrFX69xH 5zmA== X-Gm-Message-State: ALoCoQm71ER3mNCxofgQVqbdAtkAzdEglOse510hk7cd5N6aqZuA2ORNOwK69JUniQwGVnCBu2Cf X-Received: by 10.194.95.74 with SMTP id di10mr2073939wjb.0.1417686599729; Thu, 04 Dec 2014 01:49:59 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.88.1 with SMTP id bc1ls267743lab.24.gmail; Thu, 04 Dec 2014 01:49:59 -0800 (PST) X-Received: by 10.112.171.199 with SMTP id aw7mr8527153lbc.40.1417686599609; Thu, 04 Dec 2014 01:49:59 -0800 (PST) Received: from mail-la0-f42.google.com (mail-la0-f42.google.com. [209.85.215.42]) by mx.google.com with ESMTPS id t10si10814474lae.38.2014.12.04.01.49.59 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 04 Dec 2014 01:49:59 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) client-ip=209.85.215.42; Received: by mail-la0-f42.google.com with SMTP id gd6so472753lab.29 for ; Thu, 04 Dec 2014 01:49:59 -0800 (PST) X-Received: by 10.152.3.67 with SMTP id a3mr8504310laa.56.1417686599537; Thu, 04 Dec 2014 01:49:59 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp6859lbc; Thu, 4 Dec 2014 01:49:59 -0800 (PST) X-Received: by 10.194.134.234 with SMTP id pn10mr14873661wjb.34.1417686598941; Thu, 04 Dec 2014 01:49:58 -0800 (PST) Received: from mail-wg0-f43.google.com (mail-wg0-f43.google.com. [74.125.82.43]) by mx.google.com with ESMTPS id u2si19270299wix.13.2014.12.04.01.49.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 04 Dec 2014 01:49:58 -0800 (PST) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 74.125.82.43 as permitted sender) client-ip=74.125.82.43; Received: by mail-wg0-f43.google.com with SMTP id l18so22286537wgh.16 for ; Thu, 04 Dec 2014 01:49:58 -0800 (PST) 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 Cc: linux-kernel@vger.kernel.org, patches@linaro.org, will.deacon@arm.com, a.motakis@virtualopensystems.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-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: eric.auger@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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;