forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-11 04dd17822334871b23ea2862f7798fb0e0007777
kernel/arch/powerpc/kvm/e500mc.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) 2010,2012 Freescale Semiconductor, Inc. All rights reserved.
34 *
....@@ -6,10 +7,6 @@
67 * Description:
78 * This file is derived from arch/powerpc/kvm/e500.c,
89 * by Yu Liu <yu.liu@freescale.com>.
9
- *
10
- * This program is free software; you can redistribute it and/or modify
11
- * it under the terms of the GNU General Public License, version 2, as
12
- * published by the Free Software Foundation.
1310 */
1411
1512 #include <linux/kvm_host.h>
....@@ -304,30 +301,20 @@
304301 return r;
305302 }
306303
307
-static struct kvm_vcpu *kvmppc_core_vcpu_create_e500mc(struct kvm *kvm,
308
- unsigned int id)
304
+static int kvmppc_core_vcpu_create_e500mc(struct kvm_vcpu *vcpu)
309305 {
310306 struct kvmppc_vcpu_e500 *vcpu_e500;
311
- struct kvm_vcpu *vcpu;
312307 int err;
313308
314
- vcpu_e500 = kmem_cache_zalloc(kvm_vcpu_cache, GFP_KERNEL);
315
- if (!vcpu_e500) {
316
- err = -ENOMEM;
317
- goto out;
318
- }
319
- vcpu = &vcpu_e500->vcpu;
309
+ BUILD_BUG_ON(offsetof(struct kvmppc_vcpu_e500, vcpu) != 0);
310
+ vcpu_e500 = to_e500(vcpu);
320311
321312 /* Invalid PIR value -- this LPID dosn't have valid state on any cpu */
322313 vcpu->arch.oldpir = 0xffffffff;
323314
324
- err = kvm_vcpu_init(vcpu, kvm, id);
325
- if (err)
326
- goto free_vcpu;
327
-
328315 err = kvmppc_e500_tlb_init(vcpu_e500);
329316 if (err)
330
- goto uninit_vcpu;
317
+ return err;
331318
332319 vcpu->arch.shared = (void *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
333320 if (!vcpu->arch.shared) {
....@@ -335,17 +322,11 @@
335322 goto uninit_tlb;
336323 }
337324
338
- return vcpu;
325
+ return 0;
339326
340327 uninit_tlb:
341328 kvmppc_e500_tlb_uninit(vcpu_e500);
342
-uninit_vcpu:
343
- kvm_vcpu_uninit(vcpu);
344
-
345
-free_vcpu:
346
- kmem_cache_free(kvm_vcpu_cache, vcpu_e500);
347
-out:
348
- return ERR_PTR(err);
329
+ return err;
349330 }
350331
351332 static void kvmppc_core_vcpu_free_e500mc(struct kvm_vcpu *vcpu)
....@@ -354,8 +335,6 @@
354335
355336 free_page((unsigned long)vcpu->arch.shared);
356337 kvmppc_e500_tlb_uninit(vcpu_e500);
357
- kvm_vcpu_uninit(vcpu);
358
- kmem_cache_free(kvm_vcpu_cache, vcpu_e500);
359338 }
360339
361340 static int kvmppc_core_init_vm_e500mc(struct kvm *kvm)
....@@ -397,7 +376,6 @@
397376 .vcpu_put = kvmppc_core_vcpu_put_e500mc,
398377 .vcpu_create = kvmppc_core_vcpu_create_e500mc,
399378 .vcpu_free = kvmppc_core_vcpu_free_e500mc,
400
- .mmu_destroy = kvmppc_mmu_destroy_e500,
401379 .init_vm = kvmppc_core_init_vm_e500mc,
402380 .destroy_vm = kvmppc_core_destroy_vm_e500mc,
403381 .emulate_op = kvmppc_core_emulate_op_e500,