On Mon, Apr 12, 2021 at 07:55:01AM -0500, Brijesh Singh wrote: > The cur_entry is updated by the hypervisor. While building the psc > buffer the guest sets the cur_entry=0 and the end_entry point to the > last valid entry. The cur_entry is incremented by the hypervisor after > it successfully processes one 4K page. As per the spec, the hypervisor > could get interrupted in middle of the page state change and cur_entry > allows the guest to resume the page state change from the point where it > was interrupted. This is non-obvious and belongs in a comment above it. Otherwise it looks weird. > Since we can get interrupted while executing the PSC so just to be safe > I re-initialized the scratch scratch area with our buffer instead of > relying on old values. Ditto. > As per the spec the caller must check that the cur_entry > end_entry to > determine whether all the entries are processed. If not then retry the > state change. The hypervisor will skip the previously processed entries. > The snp_page_state_vmgexit() is implemented to return only after all the > entries are changed. Ditto. This whole mechanism of what the guest does and what the HV does, needs to be explained in a bigger comment somewhere around there so that it is clear what's going on. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette