From patchwork Mon Oct 30 02:56:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10031923 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 5BA05603B5 for ; Mon, 30 Oct 2017 03:01:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 47D9E28721 for ; Mon, 30 Oct 2017 03:01:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 334102872B; Mon, 30 Oct 2017 03:01: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=ham 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 B594628722 for ; Mon, 30 Oct 2017 03:01:05 +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=w0nZrwjdoneBN5GfC5EEwkQ+OUZHU+lwbLdClQYCseE=; b=emPKAvNevGn/nzlsJZT0raV50G J//gEBswhjG3RGT+jLvh8N4ewFTaOBbsLEALPTI7d3q9xQ989em38xDSsx5sLjde8NrYp5WJrk3Oy 2ywDhLjN+Iu/5cNiWoaogDQ2z8v7upih3tVaROpgJq4h+fBGP5vBqb6dia3amPHO/3imRF/ls2SiI gNczQMg9nINwuUgG3rqnkc8KPfy31uB9SU0HTX08JsOaMB7Fk4FN3gfYSCH1OPQVHrGLTFkrQeq8i hX6ckuYx4hqhi6mxob35rUPGhTL2nbEOFVNOkFw2faSPbjMWwlP1UM+cCgZDILOjVSoonqPIwUDda eBf4rkfA==; 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 1e90K0-0001gP-G0; Mon, 30 Oct 2017 03:01:04 +0000 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e90Fi-00060c-R9 for linux-arm-kernel@lists.infradead.org; Mon, 30 Oct 2017 02:56:50 +0000 Received: by mail-wm0-x241.google.com with SMTP id b189so12864241wmd.4 for ; Sun, 29 Oct 2017 19:56:19 -0700 (PDT) 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=RZWq6pb0PbAPYbOhuVMTYOMrxrSO+pdO1OFLRvBRBb8=; b=YxbvBAA6V2J6DQ7lwSnvjlwpQg3y4bmR+k/rJvY1bzSkCT9cv8ziBQWxRSX3cqQqBN rAiTQcSQktoXS7Kbwgm8fktTddcFXlU2WF709GpRqJudj2YFfN4QTnv3Bph8NQr2gDCu G/BdRZbvt+MLUEFOvrN/bZgm29ITeo/ixY/B8= 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=RZWq6pb0PbAPYbOhuVMTYOMrxrSO+pdO1OFLRvBRBb8=; b=SgyIOxoU9DB84vZ3EEpkImgOZcSIRALk8ajL4LP/c6MxsnZFizfeoqzwpGBHyVHk7M PmnhlaX1kzEQhLFnCn/LZ1FUTG8DJ03r47f2zE+6elKYJ/wv6OS+x9XVmq0cQppqBxab s5SFpzAc59kVjHFUjDioOH7UZrlaPwzIJpjMOVVjTZTUbgs493vc0e1oDe0sDutH8bPj Wuf9W8ZBUwubzAXEfovZYjPVD6Ycw5ncC/l4DmHs/U4GVV+39VDNMvPDadJRWItKrvyK ar+TyOahfIS+uhV/N2h5IJ1AoMvcVtxtgOjEeB/CXizDgMUsVSkvFgQl2x3qodjPdRtE OpPw== X-Gm-Message-State: AMCzsaVj8CwD5WxxNmpiL25MbYpLtgH/FHIm5q3MDaoxjB9dO8mDCx0f 5eSlSPvbNyqjYdyvyKBGypkHMA== X-Google-Smtp-Source: ABhQp+RQOuSIF/PtUegT6/44xwaDmjm+zTQpiPpwGZYbAmh2YFRXERxGMwvBOY2HKckafluXI++3Og== X-Received: by 10.80.145.109 with SMTP id f42mr9974489eda.215.1509332178568; Sun, 29 Oct 2017 19:56:18 -0700 (PDT) Received: from localhost.localdomain (xd93dd96b.cust.hiper.dk. [217.61.217.107]) by smtp.gmail.com with ESMTPSA id u14sm7856415edd.47.2017.10.29.19.56.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 29 Oct 2017 19:56:17 -0700 (PDT) From: Christoffer Dall To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Subject: [PULL 7/8] KVM: arm/arm64: vgic-its: Check CBASER/BASER validity before enabling the ITS Date: Mon, 30 Oct 2017 03:56:02 +0100 Message-Id: <20171030025603.23550-8-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171030025603.23550-1-christoffer.dall@linaro.org> References: <20171030025603.23550-1-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171029_195639_449100_ECE44EDD X-CRM114-Status: GOOD ( 11.08 ) 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: kvm@vger.kernel.org, Marc Zyngier , Eric Auger , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, Christoffer Dall 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: Eric Auger The spec says it is UNPREDICTABLE to enable the ITS if any of the following conditions are true: - GITS_CBASER.Valid == 0. - GITS_BASER.Valid == 0, for any GITS_BASER register where the Type field indicates Device. - GITS_BASER.Valid == 0, for any GITS_BASER register where the Type field indicates Interrupt Collection and GITS_TYPER.HCC == 0. In that case, let's keep the ITS disabled. Signed-off-by: Eric Auger Reported-by: Andre Przywara Reviewed-by: Christoffer Dall Signed-off-by: Christoffer Dall --- virt/kvm/arm/vgic/vgic-its.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c index 6a715a6ec64e..e69ef7d27fde 100644 --- a/virt/kvm/arm/vgic/vgic-its.c +++ b/virt/kvm/arm/vgic/vgic-its.c @@ -1466,6 +1466,16 @@ static void vgic_mmio_write_its_ctlr(struct kvm *kvm, struct vgic_its *its, { mutex_lock(&its->cmd_lock); + /* + * It is UNPREDICTABLE to enable the ITS if any of the CBASER or + * device/collection BASER are invalid + */ + if (!its->enabled && (val & GITS_CTLR_ENABLE) && + (!(its->baser_device_table & GITS_BASER_VALID) || + !(its->baser_coll_table & GITS_BASER_VALID) || + !(its->cbaser & GITS_CBASER_VALID))) + goto out; + its->enabled = !!(val & GITS_CTLR_ENABLE); /* @@ -1474,6 +1484,7 @@ static void vgic_mmio_write_its_ctlr(struct kvm *kvm, struct vgic_its *its, */ vgic_its_process_commands(kvm, its); +out: mutex_unlock(&its->cmd_lock); }