From patchwork Tue Oct 23 10:21:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manish Jaggi X-Patchwork-Id: 10652987 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3563014DE for ; Tue, 23 Oct 2018 10:23:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0FA1728E98 for ; Tue, 23 Oct 2018 10:23:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 03F8928FB4; Tue, 23 Oct 2018 10:23:55 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 82FE628E98 for ; Tue, 23 Oct 2018 10:23:54 +0000 (UTC) Received: from localhost ([::1]:39272 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEtqr-0004qD-Sc for patchwork-qemu-devel@patchwork.kernel.org; Tue, 23 Oct 2018 06:23:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46129) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEtp1-000314-NA for qemu-devel@nongnu.org; Tue, 23 Oct 2018 06:22:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gEtow-0005Cz-LJ for qemu-devel@nongnu.org; Tue, 23 Oct 2018 06:21:59 -0400 Received: from mail-bn3nam01on0050.outbound.protection.outlook.com ([104.47.33.50]:21833 helo=NAM01-BN3-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gEtow-0005Ci-Ef for qemu-devel@nongnu.org; Tue, 23 Oct 2018 06:21:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Wg0A7JUzvpmunq4CV8Sgk9XLW+P6oKlxCgzPMDS0jt8=; b=GL3hoG0yNlBNl7MCWgvuyXpCSCz1UOYZsOiqUKnDvZEOVAp1DRuqJYyoKHCHXTeziNZBepy0tUbBCIHdNM/Pl1Tmc0v0aOoiOtNMyvTm2jbRynfM0x2RoZwQNID6ZOt+w4b0G3A0+9yr6Mn48zB9XicHEoBCEKAE+91GXAQEoDQ= Received: from BL0PR07MB5426.namprd07.prod.outlook.com (10.167.241.215) by BL0PR07MB5524.namprd07.prod.outlook.com (20.177.242.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1228.25; Tue, 23 Oct 2018 10:21:50 +0000 Received: from BL0PR07MB5426.namprd07.prod.outlook.com ([fe80::b934:24f5:2a83:e64]) by BL0PR07MB5426.namprd07.prod.outlook.com ([fe80::b934:24f5:2a83:e64%2]) with mapi id 15.20.1250.028; Tue, 23 Oct 2018 10:21:50 +0000 From: To: "Jaggi, Manish" , "quintela@redhat.com" , "dgilbert@redhat.com" , "eric.auger@redhat.com" , "qemu-devel@nongnu.org" , "peter.maydell@linaro.org" , "Nair, Jayachandran" , "Nowicki, Tomasz" Thread-Topic: [RFC] [PATCH] kvm: arm: Introduce error code KVM_EINVARIANT Thread-Index: AQHUaro1fkyRZHtHUEqOo9gpPlhNAA== Date: Tue, 23 Oct 2018 10:21:50 +0000 Message-ID: <1540290099-146109-1-git-send-email-mjaggi@caviumnetworks.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [50.233.148.155] x-clientproxiedby: BYAPR11CA0066.namprd11.prod.outlook.com (2603:10b6:a03:80::43) To BL0PR07MB5426.namprd07.prod.outlook.com (2603:10b6:208:26::23) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Manish.Jaggi@cavium.com; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; BL0PR07MB5524; 6:RYo6VTegnHcQibq/k7FVJOFyE2ADIk5rItyq1z5afmzmk17MHkXfV4gN46zMe2TmS0mJOrj++/5HPOTe3DiAxwkmsGAj+5+JGwLqLb/pd9AnKVq56LK/+YqbIJiAERMVqCz6996+wgdsYApshUAtfT/3C2S3F1FLvB8RVHJ8nmnUKcuk+NLssSmyTJNx05xOUoxgovpFR28AelpOiRQRqG2z9kygqxXSvpME/YKLGLwS5/auPcQ4gh7FksYXQEzBCGXxIgfTEK1aKrMHdz/y1Qs0pLJaH6fyGgGDPf82CXyp2USPPe086t+VQ2MWNymhS86rqXsKi8SPyysz2sYT7opeOjXNON/xBBEU81fZtAV0ZZ8Dhvwoe9yKlSneCKcNj3PsXghFW3leH7R7EVJxiBfcsOE2ua3b1WbCR/RgCeWLgn6xfn0BvBf0+rXbaDuWV/feec4FLiE1oCq6nixumQ==; 5:XMS8jANAQVcxjMa8MzsqCWnmI5tEC+aAjvAqd1NZSh/rDJpZaOGD5e5lDSV8rkeuKmP9CjMBYT7VIv/H4QCq9S1R/cWVvuBqq4uHp0o8UkMR3hsQMIK9XfGJD6uKJh49fCkF+QFa3RW6w4Nc3dzSltkMmktwU1K8hWiUpE9DEWo=; 7:PWsaRtqQAKEDyKxkgBFutzmo4eAsr4pVOnQnO0DOQOtgGC7yZVI3yUP8ckVkRxpN2dGd3/MqPAV4Lbo31HiU2PfCwzx6hd3O3DVeIcSsuDvRV44djqnhOMqNOxcGZ3ZdB32T23yPaHyXVxY9FUHkcrHeLuHoupKxb3D+WhhGTBMs+g1FC6hRYT7+Q4FxD6zOzO28IO0HhfaDw75LdC657MgCTAd6io/V2ZU9VAPnc0Ll4i+2Z+M+2Eb5tx/3Es+O x-ms-office365-filtering-correlation-id: 2fb469ce-45c9-4123-f35b-08d638d157ff x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:BL0PR07MB5524; x-ms-traffictypediagnostic: BL0PR07MB5524: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(226959686518644)(22074186197030); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(93006095)(10201501046)(3231355)(944501410)(52105095)(3002001)(148016)(149066)(150057)(6041310)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123558120)(201708071742011)(7699051)(76991095); SRVR:BL0PR07MB5524; BCL:0; PCL:0; RULEID:; SRVR:BL0PR07MB5524; x-forefront-prvs: 0834BAF534 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(366004)(39850400004)(136003)(376002)(396003)(189003)(199004)(105586002)(256004)(186003)(6116002)(3846002)(6306002)(6486002)(305945005)(102836004)(6506007)(5660300001)(8936002)(81156014)(42882007)(68736007)(53936002)(66066001)(6436002)(110136005)(81166006)(386003)(26005)(14454004)(106356001)(6512007)(486006)(2906002)(8676002)(25786009)(2201001)(71190400001)(478600001)(2616005)(36756003)(2900100001)(72206003)(2501003)(71200400001)(5250100002)(316002)(52116002)(966005)(99286004)(97736004)(476003)(575784001)(7736002)(921003)(1121003); DIR:OUT; SFP:1101; SCL:1; SRVR:BL0PR07MB5524; H:BL0PR07MB5426.namprd07.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: wdbDFEKt837he2sFDtxP8VEM6TsRGo6IqpFacQ238o205zEel6X85/PeReVRp0bzYzBjmLcvWRWUOWfmgcBCuYO8QoWZFDaNyThSUQV92XVTeVsw2q7XhlMqg5qoKfzzq2a11GRa3127epzE+NGJ11Z8oHYrw71asC1QtXSTPkuS+4YRz/EdH2/no4bsQz3FMZROb1P5lEx/i5o0G7T7SQlZievJPrtLHotgsETSbuCjR+WVBDILiTx0nspPdC2RWbCcl/iWwI6Zh8IFCNQhfiHyJ/zNl1Xo8dG4eb4sTkpAdczXVfiWRm9KMlUIyveY40lqOZMqS7O0S2lNe/S2mrcRjwR1u/8mgr8zqAtS6fc= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2fb469ce-45c9-4123-f35b-08d638d157ff X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Oct 2018 10:21:50.0215 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR07MB5524 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.33.50 Subject: [Qemu-devel] [RFC] [PATCH] kvm: arm: Introduce error code KVM_EINVARIANT X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Manish Jaggi This patch introduces an error code KVM_EINVARIANT which is returned by KVM when userland tries to set an invariant register. The need for this error code is in VM Migration for arm64. ARM64 systems use mainly -machine virt -cpu host as parameter to qemu. Migration requires both Source and destination machines to have same physical cpu. There are cases where the overall architecture of CPU is same but the next version of the chip with some bug fixes which have no effect on qemu operation. In such cases invariant registers like MIDR have a different value. Currently Migration fails in such cases. Rather than sending a EINVAL, a specifc error code will help userland program the guest invariant register by querying the migrated host machines invariant registers. Qemu will have a parameter -hostinvariant along with checking of this error code. So it can be safely assumed that the feature is opt-in Corresponding Qemu patcset can be found at : https://lists.gnu.org/archive/html/qemu-devel/2018-10/msg05048.html Signed-off-by: Manish Jaggi --- arch/arm64/kvm/sys_regs.c | 9 ++++----- include/uapi/linux/kvm_para.h | 1 + 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index 22fbbdb..78ffc02 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -1111,7 +1111,7 @@ static int __set_id_reg(const struct sys_reg_desc *rd, void __user *uaddr, /* This is what we mean by invariant: you can't change it. */ if (val != read_id_reg(rd, raz)) - return -EINVAL; + return -KVM_EINVARIANT; return 0; } @@ -2254,9 +2254,8 @@ static int set_invariant_sys_reg(u64 id, void __user *uaddr) return err; /* This is what we mean by invariant: you can't change it. */ - if (r->val != val) - return -EINVAL; - + if (r->val != val) + return -KVM_EINVARIANT; return 0; } @@ -2335,7 +2334,7 @@ static int demux_c15_set(u64 id, void __user *uaddr) /* This is also invariant: you can't change it. */ if (newval != get_ccsidr(val)) - return -EINVAL; + return -KVM_EINVARIANT; return 0; default: return -ENOENT; diff --git a/include/uapi/linux/kvm_para.h b/include/uapi/linux/kvm_para.h index 6c0ce49..4358669 100644 --- a/include/uapi/linux/kvm_para.h +++ b/include/uapi/linux/kvm_para.h @@ -17,6 +17,7 @@ #define KVM_E2BIG E2BIG #define KVM_EPERM EPERM #define KVM_EOPNOTSUPP 95 +#define KVM_EINVARIANT 96 #define KVM_HC_VAPIC_POLL_IRQ 1 #define KVM_HC_MMU_OP 2