Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755043AbdHYIfW (ORCPT ); Fri, 25 Aug 2017 04:35:22 -0400 Received: from mail-db5eur01on0078.outbound.protection.outlook.com ([104.47.2.78]:58016 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755061AbdHYIct (ORCPT ); Fri, 25 Aug 2017 04:32:49 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Florent.Revest@arm.com; From: Florent Revest To: linux-arm-kernel@lists.infradead.org Cc: matt@codeblueprint.co.uk, ard.biesheuvel@linaro.org, pbonzini@redhat.com, rkrcmar@redhat.com, christoffer.dall@linaro.org, catalin.marinas@arm.com, will.deacon@arm.com, mark.rutland@arm.com, marc.zyngier@arm.com, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, leif.lindholm@arm.com, revestflo@gmail.com, Florent Revest Subject: [RFC 08/11] KVM, arm, arm64: Initialize KVM's core earlier Date: Fri, 25 Aug 2017 09:31:38 +0100 Message-Id: <1503649901-5834-9-git-send-email-florent.revest@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1503649901-5834-1-git-send-email-florent.revest@arm.com> References: <1503649901-5834-1-git-send-email-florent.revest@arm.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [217.140.96.140] X-ClientProxiedBy: HE1PR09CA0051.eurprd09.prod.outlook.com (2603:10a6:7:3c::19) To HE1PR08MB0812.eurprd08.prod.outlook.com (2a01:111:e400:59b1::30) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: defafd58-8d0b-413a-3a9d-08d4eb93d233 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:HE1PR08MB0812; X-Microsoft-Exchange-Diagnostics: 1;HE1PR08MB0812;3:RM8iPP5b7Lg8AdPeksy9aMXjklivUFfW1RIAGhRZANa4a2liAEhHcLP173+zmW2nxNeZgn0l2poaVcckY6EuvAcgCuP22jN3jPOTUASBFZEBMuDB3S5DpGGkkXu85194hxch+Z4xEjxi+me+ilS0EVB3r9mPbcfAR/Y+Iex6UrGMnTFSvDTqrSkyp4dFKed8q+BcEQvZxwhNbSrI+ug7kMwCha5gm/rlZro5kaAwC+3lWaSkWC6pIr9GYXif47ee;25:8eVqWF7DP1w0I1SAUvDduLpcZXt2bpg6BIEHAmPojiSuPI9oAa7nfHIWRm3xU7fWRhhZBT++jzvc/9fr8WHPleLnuy0IAg6NDOW3q/R4Xjv68vYWGTMmii+r9GmcyVtfAMBuNiVneZ91Z6Fr+jDPXlheSJlrHbV/EKmRDjcxpMEcF2s8h4eHQTUFStm5IVBBsry6l0WLqRl3APTGoeYYJmIWpMYqL21uC5ih+IWPhmyrPlNK9/TEVes9WXd3yqjKly8FoHcj+M5P+WW+O/26REZwV28NQLgY6vOI+3LyruMbjs0Vg7gLTmjlZlhXWYhX0GO+Vny8gCoMFc2fG9xxvw==;31:WDnkwZjdZ9tfMSvQvB0U4wjxTENb0lafw/xf/WS6ZTUYPCSSv+wX9y8Z4nlqrX028ZstWnOjFnaywKswCp9dmmuuawtRyoWdmno7RNQvrlxsBJ2xPGYOtik3nvV4cJsefWm/2+AWplF3CSYeFhWVPNwz+DynpHwk57APcxQyJxa9ci8fIgrz78ByvqmNZ/WqP9xStV6uOBL4oTQx0tfv0VjSygVVrbl8RoDWMTdWT/w= X-MS-TrafficTypeDiagnostic: HE1PR08MB0812: X-Microsoft-Exchange-Diagnostics: 1;HE1PR08MB0812;20:ukps+7TigqnfnCLbGB7yorGRYyI8o8Wv4HNG0Urez52cP7S49U3MQn/s5SGff9Bx9OXovuveLjN4An8C4RVe4kKtUhxv3OjpyLZjbGWzA+3F2lvrCAVGqvfdn2LDcbzFUL6gZDaDHc1DEKdvKQ8m8/5w++tH0bMUiT821Vaiw5O+6do48HuQshFsAPHU0MJ48/qB4U5XHIWlWD/iPuIqaY3MsRY3ZFpMWG4hkIaD8QTIp0hILYkAgL75xlfSQsVypsqv7KRKDdGqpbmevNIz9pbpLpZKPV0ZvXTsp+5iP0NfpPUf1TzWJSbkK4BrDDvC/NzABTB7+WmYza0Hd6tvfd8Y80CGbx63BGSnpcDkR6LfIhHCCKDOBWfAN7M2zKHD4+c58YeoazVGe3MRTrogkw9oTo+OlmCSYK2SJWi5Lm+BFDMgO9PuQva8aDYhUWZCdl0d6w+BSZHWNzRCPjzA3DpxACErXUtF7ttbaRRQkw4fnjJAYB4K/C4pRmKfZHH8;4:604XSZSVIZeynmKQ9oqigyHq25inOTlQmVf/JSXOs7MWdnp1vNUL2rfjXjN68cetOwzwl/VRHOZlyhA4nVYQUAh3KhJOp3eNnZgLJ5GK9op9tHHAdzr2cft48tbr2LH5Y7gttt1DPaTKNZyEPy+3B0pLfUUviOWY1d8UT46QMe0M+2DDwnqjSUOUXrSxV04/jf6sC1xRKGniOAxxSDwTwmXrxouafUpRspbOO4F5XUZFzsugBv/uk566ymxZrPcsPTvv6BAQLWMfpO/gAFBmDjCmCKIUM3U4G+5E03b8f9E= X-Exchange-Antispam-Report-Test: UriScan:(180628864354917); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(93006095)(93001095)(100000703101)(100105400095)(6055026)(6041248)(20161123560025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123564025)(20161123555025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:HE1PR08MB0812;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:HE1PR08MB0812; X-Forefront-PRVS: 041032FF37 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(7370300001)(6009001)(39860400002)(199003)(40434004)(189002)(478600001)(68736007)(76176999)(25786009)(5660300001)(97736004)(36756003)(6486002)(50226002)(47776003)(50986999)(50466002)(4326008)(48376002)(7350300001)(110136004)(66066001)(7416002)(8676002)(189998001)(305945005)(5890100001)(6916009)(2351001)(105586002)(42186005)(6116002)(2361001)(8746002)(3846002)(575784001)(86362001)(2906002)(72206003)(81156014)(81166006)(2950100002)(106356001)(6666003)(7736002)(33646002)(101416001)(5003940100001)(53936002);DIR:OUT;SFP:1101;SCL:1;SRVR:HE1PR08MB0812;H:e106757-lin.cambridge.arm.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;HE1PR08MB0812;23:F9lWSRO/LOxO1Jmx/qwySpL9XQyXR68qPm4LumrDY?= =?us-ascii?Q?PYz5b4/VeRG+SFbTuqV9y7vZM108MbOyp3vgY5g9vuaObtMA/KS4JvN4mp3E?= =?us-ascii?Q?KbAZ0iEBSl4dgcgXxYRodpLp1sKyGpjds6c2H1cz46FQiq9ZCwfjq1Lpq8X1?= =?us-ascii?Q?M1ZJcek3yHdzvVjy2/Gaer2MAhmAGLCMJhu9zEG7+GjoTAfl6qL2hWtI04X5?= =?us-ascii?Q?JZgXHaMQPNdxEJhoqCphuS6KRfDkoptWgOSNyQjvAgvF7JyeQka6dRc7OqdM?= =?us-ascii?Q?WDbCE/bVdGLDhZhpcV1D7yzr5ZJNuBVNynaGEM6axIXabXu0NBUOQgBUT+tF?= =?us-ascii?Q?WU6tmcOsYfGJANJm6BLO0G5a6hlHNt92Gk/aJx5eXPWQuxIYpOcA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ft-Exchange-Diagnostics: 1;HE1PR08MB0812;6:7pFkkBqdxqKHTjYbI1t1B+1OFhNka71QUp3w1zcF+jtvgxB7ja4X9Ss0WljeERK0VsOl+cjIzGzpYDWd3issUylXdb10y3FxZqx/Er8lpfMDCpl/gptlPTqwfJvuS8vzgx3HBH1IJbkAF/dxRhTyzWoCIYe7Ih1L+aF+0HQ0f1KpYncMT8TuVGvVq35rJA3qdpku/Of94O5tUc5arxosnCYOtdg50eMg9d5x6yjt/DBMczP8vnaDj7pKfnpZTnqYBupPR/qII3xBcOMBgWpPLOsnRiYfyVAf9jR9cje1mbGZcngEiARQ65Tdfl5yK7gqztqsXhQ1VkCLq/CWU4tLsw==;5:zw40Rn6+AWplPXJxyrgxDXIgmmvI8GP9UQM6v5UMh6OfTI0u3uBAIbqfECUy4Q773INjOs5q/C7+04DcN3ssR2diZHZv+vNXmEBkh+dHDVbVUMQUBm0i82YWQW/xnWwGif2ougowP3SaYYiMES4pKA==;24:pDA3VySeA3KiwSbhWw9dSBLHrh97cSQno+Zxs66NMu6AIvhXzSPwI5djpDJB4+aG4Y5JsiUUGNN2MqwmieIigcI092e4ARol0+3F842TglU=;7:Ou17Ig1gomDsCcWctDGov6dhMKdFWtTaS2ZjIoOAwrhl6rJZ1jqzA5bDIEc53PTfwwpRb0nxSlpVSjQiDla8So2OO4eIgnbePP66vXSFSonHU2uyemNfMXlGMbKKtCQIui5/C8NvBpDAyJDp3giwQsO03jt7yRavqHzl8DMT4eMjFPNbrsBG4K6IDYqsszgg3ZKm5NsQ7uBVB6I57JZYIwoGCMPmyt1uuO/3KUsFe9g= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2017 08:32:27.4749 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR08MB0812 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by nfs id v7P8ZRV0009983 Content-Length: 5665 Lines: 159 In order to use internal VMs early in the boot process, the arm_init function, in charge of initializing KVM, is split in two parts: - A subsys_initcall target initializing KVM's core only - A module_init target initializing KVM's userspace facing files An implicit dependency of VM execution on arm and arm64, the initialization of KVM system registers, is also rescheduled to be effective as soon as KVM's core is initialized. Signed-off-by: Florent Revest --- arch/arm/include/asm/kvm_coproc.h | 3 +++ arch/arm/include/asm/kvm_host.h | 1 + arch/arm/kvm/coproc.c | 6 ++++++ arch/arm/kvm/coproc_a15.c | 3 +-- arch/arm/kvm/coproc_a7.c | 3 +-- arch/arm64/include/asm/kvm_host.h | 1 + arch/arm64/kvm/sys_regs_generic_v8.c | 8 ++++++-- virt/kvm/arm/arm.c | 13 +++++++++++-- 8 files changed, 30 insertions(+), 8 deletions(-) diff --git a/arch/arm/include/asm/kvm_coproc.h b/arch/arm/include/asm/kvm_coproc.h index e74ab0f..1502723 100644 --- a/arch/arm/include/asm/kvm_coproc.h +++ b/arch/arm/include/asm/kvm_coproc.h @@ -45,4 +45,7 @@ struct kvm_coproc_target_table { int kvm_arm_coproc_get_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *); int kvm_arm_coproc_set_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *); unsigned long kvm_arm_num_coproc_regs(struct kvm_vcpu *vcpu); + +int coproc_a15_init(void); +int coproc_a7_init(void); #endif /* __ARM_KVM_COPROC_H__ */ diff --git a/arch/arm/include/asm/kvm_host.h b/arch/arm/include/asm/kvm_host.h index 127e2dd..fb94666 100644 --- a/arch/arm/include/asm/kvm_host.h +++ b/arch/arm/include/asm/kvm_host.h @@ -287,6 +287,7 @@ static inline void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu) {} static inline void kvm_arch_sched_in(struct kvm_vcpu *vcpu, int cpu) {} static inline void kvm_arch_vcpu_block_finish(struct kvm_vcpu *vcpu) {} +void kvm_arm_init_sys_reg(void); static inline void kvm_arm_init_debug(void) {} static inline void kvm_arm_setup_debug(struct kvm_vcpu *vcpu) {} static inline void kvm_arm_clear_debug(struct kvm_vcpu *vcpu) {} diff --git a/arch/arm/kvm/coproc.c b/arch/arm/kvm/coproc.c index 6d1d2e2..28bc397 100644 --- a/arch/arm/kvm/coproc.c +++ b/arch/arm/kvm/coproc.c @@ -1369,3 +1369,9 @@ void kvm_reset_coprocs(struct kvm_vcpu *vcpu) if (vcpu_cp15(vcpu, num) == 0x42424242) panic("Didn't reset vcpu_cp15(vcpu, %zi)", num); } + +void kvm_arm_init_sys_reg(void) +{ + coproc_a7_init(); + coproc_a15_init(); +} diff --git a/arch/arm/kvm/coproc_a15.c b/arch/arm/kvm/coproc_a15.c index a713675..83102a3 100644 --- a/arch/arm/kvm/coproc_a15.c +++ b/arch/arm/kvm/coproc_a15.c @@ -43,9 +43,8 @@ .num = ARRAY_SIZE(a15_regs), }; -static int __init coproc_a15_init(void) +int coproc_a15_init(void) { kvm_register_target_coproc_table(&a15_target_table); return 0; } -late_initcall(coproc_a15_init); diff --git a/arch/arm/kvm/coproc_a7.c b/arch/arm/kvm/coproc_a7.c index b19e46d..b365ac0 100644 --- a/arch/arm/kvm/coproc_a7.c +++ b/arch/arm/kvm/coproc_a7.c @@ -46,9 +46,8 @@ .num = ARRAY_SIZE(a7_regs), }; -static int __init coproc_a7_init(void) +int coproc_a7_init(void) { kvm_register_target_coproc_table(&a7_target_table); return 0; } -late_initcall(coproc_a7_init); diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 07b7460..e360bb3 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -374,6 +374,7 @@ static inline void kvm_arch_vcpu_block_finish(struct kvm_vcpu *vcpu) {} int kvm_arm_vcpu_init(struct kvm_vcpu *vcpu, struct kvm_vcpu_init *init); +void kvm_arm_init_sys_reg(void); void kvm_arm_init_debug(void); void kvm_arm_setup_debug(struct kvm_vcpu *vcpu); void kvm_arm_clear_debug(struct kvm_vcpu *vcpu); diff --git a/arch/arm64/kvm/sys_regs_generic_v8.c b/arch/arm64/kvm/sys_regs_generic_v8.c index 969ade1..0fe755d 100644 --- a/arch/arm64/kvm/sys_regs_generic_v8.c +++ b/arch/arm64/kvm/sys_regs_generic_v8.c @@ -72,7 +72,7 @@ static void reset_actlr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r) }, }; -static int __init sys_reg_genericv8_init(void) +static int sys_reg_genericv8_init(void) { unsigned int i; @@ -95,4 +95,8 @@ static int __init sys_reg_genericv8_init(void) return 0; } -late_initcall(sys_reg_genericv8_init); + +void kvm_arm_init_sys_reg(void) +{ + sys_reg_genericv8_init(); +} diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c index aa29a5d..7d0aa4f 100644 --- a/virt/kvm/arm/arm.c +++ b/virt/kvm/arm/arm.c @@ -1451,6 +1451,8 @@ int kvm_arch_init(void *opaque) int err; int ret, cpu; + kvm_arm_init_sys_reg(); + if (!is_hyp_mode_available()) { kvm_err("HYP mode not available\n"); return -ENODEV; @@ -1496,8 +1498,15 @@ void kvm_arch_exit(void) static int arm_init(void) { - int rc = kvm_init(NULL, sizeof(struct kvm_vcpu), 0, THIS_MODULE); + int rc = kvm_init(NULL, sizeof(struct kvm_vcpu), 0, NULL); return rc; } -module_init(arm_init); +subsys_initcall(arm_init); + +static int arm_module_init(void) +{ + return kvm_set_module(THIS_MODULE); +} + +module_init(arm_module_init); -- 1.9.1 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.