From patchwork Mon Mar 5 16:04:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 130689 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp2854347lja; Mon, 5 Mar 2018 08:07:34 -0800 (PST) X-Google-Smtp-Source: AG47ELtxiDqYxKpgsvpSa6SpVQlri1mMBP5dAGSRY+EtX+1dUXIOllgzESFPfeyslEf9npIqfsF7 X-Received: by 10.107.58.139 with SMTP id h133mr18518575ioa.250.1520266054149; Mon, 05 Mar 2018 08:07:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520266054; cv=none; d=google.com; s=arc-20160816; b=YbfQ5YRfJ7TkxWn3VErxY4lguESft2S+qRJG0xOlbCZUsLACZ8SLZ7+YxJsIIQeo1P W5uPIebAqqfU/b90WrKsOOwjz9XN8i+jH235qoLglYjabu0ExmQaRnptMEVXwEcEKvsu XPyaDS6WVJuyj94jrd6VuECKndtx5cVXqMA6ee2wrLczu8wtVMbbGYbnKYP5QxareJaq ywJuLS6Bs14ftAj8hKuZJw9FKflPK+vuXP1TlsU2B6o4qMzg9S5FoZoGzn5MyRwGk2il qMk8ppjlZOt2i+m/5hMAQyS1V9bQrl3uRqxFEpIGMYHaHYX9G1aVy0zb+OB5rtCMpNqW w/Aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=2Y3HCBAmFWb7ZVM0ylCSvVQ9O4upxQatDnbsXhcefRI=; b=xdEM9QolO52S+S+QffO0nJau++G5BjHuSQUCi0iTKRts5NrqlvaSusT5ML/8U4lysQ lj+UqYNHfbwt6rScJ3BwfN5+DxuJGEjp6oRgb8sWK1KsqKsu9gAEWp6JybK9g6v6XSOP J1iS/348xMxPWB/ZQBJjOoYbXApPNi20Oe1t6bTFD4CD5+9F+mMyCmyNVDy6YELVHXt/ 9Og3zi3ACUQSEvY1xoSlp6OM4WZEIELLxBhhquh1UmQhMgHZzGTq+O8tjPD3THanD9MA uBld5FxcnzQQbWD5FW3ej6bYHgU+nUBieqO3c/zcy1jnmBKhLt1Hj5TUFM0gAKiUXk/Q pMDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=QbbsL4fC; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id p22si9121555ioi.274.2018.03.05.08.07.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Mar 2018 08:07:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=QbbsL4fC; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1essc4-0000oR-0o; Mon, 05 Mar 2018 16:05:20 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1essc2-0000hs-KJ for xen-devel@lists.xenproject.org; Mon, 05 Mar 2018 16:05:18 +0000 X-Inumbo-ID: d723b697-208e-11e8-ba59-bc764e045a96 Received: from mail-wm0-x243.google.com (unknown [2a00:1450:400c:c09::243]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id d723b697-208e-11e8-ba59-bc764e045a96; Mon, 05 Mar 2018 17:04:10 +0100 (CET) Received: by mail-wm0-x243.google.com with SMTP id t74so17015028wme.3 for ; Mon, 05 Mar 2018 08:05:16 -0800 (PST) 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=4/BuLMNJp9Vz0E9IVKa5Ps1AVXKJnAUjdjrcoVPSRCw=; b=QbbsL4fCQ459AmF7NgSdz9n+2k506vwUwM45gygeCqpQPE0Er6iAQBJRSM2tGYdf9i Bm7UwZCWY0NACpwidMZbFcZwYEEbCBYVMA+N/TfzlL/bmoUvrO3ZM2dmW2l/9hY3oTuz j8a4zLV0TAbalGkumtECyozL+h1hPoirTrvWU= 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=4/BuLMNJp9Vz0E9IVKa5Ps1AVXKJnAUjdjrcoVPSRCw=; b=VYsKthKYQ2o5O15y+BENPA5qrqLHHkm1fisjkl9eK48JWxiJ0EJKlPpyMMtKlBVDzQ WMmeGQpg8rB4Aquz7W2m038WC5eSPGmj9LAsadiAzxu+6Ce8A00NhbO8dOHyIP5QU67n nmEAOdf7qvTLUsj32UDSQyKO92ZZQu88BrXT4ewd9Tvnmu8Bdpc0E71Djb2eWDEmdJzY q1AsWluWgIuGytbh3pKIFpmuKNh7IqxX+RYf2Qw4m6L2oW2i3lyNG4GTZ2EqklB/m1Rw v9H7QSU/DZowFiyRt/8Ja19UmNw4z0QYhznxIXeIoAW3ZmWYXMr/FoymK5+O2VRJnD/4 veAg== X-Gm-Message-State: AElRT7GjJQX9NTHQPvqMWhyncTok3NTtwQJjg/3zSzjEeIn5B8oDTX8O 9FrUGOI5DpI8oPeNJmA30fDOngSPGVU= X-Received: by 10.28.229.17 with SMTP id c17mr8259997wmh.1.1520265915410; Mon, 05 Mar 2018 08:05:15 -0800 (PST) Received: from e104803-lin.lan (mail.andrep.de. [217.160.17.100]) by smtp.gmail.com with ESMTPSA id y6sm6574381wmy.14.2018.03.05.08.05.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 05 Mar 2018 08:05:14 -0800 (PST) From: Andre Przywara To: Julien Grall , Stefano Stabellini Date: Mon, 5 Mar 2018 16:04:10 +0000 Message-Id: <20180305160415.16760-53-andre.przywara@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180305160415.16760-1-andre.przywara@linaro.org> References: <20180305160415.16760-1-andre.przywara@linaro.org> Cc: xen-devel@lists.xenproject.org Subject: [Xen-devel] [PATCH 52/57] ARM: new VGIC: vgic-init: register VGIC X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" This patch implements the function which is called by Xen when it wants to register the virtual GIC. This also implements domain_max_vcpus() for the new VGIC, which reports back the maximum number of VCPUs a certain GIC model supports. Signed-off-by: Andre Przywara --- Changelog RFC ... v1: - split off definition of domain_max_vcpus() xen/arch/arm/vgic/vgic-init.c | 60 +++++++++++++++++++++++++++++++++++++++++++ xen/arch/arm/vgic/vgic.c | 22 ++++++++++++++++ xen/arch/arm/vgic/vgic.h | 3 +++ 3 files changed, 85 insertions(+) create mode 100644 xen/arch/arm/vgic/vgic-init.c diff --git a/xen/arch/arm/vgic/vgic-init.c b/xen/arch/arm/vgic/vgic-init.c new file mode 100644 index 0000000000..d091c92ed0 --- /dev/null +++ b/xen/arch/arm/vgic/vgic-init.c @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2015, 2016 ARM Ltd. + * Imported from Linux ("new" KVM VGIC) and heavily adapted to Xen. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include + +#include "vgic.h" + +/* CREATION */ + +/** + * domain_vgic_register: create a virtual GIC + * @d: domain pointer + * @mmio_count: pointer to add number of required MMIO regions + * + * was: kvm_vgic_create + */ +int domain_vgic_register(struct domain *d, int *mmio_count) +{ + switch ( d->arch.vgic.version ) + { + case GIC_V2: + *mmio_count = 1; + break; + default: + BUG(); + } + + if ( d->max_vcpus > domain_max_vcpus(d) ) + return -E2BIG; + + d->arch.vgic.vgic_dist_base = VGIC_ADDR_UNDEF; + d->arch.vgic.vgic_cpu_base = VGIC_ADDR_UNDEF; + d->arch.vgic.vgic_redist_base = VGIC_ADDR_UNDEF; + + return 0; +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/arch/arm/vgic/vgic.c b/xen/arch/arm/vgic/vgic.c index 5d84a4d81a..f42092fec3 100644 --- a/xen/arch/arm/vgic/vgic.c +++ b/xen/arch/arm/vgic/vgic.c @@ -956,6 +956,28 @@ void vgic_sync_hardware_irq(struct domain *d, spin_unlock_irqrestore(&desc->lock, flags); } +unsigned int domain_max_vcpus(const struct domain *d) +{ + unsigned int vgic_vcpu_limit; + + switch ( d->arch.vgic.version ) + { +#ifdef CONFIG_HAS_GICV3 + case GIC_V3: + vgic_vcpu_limit = VGIC_V3_MAX_CPUS; + break; +#endif + case GIC_V2: + vgic_vcpu_limit = VGIC_V2_MAX_CPUS; + break; + default: + vgic_vcpu_limit = MAX_VIRT_CPUS; + break; + } + + return min_t(unsigned int, MAX_VIRT_CPUS, vgic_vcpu_limit); +} + /* * Local variables: * mode: C diff --git a/xen/arch/arm/vgic/vgic.h b/xen/arch/arm/vgic/vgic.h index b294b04391..f19dc9502f 100644 --- a/xen/arch/arm/vgic/vgic.h +++ b/xen/arch/arm/vgic/vgic.h @@ -20,6 +20,9 @@ #define PRODUCT_ID_XEN 0x58 /* ASCII code X */ #define IMPLEMENTER_ARM 0x43b +#define VGIC_ADDR_UNDEF INVALID_PADDR +#define IS_VGIC_ADDR_UNDEF(_x) ((_x) == VGIC_ADDR_UNDEF) + #define VGIC_PRI_BITS 5 #define vgic_irq_is_sgi(intid) ((intid) < VGIC_NR_SGIS)