All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: 赵天瑞 <zhaotianrui@loongson.cn>
To: "Youling Tang" <tangyouling@loongson.cn>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Huacai Chen" <chenhuacai@kernel.org>,
	"WANG Xuerui" <kernel@xen0n.name>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	loongarch@lists.linux.dev, "Jens Axboe" <axboe@kernel.dk>,
	"Mark Brown" <broonie@kernel.org>,
	"Alex Deucher" <alexander.deucher@amd.com>,
	"Oliver Upton" <oliver.upton@linux.dev>,
	maobibo@loongson.cn, "Xi Ruoyao" <xry111@xry111.site>
Subject: Re: Re: [PATCH v12 26/31] LoongArch: KVM: Implement kvm exception vector
Date: Thu, 8 Jun 2023 19:44:40 +0800 (GMT+08:00)	[thread overview]
Message-ID: <592bfebe.ac52.1889ad2b799.Coremail.zhaotianrui@loongson.cn> (raw)
In-Reply-To: <b0e8a311-d988-a1be-a256-130adcdbbfc6@loongson.cn>




> -----原始邮件-----
> 发件人: "Youling Tang" <tangyouling@loongson.cn>
> 发送时间:2023-06-06 15:00:11 (星期二)
> 收件人: "Tianrui Zhao" <zhaotianrui@loongson.cn>
> 抄送: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, "Paolo Bonzini" <pbonzini@redhat.com>, "Huacai Chen" <chenhuacai@kernel.org>, "WANG Xuerui" <kernel@xen0n.name>, "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>, loongarch@lists.linux.dev, "Jens Axboe" <axboe@kernel.dk>, "Mark Brown" <broonie@kernel.org>, "Alex Deucher" <alexander.deucher@amd.com>, "Oliver Upton" <oliver.upton@linux.dev>, maobibo@loongson.cn, "Xi Ruoyao" <xry111@xry111.site>
> 主题: Re: [PATCH v12 26/31] LoongArch: KVM: Implement kvm exception vector
> 
> 
> 
> On 05/30/2023 09:52 AM, Tianrui Zhao wrote:
> > Implement kvm exception vector, using _kvm_fault_tables array to save
> > the handle function pointer and it is used when vcpu handle exit.
> >
> > Signed-off-by: Tianrui Zhao <zhaotianrui@loongson.cn>
> > ---
> >  arch/loongarch/kvm/exit.c | 48 +++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 48 insertions(+)
> >
> > diff --git a/arch/loongarch/kvm/exit.c b/arch/loongarch/kvm/exit.c
> > index 10f9922a7e76..625045fc95c8 100644
> > --- a/arch/loongarch/kvm/exit.c
> > +++ b/arch/loongarch/kvm/exit.c
> > @@ -657,3 +657,51 @@ static int _kvm_handle_fpu_disabled(struct kvm_vcpu *vcpu)
> >  	kvm_own_fpu(vcpu);
> >  	return RESUME_GUEST;
> >  }
> > +
> > +/*
> > + * Loongarch KVM callback handling for not implemented guest exiting
> > + */
> > +static int _kvm_fault_ni(struct kvm_vcpu *vcpu)
> > +{
> > +	unsigned long estat, badv;
> > +	unsigned int exccode, inst;
> > +
> > +	/*
> > +	 *  Fetch the instruction.
> > +	 */
> > +	badv = vcpu->arch.badv;
> > +	estat = vcpu->arch.host_estat;
> > +	exccode = (estat & CSR_ESTAT_EXC) >> CSR_ESTAT_EXC_SHIFT;
> > +	inst = vcpu->arch.badi;
> > +	kvm_err("Exccode: %d PC=%#lx inst=0x%08x BadVaddr=%#lx estat=%#lx\n",
> > +			exccode, vcpu->arch.pc, inst, badv, read_gcsr_estat());
> > +	kvm_arch_vcpu_dump_regs(vcpu);
> > +	vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
> > +
> > +	return RESUME_HOST;
> > +}
> > +
> > +static exit_handle_fn _kvm_fault_tables[EXCCODE_INT_START] = {
> > +	[EXCCODE_TLBL]		= _kvm_handle_read_fault,
> > +	[EXCCODE_TLBI]		= _kvm_handle_read_fault,
> > +	[EXCCODE_TLBNR]		= _kvm_handle_read_fault,
> > +	[EXCCODE_TLBNX]		= _kvm_handle_read_fault,
> > +	[EXCCODE_TLBS]		= _kvm_handle_write_fault,
> > +	[EXCCODE_TLBM]		= _kvm_handle_write_fault,
> > +	[EXCCODE_FPDIS]		= _kvm_handle_fpu_disabled,
> > +	[EXCCODE_GSPR]		= _kvm_handle_gspr,
> > +};
> It can be modified as follows and remove _kvm_init_fault().
> 
> static exit_handle_fn _kvm_fault_tables[EXCCODE_INT_START] = {
> 	[0 ... EXCCODE_INT_START - 1]	= _kvm_fault_ni,
> 
> 	[EXCCODE_TLBL]			= _kvm_handle_read_fault,
> 	[EXCCODE_TLBI]			= _kvm_handle_read_fault,
> 	[EXCCODE_TLBNR]			= _kvm_handle_read_fault,
> 	[EXCCODE_TLBNX]			= _kvm_handle_read_fault,
> 	[EXCCODE_TLBS]			= _kvm_handle_write_fault,
> 	[EXCCODE_TLBM]			= _kvm_handle_write_fault,
> 	[EXCCODE_FPDIS]			= _kvm_handle_fpu_disabled,
> 	[EXCCODE_GSPR]			= _kvm_handle_gspr,
> };
> 
> Thanks,
> Youling
Hi Youling,
When I compile this code with W=1, there is a warning: initialized field overwritten [-Woverride-init], so considering this problem I think we have to keep the previous _kvm_init_fault, what do you think of it?

