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: 5436531 Return-Path: X-Original-To: patchwork-kvm@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 04BBF9F319 for ; Thu, 4 Dec 2014 09:50:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2590D20357 for ; Thu, 4 Dec 2014 09:50:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1E60120272 for ; Thu, 4 Dec 2014 09:50:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753547AbaLDJuF (ORCPT ); Thu, 4 Dec 2014 04:50:05 -0500 Received: from mail-wg0-f41.google.com ([74.125.82.41]:46299 "EHLO mail-wg0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753543AbaLDJt7 (ORCPT ); Thu, 4 Dec 2014 04:49:59 -0500 Received: by mail-wg0-f41.google.com with SMTP id y19so22074819wgg.14 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=iJHinMXTIH8dxJc3KinNvjj3m2vXS9vbFa9jaTEfafT2WahINwac4zC+AzEflp9Get pYGnaoLSQw5VOgtasUP+Ud66n0SOtff7fjAnzvworssfRBRJ60WzosGeV3iLRDd+u4CF cObEQmsOxLq5rhJjRlmugDWdQYw7dAs0fUTaoIE+8uZAX6S5FA20xsiy+xj59eK9aYBb OIKhqt8eu9kJx3LJuQRWD/0PJD49JQcs4aX7TyuiXw0S1rlpxh9sW8Jg6dkaPZs9dely ZIaMpXh/6yK/cB68XFn1pjbPbPx+xbFjgQ8E/6aLPEkhi/rM21QqjB8mGsUW/yJax1MC qaBg== X-Gm-Message-State: ALoCoQlYTCC6t8uo1qPFkVBdJvjkNoI/IHNhjDZeutxGjuoVRfIvXG5F6ZPwWZ1vQ0xzK0kawXW6 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> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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;