Received: by 2002:a19:f015:0:0:0:0:0 with SMTP id p21csp1183279lfc; Mon, 9 Mar 2020 07:04:42 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuDLaP8D9zRXi+U2Mxvgk3BYwWleos9ozwNQUAQ25XBPIxCYgFvkFiZtav/rkyoUFsEqgkH X-Received: by 2002:ad4:4525:: with SMTP id l5mr14975867qvu.107.1583762681972; Mon, 09 Mar 2020 07:04:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583762681; cv=none; d=google.com; s=arc-20160816; b=sVCIGH2f+cjtr0XaJcRTwrXl4lnjeNTeaFs6FWLeHplpXCqmLCRKpmSv9JfEFMwYSN p/hP/+VwwCsM+bjPHBlc90L5cS0czbR8qOVwJFFywxc6Ngb3NgtfQ3ICUz7KSIx3155P JkDmAmu0mbdvA7JCkcVG5VKBieH0Nu7dr1YNVzHWfI2GT2i863Xpy9vgf7ac1b0sq3ab f1bW4chJ0qEEfYb1wHWZ+/lAvPxCFfUoihSzCMVojhaCmFBba6Q+v6TOLGN2eXOYMrSE 5jV3E7WQxKpWVcZXZoJvZoKlQjNk+QQ5QoBrS4qnxFOeL8jfvql4IVuNvB3TkHN4sl+w kdCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:dkim-signature; bh=g8bRHChsUWbeNH+K4Sm+PqbuexS/PgwjtWJOgxupBRo=; b=pGEcwdMikV9TNrwe7E/80eAzOeJOYJLi8M+IOtSORY7LUyObP5gihnnjIYHTnlVlt3 FSFePHO26zC+Zi+5RTWvgfR72+ZFkMZpCzyW2eV8M0WT9TCaloCcVwU+nqxc7tr1veyi igeysh4kwCTe8tXaJ/wuvyfN9STgh4QttJid5DBj4y08v7GOEi7tF/N9RqiZNBSGvWS0 7hvdkTJ5xpulKb7bl1NtrToM0t6bI0B0ipdAFMxy3QxDOvQWfhz8IGcfGOmQQZqpsew5 S12GZmiK8BSZ/SScKnk1QV4Fe5SFdSWFA9xGqGYOEOPr6AID0bVVmaucaFw/4Nsg969A HdDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Ex1LOK10; spf=pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 20si7035890qtp.249.2020.03.09.07.04.41 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Mar 2020 07:04:41 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Ex1LOK10; spf=pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1]:43564 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBJ1N-0003yB-E1 for alex.bennee@linaro.org; Mon, 09 Mar 2020 10:04:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47042) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBJ12-0003xs-8M for qemu-devel@nongnu.org; Mon, 09 Mar 2020 10:04:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBJ10-0006L2-Lr for qemu-devel@nongnu.org; Mon, 09 Mar 2020 10:04:19 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:47012 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBJ10-0006KU-Gu for qemu-devel@nongnu.org; Mon, 09 Mar 2020 10:04:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583762657; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g8bRHChsUWbeNH+K4Sm+PqbuexS/PgwjtWJOgxupBRo=; b=Ex1LOK10wyqfkso99j0VAhNk0l+pFgXrAr07Xqm3RY2uKUkywLK1+HXp58zPcXBtT1yQo/ PeEV8zSuwnU7N4eTg9AXYxZeceSWhYkDF9n/+fciuVzBApyYb6oA1LAtXeGAoCGOdaw5g9 3I26jSgvVpMB+rrEMsVMqdS0Jgi12PI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-266-04HqLq1VPK6gT12MpXrf0g-1; Mon, 09 Mar 2020 10:04:16 -0400 X-MC-Unique: 04HqLq1VPK6gT12MpXrf0g-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 935241005509; Mon, 9 Mar 2020 14:04:14 +0000 (UTC) Received: from [10.36.116.59] (ovpn-116-59.ams2.redhat.com [10.36.116.59]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 267F08B773; Mon, 9 Mar 2020 14:04:12 +0000 (UTC) Subject: Re: [PATCH v3 5/6] hw/arm/virt: kvm: Check the chosen gic version is supported by the host To: Peter Maydell References: <20200302105516.5972-1-eric.auger@redhat.com> <20200302105516.5972-6-eric.auger@redhat.com> From: Auger Eric Message-ID: Date: Mon, 9 Mar 2020 15:04:11 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marc Zyngier , Andrew Jones , qemu-arm , QEMU Developers , Eric Auger Errors-To: qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org Sender: "Qemu-devel" X-TUID: l0jbtizUBKd4 Hi Peter, On 3/9/20 2:28 PM, Peter Maydell wrote: > On Mon, 2 Mar 2020 at 10:55, Eric Auger wrote: >> >> Restructure the finalize_gic_version with switch cases and, in >> KVM mode, explictly check whether the chosen version is supported >> by the host. >> >> if the end-user explicitly sets v2/v3 and this is not supported by >> the host, then the user gets an explicit error message. >> >> Signed-off-by: Eric Auger >> Reviewed-by: Richard Henderson >> Reviewed-by: Andrew Jones >> >> --- >> >> v2 -> v3: >> - explictly list V2 and V3 in the switch/case >> - fix indent >> --- >> hw/arm/virt.c | 77 +++++++++++++++++++++++++++++++++++---------------- >> 1 file changed, 53 insertions(+), 24 deletions(-) >> >> diff --git a/hw/arm/virt.c b/hw/arm/virt.c >> index eb8c57c85e..aeb6c45e51 100644 >> --- a/hw/arm/virt.c >> +++ b/hw/arm/virt.c >> @@ -1542,33 +1542,62 @@ static void virt_set_memmap(VirtMachineState *vms) >> */ >> static void finalize_gic_version(VirtMachineState *vms) >> { >> - if (vms->gic_version == VIRT_GIC_VERSION_HOST || >> - vms->gic_version == VIRT_GIC_VERSION_MAX) { >> - if (!kvm_enabled()) { >> - if (vms->gic_version == VIRT_GIC_VERSION_HOST) { >> - error_report("gic-version=host requires KVM"); >> - exit(1); >> - } else { >> - /* "max": currently means 3 for TCG */ >> - vms->gic_version = VIRT_GIC_VERSION_3; >> - } >> - } else { >> - int probe_bitmap = kvm_arm_vgic_probe(); >> + if (kvm_enabled()) { >> + int probe_bitmap = kvm_arm_vgic_probe(); > > Previously we would only do kvm_arm_vgic_probe() if the > user asked for 'host' or 'max'. Now we do it always, > which means that if the user is on a really old kernel > where the CREATE_DEVICE ioctl doesn't exist then we > will now fail if the user specifically asked for gicv2, > where previously we (probably) would have succeeded. > I don't think we should put too much weight on continuing > to theoretically support ancient kernels which we're not > actually testing against, but it does seem a bit odd to > probe even if we don't need to know the answer. > > More relevant to actual plausible use cases, if > kvm_irqchip_in_kernel() == false, we shouldn't be > probing the kernel to ask what kind of GIC to use. OK I will fix that case. I understand that the former point is not critical. Thank you for the feedback. Eric > > thanks > -- PMM >