From patchwork Sat Jul 14 17:05:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10524783 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 1818460626 for ; Sat, 14 Jul 2018 17:06:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 025E228A0D for ; Sat, 14 Jul 2018 17:06:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EAF0B28A27; Sat, 14 Jul 2018 17:06:28 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F21D28A0E for ; Sat, 14 Jul 2018 17:06:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730209AbeGNR0F (ORCPT ); Sat, 14 Jul 2018 13:26:05 -0400 Received: from mail-ve1eur02hn0215.outbound.protection.outlook.com ([104.47.6.215]:40256 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729201AbeGNR0F (ORCPT ); Sat, 14 Jul 2018 13:26:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UkGDR4gAk9DOjvKVENoa2lePOCVOEnZyVuWBrcInxfg=; b=D7S57ddFq5wue5/QWXKpM30Ditfj94h0oFs5ewNKKNv6rSy9EehGK5xj4ChrVUWfXovGjNAVLAfhRfpIG5eVz1QoGeE2gnMmUkQLkF/kfEKdcI3R/4RlZNg0BGN3OozJjj1qtg3YTNG4xjYgw4YVl1KAFUG/P+xk4hNsie8b0+M= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Christoffer.Dall@arm.com; Received: from localhost (217.140.96.140) by DB6PR0801MB2038.eurprd08.prod.outlook.com (2603:10a6:4:76::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.952.19; Sat, 14 Jul 2018 17:06:15 +0000 From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Cc: kvm@vger.kernel.org, Marc Zyngier , Eric Auger , Andre Przywara , Peter Maydell , Christoffer Dall Subject: [PATCH v3 6/9] KVM: arm/arm64: vgic: Allow configuration of interrupt groups Date: Sat, 14 Jul 2018 19:05:37 +0200 Message-Id: <1531587940-2490-7-git-send-email-christoffer.dall@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1531587940-2490-1-git-send-email-christoffer.dall@arm.com> References: <1531587940-2490-1-git-send-email-christoffer.dall@arm.com> MIME-Version: 1.0 X-Originating-IP: [217.140.96.140] X-ClientProxiedBy: CWLP265CA0212.GBRP265.PROD.OUTLOOK.COM (2603:10a6:401:4e::32) To DB6PR0801MB2038.eurprd08.prod.outlook.com (2603:10a6:4:76::19) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a04e8354-6fe4-4d2e-8ada-08d5e9ac1bc5 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600053)(711020)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(48565401081)(2017052603328)(7153060)(7193020); SRVR:DB6PR0801MB2038; X-Microsoft-Exchange-Diagnostics: 1; DB6PR0801MB2038; 3:2BRxwuctBXa9EeQDyYfyI/nmSPhy+ghlQ+VXkBnmOq97N/7V+yhdA3BtFhF2O7J6t8V0BqwV09+qtVjfuxGV6guxyaNhOrY0cHPPqwHQs7PgaV5u3G+sUqF5L2WMAw61jO2i2iobQNafjTA/tCB3UCCR0ZTUtAGKXmMaHhf3GJa6KicBdDR4V+vOA0Sz+9C3geHOIWVeA8zHvnVQ1JXqUvE9Pv77ok0afWFGlDXVS70crNgpXJWt4uuYMUNWTfId; 25:CjJa+4iJMwgsd32ENCV3QJeYvlXXpE3bMpXHgrdpvPPnGftrLDZIE426unnWxdVPVz+yCi6xvy6dUWB7H+rDjmlD1Vjgmvt/U11cFTqu21GoV+RQ85/kis44iIPXv/I9sVr0jqWiahxBH922H5+lAN40Yxl2B3As15sKxZ0Jz/fLurkFcsa8cFXvZFG2XqygyPnqJc48k/R+1UUq7pmhSLnza7gbxYm5yd6TQA3AyWW8jshQa+bPuHP4ZmOWNq0fRQdDwchFXwdg+LQeDY/Dlyta7z2HGDeNxn+ZOcwQ2/QXEUrMe1JORmALlRHTDJsDMNgIJONiGucHfrHZNqQrSg==; 31:v9hdbFVavqi+NKGy284W7pUSXUsgEj31TIiO8BxLdlGgvVpW9C5Bl28Z6tThakr3bxyPvPC034+9xckF0Fy7In1snolefc5IT5p2Liv3qSVSvJIKdbrLdkcOsBA4paII1XSSMhXPhiiK/k6l5cfGNAQuvFAXeQh2hUH9twcWCHMVHu1WWLRaXtJpYui4zibuw6Oltpm9vB2FsWXHSQ3JzCjg1rwNj7spyp5nND0EAB4= X-MS-TrafficTypeDiagnostic: DB6PR0801MB2038: X-Microsoft-Exchange-Diagnostics: 1; DB6PR0801MB2038; 20:RCYsmcM4Qs3wztdYWZwIClb4Pyx/Tsdp2odv3A75PLGmnld23CH/OB4uWhtKRapNmaIuHgYsWbab4DttPV9c8cLyalbvJyhM3V+uVNnIQ78fAMgkW2WN7NRxR6dXDAuZn3108kBsXXVxM9VxBovzMAUFM/gZbkQe7bM6vyJRzihu6yuSqVx0VfEzbA+ZzZUyf1SlWEwTIE9pye4ECFxEEKWRIunTwkorDHRVTy6TGgqQyR1upHMXPKM8MkngEhsChxjIB68vCqxHjhNNUa0fJUB2ZBaBkXHWF3n7DR6PoJH7dWMnIrdhMz8U0C6H5U0tVQ+i6vnhzDp7nLMl7h8Wtt7eCJqbY/IdiyRa75/RbabQjlIvM/lK05/fl8Lhq2Vy0EhvR2nGz/dX/vBBqy2hdeCrWiCXBYqVViXGV0KNQmF9abWkJwt8eYC7Uwo5T9xa87GCGLOHER5egRLqFkCUzwidWjtJRcPABKWNOxAbAU9txNlxVdkkkrarzn9OGzCp; 4:uvjgoC4fykdJWUeL23Qxf0Wihxi/wqao6x47IP88YE+zylXHhyunoZGlKPXb3wLkE5LS6ci0yHQUTrgqFbQRekxRH6ZzHJE9+lcnEG1dy3wfhzcrprfTd/aUxu48aLa5ArD0QxWzRmKR4fYjOjd21xsuGC+yExvUOFx1KYWBuNmbfvOmBH26vvadUjpO8ySO2+h/mFhkGQnAxixg3DgpA4fhboMfgauZAf2z3upJw1mryeRgGsakUFxpoXeOntihqiTtCFtSEX//4BkeVxG8SBjiEkgWDEuA9uhV2TuqmE8c3W//63kLpkDJCBTX1BLNFCf+eDqBvewxxWbDRSC/eatXyT+D8/ZAW72L2rBEntE= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917)(223705240517415); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231311)(944501410)(52105095)(10201501046)(3002001)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(20161123560045)(20161123562045)(201703131423095)(201703061421075)(201703161042150)(20161123564045)(20161123558120)(6042181)(6072148)(201708071742011)(7699016); SRVR:DB6PR0801MB2038; BCL:0; PCL:0; RULEID:; SRVR:DB6PR0801MB2038; X-Forefront-PRVS: 07334CBCCD X-Forefront-Antispam-Report: SFV:SPM; SFS:(10009020)(6069001)(366004)(40434004)(189003)(199004)(97736004)(81166006)(8936002)(8746002)(26005)(8676002)(81156014)(386003)(51416003)(186003)(105586002)(6496006)(7736002)(36756003)(76506005)(4326008)(305945005)(16526019)(76176011)(52116002)(2906002)(25786009)(106356001)(50226002)(68736007)(72206003)(2171002)(54906003)(5660300001)(2616005)(53936002)(48376002)(47776003)(486006)(50466002)(476003)(6486002)(66066001)(6666003)(3846002)(6116002)(86362001)(575784001)(446003)(44832011)(956004)(14444005)(11346002)(5024004)(498600001)(23200700001); DIR:OUT; SFP:1501; SCL:5; SRVR:DB6PR0801MB2038; H:localhost; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DB6PR0801MB2038; 23:0uTpUuX635H5NdBpbGpzIrvPCY3q6yJXgGzFe9e?= =?us-ascii?Q?sJErXjK6uJWcpntFlUWxmeJJxpUzhfEMMzJOxTsVRm3ej0FWfLbrphurp4Tq?= =?us-ascii?Q?A9RSwJUHobFhqTRZ3Ko4fOWlHg8DvhN42RVZrVBdh1R0rlg/u5hiaTZ4YTBB?= =?us-ascii?Q?5G1R3lZlJUaufZVT3RAZVZSxS72+jo9J3vsD6Viutq3UV4k8oysq66bdSk2J?= =?us-ascii?Q?7YiIgk28/f5b+lTfPNY/M2M1EZfm+i4wCTkg19oOVfVZ9Tg8PXDUujTTvIFg?= =?us-ascii?Q?TmKyRnfCLCstlnkmiKXDmaL2Suk6LDodmu+sdRKciKytPBqtZ8CE3YeBwTD4?= =?us-ascii?Q?4r6xquBNqj8s/jeixuO5HFSQ99pWxmti0ZijEgeCNeDB41/T6j2sHY/h4vlb?= =?us-ascii?Q?BThlfSWRLTE5y0iqtPcGWii+TT2dH2WOo4Gp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gETS5awPhjsppsGKtZaa1Zi53QtF/zIwhXB2+4lTUj05QpOSfUPuNJUXyQDL/OWACItfWSx6F7dyB3eazLWTHZiT; 5:wNqOn4GarnG8/nLkUkmli974qVSa2pJLRg8OX2w5kcE52cZmS6BVKq0ZD3Ltlca7ekK9kVHBxmGNY4hPVhFFAhOFTSgFY1/zBX0xj6ZAxBzSOzCLmKyWIyBuWg2RYjS2QkolQbGrcCrKN9V8upWEGhsBpmxsDaLdbteCz+owUmw=; 24:Os7S+QoznsnVv2ox/+H4Zgl1qvZHiLxH00qOB06/LH0rkZ8deNNFeOGBTVH7XonkUjGeyRte0jlP4g42tJU5Sg== SpamDiagnosticOutput: 1:22 X-Microsoft-Exchange-Diagnostics: 1; DB6PR0801MB2038; 7:cVPw87EOvi6+aG3s62L3GdQKEaRDAF0IzX4VAbdjk1C0telJieOa//c9MCy9uHeqt6dl/7xlHFfERl/LK1tgOXkEjA7oCb6LCqwSTmySLoZQkEaa9/2CL4dlFG7K8F7UFUXlWPnedklyKmzS/Fx4pINg8NXpV5jyi2mwEmWkHOuS4am+F5SJzcMVH+JG2cjTUemEeoxhmtvQzKt8ZKdKO5ms+FD6bSOM8fBPLFz6uqeU2U7F+DTc2lVwcZQWzX7T X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2018 17:06:15.0489 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a04e8354-6fe4-4d2e-8ada-08d5e9ac1bc5 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB2038 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Implement the required MMIO accessors for GICv2 and GICv3 for the IGROUPR distributor and redistributor registers. This can allow guests to change behavior compared to running on previous versions of KVM, but only to align with the architecture and hardware implementations. This also allows userspace to configure the interrupts groups for GICv3. We don't allow userspace to write the groups on GICv2 just yet, because that would result in GICv2 guests not receiving interrupts after migrating from an older kernel that exposes GICv2 interrupts as group 1. Signed-off-by: Christoffer Dall --- virt/kvm/arm/vgic/vgic-init.c | 2 +- virt/kvm/arm/vgic/vgic-mmio-v2.c | 12 +++++++++++- virt/kvm/arm/vgic/vgic-mmio-v3.c | 11 +++++++++-- virt/kvm/arm/vgic/vgic-mmio.c | 38 ++++++++++++++++++++++++++++++++++++++ virt/kvm/arm/vgic/vgic-mmio.h | 6 ++++++ 5 files changed, 65 insertions(+), 4 deletions(-) -- 2.7.4 IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you. diff --git a/virt/kvm/arm/vgic/vgic-init.c b/virt/kvm/arm/vgic/vgic-init.c index a7c19cd..c0c0b88 100644 --- a/virt/kvm/arm/vgic/vgic-init.c +++ b/virt/kvm/arm/vgic/vgic-init.c @@ -313,7 +313,7 @@ int vgic_init(struct kvm *kvm) vgic_debug_init(kvm); - dist->implementation_rev = 1; + dist->implementation_rev = 2; dist->initialized = true; out: diff --git a/virt/kvm/arm/vgic/vgic-mmio-v2.c b/virt/kvm/arm/vgic/vgic-mmio-v2.c index db646f1..34e36fc 100644 --- a/virt/kvm/arm/vgic/vgic-mmio-v2.c +++ b/virt/kvm/arm/vgic/vgic-mmio-v2.c @@ -26,6 +26,8 @@ * The Revision field in the IIDR have the following meanings: * * Revision 1: Report GICv2 interrupts as group 0 instead of group 1 + * Revision 2: Interrupt groups are guest-configurable and signaled using + * their configured groups. */ static unsigned long vgic_mmio_read_v2_misc(struct kvm_vcpu *vcpu, @@ -75,6 +77,13 @@ static void vgic_mmio_write_v2_misc(struct kvm_vcpu *vcpu, } } +static void vgic_mmio_uaccess_write_v2_group(struct kvm_vcpu *vcpu, + gpa_t addr, unsigned int len, + unsigned long val) +{ + /* Ignore writes from userspace */ +} + static void vgic_mmio_write_sgir(struct kvm_vcpu *source_vcpu, gpa_t addr, unsigned int len, unsigned long val) @@ -371,7 +380,8 @@ static const struct vgic_register_region vgic_v2_dist_registers[] = { vgic_mmio_read_v2_misc, vgic_mmio_write_v2_misc, 12, VGIC_ACCESS_32bit), REGISTER_DESC_WITH_BITS_PER_IRQ(GIC_DIST_IGROUP, - vgic_mmio_read_raz, vgic_mmio_write_wi, NULL, NULL, 1, + vgic_mmio_read_group, vgic_mmio_write_group, + NULL, vgic_mmio_uaccess_write_v2_group, 1, VGIC_ACCESS_32bit), REGISTER_DESC_WITH_BITS_PER_IRQ(GIC_DIST_ENABLE_SET, vgic_mmio_read_enable, vgic_mmio_write_senable, NULL, NULL, 1, diff --git a/virt/kvm/arm/vgic/vgic-mmio-v3.c b/virt/kvm/arm/vgic/vgic-mmio-v3.c index ebe10a0..49df2a1 100644 --- a/virt/kvm/arm/vgic/vgic-mmio-v3.c +++ b/virt/kvm/arm/vgic/vgic-mmio-v3.c @@ -59,6 +59,13 @@ bool vgic_supports_direct_msis(struct kvm *kvm) return kvm_vgic_global_state.has_gicv4 && vgic_has_its(kvm); } +/* + * The Revision field in the IIDR have the following meanings: + * + * Revision 2: Interrupt groups are guest-configurable and signaled using + * their configured groups. + */ + static unsigned long vgic_mmio_read_v3_misc(struct kvm_vcpu *vcpu, gpa_t addr, unsigned int len) { @@ -454,7 +461,7 @@ static const struct vgic_register_region vgic_v3_dist_registers[] = { vgic_mmio_read_rao, vgic_mmio_write_wi, 4, VGIC_ACCESS_32bit), REGISTER_DESC_WITH_BITS_PER_IRQ_SHARED(GICD_IGROUPR, - vgic_mmio_read_rao, vgic_mmio_write_wi, NULL, NULL, 1, + vgic_mmio_read_group, vgic_mmio_write_group, NULL, NULL, 1, VGIC_ACCESS_32bit), REGISTER_DESC_WITH_BITS_PER_IRQ_SHARED(GICD_ISENABLER, vgic_mmio_read_enable, vgic_mmio_write_senable, NULL, NULL, 1, @@ -527,7 +534,7 @@ static const struct vgic_register_region vgic_v3_rdbase_registers[] = { static const struct vgic_register_region vgic_v3_sgibase_registers[] = { REGISTER_DESC_WITH_LENGTH(GICR_IGROUPR0, - vgic_mmio_read_rao, vgic_mmio_write_wi, 4, + vgic_mmio_read_group, vgic_mmio_write_group, 4, VGIC_ACCESS_32bit), REGISTER_DESC_WITH_LENGTH(GICR_ISENABLER0, vgic_mmio_read_enable, vgic_mmio_write_senable, 4, diff --git a/virt/kvm/arm/vgic/vgic-mmio.c b/virt/kvm/arm/vgic/vgic-mmio.c index ff9655c..ae31bd0 100644 --- a/virt/kvm/arm/vgic/vgic-mmio.c +++ b/virt/kvm/arm/vgic/vgic-mmio.c @@ -40,6 +40,44 @@ void vgic_mmio_write_wi(struct kvm_vcpu *vcpu, gpa_t addr, /* Ignore */ } +unsigned long vgic_mmio_read_group(struct kvm_vcpu *vcpu, + gpa_t addr, unsigned int len) +{ + u32 intid = VGIC_ADDR_TO_INTID(addr, 1); + u32 value = 0; + int i; + + /* Loop over all IRQs affected by this read */ + for (i = 0; i < len * 8; i++) { + struct vgic_irq *irq = vgic_get_irq(vcpu->kvm, vcpu, intid + i); + + if (irq->group) + value |= BIT(i); + + vgic_put_irq(vcpu->kvm, irq); + } + + return value; +} + +void vgic_mmio_write_group(struct kvm_vcpu *vcpu, gpa_t addr, + unsigned int len, unsigned long val) +{ + u32 intid = VGIC_ADDR_TO_INTID(addr, 1); + int i; + unsigned long flags; + + for (i = 0; i < len * 8; i++) { + struct vgic_irq *irq = vgic_get_irq(vcpu->kvm, vcpu, intid + i); + + spin_lock_irqsave(&irq->irq_lock, flags); + irq->group = !!(val & BIT(i)); + vgic_queue_irq_unlock(vcpu->kvm, irq, flags); + + vgic_put_irq(vcpu->kvm, irq); + } +} + /* * Read accesses to both GICD_ICENABLER and GICD_ISENABLER return the value * of the enabled bit, so there is only one function for both here. diff --git a/virt/kvm/arm/vgic/vgic-mmio.h b/virt/kvm/arm/vgic/vgic-mmio.h index 5693f6df..1079862 100644 --- a/virt/kvm/arm/vgic/vgic-mmio.h +++ b/virt/kvm/arm/vgic/vgic-mmio.h @@ -134,6 +134,12 @@ unsigned long vgic_mmio_read_rao(struct kvm_vcpu *vcpu, void vgic_mmio_write_wi(struct kvm_vcpu *vcpu, gpa_t addr, unsigned int len, unsigned long val); +unsigned long vgic_mmio_read_group(struct kvm_vcpu *vcpu, gpa_t addr, + unsigned int len); + +void vgic_mmio_write_group(struct kvm_vcpu *vcpu, gpa_t addr, + unsigned int len, unsigned long val); + unsigned long vgic_mmio_read_enable(struct kvm_vcpu *vcpu, gpa_t addr, unsigned int len);