Received: by 10.223.164.221 with SMTP id h29csp2236467wrb; Sun, 29 Oct 2017 23:53:12 -0700 (PDT) X-Google-Smtp-Source: ABhQp+SFVpmRJt63kYd9pzzRGYwsHSvyl9oUya5l/nNMc8FYvuHH999PsemyO2JH+ysoJKt7o8kc X-Received: by 10.98.29.211 with SMTP id d202mr7715918pfd.49.1509346392686; Sun, 29 Oct 2017 23:53:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509346392; cv=none; d=google.com; s=arc-20160816; b=MN+kAP7bmObrl+eI1USftBsdpRarVc5mDi8nE909j8eNzs0VGVFw7Q0TSZqW5EO4Jq agpGc7Sl7LPqVu5mR6FqSr5f3Pdu5m9D2nlZoTEGXl8xMkEauqKfkY0Vo+TQkMg6vGqQ OYLGFBRmgajLVkE6EpFYwWxlUHiP6J5JhUob3jwGk6pQC19INaGkJKhSU13Q399slYiF cDHvmU7O/3gr1xNK/eMlu/0eNOC6yGRmUfhQOaEEWnFqJhSTyKoiEskW4Vge7opkV81V eV1vzypymNKAUS3HKd7JI2u3R1HYt/uCLsOUjN6/mFUwrrzw8CrwQgJapNpi9p92hzLz LCdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=Mx7NYaOCQB9vs7n1a7NED37DyYgfRBwmDkC71ByVS1w=; b=yfjkLbWWpd8LJQGVHDb7NBj9TRc/sse91nAjdezVPwdhIMPOJgki0+XCEYVaaUVNzp L5rF/KJksDi6favsYbTf+IJzOQt8Y/xy82ZpaY/TAqTyoBjAH0ToZWgXIuhh0gXKAryb m3AuN4PVz7b9PnU2218ml7vnqFgukya90PeTgbg1MqLLHYBiQvLbDKCS7oPCtyhcHX9p 9WVJg1HgPBTY22XQXYk7F2DCyjDQb2lPExQL1pxhhjAtzzqkkSgFmhGZLnnZasEm7W5L 7Veh0ST8udol0Ir0G8LXbeahECIVOwdOFCNkWDf3ERo4KwzO+z5ekOpoRXlzEgsFZ7Ng sqhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jWLh1WhT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r4si8672268pgt.604.2017.10.29.23.52.59; Sun, 29 Oct 2017 23:53:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jWLh1WhT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752434AbdJ3Gvw (ORCPT + 99 others); Mon, 30 Oct 2017 02:51:52 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:46506 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751365AbdJ3Gvt (ORCPT ); Mon, 30 Oct 2017 02:51:49 -0400 Received: by mail-lf0-f66.google.com with SMTP id g70so13669365lfl.3 for ; Sun, 29 Oct 2017 23:51:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Mx7NYaOCQB9vs7n1a7NED37DyYgfRBwmDkC71ByVS1w=; b=jWLh1WhTp8/uoshvHbb14qmog6ZzNozhwq/DyQbtyuRSpY0Xcr5p2cF3z9pTjyaLmj 3oaPIvnjL9yivKsUi9wCGZJTmDaRhcJ2Z6JDdvu4oohFCsvakUL7Le57T57R+i8ibzQb r42e7cvFb6FYBkwwOS40ZTizKMFFDt5izwJkA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Mx7NYaOCQB9vs7n1a7NED37DyYgfRBwmDkC71ByVS1w=; b=oDqNVVk4qee/kqpsQ+3nIqtOI5BdW1zwBi6cx4bxFsHzZCTm+v7PKiikcz0ZJm+mMw +p+AW8eTeWwfQDZGi4UAnnNwC+/YCapvUsw6BlYv7W+/IIPNSi/43IDlxtPj6fnt+BO/ 37pv7G3ZncOzOhfoq0iUEoM4UhjN42kMzEaM+qZRzSMNfg7lnAOwhbhGorLz0WVNt9dn 92hgymlUYrLpZNoCN2xIuvDNhxpE9fpLoBWFsG3pKsB54hFOy3eNdDv3+Qb/2qi7tuYg k0FqXjfbaFDn1yHli32IARfjtVfvonChx5YcsYlz1RQZsD0pOE4J+c+kqnTSeYEMfgWz MJqw== X-Gm-Message-State: AMCzsaUawJvybxjynpfAELBmE9RLXtWGikWbeAYRlPCLIW3maJmykXQ+ e1PTePqWt022k76e7rtBnaKSrw== X-Received: by 10.46.56.20 with SMTP id f20mr3323186lja.189.1509346308417; Sun, 29 Oct 2017 23:51:48 -0700 (PDT) Received: from localhost (212.27.17.10.bredband.3.dk. [212.27.17.10]) by smtp.gmail.com with ESMTPSA id r29sm3233866lje.4.2017.10.29.23.51.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 29 Oct 2017 23:51:47 -0700 (PDT) Date: Mon, 30 Oct 2017 07:51:39 +0100 From: Christoffer Dall To: Marc Zyngier Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Andre Przywara Subject: Re: [PATCH v5 24/26] KVM: arm/arm64: GICv4: Prevent userspace from changing doorbell affinity Message-ID: <20171030065139.GP2166@lvm> References: <20171027142855.21584-1-marc.zyngier@arm.com> <20171027142855.21584-25-marc.zyngier@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171027142855.21584-25-marc.zyngier@arm.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 27, 2017 at 03:28:53PM +0100, Marc Zyngier wrote: > We so far allocate the doorbell interrupts without taking any > special measure regarding the affinity of these interrupts. We > simply move them around as required when the vcpu gets scheduled > on a different CPU. > > But that's counting without userspace (and the evil irqbalance) that > can try and move the VPE interrupt around, causing the ITS code > to emit VMOVP commands and remap the doorbell to another redistributor. > Worse, this can happen while the vcpu is running, causing all kind > of trouble if the VPE is already resident, and we end-up in UNPRED > territory. > > So let's take a definitive action and prevent userspace from messing > with us. This is just a matter of adding IRQ_NO_BALANCING to the > set of flags we already have, letting the kernel in sole control > of the affinity. > Acked-by: Christoffer Dall > Signed-off-by: Marc Zyngier > --- > virt/kvm/arm/vgic/vgic-v4.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/virt/kvm/arm/vgic/vgic-v4.c b/virt/kvm/arm/vgic/vgic-v4.c > index d7fe610bb1f5..d10e18eabd3b 100644 > --- a/virt/kvm/arm/vgic/vgic-v4.c > +++ b/virt/kvm/arm/vgic/vgic-v4.c > @@ -23,6 +23,8 @@ > > #include "vgic.h" > > +#define DB_IRQ_FLAGS (IRQ_NOAUTOEN | IRQ_DISABLE_UNLAZY | IRQ_NO_BALANCING) > + > static irqreturn_t vgic_v4_doorbell_handler(int irq, void *info) > { > struct kvm_vcpu *vcpu = info; > @@ -83,7 +85,7 @@ int vgic_v4_init(struct kvm *kvm) > * doorbell could kick us out of the guest too > * early... > */ > - irq_set_status_flags(irq, IRQ_NOAUTOEN | IRQ_DISABLE_UNLAZY); > + irq_set_status_flags(irq, DB_IRQ_FLAGS); > ret = request_irq(irq, vgic_v4_doorbell_handler, > 0, "vcpu", vcpu); > if (ret) { > @@ -121,7 +123,7 @@ void vgic_v4_teardown(struct kvm *kvm) > struct kvm_vcpu *vcpu = kvm_get_vcpu(kvm, i); > int irq = its_vm->vpes[i]->irq; > > - irq_clear_status_flags(irq, IRQ_NOAUTOEN | IRQ_DISABLE_UNLAZY); > + irq_clear_status_flags(irq, DB_IRQ_FLAGS); > free_irq(irq, vcpu); > } > > -- > 2.11.0 > > _______________________________________________ > kvmarm mailing list > kvmarm@lists.cs.columbia.edu > https://lists.cs.columbia.edu/mailman/listinfo/kvmarm From 1582421510982612860@xxx Fri Oct 27 14:32:32 +0000 2017 X-GM-THRID: 1582421510982612860 X-Gmail-Labels: Inbox,Category Forums