Skip to contentSkip to conversation

inconsistent pfn type checking in process_page_data

DISCUSSION Olaf Hering 2 participants 5 messages Oct 27, 2020 – Oct 28, 2020

lore
Share & tools
lore
#0 lore raw

Andrew,

with commit 93c2ff78adcadbe0f8bda57eeb30b1414c966324 a new function process_page_data was added. While filling the mfns array for xenforeignmemory_map, the individual pfn types[] are checked in a different way than the checking of the result of the mapping attempt.

Is there a special reason why the first loop uses the various TAB values, and the other loop checks XTAB/BROKEN/XALLOC? The sending side also uses the latter.

Olaf

#1 lore raw
Quoted 5 lines · Olaf Hering

Andrew,

with commit 93c2ff78adcadbe0f8bda57eeb30b1414c966324 a new function process_page_data was added. While filling the mfns array for xenforeignmemory_map, the individual pfn types[] are checked in a different way than the checking of the result of the mapping attempt.

Is there a special reason why the first loop uses the various TAB values, and the other loop checks XTAB/BROKEN/XALLOC? The sending side also uses the latter.

Hmm.  (Wow that's more than 5 years old now)

IIRC, that particular piece of logic took an age to get correct.  Its quite possible it ended up being a merge of code which David and I wrote at slightly different times.

Fundamentally, there are 4 bits of page type which encode NOTAB (writeable), L{1..4}, Pinned L{1..4}, XTAB (invalid), XALLOC (allocate-only - still not sure what the purpose is.  There is no producer of this type that I'm aware of) and BROKEN.

By my count, that is 12 legal types, so asymmetric type=>"is there data" conversions is probably a bad thing.

I suspect we probably want an is_known_page_type() predicate on the source side to sanity check data from Xen, and on the destination side in handle_page_data() to sanity check data in the stream, and we probably want a page_type_has_data() predicate to use in write_batch()/process_page_data() to ensure that the handling is consistent.

Do you fancy doing a patch?  If not I can put this on my TODO list, but no ETA on when I'd get to it.

~Andrew

#2 lore raw

Am Tue, 27 Oct 2020 23:18:47 +0000
schrieb Andrew Cooper <[email protected]>:

Quoted 5 lines

I suspect we probably want an is_known_page_type() predicate on the source side to sanity check data from Xen, and on the destination side in handle_page_data() to sanity check data in the stream, and we probably want a page_type_has_data() predicate to use in write_batch()/process_page_data() to ensure that the handling is consistent.

From what I have seen, two (or three) helpers for sender and receiver will be needed:
is_known_page_type()
is_data_page_type()
maybe is_ptbl_page_type() for normalise/localise.

I will prepare a batch of changes in the coming days.

Olaf

#3 lore raw
Quoted 8 lines · Olaf Hering

Am Tue, 27 Oct 2020 23:18:47 +0000
schrieb Andrew Cooper <[email protected]>:

Quoted 5 lines

I suspect we probably want an is_known_page_type() predicate on the source side to sanity check data from Xen, and on the destination side in handle_page_data() to sanity check data in the stream, and we probably want a page_type_has_data() predicate to use in write_batch()/process_page_data() to ensure that the handling is consistent.

Quoted 4 lines

From what I have seen, two (or three) helpers for sender and receiver will be needed:
is_known_page_type()
is_data_page_type()
maybe is_ptbl_page_type() for normalise/localise.

Ah yes.  That too.

I would however recommend against the name is_data_page_type() because then the predicate is ambiguous with "== NOTAB".

page_type_has_stream_data()?  Its a bit of a mouthful, but the purpose is very clear.

~Andrew

#4 lore raw

Am Wed, 28 Oct 2020 10:39:55 +0000
schrieb Andrew Cooper <[email protected]>:

Quoted 2 lines

I would however recommend against the name is_data_page_type() because then the predicate is ambiguous with "== NOTAB".

Why is it ambiguous? It is not obvious to me.

page_type_has_stream_data() is certainly fine as a name.

Olaf