Thanks
Tianrui Zhao
> 
> > +
> > +int _kvm_handle_fault(struct kvm_vcpu *vcpu, int fault)
> > +{
> > +	return _kvm_fault_tables[fault](vcpu);
> > +}
> > +
> > +void _kvm_init_fault(void)
> > +{
> > +	int i;
> > +
> > +	for (i = 0; i < EXCCODE_INT_START; i++)
> > +		if (!_kvm_fault_tables[i])
> > +			_kvm_fault_tables[i] = _kvm_fault_ni;
> > +}
> >


本邮件及其附件含有龙芯中科的商业秘密信息,仅限于发送给上面地址中列出的个人或群组。禁止任何其他人以任何形式使用(包括但不限于全部或部分地泄露、复制或散发)本邮件及其附件中的信息。如果您错收本邮件,请您立即电话或邮件通知发件人并删除本邮件。 
This email and its attachments contain confidential information from Loongson Technology , which is intended only for the person or entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this email in error, please notify the sender by phone or email immediately and delete it. 

  parent reply	other threads:[~2023-06-08 11:45 UTC|newest]

Thread overview: 73+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-30  1:51 [PATCH v12 00/31] Add KVM LoongArch support Tianrui Zhao
2023-05-30  1:51 ` [PATCH v12 01/31] LoongArch: KVM: Add kvm related header files Tianrui Zhao
2023-06-05  5:00   ` Huacai Chen
2023-06-05 10:18     ` Paolo Bonzini
2023-06-05 12:22   ` bibo, mao
2023-06-06  6:30   ` Youling Tang
2023-06-06 10:00     ` Tianrui Zhao
2023-05-30  1:51 ` [PATCH v12 02/31] LoongArch: KVM: Implement kvm module related interface Tianrui Zhao
2023-06-05 12:27   ` bibo, mao
2023-05-30  1:51 ` [PATCH v12 03/31] LoongArch: KVM: Implement kvm hardware enable, disable interface Tianrui Zhao
2023-05-30  1:51 ` [PATCH v12 04/31] LoongArch: KVM: Implement VM related functions Tianrui Zhao
2023-06-05 12:31   ` bibo, mao
2023-05-30  1:51 ` [PATCH v12 05/31] LoongArch: KVM: Add vcpu related header files Tianrui Zhao
2023-06-05 12:42   ` bibo, mao
2023-06-06  2:00     ` Tianrui Zhao
2023-05-30  1:51 ` [PATCH v12 06/31] LoongArch: KVM: Implement vcpu create and destroy interface Tianrui Zhao
2023-06-05 12:44   ` bibo, mao
2023-05-30  1:51 ` [PATCH v12 07/31] LoongArch: KVM: Implement vcpu run interface Tianrui Zhao
2023-06-05 12:53   ` bibo, mao
2023-06-06  2:02     ` Tianrui Zhao
2023-05-30  1:52 ` [PATCH v12 08/31] LoongArch: KVM: Implement vcpu handle exit interface Tianrui Zhao
2023-06-05 13:03   ` bibo, mao
2023-06-06  2:13     ` Tianrui Zhao
2023-05-30  1:52 ` [PATCH v12 09/31] LoongArch: KVM: Implement vcpu get, vcpu set registers Tianrui Zhao
2023-06-05 13:04   ` bibo, mao
2023-06-06  6:41   ` Youling Tang
2023-06-06  9:12     ` Tianrui Zhao
2023-05-30  1:52 ` [PATCH v12 10/31] LoongArch: KVM: Implement vcpu ENABLE_CAP ioctl interface Tianrui Zhao
2023-06-05 13:12   ` bibo, mao
2023-06-06  3:20     ` Tianrui Zhao
2023-05-30  1:52 ` [PATCH v12 11/31] LoongArch: KVM: Implement fpu related operations for vcpu Tianrui Zhao
2023-06-05 13:13   ` bibo, mao
2023-05-30  1:52 ` [PATCH v12 12/31] LoongArch: KVM: Implement vcpu interrupt operations Tianrui Zhao
2023-06-05 13:13   ` bibo, mao
2023-06-06  6:49   ` Youling Tang
2023-06-06  9:13     ` Tianrui Zhao
2023-05-30  1:52 ` [PATCH v12 13/31] LoongArch: KVM: Implement misc vcpu related interfaces Tianrui Zhao
2023-05-30  1:52 ` [PATCH v12 14/31] LoongArch: KVM: Implement vcpu load and vcpu put operations Tianrui Zhao
2023-05-30  1:52 ` [PATCH v12 15/31] LoongArch: KVM: Implement vcpu status description Tianrui Zhao
2023-06-05 13:04   ` bibo, mao
2023-05-30  1:52 ` [PATCH v12 16/31] LoongArch: KVM: Implement update VM id function Tianrui Zhao
2023-06-06  1:13   ` bibo, mao
2023-05-30  1:52 ` [PATCH v12 17/31] LoongArch: KVM: Implement virtual machine tlb operations Tianrui Zhao
2023-06-06  1:20   ` bibo, mao
2023-05-30  1:52 ` [PATCH v12 18/31] LoongArch: KVM: Implement vcpu timer operations Tianrui Zhao
2023-05-30  1:52 ` [PATCH v12 19/31] LoongArch: KVM: Implement kvm mmu operations Tianrui Zhao
2023-06-06  1:28   ` bibo, mao
2023-06-06  2:51     ` Tianrui Zhao
2023-05-30  1:52 ` [PATCH v12 20/31] LoongArch: KVM: Implement handle csr excption Tianrui Zhao
2023-06-06  1:35   ` bibo, mao
2023-06-06  2:59     ` Tianrui Zhao
2023-05-30  1:52 ` [PATCH v12 21/31] LoongArch: KVM: Implement handle iocsr exception Tianrui Zhao
2023-06-06  1:36   ` bibo, mao
2023-05-30  1:52 ` [PATCH v12 22/31] LoongArch: KVM: Implement handle idle exception Tianrui Zhao
2023-06-06  1:36   ` bibo, mao
2023-05-30  1:52 ` [PATCH v12 23/31] LoongArch: KVM: Implement handle gspr exception Tianrui Zhao
2023-06-06  1:38   ` bibo, mao
2023-05-30  1:52 ` [PATCH v12 24/31] LoongArch: KVM: Implement handle mmio exception Tianrui Zhao
2023-06-06  1:41   ` bibo, mao
2023-05-30  1:52 ` [PATCH v12 25/31] LoongArch: KVM: Implement handle fpu exception Tianrui Zhao
2023-06-06  1:42   ` bibo, mao
2023-05-30  1:52 ` [PATCH v12 26/31] LoongArch: KVM: Implement kvm exception vector Tianrui Zhao
2023-06-06  1:43   ` bibo, mao
2023-06-06  7:00   ` Youling Tang
2023-06-06  9:16     ` Tianrui Zhao
2023-06-08 11:44     ` 赵天瑞 [this message]
2023-05-30  1:52 ` [PATCH v12 27/31] LoongArch: KVM: Implement vcpu world switch Tianrui Zhao
2023-06-06  2:27   ` bibo, mao
2023-05-30  1:52 ` [PATCH v12 28/31] LoongArch: KVM: Implement probe virtualization when LoongArch cpu init Tianrui Zhao
2023-05-30  1:52 ` [PATCH v12 29/31] LoongArch: KVM: Enable kvm config and add the makefile Tianrui Zhao
2023-06-06  2:37   ` bibo, mao
2023-05-30  1:52 ` [PATCH v12 30/31] LoongArch: KVM: Supplement kvm document about LoongArch-specific part Tianrui Zhao
2023-05-30  1:52 ` [PATCH v12 31/31] LoongArch: KVM: Add maintainers for LoongArch KVM Tianrui Zhao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=592bfebe.ac52.1889ad2b799.Coremail.zhaotianrui@loongson.cn \
    --to=zhaotianrui@loongson.cn \
    --cc=alexander.deucher@amd.com \
    --cc=axboe@kernel.dk \
    --cc=broonie@kernel.org \
    --cc=chenhuacai@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel@xen0n.name \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=loongarch@lists.linux.dev \
    --cc=maobibo@loongson.cn \
    --cc=oliver.upton@linux.dev \
    --cc=pbonzini@redhat.com \
    --cc=tangyouling@loongson.cn \
    --cc=xry111@xry111.site \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.