Re: [PATCH v2] KVM: SVM: Convert plain error code numbers to defines

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Dec 03, 2024, Melody (Huibo) Wang wrote:
> Hi Sean,
> 
> On 12/2/2024 4:11 PM, Sean Christopherson wrote:
> 
> > 
> > E.g. something like this?  Definitely feel free to suggest better names.
> > 
> > static inline void svm_vmgexit_set_return_code(struct vcpu_svm *svm,
> > 					       u64 response, u64 data)
> > {
> > 	ghcb_set_sw_exit_info_1(svm->sev_es.ghcb, response);
> > 	ghcb_set_sw_exit_info_2(svm->sev_es.ghcb, data);
> > }
> > 
> If I make this function more generic where the exit info is set for both KVM
> and the guest, then maybe I can write something like this:

I like the idea, but I actually think it's better to keep the guest and host code
separate in the case, because the guest code should actually set a triple, e.g.

static __always_inline void sev_es_vmgexit_set_exit_info(struct ghcb *ghcb,
							 u64 exit_code,
							 u64 exit_info_1,
							 u64 exit_info_2)
{
	ghcb_set_sw_exit_code(ghcb, exit_code);
	ghcb_set_sw_exit_info_1(ghcb, exit_info_1);
	ghcb_set_sw_exit_info_2(ghcb, exit_info_2);
}

I'm not totally opposed to sharing code, but I think it will be counter-productive
in this specific case.  E.g. the guest version needs to be __always_inline so that
it can be used in noinstr code.

> void ghcb_set_exit_info(struct ghcb *ghcb,
>                       u64 info1, u64 info2)
> {
> 	ghcb_set_sw_exit_info_1(ghcb, info1);
> 	ghcb_set_sw_exit_info_2(ghcb, info2);
> 
> }
> This way we can address every possible case that sets the exit info - not only KVM. 
> 
> And I am not sure about the wrappers for each specific case because we will
> have too many, too specific small functions, but if you want them I can add
> them.

I count three.  We have far, far more wrappers VMX's is_exception_n(), and IMO
those wrappers make the code significantly more readable.




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux