From patchwork Thu Mar 15 20:30:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 131880 Delivered-To: patch@linaro.org Received: by 10.46.84.17 with SMTP id i17csp1580841ljb; Thu, 15 Mar 2018 13:35:01 -0700 (PDT) X-Google-Smtp-Source: AG47ELt33BcgsDcMNPHceJ6bP3ua6gyeq7xSIriiL8eu8d4FDSRx+56eGkKX6QdAay4BY0NyFJJ7 X-Received: by 10.36.37.149 with SMTP id g143mr7957505itg.85.1521146011560; Thu, 15 Mar 2018 13:33:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521146011; cv=none; d=google.com; s=arc-20160816; b=kNZ4Zy4jE5Wb80SJHgXDDipO2wqmUesaY1Ed3kROOSqjsBD9+f8G2Ke8m2uth0Apq2 7nN8s/0YAeJGDRaBmPHHBeMQavDYMnyGHdmM9v0Cqg0VELpYMiVv8mRGFNQdBxowIS84 s9Sev3MnDT37z0Eud4lvFu8KnL2p2uthIvZSzMr8mu/tLQyNxREq3Z9OTBBHN1se495n y3fa8cDO5ACR6DBSxpZgO9QD2cNsauKnmDOvmfJCHq49uqMJZvVwabecEHmK+nxUEvaC 2dCLnaeoBeOncXHwmzbAgA7PD9BPwJgG+HfFXo7ehWo6VUEheJS0hK9doqjCuyrlaDPc wBjg== 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=jED8s+98yauHirR9YoiAgfsHTtYLdKsYtQQDRjCLB8M=; b=ZeeMgz+blyqFNLJHIbGHO40RqEAKBQJvYweEoZgcuxMAaXejyzPQYuEVmQq6oqmlbE AIZxOstYuM8yUwfNPYIVrcd30c7WsPLs2jCTYgH+MDy2UQK1Qiwzd2zAGNmka+CBMKwY 3P3JM/grnhc7Rg5SnGaSCcQv56g53hsAIACixsnJSldDZX8QmKSXH+T/oqNGLcDtF8aW GaljPDryyLoVsBGg8LB3iM0VxEJp/q4uyJEQufYQXKdzTUShBzLfyaDPIsJDmzjHayGg j9r+/v/hSMDIgtfmwHpjzaYdUiV3Ej5TtZoGy9ufEAUk+jAmPcWoy21oJOnABII/4ZiE 9UbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=gU/heCKA; 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 d72-v6si2863488itb.140.2018.03.15.13.33.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Mar 2018 13:33:31 -0700 (PDT) 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=gU/heCKA; 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 1ewZWp-00031i-SB; Thu, 15 Mar 2018 20:31:11 +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 1ewZWp-00030z-C2 for xen-devel@lists.xenproject.org; Thu, 15 Mar 2018 20:31:11 +0000 X-Inumbo-ID: c85b6002-288f-11e8-9728-bc764e045a96 Received: from mail-wm0-x242.google.com (unknown [2a00:1450:400c:c09::242]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id c85b6002-288f-11e8-9728-bc764e045a96; Thu, 15 Mar 2018 21:31:04 +0100 (CET) Received: by mail-wm0-x242.google.com with SMTP id u10so12784575wmu.4 for ; Thu, 15 Mar 2018 13:31:10 -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=7VUJdTPcPNGCSCjjb6iIv1/1PpejE5laqUHew1Mq4mc=; b=gU/heCKAuvctPQN8FMrebxcjszddB8b3vel6fHMEn5acruqWcr87hcFKx2+kXYtpWO 1AAfV4s02QZKATIac4UQKBgYmc0ibS8gxeuslLuH2M56vR0JHu20IE7tt8TdSR85+Je/ KY4c6xwjyJPKUW8OQ6wmq64oQ+sKKgjOlccQY= 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=7VUJdTPcPNGCSCjjb6iIv1/1PpejE5laqUHew1Mq4mc=; b=SqXW+TXQi4kCvA1JpfLEMsgoDhfeIPvE58qNAtCwcW4JVlg6w/BSrtxoEjNsPQn6r7 XdZ8fkUJPSdn5CDnqt+FEXCsVCY7uC6KJKCcOxx527GQ9zgt8gBg39IYJnNi+j4x/OmX OK4kwWRV3QzeAhQIEimAfpQoTZJ7CQNtjnPDq/79GOLuZOZo8z7l429NbqY8Pu4zmix0 uwwIQXSngZSOR2DZxemO5okmuVe4DNVUffw6sQNOoLaR3R0qexXK6me7oeTKsZe8bAsh WjbUt3LDvUQ5Ob9hs/9x0VZDCk9wePFIjxT0x7rh/mHHa8oK6tM/qsKJNDpY8r0d5F7J pnjw== X-Gm-Message-State: AElRT7FNngPN8Z/5pukDkGm4DjJrWgxv7jXZ2JHUhCFqTakRieddUMiq VVhCfidNDg80IlhbbD9kItDe9A== X-Received: by 10.28.173.198 with SMTP id w189mr6242698wme.139.1521145869229; Thu, 15 Mar 2018 13:31:09 -0700 (PDT) Received: from e104803-lin.lan (mail.andrep.de. [217.160.17.100]) by smtp.gmail.com with ESMTPSA id w125sm3217102wmw.20.2018.03.15.13.31.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Mar 2018 13:31:08 -0700 (PDT) From: Andre Przywara To: Stefano Stabellini , Julien Grall Date: Thu, 15 Mar 2018 20:30:09 +0000 Message-Id: <20180315203050.19791-5-andre.przywara@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180315203050.19791-1-andre.przywara@linaro.org> References: <20180315203050.19791-1-andre.przywara@linaro.org> Cc: xen-devel@lists.xenproject.org, Andre Przywara Subject: [Xen-devel] [PATCH v2 04/45] xen/arm: vgic: Override the group in lr everytime 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" From: Julien Grall At the moment, write_lr is assuming the caller will set correctly the group. However the group should always be 0 when the guest is using vGICv2 and 1 for vGICv3. As the caller should not care about the group, override it directly. With that change, write_lr is now behaving like update_lr for the group. Signed-off-by: Julien Grall Reviewed-by: Andre Przywara Signed-off-by: Andre Przywara Acked-by: Stefano Stabellini --- Changes: - Add Andre's reviewed-by xen/arch/arm/gic-v2.c | 4 +--- xen/arch/arm/gic-v3.c | 11 ++++++++--- xen/include/asm-arm/gic.h | 1 - 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c index f16e17c1a3..fc105c08b8 100644 --- a/xen/arch/arm/gic-v2.c +++ b/xen/arch/arm/gic-v2.c @@ -469,7 +469,6 @@ static void gicv2_read_lr(int lr, struct gic_lr *lr_reg) lr_reg->priority = (lrv >> GICH_V2_LR_PRIORITY_SHIFT) & GICH_V2_LR_PRIORITY_MASK; lr_reg->state = (lrv >> GICH_V2_LR_STATE_SHIFT) & GICH_V2_LR_STATE_MASK; lr_reg->hw_status = (lrv >> GICH_V2_LR_HW_SHIFT) & GICH_V2_LR_HW_MASK; - lr_reg->grp = (lrv >> GICH_V2_LR_GRP_SHIFT) & GICH_V2_LR_GRP_MASK; } static void gicv2_write_lr(int lr, const struct gic_lr *lr_reg) @@ -483,8 +482,7 @@ static void gicv2_write_lr(int lr, const struct gic_lr *lr_reg) ((uint32_t)(lr_reg->state & GICH_V2_LR_STATE_MASK) << GICH_V2_LR_STATE_SHIFT) | ((uint32_t)(lr_reg->hw_status & GICH_V2_LR_HW_MASK) - << GICH_V2_LR_HW_SHIFT) | - ((uint32_t)(lr_reg->grp & GICH_V2_LR_GRP_MASK) << GICH_V2_LR_GRP_SHIFT) ); + << GICH_V2_LR_HW_SHIFT)); writel_gich(lrv, GICH_LR + lr * 4); } diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c index 09b49a07d5..0dfa1a1e08 100644 --- a/xen/arch/arm/gic-v3.c +++ b/xen/arch/arm/gic-v3.c @@ -1012,7 +1012,6 @@ static void gicv3_read_lr(int lr, struct gic_lr *lr_reg) lr_reg->priority = (lrv >> ICH_LR_PRIORITY_SHIFT) & ICH_LR_PRIORITY_MASK; lr_reg->state = (lrv >> ICH_LR_STATE_SHIFT) & ICH_LR_STATE_MASK; lr_reg->hw_status = (lrv >> ICH_LR_HW_SHIFT) & ICH_LR_HW_MASK; - lr_reg->grp = (lrv >> ICH_LR_GRP_SHIFT) & ICH_LR_GRP_MASK; } static void gicv3_write_lr(int lr_reg, const struct gic_lr *lr) @@ -1023,8 +1022,14 @@ static void gicv3_write_lr(int lr_reg, const struct gic_lr *lr) ((u64)(lr->virq & ICH_LR_VIRTUAL_MASK) << ICH_LR_VIRTUAL_SHIFT) | ((u64)(lr->priority & ICH_LR_PRIORITY_MASK) << ICH_LR_PRIORITY_SHIFT)| ((u64)(lr->state & ICH_LR_STATE_MASK) << ICH_LR_STATE_SHIFT) | - ((u64)(lr->hw_status & ICH_LR_HW_MASK) << ICH_LR_HW_SHIFT) | - ((u64)(lr->grp & ICH_LR_GRP_MASK) << ICH_LR_GRP_SHIFT) ); + ((u64)(lr->hw_status & ICH_LR_HW_MASK) << ICH_LR_HW_SHIFT) ); + + /* + * When the guest is using vGICv3, all the IRQs are Group 1. Group 0 + * would result in a FIQ, which will not be expected by the guest OS. + */ + if ( current->domain->arch.vgic.version == GIC_V3 ) + lrv |= ICH_LR_GRP1; gicv3_ich_write_lr(lr_reg, lrv); } diff --git a/xen/include/asm-arm/gic.h b/xen/include/asm-arm/gic.h index 49cb94f792..1eb08b856e 100644 --- a/xen/include/asm-arm/gic.h +++ b/xen/include/asm-arm/gic.h @@ -211,7 +211,6 @@ struct gic_lr { uint8_t priority; uint8_t state; uint8_t hw_status; - uint8_t grp; }; enum gic_version {