From patchwork Sat Jul 14 17:05:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10524789 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 80FA5601C2 for ; Sat, 14 Jul 2018 17:07:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 67CCD28739 for ; Sat, 14 Jul 2018 17:07:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5A09628750; Sat, 14 Jul 2018 17:07:06 +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 1575828739 for ; Sat, 14 Jul 2018 17:07:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730745AbeGNR0o (ORCPT ); Sat, 14 Jul 2018 13:26:44 -0400 Received: from mail-am5eur03hn0215.outbound.protection.outlook.com ([104.47.8.215]:20625 "EHLO EUR03-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728135AbeGNR0o (ORCPT ); Sat, 14 Jul 2018 13:26:44 -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=T9tpSseL9wFrHCowJ5by15DjjVlvkiy1X8xQpMG9goA=; b=Znf/nwdAq5bg6KFqju7zPqtyle77R+1FtUncXcoXXgvSV36pp8ZEwrI2JTXEgza2Ev7QTopvw1f1yDWoodFJY5yxOjqVcC5ji3Z3vnLgWn5z6ERAz/BT+dSJF0fMZUdakVysvqCT/r/a5QG+ACo/dCEqEjsLaJ+FdZRRyQ9R00U= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Christoffer.Dall@arm.com; Received: from localhost (217.140.96.140) by DB6PR0801MB2040.eurprd08.prod.outlook.com (2603:10a6:4:76::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.930.21; Sat, 14 Jul 2018 17:06:17 +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 7/9] KVM: arm/arm64: vgic: Permit uaccess writes to return errors Date: Sat, 14 Jul 2018 19:05:38 +0200 Message-Id: <1531587940-2490-8-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: DB6PR0301CA0044.eurprd03.prod.outlook.com (2603:10a6:4:54::12) To DB6PR0801MB2040.eurprd08.prod.outlook.com (2603:10a6:4:76::21) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 70bc376c-0eeb-4413-3de2-08d5e9ac1d33 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:DB6PR0801MB2040; X-Microsoft-Exchange-Diagnostics: 1; DB6PR0801MB2040; 3:w3M5TWiDTRBJ0zv9geTogGQ3QaE6aP7DdN8YWEgfnsPng1uYUro0v05nPilrUuSCZLguxNbru8HINgAiwpHU2ovTOKePCvAabZYzp0zDkkONvqm6X06TLIdr0mXUxqRYGHXbXH2CYOj+l3vQm6a2n1vIjGNyJ83XHZFh2VIDGWwvbN5oQYvAPgVxOOhe9ZZ4n9Mdy7EC2/ezlxW6vRE0mzErNiCyg9AlIkZRqakqHjK3kNSz1lYJqro/xNX8L976; 25:dVjL4ZNDG2FGENJNA+5RIOYeNMfspZ8grjpH/5Lj5sNzwXEE625mrfE4ZcyTEf7xFjBnUuC2kkRU4Tf5wBu58HnfOwRPy3ybgKAW7LJ4Yjx7XodTrOmbfQVuPnYPJ2u0dpJM0qGrgpkHA0HcFvekHozilayfBbrUTKz6jSIbfHniQrHncwfl/T2T5oFsxrD1GWL65jK6Y+oSskZd2fNAoaZhVA69swypa3i5fhAjNqffN8Ha0/kJSC2ina3iiDdQKDVSvyIJiNA1A+/VJ2FY1ceQbunxJ5P55A7GNQAr6cdMv+D7fpn8pi64T3STT97nqTVW70BxKMFZtPzZfKJb0w==; 31:pWeMp7aDJs7n5SezIyLBOa+1PcNZUjWiILsDrFz4UrObjTDNYVx7auRvFCK2jDX5r/Z1Zwpkojq6xZkyD1r/L+N2Od2OZemqgmQrwIVXTQkSi970DEQ/rDaZ+KvOdl1TUpH2ORNhSCeb/fIYh0J0NS8JTEFkonQkb52mzntLPBouz7ZYsEYhDLqJv1T42zfszrY+k1jUE5lKyMXhnylAAtyFLKk3k71OyBgCskrAlvs= X-MS-TrafficTypeDiagnostic: DB6PR0801MB2040: X-Microsoft-Exchange-Diagnostics: 1; DB6PR0801MB2040; 20:0qPcudvrYj9A2qOl2Vip4f49fAR6yWjag1ud7VbxXcXfC5TqrQfhYtWI/nI6XXYw2UR1qXctkpLq6Pt2QWofkHsWIGUMBwrEwb1NCzdYIiE0JCYXqTV5Y32S7s0bVcuRlSN8gb1hFxTTPJjUI9TDHRPaqTZdGyaWdUW82byhK3QlzsfE95qeSvyu/LoHtgi7R7aw8mmVdJb7OQJMWtuveLixm/HZLpapySO+Uvj2Rljx5wjY8hQz57bHCyYVCoHfPMjL4l10XQ+j23gmu/WHZjiaYynuAzYkBBL0haiw2HAC/oH+4r1n2ygZ9uFDPxcT64M6pJEi5x5krkVo7b4gGpxXXYfE5KyYEQPoex/WYhpK3SJH5fAhscfFEmm2ZhprsYUn50eJKmMt6AdBD/1YwtOfGjBvyjs0vSpdL7hlybGFFiZ8Vz+YKPLJbs6Eeoc7T2nHXFiShhe/QIyTY3Wq9MQNvMjcn3efTTrlhi6LV7nU2yLJt7mJXEEpwcazDxaP; 4:190ykbzPSfMKFw+8BxFyGnYb8OZNvM1razMVFh/ULjTzMIEdZd8Vn/ACQDQb0lFIh1PWngsJ/Mh/dXbTfsDgGCF9b1/IcobzmZ1KuehYUaMGAyB1DL624FsvXZbmnd/OCh2YgPJAHibYyOXgvhxRW+rp3WKugwdNbgY9Z6byMFTIaxmdzUQjQwekZMCIFEjYyFnFAyAYLoL5HwFs8aqrtEkUSsjJ7Xf8cPzgkQd/4kt9Sg+8kClniXP5uBXfPata63cdP+ezBKyhLQEWqgCAGryiOjfDmrpx5/CHmkkvvX2TEDGSkfxpCcxv9Z54PKJUoGi/pqnHHpNL8ZYD7yydQMNESnIWblBOSZ6Wtn5INmY= 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)(3002001)(93006095)(93001095)(10201501046)(6055026)(149027)(150027)(6041310)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:DB6PR0801MB2040; BCL:0; PCL:0; RULEID:; SRVR:DB6PR0801MB2040; X-Forefront-PRVS: 07334CBCCD X-Forefront-Antispam-Report: SFV:SPM; SFS:(10009020)(6069001)(376002)(39850400004)(396003)(136003)(346002)(366004)(199004)(189003)(40434004)(105586002)(3846002)(97736004)(66066001)(36756003)(25786009)(2906002)(478600001)(72206003)(47776003)(6486002)(6116002)(76506005)(106356001)(76176011)(446003)(305945005)(50466002)(8676002)(486006)(44832011)(52116002)(6496006)(2171002)(86362001)(575784001)(48376002)(6666003)(51416003)(8936002)(386003)(81156014)(54906003)(7736002)(2616005)(476003)(8746002)(81166006)(956004)(316002)(68736007)(26005)(5024004)(50226002)(5660300001)(186003)(16526019)(14444005)(11346002)(53936002)(4326008)(23200700001); DIR:OUT; SFP:1501; SCL:5; SRVR:DB6PR0801MB2040; 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; DB6PR0801MB2040; 23:/X0rXsSROphgxC7GAaTuU11tlwBSsk+/ASIZZpk?= =?us-ascii?Q?dlZeUEuU7OQtl8ryrLY7cgNOLJjuh++Wl5XIIAC4J7iqP1yiCm3T8C+7skmm?= =?us-ascii?Q?3WpU2HkYv9Bwy3dU1yd+MQsSKAMhx9Jxs1gmTLgfxtXf9XDeGKLfjL6rw+63?= =?us-ascii?Q?plae6xI8PvpdV4e1a36MmiKxHJ19XYiO/BY131EzqFN1OfW3C7x4zT1br6In?= =?us-ascii?Q?awBwWZzL8OEAkSDdIhWJkuYrJc0eTZ4Tz4lA0UkwlHMIt/beVS1LUp5bqtTd?= =?us-ascii?Q?0Bv/WE3aqnZ0eRtQ0Efqx3pLJSeoQKEJv6+erXw/So02O0TOjAE6HxZo7FBd?= =?us-ascii?Q?rYqsos7k4fCRi1G77vXvERX6xRDzHcMN5T3ZX7zc072E+O/NCfGIVYutYduv?= =?us-ascii?Q?d0d7hw8A+uf36piSQKu0NCrjShsFQ46bwjYASezKQcS6r2IERcS8xlXocapZ?= =?us-ascii?Q?rMO2Munf5VByskLXW3fkege6b9ruEqdfrlhi9FRuc+qdbxG5JPySKa1ULTSk?= =?us-ascii?Q?VRNGiQnNb4V93wsebc2THVCi0Nr2DLuQXD6doEso74T6gqhQSJTC3/d/+vDA?= =?us-ascii?Q?+bDUSWME5C25oVWdF7zBZWT9eparhxXM2V9gid65c3T6BUb4kcQag9Lvr7F9?= =?us-ascii?Q?IJT0uUK789A0wxgIvNkROkbFuqgL1FBCZa+86DF/s+2wRE0DgZnqEN86zWry?= =?us-ascii?Q?Km0DtECVL/Yn8E8LlYxkOtuHbkv5xIb8yGS+NHoeMwjdxZw/7JLC2/df5yym?= =?us-ascii?Q?oMlEhAugc3EtxH0d6y1EGMlU7RyVdvff7fBqS79gTP5PKBknWNiid97KY9a5?= =?us-ascii?Q?u679VQg+uwEH+RD0BH7JtHp1B+BZUJkM8QxM7Ub8Al3kqvwKbbd+lP7qPEKu?= =?us-ascii?Q?WvUISsZuKJVnQ+8ysLGvNvM6MIjWzwEwApMuB+Ts265lwosJcwFS5sYBBcfr?= =?us-ascii?Q?xKpZ65kGMWLNeiy80ia5T6zIZklQ+UnQwRf22M3GPUlR2dTgmlM9QY6y18k6?= =?us-ascii?Q?KPHUWQ0J8onOjivwv/YckU2gzDOLTq3/+hrwqicA//I5SiEib7s1jcyFZUvG?= =?us-ascii?Q?RTPxMAz79j6csZyGTt9i0bLpLs0eP/M/fdql+uzaW/3P3UN2WjBdY+JMT0ZW?= =?us-ascii?Q?R+JOWu/KeLt0Ptg236x+WR8OZgz3TZFM7E5z69FG/vAmIYu8lOnpYkpZB95B?= =?us-ascii?Q?v0UDxdRgzdbxYYVI8/8tQPwzipmaRaKuO0nC/Qli7M/1vp66ZmQxMgaoJSDB?= =?us-ascii?Q?rsAdCPrLjGVruzEeZcwQbFuKjLGvQP6j8MDAxTsZRDdAc4oBsEJ3HCiGAget?= =?us-ascii?Q?vQN3tVIuOXMbprXhHoOB/EswDBvNDyTir9l6TX6wMINfiSjZruLKcbLK6sVT?= =?us-ascii?Q?rYuZ0OogCdTq9l44I8iv669KFumC1BkRwbchCYew9M/PrD6Zh?= X-Microsoft-Antispam-Message-Info: UAACA+fH2Xe7Hxw3Kz5yLX9ly38C4D07rnh51hGrxlHnNtL6t7S89jgFYonAjpMyDyfotqPU/v/abIIlZj2HE/A1rpWcBWwjJY8EYbCqTpxjGVPhNwE/zFhATOHeQdPIF3HYmmyiPnev3DDFXioIkC9Fg72H3RfCi92wvMFKqKgk3+MWnJoBwQ+JK62qYJBiiKcIM/4pkmc9sHg7Hk+9KeSx76IslTgGnZOryYMQmV2jtQCfZ60iKwRvspNGCM/J3q8HXnI+jrFdnm1/bHrHULpMLhX9RIYwch7zIIaEIM1MTyw3LpgLX24IZZwtcLpWNXXwmEFkmx+rfTLvfFPRTe1fFjwdJw8kLZ+ZIprcDmi2RppoZyR+dIuE1913pZsD0FUPprU/NKW4e0oDhIOx5i+XR9SOCm5bIdLhFsFBmZoV3Zv55oSoUrhzigZUQIxSmBhtxe7ueh943fHHpxXutvOlRBBBvzghJHMPkYEKF7Qzfu4vJ2W4TCGTL6VjvSD99QetOV8q+lrNEnmJq90wTzxl/O3tINhFw27A+u4mnAvUc7kGjJnys8/za/IhlEKuPfJ9QcmEyMG3s1+E7QpPEQ== X-Microsoft-Exchange-Diagnostics: 1; DB6PR0801MB2040; 6:L8DBX0EaclmZQhDiITVhUkdaTm88VvCsNKcdWxd19ztLw2D8kx3RjqBQPWFiN9W+J/r09xBibh+rhLqs/E/aMJXtkLgi5JyP+0bWpyJOGSdQVfvhXXi9gZoqtz4BUbjw0U5KLIsHemv9+8AFE0p0Wkd8vYIk+SCsaFyKytVO0yypgJczweYiIXtdTHpG9VCAUz+Ug3rm9ZBkb8FxZVtxlg3wK2RQPW4ARAxuwElAckLRi3CUprDPToYbv7ir1+/8IWS2fOeD07KzmVnRjkp4RrBlCUoVFPJqGwY25FszqkdBPJtJ2mSyC0NxPt0I9BLS/xeFHwF96ETZHiu3jAeDDJZinybHEMjBtMh/JhEC5y4xC4559vFt8UiBcJ1X4RQY9gqYCObVgBWSAR/aLWlfe8qkT5MNnw97xx04gOBl1wKonCzfcdShMOfIs9J+bP9HpsNG7/Ebp3RdcZmwCTwKAdmlPu5vPGtYFWMBIKEasUJPlvuexATVi71+wLuZgICq; 5:JoPlLdzK4VIgOQipco53CIpE3P2LlgJ69olK/O2MCMryFBCLJ4UxFBRjjgmBxOsNILLl0lEZSLtonBaHR1VGNQ+GUsTQyJNdKvU484UuQYguL5Iknm0/IuU3DBYs0vQAEckkJvPqV2hi+qqUhrsgG7wV095ySNPand83+MIddU8=; 24:JMVjfFP8cn81ie6TGGEShNWrv4dzucJKzbPy3gpVnDw2BulaYzZ9SgHGudFH4h8ykyDR4dyOj4P4n+1mM5qtfg== SpamDiagnosticOutput: 1:22 X-Microsoft-Exchange-Diagnostics: 1; DB6PR0801MB2040; 7:ySG1PH/F2938uF6Pg0uLJvTFlHl3fhVM0ddhjHs6Lmk4DfJvoGa77C9t+4PKGI2/08/mEpQUShJ74giY8QjpdewM+fBfPDkJROLzo5PMs9M+sZHUQTNIn060xVeqprvtAEuVZp79mKdlPvMBYUxLnEWWkU6j0sZ5AkhAWB1mnodC2ZloPZ59DMQbjaZ4106F69kdIh+T3PSWqXDmNMgwf2z+re9ZWi1WqMOCoXBilEE+8+9Pq01foxe/ziaYvKiM X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2018 17:06:17.4906 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 70bc376c-0eeb-4413-3de2-08d5e9ac1d33 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB2040 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently we do not allow any vgic mmio write operations to fail, which makes sense from mmio traps from the guest. However, we should be able to report failures to userspace, if userspace writes incompatible values to read-only registers. Rework the internal interface to allow errors to be returned on the write side for userspace writes. Signed-off-by: Christoffer Dall --- virt/kvm/arm/vgic/vgic-mmio-v2.c | 26 +++++++++++++++++++++----- virt/kvm/arm/vgic/vgic-mmio-v3.c | 31 ++++++++++++++++++++++++------- virt/kvm/arm/vgic/vgic-mmio.c | 18 +++++++++++++----- virt/kvm/arm/vgic/vgic-mmio.h | 19 +++++++++++-------- 4 files changed, 69 insertions(+), 25 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-mmio-v2.c b/virt/kvm/arm/vgic/vgic-mmio-v2.c index 34e36fc..b79de42 100644 --- a/virt/kvm/arm/vgic/vgic-mmio-v2.c +++ b/virt/kvm/arm/vgic/vgic-mmio-v2.c @@ -77,11 +77,26 @@ 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) +static int vgic_mmio_uaccess_write_v2_misc(struct kvm_vcpu *vcpu, + gpa_t addr, unsigned int len, + unsigned long val) +{ + switch (addr & 0x0c) { + case GIC_DIST_IIDR: + if (val != vgic_mmio_read_v2_misc(vcpu, addr, len)) + return -EINVAL; + } + + vgic_mmio_write_v2_misc(vcpu, addr, len, val); + return 0; +} + +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 */ + return 0; } static void vgic_mmio_write_sgir(struct kvm_vcpu *source_vcpu, @@ -376,8 +391,9 @@ static void vgic_mmio_write_apr(struct kvm_vcpu *vcpu, } static const struct vgic_register_region vgic_v2_dist_registers[] = { - REGISTER_DESC_WITH_LENGTH(GIC_DIST_CTRL, - vgic_mmio_read_v2_misc, vgic_mmio_write_v2_misc, 12, + REGISTER_DESC_WITH_LENGTH_UACCESS(GIC_DIST_CTRL, + vgic_mmio_read_v2_misc, vgic_mmio_write_v2_misc, + NULL, vgic_mmio_uaccess_write_v2_misc, 12, VGIC_ACCESS_32bit), REGISTER_DESC_WITH_BITS_PER_IRQ(GIC_DIST_IGROUP, vgic_mmio_read_group, vgic_mmio_write_group, diff --git a/virt/kvm/arm/vgic/vgic-mmio-v3.c b/virt/kvm/arm/vgic/vgic-mmio-v3.c index 49df2a1..fabec2b 100644 --- a/virt/kvm/arm/vgic/vgic-mmio-v3.c +++ b/virt/kvm/arm/vgic/vgic-mmio-v3.c @@ -120,6 +120,20 @@ static void vgic_mmio_write_v3_misc(struct kvm_vcpu *vcpu, } } +static int vgic_mmio_uaccess_write_v3_misc(struct kvm_vcpu *vcpu, + gpa_t addr, unsigned int len, + unsigned long val) +{ + switch (addr & 0x0c) { + case GICD_IIDR: + if (val != vgic_mmio_read_v3_misc(vcpu, addr, len)) + return -EINVAL; + } + + vgic_mmio_write_v3_misc(vcpu, addr, len, val); + return 0; +} + static unsigned long vgic_mmio_read_irouter(struct kvm_vcpu *vcpu, gpa_t addr, unsigned int len) { @@ -256,9 +270,9 @@ static unsigned long vgic_v3_uaccess_read_pending(struct kvm_vcpu *vcpu, return value; } -static void vgic_v3_uaccess_write_pending(struct kvm_vcpu *vcpu, - gpa_t addr, unsigned int len, - unsigned long val) +static int vgic_v3_uaccess_write_pending(struct kvm_vcpu *vcpu, + gpa_t addr, unsigned int len, + unsigned long val) { u32 intid = VGIC_ADDR_TO_INTID(addr, 1); int i; @@ -283,6 +297,8 @@ static void vgic_v3_uaccess_write_pending(struct kvm_vcpu *vcpu, vgic_put_irq(vcpu->kvm, irq); } + + return 0; } /* We want to avoid outer shareable. */ @@ -454,8 +470,9 @@ static void vgic_mmio_write_pendbase(struct kvm_vcpu *vcpu, } static const struct vgic_register_region vgic_v3_dist_registers[] = { - REGISTER_DESC_WITH_LENGTH(GICD_CTLR, - vgic_mmio_read_v3_misc, vgic_mmio_write_v3_misc, 16, + REGISTER_DESC_WITH_LENGTH_UACCESS(GICD_CTLR, + vgic_mmio_read_v3_misc, vgic_mmio_write_v3_misc, + NULL, vgic_mmio_uaccess_write_v3_misc, 16, VGIC_ACCESS_32bit), REGISTER_DESC_WITH_LENGTH(GICD_STATUSR, vgic_mmio_read_rao, vgic_mmio_write_wi, 4, @@ -475,7 +492,7 @@ static const struct vgic_register_region vgic_v3_dist_registers[] = { VGIC_ACCESS_32bit), REGISTER_DESC_WITH_BITS_PER_IRQ_SHARED(GICD_ICPENDR, vgic_mmio_read_pending, vgic_mmio_write_cpending, - vgic_mmio_read_raz, vgic_mmio_write_wi, 1, + vgic_mmio_read_raz, vgic_mmio_uaccess_write_wi, 1, VGIC_ACCESS_32bit), REGISTER_DESC_WITH_BITS_PER_IRQ_SHARED(GICD_ISACTIVER, vgic_mmio_read_active, vgic_mmio_write_sactive, @@ -548,7 +565,7 @@ static const struct vgic_register_region vgic_v3_sgibase_registers[] = { VGIC_ACCESS_32bit), REGISTER_DESC_WITH_LENGTH_UACCESS(GICR_ICPENDR0, vgic_mmio_read_pending, vgic_mmio_write_cpending, - vgic_mmio_read_raz, vgic_mmio_write_wi, 4, + vgic_mmio_read_raz, vgic_mmio_uaccess_write_wi, 4, VGIC_ACCESS_32bit), REGISTER_DESC_WITH_LENGTH_UACCESS(GICR_ISACTIVER0, vgic_mmio_read_active, vgic_mmio_write_sactive, diff --git a/virt/kvm/arm/vgic/vgic-mmio.c b/virt/kvm/arm/vgic/vgic-mmio.c index ae31bd0..f56ff1c 100644 --- a/virt/kvm/arm/vgic/vgic-mmio.c +++ b/virt/kvm/arm/vgic/vgic-mmio.c @@ -40,6 +40,13 @@ void vgic_mmio_write_wi(struct kvm_vcpu *vcpu, gpa_t addr, /* Ignore */ } +int vgic_mmio_uaccess_write_wi(struct kvm_vcpu *vcpu, gpa_t addr, + unsigned int len, unsigned long val) +{ + /* Ignore */ + return 0; +} + unsigned long vgic_mmio_read_group(struct kvm_vcpu *vcpu, gpa_t addr, unsigned int len) { @@ -401,11 +408,12 @@ void vgic_mmio_write_cactive(struct kvm_vcpu *vcpu, mutex_unlock(&vcpu->kvm->lock); } -void vgic_mmio_uaccess_write_cactive(struct kvm_vcpu *vcpu, +int vgic_mmio_uaccess_write_cactive(struct kvm_vcpu *vcpu, gpa_t addr, unsigned int len, unsigned long val) { __vgic_mmio_write_cactive(vcpu, addr, len, val); + return 0; } static void __vgic_mmio_write_sactive(struct kvm_vcpu *vcpu, @@ -437,11 +445,12 @@ void vgic_mmio_write_sactive(struct kvm_vcpu *vcpu, mutex_unlock(&vcpu->kvm->lock); } -void vgic_mmio_uaccess_write_sactive(struct kvm_vcpu *vcpu, +int vgic_mmio_uaccess_write_sactive(struct kvm_vcpu *vcpu, gpa_t addr, unsigned int len, unsigned long val) { __vgic_mmio_write_sactive(vcpu, addr, len, val); + return 0; } unsigned long vgic_mmio_read_priority(struct kvm_vcpu *vcpu, @@ -773,10 +782,9 @@ static int vgic_uaccess_write(struct kvm_vcpu *vcpu, struct kvm_io_device *dev, r_vcpu = iodev->redist_vcpu ? iodev->redist_vcpu : vcpu; if (region->uaccess_write) - region->uaccess_write(r_vcpu, addr, sizeof(u32), *val); - else - region->write(r_vcpu, addr, sizeof(u32), *val); + return region->uaccess_write(r_vcpu, addr, sizeof(u32), *val); + region->write(r_vcpu, addr, sizeof(u32), *val); return 0; } diff --git a/virt/kvm/arm/vgic/vgic-mmio.h b/virt/kvm/arm/vgic/vgic-mmio.h index 1079862..a07f90a 100644 --- a/virt/kvm/arm/vgic/vgic-mmio.h +++ b/virt/kvm/arm/vgic/vgic-mmio.h @@ -37,8 +37,8 @@ struct vgic_register_region { unsigned long (*uaccess_read)(struct kvm_vcpu *vcpu, gpa_t addr, unsigned int len); union { - void (*uaccess_write)(struct kvm_vcpu *vcpu, gpa_t addr, - unsigned int len, unsigned long val); + int (*uaccess_write)(struct kvm_vcpu *vcpu, gpa_t addr, + unsigned int len, unsigned long val); int (*uaccess_its_write)(struct kvm *kvm, struct vgic_its *its, gpa_t addr, unsigned int len, unsigned long val); @@ -134,6 +134,9 @@ 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); +int vgic_mmio_uaccess_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); @@ -173,13 +176,13 @@ void vgic_mmio_write_sactive(struct kvm_vcpu *vcpu, gpa_t addr, unsigned int len, unsigned long val); -void vgic_mmio_uaccess_write_cactive(struct kvm_vcpu *vcpu, - gpa_t addr, unsigned int len, - unsigned long val); +int vgic_mmio_uaccess_write_cactive(struct kvm_vcpu *vcpu, + gpa_t addr, unsigned int len, + unsigned long val); -void vgic_mmio_uaccess_write_sactive(struct kvm_vcpu *vcpu, - gpa_t addr, unsigned int len, - unsigned long val); +int vgic_mmio_uaccess_write_sactive(struct kvm_vcpu *vcpu, + gpa_t addr, unsigned int len, + unsigned long val); unsigned long vgic_mmio_read_priority(struct kvm_vcpu *vcpu, gpa_t addr, unsigned int len);