From patchwork Sat Jul 14 17:05:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10524883 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 122B360245 for ; Sat, 14 Jul 2018 22:01:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 003C328936 for ; Sat, 14 Jul 2018 22:01:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E7F8C28949; Sat, 14 Jul 2018 22:01:57 +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=-2.9 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, DKIM_VALID, MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6F5F628936 for ; Sat, 14 Jul 2018 22:01:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=TVWdR7CaEB0WYaoNn54Fq9jITpobDmfnVSEup5apL8A=; b=fEboXV++091Of+ G8zAjqV8szdqwTR123DO3ganiIm7cxrIBvm3GRytrKfv1nGy8wRNaotfVCB7svlD8XCFTcbmJR0Ox yDJeVV/oiYIABWKxlXNGs0uhjoChepocP152uJQp7me5K++tOuDbaqkahHATbua6BDB2JjSl/aadz qUngC1jmIgcgTjE68b1/NHDBYMECTCaTkBfe6nDUGm6j4qSPYn9waMKIsCZWZ25oBtV1buGhpQryD D1qxGDOX5JAopsQjpbo3GMBKShF3RIeHJrMUxtAmVBAyUiClzeqyz0TJ+pDJuMom5FCjapkeuQKlA hjgygLnWTIs0J6/kdkrA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1feSbx-0000CZ-0j; Sat, 14 Jul 2018 22:01:53 +0000 Received: from merlin.infradead.org ([205.233.59.134]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1feSTj-0003VM-Fu for linux-arm-kernel@bombadil.infradead.org; Sat, 14 Jul 2018 21:53:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=k6cRyG/eGtQnF0mX6xxc9aExjPRhB86I/A926uNs62o=; b=h4oJjF2oi3OgYZ10lQ0lN1rMNy tXb0eHELCXieYttsJTI2AuN0HrZ+0WR9Sl2IepPCrd8Ooh8AqeXQ8aImzR/LWAqaV0lLNrK+yGUap E4EccAs2oOEY1nggHkJG75UJFvpB9XKZ6IK3RMzhjCV06OiNlR3R62f5vIbglFLFJ64ZJLLk7Ru0q trLOtKOhP0lpYAV6XEuYBKlAD/eRvuf9K2Zj8fcnXDZa7CxOd8YWxf03PZ8PReaKrT3+ao9svF7DO 0oeCU3Zn84y5DWT/8l+WkcFJyfR7lusFQVCxHsAGnCkw22MRE3OMqfze8oXm88W+vsJ74ETB01Jlh XxGr6N5Q==; Received: from mail-db5eur01hn0238.outbound.protection.outlook.com ([104.47.2.238] helo=EUR01-DB5-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1feO0f-0000d4-0C for linux-arm-kernel@lists.infradead.org; Sat, 14 Jul 2018 17:07:05 +0000 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=k6cRyG/eGtQnF0mX6xxc9aExjPRhB86I/A926uNs62o=; b=Zzn1GR18dyPKeZPZ/SKu+Zxaipk19iYk0uSV0FBGEe+iKVyiT7UhTdgCK+CASI6oxn1IWDCwP0Myrc6U+JjeNmRgU1n54HuLhjgfAxHGWClN0mNDih31XlGOeQP2rZEPFWJ2kiFrt8ztkPOdGX00OgZe8hTcUbSFoDRyAkH1kM0= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Christoffer.Dall@arm.com; Received: from localhost (217.140.96.140) by AM5PR0801MB2034.eurprd08.prod.outlook.com (2603:10a6:203:4c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.952.17; Sat, 14 Jul 2018 17:06:20 +0000 From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 8/9] KVM: arm/arm64: vgic: Let userspace opt-in to writable v2 IGROUPR Date: Sat, 14 Jul 2018 19:05:39 +0200 Message-Id: <1531587940-2490-9-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: CWLP265CA0209.GBRP265.PROD.OUTLOOK.COM (2603:10a6:401:4e::29) To AM5PR0801MB2034.eurprd08.prod.outlook.com (2603:10a6:203:4c::8) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: d2055a1b-506f-4292-0f93-08d5e9ac1ec5 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(48565401081)(5600053)(711020)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020); SRVR:AM5PR0801MB2034; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB2034; 3:j9/ir9Ee0gT+4qPauxXY5Wp36XGudpunGPHCP+s7GJQJAwVIo+ZqVpZSkACNpl+YEjDzzRfjwqW1K/RjsECY2n1/uPEkMiC6rxGmysUYmMpoibFhLxb/j6KsKaiMwmxcqo0co/cpQFnJdS5/5x4TfxFEv51Z+bIC823CsQk+X2yn5R3C7GcpQC9lN0G5/F8H0SfoxwjrEg4f7+pNqWc7l7FaHbgsJnF5eDDr6+TpyAnSj0H3WWJSaso4Muxf3eS5; 25:F5SX6lp7CF4dkfIhzDmbrKmC2n8g3t5kEbSBugutKNcbWPPoA6ErWbFVlUFjxokVoi0EMuVzGzKnFOaX6ccHVnPL00KPt+xz+uibHqVg9XeKAOOxSlCbBJHR5C3spVz7h11U4huWN5bAvWCo1dcFEOFrdF9ScdYJb5vX7ewguQNRV38ukastuFacLE3CBZquqkv581fck5rU95HKEuUpts3JGWd6eIfBTLCrmdXd/o/Guu3S8uO+Pm2+xIt9W+YMxbYLKN6qCTrcT0vfRRt/MSd3hCtWrK1YOtDlSWG2pYygva3YS9PvoVEnBjUjK6HkjQiiv2dDdFaAt9bzKs2Vew==; 31:xTWxxYJSUtQr6ATUkwgjdJCAhpTxwzTzLTAvE1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zVZ2/gV9QrHWkjwOqMFzSEr4q5+5KNCTSUht+1+WbbQFMLX0D4hpLy2qnyexwBR52lJpFqNvbOk7LX4TcrdqfnRYfgibtinUruRddWwiFi2wd5HUkwtsabm/1sSD4P4UZ4= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(190756311086443)(180628864354917)(223705240517415)(211171220733660); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(3002001)(3231311)(944501410)(52105095)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(20161123564045)(20161123558120)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:AM5PR0801MB2034; BCL:0; PCL:0; RULEID:; SRVR:AM5PR0801MB2034; X-Forefront-PRVS: 07334CBCCD X-Forefront-Antispam-Report: SFV:SPM; SFS:(10009020)(6069001)(396003)(346002)(39850400004)(136003)(366004)(376002)(199004)(189003)(40434004)(25786009)(50226002)(81156014)(8676002)(8746002)(53936002)(8936002)(5660300001)(81166006)(4326008)(2171002)(76506005)(316002)(97736004)(54906003)(14444005)(5024004)(106356001)(105586002)(72206003)(68736007)(47776003)(478600001)(66066001)(6486002)(51416003)(386003)(16526019)(6496006)(186003)(26005)(6666003)(76176011)(86362001)(575784001)(305945005)(7736002)(52116002)(48376002)(50466002)(36756003)(956004)(11346002)(446003)(486006)(44832011)(476003)(2616005)(6116002)(3846002)(2906002)(23200700001); DIR:OUT; SFP:1501; SCL:5; SRVR:AM5PR0801MB2034; H:localhost; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM5PR0801MB2034; 23:cCmvUVroiAhl1sPNeQ/ruv6khcrNbO8QakhVGWW?= =?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hPGZBgt+xIEzO3OB7+c7CHGEMiAFhURFylvQOVJaUWpmj1qbcPbAfrY1ILP2wYOBXEKyYXzlDxCJinu0xmdKzmDYtHiPE/3gG5/g9PAjAamjr1/jDeKHrKw69mdx3eJF+qEkxONiO2Z2vZK8ui31KXUrE02Ict8YKbW0WToQo38KjVgcvT1WERc4igFMJweuiEBL7yq57imZL+e9Tn X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2018 17:06:20.0809 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d2055a1b-506f-4292-0f93-08d5e9ac1ec5 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB2034 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180714_130705_152004_93116FC1 X-CRM114-Status: GOOD ( 16.85 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , kvm@vger.kernel.org, Marc Zyngier , Andre Przywara , Christoffer Dall , Eric Auger Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Simply letting IGROUPR be writable from userspace would break migration from old kernels to newer kernels, because old kernels incorrectly report interrupt groups as group 1. This would not be a big problem if userspace wrote GICD_IIDR as read from the kernel, because we could detect the incompatibility and return an error to userspace. Unfortunately, this is not the case with current userspace implementations and simply letting IGROUPR be writable from userspace for an emulated GICv2 silently breaks migration and causes the destination VM to no longer run after migration. We now encourage userspace to write the read and expected value of GICD_IIDR as the first part of a GIC register restore, and if we observe a write to GICD_IIDR we know that userspace has been updated and has had a chance to cope with older kernels (VGICv2 IIDR.Revision == 0) incorrectly reporting interrupts as group 1, and therefore we now allow groups to be user writable. Signed-off-by: Christoffer Dall --- include/kvm/arm_vgic.h | 3 +++ virt/kvm/arm/vgic/vgic-mmio-v2.c | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) -- 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/include/kvm/arm_vgic.h b/include/kvm/arm_vgic.h index c661d0e..c134790 100644 --- a/include/kvm/arm_vgic.h +++ b/include/kvm/arm_vgic.h @@ -221,6 +221,9 @@ struct vgic_dist { /* Implementation revision as reported in the GICD_IIDR */ u32 implementation_rev; + /* Userspace can write to GICv2 IGROUPR */ + bool v2_groups_user_writable; + /* Do injected MSIs require an additional device ID? */ bool msis_require_devid; diff --git a/virt/kvm/arm/vgic/vgic-mmio-v2.c b/virt/kvm/arm/vgic/vgic-mmio-v2.c index b79de42..9b6b758 100644 --- a/virt/kvm/arm/vgic/vgic-mmio-v2.c +++ b/virt/kvm/arm/vgic/vgic-mmio-v2.c @@ -85,6 +85,17 @@ static int vgic_mmio_uaccess_write_v2_misc(struct kvm_vcpu *vcpu, case GIC_DIST_IIDR: if (val != vgic_mmio_read_v2_misc(vcpu, addr, len)) return -EINVAL; + + /* + * If we observe a write to GICD_IIDR we know that userspace + * has been updated and has had a chance to cope with older + * kernels (VGICv2 IIDR.Revision == 0) incorrectly reporting + * interrupts as group 1, and therefore we now allow gruops to + * be user writable. Doing this by default would break + * migration from old kernels to new kernels with legacy + * userspace. + */ + vcpu->kvm->arch.vgic.v2_groups_user_writable = true; } vgic_mmio_write_v2_misc(vcpu, addr, len, val); @@ -95,7 +106,9 @@ static int vgic_mmio_uaccess_write_v2_group(struct kvm_vcpu *vcpu, gpa_t addr, unsigned int len, unsigned long val) { - /* Ignore writes from userspace */ + if (vcpu->kvm->arch.vgic.v2_groups_user_writable) + vgic_mmio_write_group(vcpu, addr, len, val); + return 0; }