lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1bf2bf7f-bc52-4971-3dd3-06bfa85f9275@loongson.cn>
Date:   Mon, 5 Jun 2023 20:31:46 +0800
From:   "bibo, mao" <maobibo@...ngson.cn>
To:     Tianrui Zhao <zhaotianrui@...ngson.cn>,
        linux-kernel@...r.kernel.org, kvm@...r.kernel.org
Cc:     Paolo Bonzini <pbonzini@...hat.com>,
        Huacai Chen <chenhuacai@...nel.org>,
        WANG Xuerui <kernel@...0n.name>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        loongarch@...ts.linux.dev, Jens Axboe <axboe@...nel.dk>,
        Mark Brown <broonie@...nel.org>,
        Alex Deucher <alexander.deucher@....com>,
        Oliver Upton <oliver.upton@...ux.dev>,
        Xi Ruoyao <xry111@...111.site>
Subject: Re: [PATCH v12 04/31] LoongArch: KVM: Implement VM related functions

Reviewed-by: Bibo, Mao <maobibo@...ngson.cn>

在 2023/5/30 09:51, Tianrui Zhao 写道:
> Implement LoongArch VM operations: Init and destroy vm interface,
> allocating memory page to save the vm pgd when init vm. Implement
> vm check extension, such as getting vcpu number info, memory slots
> info, and fpu info. And implement vm status description.
> 
> Signed-off-by: Tianrui Zhao <zhaotianrui@...ngson.cn>
> ---
>  arch/loongarch/kvm/vm.c | 78 +++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 78 insertions(+)
>  create mode 100644 arch/loongarch/kvm/vm.c
> 
> diff --git a/arch/loongarch/kvm/vm.c b/arch/loongarch/kvm/vm.c
> new file mode 100644
> index 000000000000..43688a04ab78
> --- /dev/null
> +++ b/arch/loongarch/kvm/vm.c
> @@ -0,0 +1,78 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (C) 2020-2023 Loongson Technology Corporation Limited
> + */
> +
> +#include <linux/kvm_host.h>
> +
> +#define KVM_LOONGARCH_VERSION 1
> +
> +const struct _kvm_stats_desc kvm_vm_stats_desc[] = {
> +	KVM_GENERIC_VM_STATS(),
> +};
> +
> +const struct kvm_stats_header kvm_vm_stats_header = {
> +	.name_size = KVM_STATS_NAME_SIZE,
> +	.num_desc = ARRAY_SIZE(kvm_vm_stats_desc),
> +	.id_offset =  sizeof(struct kvm_stats_header),
> +	.desc_offset = sizeof(struct kvm_stats_header) + KVM_STATS_NAME_SIZE,
> +	.data_offset = sizeof(struct kvm_stats_header) + KVM_STATS_NAME_SIZE +
> +					sizeof(kvm_vm_stats_desc),
> +};
> +
> +int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
> +{
> +	/* Allocate page table to map GPA -> RPA */
> +	kvm->arch.gpa_mm.pgd = kvm_pgd_alloc();
> +	if (!kvm->arch.gpa_mm.pgd)
> +		return -ENOMEM;
> +
> +	kvm_init_vmcs(kvm);
> +	kvm->arch.gpa_size = BIT(cpu_vabits - 1);
> +	return 0;
> +}
> +
> +void kvm_arch_destroy_vm(struct kvm *kvm)
> +{
> +	kvm_destroy_vcpus(kvm);
> +	_kvm_destroy_mm(kvm);
> +}
> +
> +int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
> +{
> +	int r;
> +
> +	switch (ext) {
> +	case KVM_CAP_ONE_REG:
> +	case KVM_CAP_ENABLE_CAP:
> +	case KVM_CAP_READONLY_MEM:
> +	case KVM_CAP_SYNC_MMU:
> +	case KVM_CAP_IMMEDIATE_EXIT:
> +	case KVM_CAP_IOEVENTFD:
> +	case KVM_CAP_MP_STATE:
> +		r = 1;
> +		break;
> +	case KVM_CAP_NR_VCPUS:
> +		r = num_online_cpus();
> +		break;
> +	case KVM_CAP_MAX_VCPUS:
> +		r = KVM_MAX_VCPUS;
> +		break;
> +	case KVM_CAP_MAX_VCPU_ID:
> +		r = KVM_MAX_VCPU_IDS;
> +		break;
> +	case KVM_CAP_NR_MEMSLOTS:
> +		r = KVM_USER_MEM_SLOTS;
> +		break;
> +	default:
> +		r = 0;
> +		break;
> +	}
> +
> +	return r;
> +}
> +
> +int kvm_arch_vm_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg)
> +{
> +	return -ENOIOCTLCMD;
> +}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