forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-11 04dd17822334871b23ea2862f7798fb0e0007777
kernel/arch/powerpc/kvm/e500.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) 2008-2011 Freescale Semiconductor, Inc. All rights reserved.
34 *
....@@ -6,10 +7,6 @@
67 * Description:
78 * This file is derived from arch/powerpc/kvm/44x.c,
89 * by Hollis Blanchard <hollisb@us.ibm.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>
....@@ -436,28 +433,16 @@
436433 return r;
437434 }
438435
439
-static struct kvm_vcpu *kvmppc_core_vcpu_create_e500(struct kvm *kvm,
440
- unsigned int id)
436
+static int kvmppc_core_vcpu_create_e500(struct kvm_vcpu *vcpu)
441437 {
442438 struct kvmppc_vcpu_e500 *vcpu_e500;
443
- struct kvm_vcpu *vcpu;
444439 int err;
445440
446
- vcpu_e500 = kmem_cache_zalloc(kvm_vcpu_cache, GFP_KERNEL);
447
- if (!vcpu_e500) {
448
- err = -ENOMEM;
449
- goto out;
450
- }
441
+ BUILD_BUG_ON(offsetof(struct kvmppc_vcpu_e500, vcpu) != 0);
442
+ vcpu_e500 = to_e500(vcpu);
451443
452
- vcpu = &vcpu_e500->vcpu;
453
- err = kvm_vcpu_init(vcpu, kvm, id);
454
- if (err)
455
- goto free_vcpu;
456
-
457
- if (kvmppc_e500_id_table_alloc(vcpu_e500) == NULL) {
458
- err = -ENOMEM;
459
- goto uninit_vcpu;
460
- }
444
+ if (kvmppc_e500_id_table_alloc(vcpu_e500) == NULL)
445
+ return -ENOMEM;
461446
462447 err = kvmppc_e500_tlb_init(vcpu_e500);
463448 if (err)
....@@ -469,18 +454,13 @@
469454 goto uninit_tlb;
470455 }
471456
472
- return vcpu;
457
+ return 0;
473458
474459 uninit_tlb:
475460 kvmppc_e500_tlb_uninit(vcpu_e500);
476461 uninit_id:
477462 kvmppc_e500_id_table_free(vcpu_e500);
478
-uninit_vcpu:
479
- kvm_vcpu_uninit(vcpu);
480
-free_vcpu:
481
- kmem_cache_free(kvm_vcpu_cache, vcpu_e500);
482
-out:
483
- return ERR_PTR(err);
463
+ return err;
484464 }
485465
486466 static void kvmppc_core_vcpu_free_e500(struct kvm_vcpu *vcpu)
....@@ -490,8 +470,6 @@
490470 free_page((unsigned long)vcpu->arch.shared);
491471 kvmppc_e500_tlb_uninit(vcpu_e500);
492472 kvmppc_e500_id_table_free(vcpu_e500);
493
- kvm_vcpu_uninit(vcpu);
494
- kmem_cache_free(kvm_vcpu_cache, vcpu_e500);
495473 }
496474
497475 static int kvmppc_core_init_vm_e500(struct kvm *kvm)
....@@ -512,7 +490,6 @@
512490 .vcpu_put = kvmppc_core_vcpu_put_e500,
513491 .vcpu_create = kvmppc_core_vcpu_create_e500,
514492 .vcpu_free = kvmppc_core_vcpu_free_e500,
515
- .mmu_destroy = kvmppc_mmu_destroy_e500,
516493 .init_vm = kvmppc_core_init_vm_e500,
517494 .destroy_vm = kvmppc_core_destroy_vm_e500,
518495 .emulate_op = kvmppc_core_emulate_op_e500,