From: Hans-Jörg Höxer Subject: Re: [EXT] Re: SEV-ES guest: early GHCB allocation and early #VC trap handling 1/3 To: Date: Tue, 1 Jul 2025 10:27:11 +0200 Hi Mike, thanks again for your review and feedback! Answers inline below. > ... > > @@ -297,6 +301,52 @@ kpageflttrap(struct trapframe *frame, uint64_t cr2) > > return 1; > > } > > > > +int > > +vctrap(struct trapframe *frame) > > +{ > > + uint64_t sw_exitcode, sw_exitinfo1, sw_exitinfo2; > > + struct ghcb_sync syncout, syncin; > > + struct ghcb_sa *ghcb; > > + > > + intr_disable(); > > + > > + memset(&syncout, 0, sizeof(syncout)); > > + memset(&syncin, 0, sizeof(syncin)); > > + > > + sw_exitcode = frame->tf_err; > > + sw_exitinfo1 = 0; > > + sw_exitinfo2 = 0; > > + > > + switch (sw_exitcode) { > > + default: > > + panic("invalid exit code 0x%llx", sw_exitcode); > > + } > > I was scratching my head on this until tb@ pointed out that this is filled out > in a later diff. What are your thoughts around combining the diffs together > so that if we need to revert diff #3 later for some reason, we aren't left with > a halfway working vctrap()? Eg, "all or nothing"? I'll defer to you and bluhm@. good point, sorry for the confusion. > ... > > diff --git a/sys/arch/amd64/include/cpufunc.h b/sys/arch/amd64/include/cpufunc.h > > index e4c8d6924d2..9f01b3cb989 100644 > > --- a/sys/arch/amd64/include/cpufunc.h > > +++ b/sys/arch/amd64/include/cpufunc.h > > @@ -439,6 +439,13 @@ breakpoint(void) > > __asm volatile("int $3"); > > } > > > > +/* VMGEXIT */ > > +static __inline void > > +vmgexit(void) > > +{ > > + __asm volatile("rep; vmmcall"); > > > A comment here about the conversation we had the other day would be useful for > posterity: > > /* rep; vmmcall encodes the vmgexit instruction */ ack! bluhm@ already added that comment, thanks! > ...