From patchwork Wed Jul 4 09:38:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10506333 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 0A3EC60532 for ; Wed, 4 Jul 2018 09:39:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E0A2128DD1 for ; Wed, 4 Jul 2018 09:39:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D4C2D28DD7; Wed, 4 Jul 2018 09:39:18 +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 1F18F28DD1 for ; Wed, 4 Jul 2018 09:39:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932908AbeGDJjQ (ORCPT ); Wed, 4 Jul 2018 05:39:16 -0400 Received: from mail-he1eur02hn0226.outbound.protection.outlook.com ([104.47.5.226]:9016 "EHLO EUR02-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933006AbeGDJiy (ORCPT ); Wed, 4 Jul 2018 05:38:54 -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=z+PidM+mfYqgpUY4GFlgTOfmN4pK8rAq0dKibDu1LkY=; b=V+AG9WxUqCTehhNNsC4lRPu4hIG0p5X8UufNBsgyl9c1WoNUbTOnXfMXd9NaKKbG/B9ah+y3uvgOZjHUP7GqGZ89Z+7jSagApg2IZR+wwHzNWk+OP4S83SRpMQ4qUBCdS/M8FowoUoru0FSiO9B2IkcPoSb8lQWmJJUsAHqXlVQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Christoffer.Dall@arm.com; Received: from localhost (217.140.96.140) by AM5PR0801MB2035.eurprd08.prod.outlook.com (2603:10a6:203:4c::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.930.18; Wed, 4 Jul 2018 09:38:51 +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 , Andrew Jones Subject: [PATCH v2 6/6] KVM: arm/arm64: vgic: Allow configuration of interrupt groups Date: Wed, 4 Jul 2018 11:38:20 +0200 Message-Id: <1530697100-22419-7-git-send-email-christoffer.dall@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1530697100-22419-1-git-send-email-christoffer.dall@arm.com> References: <1530697100-22419-1-git-send-email-christoffer.dall@arm.com> MIME-Version: 1.0 X-Originating-IP: [217.140.96.140] X-ClientProxiedBy: VI1P195CA0055.EURP195.PROD.OUTLOOK.COM (2603:10a6:802:5a::44) To AM5PR0801MB2035.eurprd08.prod.outlook.com (2603:10a6:203:4c::9) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 797c94c8-38f4-419b-aff9-08d5e191f397 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600053)(711020)(48565401081)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020); SRVR:AM5PR0801MB2035; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB2035; 3:hK+Y7uAn3W4eo+fxz/RQETSkPIW7/x/0uo3hDq7MVPYUl/sBfivyH9w2GRq4J75+hI3S6dAAzelcJaeMp0AJcT7Fs7+XAjIKiLOnqgdR/jq2FdMinPqyNv7dWPSJxjVCoKmiD6rP+TBK5xA/ZD7dVp1cLD3TMFO7ecOVBnlzSJ066uO9LQs9FZiV3NUvsVpYQoE4wZMoo3Lh9Zp+M2e+E3tabNcXZmQuNdIGZqnW262gS2Zlz6XgvRIN5PlJGh9Y; 25:RghmoaNhP/tc+cVO20GAvbf+av3p7iCC9XckqfsdDE+4LhqM1Y9FaKF2Ds/zxIUPqhg6fJc/c83zHnEkOUEEul6lopuRCoMIrbHzeNGRNPEwgXGF/fRLdOriJQhntTB3ab/pNWcRQ1+Z3KFsimxz+A3WYrTVA7BOb//oYR5lzwb1I6t/3NBDQf+7dCIrWgI2KODPiOjU4QcUe7j7k60rY1dXQ9Dm6wBJUqHiF72JZ4kDTqr0YyY776R1sKyg3BFo/nONG0qxz7o3/ZLqrveKy+wZW/BIpSMRSy8swVospZqpiUNJY7vjFi2CEWhuHLqmRaJ0HpuVta9KkDsdXf0tQg==; 31:wuofgbZKixuAEdnHehNIY6i675XW7Uxvnpuvcxo6u7J+ykGhrOyFtsFaRrrMsQmK6ozJH4ekcBiaUvvqUhS1qWUeDTmLgMV+7fVyHA4PxUDGiHuF4UvqpqLQ2guH7IAv6+FKGfqRWZ7L1+hV1Dm6YyUz/kK5N+dKe/wv7OOoqf5XksP0eAuP6eFEg6yu/GrloUM7EACkbWyyBZCdRbjDIlp1nPwNesUdqeic8pLobQw= X-MS-TrafficTypeDiagnostic: AM5PR0801MB2035: X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB2035; 20:HWlkYtfCSPDqsOARJFGi7TmyjUmCTDvXXfzvqL/G86UUoxFl1r9eOpjyD9kLXkYRZRCMiT8t+9zNQVQvNv6RC3imbljoYGU/Mlo/LYqNXcrsp/8OXhkfHNVWNW1/EXp7wQbOfI1TtqlV8lvganoB1iIzjc0kJp4nl7QtTEuqsh5w6m2IQ0fofOHa06WW8Ccrx604YR6HzQ21LLq1u+ZrsHPVoePxJPMyXRaAYjQbrw6ECYZ8MY5PDjziQo4rmPNval3nqnamMMyWa/SM/DLu3Bmxf2OTY6pvtIFDNCN7W0sRUEVSJuVRNfMYzpkZim3YBeb3NPuJIG8VNNFNRlkzYw7nMZxEnVaMrCr7RINATeiyJ8fJjoOzolp2PQPWAN1S2FXtEf3eF2YGyym2fgWwQr3l2FrqJUvMov/yWYKX7lUc2EhxKDsFEB2AhPYxzkc2+IV3IQRLo0CLuf1DRwp3r+RwxYoHpV/zcOBDh378jMLovyXjXbi6WriApOcFw9pj; 4:fK+K1EW0ymgNNBvQX1T3Tuwi9sH2sY5TTrxMfhUR0b65OMBAAptHKqplArgfytN/zg5mRR1tBpcEOasctA4B1ofghCckecMBbi+Cp/+4ma6SYUzW+8A+0LT9ThkgxGiQTtaIrneelULW825kPvXqtTyFHnVTVypHmqCmrXaAXxevxh57NYJKM5292ZvjAdwmKWvUBY0qK0bXa71wTVaox+cdcNFNXdiNZauGygceL6SbDzoI9i3XsQZh0YW+3OM24EqVoeXVJolfV2opxzzwRc3ihIyeuw6RIUhUrRAfVHVR+69ur2KobzpamMYAfr8O257XC/zmXwZB/oqbgR38uPfEwNc3NuCGQ/EMgOQRHmA= 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)(10201501046)(3231254)(944501410)(52105095)(3002001)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(20161123562045)(20161123564045)(20161123560045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:AM5PR0801MB2035; BCL:0; PCL:0; RULEID:; SRVR:AM5PR0801MB2035; X-Forefront-PRVS: 0723A02764 X-Forefront-Antispam-Report: SFV:SPM; SFS:(10009020)(6069001)(376002)(396003)(136003)(366004)(346002)(39860400002)(189003)(199004)(40434004)(386003)(66066001)(44832011)(47776003)(2906002)(486006)(81166006)(5024004)(186003)(81156014)(8676002)(26005)(76506005)(2616005)(446003)(956004)(11346002)(76176011)(476003)(14444005)(5660300001)(316002)(86362001)(575784001)(7736002)(105586002)(106356001)(305945005)(6666003)(97736004)(8746002)(25786009)(50226002)(36756003)(6496006)(50466002)(478600001)(53936002)(8936002)(6486002)(16526019)(68736007)(4326008)(48376002)(52116002)(54906003)(6116002)(51416003)(3846002)(2171002)(72206003)(23200700001); DIR:OUT; SFP:1501; SCL:5; SRVR:AM5PR0801MB2035; 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; AM5PR0801MB2035; 23:LdcL3miElpJZr/caw5PykpJov5E4kihaxq1Sxcx?= =?us-ascii?Q?9b57IRDoJT/hadDwdFrdo26KSLSVDulKfwEn3jYTwJicFNnVcLG/wJ8eIJSS?= =?us-ascii?Q?71uqJU6JQeyRo/z+1OnAkciYDHP9m69pCBKccon/im57LQQvkxDWGAIsOO4z?= =?us-ascii?Q?jgOq7S0g19TO2aljKzvrWD32wrm0Lx589QPxsniGisM/rBAfLgmqTeKYnWG/?= =?us-ascii?Q?Oy8uLaf4BKEtUpA8FAhP+gcp2oHvWEME6Od2m4S7BItkHXV6aMgzm2Z9Xlmy?= =?us-ascii?Q?HxkVngVCddcRZ20WgRYqQUiRyVEhWKnMng3eJMMD5SUOVJZ9xHMm2WnqSMLL?= =?us-ascii?Q?wdIE4Olq/dbBpcgcOKdzfIR4TkRTND11ZbEsoUACciD8PsbqRSgXESsO9PNV?= =?us-ascii?Q?OAeLy9pM9dM0JfmE79QRw+maeztp/vJ1dVXzq07c/aEycJF59H9NZbszz16F?= =?us-ascii?Q?w4ngv23t8hl7qF78aFfnVxE6mdqqoMMSa73RtQsnks80/WgFtPTCbPCcB6lq?= =?us-ascii?Q?PFf7VTdaFpr+yeuguOUphhLAIJoFXu7khEbxxGAjtTY0j/0osbWIgMiMXKDT?= =?us-ascii?Q?ES4CVmouP10Q8w0i8LHaNlD8PLzvTXcHrmteLttv0eSfTQjW4dQGsq677Y2D?= =?us-ascii?Q?RmMSjPgka1h1DOB9zzT84So4a37Jmo/iKymYA5ShtPQmRbtgfVeZw3YvyCX6?= =?us-ascii?Q?G/egW62WYhCNFEGVkiR9EXjY94Fw4NQNsigcouAxMfOnNt6jo0fuU2Exxi/Z?= =?us-ascii?Q?UARs+1NlTfE80QyhwqpyfcV52luEwqqauF2oVDhlabxt2syfCtGqVkhm0LH0?= =?us-ascii?Q?C4haPn5sT4Wi+Ri5WUTnoGcQgysVQI3MOmfAM9wgbVEAFD0infhlbKcivHnZ?= =?us-ascii?Q?ISX8S4eorf2PnfRLJZSft/UDJu+jThsbTXIbk8b5RWfDhwbUlErS+eyR5uL7?= =?us-ascii?Q?s4vHHgn7XcmjfKZZAWWSD/xRnj3ch3wqr3rkX+3ivCXYU5VJEEQL+F+uaJSY?= =?us-ascii?Q?QEbGqCSdf2+7l8RD/LvK/LtVY1SNsHSN2XKwl11q9TQ9bXjwhHC/aAUPcoau?= =?us-ascii?Q?M1DXywNulpXPPo7DtSmTBXrww3nzjuCKI/FesXdA7JWKT2WIO1rqzcCNMZmo?= =?us-ascii?Q?jnv6tvScT4aG6Vy4rGDXNvi+kJV4f5x1omyvMJgqjvmQe1xH9lFaAZd+c4F9?= =?us-ascii?Q?cpFi6R2tKreQwpWjy8PhetkWQAAbeUSfIz90cT7kwYQ1oULGUSznpEg5X+h4?= =?us-ascii?Q?zeunemEQhJM+WETkX6EHGKXxA4Fmhy9a0rIh2BE2K6DEVtysUF4QffqjPs7f?= =?us-ascii?Q?N5GChHoRS4AxovNlsZIRL79MI21IA59v2ehOdvPhBOM/WnE3yyEYkD/b5kpN?= =?us-ascii?Q?vnN89/I4NjkNlpsNGly+wisIC7up2tHLW/4xDU39tLSLVLqY+?= X-Microsoft-Antispam-Message-Info: 02sjm0u990xmKXD1D8Oz8uYnXffdxSudpzpYzupTkVkJxXAhD8SXzTyrL24AsF0NlEwpJcOs/miMs6vfq+Ihn2U8kXfxYJx0zNPB+QmYXKK/TG4SncOWn4/2IDqcPQ6jfqdPuNqllIz7uxfOZSkbO6wlekP95PVZQX0BzbX6t0/YN8JmMO+Ul9bGrXHYOhkdHjs6Q6KcdkLVViqUmsuV3ZRYNi0x09yMMGzyKo/UI2AHw/lqnNFDbYHvYCAPWNXuvWAH5ThD7WUz+JiGOK2ZOAAMQVbanruTWs0K0jmWKpIKuDcbX4OXxxlxkOapRh4OWflyzYpke3AcvJVz36RGJA2bamEC5hR4VSpwCw6Xg+psQVOhdPNGvt6+wwNVLWkSEeqmQ/z332gquSs33Djwq74gCyLOBflcfCJD8uWxImLbtwlDlQQtavAw1dp+iB76es/yYsP/0sJ0lLW4BeFNtc96P80qzJd1kTNmSW3/uRCdZV1RmX6n/dJZpks01HQEdVcLLhp5fC7whJ0nJq2pDvrDUefSeKOj5BBSPmIwGjW9PGKepGWszqh4i6PSVbRPN7/tSnz14KMKf/+qLygSaA== X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB2035; 6:flICihjzlzz0Da3p6sWwuT4GhtHFRCc30ndQeJCkniC6u9vqte85n/gSVj19TMrhVur5wHES+w/z+dJZvSqaMBRqrung6Wa2zAzHPkWgQMtSONISIwlIo340VDr6zywL1kPEenCdB5dA7VxqWBDkYmglbseCPv+8kwMwusd4YBdTBSb4ectdA4KME+WD9e8+EWd+XaAl0z4wssfsq4/vDuRS9uHSeu88FhC99yQHZfK6vnDrMQDDFFujgKX7ZvFk+zfhcVNoy+reZoC+GLNaKiafFsjgqF8BKnLxHBvxMbgoE2XW+AiKyCRCVHeNqUz47yuj3/RlEVd7pE71sbkMX0STfc4Szky3qXRvhk1POVpirup0H9XynWsELoQ+wKIl4NGJ2AQhP2WZDy5+5fWbG/aw6K9Blm+zvpepdNXyFKOtdij+Nl5kCG9xMIT6w6pqQUUvUUPzMIp9rAG4WvhsVFOA5/TV4uyxtD58ABtFbL6UcgdUJHsGUet4SSUETKOa; 5:GiigU7/GNTxyMnogpD0eIKH+WBF1KBnKpkZQr8O0+rfHTlCc9V42Wzp7o2bdgU6Xk8RaeKcxntvkAXeXZnrZKk62eyFYcYp8vvoUXae40TlBJzCxSKDw+FO0YVv70f28B9BaOhWig+fHSJv8snwITwnU/uESfsI00ImcY+Jsqcs=; 24:CYzAlax6ZeDisRy/wUHrvfEjUyIWPLKzGGV3kur53pBLH3FkmdOHWpvATJ+eXZik+981rkp3TrgbC6BPBhCDFw== SpamDiagnosticOutput: 1:22 X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB2035; 7:q3aYu53R8+ENecP9v2Tk7PO/mk+t/TnNcwn3Qju5mgIjMdQHOBjuRaVAHsC4wJYh3G6OLG39PQ9iMruDryIbtYRMUvKJvcy8Mjl6Uoo6n/N5ma/4SfDCxTZ/UYJU2nT7qqqbXgTyYrI3xcfWFQkjbRCXi7rHp3YY91Jto1k3PNYxVM1OEhPt6kWa6BcMgdv9VoE5FSVokktsL0yA+j4mptJxb2pMMDFZ9yc6kwhXld/CFtNIufoesb5Dno2N0sJm X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jul 2018 09:38:51.3422 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 797c94c8-38f4-419b-aff9-08d5e191f397 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB2035 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 groups for interrupts. Note that this potentially results in GICv2 guests not receiving interrupts after migration if migrating from an older kernel that exposes GICv2 interrupts as group 1. Cc: Andrew Jones Signed-off-by: Christoffer Dall --- I implemented (but stashed) a version of this which predicated the behavior based on the value of GICD_IIDR revision field, falling back to ignoring writes and resetting GICv2 groups to 0 if the guest wrote a revision less than 2. However, current QEMU implementations simply don't write the GICD_IIDR, so this doesn't help at all without changing QEMU anyhow. The only actual fix I can see here to work around the problem in the kernel is to require an opt-in to allow restoring groups from userspace, but that's a lot of logic to support cross-kernel version migration. Question: Do we expect that cross-kernel version migration is a critical feature that people really expect to work, and do we actually have examples of catering to this in the kernel elsewhere? (Also, how would then that relate to the whole 'adding a new sysreg breaks migration' situation?) virt/kvm/arm/vgic/vgic-init.c | 2 +- virt/kvm/arm/vgic/vgic-mmio-v2.c | 4 +++- 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, 57 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..a7f09b5 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, @@ -371,7 +373,7 @@ 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, NULL, 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);